4 from PyQt4.QtCore import *
5 from PyQt4.QtGui import *
6 from PyQt4.QtXml import *
8 from sface.xmlwidget import *
9 from sface.config import config
10 from sface.screens.sfascreen import SfaScreen
13 class RSpecView(XmlView):
14 def __init__(self, parent):
15 XmlView.__init__(self, parent)
17 def expandMatchingText(self, txt):
23 def recursiveExpand(index):
24 parent = index.parent()
25 if parent and parent.isValid():
26 recursiveExpand(parent)
30 if index.data().toString() == txt:
31 recursiveExpand(index)
32 self.scrollTo(index, self.PositionAtCenter)
35 rows = model.rowCount(index)
37 child_index = index.child(r, 0)
40 root_rows = model.rowCount()
41 for r in range(root_rows):
42 index = model.index(r, 0)
45 class RSpecWindow(XmlWindow):
46 def __init__(self, parent=None):
47 XmlWindow.__init__(self, parent, 'RSpec Window')
48 self.view = RSpecView(self)
50 def showNode(self, hostname):
51 self.view.expandMatchingText(hostname)
54 XmlWindow.updateView(self)
56 rspec_file = config.getSliceRSpecFile()
57 if not os.path.exists(rspec_file):
60 self.document.setContent(open(rspec_file,'r').read())