Example #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
Example #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)
Example #3
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
    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