@@ -71,6 +71,7 @@ def __init__(self):
71
71
self .processingToolbar .setIconSize (iface .iconSize (True ))
72
72
73
73
self .searchBox .textChanged .connect (self .textChanged )
74
+ self .searchBox .returnPressed .connect (self .activateCurrent )
74
75
self .algorithmTree .customContextMenuRequested .connect (
75
76
self .showPopupMenu )
76
77
self .algorithmTree .doubleClicked .connect (self .executeAlgorithm )
@@ -136,6 +137,12 @@ def textChanged(self):
136
137
showTip = ProcessingConfig .getSetting (ProcessingConfig .SHOW_PROVIDERS_TOOLTIP )
137
138
if showTip :
138
139
self .txtDisabled .setVisible (bool (self .disabledWithMatchingAlgs ))
140
+
141
+ if self .algorithmTree .currentItem () is None or self .algorithmTree .currentItem ().isHidden ():
142
+ # if previously selected item was hidden, auto select the first visible algorithm
143
+ first_visible = self ._findFirstVisibleAlgorithm (self .algorithmTree .invisibleRootItem ())
144
+ if first_visible is not None :
145
+ self .algorithmTree .setCurrentItem (first_visible )
139
146
else :
140
147
self .algorithmTree .collapseAll ()
141
148
self .algorithmTree .invisibleRootItem ().child (0 ).setExpanded (True )
@@ -166,6 +173,27 @@ def _filterItem(self, item, text):
166
173
item .setHidden (True )
167
174
return False
168
175
176
+ def _findFirstVisibleAlgorithm (self , item ):
177
+ """
178
+ Returns the first visible algorithm in the tree widget
179
+ """
180
+ if item is None :
181
+ return None
182
+ if item .childCount () > 0 :
183
+ for i in range (item .childCount ()):
184
+ child = item .child (i )
185
+ first_visible = self ._findFirstVisibleAlgorithm (child )
186
+ if first_visible is not None :
187
+ return first_visible
188
+ return None
189
+ elif isinstance (item , TreeAlgorithmItem ):
190
+ if not item .isHidden ():
191
+ return item
192
+ else :
193
+ return None
194
+ else :
195
+ return None
196
+
169
197
def addProviderActions (self , provider ):
170
198
if provider .id () in ProviderActions .actions :
171
199
toolbarButton = QToolButton ()
@@ -269,6 +297,9 @@ def editRenderingStyles(self):
269
297
dlg = EditRenderingStylesDialog (alg )
270
298
dlg .exec_ ()
271
299
300
+ def activateCurrent (self ):
301
+ self .executeAlgorithm ()
302
+
272
303
def executeAlgorithmAsBatchProcess (self ):
273
304
item = self .algorithmTree .currentItem ()
274
305
if isinstance (item , TreeAlgorithmItem ):
0 commit comments