- rect.setWidth(fm.width(QString(data)) + 8)
- rect.setHeight(rect.height() - 2)
- rect.setX(rect.x() + 4)
- x, y, h, w = rect.x(), rect.y(), rect.height(), rect.width()
-
- path = QPainterPath()
- path.addRoundedRect(x, y, w, h, 4, 4)
-
- painter.save()
- painter.setRenderHint(QPainter.Antialiasing)
- painter.drawRoundedRect(rect, 4, 4)
-
- if status_data == node_status['in']: # already in 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['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))
- painter.drawRect(x + w + 10, y + 3, 10, 10)
- painter.fillRect(x + w + 10, y + 3, 10, 10, QColor.fromRgb(0, 250, 0))
-
- 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))
- painter.drawRect(x + w + 10, y + 3, 10, 10)
- painter.fillRect(x + w + 10, y + 3, 10, 10, QColor.fromRgb(250, 0, 0))
+
+ if itemType(index) == "node":
+ data = "%s" % index.data().toString()
+ #if status_data not in (node_status['in'], node_status['remove'], node_status['add']):
+ # default view
+ # QStyledItemDelegate.paint(self, painter, option, index)
+ # return
+
+ rect.setHeight(rect.height() - 2)
+ rect.setWidth(fm.width(QString(data)) + 6)
+ rect.setX(rect.x() + 5)
+ 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 == 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))