64 changes: 21 additions & 43 deletions python/plugins/processing/gui/AutofillDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,63 +25,41 @@

__revision__ = '$Format:%H$'

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

from processing.ui.ui_DlgAutofill import Ui_DlgAutofill

class AutofillDialog(QtGui.QDialog):

class AutofillDialog(QDialog, Ui_DlgAutofill):

DO_NOT_AUTOFILL = 0
FILL_WITH_NUMBERS = 1
FILL_WITH_PARAMETER = 2

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

self.verticalLayout = QtGui.QVBoxLayout(self)
self.verticalLayout.setSpacing(40)
self.verticalLayout.setMargin(20)
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.label = QtGui.QLabel('Autofill mode')
self.horizontalLayout.addWidget(self.label)
self.typeCombo = QtGui.QComboBox()
self.typeCombo.addItem('Do not autofill')
self.typeCombo.addItem('Fill with numbers')
self.typeCombo.addItem('Fill with parameter values')
self.horizontalLayout.addWidget(self.typeCombo)
self.verticalLayout.addLayout(self.horizontalLayout)
self.horizontalLayout2 = QtGui.QHBoxLayout(self)
self.horizontalLayout2.setSpacing(2)
self.horizontalLayout2.setMargin(0)
self.label2 = QtGui.QLabel('Parameter to use')
self.horizontalLayout2.addWidget(self.label2)
self.fieldCombo = QtGui.QComboBox()
for param in alg.parameters:
self.fieldCombo.addItem(param.description)
self.horizontalLayout2.addWidget(self.fieldCombo)
self.verticalLayout.addLayout(self.horizontalLayout2)
self.cmbFillType.currentIndexChanged.connect(self.toggleParameters)

self.buttonBox = QtGui.QDialogButtonBox(self)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
| QtGui.QDialogButtonBox.Ok)
QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'),
self.okPressed)
QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'),
self.cancelPressed)
self.verticalLayout.addWidget(self.buttonBox)
for param in alg.parameters:
self.cmbParameters.addItem(param.description)

self.setLayout(self.verticalLayout)
def toggleParameters(self, index):
if index == self.FILL_WITH_PARAMETER:
self.lblParameters.setEnabled(True)
self.cmbParameters.setEnabled(True)
else:
self.lblParameters.setEnabled(False)
self.cmbParameters.setEnabled(False)

def okPressed(self):
self.mode = self.typeCombo.currentIndex()
self.param = self.fieldCombo.currentIndex()
self.close()
def accept(self):
self.mode = self.cmbFillType.currentIndex()
self.param = self.cmbParameters.currentIndex()
QDialog.accept(self)

def cancelPressed(self):
def reject(self):
self.mode = None
self.param = None
self.close()
QDialog.reject(self)
5 changes: 2 additions & 3 deletions python/plugins/processing/gui/EditRenderingStylesDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(self, alg):

self.alg = alg

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

Expand Down Expand Up @@ -79,13 +78,13 @@ def setTableContent(self):
self.tblStyles.setRowHeight(i, 22)
i += 1

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

QDialog.accept(self)

def rejected(self):
def reject(self):
QDialog.reject(self)
73 changes: 25 additions & 48 deletions python/plugins/processing/gui/MultipleInputDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,81 +25,58 @@

__revision__ = '$Format:%H$'

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

from processing.ui.ui_DlgMultipleSelection import Ui_DlgMultipleSelection

class MultipleInputDialog(QtGui.QDialog):

def __init__(self, options, selectedoptions):
class MultipleInputDialog(QDialog, Ui_DlgMultipleSelection):

def __init__(self, options, selectedoptions=None):
QDialog.__init__(self)
self.setupUi(self)

self.options = options
self.selectedoptions = selectedoptions
QtGui.QDialog.__init__(self)
self.setModal(True)
self.setupUi()
self.selectedoptions = None

def setupUi(self):
self.resize(381, 320)
self.setWindowTitle('Multiple selection')
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.buttonBox = QtGui.QDialogButtonBox()
self.buttonBox.setOrientation(QtCore.Qt.Vertical)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
| QtGui.QDialogButtonBox.Ok)
self.table = QtGui.QTableWidget()
self.table.setColumnCount(1)
self.table.setColumnWidth(0, 270)
self.table.verticalHeader().setVisible(False)
self.table.horizontalHeader().setVisible(False)
self.table.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
self.selectAllButton = QtGui.QPushButton()
self.selectAllButton.setText('(de)Select all')
# Additional buttons
self.btnSelectAll = QPushButton(self.tr('(de)Select all'))
self.buttonBox.addButton(self.btnSelectAll,
QDialogButtonBox.ActionRole)

self.btnSelectAll.clicked.connect(self.toggleSelection)

self.setTableContent()
self.buttonBox.addButton(self.selectAllButton,
QtGui.QDialogButtonBox.ActionRole)
self.horizontalLayout.addWidget(self.table)
self.horizontalLayout.addWidget(self.buttonBox)
self.setLayout(self.horizontalLayout)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'),
self.okPressed)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'),
self.cancelPressed)
QtCore.QObject.connect(self.selectAllButton, QtCore.SIGNAL('clicked()'
), self.selectAll)
QtCore.QMetaObject.connectSlotsByName(self)

def setTableContent(self):
self.table.setRowCount(len(self.options))
self.tblLayers.setRowCount(len(self.options))
for i in range(len(self.options)):
item = QtGui.QCheckBox()
item = QCheckBox()
item.setText(self.options[i])
if i in self.selectedoptions:
item.setChecked(True)
self.table.setCellWidget(i, 0, item)
self.tblLayers.setCellWidget(i, 0, item)

def okPressed(self):
def accept(self):
self.selectedoptions = []
for i in range(len(self.options)):
widget = self.table.cellWidget(i, 0)
widget = self.tblLayers.cellWidget(i, 0)
if widget.isChecked():
self.selectedoptions.append(i)
self.close()
QDialog.accept(self)

def cancelPressed(self):
def reject(self):
self.selectedoptions = None
self.close()
QDialog.reject(self)

def selectAll(self):
def toggleSelection(self):
checked = False
for i in range(len(self.options)):
widget = self.table.cellWidget(i, 0)
widget = self.tblLayers.cellWidget(i, 0)
if not widget.isChecked():
checked = True
break
for i in range(len(self.options)):
widget = self.table.cellWidget(i, 0)
widget = self.tblLayers.cellWidget(i, 0)
widget.setChecked(checked)
113 changes: 113 additions & 0 deletions python/plugins/processing/ui/DlgAutofill.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>DlgAutofill</class>
<widget class="QDialog" name="DlgAutofill">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>104</height>
</rect>
</property>
<property name="windowTitle">
<string>Autofill settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Autofill mode</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cmbFillType">
<item>
<property name="text">
<string>Do not autofill</string>
</property>
</item>
<item>
<property name="text">
<string>Fill with numbers</string>
</property>
</item>
<item>
<property name="text">
<string>Fill with parameter values</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblParameters">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Parameter to use</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cmbParameters">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<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>DlgAutofill</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>DlgAutofill</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>
Loading