Exemplo n.º 1
0
    def add(self,
            seq,
            text,
            position,
            foreground=False,
            background=False,
            icon=False):
        from PyQt4.QtGui import QTreeWidgetItem

        item = QTreeWidgetItem()

        item.setText(0, text)
        item.setData(0, Qt.UserRole, position)

        if foreground:
            item.setForeground(0, foreground)

        if background:
            item.setBackground(0, background)

        if icon:
            item.setIcon(0, icon)

        seq.append(item)
        return item
Exemplo n.º 2
0
    def fillBase(self, node):
        fsobj = node.fsobj()
        fsobjname = ""
        if fsobj != None:
            fsobjname = fsobj.name
        itemName = QTreeWidgetItem(self)
        itemName.setText(0, self.nameText)
        itemName.setText(1, QString.fromUtf8(node.name()))
        if isinstance(node, VLink):
            linkPath = QTreeWidgetItem(self)
            linkPath.setText(0, self.linkPath)
            label = QLabel('<a href="' + QString.fromUtf8(node.linkPath()) +
                           '" style="color: blue">' +
                           QString.fromUtf8(node.linkAbsolute()) + ' </a>')
            label.connect(label, SIGNAL("linkActivated(QString)"),
                          self.gotolink)
            self.setItemWidget(linkPath, 1, label)

        itemName = QTreeWidgetItem(self)
        itemName.setText(0, self.nodeTypeText)

        typestr = ""
        if node.isFile():
            typestr += self.fileText
            if node.hasChildren():
                typestr += self.modAppliedText
        self.fillCompatModule(node)
        if node.hasChildren():
            self.fillChildren(node)

        if node.isDir():
            typestr += self.folderText
            if not node.hasChildren():
                typestr += self.emptyText
        if node.isDeleted():
            typestr += self.deletedText
        itemName.setText(1, typestr)

        itemModule = QTreeWidgetItem(self)
        itemModule.setText(0, self.generateText)
        itemModule.setText(1, str(fsobjname))

        itemSize = QTreeWidgetItem(self)
        itemSize.setText(0, self.sizeText)
        itemSize.setText(1, str(node.size()))

        tags = node.tags()
        if len(tags):
            itemTags = QTreeWidgetItem(self)
            itemTags.setText(0, "tags")
            tags = node.tags()
            for tag in tags:
                itemTag = QTreeWidgetItem(itemTags)
                color = tag.color()
                itemTag.setBackground(
                    0, QBrush(QColor(color.r, color.g, color.b)))
                itemTag.setForeground(0, QBrush(QColor(255, 255, 255)))
                itemTag.setText(0, QString.fromUtf8(tag.name()))
            self.expandItem(itemTags)
Exemplo n.º 3
0
    def populate(self):
        groups = {}
        count = 0
        provider = Processing.algs[self.providerName]
        algs = provider.values()

        name = 'ACTIVATE_' + self.providerName.upper().replace(' ', '_')
        active = ProcessingConfig.getSetting(name)

        # Add algorithms
        for alg in algs:
            if not alg.showInToolbox:
                continue
            if alg.group in groups:
                groupItem = groups[alg.group]
            else:
                groupItem = QTreeWidgetItem()
                name = alg.i18n_group or alg.group
                if not active:
                    groupItem.setForeground(0, Qt.darkGray)
                groupItem.setText(0, name)
                groupItem.setToolTip(0, name)
                groups[alg.group] = groupItem
            algItem = TreeAlgorithmItem(alg)
            if not active:
                algItem.setForeground(0, Qt.darkGray)
            groupItem.addChild(algItem)
            count += 1

        actions = Processing.actions[self.providerName]
        for action in actions:
            if action.group in groups:
                groupItem = groups[action.group]
            else:
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, action.group)
                groups[action.group] = groupItem
            algItem = TreeActionItem(action)
            groupItem.addChild(algItem)

        text = self.provider.getDescription()

        if not active:
            def activateProvider():
                self.toolbox.activateProvider(self.providerName)
            label = QLabel(text + "&nbsp;&nbsp;&nbsp;&nbsp;<a href='%s'>Activate</a>")
            label.setStyleSheet("QLabel {background-color: white; color: grey;}")
            label.linkActivated.connect(activateProvider)
            self.tree.setItemWidget(self, 0, label)

        else:
            text += QCoreApplication.translate("TreeProviderItem", " [{0} geoalgorithms]").format(count)
        self.setText(0, text)
        self.setToolTip(0, self.text(0))
        for groupItem in groups.values():
            self.addChild(groupItem)
Exemplo n.º 4
0
    def populate(self):
        groups = {}
        count = 0
        provider = Processing.algs[self.providerName]
        algs = provider.values()

        name = 'ACTIVATE_' + self.providerName.upper().replace(' ', '_')
        active = ProcessingConfig.getSetting(name)

        # Add algorithms
        for alg in algs:
            if not alg.showInToolbox:
                continue
            if alg.group in groups:
                groupItem = groups[alg.group]
            else:
                groupItem = QTreeWidgetItem()
                name = alg.i18n_group or alg.group
                if not active:
                    groupItem.setForeground(0, Qt.darkGray)
                groupItem.setText(0, name)
                groupItem.setToolTip(0, name)
                groups[alg.group] = groupItem
            algItem = TreeAlgorithmItem(alg)
            if not active:
                algItem.setForeground(0, Qt.darkGray)
            groupItem.addChild(algItem)
            count += 1

        actions = Processing.actions[self.providerName]
        for action in actions:
            if action.group in groups:
                groupItem = groups[action.group]
            else:
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, action.group)
                groups[action.group] = groupItem
            algItem = TreeActionItem(action)
            groupItem.addChild(algItem)

        text = self.provider.getDescription()

        if not active:
            def activateProvider():
                self.toolbox.activateProvider(self.providerName)
            label = QLabel(text + "&nbsp;&nbsp;&nbsp;&nbsp;<a href='%s'>Activate</a>")
            label.setStyleSheet("QLabel {background-color: white; color: grey;}")
            label.linkActivated.connect(activateProvider)
            self.tree.setItemWidget(self, 0, label)

        else:
            text += QCoreApplication.translate("TreeProviderItem", " [{0} geoalgorithms]").format(count)
        self.setText(0, text)
        self.setToolTip(0, self.text(0))
        for groupItem in groups.values():
            self.addChild(groupItem)
Exemplo n.º 5
0
    def _insert_message(self, message, top):
        item = QTreeWidgetItem(None, [message.title or '', message.sender or 'Unknown',
                                      time.strftime('%Y-%m-%d %H:%M:%S', message.date.timetuple())])
        item.setData(0, Qt.UserRole, message)
        if message.flags & message.IS_UNREAD:
            item.setForeground(0, QBrush(Qt.darkYellow))
            item.setForeground(1, QBrush(Qt.darkYellow))
            item.setForeground(2, QBrush(Qt.darkYellow))

        top.addChild(item)

        for child in message.children:
            self._insert_message(child, item)
Exemplo n.º 6
0
    def addTangoHost(self, host):
        host, port = parseTangoHost(host).split(':')

        db = PyTango.Database(host, port)

        hostitem = QTreeWidgetItem()
        hostitem.setIcon(0, QIcon(':/server.png'))
        hostitem.setText(0, host)

        hostinfo = {}
        devices = {}

        # get a list of all devices
        for server in db.get_server_list():
            hostinfo[server] = {}
            devclslist = db.get_device_class_list(server)
            for i in xrange(0, len(devclslist), 2):
                devname, devcls = devclslist[i:i + 2]
                devinfo = db.get_device_info(devname)
                hostinfo[devname] = [server, devcls, devinfo]

                domain, family, member = devname.split('/')
                devices.setdefault(domain, {}).setdefault(family, set()).add(member)

        # create tree widget items for the devices
        for domain in sorted(devices):
            domainitem = QTreeWidgetItem([domain, ''])
            domainitem.setIcon(0, QIcon(':/folder.png'))
            for family in sorted(devices[domain]):
                familyitem = QTreeWidgetItem([family, ''])
                familyitem.setIcon(0, QIcon(':/folder.png'))
                for member in sorted(devices[domain][family]):
                    devname = domain + '/' + family + '/' + member
                    devitem = QTreeWidgetItem([member, hostinfo[devname][0]])
                    devitem.setIcon(0, QIcon(':/plug.png'))
                    if not hostinfo[devname][2].exported:
                        devitem.setForeground(0, QBrush(QColor('#666666')))
                    familyitem.addChild(devitem)
                domainitem.addChild(familyitem)
            hostitem.addChild(domainitem)

        self.tree.addTopLevelItem(hostitem)
        hostitem.setExpanded(True)

        self._tangoHosts[host] = hostinfo
Exemplo n.º 7
0
    def _insert_message(self, message, top):
        item = QTreeWidgetItem(None, [message.title or '', message.sender or 'Unknown',
                                      time.strftime('%Y-%m-%d %H:%M:%S', message.date.timetuple())])
        item.setData(0, Qt.UserRole, message)
        if message.flags & message.IS_UNREAD:
            item.setForeground(0, QBrush(Qt.darkYellow))
            item.setForeground(1, QBrush(Qt.darkYellow))
            item.setForeground(2, QBrush(Qt.darkYellow))

        if top is not None:
            # threads
            top.addChild(item)
        else:
            # discussion
            self.ui.messagesTree.invisibleRootItem().insertChild(0, item)

        if message.children is not None:
            for child in message.children:
                self._insert_message(child, top and item)
Exemplo n.º 8
0
    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()
Exemplo n.º 9
0
    def _insert_message(self, message, top):
        item = QTreeWidgetItem(None, [message.title or '', message.sender or 'Unknown',
                                      time.strftime('%Y-%m-%d %H:%M:%S', message.date.timetuple())])
        item.setData(0, Qt.UserRole, message)
        if message.flags & message.IS_UNREAD:
            item.setForeground(0, QBrush(Qt.darkYellow))
            item.setForeground(1, QBrush(Qt.darkYellow))
            item.setForeground(2, QBrush(Qt.darkYellow))

        if top is not None:
            # threads
            top.addChild(item)
        else:
            # discussion
            self.ui.messagesTree.invisibleRootItem().insertChild(0, item)

        if message.children is not None:
            for child in message.children:
                self._insert_message(child, top and item)
Exemplo n.º 10
0
    def refresh(self):
        tree = self.uiFilterTREE

        tree.blockSignals(True)
        tree.setUpdatesEnabled(False)

        tree.clear()

        # create the code color
        codeClr = tree.palette().color(tree.palette().Base).darker(140)

        # sort the data hash
        filters = self._filterOptions.items()
        filters.sort(lambda x, y: cmp(x[1].get('order', 100000), y[1].get(
            'order', 100000)))

        for key, option in filters:
            # create the data for this item
            data = {'code': key}
            data.update(option)

            # create the data item
            item = QTreeWidgetItem(
                [data.get('name', ''),
                 data.get('code', '')])
            item.setIcon(0, resources.icon(data.get('icon', '') % data))
            item.setSizeHint(0, QSize(0, 18))

            # check the item if its enabled
            if (self.isCheckable()):
                enabled = data.get('enabled', False)
                item.setCheckState(0, Qt.Checked if enabled else Qt.Unchecked)

            # set some ui data for the code name to hide it a bit
            item.setTextAlignment(1, Qt.AlignRight | Qt.AlignCenter)
            item.setForeground(1, codeClr)

            # add to the tree
            tree.addTopLevelItem(item)

        tree.setUpdatesEnabled(True)
        tree.blockSignals(False)
Exemplo n.º 11
0
    def add(self, seq, text, position, foreground=False, background=False, icon=False):
        from  PyQt4.QtGui import QTreeWidgetItem



        item = QTreeWidgetItem()

        item.setText(0, text)
        item.setData(0, Qt.UserRole, position)

        if foreground:
            item.setForeground(0, foreground)

        if background:
            item.setBackground(0, background)

        if icon:
            item.setIcon(0, icon)

        seq.append(item)
        return item
Exemplo n.º 12
0
 def refresh( self ):
     tree = self.uiFilterTREE
     
     tree.blockSignals(True)
     tree.setUpdatesEnabled(False)
     
     tree.clear()
     
     # create the code color
     codeClr = tree.palette().color(tree.palette().Base).darker(140)
     
     # sort the data hash
     filters = self._filterOptions.items()
     filters.sort( lambda x,y: cmp(x[1].get('order',100000),y[1].get('order',100000)) )
     
     for key, option in filters:
         # create the data for this item
         data = { 'code': key }
         data.update(option)
         
         # create the data item
         item = QTreeWidgetItem( [data.get('name',''),data.get('code','')] )
         item.setIcon( 0, resources.icon( data.get('icon','') % data ) )
         item.setSizeHint( 0, QSize( 0, 18 ) )
         
         # check the item if its enabled
         if ( self.isCheckable() ):
             enabled = data.get('enabled',False)
             item.setCheckState( 0, Qt.Checked if enabled else Qt.Unchecked )
         
         # set some ui data for the code name to hide it a bit
         item.setTextAlignment( 1, Qt.AlignRight | Qt.AlignCenter )
         item.setForeground( 1, codeClr )
         
         # add to the tree
         tree.addTopLevelItem(item)
     
     tree.setUpdatesEnabled(True)
     tree.blockSignals(False)
Exemplo n.º 13
0
    def __init__(self, report):
        super(ReportDialog, self).__init__()
        self.setupUi(self)

        self.actionSaveAll.setIcon(
            QgsApplication.getThemeIcon('/mActionFileSave.svg'))
        self.actionSaveSelected.setIcon(
            QgsApplication.getThemeIcon('/mActionFileSaveAs.svg'))
        self.actionOpenTracker.setIcon(
            QgsApplication.getThemeIcon('/mActionHelpAPI.png'))

        self.actionSaveAll.triggered.connect(lambda: self.saveResults(True))
        self.actionSaveSelected.triggered.connect(
            lambda: self.saveResults(False))

        self.resultsTree.clear()

        results = report.results

        allResults = defaultdict(list)
        for result in results:
            test = result.test
            allResults[test.group].append(result)

        for group, groupResults in allResults.iteritems():
            groupItem = QTreeWidgetItem()
            groupItem.setText(0, group)
            for result in groupResults:
                resultItem = QTreeWidgetItem()
                resultItem.result = result
                resultItem.setText(0, result.test.name)
                resultItem.setForeground(0, self.resultColor[result.status])
                groupItem.addChild(resultItem)
            self.resultsTree.addTopLevelItem(groupItem)

        self.resultsTree.expandAll()
        self.resultsTree.itemClicked.connect(self.itemClicked)
        self.resultsTree.customContextMenuRequested.connect(self.showPopupMenu)
Exemplo n.º 14
0
    def refresh(self):
        self.uiStatusTREE.blockSignals(True)
        self.uiStatusTREE.setUpdatesEnabled(False)

        self.uiStatusTREE.clear()

        # collect the data from the prefs
        ordered = self._statusPrefs.values('order').items()

        # sort the items by their order
        ordered.sort(lambda x, y: cmp(x[1], y[1]))

        # add the statuses to the tree
        from PyQt4.QtCore import Qt
        from PyQt4.QtGui import QTreeWidgetItem, QPalette, QIcon

        for status, order in ordered:
            # grab info from the hash
            icon, display_name = self._statusHash.get(status, ('', 'Missing'))

            item = QTreeWidgetItem([display_name, status])
            item.setIcon(0, QIcon(icon))

            # check the item if it is enabled
            enabled = self._statusPrefs.value(status, 'enabled')
            item.setCheckState(0, Qt.Checked if enabled else Qt.Unchecked)

            # set some ui options for the status name to hide it a bit
            item.setTextAlignment(1, Qt.AlignRight | Qt.AlignVCenter)
            item.setForeground(
                1,
                self.uiStatusTREE.palette().color(QPalette.Base).darker(140))

            # add to the tree
            self.uiStatusTREE.addTopLevelItem(item)

        self.uiStatusTREE.blockSignals(False)
        self.uiStatusTREE.setUpdatesEnabled(True)
 def __createEntry(self, info):
     """
     Private method to create a list entry based on the provided info.
     
     @param info tuple giving the info for the entry
     """
     infoList = QStringList() \
         << info[0] \
         << info[1] \
         << info[2] \
         << (info[3] and self.trUtf8("Yes") or self.trUtf8("No")) \
         << (info[4] and self.trUtf8("Yes") or self.trUtf8("No")) \
         << info[5]
     itm = QTreeWidgetItem(self.pluginList, infoList)
     if info[6]:
         # plugin error
         for col in range(self.pluginList.columnCount()):
             itm.setForeground(col, QBrush(Qt.red))
     itm.setTextAlignment(self.__autoActivateColumn, Qt.AlignHCenter)
     itm.setTextAlignment(self.__activeColumn, Qt.AlignHCenter)
     
     self.pluginList.header().resizeSections(QHeaderView.ResizeToContents)
     self.pluginList.header().setStretchLastSection(True)
Exemplo n.º 16
0
 def refresh( self ):
     self.uiStatusTREE.blockSignals(True)
     self.uiStatusTREE.setUpdatesEnabled(False)
     
     self.uiStatusTREE.clear()
     
     # collect the data from the prefs
     ordered = self._statusPrefs.values('order').items()
     
     # sort the items by their order
     ordered.sort( lambda x,y: cmp( x[1], y[1] ) )
     
     # add the statuses to the tree
     from PyQt4.QtCore   import Qt
     from PyQt4.QtGui    import QTreeWidgetItem, QPalette, QIcon
     
     for status, order in ordered:
         # grab info from the hash
         icon, display_name = self._statusHash.get(status,('','Missing'))
         
         item = QTreeWidgetItem([display_name,status])
         item.setIcon( 0, QIcon(icon) )
         
         # check the item if it is enabled
         enabled = self._statusPrefs.value(status,'enabled')
         item.setCheckState( 0, Qt.Checked if enabled else Qt.Unchecked )
         
         # set some ui options for the status name to hide it a bit
         item.setTextAlignment( 1, Qt.AlignRight | Qt.AlignVCenter )
         item.setForeground( 1, self.uiStatusTREE.palette().color(QPalette.Base).darker(140) )
         
         # add to the tree
         self.uiStatusTREE.addTopLevelItem(item)
         
     self.uiStatusTREE.blockSignals(False)
     self.uiStatusTREE.setUpdatesEnabled(True)
Exemplo n.º 17
0
    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)

            if not instances:
                self._items[service] = serviceItem
                btn = JobButtons(self._client, service, None, serviceItem)
                self.setItemWidget(serviceItem, 2, btn)
                if descrs.get(service):
                    serviceItem.setText(0, descrs[service])
            else:
                self._items[service] = (serviceItem, {})
                btns = []
                for instance in instances:
                    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][1][instance] = instanceItem
                multibtn = MultiJobButtons(btns)
                self.setItemWidget(serviceItem, 2, multibtn)

        self.expandAll()
Exemplo n.º 18
0
    def add_node(self, parentItem, path, type):
        item = QTreeWidgetItem(parentItem)
        item.setText(0, path_leaf(path))
        buttonGroup = QButtonGroup()

        isNewFile = type is "UNTRACKED"
        isModifiedFile = type is "MODIFIED"
        isMissing = type is "MISSING"
        isDirectory = type is "DIR"

        if isNewFile:
            item.setText(1, type)
            item.setForeground(1, QBrush(QColor(0, 255, 0)))
        if isModifiedFile:
            item.setText(1, type)
            item.setForeground(1, QBrush(QColor(0, 0, 255)))
        if isMissing:
            item.setText(1, type)
            item.setForeground(1, QBrush(QColor(255, 0, 0)))
        if isDirectory:
            for i in range(self.tree.columnCount()):
                item.setBackground(i, QBrush(QColor(230, 230, 255)))

        # must keep reference to buttonGroup for its callback to work
        parent_data = self.retrieve_data(parentItem)
        if parent_data != None:
            path = os.path.join(parent_data[0], path)
        self.attach_data(item, (path, buttonGroup, type))

        for i in range(self.uncheckableColumns, self.tree.columnCount()):
            if i == self.tree.columnCount() - 7 and isMissing:
                continue # option to add not enabled for missing files
            if i == self.tree.columnCount() - 4 and isNewFile:
                continue # option to resolve not enabled for new files
            if i == self.tree.columnCount() - 3 and not isMissing:
                continue # option to stop tracking enabled only for missing files
            if i == self.tree.columnCount() - 2 and not isNewFile:
                continue # option to delete enabled only for untracked files
            if i == self.tree.columnCount() - 2 and isDirectory:
                continue # option to delete not enabled for directories, too dangerous
            button = QRadioButton()
            buttonGroup.addButton(button, i - self.uncheckableColumns) # id is the index
            button.treeItem = item
            self.tree.setItemWidget(item, i, button)

        buttonGroup.buttonClicked.connect(self.tree_item_radio_clicked)

        return item
Exemplo n.º 19
0
    def updateHelpIndex(self):
        # Add commands group
        commands = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Commands')]
          , cmake_help_parser.help_category.COMMAND
          )
        deprecated = [cmd[0] for cmd in cmake_help_parser.get_cmake_deprecated_commands_list()]
        for cmd in cmake_help_parser.get_cmake_commands_list():
            c = QTreeWidgetItem(
                commands
              , [cmd]
              , cmake_help_parser.help_category.HELP_ITEM
              )
            global _cmake_completion_model
            schema = KColorScheme(QPalette.Normal, KColorScheme.Selection)
            if _cmake_completion_model.has_completion_for_command(cmd):
                c.setForeground(0, schema.foreground(KColorScheme.PositiveText).color())
            else:
                if cmd in deprecated:
                    c.setForeground(0, schema.foreground(KColorScheme.NeutralText).color())
                else:
                    c.setForeground(0, schema.foreground(KColorScheme.NegativeText).color())

        # Add modules group
        standard_modules = cmake_help_parser.get_cmake_modules_list()
        total_modules_count = len(standard_modules)
        custom_modules = {}
        for path in kate.sessionConfiguration[settings.AUX_MODULE_DIRS]:
            modules_list = cmake_help_parser.get_cmake_modules_list(path)
            filtered_modules_list = [mod for mod in modules_list if mod not in standard_modules]
            filtered_modules_list.sort()
            custom_modules[
                i18nc('@item:inlistbox', 'Modules from %1 (%2)', path, len(path))
              ] = filtered_modules_list
            total_modules_count += len(filtered_modules_list)
        custom_modules[
            i18nc('@item:inlistbox', 'Standard modules (%1)', len(standard_modules))
          ] = standard_modules
        #
        modules = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Modules (%1)', total_modules_count)]
          , cmake_help_parser.help_category.MODULE
          )
        for from_path, modules_list in custom_modules.items():
            ss_item = QTreeWidgetItem(
                modules
              , [from_path]
              , cmake_help_parser.help_category.MODULE
              )
            for mod in modules_list:
                m = QTreeWidgetItem(
                    ss_item
                  , [mod]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )

        # Add policies group
        policies = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Policies')]
          , cmake_help_parser.help_category.POLICY
          )
        for pol in cmake_help_parser.get_cmake_policies_list():
            p = QTreeWidgetItem(
                policies
              , [pol]
              , cmake_help_parser.help_category.HELP_ITEM
              )

        # Add properties group
        properties = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Properties')]
          , cmake_help_parser.help_category.PROPERTY
          )
        for subsection, props_list in cmake_help_parser.get_cmake_properties_list().items():
            ss_item = QTreeWidgetItem(
                properties
              , [subsection]
              , cmake_help_parser.help_category.PROPERTY
              )
            for prop in props_list:
                v = QTreeWidgetItem(
                    ss_item
                  , [prop[0]]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )
                v.setToolTip(0, prop[1])

        # Add variables group
        variables = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Variables')]
          , cmake_help_parser.help_category.VARIABLE
          )
        for subsection, vars_list in cmake_help_parser.get_cmake_vars_list().items():
            ss_item = QTreeWidgetItem(
                variables
              , [subsection]
              , cmake_help_parser.help_category.VARIABLE
              )
            for var in vars_list:
                v = QTreeWidgetItem(
                    ss_item
                  , [var[0]]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )
                v.setToolTip(0, var[1])
        #
        self.vewHelpPage.helpTargets.resizeColumnToContents(0)
Exemplo n.º 20
0
	def populateTree(self):
		"""Populates tree view with information from ItemTracker."""
		if len(self.errorIds):
			self.mkError("{0} entries do not have valid "
			"ItemTracker IDs in Bionumerics.".format(len(self.errorIds)))

			for key, msg in self.errorIds.iteritems():
				self.mkError("KEY: {0} {1}".format(key, msg))

		if not len(self.selectedIds):
			self.statusbar.showMessage("No items to process", 5000)
			return

		parents = {}
		headers = ["Items", "Selected", "SelectedBy", "Viability", "Volume",
				 "DNA concentration", "UserName", "TubePresent", "InputDate",
				 "AlternID", "Status"]

		self.treeWidget.setItemsExpandable(True)
		self.treeWidget.setAlternatingRowColors(True)
		self.treeWidget.setColumnCount(len(headers))
		self.treeWidget.setHeaderLabels(headers)

		msg = "Getting information from ItemTracker. Please wait..."
		self.statusbar.showMessage(msg)

		self.progressBar.setMinimum(0)
		self.progressBar.setMaximum(0)
		self.progressBar.show()

		(treeData, self.itemProperties,
		 message) = lims.GetDictionary((self.selectedIds.keys()))

		if len(message):
			for msg in message:
				self.mkError("ItemTracker error: {0}".format(msg))

		if not len(treeData):
			self.mkError("Could not get data from ItemTracker for"
						"selected entries")
			self.statusBar().clearMessage()
			self.progressBar.hide()
			self.updateUi()
			return

		# bugfix: If ItemType property does not exist for the first item
		# self.database is not set and tree view is not updated.
		db = None
		if not self.database:
			for item in self.itemProperties.values():
				try:
					db = item["ItemType"]
				except KeyError:
					pass

				if db == "Salmonella":
					self.database = db
					break
				elif db == "Listeria":
					self.database = db
					break

		self.progressBar.setMaximum(len(treeData))
		count = 0
		for key, value  in treeData.iteritems():
			count += 1
			self.progressBar.setValue(count)
			if not(value and isinstance(value, dict)):
				self.mkWarn("No data returned for key {0}".format(key))
				continue

			items = {}
			items[key] = value
			for results in self.getData(items, key):
				parent = parents.get(results[0])

				if not parent:
					parent_id = self.selectedIds[results[0]]
					self.strainInfo[parent_id] = {self.database:[],
												"Frozen Stock":[], "DNA":[]}
					parent = QTreeWidgetItem(self.treeWidget,
					[unicode(parent_id)])

					brush = QBrush()
					brush.setColor(Qt.blue)
					parent.setForeground(0, brush)
					parent.setIcon(0, QIcon(":/branch-closed.png"))
					parent.setData(0, Qt.CheckStateRole, QVariant())
					parents[results[0]] = parent

				for children in results[1]:
					itemName = self.itemProperties[children]["ItemName"]
					if not self.itemIds.get(itemName):
						self.itemIds[itemName] = children

					childprops = []
					childprops.append(unicode(itemName))

					for header in headers[1:]:
						try:
							childprop = self.itemProperties[children][header]

							if childprop is None or childprop == "":
								childprops.append(unicode(""))
							else:
								childprops.append(unicode(childprop))
						except KeyError:
							childprops.append(unicode(""))
							continue

					childs = parents.get(children)
					if not childs:
						childs = QTreeWidgetItem(parent, childprops)

						if self.itemProperties[children]["TubePresent"] == "-":
							childs.setBackgroundColor(0, QColor(232, 87, 82))
							childs.setForeground(0, QColor(255, 255, 255))

						if self.itemProperties[children]["Selected"] == "yes":
							childs.setBackgroundColor(0, QColor(119, 183, 83))
							childs.setForeground(0, QColor(255, 255, 255))

						itype = self.itemProperties[children]["ItemType"]
						if itype:
							self.strainInfo[parent_id][itype].append(itemName)
						parents[children] = childs
					childs.setCheckState(0, Qt.Unchecked)

		self.treeWidget.expandAll()
		for i in range(len(headers)):
			self.treeWidget.resizeColumnToContents(i)
		if not self.treeWidget.isEnabled():
			self.treeWidget.setEnabled(True)
		self.mkInfo("Processed <b>{0}</b> entries".format(len(treeData)))

		self.progressBar.setValue(len(treeData))
		self.progressBar.hide()
		self.populatedTree = True
		self.updateUi()
		self.statusbar.showMessage("Ready", 5000)