Exemple #1
0
    def drawRow(self, painter, option, index):
        """
        """
        # draw the partially selected rows a lighter colour
        selectionState = index.model().itemFromIndex(index).data(
            role=common.ROLE_SELECTION_STATE)
        if selectionState == 1:
            palette = self.palette()
            selectionColor = palette.color(palette.Highlight)
            selectionColor.setAlpha(127)
            painter.save()
            painter.fillRect(option.rect, selectionColor)
            painter.restore()

        QtGui.QTreeView.drawRow(self, painter, option, index)

        # draw the grid line
        if self.__showGrid:
            painter.save()
            gridHint = self.style().styleHint(
                QtGui.QStyle.SH_Table_GridLineColor, self.viewOptions(), self,
                None)
            # must ensure that the value is positive before constructing a QColor from it
            # http://www.riverbankcomputing.com/pipermail/pyqt/2010-February/025893.html
            gridColor = QtGui.QColor.fromRgb(gridHint & 0xffffffff)
            painter.setPen(QtGui.QPen(gridColor, 0, QtCore.Qt.SolidLine))
            # paint the horizontal line
            painter.drawLine(option.rect.left(), option.rect.bottom(),
                             option.rect.right(), option.rect.bottom())
            painter.restore()
Exemple #2
0
    def paint(self, painter, option, index):
        """
        """
        origRect = QtCore.QRect(option.rect)
        if self._view.showGrid():
            # remove 1 pixel from right and bottom edge of rect, to
            # make room for drawing grid
            option.rect.setRight(option.rect.right() - 1)
            option.rect.setBottom(option.rect.bottom() - 1)

        # paint the item
        Delegate.paint(self, painter, option, index)

        # draw the vertical grid lines (horizontal lines are painted
        # in TreeView.drawRow())
        if self._view.showGrid():
            painter.save()
            gridHint = QtGui.QApplication.style().styleHint(
                QtGui.QStyle.SH_Table_GridLineColor, option, self._view, None)
            # must ensure that the value is positive before
            # constructing a QColor from it
            # http://www.riverbankcomputing.com/pipermail/pyqt/2010-February/025893.html
            gridColor = QtGui.QColor.fromRgb(gridHint & 0xffffffff)
            painter.setPen(QtGui.QPen(gridColor, 0, QtCore.Qt.SolidLine))
            # paint the vertical line
            painter.drawLine(origRect.right(), origRect.top(),
                             origRect.right(), origRect.bottom())
            painter.restore()
Exemple #3
0
    def drawBranches(self, painter, rect, index):
        """
        """

        QtGui.QTreeView.drawBranches(self, painter, rect, index)
        # draw the grid line
        if self.__showGrid:
            painter.save()
            gridHint = QtGui.QApplication.style().styleHint(
                QtGui.QStyle.SH_Table_GridLineColor, self.viewOptions(), self,
                None)
            # must ensure that the value is positive before
            # constructing a QColor from it
            # http://www.riverbankcomputing.com/pipermail/pyqt/2010-February/025893.html
            gridColor = QtGui.QColor.fromRgb(gridHint & 0xffffffff)
            painter.setPen(QtGui.QPen(gridColor, 0, QtCore.Qt.SolidLine))
            # paint the horizontal line
            painter.drawLine(rect.left(), rect.bottom(), rect.right(),
                             rect.bottom())
            painter.restore()