Skip to content
Permalink
Browse files

[processing] use QtDesigner ui file for Edit rendering styles dialog

  • Loading branch information
alexbruy committed Oct 2, 2013
1 parent 498a5d9 commit 7cb0be0806dca76c96dce752da6b3dd2fef0e70a
@@ -27,88 +27,65 @@

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

from processing.gui.RenderingStyles import RenderingStyles
from processing.gui.RenderingStyleFilePanel import RenderingStyleFilePanel
from processing.outputs.OutputRaster import OutputRaster
from processing.outputs.OutputVector import OutputVector

from processing.ui.ui_DlgRenderingStyles import Ui_DlgRenderingStyles


class EditRenderingStylesDialog(QtGui.QDialog):
class EditRenderingStylesDialog(QDialog, Ui_DlgRenderingStyles):

def __init__(self, alg):
QtGui.QDialog.__init__(self)
self.setModal(True)
QDialog.__init__(self)
self.setupUi(self)

self.alg = alg
self.setupUi()

def setupUi(self):
self.setModal(True)
self.tblStyles.horizontalHeader().setResizeMode(QHeaderView.Stretch)
self.setWindowTitle(self.alg.name)

self.valueItems = {}
self.dependentItems = {}
self.resize(650, 450)
self.buttonBox = QtGui.QDialogButtonBox()
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
| QtGui.QDialogButtonBox.Ok)
self.tableWidget = QtGui.QTableWidget()
self.tableWidget.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
self.tableWidget.setColumnCount(2)
self.tableWidget.setColumnWidth(0, 300)
self.tableWidget.setColumnWidth(1, 300)
self.tableWidget.setHorizontalHeaderItem(0,
QtGui.QTableWidgetItem('Output'))
self.tableWidget.setHorizontalHeaderItem(1,
QtGui.QTableWidgetItem('Style'))
self.tableWidget.verticalHeader().setVisible(False)
self.tableWidget.horizontalHeader().setResizeMode(
QtGui.QHeaderView.Stretch)
self.setTableContent()
self.setWindowTitle(self.alg.name)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0)
self.verticalLayout.addWidget(self.tableWidget)
self.verticalLayout.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'),
self.okPressed)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'),
self.cancelPressed)
QtCore.QMetaObject.connectSlotsByName(self)

def setTableContent(self):
numOutputs = 0
for output in self.alg.outputs:
if isinstance(output, (OutputVector, OutputRaster)):
if not output.hidden:
numOutputs += 1
self.tableWidget.setRowCount(numOutputs)
self.tblStyles.setRowCount(numOutputs)

i = 0
for output in self.alg.outputs:
if isinstance(output, (OutputVector, OutputRaster)):
if not output.hidden:
item = QtGui.QTableWidgetItem(output.description + '<'
item = QTableWidgetItem(output.description + '<'
+ output.__module__.split('.')[-1] + '>')
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.tableWidget.setItem(i, 0, item)
item.setFlags(Qt.ItemIsEnabled)
self.tblStyles.setItem(i, 0, item)
item = RenderingStyleFilePanel()
style = \
RenderingStyles.getStyle(self.alg.commandLineName(),
output.name)
if style:
item.setText(str(style))
self.valueItems[output.name] = item
self.tableWidget.setCellWidget(i, 1, item)
self.tableWidget.setRowHeight(i, 22)
self.tblStyles.setCellWidget(i, 1, item)
self.tblStyles.setRowHeight(i, 22)
i += 1

def okPressed(self):
def accepted(self):
styles = {}
for key in self.valueItems.keys():
styles[key] = str(self.valueItems[key].getValue())
RenderingStyles.addAlgStylesAndSave(self.alg.commandLineName(), styles)
self.close()

def cancelPressed(self):
self.close()
QDialog.accept(self)

def rejected(self):
QDialog.reject(self)
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgRenderingStyles</class>
<widget class="QDialog" name="DlgRenderingStyles">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>550</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QTableWidget" name="tblStyles">
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Output</string>
</property>
</column>
<column>
<property name="text">
<string>Style</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DlgRenderingStyles</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>DlgRenderingStyles</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,0 +1,52 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'python/plugins/processing/ui/DlgRenderingStyles.ui'
#
# Created: Wed Oct 2 17:04:59 2013
# by: PyQt4 UI code generator 4.9.1
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s

class Ui_DlgRenderingStyles(object):
def setupUi(self, DlgRenderingStyles):
DlgRenderingStyles.setObjectName(_fromUtf8("DlgRenderingStyles"))
DlgRenderingStyles.resize(550, 400)
self.verticalLayout = QtGui.QVBoxLayout(DlgRenderingStyles)
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.tblStyles = QtGui.QTableWidget(DlgRenderingStyles)
self.tblStyles.setObjectName(_fromUtf8("tblStyles"))
self.tblStyles.setColumnCount(2)
self.tblStyles.setRowCount(0)
item = QtGui.QTableWidgetItem()
self.tblStyles.setHorizontalHeaderItem(0, item)
item = QtGui.QTableWidgetItem()
self.tblStyles.setHorizontalHeaderItem(1, item)
self.tblStyles.verticalHeader().setVisible(False)
self.verticalLayout.addWidget(self.tblStyles)
self.buttonBox = QtGui.QDialogButtonBox(DlgRenderingStyles)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.verticalLayout.addWidget(self.buttonBox)

self.retranslateUi(DlgRenderingStyles)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), DlgRenderingStyles.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), DlgRenderingStyles.reject)
QtCore.QMetaObject.connectSlotsByName(DlgRenderingStyles)

def retranslateUi(self, DlgRenderingStyles):
DlgRenderingStyles.setWindowTitle(QtGui.QApplication.translate("DlgRenderingStyles", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
item = self.tblStyles.horizontalHeaderItem(0)
item.setText(QtGui.QApplication.translate("DlgRenderingStyles", "Output", None, QtGui.QApplication.UnicodeUTF8))
item = self.tblStyles.horizontalHeaderItem(1)
item.setText(QtGui.QApplication.translate("DlgRenderingStyles", "Style", None, QtGui.QApplication.UnicodeUTF8))

0 comments on commit 7cb0be0

Please sign in to comment.
You can’t perform that action at this time.