def addItems(self, menus, processed=None): """ Adds items to the completion tree from the menu. :param menus | [<QMenu>, ..] procesed | [<QAction>, ..] || None """ if processed is None: processed = [] for menu in menus: for action in menu.actions(): # since we can have 1 action in more than 1 submenu, we # will want to make sure we're only adding a unique one # so we don't have duplicates text = nativestring(action.text()) if text in processed or action.isSeparator(): continue processed.append(text) if text and unwrapVariant(action.data()) != 'menu': item = XTreeWidgetItem(self._completer, [text]) item.setFixedHeight(20) item.setIcon(0, action.icon()) item.setToolTip(0, action.toolTip()) item.setData(0, Qt.UserRole, wrapVariant(action))
def __init__(self, loggerWidget): super(XLoggerControls, self).__init__(loggerWidget) # load the user interface projexui.loadUi(__file__, self) self._url = 'https://docs.python.org/2/library/logging.html#logrecord-attributes' self._loggerWidget = loggerWidget self.uiLoggerTREE.setLoggerWidget(loggerWidget) self.uiFormatTXT.setText(loggerWidget.formatText()) # load the levels if 'designer' not in sys.executable: tree = self.uiLevelTREE from projexui.widgets.xloggerwidget import XLoggerWidget items = sorted(XLoggerWidget.LoggingMap.items()) for i, (level, data) in enumerate(items): item = XTreeWidgetItem(tree, [projex.text.pretty(data[0])]) item.setFixedHeight(22) item.setData(0, QtCore.Qt.UserRole, wrapVariant(level)) item.setCheckState(0, QtCore.Qt.Unchecked) # create connections self.uiFormatTXT.textChanged.connect(loggerWidget.setFormatText) self.uiLevelTREE.itemChanged.connect(self.updateLevels) self.uiHelpBTN.clicked.connect(self.showHelp)
def addEntry(self, key='', value=''): """ Creates a new entry item for this widget. :param key | <str> value | <variant> """ img = resources.find('img/close.png') new_item = XTreeWidgetItem() new_item.setText(1, nativestring(key)) new_item.setText(2, nativestring(value)) new_item.setIcon(0, QtGui.QIcon(img)) new_item.setFixedHeight(22) self.insertTopLevelItem(self.topLevelItemCount() - 1, new_item) return new_item
def setPlugins( self, plugins ): """ Loads the plugins for the inputed dialog. :param plugins | [<XConfigPlugin>, ..] """ plugins = sorted(plugins, key = lambda x: x.title()) breakdown = {} for plugin in plugins: breakdown.setdefault(plugin.configGroup(), []) breakdown[plugin.configGroup()].append(plugin) for grp in sorted(breakdown.keys()): gitem = XTreeWidgetItem([grp]) gitem.initGroupStyle() gitem.setFixedHeight(22) for plugin in breakdown[grp]: item = PluginItem(plugin) gitem.addChild(item) self.uiPluginTREE.addTopLevelItem(gitem) gitem.setExpanded(True)
def _addXdkItem(self, filename): item = XdkItem(filename) # add the xdk content item self.uiContentsTREE.addTopLevelItem(item) # add the index list items self.uiIndexTREE.blockSignals(True) self.uiIndexTREE.setUpdatesEnabled(False) for name, url in item.indexlist(): item = XTreeWidgetItem([name]) item.setToolTip(0, url) item.setFixedHeight(22) self.uiIndexTREE.addTopLevelItem(item) self.uiIndexTREE.blockSignals(False) self.uiIndexTREE.setUpdatesEnabled(True) self.uiIndexTREE.sortByColumn(0, Qt.AscendingOrder) self.unsetCursor()
def __init__(self, loggerWidget): super(XLogRecordControls, self).__init__(loggerWidget) # load the user interface projexui.loadUi(__file__, self) self._loggerWidget = loggerWidget self.uiLoggerTREE.setLoggerWidget(loggerWidget) # load the levels if 'designer' not in sys.executable: tree = self.uiLevelTREE from projexui.widgets.xloggerwidget import XLoggerWidget items = sorted(XLoggerWidget.LoggingMap.items()) for i, (level, data) in enumerate(items): item = XTreeWidgetItem(tree, [projex.text.pretty(data[0])]) item.setFixedHeight(22) item.setData(0, QtCore.Qt.UserRole, wrapVariant(level)) item.setCheckState(0, QtCore.Qt.Unchecked) # create connections self.uiLevelTREE.itemChanged.connect(self.updateLevels)
def setDictionary(self, props): """ Sets a dictionary of the key/value pairing for the items in this widget. :param props | {<str> key: <str> value, ..} """ if not self._initialized: self.setColumns(['', 'Property', 'Value']) self.setColumnWidth(0, 22) self._initialized = True self.clear() palette = self.palette() item = XTreeWidgetItem(self, ['add another item']) item.setForeground(0, palette.color(palette.Disabled, palette.Text)) item.setTextAlignment(0, QtCore.Qt.AlignCenter) item.setFlags(QtCore.Qt.ItemFlags(0)) item.setFixedHeight(22) item.setFirstColumnSpanned(True) for key, text in props.items(): self.addEntry(key, text)
def setPlugins( self, plugins ): """ Loads the plugins for the inputed dialog. :param plugins | [<XWizardPlugin>, ..] """ langs = {} icons = {} for plugin in plugins: wlang = plugin.wizardType() wgrp = plugin.wizardGroup() langs.setdefault(wlang, {}) langs[wlang].setdefault(wgrp, []) langs[wlang][wgrp].append( plugin ) icons.setdefault(wgrp, plugin.groupIcon(wgrp)) self._plugins = langs self.blockSignals(True) self.setUpdatesEnabled(False) self.uiPluginTREE.clear() folder = QIcon(projexui.resources.find('img/folder_32.png')) for wlang in sorted(langs.keys()): langitem = XTreeWidgetItem(self.uiPluginTREE, [wlang]) langitem.setFixedHeight(28) langitem.initGroupStyle() langitem.setExpanded(True) for wgrp in sorted(langs[wlang].keys()): grpitem = XTreeWidgetItem(langitem, [wgrp]) grpitem.setIcon(0, QIcon(icons[wgrp])) grpitem.setFixedHeight(26) self.blockSignals(False) self.setUpdatesEnabled(True)