+ sizeHint(self, option, index)
+
+class TextNodeDelegate(QAbstractItemDelegate):
+ def paint(self, painter, option, index):
+ #print "TEXT DELEG CALLED"
+ paint(self, painter, option, index)
+
+ def sizeHint(self, option, index):
+ sizeHint(self, option, index)
+
+class CommentNodeDelegate(QAbstractItemDelegate):
+ def paint(self, painter, option, index):
+ #print "TEXT DELEG CALLED"
+ paint(self, painter, option, index)
+
+def paint(self, painter, option, index):
+ text = index.model().data(index).property('content').toString()
+ palette = QApplication.palette()
+ document = QTextDocument()
+ document.setDefaultFont(option.font)
+ if option.state & QStyle.State_Selected:
+ rx = QRegExp(QString('<font .*>'))
+ rx.setMinimal(True)
+ # If selected, I remove the <font color="..."> by hand,
+ # and give the highlight color
+ document.setHtml(QString("<font color=%1>%2</font>") \
+ .arg(palette.highlightedText().color().name())\
+ .arg(text.replace(rx, QString('')).
+ replace(QString('</font>'),QString(''))))
+ else: