Skip to content

Commit 21dd387

Browse files
author
volayaf@gmail.com
committed
added multiple input dialgo and panel
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@13 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 398e2a3 commit 21dd387

File tree

5 files changed

+188
-5
lines changed

5 files changed

+188
-5
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Form implementation generated from reading ui file 'D:\projects\sextante\workspaces\qgis-plugin\sextante\src\sextante\gui\MultipleSelectionDialog.ui'
4+
#
5+
# Created: Wed Jan 11 17:48:49 2012
6+
# by: PyQt4 UI code generator 4.9
7+
#
8+
# WARNING! All changes made in this file will be lost!
9+
10+
from PyQt4 import QtCore, QtGui
11+
12+
try:
13+
_fromUtf8 = QtCore.QString.fromUtf8
14+
except AttributeError:
15+
_fromUtf8 = lambda s: s
16+
17+
18+
class MultipleInputDialog(QtGui.QDialog):
19+
def __init__(self, options, selectedoptions):
20+
self.options = options
21+
self.selectedoptions = selectedoptions
22+
QtGui.QDialog.__init__(self)
23+
self.setModal(True)
24+
self.ui = Ui_MultipleInputDialog()
25+
self.ui.setupUi(self)
26+
27+
class Ui_MultipleInputDialog(object):
28+
def setupUi(self, dialog):
29+
self.dialog = dialog
30+
dialog.setObjectName(_fromUtf8("Dialog"))
31+
dialog.resize(381, 320)
32+
dialog.setWindowTitle("Multiple selection")
33+
self.buttonBox = QtGui.QDialogButtonBox(dialog)
34+
self.buttonBox.setGeometry(QtCore.QRect(290, 10, 81, 61))
35+
self.buttonBox.setOrientation(QtCore.Qt.Vertical)
36+
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
37+
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
38+
self.table = QtGui.QTableWidget(dialog)
39+
self.table.setGeometry(QtCore.QRect(10, 10, 271, 301))
40+
self.table.setObjectName(_fromUtf8("table"))
41+
self.table.setColumnCount(1)
42+
self.table.verticalHeader().setVisible(True)
43+
self.table.horizontalHeader().setVisible(True)
44+
self.selectAllButton = QtGui.QPushButton(dialog)
45+
self.selectAllButton.setGeometry(QtCore.QRect(290, 290, 81, 23))
46+
self.selectAllButton.setObjectName(_fromUtf8("selectAllButton"))
47+
self.selectAllButton.setText("(de)Select all")
48+
self.setTableContent()
49+
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.accept)
50+
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), self.reject)
51+
QtCore.QObject.connect(self.selectAllButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.selectAll)
52+
QtCore.QMetaObject.connectSlotsByName(dialog)
53+
54+
def setTableContent(self):
55+
for i in range(len(self.dialog.options)):
56+
item = QtGui.QCheckBox()
57+
item.setText(self.dialog.options[i])
58+
self.table.setCellWidget(i,0, item)
59+
60+
61+
def accept(self):
62+
self.dialog.selectedoptions = []
63+
for i in range(len(self.dialog.options)):
64+
widget = self.table.cellWidget(i, 0)
65+
if widget.isChecked():
66+
self.dialog.selectedoptions.append(i)
67+
68+
69+
def reject(self):
70+
self.dialog.selectedoptions = None
71+
self.dialog.close()
72+
73+
def selectAll(self):
74+
checked = False
75+
for i in range(len(self.dialog.options)):
76+
widget = self.table.cellWidget(i, 0)
77+
if not widget.isChecked():
78+
checked = True
79+
break
80+
for i in range(len(self.dialog.options)):
81+
widget = self.table.cellWidget(i, 0)
82+
widget.setChecked(checked)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from PyQt4 import QtCore, QtGui
2+
from sextante.gui.MultipleInputDialog import MultipleInputDialog
3+
4+
try:
5+
_fromUtf8 = QtCore.QString.fromUtf8
6+
except AttributeError:
7+
_fromUtf8 = lambda s: s
8+
9+
class MultipleInputPanel(QtGui.QWidget):
10+
11+
def __init__(self, options, parent = None):
12+
self.options = options
13+
self.selectedoptions = []
14+
super(MultipleInputPanel, self).__init__(parent)
15+
self.setObjectName(_fromUtf8("MSPanel"))
16+
self.resize(266, 30)
17+
self.pushButton = QtGui.QPushButton(self)
18+
self.pushButton.setGeometry(QtCore.QRect(220, 0, 40, 30))
19+
self.pushButton.setObjectName(_fromUtf8("pushButton"))
20+
self.label = QtGui.QLabel(self)
21+
self.label.setGeometry(QtCore.QRect(0, 0, 220, 30))
22+
self.label.setObjectName(_fromUtf8("label"))
23+
self.pushButton.setText("...")
24+
self.label.setText("0 elements selected")
25+
self.pushButton.clicked.connect(self.showSelectionDialog)
26+
#QtCore.QMetaObject.connectSlotsByName(Form)
27+
28+
def showSelectionDialog(self):
29+
dlg = MultipleInputDialog(self.options, self.selectedoptions)
30+
dlg.exec_()
31+
if dlg.selected != None:
32+
self.selectedoptions = dlg.selectedOptions
33+
self.label.setText(str(len(self.selectedoptions)) + " elements selected")

src/sextante/gui/ParametersDialog.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from sextante.parameters.ParameterVector import ParameterVector
77
from sextante.parameters.ParameterBoolean import ParameterBoolean
88
from sextante.parameters.ParameterSelection import ParameterSelection
9+
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput
10+
from sextante.gui.MultipleInputPanel import MultipleInputPanel
911

1012
try:
1113
_fromUtf8 = QtCore.QString.fromUtf8
@@ -71,6 +73,12 @@ def getItemFromParameter(self, param):
7173
elif isinstance(param, ParameterSelection):
7274
item = QtGui.QComboBox()
7375
item.addItems(param.options)
76+
elif isinstance(param, ParameterMultipleInput):
77+
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
78+
options = QGisLayers.getVectorLayers()
79+
else:
80+
options = QGisLayers.getRasterLayers()
81+
item = MultipleInputPanel(options)
7482
else:
7583
item = QtGui.QLineEdit()
7684

src/sextante/gui/SextanteToolbox.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def setupUi(self, SextanteToolbox):
2727
self.toolbox = SextanteToolbox
2828
SextanteToolbox.setObjectName(_fromUtf8("SextanteToolbox"))
2929
SextanteToolbox.resize(400, 300)
30+
SextanteToolbox.setWindowTitle("SEXTANTE Toolbox")
3031
self.verticalLayoutWidget = QtGui.QWidget(SextanteToolbox)
3132
self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 9, 381, 281))
3233
self.verticalLayoutWidget.setObjectName(_fromUtf8("verticalLayoutWidget"))
@@ -43,8 +44,6 @@ def setupUi(self, SextanteToolbox):
4344
self.verticalLayout.addWidget(self.searchBox)
4445
self.algorithmTree.doubleClicked.connect(self.executeAlgorithm)
4546
self.fillTree()
46-
47-
self.retranslateUi(SextanteToolbox)
4847
QtCore.QMetaObject.connectSlotsByName(SextanteToolbox)
4948

5049
def executeAlgorithm(self):
@@ -88,9 +87,6 @@ def fillTree(self):
8887
groupItem.setExpanded(True)
8988

9089

91-
def retranslateUi(self, SextantePlugin):
92-
SextantePlugin.setWindowTitle("SEXTANTE Toolbox")
93-
9490
class TreeAlgorithmItem(QtGui.QTreeWidgetItem):
9591

9692
def __init__(self, alg, layersCount):
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
class SagaGroupNameDecorator():
2+
3+
groups = {}
4+
groups["contrib_a_perego"] = "Contributions"
5+
groups["geostatistics_grid"]= "Geostatistics"
6+
groups["geostatistics_kriging"]= "Kriging"
7+
groups["geostatistics_points"]= "Geostatistics"
8+
groups["geostatistics_regression"]= "Geostatistics"
9+
groups["grid_analysis"]= "Grid - Analysis"
10+
groups["grid_calculus"]= "Grid - Calculus"
11+
groups["grid_calculus_bsl"]= "Grid - Calculus"
12+
groups["grid_discretisation"]= "Grid - Discretisation"
13+
groups["grid_filter"]= "Grid - Filter"
14+
groups["grid_gridding"]= "Grid - Gridding"
15+
groups["grid_spline"]= "Grid - Spline"
16+
groups["grid_tools"]= "Grid - Tools"
17+
groups["grid_visualisation"]= "Grid - Visualization"
18+
groups["hacres"]= "Hacres"
19+
groups["imagery_segmentation"]= "Imagery - Segmentation"
20+
groups["imagery_classification"]= "Imagery - Classification"
21+
groups["imagery_rga"]= "Imagery - RGA"
22+
groups["io_esri_e00"]= "I/O"
23+
groups["io_gdal"]= "I/O"
24+
groups["io_gps"]= "I/O"
25+
groups["io_grid"]= "I/O"
26+
groups["io_grid_grib2"]= "I/O"
27+
groups["io_grid_image"]= "I/O"
28+
groups["io_odbc"]= "I/O"
29+
groups["io_shapes"]= "I/O"
30+
groups["io_shapes_dxf"]= "I/O"
31+
groups["io_shapes_las"]= "I/O"
32+
groups["io_table"]= "I/O"
33+
groups["lectures_introduction"]= "Lectures"
34+
groups["pj_georeference"]= "Georeferencing"
35+
groups["pj_geotrans"]= "Projections and Transformations"
36+
groups["pj_proj4"]= "Projections and Transformations"
37+
groups["pointcloud_tools"]= "Point clouds"
38+
groups["recreations_fractals"]= "Recreations"
39+
groups["recreations_games"]= "Diversiones"
40+
groups["shapes_grid"]= "Shapes - Grid"
41+
groups["shapes_lines"]= "Shapes - Lines"
42+
groups["shapes_points"]= "Shapes - Points"
43+
groups["shapes_polygons"]= "Shapes - Polygons"
44+
groups["shapes_tools"]= "Shapes - Tools"
45+
groups["shapes_transect"]= "Shapes - Transect"
46+
groups["sim_cellular_automata"]= "Simulation - CA"
47+
groups["sim_ecosystems_hugget"]= "Simulation - Ecosystems"
48+
groups["sim_fire_spreading"]= "Simulation - Fire Spreading"
49+
groups["sim_hydrology"]= "Simulation - Hydrology"
50+
groups["table_calculus"]= "Table - Calculus"
51+
groups["table_tools"]= "Table - Tools"
52+
groups["ta_channels"]= "Terrain Analysis - Channels"
53+
groups["ta_compound"]= "Terrain Analysis - Morphometry"
54+
groups["ta_hydrology"]= "Terrain Analysis - Hydrology"
55+
groups["ta_lighting"]= "Terrain Analysis - Lighting"
56+
groups["ta_morphometry"]= "Terrain Analysis - Morphometry"
57+
groups["ta_preprocessor"]= "Terrain Analysis - Hydrology"
58+
groups["ta_profiles"]= "Terrain Analysis - Profiles"
59+
groups["tin_tools"]= "TIN"
60+
groups["vigra"]= "Vigra"
61+
62+
@staticmethod
63+
def getDecoratedName(groupName):
64+
return SagaGroupNameDecorator.groups[groupName]

0 commit comments

Comments
 (0)