- select_index = model.index(index.row(), 2, index.parent())
- select_data = select_index.data().toString()
-# if select_data == "false":
-# print select_data
-# model.setData(index, QString("*%s" % data), Qt.EditRole)
-# model.setData(select_index, QString("true"), Qt.EditRole)
-
-
- if select_data == "true": # already in the sliver
- fm = QFontMetrics(option.font)
- rect = option.rect
- rect.setWidth(fm.width(QString(data)))
+ status_index = model.index(index.row(), 2, index.parent())
+ status_data = status_index.data().toString()
+
+ fm = QFontMetrics(option.font)
+ rect = option.rect
+
+ 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])