diff --git a/python/plugins/processing/gui/EditRenderingStylesDialog.py b/python/plugins/processing/gui/EditRenderingStylesDialog.py index b80be8e9e2d..36865fab96b 100644 --- a/python/plugins/processing/gui/EditRenderingStylesDialog.py +++ b/python/plugins/processing/gui/EditRenderingStylesDialog.py @@ -44,7 +44,6 @@ class EditRenderingStylesDialog(QDialog, Ui_DlgRenderingStyles): self.alg = alg - self.setModal(True) self.tblStyles.horizontalHeader().setResizeMode(QHeaderView.Stretch) self.setWindowTitle(self.alg.name) @@ -79,7 +78,7 @@ class EditRenderingStylesDialog(QDialog, Ui_DlgRenderingStyles): 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()) @@ -87,5 +86,5 @@ class EditRenderingStylesDialog(QDialog, Ui_DlgRenderingStyles): QDialog.accept(self) - def rejected(self): + def reject(self): QDialog.reject(self) diff --git a/python/plugins/processing/gui/MultipleInputDialog.py b/python/plugins/processing/gui/MultipleInputDialog.py index 4bfad5ba17d..d74a2eb4762 100644 --- a/python/plugins/processing/gui/MultipleInputDialog.py +++ b/python/plugins/processing/gui/MultipleInputDialog.py @@ -25,81 +25,58 @@ __copyright__ = '(C) 2012, Victor Olaya' __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) diff --git a/python/plugins/processing/ui/DlgMultipleSelection.ui b/python/plugins/processing/ui/DlgMultipleSelection.ui new file mode 100644 index 00000000000..15d3e57ba0c --- /dev/null +++ b/python/plugins/processing/ui/DlgMultipleSelection.ui @@ -0,0 +1,87 @@ + + + DlgMultipleSelection + + + + 0 + 0 + 380 + 320 + + + + Multiple selection + + + + 2 + + + 0 + + + + + 1 + + + false + + + true + + + false + + + + + + + + Qt::Vertical + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DlgMultipleSelection + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DlgMultipleSelection + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/python/plugins/processing/ui/ui_DlgMultipleSelection.py b/python/plugins/processing/ui/ui_DlgMultipleSelection.py new file mode 100644 index 00000000000..5189373be3c --- /dev/null +++ b/python/plugins/processing/ui/ui_DlgMultipleSelection.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'python/plugins/processing/ui/DlgMultipleSelection.ui' +# +# Created: Wed Oct 2 20:04:27 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_DlgMultipleSelection(object): + def setupUi(self, DlgMultipleSelection): + DlgMultipleSelection.setObjectName(_fromUtf8("DlgMultipleSelection")) + DlgMultipleSelection.resize(380, 320) + self.horizontalLayout = QtGui.QHBoxLayout(DlgMultipleSelection) + self.horizontalLayout.setSpacing(2) + self.horizontalLayout.setMargin(0) + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.tblLayers = QtGui.QTableWidget(DlgMultipleSelection) + self.tblLayers.setColumnCount(1) + self.tblLayers.setObjectName(_fromUtf8("tblLayers")) + self.tblLayers.setRowCount(0) + self.tblLayers.horizontalHeader().setVisible(False) + self.tblLayers.horizontalHeader().setStretchLastSection(True) + self.tblLayers.verticalHeader().setVisible(False) + self.horizontalLayout.addWidget(self.tblLayers) + self.buttonBox = QtGui.QDialogButtonBox(DlgMultipleSelection) + self.buttonBox.setOrientation(QtCore.Qt.Vertical) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.horizontalLayout.addWidget(self.buttonBox) + + self.retranslateUi(DlgMultipleSelection) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), DlgMultipleSelection.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), DlgMultipleSelection.reject) + QtCore.QMetaObject.connectSlotsByName(DlgMultipleSelection) + + def retranslateUi(self, DlgMultipleSelection): + DlgMultipleSelection.setWindowTitle(QtGui.QApplication.translate("DlgMultipleSelection", "Multiple selection", None, QtGui.QApplication.UnicodeUTF8)) +