Skip to content
Permalink
Browse files

added fixed table dialog. Improved saga descriptions reading

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@15 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com
volayaf@gmail.com committed Jan 13, 2012
1 parent 21dd387 commit 71f731cbe357decc80bb1901e0b81e3be085631e
@@ -24,7 +24,8 @@ def __init__(self, iface):
Sextante.initialize()

def initGui(self):

self.toolbox = SextanteToolbox(self.iface)
self.toolbox.setVisible(False)
self.toolboxAction = QAction(QIcon(":/plugins/sextante/toolbox.png"), \
"SEXTANTE Toolbox", self.iface.mainWindow())
QObject.connect(self.toolboxAction, SIGNAL("triggered()"), self.openToolbox)
@@ -42,8 +43,9 @@ def unload(self):

def openToolbox(self):

dlg = SextanteToolbox()
dlg.exec_()
#dlg = SextanteToolbox(self.iface)
self.toolbox.setVisible(True)
#dlg.exec_()

def openModeler(self):
pass
@@ -30,14 +30,20 @@ def getAlgorithm(name):
return None

@staticmethod
def asStr():
def algList():
s=""
for alg in Sextante.algs.values():
s+=(str(alg) + "\n")
s+=str(len(Sextante.algs)) + " algorithms"
return s

for provider in Sextante.algs.values():
for alg in provider.values():
s+=(alg.name + " --->" + alg.commandLineName() + "\n")
print s

@staticmethod
def algHelp(name):
alg = Sextante.getAlgorithm(name)
if alg != None:
print(str(alg))
else:
print "Algorithm not found"



@@ -0,0 +1,76 @@
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *

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


class FixedTableDialog(QtGui.QDialog):
def __init__(self, param, table):
QtGui.QDialog.__init__(self)
self.setModal(True)
self.param = param
if table != None:
self.table = table
else:
self.table = []
for i in range(param.numRows):
self.table.append(list())
for j in range(len(param.cols)):
self.table[i].append("0")
self.ui = Ui_FixedTableDialog()
self.ui.setupUi(self)
self.table = None

class Ui_FixedTableDialog(object):
def setupUi(self, dialog):
self.dialog = dialog
dialog.setObjectName(_fromUtf8("Dialog"))
dialog.resize(400, 350)
dialog.setWindowTitle("Fixed Table")
self.buttonBox = QtGui.QDialogButtonBox(dialog)
self.buttonBox.setGeometry(QtCore.QRect(290, 10, 81, 61))
self.buttonBox.setOrientation(QtCore.Qt.Vertical)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.table = QtGui.QTableWidget(dialog)
self.table.setGeometry(QtCore.QRect(10, 10, 270, 300))
self.table.setObjectName(_fromUtf8("table"))
self.table.setColumnCount(len(self.dialog.param.cols))
for i in range(len(self.dialog.param.cols)):
self.table.setColumnWidth(i,380 / len(self.dialog.param.cols))
self.table.setHorizontalHeaderItem(i, QtGui.QTableWidgetItem(self.dialog.param.cols[i]))
self.table.setRowCount(self.dialog.param.numRows)
self.table.verticalHeader().setVisible(False)
self.addRow = QtGui.QPushButton(dialog)
self.addRow.setGeometry(QtCore.QRect(290, 290, 81, 23))
self.addRow.setObjectName(_fromUtf8("addRow"))
self.addRow.setText("Add row")
self.setTableContent()
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), self.reject)
QtCore.QObject.connect(self.addRow, QtCore.SIGNAL(_fromUtf8("clicked()")), self.addRow)
QtCore.QMetaObject.connectSlotsByName(dialog)

def setTableContent(self):
for i in range(len(self.dialog.table)):
for j in range(len(self.dialog.table)):
self.table.setItem(i,j,QtGui.QTableWidgetItem(self.dialog.table[i][j]))

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

def reject(self):
self.dialog.selectedoptions = None
self.dialog.close()

def addRow(self):
self.table.addRow()
@@ -0,0 +1,36 @@
from PyQt4 import QtCore, QtGui
from sextante.gui.FixedTableDialog import FixedTableDialog

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

class FixedTablePanel(QtGui.QWidget):

def __init__(self, param, parent = None):
super(FixedTablePanel, self).__init__(parent)
self.param = param
self.table = []
self.setObjectName(_fromUtf8("MSPanel"))
self.contents = QtGui.QWidget(self)
self.contents.setObjectName(_fromUtf8("contents"))
self.horizontalLayout = QtGui.QHBoxLayout(self.contents)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.horizontalLayout.setObjectName(_fromUtf8("hLayout"))
self.label = QtGui.QLabel(self.contents)
self.label.setObjectName(_fromUtf8("label"))
self.label.setText("Fixed table " + str(len(param.cols)) + " X " + str(param.numRows))
self.horizontalLayout.addWidget(self.label)
self.pushButton = QtGui.QPushButton(self.contents)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton.setText("...")
self.pushButton.clicked.connect(self.showFixedTableDialog)
self.horizontalLayout.addWidget(self.pushButton)

def showFixedTableDialog(self):
dlg = FixedTableDialog(self.param, self.table)
dlg.exec_()
if dlg.table != None:
self.table = dlg.table
@@ -1,13 +1,6 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'D:\projects\sextante\workspaces\qgis-plugin\sextante\src\sextante\gui\MultipleSelectionDialog.ui'
#
# Created: Wed Jan 11 17:48:49 2012
# by: PyQt4 UI code generator 4.9
#
# WARNING! All changes made in this file will be lost!

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

try:
_fromUtf8 = QtCore.QString.fromUtf8
@@ -23,6 +16,7 @@ def __init__(self, options, selectedoptions):
self.setModal(True)
self.ui = Ui_MultipleInputDialog()
self.ui.setupUi(self)
self.selectedoptions = None

class Ui_MultipleInputDialog(object):
def setupUi(self, dialog):
@@ -36,11 +30,12 @@ def setupUi(self, dialog):
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.table = QtGui.QTableWidget(dialog)
self.table.setGeometry(QtCore.QRect(10, 10, 271, 301))
self.table.setGeometry(QtCore.QRect(10, 10, 270, 300))
self.table.setObjectName(_fromUtf8("table"))
self.table.setColumnCount(1)
self.table.verticalHeader().setVisible(True)
self.table.horizontalHeader().setVisible(True)
self.table.setColumnWidth(0,270)
self.table.verticalHeader().setVisible(False)
self.table.horizontalHeader().setVisible(False)
self.selectAllButton = QtGui.QPushButton(dialog)
self.selectAllButton.setGeometry(QtCore.QRect(290, 290, 81, 23))
self.selectAllButton.setObjectName(_fromUtf8("selectAllButton"))
@@ -52,19 +47,21 @@ def setupUi(self, dialog):
QtCore.QMetaObject.connectSlotsByName(dialog)

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


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

self.dialog.close()

def reject(self):
self.dialog.selectedoptions = None
@@ -9,25 +9,29 @@
class MultipleInputPanel(QtGui.QWidget):

def __init__(self, options, parent = None):
super(MultipleInputPanel, self).__init__(parent)
self.options = options
self.selectedoptions = []
super(MultipleInputPanel, self).__init__(parent)
self.setObjectName(_fromUtf8("MSPanel"))
self.resize(266, 30)
self.pushButton = QtGui.QPushButton(self)
self.pushButton.setGeometry(QtCore.QRect(220, 0, 40, 30))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.label = QtGui.QLabel(self)
self.label.setGeometry(QtCore.QRect(0, 0, 220, 30))
self.contents = QtGui.QWidget(self)
self.contents.setObjectName(_fromUtf8("contents"))
self.horizontalLayout = QtGui.QHBoxLayout(self.contents)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0)
self.horizontalLayout.setObjectName(_fromUtf8("hLayout"))
self.label = QtGui.QLabel(self.contents)
self.label.setObjectName(_fromUtf8("label"))
self.pushButton.setText("...")
self.label.setText("0 elements selected")
self.horizontalLayout.addWidget(self.label)
self.pushButton = QtGui.QPushButton(self.contents)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton.setText("...")
self.pushButton.clicked.connect(self.showSelectionDialog)
#QtCore.QMetaObject.connectSlotsByName(Form)
self.horizontalLayout.addWidget(self.pushButton)

def showSelectionDialog(self):
dlg = MultipleInputDialog(self.options, self.selectedoptions)
dlg.exec_()
if dlg.selected != None:
self.selectedoptions = dlg.selectedOptions
if dlg.selectedoptions != None:
self.selectedoptions = dlg.selectedoptions
self.label.setText(str(len(self.selectedoptions)) + " elements selected")

0 comments on commit 71f731c

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