-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added search functionality to toolbox git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@12 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
- Loading branch information
volayaf@gmail.com
committed
Jan 11, 2012
1 parent
eb91e9a
commit 398e2a3
Showing
7 changed files
with
220 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,104 @@ | ||
|
||
from PyQt4 import QtGui | ||
from sextante.gui.ui_SextanteToolbox import Ui_SextanteToolbox | ||
|
||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
from PyQt4 import QtCore, QtGui | ||
from sextante.core.Sextante import Sextante | ||
from sextante.gui.ParametersDialog import ParametersDialog | ||
import copy | ||
from sextante.core.QGisLayers import QGisLayers | ||
|
||
try: | ||
_fromUtf8 = QtCore.QString.fromUtf8 | ||
except AttributeError: | ||
_fromUtf8 = lambda s: s | ||
|
||
|
||
class SextanteToolbox(QtGui.QDialog): | ||
def __init__(self): | ||
QtGui.QDialog.__init__(self) | ||
self.setModal(True) | ||
self.ui = Ui_SextanteToolbox() | ||
self.ui.setupUi(self) | ||
|
||
class Ui_SextanteToolbox(object): | ||
|
||
def setupUi(self, SextanteToolbox): | ||
self.toolbox = SextanteToolbox | ||
SextanteToolbox.setObjectName(_fromUtf8("SextanteToolbox")) | ||
SextanteToolbox.resize(400, 300) | ||
self.verticalLayoutWidget = QtGui.QWidget(SextanteToolbox) | ||
self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 9, 381, 281)) | ||
self.verticalLayoutWidget.setObjectName(_fromUtf8("verticalLayoutWidget")) | ||
self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget) | ||
self.verticalLayout.setMargin(0) | ||
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) | ||
self.algorithmTree = QtGui.QTreeWidget(self.verticalLayoutWidget) | ||
self.algorithmTree.setObjectName(_fromUtf8("algorithmTree")) | ||
self.algorithmTree.setHeaderHidden(True) | ||
self.verticalLayout.addWidget(self.algorithmTree) | ||
self.searchBox = QtGui.QLineEdit(self.verticalLayoutWidget) | ||
self.searchBox.setObjectName(_fromUtf8("searchBox")) | ||
self.searchBox.textChanged.connect(self.fillTree) | ||
self.verticalLayout.addWidget(self.searchBox) | ||
self.algorithmTree.doubleClicked.connect(self.executeAlgorithm) | ||
self.fillTree() | ||
|
||
self.retranslateUi(SextanteToolbox) | ||
QtCore.QMetaObject.connectSlotsByName(SextanteToolbox) | ||
|
||
def executeAlgorithm(self): | ||
item = self.algorithmTree.currentItem() | ||
if isinstance(item, TreeAlgorithmItem): | ||
alg = Sextante.getAlgorithm(item.getAlg().commandLineName()) | ||
alg = copy.deepcopy(alg) | ||
dlg = ParametersDialog(alg) | ||
dlg.exec_() | ||
if dlg.alg != None: | ||
QMessageBox.critical(None, "test", str(alg)) | ||
|
||
|
||
|
||
def fillTree(self): | ||
self.algorithmTree.clear() | ||
text = str(self.searchBox.text()) | ||
layersCount = QGisLayers.getLayersCount() | ||
for providerName in Sextante.algs.keys(): | ||
groups = {} | ||
provider = Sextante.algs[providerName] | ||
algs = provider.values() | ||
for alg in algs: | ||
if text =="" or text.lower() in alg.name.lower(): | ||
if alg.group in groups: | ||
groupItem = groups[alg.group] | ||
else: | ||
groupItem = QtGui.QTreeWidgetItem() | ||
groupItem.setText(0,alg.group) | ||
groups[alg.group] = groupItem | ||
algItem = TreeAlgorithmItem(alg, layersCount) | ||
groupItem.addChild(algItem) | ||
providerItem = QtGui.QTreeWidgetItem() | ||
providerItem.setText(0,providerName) | ||
for groupItem in groups.values(): | ||
providerItem.addChild(groupItem) | ||
self.algorithmTree.addTopLevelItem(providerItem) | ||
providerItem.setExpanded(True) | ||
for groupItem in groups.values(): | ||
if text != "": | ||
groupItem.setExpanded(True) | ||
|
||
|
||
def retranslateUi(self, SextantePlugin): | ||
SextantePlugin.setWindowTitle("SEXTANTE Toolbox") | ||
|
||
class TreeAlgorithmItem(QtGui.QTreeWidgetItem): | ||
|
||
def __init__(self, alg, layersCount): | ||
QTreeWidgetItem.__init__(self) | ||
self.alg = alg | ||
self.setText(0,alg.name) | ||
if not alg.canBeExecuted(layersCount): | ||
self.setForeground(0, QtGui.QBrush(QtGui.QColor(150,150,150))) | ||
|
||
def getAlg(self): | ||
return self.alg |
Oops, something went wrong.