# doesn't know about my QMap strategy.
QItemDelegate.paint(self, painter, option, index)
-# def sizeHint(self, option, index):
-# fm = option.fontMetrics
-# print "TYPE:", str(type(index.model().data(index).convert(QObject)))
-# text = "the fish doesn't talk"
-# #text = str(index.model().data(index).property('content').toString())
-# nodeType = str(index.model().data(index).property('nodeType').toString())
-# if nodeType == 'element' or nodeType == 'comment':
-# numlines = 1
-# elif nodeType == 'text':
-# numlines = text.count('\n')
-# sys.__stdout__.write("TEXT: \n" + text)
-# else:
-# numlines = 1
-# document = QTextDocument()
-# document.setDefaultFont(option.font)
-# document.setHtml(text)
-# # the +5 is for margin. The +4 is voodoo;
-# # fm.height just give it too small.
-# return QSize(document.idealWidth() + 5, (fm.height() + 4) * numlines)
+ def sizeHint(self, option, index):
+ fm = option.fontMetrics
+ text = "the fish doesn't talk"
+ dataAsQVarMap = index.model().data(index)
+ nodeType = str(QVarMapAccess(dataAsQVarMap, 'nodeType'))
+ if nodeType == 'element' or nodeType == 'comment':
+ numlines = 1
+ elif nodeType == 'text':
+ nl = text.count('\n')
+ numlines = nl if nl > 0 else 1
+ sys.__stdout__.write("TEXT: \n" + text)
+ else:
+ numlines = 1
+ document = QTextDocument()
+ document.setDefaultFont(option.font)
+ document.setHtml(text)
+ # the +5 is for margin. The +4 is voodoo;
+ # fm.height just give it too small.
+ return QSize(document.idealWidth() + 5, (fm.height() + 4) * numlines)
class ElemNodeDelegate(QAbstractItemDelegate):
def paint(self, painter, option, index):