- painter.drawRoundedRect(rect, 4, 4)
- painter.fillPath(path, QColor.fromRgb(0, 250, 0))
- painter.setPen(QColor.fromRgb(0, 0, 0))
- painter.drawText(option.rect, 0, QString(data))
- painter.restore()
- else: # others, fall back to default view
- QStyledItemDelegate.paint(self, painter, option, index)
+
+ if status_data == node_status['in']: # already in the slice
+ painter.fillPath(path, QColor("cyan"))
+ painter.setPen(QColor.fromRgb(0, 0, 0))
+ painter.drawText(option.rect, 0, QString(data))
+
+ elif status_data == node_status['add']: # newly added to the slice
+ painter.fillPath(path, QColor.fromRgb(0, 250, 0))
+ painter.setPen(QColor.fromRgb(0, 0, 0))
+ painter.drawText(option.rect, 0, QString(data))
+
+ elif status_data == node_status['remove']: # removed from the slice
+ painter.fillPath(path, QColor.fromRgb(250, 0, 0))
+ painter.setPen(QColor.fromRgb(0, 0, 0))
+ painter.drawText(option.rect, 0, QString(data))
+
+ else:
+ painter.setPen(QColor.fromRgb(0, 0, 0))
+ painter.drawText(option.rect, 0, QString(data))
+
+ else:
+ indent = 16
+ tag = index.data().toStringList()
+ data = "%s: %s" % (tag[0], tag[1])
+ rect.setHeight(rect.height() - 2)
+ rect.setWidth(fm.width(QString(data)) + 6 + indent)
+ rect.setX(rect.x() + 4 + indent)
+ rect.setY(rect.y() - 1)
+
+ x, y, h, w = rect.x(), rect.y(), rect.height(), rect.width()
+
+ path = QPainterPath()
+ path.addRoundedRect(x - 1, y + 1, w, h, 4, 4)
+
+ painter.save()
+ painter.setRenderHint(QPainter.Antialiasing)
+
+ if status_data == tag_status['in']: # already in the slice
+ painter.fillPath(path, QColor("cyan"))
+ painter.setPen(QColor.fromRgb(0, 0, 0))
+ painter.drawText(option.rect, 0, QString(data))
+
+ elif status_data == tag_status['add']: # newly added to the slice
+ painter.fillPath(path, QColor.fromRgb(0, 250, 0))
+ painter.setPen(QColor.fromRgb(0, 0, 0))
+ painter.drawText(option.rect, 0, QString(data))
+
+ elif status_data == tag_status['remove']: # removed from the slice
+ painter.fillPath(path, QColor.fromRgb(250, 0, 0))
+ painter.setPen(QColor.fromRgb(0, 0, 0))
+ painter.drawText(option.rect, 0, QString(data))
+
+ else:
+ painter.setPen(QColor.fromRgb(0, 0, 0))
+ painter.drawText(option.rect, 0, QString(data))
+
+ painter.restore()
+