def set_listWidget(self):
# Sets the default values if the fume is closed without any elements in listWidget
# Important: These values are preset and defined in .ui file
defaults = ['Noch keine Mannschaften hinzugefügt...', 'Region wählen und unten auf "+" klicken']
elements = self.settings.value('filter', defaults)
if elements != defaults and len(elements) != 0:
self.listWidget.clear()
for i in elements:
item = QtWidgets.QListWidgetItem()
item.setText(i[0])
item.setData(QtCore.Qt.UserRole, i[1])
self.listWidget.addItem(item)
# Loading selected items
for i in self.settings.value('filter_calendar', []):
for j in self.listWidget.findItems(i, QtCore.Qt.MatchExactly):
j.setSelected(True)
self.itemSelection_changed()
self.current_selection = [x for x in self.listWidget.selectedItems()] # for restoring selection
评论列表
文章目录