コード例 #1
0
ファイル: job.py プロジェクト: ThreePointSquare/plow
    def paintEvent(self, event):

        total_width = self.width() - self.Margins[2]
        total_height = self.height() - self.Margins[3]
        total_tasks = float(self.__totals.total)

        vals = self.__values
        bar = [(total_width * (val / total_tasks), color)
               for val, color in vals if val != 0]

        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHints(painter.HighQualityAntialiasing
                               | painter.SmoothPixmapTransform
                               | painter.Antialiasing)
        painter.setPen(self.__PEN)

        move = 0
        x, y = self.Margins[:2]
        for width, color in reversed(bar):
            painter.setBrush(color)
            rect = QtCore.QRectF(x, y, total_width, total_height)
            if move:
                rect.setLeft(move)
            move += width
            painter.drawRoundedRect(rect, 3, 3)
        painter.end()
        event.accept()
コード例 #2
0
    def paintEvent(self, event):

        total_width = self.width() - self.Margins[2]
        total_height = self.height() - self.Margins[3]
        total_tasks = float(self.__totals.total)

        bar = []
        for i, v in enumerate(self.__values):
            if v == 0:
                continue
            bar.append((total_width * (v / total_tasks),
                        constants.COLOR_TASK_STATE[i + 1]))

        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHints(painter.HighQualityAntialiasing
                               | painter.SmoothPixmapTransform
                               | painter.Antialiasing)
        painter.setPen(self.__PEN)

        move = 0
        for width, color in bar:
            painter.setBrush(color)
            rect = QtCore.QRectF(self.Margins[0], self.Margins[1], total_width,
                                 total_height)
            if move:
                rect.setLeft(move)
            move += width
            painter.drawRoundedRect(rect, 3, 3)
        painter.end()
        event.accept()
コード例 #3
0
ファイル: job.py プロジェクト: ThreePointSquare/plow
    def paint(self, painter, opts, index):
        job = index.data(self._role)
        if not job:
            super(JobProgressDelegate, self).paint(painter, opts, index)
            return

        state = plow.client.TaskState
        colors = constants.COLOR_TASK_STATE
        totals = job.totals

        values = [
            (totals.dead, colors[state.DEAD]),
            (totals.eaten, colors[state.EATEN]),
            (totals.waiting, colors[state.WAITING]),
            (totals.depend, colors[state.DEPEND]),
            (totals.running, colors[state.RUNNING]),
            (totals.succeeded, colors[state.SUCCEEDED]),
        ]

        rect = opts.rect
        total_width = rect.width() - self.MARGINS[2]
        total_height = rect.height() - self.MARGINS[3]
        total_tasks = float(totals.total)

        bar = [(total_width * (val / total_tasks), color)
               for val, color in values if val != 0]

        painter.setRenderHints(painter.HighQualityAntialiasing
                               | painter.SmoothPixmapTransform
                               | painter.Antialiasing)

        # self.drawBackground(painter, opt, index)

        painter.setPen(self.PEN)

        x, y = rect.x(), rect.y()
        x += self.MARGINS[0]
        y += self.MARGINS[1]

        move = 0

        for width, color in reversed(bar):
            painter.setBrush(color)
            rect = QtCore.QRectF(x, y, total_width, total_height)
            if move:
                rect.setLeft(x + move)
            move += width
            painter.drawRoundedRect(rect, 3, 3)