@@ -136,6 +136,12 @@ def textChanged(self):
136
136
showTip = ProcessingConfig .getSetting (ProcessingConfig .SHOW_PROVIDERS_TOOLTIP )
137
137
if showTip :
138
138
self .txtDisabled .setVisible (bool (self .disabledWithMatchingAlgs ))
139
+
140
+ if self .algorithmTree .currentItem () is None or self .algorithmTree .currentItem ().isHidden ():
141
+ # if previously selected item was hidden, auto select the first visible algorithm
142
+ first_visible = self ._findFirstVisibleAlgorithm (self .algorithmTree .invisibleRootItem ())
143
+ if first_visible is not None :
144
+ self .algorithmTree .setCurrentItem (first_visible )
139
145
else :
140
146
self .algorithmTree .collapseAll ()
141
147
self .algorithmTree .invisibleRootItem ().child (0 ).setExpanded (True )
@@ -166,6 +172,27 @@ def _filterItem(self, item, text):
166
172
item .setHidden (True )
167
173
return False
168
174
175
+ def _findFirstVisibleAlgorithm (self , item ):
176
+ """
177
+ Returns the first visible algorithm in the tree widget
178
+ """
179
+ if item is None :
180
+ return None
181
+ if item .childCount () > 0 :
182
+ for i in range (item .childCount ()):
183
+ child = item .child (i )
184
+ first_visible = self ._findFirstVisibleAlgorithm (child )
185
+ if first_visible is not None :
186
+ return first_visible
187
+ return None
188
+ elif isinstance (item , TreeAlgorithmItem ):
189
+ if not item .isHidden ():
190
+ return item
191
+ else :
192
+ return None
193
+ else :
194
+ return None
195
+
169
196
def addProviderActions (self , provider ):
170
197
if provider .id () in ProviderActions .actions :
171
198
toolbarButton = QToolButton ()
0 commit comments