Skip to content
Permalink
Browse files

Merge pull request #6423 from nyalldawson/proc_auto_select_alg

[processing] Some toolbox ux tweaks
  • Loading branch information
alexbruy committed Feb 23, 2018
2 parents a5399de + 62cd1ed commit 673421b00d7e6509fde3d8e743a5c43e3f855d22
Showing with 31 additions and 0 deletions.
  1. +31 −0 python/plugins/processing/gui/ProcessingToolbox.py
@@ -71,6 +71,7 @@ def __init__(self):
self.processingToolbar.setIconSize(iface.iconSize(True))

self.searchBox.textChanged.connect(self.textChanged)
self.searchBox.returnPressed.connect(self.activateCurrent)
self.algorithmTree.customContextMenuRequested.connect(
self.showPopupMenu)
self.algorithmTree.doubleClicked.connect(self.executeAlgorithm)
@@ -136,6 +137,12 @@ def textChanged(self):
showTip = ProcessingConfig.getSetting(ProcessingConfig.SHOW_PROVIDERS_TOOLTIP)
if showTip:
self.txtDisabled.setVisible(bool(self.disabledWithMatchingAlgs))

if self.algorithmTree.currentItem() is None or self.algorithmTree.currentItem().isHidden():
# if previously selected item was hidden, auto select the first visible algorithm
first_visible = self._findFirstVisibleAlgorithm(self.algorithmTree.invisibleRootItem())
if first_visible is not None:
self.algorithmTree.setCurrentItem(first_visible)
else:
self.algorithmTree.collapseAll()
self.algorithmTree.invisibleRootItem().child(0).setExpanded(True)
@@ -166,6 +173,27 @@ def _filterItem(self, item, text):
item.setHidden(True)
return False

def _findFirstVisibleAlgorithm(self, item):
"""
Returns the first visible algorithm in the tree widget
"""
if item is None:
return None
if item.childCount() > 0:
for i in range(item.childCount()):
child = item.child(i)
first_visible = self._findFirstVisibleAlgorithm(child)
if first_visible is not None:
return first_visible
return None
elif isinstance(item, TreeAlgorithmItem):
if not item.isHidden():
return item
else:
return None
else:
return None

def addProviderActions(self, provider):
if provider.id() in ProviderActions.actions:
toolbarButton = QToolButton()
@@ -269,6 +297,9 @@ def editRenderingStyles(self):
dlg = EditRenderingStylesDialog(alg)
dlg.exec_()

def activateCurrent(self):
self.executeAlgorithm()

def executeAlgorithmAsBatchProcess(self):
item = self.algorithmTree.currentItem()
if isinstance(item, TreeAlgorithmItem):

0 comments on commit 673421b

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