X-Git-Url: http://git.onelab.eu/?p=sface.git;a=blobdiff_plain;f=sface%2Fxmlwidget.py;fp=sface%2Fxmlwidget.py;h=633c95a2ee55ce3451aa0fad315eaf62e646a981;hp=a2d3ec2312d6a9a24c484e843ba4c68df92e5779;hb=16fda85a3620dcd2a198a2ba5b9f17be0cc72049;hpb=5ca19693a97294cff7be4a2e3cbb92ce5a039794
diff --git a/sface/xmlwidget.py b/sface/xmlwidget.py
index a2d3ec2..633c95a 100644
--- a/sface/xmlwidget.py
+++ b/sface/xmlwidget.py
@@ -254,7 +254,6 @@ class XmlDelegate(QItemDelegate):
class ElemNodeDelegate(QAbstractItemDelegate):
def paint(self, painter, option, index):
- text = index.model().data(index)
palette = QApplication.palette()
document = QTextDocument()
document.setDefaultFont(option.font)
@@ -263,9 +262,7 @@ class ElemNodeDelegate(QAbstractItemDelegate):
highGlobPattern = '<%s%s>'
highAttPattern = ' %s="%s"'
def getHtmlText(plainText, globPattern, attPattern):
- print "PLAIN TEXT:", plainText
tmp = plainText.split(' ', 1)
- print "TMP:", tmp
elemName = tmp[0]
AttListHtml = ''
if len(tmp) > 1:
@@ -281,7 +278,6 @@ class ElemNodeDelegate(QAbstractItemDelegate):
def colorize(color, text):
return '' + text + ''
text = str(index.model().data(index).property('content').toString())
- print "TEXT:", text
if option.state & QStyle.State_Selected:
htmlText = colorize(palette.highlightedText().color().name(),
getHtmlText(text, highGlobPattern, highAttPattern))
@@ -293,7 +289,6 @@ class ElemNodeDelegate(QAbstractItemDelegate):
if option.state & QStyle.State_Selected \
else palette.base().color()
painter.save()
- print "COLOR:", color.name()
# voodoo: if not highlighted, filling the rect
# with the base color makes no difference
painter.fillRect(option.rect, color)
@@ -306,15 +301,40 @@ class ElemNodeDelegate(QAbstractItemDelegate):
class TextNodeDelegate(QAbstractItemDelegate):
def paint(self, painter, option, index):
- #print "TEXT DELEG CALLED"
- paint(self, painter, option, index)
+ palette = QApplication.palette()
+ document = QTextDocument()
+ document.setDefaultFont(option.font)
+ def verbatimize(text):
+ text.replace('\n', '
')
+ return '
' + text + '' + text + '' + text = str(index.model().data(index).property('content').toString()) + if option.state & QStyle.State_Selected: + htmlText = colorize(palette.highlightedText().color().name(), + verbatimize(text)) + document.setHtml(QString(htmlText)) + else: + htmlText = verbatimize(text) + document.setHtml(QString(htmlText)) + color = palette.highlight().color() \ + if option.state & QStyle.State_Selected \ + else palette.base().color() + painter.save() + # voodoo: if not highlighted, filling the rect + # with the base color makes no difference + painter.fillRect(option.rect, color) + painter.translate(option.rect.x(), option.rect.y()) + document.drawContents(painter) + painter.restore() 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):