From: Giovanni Gherdovich <ggherdov@brentaal.inria.fr>
Date: Tue, 19 Oct 2010 16:24:51 +0000 (+0200)
Subject: done with sizeHint. Next: it a bit slow in changing the orientation of the arrow... 
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=e03066962aa3f15dc6646e53d4682f4ccad28bef;p=sface.git

done with sizeHint. Next: it a bit slow in changing the orientation of the arrow in the tree. Then clean all the -print- statements
---

diff --git a/sface/xmlwidget.py b/sface/xmlwidget.py
index 865f276..2a57587 100644
--- a/sface/xmlwidget.py
+++ b/sface/xmlwidget.py
@@ -231,25 +231,25 @@ class XmlDelegate(QItemDelegate):
             # 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):