From: Giovanni Gherdovich Date: Wed, 20 Oct 2010 15:42:04 +0000 (+0200) Subject: restore baris tree expansion feature. Removed >print< statements. X-Git-Url: http://git.onelab.eu/?p=sface.git;a=commitdiff_plain;h=eb6b726661868a93d439c030ead00f4b7a2fe0a7 restore baris tree expansion feature. Removed >print< statements. --- diff --git a/sface/mainwindow.py b/sface/mainwindow.py index b064769..0b52d95 100644 --- a/sface/mainwindow.py +++ b/sface/mainwindow.py @@ -175,6 +175,5 @@ class MainWindow(QWidget): self.status.set(msg, timeout) def nodeSelectionChanged(self, hostname): - print "nodeSelectionChanged" if self.rspecWindow.isVisible(): self.rspecWindow.showNode(hostname) diff --git a/sface/rspecwindow.py b/sface/rspecwindow.py index 021d8fa..2abd5fd 100644 --- a/sface/rspecwindow.py +++ b/sface/rspecwindow.py @@ -15,7 +15,6 @@ class RSpecView(XmlView): XmlView.__init__(self, parent) def expandMatchingText(self, txt): - print "LHS", txt self.collapseAll() self.expandToDepth(0) @@ -28,8 +27,11 @@ class RSpecView(XmlView): 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 @@ -60,11 +62,9 @@ class RSpecWindow(QDialog): layout.addWidget(self.view) self.setLayout(layout) - print 'CHILDREN', str(self.children()) self.updateView() def showNode(self, hostname): - print "SHOWNODE" self.view.expandMatchingText(hostname) def updateView(self): diff --git a/sface/xmlwidget.py b/sface/xmlwidget.py index 35cc64a..2c0f53c 100644 --- a/sface/xmlwidget.py +++ b/sface/xmlwidget.py @@ -8,22 +8,6 @@ from PyQt4.QtXml import * 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) @@ -46,7 +30,6 @@ class DomModel(QAbstractItemModel): currElem = childList.item(i) if (currElem.nodeType() == QDomNode.ProcessingInstructionNode): document.removeChild(currElem) - print "REMOVED!" 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(' ')) - #print "1" answer = nodeData(ElemNameAndAtts) answer.setType('element') return answer elif node.nodeType() == QDomNode.AttributeNode: - print "2" return QVariant() elif node.nodeType() == QDomNode.TextNode: - #print "3" 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: - print "5" return QString('unsupported node type') elif node.nodeType() == QDomNode.EntityNode: - print "6" 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: - print "9" return QString('unsupported node type') elif node.nodeType() == QDomNode.DocumentTypeNode: - print "10" return QString('unsupported node type') elif node.nodeType() == QDomNode.DocumentFragmentNode: - print "12" return QString('unsupported node type') elif node.nodeType() == QDomNode.NotationNode: - print "13" return QString('unsupported node type') elif node.nodeType() == QDomNode.BaseNode: - print "14" return QString('unsupported node type') elif node.nodeType() == QDomNode.CharacterDataNode: - print "15" return QString('unsupported node type') else: - print "16" return QVariant() else: - print "17" return QVariant() def flags(self, index): @@ -228,26 +196,15 @@ class XmlDelegate(QItemDelegate): del self.delegates[nodeType] def paint(self, painter, option, index): - start = time.time() - #print "ASKING FOR DATA" nodeData = index.model().data(index) - #print "GOT DATA" nodeType = nodeData.getType() delegate = self.delegates.get(nodeType) - #print "DELEGS DICT:", self.delegates - #print "NODETYPE:", nodeType.toString() if delegate is not None: - #print "WOW DELEG ISNT NONE" 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) - #print time.strftime('%M:%S'),"[%.3f s]"%(time.time()-start), 'paint' ,'Done' def sizeHint(self, option, index): - start = time.time() 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 - sys.__stdout__.write("TEXT: \n" + text) 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. - #print time.strftime('%M:%S'),"[%.3f s]"%(time.time()-start), 'hint' ,'Done' 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)) - #print htmlText - #print getHtmlText(text, highGlobPattern, highAttPattern) document.setHtml(QString(htmlText)) else: htmlText = getHtmlText(text, nonHighGlobPattern, nonHighAttPattern)