restore baris tree expansion feature. Removed >print< statements.
authorGiovanni Gherdovich <ggherdov@brentaal.inria.fr>
Wed, 20 Oct 2010 15:42:04 +0000 (17:42 +0200)
committerGiovanni Gherdovich <ggherdov@brentaal.inria.fr>
Wed, 20 Oct 2010 15:42:04 +0000 (17:42 +0200)
sface/mainwindow.py
sface/rspecwindow.py
sface/xmlwidget.py

index b064769..0b52d95 100644 (file)
@@ -175,6 +175,5 @@ class MainWindow(QWidget):
         self.status.set(msg, timeout)
 
     def nodeSelectionChanged(self, hostname):
         self.status.set(msg, timeout)
 
     def nodeSelectionChanged(self, hostname):
-        print "nodeSelectionChanged"
         if self.rspecWindow.isVisible():
             self.rspecWindow.showNode(hostname)
         if self.rspecWindow.isVisible():
             self.rspecWindow.showNode(hostname)
index 021d8fa..2abd5fd 100644 (file)
@@ -15,7 +15,6 @@ class RSpecView(XmlView):
         XmlView.__init__(self, parent)
 
     def expandMatchingText(self, txt):
         XmlView.__init__(self, parent)
 
     def expandMatchingText(self, txt):
-        print "LHS", txt
         self.collapseAll()
         self.expandToDepth(0)
 
         self.collapseAll()
         self.expandToDepth(0)
 
@@ -28,8 +27,11 @@ class RSpecView(XmlView):
             self.expand(index)
 
         def search(index):
             self.expand(index)
 
         def search(index):
-            print index.data().toString()
-            if index.data().toString() == txt:
+            # voodoo alert: baris was using index.data()
+            # and apparently it worked. But after me
+            # messing around, only index.model().data(index)
+            # seems to give non-empty QVariant as output.
+            if index.model().data(index).toString() == txt:
                 recursiveExpand(index)
                 self.scrollTo(index, self.PositionAtCenter)
                 return
                 recursiveExpand(index)
                 self.scrollTo(index, self.PositionAtCenter)
                 return
@@ -60,11 +62,9 @@ class RSpecWindow(QDialog):
         layout.addWidget(self.view)
         self.setLayout(layout)
         
         layout.addWidget(self.view)
         self.setLayout(layout)
         
-        print 'CHILDREN', str(self.children())
         self.updateView()
 
     def showNode(self, hostname):
         self.updateView()
 
     def showNode(self, hostname):
-        print "SHOWNODE"
         self.view.expandMatchingText(hostname)
 
     def updateView(self):
         self.view.expandMatchingText(hostname)
 
     def updateView(self):
index 35cc64a..2c0f53c 100644 (file)
@@ -8,22 +8,6 @@ from PyQt4.QtXml import *
 from sface.config import config
 from sface.screens.sfascreen import SfaScreen
 
 from sface.config import config
 from sface.screens.sfascreen import SfaScreen
 
-import time
-
-
-
-def QVarMapAccess(qv, key):
-    # helper function. qv is a dict wrapped into a QVariant
-    #print 10*'='
-    #print "DICT:", qv.toMap()
-#    if len(qv.toMap().keys()) == 0:
-#        print "EMPTY!"
-#        import traceback
-#        traceback.print_stack()
-#        return None
-#    else:
-    return qv.toMap()[QString(key)].toString()
-
 class nodeData(QVariant):
     def __init__(self, *args, **kws):
         QVariant.__init__(self, *args, **kws)
 class nodeData(QVariant):
     def __init__(self, *args, **kws):
         QVariant.__init__(self, *args, **kws)
@@ -46,7 +30,6 @@ class DomModel(QAbstractItemModel):
             currElem = childList.item(i)
             if (currElem.nodeType() == QDomNode.ProcessingInstructionNode):
                 document.removeChild(currElem)
             currElem = childList.item(i)
             if (currElem.nodeType() == QDomNode.ProcessingInstructionNode):
                 document.removeChild(currElem)
-                print "REMOVED!"
                 break
         self.rootItem = DomItem(document, 0);
 
                 break
         self.rootItem = DomItem(document, 0);
 
@@ -68,57 +51,42 @@ class DomModel(QAbstractItemModel):
                     elem = ' %s="%s"' % (attr.nodeName(), attr.nodeValue())
                     qslist.append(elem)
                 ElemNameAndAtts = '%s%s'% (node.nodeName(), qslist.join(' '))
                     elem = ' %s="%s"' % (attr.nodeName(), attr.nodeValue())
                     qslist.append(elem)
                 ElemNameAndAtts = '%s%s'% (node.nodeName(), qslist.join(' '))
-                #print "1"
                 answer = nodeData(ElemNameAndAtts)
                 answer.setType('element')
                 return answer
             elif node.nodeType() == QDomNode.AttributeNode:
                 answer = nodeData(ElemNameAndAtts)
                 answer.setType('element')
                 return answer
             elif node.nodeType() == QDomNode.AttributeNode:
-                print "2"
                 return QVariant()
             elif node.nodeType() == QDomNode.TextNode:
                 return QVariant()
             elif node.nodeType() == QDomNode.TextNode:
-                #print "3"
                 answer = nodeData(node.nodeValue())
                 answer.setType('text')
                 return answer
             elif node.nodeType() == QDomNode.CDATASectionNode:
                 answer = nodeData(node.nodeValue())
                 answer.setType('text')
                 return answer
             elif node.nodeType() == QDomNode.CDATASectionNode:
-                print "4"
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.EntityReferenceNode:
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.EntityReferenceNode:
-                print "5"
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.EntityNode:
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.EntityNode:
-                print "6"
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.ProcessingInstructionNode:
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.ProcessingInstructionNode:
-                print "7"
                 return QVariant()
             elif node.nodeType() == QDomNode.CommentNode:
                 answer = nodeData(node.nodeValue())
                 answer.setType('comment')
                 return answer
             elif node.nodeType() == QDomNode.DocumentNode:
                 return QVariant()
             elif node.nodeType() == QDomNode.CommentNode:
                 answer = nodeData(node.nodeValue())
                 answer.setType('comment')
                 return answer
             elif node.nodeType() == QDomNode.DocumentNode:
-                print "9"
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.DocumentTypeNode:
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.DocumentTypeNode:
-                print "10"
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.DocumentFragmentNode:
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.DocumentFragmentNode:
-                print "12"
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.NotationNode:
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.NotationNode:
-                print "13"
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.BaseNode:
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.BaseNode:
-                print "14"
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.CharacterDataNode:
                 return QString('unsupported node type')
             elif node.nodeType() == QDomNode.CharacterDataNode:
-                print "15"
                 return QString('unsupported node type')
             else:
                 return QString('unsupported node type')
             else:
-                print "16"
                 return QVariant()
         else:
                 return QVariant()
         else:
-            print "17"
             return QVariant()
 
     def flags(self, index):
             return QVariant()
 
     def flags(self, index):
@@ -228,26 +196,15 @@ class XmlDelegate(QItemDelegate):
             del self.delegates[nodeType]
     
     def paint(self, painter, option, index):
             del self.delegates[nodeType]
     
     def paint(self, painter, option, index):
-        start = time.time()
-        #print "ASKING FOR DATA"
         nodeData = index.model().data(index)
         nodeData = index.model().data(index)
-        #print "GOT DATA"
         nodeType = nodeData.getType()
         delegate = self.delegates.get(nodeType)
         nodeType = nodeData.getType()
         delegate = self.delegates.get(nodeType)
-        #print "DELEGS DICT:", self.delegates
-        #print "NODETYPE:", nodeType.toString()
         if delegate is not None:
         if delegate is not None:
-            #print "WOW DELEG ISNT NONE"
             delegate.paint(painter, option, index)
         else:
             delegate.paint(painter, option, index)
         else:
-            #print "ELSE BRANCH"
-            # not sure this will ever work. this delegate
-            # doesn't know about my QMap strategy.
             QItemDelegate.paint(self, painter, option, index)
             QItemDelegate.paint(self, painter, option, index)
-        #print time.strftime('%M:%S'),"[%.3f s]"%(time.time()-start), 'paint' ,'Done'
 
     def sizeHint(self, option, index):
 
     def sizeHint(self, option, index):
-        start = time.time()
         fm = option.fontMetrics
         nodeData = index.model().data(index)
         nodeType = nodeData.getType()
         fm = option.fontMetrics
         nodeData = index.model().data(index)
         nodeType = nodeData.getType()
@@ -257,7 +214,6 @@ class XmlDelegate(QItemDelegate):
         elif nodeType == 'text':
             nl = text.count('\n')
             numlines = nl if nl > 0 else 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()
         else:
             numlines = 1
         document = QTextDocument()
@@ -265,7 +221,6 @@ class XmlDelegate(QItemDelegate):
         document.setHtml(text)
         # the +5 is for margin. The +4 is voodoo;
         # fm.height just give it too small.
         document.setHtml(text)
         # the +5 is for margin. The +4 is voodoo;
         # fm.height just give it too small.
-        #print time.strftime('%M:%S'),"[%.3f s]"%(time.time()-start), 'hint' ,'Done'
         return QSize(document.idealWidth() + 5, (fm.height() + 4) * numlines)    
 
 class ElemNodeDelegate(QAbstractItemDelegate):
         return QSize(document.idealWidth() + 5, (fm.height() + 4) * numlines)    
 
 class ElemNodeDelegate(QAbstractItemDelegate):
@@ -300,8 +255,6 @@ class ElemNodeDelegate(QAbstractItemDelegate):
         if option.state & QStyle.State_Selected:
             htmlText = colorize(palette.highlightedText().color().name(),
                                 getHtmlText(text, highGlobPattern, highAttPattern))
         if option.state & QStyle.State_Selected:
             htmlText = colorize(palette.highlightedText().color().name(),
                                 getHtmlText(text, highGlobPattern, highAttPattern))
-            #print htmlText
-            #print getHtmlText(text, highGlobPattern, highAttPattern)
             document.setHtml(QString(htmlText))
         else:
             htmlText = getHtmlText(text, nonHighGlobPattern, nonHighAttPattern)
             document.setHtml(QString(htmlText))
         else:
             htmlText = getHtmlText(text, nonHighGlobPattern, nonHighAttPattern)