Пример #1
0
    def updateItems(self):
        if not self._model:
            return

        if self.currentItem():
            self._lastID = self.currentItem().data(0, Qt.UserRole)

        self._updating = True
        self.clear()
        plots = self._model.getPlotsByImportance()

        h = [self.tr("Main"), self.tr("Secondary"), self.tr("Minor")]
        for i in range(3):
            cat = QTreeWidgetItem(self, [h[i]])
            cat.setBackground(0, QBrush(QColor(S.highlightLight)))
            cat.setForeground(0, QBrush(QColor(S.highlightedTextDark)))
            cat.setTextAlignment(0, Qt.AlignCenter)
            f = cat.font(0)
            f.setBold(True)
            cat.setFont(0, f)
            cat.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            self.addTopLevelItem(cat)
            # cat.setChildIndicatorPolicy(cat.DontShowIndicator)

            for ID in plots[i]:
                name = self._model.getPlotNameByID(ID)
                if not self._filter.lower() in name.lower():
                    continue
                item = QTreeWidgetItem(cat, [name])
                item.setData(0, Qt.UserRole, ID)
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

                if self._showSubPlot:

                    f = item.font(0)
                    f.setBold(True)
                    item.setFont(0, f)

                    for subID, name, summary in self._model.getSubPlotsByID(
                            ID):
                        sub = QTreeWidgetItem(item, [name])
                        # sub.setData(0, Qt.UserRole, "{}:{}".format(ID, subID))
                        sub.setData(0, Qt.UserRole, ID)

                if ID == self._lastID:
                    self.setCurrentItem(item)

        self.expandAll()
        self._updating = False
Пример #2
0
    def updateItems(self):
        if not self._model:
            return

        if self.currentItem():
            self._lastID = self.currentItem().data(0, Qt.UserRole)

        self._updating = True
        self.clear()
        plots = self._model.getPlotsByImportance()

        h = [self.tr("Main"), self.tr("Secondary"), self.tr("Minor")]
        for i in range(3):
            cat = QTreeWidgetItem(self, [h[i]])
            cat.setBackground(0, QBrush(QColor(S.highlightLight)))
            cat.setForeground(0, QBrush(QColor(S.highlightedTextDark)))
            cat.setTextAlignment(0, Qt.AlignCenter)
            f = cat.font(0)
            f.setBold(True)
            cat.setFont(0, f)
            cat.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            self.addTopLevelItem(cat)
            # cat.setChildIndicatorPolicy(cat.DontShowIndicator)

            for ID in plots[i]:
                name = self._model.getPlotNameByID(ID)
                if not self._filter.lower() in name.lower():
                    continue
                item = QTreeWidgetItem(cat, [name])
                item.setData(0, Qt.UserRole, ID)
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

                if self._showSubPlot:

                    f = item.font(0)
                    f.setBold(True)
                    item.setFont(0, f)

                    for subID, name, summary in self._model.getSubPlotsByID(ID):
                        sub = QTreeWidgetItem(item, [name])
                        # sub.setData(0, Qt.UserRole, "{}:{}".format(ID, subID))
                        sub.setData(0, Qt.UserRole, ID)

                if ID == self._lastID:
                    self.setCurrentItem(item)

        self.expandAll()
        self._updating = False
Пример #3
0
    def nodesChanged(self, address, nodeid, connidx):
        if nodeid[0] < len(self.hosts):
            host = self.hosts[nodeid[0]]
        else:
            host = QTreeWidgetItem(self.nodetree)
            hostname = address
            if address in ['127.0.0.1', 'localhost']:
                hostname = 'This computer'
            f = host.font(0)
            f.setBold(True)
            host.setExpanded(True)
            btn = QPushButton(self.nodetree)
            btn.setText(hostname)
            btn.setFlat(True)
            btn.setStyleSheet('font-weight:bold')

            btn.setIcon(
                QIcon(settings.data_path + '/graphics/icons/addnode.svg'))
            btn.setIconSize(QSize(24, 16))
            btn.setLayoutDirection(Qt.RightToLeft)
            btn.setMaximumHeight(16)
            btn.clicked.connect(manager.instance.addNode)
            self.nodetree.setItemWidget(host, 0, btn)
            self.hosts.append(host)

        node = QTreeWidgetItem(host)
        node.setText(0, '%d:%d <init>' % nodeid)
        node.setText(1, '00:00:00')
        node.connidx = connidx
        node.nodeid = nodeid
        self.nodes.append(node)
Пример #4
0
    def nodesChanged(self, address, nodeid, connidx):
        if nodeid[0] < len(self.hosts):
            host = self.hosts[nodeid[0]]
        else:
            host = QTreeWidgetItem(self.nodetree)
            hostname = address
            if address in ['127.0.0.1', 'localhost']:
                hostname = 'This computer'
            f = host.font(0)
            f.setBold(True)
            # host.setFont(0, f)
            # host.setText(0, hostname)
            host.setExpanded(True)
            btn = QPushButton(self.nodetree)
            # btn.setFont(0, f)
            btn.setText(hostname)
            btn.setFlat(True)
            btn.setStyleSheet('font-weight:bold')

            btn.setIcon(QIcon(data_path + '/graphics/icons/addnode.svg'))
            btn.setIconSize(QSize(24, 16))
            btn.setLayoutDirection(Qt.RightToLeft)
            btn.setMaximumHeight(16)
            btn.clicked.connect(manager.instance.addNode)
            self.nodetree.setItemWidget(host, 0, btn)
            self.hosts.append(host)

        node = QTreeWidgetItem(host)
        node.setText(0, '%d:%d <init>' % nodeid)
        node.setText(1, '00:00:00')
        node.connidx = connidx
        node.nodeid  = nodeid
        self.nodes.append(node)
Пример #5
0
 def __createResultItem(self, file, statements, executed, coverage,
                        excluded, missing):
     """
     Private method to create an entry in the result list.
     
     @param file filename of file (string)
     @param statements amount of statements (integer)
     @param executed amount of executed statements (integer)
     @param coverage percent of coverage (integer)
     @param excluded list of excluded lines (string)
     @param missing list of lines without coverage (string)
     """
     itm = QTreeWidgetItem(self.resultList, [
         file,
         str(statements),
         str(executed),
         "{0:.0f}%".format(coverage),
         excluded,
         missing
     ])
     for col in range(1, 4):
         itm.setTextAlignment(col, Qt.AlignRight)
     if statements != executed:
         font = itm.font(0)
         font.setBold(True)
         for col in range(itm.columnCount()):
             itm.setFont(col, font)
Пример #6
0
 def __generateItem(self, revision, changeset, signature):
     """
     Private method to generate a patch item in the list of patches.
     
     @param revision revision number (string)
     @param changeset changeset of the bookmark (string)
     @param signature signature of the changeset (string)
     """
     if revision == "" and changeset == "":
         QTreeWidgetItem(self.signaturesList, [signature])
     else:
         revString = "{0:>7}:{1}".format(revision, changeset)
         topItems = self.signaturesList.findItems(
             revString, Qt.MatchExactly)
         if len(topItems) == 0:
             # first signature for this changeset
             topItm = QTreeWidgetItem(self.signaturesList, [
                 "{0:>7}:{1}".format(revision, changeset)])
             topItm.setExpanded(True)
             font = topItm.font(0)
             font.setBold(True)
             topItm.setFont(0, font)
         else:
             topItm = topItems[0]
         QTreeWidgetItem(topItm, [signature])
Пример #7
0
 def __generateItem(self, revision, changeset, signature):
     """
     Private method to generate a patch item in the list of patches.
     
     @param revision revision number (string)
     @param changeset changeset of the bookmark (string)
     @param signature signature of the changeset (string)
     """
     if revision == "" and changeset == "":
         QTreeWidgetItem(self.signaturesList, [signature])
     else:
         revString = "{0:>7}:{1}".format(revision, changeset)
         topItems = self.signaturesList.findItems(revString,
                                                  Qt.MatchExactly)
         if len(topItems) == 0:
             # first signature for this changeset
             topItm = QTreeWidgetItem(
                 self.signaturesList,
                 ["{0:>7}:{1}".format(revision, changeset)])
             topItm.setExpanded(True)
             font = topItm.font(0)
             font.setBold(True)
             topItm.setFont(0, font)
         else:
             topItm = topItems[0]
         QTreeWidgetItem(topItm, [signature])
Пример #8
0
    def __populateVenvList(self):
        """
        Private method to populate the list of virtual environments.
        """
        environments = self.__manager.getEnvironmentEntries()
        for venvName in environments:
            itm = QTreeWidgetItem(self.venvList, [
                venvName,
                environments[venvName]["path"],
                environments[venvName]["interpreter"],
            ])
            itm.setData(0, VirtualenvManagerDialog.PythonVariantRole,
                        environments[venvName]["variant"])
            itm.setData(0, VirtualenvManagerDialog.IsGlobalRole,
                        environments[venvName]["is_global"])
            itm.setData(0, VirtualenvManagerDialog.IsCondaRole,
                        environments[venvName]["is_conda"])
            itm.setData(0, VirtualenvManagerDialog.IsRemoteRole,
                        environments[venvName]["is_remote"])
            itm.setData(0, VirtualenvManagerDialog.ExecPathRole,
                        environments[venvName]["exec_path"])

            # show remote environments with underlined font
            if environments[venvName]["is_remote"]:
                font = itm.font(0)
                font.setUnderline(True)
                for column in range(itm.columnCount()):
                    itm.setFont(column, font)
            else:
                # local environments

                # show global environments with bold font
                if environments[venvName]["is_global"]:
                    font = itm.font(0)
                    font.setBold(True)
                    for column in range(itm.columnCount()):
                        itm.setFont(column, font)

                # show Anaconda environments with italic font
                if environments[venvName]["is_conda"]:
                    font = itm.font(0)
                    font.setItalic(True)
                    for column in range(itm.columnCount()):
                        itm.setFont(column, font)

        self.__resizeSections()
    def __refreshCookiesList(self):
        """
        Private slot to refresh the cookies list.
        """
        QApplication.setOverrideCursor(Qt.WaitCursor)

        cookies = self.__manager.flashCookies()
        self.cookiesList.clear()

        counter = 0
        originDict = {}
        for cookie in cookies:
            cookieOrigin = cookie.origin
            if cookieOrigin.startswith("."):
                cookieOrigin = cookieOrigin[1:]

            if cookieOrigin in originDict:
                itm = QTreeWidgetItem(originDict[cookieOrigin])
            else:
                newParent = QTreeWidgetItem(self.cookiesList)
                newParent.setText(0, cookieOrigin)
                newParent.setIcon(0, UI.PixmapCache.getIcon("dirOpen.png"))
                self.cookiesList.addTopLevelItem(newParent)
                originDict[cookieOrigin] = newParent

                itm = QTreeWidgetItem(newParent)

            suffix = ""
            if cookie.path.startswith(
                    self.__manager.flashPlayerDataPath() +
                    "/macromedia.com/support/flashplayer/sys"):
                suffix = self.tr(" (settings)")

            if cookie.path + "/" + cookie.name in (
                    self.__manager.newCookiesList()):
                suffix += self.tr(" [new]")
                font = itm.font(0)
                font.setBold(True)
                itm.setFont(font)
                itm.parent().setExpanded(True)

            itm.setText(
                0,
                self.tr("{0}{1}",
                        "name and suffix").format(cookie.name, suffix))
            itm.setData(0, Qt.UserRole, cookie)

            counter += 1
            if counter > 100:
                QApplication.processEvents()
                counter = 0

        self.removeAllButton.setEnabled(
            self.cookiesList.topLevelItemCount() > 0)
        self.removeButton.setEnabled(False)

        QApplication.restoreOverrideCursor()
Пример #10
0
 def addTopLevelItem(self, name):
     item = QTreeWidgetItem(self.tree, [name])
     item.setBackground(0, QBrush(QColor(S.highlightLight)))
     item.setForeground(0, QBrush(QColor(S.highlightedTextDark)))
     item.setTextAlignment(0, Qt.AlignCenter)
     item.setFlags(Qt.ItemIsEnabled)
     f = item.font(0)
     f.setBold(True)
     item.setFont(0, f)
     return item
Пример #11
0
 def addTopLevelItem(self, name):
     item = QTreeWidgetItem(self.tree, [name])
     item.setBackground(0, QBrush(QColor(S.highlightLight)))
     item.setForeground(0, QBrush(QColor(S.highlightedTextDark)))
     item.setTextAlignment(0, Qt.AlignCenter)
     item.setFlags(Qt.ItemIsEnabled)
     f = item.font(0)
     f.setBold(True)
     item.setFont(0, f)
     return item
Пример #12
0
 def __refreshCookiesList(self):
     """
     Private slot to refresh the cookies list.
     """
     QApplication.setOverrideCursor(Qt.WaitCursor)
     
     cookies = self.__manager.flashCookies()
     self.cookiesList.clear()
     
     counter = 0
     originDict = {}
     for cookie in cookies:
         cookieOrigin = cookie.origin
         if cookieOrigin.startswith("."):
             cookieOrigin = cookieOrigin[1:]
         
         if cookieOrigin in originDict:
             itm = QTreeWidgetItem(originDict[cookieOrigin])
         else:
             newParent = QTreeWidgetItem(self.cookiesList)
             newParent.setText(0, cookieOrigin)
             newParent.setIcon(0, UI.PixmapCache.getIcon("dirOpen.png"))
             self.cookiesList.addTopLevelItem(newParent)
             originDict[cookieOrigin] = newParent
             
             itm = QTreeWidgetItem(newParent)
         
         suffix = ""
         if cookie.path.startswith(
             self.__manager.flashPlayerDataPath() +
                 "/macromedia.com/support/flashplayer/sys"):
             suffix = self.tr(" (settings)")
         
         if cookie.path + "/" + cookie.name in \
                 self.__manager.newCookiesList():
             suffix += self.tr(" [new]")
             font = itm.font(0)
             font.setBold(True)
             itm.setFont(font)
             itm.parent().setExpanded(True)
         
         itm.setText(0, self.tr("{0}{1}", "name and suffix").format(
             cookie.name, suffix))
         itm.setData(0, Qt.UserRole, cookie)
         
         counter += 1
         if counter > 100:
             QApplication.processEvents()
             counter = 0
     
     self.removeAllButton.setEnabled(
         self.cookiesList.topLevelItemCount() > 0)
     self.removeButton.setEnabled(False)
     
     QApplication.restoreOverrideCursor()
Пример #13
0
    def render_association_to_row(self, association, row: QTreeWidgetItem):
        uploaded = association["file"]["createdAt"][:-1]  # Trim trailing "Z"
        uploaded = datetime.fromisoformat(uploaded)

        row.setText(Cols.filename, association["file"]["filename"])
        row.setText(Cols.version, association["file"]["version"])
        row.setText(Cols.uploaded_at, uploaded.strftime(self.time_format))
        row.setText(Cols.description, association["file"]["description"])

        if association["file"]["owner"] == "epc":
            font: QFont = row.font(Cols.creator)
            font.setBold(True)
            row.setFont(Cols.creator, font)
            row.setForeground(Cols.creator, self.color_blue)
            row.setFont(Cols.creator, row.font(Cols.creator))
            row.setText(Cols.creator, "EPC Power")
        else:
            row.setFont(Cols.creator, row.font(Cols.uploaded_at))
            row.setForeground(Cols.creator, self.color_black)
            row.setText(Cols.creator, association["file"].get("createdBy"))

        if association.get("model"):
            model_name = " " + association["model"]["name"]

            if association.get("customer"):
                relationship = Relationships.customer
                rel_text = association["customer"]["name"] + "," + model_name
            elif association.get("site"):
                relationship = Relationships.site
                rel_text = association["site"]["name"] + "," + model_name
            else:
                relationship = Relationships.model
                rel_text = "All" + model_name
        else:
            relationship = Relationships.inverter
            rel_text = "SN: " + association["inverter"]["serialNumber"]

        self.show_relationship(row, relationship, rel_text)
Пример #14
0
 def nodesChanged(self, data):
     for host_id, host_data in data.items():
         host = self.hosts.get(host_id)
         if not host:
             host = QTreeWidgetItem(self.nodetree)
             self.maxhostnum += 1
             host.host_num = self.maxhostnum
             host.host_id = host_id
             hostname = 'This computer' if host_id == bs.net.get_hostid(
             ) else str(host_id)
             f = host.font(0)
             f.setBold(True)
             host.setExpanded(True)
             host.setText(0, hostname)
             host.setText(1, f'(nodes: {len(host_data["nodes"])})')
             host.nodes = host_data['nodes']
             self.hosts[host_id] = host
Пример #15
0
    def updateItems(self):
        if not self._model:
            return

        if self.currentItem():
            self._lastID = self.currentItem().data(0, Qt.UserRole)

        self._updating = True
        self.clear()
        characters = self._model.getCharactersByImportance()

        h = [self.tr("Main"), self.tr("Secondary"), self.tr("Minor")]

        for i in range(3):
            # Create category item
            cat = QTreeWidgetItem(self, [h[i]])
            cat.setBackground(0, QBrush(QColor(S.highlightLight)))
            cat.setForeground(0, QBrush(QColor(S.highlightedTextDark)))
            cat.setTextAlignment(0, Qt.AlignCenter)
            f = cat.font(0)
            f.setBold(True)
            cat.setFont(0, f)
            self.addTopLevelItem(cat)
            # cat.setChildIndicatorPolicy(cat.DontShowIndicator)

            for c in characters[i]:
                name = c.name()
                # Check if name passes filter
                if not self._filter.lower() in name.lower():
                    continue

                item = QTreeWidgetItem(cat, [name])
                item.setData(0, Qt.UserRole, c.ID())
                px = QPixmap(32, 32)
                color = QColor(c.color())
                px.fill(color)
                item.setIcon(0, QIcon(px))

                if c.ID() == self._lastID:
                    self.setCurrentItem(item)

        self.expandAll()
        self._updating = False
Пример #16
0
    def updateItems(self):
        if not self._model:
            return

        if self.currentItem():
            self._lastID = self.currentItem().data(0, Qt.UserRole)

        self._updating = True
        self.clear()
        characters = self._model.getCharactersByImportance()

        h = [self.tr("Main"), self.tr("Secondary"), self.tr("Minor")]

        for i in range(3):
            # Create category item
            cat = QTreeWidgetItem(self, [h[i]])
            cat.setBackground(0, QBrush(QColor(S.highlightLight)))
            cat.setForeground(0, QBrush(QColor(S.highlightedTextDark)))
            cat.setTextAlignment(0, Qt.AlignCenter)
            f = cat.font(0)
            f.setBold(True)
            cat.setFont(0, f)
            self.addTopLevelItem(cat)
            # cat.setChildIndicatorPolicy(cat.DontShowIndicator)

            for c in characters[i]:
                name = c.name()
                # Check if name passes filter
                if not self._filter.lower() in name.lower():
                    continue

                item = QTreeWidgetItem(cat, [name])
                item.setData(0, Qt.UserRole, c.ID())
                px = QPixmap(32, 32)
                color = QColor(c.color())
                px.fill(color)
                item.setIcon(0, QIcon(px))

                if c.ID() == self._lastID:
                    self.setCurrentItem(item)

        self.expandAll()
        self._updating = False
Пример #17
0
    def nodesChanged(self, data):
        for host_id, host_data in data.items():
            host = self.hosts.get(host_id)
            if not host:
                host = QTreeWidgetItem(self.nodetree)
                self.maxhostnum += 1
                host.host_num = self.maxhostnum
                host.host_id = host_id
                hostname = 'This computer' if host_id == bs.net.get_hostid(
                ) else str(host_id)
                f = host.font(0)
                f.setBold(True)
                host.setExpanded(True)
                btn = QPushButton(self.nodetree)
                btn.host_id = host_id
                btn.setText(hostname)
                btn.setFlat(True)
                btn.setStyleSheet('font-weight:bold')

                btn.setIcon(
                    QIcon(
                        os.path.join(bs.settings.gfx_path,
                                     'icons/addnode.svg')))
                btn.setIconSize(QSize(24, 16))
                btn.setLayoutDirection(Qt.RightToLeft)
                btn.setMaximumHeight(16)
                btn.clicked.connect(self.buttonClicked)
                self.nodetree.setItemWidget(host, 0, btn)
                self.hosts[host_id] = host

            for node_num, node_id in enumerate(host_data['nodes']):
                if node_id not in self.nodes:
                    # node_num = node_id[-2] * 256 + node_id[-1]
                    node = QTreeWidgetItem(host)
                    node.setText(
                        0, '{}:{} <init>'.format(host.host_num, node_num + 1))
                    node.setText(1, '00:00:00')
                    node.node_id = node_id
                    node.node_num = node_num + 1
                    node.host_num = host.host_num

                    self.nodes[node_id] = node
Пример #18
0
 def __createEntry(self, description, entryText, entryVersion):
     """
     Private method to generate a program entry.
     
     @param description descriptive text (string)
     @param entryText text to show (string)
     @param entryVersion version string to show (string).
     """
     itm = QTreeWidgetItem(self.programsList, [description])
     font = itm.font(0)
     font.setBold(True)
     itm.setFont(0, font)
     
     if len(entryVersion):
         QTreeWidgetItem(itm, [entryText, entryVersion])
         itm.setExpanded(True)
     else:
         itm.setText(1, self.tr("(not found)"))
     QApplication.processEvents()
     self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
     self.programsList.header().setStretchLastSection(True)
Пример #19
0
    def __createEntry(self, description, entryText, entryVersion):
        """
        Private method to generate a program entry.
        
        @param description descriptive text (string)
        @param entryText text to show (string)
        @param entryVersion version string to show (string).
        """
        itm = QTreeWidgetItem(self.programsList, [description])
        font = itm.font(0)
        font.setBold(True)
        itm.setFont(0, font)

        if len(entryVersion):
            QTreeWidgetItem(itm, [entryText, entryVersion])
            itm.setExpanded(True)
        else:
            itm.setText(1, self.tr("(not found)"))
        QApplication.processEvents()
        self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
        self.programsList.header().setStretchLastSection(True)
Пример #20
0
    def updateItems(self):
        if not self._model:
            return

        if self.currentItem():
            self._lastID = self.currentItem().data(0, Qt.UserRole)

        self._updating = True
        self.clear()
        persos = self._model.getPersosByImportance()

        h = [self.tr("Main"), self.tr("Secondary"), self.tr("Minor")]
        for i in range(3):
            cat = QTreeWidgetItem(self, [h[i]])
            cat.setBackground(0, QBrush(QColor(Qt.blue).lighter(190)))
            cat.setForeground(0, QBrush(Qt.darkBlue))
            cat.setTextAlignment(0, Qt.AlignCenter)
            f = cat.font(0)
            f.setBold(True)
            cat.setFont(0, f)
            self.addTopLevelItem(cat)
            # cat.setChildIndicatorPolicy(cat.DontShowIndicator)

            for ID in persos[i]:
                name = self._model.getPersoNameByID(ID)
                if not self._filter.lower() in name.lower():
                    continue
                item = QTreeWidgetItem(cat, [name])
                item.setData(0, Qt.UserRole, ID)
                px = QPixmap(32, 32)
                color = QColor(self._model.getPersoColorByID(ID))
                px.fill(color)
                item.setIcon(0, QIcon(px))

                if ID == self._lastID:
                    self.setCurrentItem(item)

        self.expandAll()
        self._updating = False
Пример #21
0
 def __generateItem(self, commit, name, msg="", bold=False, italic=False):
     """
     Private method to generate a tag item in the tag list.
     
     @param commit commit id of the tag/branch (string)
     @param name name of the tag/branch (string)
     @param msg tag annotation message
     @param bold flag indicating to show the entry in bold (boolean)
     @param italic flag indicating to show the entry in italic (boolean)
     """
     itm = QTreeWidgetItem(self.tagList)
     itm.setData(0, Qt.DisplayRole, commit)
     itm.setData(1, Qt.DisplayRole, name)
     if msg:
         itm.setData(2, Qt.DisplayRole, msg)
     itm.setTextAlignment(0, Qt.AlignRight)
     if bold or italic:
         font = itm.font(1)
         if bold:
             font.setBold(True)
         if italic:
             font.setItalic(True)
         itm.setFont(1, font)
Пример #22
0
    def nodesChanged(self, data):
        for host_id, host_data in data.items():
            host = self.hosts.get(host_id)
            if not host:
                host = QTreeWidgetItem(self.nodetree)
                self.maxhostnum += 1
                host.host_num = self.maxhostnum
                host.host_id = host_id
                hostname = 'This computer' if host_id == bs.net.get_hostid() else str(host_id)
                f = host.font(0)
                f.setBold(True)
                host.setExpanded(True)
                btn = QPushButton(self.nodetree)
                btn.host_id = host_id
                btn.setText(hostname)
                btn.setFlat(True)
                btn.setStyleSheet('font-weight:bold')

                btn.setIcon(QIcon(os.path.join(bs.settings.gfx_path, 'icons/addnode.svg')))
                btn.setIconSize(QSize(24, 16))
                btn.setLayoutDirection(Qt.RightToLeft)
                btn.setMaximumHeight(16)
                btn.clicked.connect(self.buttonClicked)
                self.nodetree.setItemWidget(host, 0, btn)
                self.hosts[host_id] = host

            for node_num, node_id in enumerate(host_data['nodes']):
                if node_id not in self.nodes:
                    # node_num = node_id[-2] * 256 + node_id[-1]
                    node = QTreeWidgetItem(host)
                    node.setText(0, '{}:{} <init>'.format(host.host_num, node_num + 1))
                    node.setText(1, '00:00:00')
                    node.node_id  = node_id
                    node.node_num = node_num + 1
                    node.host_num = host.host_num

                    self.nodes[node_id] = node
Пример #23
0
 def __createResultItem(self, file, statements, executed, coverage,
                        excluded, missing):
     """
     Private method to create an entry in the result list.
     
     @param file filename of file (string)
     @param statements amount of statements (integer)
     @param executed amount of executed statements (integer)
     @param coverage percent of coverage (integer)
     @param excluded list of excluded lines (string)
     @param missing list of lines without coverage (string)
     """
     itm = QTreeWidgetItem(self.resultList, [
         file,
         str(statements),
         str(executed), "{0:.0f}%".format(coverage), excluded, missing
     ])
     for col in range(1, 4):
         itm.setTextAlignment(col, Qt.AlignRight)
     if statements != executed:
         font = itm.font(0)
         font.setBold(True)
         for col in range(itm.columnCount()):
             itm.setFont(col, font)
Пример #24
0
 def __createProgramEntry(self,
                          description,
                          exe,
                          versionCommand="",
                          versionStartsWith="",
                          versionPosition=0,
                          version="",
                          versionCleanup=None,
                          versionRe=None,
                          exeModule=None):
     """
     Private method to generate a program entry.
     
     @param description descriptive text (string)
     @param exe name of the executable program (string)
     @param versionCommand command line switch to get the version info
         (str). If this is empty, the given version will be shown.
     @param versionStartsWith start of line identifying version info
         (string)
     @param versionPosition index of part containing the version info
         (integer)
     @keyparam version version string to show (string)
     @keyparam versionCleanup tuple of two integers giving string positions
         start and stop for the version string (tuple of integers)
     @keyparam versionRe regexp to determine the line identifying version
         info (string). Takes precedence over versionStartsWith.
     @keyparam exeModule list of command line parameters to execute a module
         with the program given in exe (e.g. to execute a Python module)
         (list of str)
     @return version string of detected or given version (string)
     """
     itmList = self.programsList.findItems(description,
                                           Qt.MatchCaseSensitive)
     if itmList:
         itm = itmList[0]
     else:
         itm = QTreeWidgetItem(self.programsList, [description])
     font = itm.font(0)
     font.setBold(True)
     itm.setFont(0, font)
     rememberedExe = exe
     if not exe:
         itm.setText(1, self.tr("(not configured)"))
     else:
         if os.path.isabs(exe):
             if not Utilities.isExecutable(exe):
                 exe = ""
         else:
             exe = Utilities.getExecutablePath(exe)
         if exe:
             available = True
             if (versionCommand
                     and (versionStartsWith != "" or
                          (versionRe is not None and versionRe != ""))
                     and versionPosition):
                 proc = QProcess()
                 proc.setProcessChannelMode(QProcess.MergedChannels)
                 if exeModule:
                     args = exeModule[:] + [versionCommand]
                 else:
                     args = [versionCommand]
                 proc.start(exe, args)
                 finished = proc.waitForFinished(10000)
                 if finished:
                     output = str(proc.readAllStandardOutput(),
                                  Preferences.getSystem("IOEncoding"),
                                  'replace')
                     if (exeModule and exeModule[0] == "-m"
                             and ("ImportError:" in output
                                  or "ModuleNotFoundError:" in output
                                  or proc.exitCode() != 0)):
                         version = self.tr("(module not found)")
                         available = False
                     else:
                         if versionRe is None:
                             versionRe = "^{0}".format(
                                 re.escape(versionStartsWith))
                         versionRe = re.compile(versionRe, re.UNICODE)
                         for line in output.splitlines():
                             if versionRe.search(line):
                                 try:
                                     version = line.split()[versionPosition]
                                     if versionCleanup:
                                         version = version[versionCleanup[
                                             0]:versionCleanup[1]]
                                     break
                                 except IndexError:
                                     version = self.tr("(unknown)")
                                     available = False
                         else:
                             version = self.tr("(unknown)")
                             available = False
                 else:
                     version = self.tr("(not executable)")
                     available = False
             if exeModule:
                 citm = QTreeWidgetItem(
                     itm,
                     ["{0} {1}".format(exe, " ".join(exeModule)), version])
             else:
                 citm = QTreeWidgetItem(itm, [exe, version])
             citm.setData(0, self.ToolAvailableRole, available)
             itm.setExpanded(True)
         else:
             if itm.childCount() == 0:
                 itm.setText(1, self.tr("(not found)"))
             else:
                 citm = QTreeWidgetItem(
                     itm,
                     [rememberedExe, self.tr("(not found)")])
                 citm.setData(0, self.ToolAvailableRole, False)
                 itm.setExpanded(True)
     QApplication.processEvents()
     self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
     self.programsList.header().setStretchLastSection(True)
     return version
Пример #25
0
 def __createProgramEntry(self,
                          description,
                          exe,
                          versionCommand="",
                          versionStartsWith="",
                          versionPosition=0,
                          version="",
                          versionCleanup=None,
                          versionRe=None):
     """
     Private method to generate a program entry.
     
     @param description descriptive text (string)
     @param exe name of the executable program (string)
     @param versionCommand command line switch to get the version info
         (string) if this is empty, the given version will be shown.
     @param versionStartsWith start of line identifying version info
         (string)
     @param versionPosition index of part containing the version info
         (integer)
     @keyparam version version string to show (string)
     @keyparam versionCleanup tuple of two integers giving string positions
         start and stop for the version string (tuple of integers)
     @keyparam versionRe regexp to determine the line identifying version
         info (string). Takes precedence over versionStartsWith.
     @return version string of detected or given version (string)
     """
     itmList = self.programsList.findItems(description,
                                           Qt.MatchCaseSensitive)
     if itmList:
         itm = itmList[0]
     else:
         itm = QTreeWidgetItem(self.programsList, [description])
     font = itm.font(0)
     font.setBold(True)
     itm.setFont(0, font)
     if not exe:
         itm.setText(1, self.tr("(not configured)"))
     else:
         if os.path.isabs(exe):
             if not Utilities.isExecutable(exe):
                 exe = ""
         else:
             exe = Utilities.getExecutablePath(exe)
         if exe:
             if versionCommand and \
                (versionStartsWith != "" or
                 (versionRe is not None and versionRe != "")) and \
                versionPosition:
                 proc = QProcess()
                 proc.setProcessChannelMode(QProcess.MergedChannels)
                 proc.start(exe, [versionCommand])
                 finished = proc.waitForFinished(10000)
                 if finished:
                     output = str(proc.readAllStandardOutput(),
                                  Preferences.getSystem("IOEncoding"),
                                  'replace')
                     if versionRe is None:
                         versionRe = "^{0}".format(
                             re.escape(versionStartsWith))
                     versionRe = re.compile(versionRe, re.UNICODE)
                     for line in output.splitlines():
                         if versionRe.search(line):
                             try:
                                 version = line.split()[versionPosition]
                                 if versionCleanup:
                                     version = version[versionCleanup[0]:
                                                       versionCleanup[1]]
                                 break
                             except IndexError:
                                 version = self.tr("(unknown)")
                     else:
                         version = self.tr("(unknown)")
                 else:
                     version = self.tr("(not executable)")
             QTreeWidgetItem(itm, [exe, version])
             itm.setExpanded(True)
         else:
             itm.setText(1, self.tr("(not found)"))
     QApplication.processEvents()
     self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
     self.programsList.header().setStretchLastSection(True)
     return version
Пример #26
0
    def _populateTree(self):
        """Set the content of the chapter/page tree.
        """
        dblPages = self.dblValue.isChecked()
        wpPage = self.wpValue.value()
        fstPage = self.poValue.value() - 1

        pTotal = 0
        tPages = 1

        theList = []
        for _, tLevel, tTitle, wCount in self._theToC:
            pCount = math.ceil(wCount / wpPage)
            if dblPages:
                pCount += pCount % 2

            pTotal += pCount
            theList.append((tLevel, tTitle, wCount, pCount))

        pMax = pTotal - fstPage

        self.tocTree.clear()
        for tLevel, tTitle, wCount, pCount in theList:
            newItem = QTreeWidgetItem()

            if tPages <= fstPage:
                progPage = numberToRoman(tPages, True)
                progText = ""
            else:
                cPage = tPages - fstPage
                pgProg = 100.0 * (cPage - 1) / pMax if pMax > 0 else 0.0
                progPage = f"{cPage:n}"
                progText = f"{pgProg:.1f}{nwUnicode.U_THSP}%"

            newItem.setIcon(self.C_TITLE,
                            self.theTheme.getIcon("doc_h%d" % tLevel))
            newItem.setText(self.C_TITLE, tTitle)
            newItem.setText(self.C_WORDS, f"{wCount:n}")
            newItem.setText(self.C_PAGES, f"{pCount:n}")
            newItem.setText(self.C_PAGE, progPage)
            newItem.setText(self.C_PROG, progText)

            newItem.setTextAlignment(self.C_WORDS, Qt.AlignRight)
            newItem.setTextAlignment(self.C_PAGES, Qt.AlignRight)
            newItem.setTextAlignment(self.C_PAGE, Qt.AlignRight)
            newItem.setTextAlignment(self.C_PROG, Qt.AlignRight)

            # Make pages and titles/partitions stand out
            if tLevel < 2:
                bFont = newItem.font(self.C_TITLE)
                if tLevel == 0:
                    bFont.setItalic(True)
                else:
                    bFont.setBold(True)
                    bFont.setUnderline(True)
                newItem.setFont(self.C_TITLE, bFont)

            tPages += pCount

            self.tocTree.addTopLevelItem(newItem)

        return
Пример #27
0
 def __createProgramEntry(self, description, exe,
                          versionCommand="", versionStartsWith="",
                          versionPosition=0, version="",
                          versionCleanup=None, versionRe=None):
     """
     Private method to generate a program entry.
     
     @param description descriptive text (string)
     @param exe name of the executable program (string)
     @param versionCommand command line switch to get the version info
         (string) if this is empty, the given version will be shown.
     @param versionStartsWith start of line identifying version info
         (string)
     @param versionPosition index of part containing the version info
         (integer)
     @keyparam version version string to show (string)
     @keyparam versionCleanup tuple of two integers giving string positions
         start and stop for the version string (tuple of integers)
     @keyparam versionRe regexp to determine the line identifying version
         info (string). Takes precedence over versionStartsWith.
     @return version string of detected or given version (string)
     """
     itmList = self.programsList.findItems(
         description, Qt.MatchCaseSensitive)
     if itmList:
         itm = itmList[0]
     else:
         itm = QTreeWidgetItem(self.programsList, [description])
     font = itm.font(0)
     font.setBold(True)
     itm.setFont(0, font)
     if not exe:
         itm.setText(1, self.tr("(not configured)"))
     else:
         if os.path.isabs(exe):
             if not Utilities.isExecutable(exe):
                 exe = ""
         else:
             exe = Utilities.getExecutablePath(exe)
         if exe:
             if versionCommand and \
                (versionStartsWith != "" or
                 (versionRe is not None and versionRe != "")) and \
                versionPosition:
                 proc = QProcess()
                 proc.setProcessChannelMode(QProcess.MergedChannels)
                 proc.start(exe, [versionCommand])
                 finished = proc.waitForFinished(10000)
                 if finished:
                     output = str(proc.readAllStandardOutput(),
                                  Preferences.getSystem("IOEncoding"),
                                  'replace')
                     if versionRe is None:
                         versionRe = "^{0}".format(
                             re.escape(versionStartsWith))
                     versionRe = re.compile(versionRe, re.UNICODE)
                     for line in output.splitlines():
                         if versionRe.search(line):
                             try:
                                 version = line.split()[versionPosition]
                                 if versionCleanup:
                                     version = version[
                                         versionCleanup[0]:versionCleanup[1]
                                     ]
                                 break
                             except IndexError:
                                 version = self.tr("(unknown)")
                     else:
                         version = self.tr("(unknown)")
                 else:
                     version = self.tr("(not executable)")
             QTreeWidgetItem(itm, [exe, version])
             itm.setExpanded(True)
         else:
             itm.setText(1, self.tr("(not found)"))
     QApplication.processEvents()
     self.programsList.header().resizeSections(QHeaderView.ResizeToContents)
     self.programsList.header().setStretchLastSection(True)
     return version
Пример #28
0
    def loadToolsJSON(self, tw):
        json_tools_path = app_dirs.user_config_dir + "/tools_urls.json"
        if not os.path.exists(json_tools_path):  # todo: update if too old
            try:
                r = requests.get(json_url)
                r.raise_for_status()
                with open(json_tools_path, "w") as f:
                    f.write(r.text)
            except requests.exceptions.RequestException as e:
                debug_log(e, logging.ERROR)

        if not os.path.exists(json_tools_path):
            return

        with open(json_tools_path, "r") as tools_url_file:
            tools_json = json.load(tools_url_file)

            tw.setColumnCount(4)
            tw.headerItem().setHidden(False)
            tw.headerItem().setText(0, self.tr("Name"))
            tw.headerItem().setText(1, self.tr("Category"))
            tw.headerItem().setText(2, self.tr("Download"))
            tw.headerItem().setText(3, self.tr("Status"))
            req = QTreeWidgetItem()
            req.setText(0, self.tr("Required"))
            #            req.setCheckState(0,2)
            tw.addTopLevelItem(req)
            opt = QTreeWidgetItem()
            opt.setText(0, self.tr("Optional"))
            #            opt.setCheckState(0,0)
            tw.addTopLevelItem(opt)

            for title, values in tools_json.items():
                item = QTreeWidgetItem()
                item.setText(0, title)
                font = item.font(0)
                font.setBold(True)
                item.setFont(0, font)
                required = values['required']
                platform_s = values['platform']
                if required:
                    req.addChild(item)
                    item.setCheckState(0, 2)
                else:
                    opt.addChild(item)
                    item.setCheckState(0, 0)
                if self.checkInstalled(title):
                    item.setText(3, self.tr("Installed"))
                    item.setDisabled(True)
                    item.setCheckState(0, 2)
                else:
                    item.setText(3, self.tr("Not installed"))
                url = values['url']
                try:
                    url64 = values['url64']
                except KeyError:
                    url64 = ""
                install_dir = values['install_dir']
                if (platform.machine() == "AMD64") and not (url64 == ""):
                    item.setData(0, dataURL, url64)
                else:
                    item.setData(0, dataURL, url)
                item.setData(0, dataInstallDir, install_dir)
                category = values['category']
                item.setText(1, category)
                description = values['description']
                di = QTreeWidgetItem()
                label = QLabel(description)
                label.setWordWrap(True)
                item.addChild(di)
                tw.setItemWidget(di, 0, label)
                tw.setFirstItemColumnSpanned(di, False)
                item.setExpanded(True)
            #        req.setChildIndicatorPolicy(QTreeWidgetItem.DontShowIndicator)
            #        opt.setChildIndicatorPolicy(QTreeWidgetItem.DontShowIndicator)
        req.setExpanded(True)
        opt.setExpanded(True)
        tw.resizeColumnToContents(1)
        tw.resizeColumnToContents(2)
        tw.resizeColumnToContents(3)
        tw.resizeColumnToContents(0)

        delayTimer = QTimer(self)
        delayTimer.timeout.connect(self.getDLsize)
        delayTimer.setInterval(100)
        delayTimer.setSingleShot(True)
        delayTimer.start()
 def __createResultItem(self, file, line, pos, message, fixed, autofixing,
                        ignored):
     """
     Private method to create an entry in the result list.
     
     @param file file name of the file (string)
     @param line line number of issue (integer or string)
     @param pos character position of issue (integer or string)
     @param message message text (string)
     @param fixed flag indicating a fixed issue (boolean)
     @param autofixing flag indicating, that we are fixing issues
         automatically (boolean)
     @param ignored flag indicating an ignored issue (boolean)
     @return reference to the created item (QTreeWidgetItem)
     """
     from .CodeStyleFixer import FixableCodeStyleIssues
     
     if self.__lastFileItem is None:
         # It's a new file
         self.__lastFileItem = QTreeWidgetItem(self.resultList, [file])
         self.__lastFileItem.setFirstColumnSpanned(True)
         self.__lastFileItem.setExpanded(True)
         self.__lastFileItem.setData(0, self.filenameRole, file)
     
     fixable = False
     code, message = message.split(None, 1)
     itm = QTreeWidgetItem(
         self.__lastFileItem,
         ["{0:6}".format(line), code, message])
     if code.startswith(("W", "-")):
         itm.setIcon(1, UI.PixmapCache.getIcon("warning.png"))
     elif code.startswith("N"):
         itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png"))
     elif code.startswith("D"):
         itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png"))
     else:
         itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.png"))
     if fixed:
         itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed.png"))
     elif code in FixableCodeStyleIssues and not autofixing:
         itm.setIcon(0, UI.PixmapCache.getIcon("issueFixable.png"))
         fixable = True
     
     itm.setTextAlignment(0, Qt.AlignRight)
     itm.setTextAlignment(1, Qt.AlignHCenter)
     
     itm.setTextAlignment(0, Qt.AlignVCenter)
     itm.setTextAlignment(1, Qt.AlignVCenter)
     itm.setTextAlignment(2, Qt.AlignVCenter)
     
     itm.setData(0, self.filenameRole, file)
     itm.setData(0, self.lineRole, int(line))
     itm.setData(0, self.positionRole, int(pos))
     itm.setData(0, self.messageRole, message)
     itm.setData(0, self.fixableRole, fixable)
     itm.setData(0, self.codeRole, code)
     itm.setData(0, self.ignoredRole, ignored)
     
     if ignored:
         font = itm.font(0)
         font.setItalic(True)
         for col in range(itm.columnCount()):
             itm.setFont(col, font)
     
     return itm
Пример #30
0
 def __createResultItem(self, filename, line, pos, message, fixed,
                        autofixing, ignored):
     """
     Private method to create an entry in the result list.
     
     @param filename file name of the file (string)
     @param line line number of issue (integer or string)
     @param pos character position of issue (integer or string)
     @param message message text (string)
     @param fixed flag indicating a fixed issue (boolean)
     @param autofixing flag indicating, that we are fixing issues
         automatically (boolean)
     @param ignored flag indicating an ignored issue (boolean)
     @return reference to the created item (QTreeWidgetItem)
     """
     from .CodeStyleFixer import FixableCodeStyleIssues
     
     if self.__lastFileItem is None:
         # It's a new file
         self.__lastFileItem = QTreeWidgetItem(self.resultList, [
             self.__project.getRelativePath(filename)])
         self.__lastFileItem.setFirstColumnSpanned(True)
         self.__lastFileItem.setExpanded(True)
         self.__lastFileItem.setData(0, self.filenameRole, filename)
     
     fixable = False
     code, message = message.split(None, 1)
     itm = QTreeWidgetItem(
         self.__lastFileItem,
         ["{0:6}".format(line), code, message])
     if code.startswith(("W", "-", "C", "M")):
         itm.setIcon(1, UI.PixmapCache.getIcon("warning.png"))
     elif code.startswith("N"):
         itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png"))
     elif code.startswith("D"):
         itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png"))
     else:
         itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.png"))
     if fixed:
         itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed.png"))
     elif code in FixableCodeStyleIssues and not autofixing and \
             code not in self.__noFixCodesList:
         itm.setIcon(0, UI.PixmapCache.getIcon("issueFixable.png"))
         fixable = True
     
     itm.setTextAlignment(0, Qt.AlignRight)
     itm.setTextAlignment(1, Qt.AlignHCenter)
     
     itm.setTextAlignment(0, Qt.AlignVCenter)
     itm.setTextAlignment(1, Qt.AlignVCenter)
     itm.setTextAlignment(2, Qt.AlignVCenter)
     
     itm.setData(0, self.filenameRole, filename)
     itm.setData(0, self.lineRole, int(line))
     itm.setData(0, self.positionRole, int(pos))
     itm.setData(0, self.messageRole, message)
     itm.setData(0, self.fixableRole, fixable)
     itm.setData(0, self.codeRole, code)
     itm.setData(0, self.ignoredRole, ignored)
     
     if ignored:
         font = itm.font(0)
         font.setItalic(True)
         for col in range(itm.columnCount()):
             itm.setFont(col, font)
     
     return itm