Skip to content

Commit

Permalink
create results viewer dialog from .ui
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Dec 3, 2012
1 parent e05519d commit 4215ea7
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 47 deletions.
69 changes: 22 additions & 47 deletions python/plugins/sextante/gui/ResultsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,57 +25,33 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui, QtWebKit

from sextante.core.SextanteResults import SextanteResults

class ResultsDialog(QtGui.QDialog):
from sextante.ui.ui_DlgResults import Ui_DlgResults

class ResultsDialog(QDialog, Ui_DlgResults):
def __init__(self):
QtGui.QDialog.__init__(self)
self.setModal(True)
self.setupUi()
QDialog.__init__(self)
self.setupUi(self)

# seems not used and can be removed
#self.groupIcon = QIcon()
#self.groupIcon.addPixmap(self.style().standardPixmap(QStyle.SP_DirClosedIcon),
# QIcon.Normal, QIcon.Off)
#self.groupIcon.addPixmap(self.style().standardPixmap(QStyle.SP_DirOpenIcon),
# QIcon.Normal, QIcon.On)

self.keyIcon = QIcon()
self.keyIcon.addPixmap(self.style().standardPixmap(QStyle.SP_FileIcon))

self.tree.itemClicked.connect(self.changeResult)

def setupUi(self):
self.resize(800, 600)
self.tree = QtGui.QTreeWidget()
self.tree.setHeaderHidden(True)
self.tree.setMinimumWidth(300)
QObject.connect(self.tree, QtCore.SIGNAL("itemClicked(QTreeWidgetItem*, int)"), self.changeResult)
self.groupIcon = QtGui.QIcon()
self.groupIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_DirClosedIcon),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.groupIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_DirOpenIcon),
QtGui.QIcon.Normal, QtGui.QIcon.On)
self.keyIcon = QtGui.QIcon()
self.keyIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_FileIcon))
self.fillTree()
self.webView = QtWebKit.QWebView()
self.setWindowTitle("Results")
self.horizontalLayout= QtGui.QHBoxLayout()
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.horizontalLayout.addWidget(self.tree)
self.horizontalLayout.addWidget(self.webView)
self.closeButton = QtGui.QPushButton()
self.closeButton.setText("Close")
self.horizontalLayout2= QtGui.QHBoxLayout()
self.horizontalLayout2.setSpacing(2)
self.horizontalLayout2.setMargin(0)
self.horizontalLayout2.addStretch(1000)
self.horizontalLayout2.addWidget(self.closeButton)
QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.closeWindow)
self.verticalLayout= QtGui.QVBoxLayout()
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0)
self.verticalLayout.addLayout(self.horizontalLayout)
self.verticalLayout.addLayout(self.horizontalLayout2)
self.setLayout(self.verticalLayout)
QtCore.QMetaObject.connectSlotsByName(self)

if self.lastUrl:
self.webView.load(self.lastUrl)

def closeWindow(self):
self.close()

def fillTree(self):
elements = SextanteResults.getResults()
if len(elements) == 0:
Expand All @@ -85,16 +61,15 @@ def fillTree(self):
item = TreeResultItem(element)
item.setIcon(0, self.keyIcon)
self.tree.addTopLevelItem(item)
self.lastUrl = QtCore.QUrl(elements[-1].filename)
self.lastUrl = QUrl(elements[-1].filename)

def changeResult(self):
item = self.tree.currentItem()
if isinstance(item, TreeResultItem):
url = QtCore.QUrl(item.filename)
url = QUrl(item.filename)
self.webView.load(url)


class TreeResultItem(QtGui.QTreeWidgetItem):
class TreeResultItem(QTreeWidgetItem):
def __init__(self, result):
QTreeWidgetItem.__init__(self)
self.filename = result.filename
Expand Down
113 changes: 113 additions & 0 deletions python/plugins/sextante/ui/DlgResults.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgResults</class>
<widget class="QDialog" name="DlgResults">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>623</width>
<height>515</height>
</rect>
</property>
<property name="windowTitle">
<string>Results</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeWidget" name="tree">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
<widget class="QWebView" name="webView">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DlgResults</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DlgResults</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 4215ea7

Please sign in to comment.