def populate(self): """Puts the deleted/changed snippets in the tree.""" self.deletedItem.takeChildren() self.deletedItem.setExpanded(True) self.deletedItem.setCheckState(0, Qt.Unchecked) self.changedItem.takeChildren() self.changedItem.setExpanded(True) self.changedItem.setCheckState(0, Qt.Unchecked) builtins = list(builtin.builtin_snippets) builtins.sort(key = snippets.title) names = frozenset(snippets.names()) for name in builtins: if name in names: if snippets.isoriginal(name): continue parent = self.changedItem else: parent = self.deletedItem item = QTreeWidgetItem(parent) item.name = name item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) item.setCheckState(0, Qt.Unchecked) item.setText(0, snippets.title(name)) self.deletedItem.setDisabled(self.deletedItem.childCount() == 0) self.changedItem.setDisabled(self.changedItem.childCount() == 0) self.checkOkButton()
def populate(self): self.tree.connect(self.tree, SIGNAL("itemClicked(QTreeWidgetItem *, int)"), self.clicked) self.tree.connect(self.tree, SIGNAL("itemPressed(QTreeWidgetItem *, int)"), self.clicked) for mimetype, mimecontent in self.mm.mimetypes.iteritems(): mimetypeItem = QTreeWidgetItem(self.tree, [mimetype]) mimetypeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) mimetypeItem.setCheckState(0, Qt.Unchecked) rCheckBox = RootCheckBox() rCheckBox.setEnabled(False) self.tree.setItemWidget(mimetypeItem, 1, rCheckBox) self.typeItems.append(mimetypeItem) for value in mimecontent: filetypeItem = QTreeWidgetItem(mimetypeItem, [value]) filetypeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) filetypeItem.setCheckState(0, Qt.Unchecked) checkBox = QCheckBox() checkBox.setEnabled(False) rCheckBox.addChild(checkBox) rCheckBox.connect(checkBox, SIGNAL("stateChanged(int)"), rCheckBox.update) self.tree.setItemWidget(filetypeItem, 1, checkBox) self.tree.resizeColumnToContents(0)
def __init__(self): super(ShortcutSection, self).__init__() container = QVBoxLayout(self) self.tree = QTreeWidget() self.tree.setHeaderLabels([self.tr("Keys"), self.tr("Description")]) self.tree.header().setStretchLastSection(True) self.tree.setColumnWidth(0, 200) container.addWidget(self.tree) self.items = { "new": "Create a new editor to work in a file", "new-project": "Create a new project", "open": "Open one or more files", "open-project": "Opens an existing project Edis", "reload": "Reload file", "save": "Save file" } for i, e in list(self.items.items()): item = QTreeWidgetItem(self.tree, [keymap.get_keymap(i).toString(), e]) item.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled) self.tree.itemDoubleClicked.connect(self._change_shortcut) # Install EnvironmentConfiguration.install_widget(self.tr("Shortcuts"), self)
def setAnnotations(self, gds): self._annotationsUpdating = True self.annotationsTree.clear() annotations = defaultdict(set) subsetscount = {} for desc in gds["subsets"]: annotations[desc["type"]].add(desc["description"]) subsetscount[desc["description"]] = str(len(desc["sample_id"])) for type, subsets in annotations.items(): key = (gds["dataset_id"], type) subsetItem = QTreeWidgetItem(self.annotationsTree, [type]) subsetItem.setFlags(subsetItem.flags() | Qt.ItemIsUserCheckable | Qt.ItemIsTristate) subsetItem.setCheckState( 0, self.gdsSelectionStates.get(key, Qt.Checked)) subsetItem.key = key for subset in subsets: key = (gds["dataset_id"], type, subset) item = QTreeWidgetItem( subsetItem, [subset, subsetscount.get(subset, "")]) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState( 0, self.gdsSelectionStates.get(key, Qt.Checked)) item.key = key self._annotationsUpdating = False self.annotationsTree.expandAll() for i in range(self.annotationsTree.columnCount()): self.annotationsTree.resizeColumnToContents(i)
def createActionItem(self, key): """ Creates a new action item for the inputed key. :param key | <str> :return <QTreeWidgetItem> """ action = self._actions.get(key) if (not action): text = 'Missing Action: %s' % key item = QTreeWidgetItem([text]) ico = projexui.resources.find('img/log/warning.png') item.setIcon(0, QIcon(ico)) else: item = QTreeWidgetItem([str(action.text()).replace('&', '')]) item.setIcon(0, action.icon()) item.setSizeHint(0, QSize(120, 20)) item.setData(0, Qt.UserRole, qt.wrapVariant(key)) flags = item.flags() flags ^= Qt.ItemIsDropEnabled item.setFlags(flags) return item
def _populate_datasets_tree(self): """ Initialize the tree widget of datasets and volumes. """ self._data_treewidget.clear() if self._repos_info is None: return for dset_uuid, dset_info in sorted(self._repos_info.items()): dset_item = QTreeWidgetItem( self._data_treewidget, QStringList( dset_uuid ) ) dset_item.setData( 0, Qt.UserRole, (dset_uuid, "") ) for data_name in dset_info["DataInstances"].keys(): data_item = QTreeWidgetItem( dset_item, QStringList( data_name ) ) data_item.setData( 0, Qt.UserRole, (dset_uuid, data_name) ) if self._mode == 'specify_new': # If we're in specify_new mode, only the dataset parent items are selectable. flags = data_item.flags() flags &= ~Qt.ItemIsSelectable flags &= ~Qt.ItemIsEnabled data_item.setFlags( flags ) # Expand everything self._data_treewidget.expandAll() # Select the first item by default. if self._mode == "select_existing": first_item = self._data_treewidget.topLevelItem(0).child(0) else: first_item = self._data_treewidget.topLevelItem(0) self._data_treewidget.setCurrentItem( first_item, 0 )
def add_server_tree_item(self, label, parent=None, is_leaf=False): item = QTreeWidgetItem(parent) item.setText(0, unicode(label)) if is_leaf: item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable) self.server_tree.addTopLevelItem(item) return item
def setAnnotations(self, gds): self._annotationsUpdating = True self.annotationsTree.clear() annotations = defaultdict(set) subsetscount = {} for desc in gds["subsets"]: annotations[desc["type"]].add(desc["description"]) subsetscount[desc["description"]] = str(len(desc["sample_id"])) for type, subsets in annotations.items(): key = (gds["dataset_id"], type) subsetItem = QTreeWidgetItem(self.annotationsTree, [type]) subsetItem.setFlags(subsetItem.flags() | Qt.ItemIsUserCheckable | Qt.ItemIsTristate) subsetItem.setCheckState( 0, self.gdsSelectionStates.get(key, Qt.Checked) ) subsetItem.key = key for subset in subsets: key = (gds["dataset_id"], type, subset) item = QTreeWidgetItem( subsetItem, [subset, subsetscount.get(subset, "")] ) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState( 0, self.gdsSelectionStates.get(key, Qt.Checked) ) item.key = key self._annotationsUpdating = False self.annotationsTree.expandAll() for i in range(self.annotationsTree.columnCount()): self.annotationsTree.resizeColumnToContents(i)
def __init__(self, featureDict, selectedFeatures=None, parent=None): QDialog.__init__(self, parent) self.featureDict = featureDict if selectedFeatures is None or len(selectedFeatures) == 0: selectedFeatures = defaultdict(list) self.selectedFeatures = selectedFeatures self.setWindowTitle("Object Features") ui_class, widget_class = uic.loadUiType(os.path.split(__file__)[0] + "/featureSelection.ui") self.ui = ui_class() self.ui.setupUi(self) self.ui.buttonBox.accepted.connect(self.accept) self.ui.buttonBox.rejected.connect(self.reject) self.ui.allButton.pressed.connect(self.handleAll) self.ui.noneButton.pressed.connect(self.handleNone) self.ui.treeWidget.setColumnCount(1) for pluginName, features in featureDict.iteritems(): parent = QTreeWidgetItem(self.ui.treeWidget) parent.setText(0, pluginName) parent.setExpanded(True) for name in sorted(features): item = QTreeWidgetItem(parent) item.setText(0, name) item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) if pluginName in self.selectedFeatures: if name in self.selectedFeatures[pluginName]: item.setCheckState(0, Qt.Checked) else: item.setCheckState(0, Qt.Unchecked)
def generate_tree_model(self, data_dict): """Generate a tree model for specified dictionary :param data_dict: A dictionary :type data_dict: dict :return: list of QTreeWidgetItem :rtype list: """ widget_items = [] font = QFont() font.setBold(True) for key in data_dict.keys(): entry = data_dict[key] key_item = QTreeWidgetItem() key_item.setText(0, str(key)) key_item.setFont(0, font) if isinstance(entry, dict): items = self.generate_tree_model(entry) key_item.addChildren(items) else: # value_item = QTreeWidgetItem() key_item.setText(1, str(entry)) key_item.setFlags(key_item.flags() | Qt.ItemIsEditable) # key_item.addChild(key_item) widget_items.append(key_item) return widget_items
def __add_themen(self): self.ui.TREE_THEMEN.headerItem().setText(0, '') #TODO: resize column to contents #all of these don't work?? self.ui.TREE_THEMEN.header().resizeSection(0, 250) self.ui.TREE_THEMEN.header().setResizeMode( QHeaderView.ResizeToContents) self.ui.TREE_THEMEN.header().setStretchLastSection(True) themen = self.json_settings.themen() for thema_name, thema in themen.iteritems(): tree_thema = QTreeWidgetItem(self.ui.TREE_THEMEN) tree_thema.setText(0, thema_name) tree_thema.setData(0, Qt.UserRole, thema) tree_thema.setFlags(tree_thema.flags() | Qt.ItemIsUserCheckable) if thema_name == 'DKM': tree_thema.setCheckState(0, Qt.Checked) else: tree_thema.setCheckState(0, Qt.Unchecked) if not thema.subthemen is None: for subthema in thema.subthemen: if VRP_DEBUG is True: QgsMessageLog.logMessage( u'Subthema: {0}'.format(subthema.name), DLG_CAPTION) tree_subthema = QTreeWidgetItem() tree_subthema.setText(0, subthema.name) tree_subthema.setData(0, Qt.UserRole, subthema) tree_subthema.setFlags(tree_subthema.flags() | Qt.ItemIsUserCheckable) tree_subthema.setCheckState(0, Qt.Unchecked) tree_thema.addChild(tree_subthema)
def loadPagesList(self, checkable=False): self.clear() for section in self.user_settings['pagesindex'].sections: root = QTreeWidgetItem([section.title]) root.setData(0, Qt.UserRole, QVariant(QString(section.name))) root.setData(0, Qt.DecorationRole, QVariant(QIcon(section.icon))) self.addTopLevelItem(root) for page_id, page in section.pages: if not page: page = self.getPage(page_id) if page.title: page_title = page.title else: page_title = tr('(No name)') item = QTreeWidgetItem([page_title]) item.setData(0, Qt.UserRole ,QVariant(QString(page_id))) if checkable: item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(0, Qt.Unchecked) root.addChild(item) if page == self.window.current_page: f = QFont() f.setWeight(QFont.Bold) item.setData(0, Qt.FontRole, QVariant(f)) self.setCurrentItem(item) self.expandAll()
def __add_themen(self): self.ui.TREE_THEMEN.headerItem().setText(0, '') #TODO: resize column to contents #all of these don't work?? self.ui.TREE_THEMEN.header().resizeSection(0, 250) self.ui.TREE_THEMEN.header().setResizeMode(QHeaderView.ResizeToContents); self.ui.TREE_THEMEN.header().setStretchLastSection(True); themen = self.json_settings.themen() for thema_name, thema in themen.iteritems(): tree_thema = QTreeWidgetItem(self.ui.TREE_THEMEN) tree_thema.setText(0, thema_name) tree_thema.setData(0, Qt.UserRole, thema) tree_thema.setFlags(tree_thema.flags() | Qt.ItemIsUserCheckable) if thema_name == 'DKM': tree_thema.setCheckState(0, Qt.Checked) else: tree_thema.setCheckState(0, Qt.Unchecked) if not thema.subthemen is None: for subthema in thema.subthemen: if VRP_DEBUG is True: QgsMessageLog.logMessage(u'Subthema: {0}'.format(subthema.name), DLG_CAPTION) tree_subthema = QTreeWidgetItem() tree_subthema.setText(0, subthema.name) tree_subthema.setData(0, Qt.UserRole, subthema) tree_subthema.setFlags(tree_subthema.flags() | Qt.ItemIsUserCheckable) tree_subthema.setCheckState(0, Qt.Unchecked) tree_thema.addChild(tree_subthema)
def OpenProjectFromFile(self, name): self.demands = {} self.project = Project() #try: self.project.Load(name) #except : # TODO: proper exceptioning # QMessageBox.critical(self, self.tr("An error occured"), self.tr("File is not a valid project file: ") + name) # return self.projectFile = name self.resourcesGraphEditor.setData(self.project.resources) self.ui.demands.clear() for d in self.project.demands: it = QTreeWidgetItem(self.ui.demands, QStringList([d.id, str(d.startTime), str(d.endTime), self.tr("No") if d.critical else self.tr("Yes"), self.tr("Yes") if d.assigned else self.tr("No")])) cb = QComboBox() cb.addItems([self.tr("No"),self.tr("Yes")]) cb.setCurrentIndex(0 if d.critical else 1) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged) self.ui.demands.setItemWidget(it,3,cb) it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.demands[it] = d self.UpdateRecentFiles() self.setWindowTitle(self.project.name + " - " + self.basename) self.ui.projectname.setText(self.project.name) self.showStats() self.backupTimer.start() self.autosaveTimer.start()
def _populate_datasets_tree(self): """ Initialize the tree widget of datasets and volumes. """ self._data_treewidget.clear() if self._repos_info is None: return for dset_uuid, dset_info in sorted(self._repos_info.items()): dset_item = QTreeWidgetItem(self._data_treewidget, QStringList(dset_uuid)) dset_item.setData(0, Qt.UserRole, (dset_uuid, "")) for data_name in dset_info["DataInstances"].keys(): data_item = QTreeWidgetItem(dset_item, QStringList(data_name)) data_item.setData(0, Qt.UserRole, (dset_uuid, data_name)) if self._mode == 'specify_new': # If we're in specify_new mode, only the dataset parent items are selectable. flags = data_item.flags() flags &= ~Qt.ItemIsSelectable flags &= ~Qt.ItemIsEnabled data_item.setFlags(flags) # Expand everything self._data_treewidget.expandAll() # Select the first item by default. if self._mode == "select_existing": first_item = self._data_treewidget.topLevelItem(0).child(0) else: first_item = self._data_treewidget.topLevelItem(0) self._data_treewidget.setCurrentItem(first_item, 0)
def populate(self): """Puts the deleted/changed snippets in the tree.""" self.deletedItem.takeChildren() self.deletedItem.setExpanded(True) self.deletedItem.setCheckState(0, Qt.Unchecked) self.changedItem.takeChildren() self.changedItem.setExpanded(True) self.changedItem.setCheckState(0, Qt.Unchecked) builtins = list(builtin.builtin_snippets) builtins.sort(key=snippets.title) names = frozenset(snippets.names()) for name in builtins: if name in names: if snippets.isoriginal(name): continue parent = self.changedItem else: parent = self.deletedItem item = QTreeWidgetItem(parent) item.name = name item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) item.setCheckState(0, Qt.Unchecked) item.setText(0, snippets.title(name)) self.deletedItem.setDisabled(self.deletedItem.childCount() == 0) self.changedItem.setDisabled(self.changedItem.childCount() == 0) self.checkOkButton()
def _populate_repo_tree(self): """ Initialize the tree widget of repos and volumes. """ self._repo_treewidget.clear() if self._repos_info is None: return for repo_uuid, repo_info in sorted(self._repos_info.items()): if repo_info is None: continue repo_column_dict = collections.defaultdict(str) repo_column_dict["Alias"] = repo_info["Alias"] repo_column_dict["Details"] = "Created: " + repo_info["Created"] repo_column_dict["UUID"] = repo_uuid repo_column_values = [repo_column_dict[k] for k in TREEVIEW_COLUMNS] repo_item = QTreeWidgetItem( self._repo_treewidget, QStringList( repo_column_values ) ) repo_item.setData( 0, Qt.UserRole, (repo_uuid, "", "") ) for data_name, data_info in repo_info["DataInstances"].items(): data_instance_dict = collections.defaultdict(str) data_instance_dict["Alias"] = data_name typename = data_info["Base"]["TypeName"] data_instance_dict["TypeName"] = typename is_voxels = (typename in VOXEL_TYPENAMES) if is_voxels: start_coord = data_info["Extended"]["MinPoint"] if start_coord: start_coord = tuple(start_coord) stop_coord = data_info["Extended"]["MaxPoint"] if stop_coord: stop_coord = tuple(x+1 for x in stop_coord) if start_coord and stop_coord: shape = tuple(b - a for a,b in zip(start_coord, stop_coord)) else: shape = None data_instance_dict["Details"] = "Size={} | Start={} | Stop={}".format( shape, start_coord, stop_coord ) data_column_values = [data_instance_dict[k] for k in TREEVIEW_COLUMNS] data_item = QTreeWidgetItem( repo_item, data_column_values ) data_item.setData( 0, Qt.UserRole, (repo_uuid, data_name, typename) ) # If we're in specify_new mode, only the # repo parent items are selectable. # Also, non-volume items aren't selectable. if self._mode == 'specify_new' or typename not in self._selectable_types: flags = data_item.flags() flags &= ~Qt.ItemIsSelectable flags &= ~Qt.ItemIsEnabled data_item.setFlags( flags ) self._repo_treewidget.collapseAll() self._repo_treewidget.setSortingEnabled(True) if self._hostname in self._default_nodes: self._select_node_uuid(self._default_nodes[self._hostname]) self._repo_treewidget.resizeColumnToContents(0) self._repo_treewidget.setFocus()
def _loadCardGroup( self, groupName, records, parent = None ): if ( not groupName ): groupName = 'None' cards = self.cardWidget() factory = self.factory() # create the group item group_item = QTreeWidgetItem(parent, [groupName]) font = group_item.font(0) font.setBold(True) font.setPointSize(font.pointSize() + 2) group_item.setFont(0, font) group_item.setFlags(Qt.ItemIsEnabled) # load sub-groups if ( type(records) == dict ): for subgroup, records in sorted(records.items()): self._loadCardGroup(subgroup, records, group_item) else: for record in records: widget = factory.createCard(cards, record) if ( not widget ): continue widget.adjustSize() # create the card item item = QTreeWidgetItem(group_item) item.setSizeHint(0, QSize(0, widget.height())) cards.setItemWidget(item, 0, widget) group_item.setExpanded(True)
def RandomDemand(self): d = self.randomDialog types = [] for v in self.project.resources.vertices: if isinstance(v, Storage) and (types.count(v.type) == 0): types.append(v.type) if len(types) == 1: #only type 0 d.ui.cc1.setEnabled(False) d.ui.cc2.setEnabled(False) d.exec_() if d.result() == QDialog.Accepted: dict = d.GetResult() dict["types"] = types for i in range(dict["n"]): demand = self.project.CreateRandomDemand(dict) it = QTreeWidgetItem( self.ui.demands, QStringList([ demand.id, str(demand.startTime), str(demand.endTime), self.tr("No"), self.tr("No") ])) cb = QComboBox() cb.addItems([self.tr("No"), self.tr("Yes")]) self.ui.demands.setItemWidget(it, 3, cb) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged) it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.demands[it] = demand
def GenerateRequests(self): generator = self.generators[self.sender()] data = generator.GetSettings() d = ParamsDialog(data, self, generator.GetName() == "Tightly coupled", generator.GetName() == "Tightly coupled") d.exec_() if d.result() == QDialog.Accepted: generator.UpdateSettings(d.data) #TODO: populate the table with new demands self.project.demands = generator.Generate(self.project.resources) self.ui.demands.clear() self.demands = {} for demand in self.project.demands: it = QTreeWidgetItem( self.ui.demands, QStringList([ demand.id, str(demand.startTime), str(demand.endTime), self.tr("No"), self.tr("No") ])) cb = QComboBox() cb.addItems([self.tr("No"), self.tr("Yes")]) self.ui.demands.setItemWidget(it, 3, cb) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged) it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.demands[it] = demand
def _add_symbol_to_tree_widget(self, symbol): """ Add the given symbol to the tree widget. If this is a new category create it, otherwise append it to the already existing one. """ # find category category = symbol["category"] categoryItems = self.availableSymbolsWidget.findItems(category, Qt.MatchExactly, 0) name = symbol["name"] symbolItem = QTreeWidgetItem([name]) symbolItem.setData(0, Qt.UserRole, name) symbolItem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) if categoryItems: categoryItems[0].addChild(symbolItem) else: categoryItem = QTreeWidgetItem(self.availableSymbolsWidget, [category]) categoryItem.setFlags(Qt.ItemIsEnabled) categoryItem.addChild(symbolItem) self.availableSymbolsWidget.resizeColumnToContents(0) self.availableSymbolsWidget.sortItems(0, Qt.AscendingOrder) self.availableSymbolsWidget.setCurrentItem(symbolItem)
class QNGWItem(QTreeWidgetItem): def __init__(self): QTreeWidgetItem.__init__(self) self.locked_item = QTreeWidgetItem(["loading..."]) self.locked_item.setFlags(Qt.NoItemFlags) self.locked_item.setDisabled(True) self.release() def lock(self): self.__isLock = True self.setFlags(Qt.NoItemFlags) self.addChild( self.locked_item ) def is_locked(self): return self.__isLock def release(self): self.__isLock = False self.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.removeChild( self.locked_item ) def ngw_resource_children_count(self): raise NotImplementedError()
def _loadCardGroup(self, groupName, records, parent=None): if (not groupName): groupName = 'None' cards = self.cardWidget() factory = self.factory() # create the group item group_item = QTreeWidgetItem(parent, [groupName]) font = group_item.font(0) font.setBold(True) font.setPointSize(font.pointSize() + 2) group_item.setFont(0, font) group_item.setFlags(Qt.ItemIsEnabled) # load sub-groups if (type(records) == dict): for subgroup, records in sorted(records.items()): self._loadCardGroup(subgroup, records, group_item) else: for record in records: widget = factory.createCard(cards, record) if (not widget): continue widget.adjustSize() # create the card item item = QTreeWidgetItem(group_item) item.setSizeHint(0, QSize(0, widget.height())) cards.setItemWidget(item, 0, widget) group_item.setExpanded(True)
def _add_symbol_to_tree_widget(self, symbol): """ Add the given symbol to the tree widget. If this is a new category create it, otherwise append it to the already existing one. """ # find category category = symbol["category"] categoryItems = self.availableSymbolsWidget.findItems( category, Qt.MatchExactly, 0) name = symbol["name"] symbolItem = QTreeWidgetItem([name]) symbolItem.setData(0, Qt.UserRole, name) symbolItem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) if categoryItems: categoryItems[0].addChild(symbolItem) else: categoryItem = QTreeWidgetItem(self.availableSymbolsWidget, [category]) categoryItem.setFlags(Qt.ItemIsEnabled) categoryItem.addChild(symbolItem) self.availableSymbolsWidget.resizeColumnToContents(0) self.availableSymbolsWidget.sortItems(0, Qt.AscendingOrder) self.availableSymbolsWidget.setCurrentItem(symbolItem)
def createActionItem( self, key ): """ Creates a new action item for the inputed key. :param key | <str> :return <QTreeWidgetItem> """ action = self._actions.get(key) if ( not action ): text = 'Missing Action: %s' % key item = QTreeWidgetItem([text]) ico = projexui.resources.find('img/log/warning.png') item.setIcon(0, QIcon(ico)) else: item = QTreeWidgetItem([str(action.text()).replace('&', '')]) item.setIcon(0, action.icon()) item.setSizeHint(0, QSize(120, 20)) item.setData(0, Qt.UserRole, qt.wrapVariant(key)) flags = item.flags() flags ^= Qt.ItemIsDropEnabled item.setFlags(flags) return item
def _load_shortcuts(self): for action in resources.CUSTOM_SHORTCUTS: shortcut_action = resources.get_shortcut(action) #populate the tree widget tree_data = [self.shortcuts_text[action], shortcut_action.toString(QKeySequence.NativeText), action] item = QTreeWidgetItem(self.result_widget, tree_data) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
def addNode(self, parent, text="", data=""): node = QTreeWidgetItem(parent) node.setText(0, text) node.setCheckState(0, Qt.Unchecked) node.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) node.setData(0, Qt.UserRole, data) return node
def _populate_reporting_tab(self): """Populate trees about layers.""" self.tree.clear() self.add_layer.setEnabled(False) self.remove_layer.setEnabled(False) self.move_up.setEnabled(False) self.move_down.setEnabled(False) self.tree.setColumnCount(1) self.tree.setRootIsDecorated(False) self.tree.setHeaderHidden(True) analysis_branch = QTreeWidgetItem(self.tree.invisibleRootItem(), [FROM_ANALYSIS['name']]) analysis_branch.setFont(0, bold_font) analysis_branch.setExpanded(True) analysis_branch.setFlags(Qt.ItemIsEnabled) if self._multi_exposure_if: expected = self._multi_exposure_if.output_layers_expected() for group, layers in expected.iteritems(): group_branch = QTreeWidgetItem(analysis_branch, [group]) group_branch.setFont(0, bold_font) group_branch.setExpanded(True) group_branch.setFlags(Qt.ItemIsEnabled) for layer in layers: layer = definition(layer) if layer.get('allowed_geometries', None): item = QTreeWidgetItem(group_branch, [layer.get('name')]) item.setData(0, LAYER_ORIGIN_ROLE, FROM_ANALYSIS['key']) item.setData(0, LAYER_PARENT_ANALYSIS_ROLE, group) item.setData(0, LAYER_PURPOSE_KEY_OR_ID_ROLE, layer['key']) item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) canvas_branch = QTreeWidgetItem(self.tree.invisibleRootItem(), [FROM_CANVAS['name']]) canvas_branch.setFont(0, bold_font) canvas_branch.setExpanded(True) canvas_branch.setFlags(Qt.ItemIsEnabled) # List layers from the canvas loaded_layers = QgsMapLayerRegistry.instance().mapLayers().values() canvas_layers = self.iface.mapCanvas().layers() flag = setting('visibleLayersOnlyFlag', expected_type=bool) for loaded_layer in loaded_layers: if flag and loaded_layer not in canvas_layers: continue title = loaded_layer.name() item = QTreeWidgetItem(canvas_branch, [title]) item.setData(0, LAYER_ORIGIN_ROLE, FROM_CANVAS['key']) item.setData(0, LAYER_PURPOSE_KEY_OR_ID_ROLE, loaded_layer.id()) item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.tree.resizeColumnToContents(0)
def setData(self, project): self.project = project self.canvas.Clear() self.ui.info.setText("") self.ui.assignedTenants.clear() for d in self.project.tenants: it = QTreeWidgetItem(self.ui.assignedTenants, [d.name]) it.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.canvas.Visualize(self.project.resources)
def _load_defaults_shortcuts(self): self.result_widget.clear() for name, action in resources.SHORTCUTS.iteritems(): shortcut_action = action #populate the tree widget tree_data = [self.shortcuts_text[name], shortcut_action.toString(QKeySequence.NativeText)] item = QTreeWidgetItem(self.result_widget, tree_data) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
def makeTree(self): self.tree.clear() arr = Valid().pullData('datas', '', {'pubID': self.titleID}) self.hold_data = {} self.hold_mdata = {} self.hold_data_add = {} self.hold_data_add_item = {} if self.titleSub and self.titleSub > 0: if arr and len(arr) > 0: for val in arr: ch = Valid().pullData('datas', '', {'subID': val['id']}) child = QTreeWidgetItem(self.tree) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, str(val['name']).upper()) child.setText(1, str(val['abbrv']).upper()) self.hold_data[val['id']] = child self.hold_mdata[val['id']] = child if (val['active'] == 0): child.setCheckState(0, Qt.Checked) else: child.setCheckState(0, Qt.Unchecked) for va in ch: child1 = QTreeWidgetItem(child) child1.setFlags(child1.flags() | Qt.ItemIsUserCheckable) child1.setText(0, str(va['name']).upper()) child1.setText(1, str(va['abbrv']).upper()) self.hold_data[va['id']] = child1 if (va['active'] == 0): child1.setCheckState(0, Qt.Checked) else: child1.setCheckState(0, Qt.Unchecked) child1 = QTreeWidgetItem(child) child1.setFlags(child1.flags() | Qt.ItemIsUserCheckable) child1.setText(0, 'Add New Item') self.hold_data_add_item[val['id']] = child1 else: if arr and len(arr) > 0: for val in arr: child = QTreeWidgetItem(self.tree) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, str(val['name']).upper()) child.setText(1, str(val['abbrv']).upper()) self.hold_data[val['id']] = child if (val['active'] == 0): child.setCheckState(0, Qt.Checked) else: child.setCheckState(0, Qt.Unchecked) child = QTreeWidgetItem(self.tree) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, 'Add New') self.hold_data_add['addnew'] = child
def treeAddParticle(self): item = QTreeWidgetItem( ("0.0", "0.0", "0.0", "AU", "0.0", "0.0", "0.0", "km/s", "0.0", "MSun", "0.0", "km" )) item.setFlags(item.flags() | Qt.ItemIsEditable) self.ui.particlesTree.addTopLevelItem(item)
def createItem(self, name, description): """ Create a new item. """ item = QTreeWidgetItem(self.treeWidget) item.groupName = name item.setFont(0, QFont("monospace")) item.setText(0, name) item.setText(1, description) item.setText(2, self.manager.shortcutText(name)) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled) return item
def _load_defaults_shortcuts(self): #clean custom shortcuts and UI widget resources.clean_custom_shortcuts() self.result_widget.clear() for name, action in list(resources.SHORTCUTS.items()): shortcut_action = action #populate the tree widget tree_data = [self.shortcuts_text[name], shortcut_action.toString(QKeySequence.NativeText), name] item = QTreeWidgetItem(self.result_widget, tree_data) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
def _load_defaults_shortcuts(self): self.result_widget.clear() for name, action in resources.SHORTCUTS.iteritems(): shortcut_action = action #populate the tree widget tree_data = [ self.tr(name), shortcut_action.toString(QKeySequence.NativeText) ] item = QTreeWidgetItem(self.result_widget, tree_data) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
def _addRequirements(self): for requirement, component, reason, optional in self._requirements: item = QTreeWidgetItem() item.setCheckState(0, Qt.Checked) if not optional: item.setFlags(Qt.ItemFlags(int(item.flags()) & ~Qt.ItemIsEnabled)) item.setText(0, requirement) item.setText(1, reason) item.setText(2, component) item.setData(0, self._REQUIREMENT_ROLE, QVariant(requirement)) self._reqTable.addTopLevelItem(item)
def build_tree_widget_item(parent, name, is_checkable=True): child = QTreeWidgetItem(parent) if is_checkable: child.setFlags(child.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsTristate) child.setCheckState(0, QtCore.Qt.Unchecked) else: child.setFlags(QtCore.Qt.ItemIsEnabled) child.setText(0, name) return child
def fill(self): self.clear() services = self._client.getServices() try: descrs = self._client.getServiceDescriptions(services) except Exception: descrs = {} self._client.startPoller(self.updateStatus) for service, instances in iteritems(services): serviceItem = QTreeWidgetItem([service]) serviceItem.setForeground(1, QBrush(QColor('white'))) serviceItem.setTextAlignment(1, Qt.AlignCenter) serviceItem.setFlags(Qt.ItemIsEnabled) serviceItem.setForeground(3, QBrush(QColor('red'))) self.addTopLevelItem(serviceItem) btns = [] has_empty_instance = None for instance in instances: if not instance: has_empty_instance = True continue instanceItem = QTreeWidgetItem([instance]) instanceItem.setForeground(1, QBrush(QColor('white'))) instanceItem.setTextAlignment(1, Qt.AlignCenter) instanceItem.setFlags(Qt.ItemIsEnabled) instanceItem.setForeground(3, QBrush(QColor('red'))) if descrs.get((service, instance)): instanceItem.setText(0, descrs[service, instance]) serviceItem.addChild(instanceItem) btn = JobButtons(self._client, service, instance, instanceItem) btns.append(btn) self.setItemWidget(instanceItem, 2, btn) self._items[service, instance] = instanceItem if has_empty_instance: btn = JobButtons(self._client, service, '', serviceItem) btn.setMinimumSize(QSize(30, 40)) self.setItemWidget(serviceItem, 2, btn) if descrs.get((service, '')): serviceItem.setText(0, descrs[service, '']) self._items[service, ''] = serviceItem else: # create "virtual" job with buttons that start/stop all # instances of the service self._virt_items[service] = serviceItem multibtn = MultiJobButtons(btns) self.setItemWidget(serviceItem, 2, multibtn) self.expandAll()
def populate(self, items, selected): for item in items: treeItem = QTreeWidgetItem(self.treeWidget) treeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) if item in selected: treeItem.setCheckState(0, Qt.Checked) else: treeItem.setCheckState(0, Qt.Unchecked) treeItem.setText(0, item) self.items.append(treeItem) self.treeWidget.resizeColumnToContents(0)
def add_children(child_nodes, parent): children = [] for node in child_nodes: twitem = QTreeWidgetItem((node['label'], )) twitem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) twitem.setCheckState(0, Qt.Unchecked) twitem.setData(0, Qt.UserRole, node) if 'children' in node: add_children(node['children'], twitem) children.append(twitem) parent.addChildren(children)
def populate_classified_values(self, unassigned_values, assigned_values, default_classes): """Populate lstUniqueValues and treeClasses.from the parameters. :param unassigned_values: List of values that haven't been assigned to a class. It will be put in self.lstUniqueValues. :type unassigned_values: list :param assigned_values: Dictionary with class as the key and list of value as the value of the dictionary. It will be put in self.treeClasses. :type assigned_values: dict :param default_classes: Default classes from unit. :type default_classes: list """ # Populate the unique values list self.lstUniqueValues.clear() self.lstUniqueValues.setSelectionMode( QAbstractItemView.ExtendedSelection) for value in unassigned_values: value_as_string = value is not None and unicode(value) or 'NULL' list_item = QListWidgetItem(self.lstUniqueValues) list_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled) list_item.setData(Qt.UserRole, value) list_item.setText(value_as_string) self.lstUniqueValues.addItem(list_item) # Populate assigned values tree self.treeClasses.clear() self.treeClasses.invisibleRootItem().setFlags(Qt.ItemIsEnabled) for default_class in default_classes: # Create branch for class tree_branch = QTreeWidgetItem(self.treeClasses) tree_branch.setFlags(Qt.ItemIsDropEnabled | Qt.ItemIsEnabled) tree_branch.setExpanded(True) tree_branch.setFont(0, bold_font) if 'name' in default_class: default_class_name = default_class['name'] else: default_class_name = default_class['key'] tree_branch.setText(0, default_class_name) tree_branch.setData(0, Qt.UserRole, default_class['key']) if 'description' in default_class: tree_branch.setToolTip(0, default_class['description']) # Assign known values for value in assigned_values[default_class['key']]: string_value = value is not None and unicode(value) or 'NULL' tree_leaf = QTreeWidgetItem(tree_branch) tree_leaf.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled) tree_leaf.setData(0, Qt.UserRole, value) tree_leaf.setText(0, string_value)
def fillInputsTree(self): icon = QIcon(os.path.join(pluginPath, 'images', 'input.png')) parametersItem = QTreeWidgetItem() parametersItem.setText(0, self.tr('Parameters')) for paramType in ModelerParameterDefinitionDialog.paramTypes: paramItem = QTreeWidgetItem() paramItem.setText(0, paramType) paramItem.setIcon(0, icon) paramItem.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled) parametersItem.addChild(paramItem) self.inputsTree.addTopLevelItem(parametersItem) parametersItem.setExpanded(True)
def _load_defaults_shortcuts(self): """Method to load the default builtin shortcuts""" #clean custom shortcuts and UI widget resources.clean_custom_shortcuts() self.result_widget.clear() for name, action in list(resources.SHORTCUTS.items()): shortcut_action = action #populate the tree widget tree_data = [self.shortcuts_text[name], shortcut_action.toString(QKeySequence.NativeText), name] item = QTreeWidgetItem(self.result_widget, tree_data) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
def AddTenant(self): d = self.project.CreateTenant() it = QTreeWidgetItem(self.ui.tenants, QStringList(["New_tenant", self.tr("No"), self.tr("No")])) cb = QComboBox() cb.addItems([self.tr("No"),self.tr("Yes")]) self.ui.tenants.setItemWidget(it,1,cb) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged) it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.tenants[it] = d self.ui.tenants.editItem(it) self.tenants[it].name = unicode(it.text(0)) self.tenants[it].critical = False if self.ui.tenants.itemWidget(it,1).currentText() == self.tr("Yes") else True self.UpdateTenant(it)
def __init__(self, parent=None): super(OfflineDialog, self).__init__(parent) self.pagetitle = 'Offline Back Up' stylesheet = Valid().background() + Valid().font() self.hold_data = {} self.tree = QTreeWidget() self.tree.setHeaderLabel("Choose Sessions to Back-up") self.tree.headerItem().setText(0, 'Name') #self.tree.setStyleSheet(treeStyleSheet) arr = Db().selectn('session','', 5) if arr and len(arr) > 0: for val in arr: child = QTreeWidgetItem(self.tree) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, str(val['name']).upper()) self.hold_data[val['id']] = child child.setCheckState(0, Qt.Checked) self.pb = QPushButton() self.pb.setObjectName("Add") self.pb.setText("Save") self.pb1 = QPushButton() self.pb1.setObjectName("Cancel") self.pb1.setText("Close") hbo = QHBoxLayout() hbo.addWidget(self.pb1) hbo.addStretch() hbo.addWidget(self.pb) groupBox2 = QGroupBox('') groupBox2.setLayout(hbo) grid = QGridLayout() grid.addWidget(self.tree, 0, 0) grid.addWidget(groupBox2, 1, 0) self.setLayout(grid) self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click()) self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self)) self.setStyleSheet(stylesheet) #self.setWindowIcon(QIcon(self.titleIcon)) self.setWindowTitle(self.pagetitle)
def AddDemand(self): d = self.project.CreateDemand() it = QTreeWidgetItem(self.ui.demands, QStringList(["New_demand", "0", "1", self.tr("No"), self.tr("No")])) cb = QComboBox() cb.addItems([self.tr("No"),self.tr("Yes")]) self.ui.demands.setItemWidget(it,3,cb) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged) it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.demands[it] = d self.ui.demands.editItem(it) self.demands[it].id = unicode(it.text(0)) self.demands[it].startTime = int(it.text(1)) self.demands[it].endTime = int(it.text(2)) self.demands[it].critical = False if self.ui.demands.itemWidget(it,3).currentText() == self.tr("Yes") else True
def treeMenuSetupRecur(self, curStruct, parent=None): item = QTreeWidgetItem(parent) item.setText(0, curStruct["text"]) if "flags" in curStruct: item.setFlags(curStruct["flags"]) if "children" in curStruct: children = [] for child in curStruct["children"]: children.append(self.treeMenuSetupRecur(child, item)) item.addChildren(children) if "expanded" in curStruct: print(curStruct["expanded"]) item.setExpanded(curStruct["expanded"]) print(item.isExpanded()) return item
def add_item(self, texts, edit_item=False, select_item=False): item = QTreeWidgetItem(texts) item.setFlags(item.flags() | Qt.ItemIsEditable) self.tree_items.addTopLevelItem(item) if edit_item: self.tree_items.setCurrentItem(item) self.tree_items.setFocus() self.tree_items.editItem(item) elif select_item: self.tree_items.setCurrentItem(item) self.tree_items.setFocus() self.update_ui_state()
def populate(self): self.ui.treeWidget.setColumnCount(1) for pluginName, features in self.featureDict.iteritems(): if pluginName == "TestFeatures" and not ilastik_config.getboolean( "ilastik", "debug"): continue parent = QTreeWidgetItem(self.ui.treeWidget) parent.setText(0, pluginName) parent.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) # hack to ensure checkboxes visible parent.setCheckState(0, Qt.Checked) parent.setCheckState(0, Qt.Unchecked) parent.setExpanded(False) self.countChecked[pluginName] = 0 self.countAll[pluginName] = len(self.featureDict[pluginName]) advanced_names = [] simple_names = [] for name in sorted(features.keys()): parameters = features[name] if 'advanced' in parameters: advanced_names.append(name) else: simple_names.append(name) for name in simple_names + advanced_names: parameters = features[name] item = QTreeWidgetItem(parent) item.setText(0, name) item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) if 'tooltip' in parameters: item.setToolTip(0, parameters['tooltip']) # hack to ensure checkboxes visible item.setCheckState(0, Qt.Checked) item.setCheckState(0, Qt.Unchecked) if pluginName in self.selectedFeatures: if name in self.selectedFeatures[pluginName]: item.setCheckState(0, Qt.Checked) self.countChecked[pluginName] += 1 if self.countChecked[pluginName] == 0: parent.setCheckState(0, Qt.Unchecked) elif self.countChecked[pluginName] == self.countAll[pluginName]: parent.setCheckState(0, Qt.Checked) else: parent.setCheckState(0, Qt.PartiallyChecked) self.updateToolTip(parent) # facilitates switching of the CheckBox when clicking on the Text of a QTreeWidgetItem self.ui.treeWidget.setCurrentItem(None)
def createSeparatorItem(self): """ Creates a new separator item. :return <QTreeWidgetItem> """ item = QTreeWidgetItem([' ']) font = item.font(0) font.setStrikeOut(True) item.setFont(0, font) item.setData(0, Qt.UserRole, qt.wrapVariant('separator')) flags = item.flags() flags ^= Qt.ItemIsDropEnabled item.setFlags(flags) return item
def createSeparatorItem( self ): """ Creates a new separator item. :return <QTreeWidgetItem> """ item = QTreeWidgetItem([' ']) font = item.font(0) font.setStrikeOut(True) item.setFont(0, font) item.setData(0, Qt.UserRole, qt.wrapVariant('separator')) flags = item.flags() flags ^= Qt.ItemIsDropEnabled item.setFlags(flags) return item
def setupDialog(self): for particle in self.particles: pos = particle.position.number vel = particle.velocity.number mass = particle.mass.number radius = particle.radius.number item = QTreeWidgetItem(( str(pos[0]), str(pos[1]), str(pos[2]), str(particle.position.unit), str(vel[0]), str(vel[1]), str(vel[2]), str(particle.velocity.unit), str(mass), str(particle.mass.unit), str(radius), str(particle.radius.unit) )) item.setFlags(item.flags() | Qt.ItemIsEditable) self.ui.particlesTree.addTopLevelItem(item)
def setData(self, project): self.project = project self.canvas.Clear() r = self.project.resources.GetTimeBounds() self.time = r[0] self.ui.timeSpinBox.setValue(r[0]) self.ui.timeSpinBox.setMinimum(r[0]) self.ui.timeSpinBox.setMaximum(r[1]) self.ui.timeSlider.setValue(r[0]) self.ui.timeSlider.setMinimum(r[0]) self.ui.timeSlider.setMaximum(r[1]) self.ui.info.setText("") timeInt = self.project.resources.GetTimeInterval(self.time) self.ui.assignedDemands.clear() for d in self.project.demands: if d.assigned and (d.startTime <= self.time) and (d.endTime >= self.time): it = QTreeWidgetItem(self.ui.assignedDemands, [d.id]) it.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.canvas.Visualize(self.project.resources, timeInt)
def AddDemand(self): d = self.project.CreateDemand() it = QTreeWidgetItem( self.ui.demands, QStringList(["New_demand", "0", "1", self.tr("No"), self.tr("No")])) cb = QComboBox() cb.addItems([self.tr("No"), self.tr("Yes")]) self.ui.demands.setItemWidget(it, 3, cb) QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged) it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.demands[it] = d self.ui.demands.editItem(it) self.demands[it].id = unicode(it.text(0)) self.demands[it].startTime = int(it.text(1)) self.demands[it].endTime = int(it.text(2)) self.demands[it].critical = False if self.ui.demands.itemWidget( it, 3).currentText() == self.tr("Yes") else True
def populate(self): self.ui.treeWidget.setColumnCount(1) for pluginName, features in self.featureDict.iteritems(): if pluginName == "TestFeatures" and not ilastik_config.getboolean( "ilastik", "debug"): continue parent = QTreeWidgetItem(self.ui.treeWidget) if pluginName == "Standard Object Features": parent.setText(0, pluginName) parent.setToolTip( 0, 'http://hci.iwr.uni-heidelberg.de/vigra/doc/vigra/group__FeatureAccumulators.html' ) else: parent.setText(0, pluginName) parent.setExpanded(True) advanced_names = [] simple_names = [] for name in sorted(features.keys()): parameters = features[name] if 'advanced' in parameters: advanced_names.append(name) else: simple_names.append(name) for name in simple_names + advanced_names: parameters = features[name] item = QTreeWidgetItem(parent) item.setText(0, name) item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) if 'tooltip' in parameters: item.setToolTip(0, parameters['tooltip']) # hack to ensure checkboxes visible item.setCheckState(0, Qt.Checked) item.setCheckState(0, Qt.Unchecked) if pluginName in self.selectedFeatures: if name in self.selectedFeatures[pluginName]: item.setCheckState(0, Qt.Checked)