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 LoadInfoProcess(self): lproc = self.tm.lprocessus for proc in lproc: try: item = self.procItemDic[proc] except KeyError: item = QTreeWidgetItem(self.treeProcess) self.procItemDic[proc] = item item.setText(0, str(proc.pid)) item.setText(1, str(proc.name)) if item.text(2) != str(proc.state): item.setText(2, str(proc.state)) if item.text(3) != str(proc.stateinfo): item.setText(3, str(proc.stateinfo))
def filter(self, filterString: str, item: QTreeWidgetItem) -> bool: visible = (filterString == "") columnCount = item.columnCount() for i in range(columnCount): if not visible: break text = item.text(i) if HostOsInfo.isMacHost(): # accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd if i == columnCount - 1: key = QKeySequence.fromString(text, QKeySequence.NativeText) if not key.isEmpty(): text = key.toString(QKeySequence.PortableText) text.replace("Ctrl", "Cmd") text.replace("Meta", "Ctrl") text.replace("Alt", "Opt") if filterString.upper() in text.upper(): # case insensitive visible = True childCount = item.childCount() if childCount > 0: # force visibility if this item matches leafFilterString = "" if visible else filterString for i in range(childCount): citem = item.child(i) # QTreeWidgetItem if not filter(leafFilterString, citem): visible = True item.setHidden(not visible) return not visible
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 LoadInfoProcess(self): lproc = self.tm.lprocessus for proc in lproc: try: item = self.procItemDic[proc] except KeyError: item = QTreeWidgetItem(self) self.procItemDic[proc] = item item.setText(0, str(proc.pid)) item.setText(1, str(proc.name)) if item.text(2) != str(proc.state): item.setText(2, str(proc.state)) if item.text(3) != str(proc.stateinfo): item.setText(3, str(proc.stateinfo)) stime = datetime.fromtimestamp(proc.timestart) if proc.timeend: etime = datetime.fromtimestamp(proc.timeend) else: etime = datetime.fromtimestamp(time.time()) delta = etime - stime item.setText(4, str(delta))
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 onClickItem(self, item: QtGui.QTreeWidgetItem, column: int): """ Action performed when an item in the QTreeWidget is clicked. Keyword arguments: item -- The item user clicked on. column -- The column number clicked (not used here). """ if self.path and self.key != None: self.saveValue() if self.data and item.isLeaf() and len(item.text(0).split()) == 1: # Update GUI self.dataClicked(item) else: # Update GUI self.dataStructureClicked(item)
def fillTreeUsingCategories(self): providersToExclude = ["model", "script"] self.algorithmTree.clear() text = unicode(self.searchBox.text()) groups = {} for providerName in Processing.algs.keys(): provider = Processing.algs[providerName] name = "ACTIVATE_" + providerName.upper().replace(" ", "_") if not ProcessingConfig.getSetting(name): continue if providerName in providersToExclude or len(ModelerUtils.providers[providerName].actions) != 0: continue algs = provider.values() # add algorithms for alg in algs: if not alg.showInToolbox: continue (altgroup, altsubgroup, altname) = AlgorithmDecorator.getGroupsAndName(alg) if altgroup is None: continue if text == "" or text.lower() in altname.lower(): if altgroup not in groups: groups[altgroup] = {} group = groups[altgroup] if altsubgroup not in group: groups[altgroup][altsubgroup] = [] subgroup = groups[altgroup][altsubgroup] subgroup.append(alg) if len(groups) > 0: mainItem = QTreeWidgetItem() mainItem.setText(0, "Geoalgorithms") mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) mainItem.setToolTip(0, mainItem.text(0)) for (groupname, group) in groups.items(): groupItem = QTreeWidgetItem() groupItem.setText(0, groupname) groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) groupItem.setToolTip(0, groupItem.text(0)) mainItem.addChild(groupItem) for (subgroupname, subgroup) in group.items(): subgroupItem = QTreeWidgetItem() subgroupItem.setText(0, subgroupname) subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) subgroupItem.setToolTip(0, subgroupItem.text(0)) groupItem.addChild(subgroupItem) for alg in subgroup: algItem = TreeAlgorithmItem(alg) subgroupItem.addChild(algItem) self.algorithmTree.addTopLevelItem(mainItem) for providerName in Processing.algs.keys(): if providerName not in providersToExclude: continue name = "ACTIVATE_" + providerName.upper().replace(" ", "_") if not ProcessingConfig.getSetting(name): continue providerItem = TreeProviderItem(providerName) self.algorithmTree.addTopLevelItem(providerItem)
def fillAlgorithmTreeUsingCategories(self): providersToExclude = ['model', 'script'] self.algorithmTree.clear() text = unicode(self.searchBox.text()) groups = {} allAlgs = ModelerUtils.allAlgs for providerName in allAlgs.keys(): provider = allAlgs[providerName] name = 'ACTIVATE_' + providerName.upper().replace(' ', '_') if not ProcessingConfig.getSetting(name): continue if providerName in providersToExclude \ or len(ModelerUtils.providers[providerName].actions) != 0: continue algs = provider.values() # Add algorithms for alg in algs: if not alg.showInModeler or alg.allowOnlyOpenedLayers: continue altgroup, altsubgroup = AlgorithmClassification.getClassification(alg) if altgroup is None: continue algName = AlgorithmClassification.getDisplayName(alg) if text == '' or text.lower() in algName.lower(): if altgroup not in groups: groups[altgroup] = {} group = groups[altgroup] if altsubgroup not in group: groups[altgroup][altsubgroup] = [] subgroup = groups[altgroup][altsubgroup] subgroup.append(alg) if len(groups) > 0: mainItem = QTreeWidgetItem() mainItem.setText(0, self.tr('Geoalgorithms')) mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) mainItem.setToolTip(0, mainItem.text(0)) for (groupname, group) in groups.items(): groupItem = QTreeWidgetItem() groupItem.setText(0, groupname) groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) groupItem.setToolTip(0, groupItem.text(0)) mainItem.addChild(groupItem) for (subgroupname, subgroup) in group.items(): subgroupItem = QTreeWidgetItem() subgroupItem.setText(0, subgroupname) subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) subgroupItem.setToolTip(0, subgroupItem.text(0)) groupItem.addChild(subgroupItem) for alg in subgroup: algItem = TreeAlgorithmItem(alg) subgroupItem.addChild(algItem) self.algorithmTree.addTopLevelItem(mainItem) for providerName in allAlgs.keys(): groups = {} provider = allAlgs[providerName] name = 'ACTIVATE_' + providerName.upper().replace(' ', '_') if not ProcessingConfig.getSetting(name): continue if providerName not in providersToExclude: continue algs = provider.values() # Add algorithms for alg in algs: if not alg.showInModeler or alg.allowOnlyOpenedLayers: continue if text == '' or text.lower() in alg.name.lower(): if alg.group in groups: groupItem = groups[alg.group] else: groupItem = QTreeWidgetItem() name = alg.i18n_group groupItem.setText(0, name) groupItem.setToolTip(0, name) groups[alg.group] = groupItem algItem = TreeAlgorithmItem(alg) groupItem.addChild(algItem) if len(groups) > 0: providerItem = QTreeWidgetItem() providerItem.setText(0, ModelerUtils.providers[providerName].getDescription()) providerItem.setIcon(0, ModelerUtils.providers[providerName].getIcon()) providerItem.setToolTip(0, providerItem.text(0)) for groupItem in groups.values(): providerItem.addChild(groupItem) self.algorithmTree.addTopLevelItem(providerItem) providerItem.setExpanded(text != '') for groupItem in groups.values(): if text != '': groupItem.setExpanded(True)
def fillTreeUsingCategories(self): providersToExclude = ['model', 'script'] self.algorithmTree.clear() text = unicode(self.searchBox.text()) groups = {} for providerName in Processing.algs.keys(): provider = Processing.algs[providerName] name = 'ACTIVATE_' + providerName.upper().replace(' ', '_') if not ProcessingConfig.getSetting(name): continue if providerName in providersToExclude or \ len(ModelerUtils.providers[providerName].actions) != 0: continue algs = provider.values() # add algorithms for alg in algs: if not alg.showInToolbox: continue altgroup, altsubgroup = AlgorithmClassification.getClassification(alg) if altgroup is None: continue algName = AlgorithmClassification.getDisplayName(alg) if text == '' or text.lower() in algName.lower(): if altgroup not in groups: groups[altgroup] = {} group = groups[altgroup] if altsubgroup not in group: groups[altgroup][altsubgroup] = [] subgroup = groups[altgroup][altsubgroup] subgroup.append(alg) if len(groups) > 0: mainItem = QTreeWidgetItem() mainItem.setText(0, 'Geoalgorithms') mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) mainItem.setToolTip(0, mainItem.text(0)) for (groupname, group) in groups.items(): groupItem = QTreeWidgetItem() groupItem.setText(0, groupname) groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) groupItem.setToolTip(0, groupItem.text(0)) mainItem.addChild(groupItem) for (subgroupname, subgroup) in group.items(): subgroupItem = QTreeWidgetItem() subgroupItem.setText(0, subgroupname) subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) subgroupItem.setToolTip(0, subgroupItem.text(0)) groupItem.addChild(subgroupItem) for alg in subgroup: algItem = TreeAlgorithmItem(alg) subgroupItem.addChild(algItem) self.algorithmTree.addTopLevelItem(mainItem) for providerName in Processing.algs.keys(): if providerName not in providersToExclude: continue name = 'ACTIVATE_' + providerName.upper().replace(' ', '_') if not ProcessingConfig.getSetting(name): continue providerItem = TreeProviderItem(providerName) self.algorithmTree.addTopLevelItem(providerItem)
def fillListBox(self, f25, f50, f100, f250): self.cartasList.clear() item25 = QTreeWidgetItem(['1:25.000 (' + str(len(f25)) + ')', '']) item50 = QTreeWidgetItem(['1:50.000 (' + str(len(f50)) + ')', '']) item100 = QTreeWidgetItem(['1:100.000 (' + str(len(f100)) + ')', '']) item250 = QTreeWidgetItem(['1:250.000 (' + str(len(f250)) + ')', '']) itemNotFound = QTreeWidgetItem([u'Não existentes', '']) self.cartasList.addTopLevelItems( [item25, item50, item100, item250, itemNotFound]) for c in f25.keys(): if f25[c] != '': if f25[c][0] != '-': item = QTreeWidgetItem([c, f25[c]]) item25.addChild(item) else: item = QTreeWidgetItem([c, '']) itemNotFound.addChild(item) else: item = QTreeWidgetItem([c, '']) itemNotFound.addChild(item) item25.setExpanded(True) for c in f50.keys(): if f50[c] != '': if f50[c][0] != '-': item = QTreeWidgetItem([c, f50[c]]) item50.addChild(item) else: item = QTreeWidgetItem([c, '']) itemNotFound.addChild(item) else: item = QTreeWidgetItem([c, '']) itemNotFound.addChild(item) item50.setExpanded(True) for c in f100.keys(): if f100[c] != '': if f100[c][0] != '-': item = QTreeWidgetItem([c, f100[c]]) item100.addChild(item) else: item = QTreeWidgetItem([c, '']) itemNotFound.addChild(item) else: item = QTreeWidgetItem([c, '']) itemNotFound.addChild(item) item100.setExpanded(True) for c in f250.keys(): if f250[c] != '': if f250[c][0] != '-': item = QTreeWidgetItem([c, f250[c]]) item250.addChild(item) else: item = QTreeWidgetItem([c, '']) itemNotFound.addChild(item) else: item = QTreeWidgetItem([c, '']) itemNotFound.addChild(item) item250.setExpanded(True) itemNotFound.setExpanded(True) if itemNotFound.childCount() == 0: self.cartasList.invisibleRootItem().removeChild(itemNotFound) else: itemNotFound.setText( 0, itemNotFound.text(0) + ' (' + str(itemNotFound.childCount()) + ')') self.cartasList.header().setResizeMode( QtGui.QHeaderView.ResizeToContents)
def fillAlgorithmTreeUsingCategories(self): providersToExclude = ['model', 'script'] self.algorithmTree.clear() text = unicode(self.searchBox.text()) groups = {} allAlgs = ModelerUtils.allAlgs for providerName in allAlgs.keys(): provider = allAlgs[providerName] name = 'ACTIVATE_' + providerName.upper().replace(' ', '_') if not ProcessingConfig.getSetting(name): continue if providerName in providersToExclude \ or len(ModelerUtils.providers[providerName].actions) != 0: continue algs = provider.values() # Add algorithms for alg in algs: if not alg.showInModeler or alg.allowOnlyOpenedLayers: continue altgroup, altsubgroup = AlgorithmClassification.getClassification( alg) if altgroup is None: continue algName = AlgorithmClassification.getDisplayName(alg) if text == '' or text.lower() in algName.lower(): if altgroup not in groups: groups[altgroup] = {} group = groups[altgroup] if altsubgroup not in group: groups[altgroup][altsubgroup] = [] subgroup = groups[altgroup][altsubgroup] subgroup.append(alg) if len(groups) > 0: mainItem = QTreeWidgetItem() mainItem.setText(0, self.tr('Geoalgorithms')) mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) mainItem.setToolTip(0, mainItem.text(0)) for (groupname, group) in groups.items(): groupItem = QTreeWidgetItem() groupItem.setText(0, groupname) groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) groupItem.setToolTip(0, groupItem.text(0)) mainItem.addChild(groupItem) for (subgroupname, subgroup) in group.items(): subgroupItem = QTreeWidgetItem() subgroupItem.setText(0, subgroupname) subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) subgroupItem.setToolTip(0, subgroupItem.text(0)) groupItem.addChild(subgroupItem) for alg in subgroup: algItem = TreeAlgorithmItem(alg) subgroupItem.addChild(algItem) self.algorithmTree.addTopLevelItem(mainItem) for providerName in allAlgs.keys(): groups = {} provider = allAlgs[providerName] name = 'ACTIVATE_' + providerName.upper().replace(' ', '_') if not ProcessingConfig.getSetting(name): continue if providerName not in providersToExclude: continue algs = provider.values() # Add algorithms for alg in algs: if not alg.showInModeler or alg.allowOnlyOpenedLayers: continue if text == '' or text.lower() in alg.name.lower(): if alg.group in groups: groupItem = groups[alg.group] else: groupItem = QTreeWidgetItem() name = alg.i18n_group groupItem.setText(0, name) groupItem.setToolTip(0, name) groups[alg.group] = groupItem algItem = TreeAlgorithmItem(alg) groupItem.addChild(algItem) if len(groups) > 0: providerItem = QTreeWidgetItem() providerItem.setText( 0, ModelerUtils.providers[providerName].getDescription()) providerItem.setIcon( 0, ModelerUtils.providers[providerName].getIcon()) providerItem.setToolTip(0, providerItem.text(0)) for groupItem in groups.values(): providerItem.addChild(groupItem) self.algorithmTree.addTopLevelItem(providerItem) providerItem.setExpanded(text != '') for groupItem in groups.values(): if text != '': groupItem.setExpanded(True)