Skip to content

Commit e61b89f

Browse files
committed
matches keywords in addition to matching title in quick menu widget search
1 parent 0f84885 commit e61b89f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Orange/canvas/document/quickmenu.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def setModel(self, model):
259259
proxy.setFilterCaseSensitivity(False)
260260
proxy.setSourceModel(flat)
261261
ToolTree.setModel(self, proxy)
262+
print(flat.data(proxy.index(0, 0), role=QtWidgetRegistry.WIDGET_DESC_ROLE))
262263
self.ensureCurrent()
263264

264265
def setFilterFixedString(self, pattern):
@@ -323,7 +324,22 @@ def filterFunc(self):
323324
return self.__filterFunc
324325

325326
def filterAcceptsRow(self, row, parent=QModelIndex()):
326-
accepted = QSortFilterProxyModel.filterAcceptsRow(self, row, parent)
327+
flat_model = self.sourceModel()
328+
index = flat_model.index(row, self.filterKeyColumn(), parent)
329+
keywords = flat_model.data(index, role=QtWidgetRegistry.WIDGET_DESC_ROLE).keywords
330+
331+
# match keywords
332+
accepted = False
333+
for keyword in keywords:
334+
if self.filterRegExp().indexIn(keyword) > -1:
335+
accepted = True
336+
break
337+
338+
# if does not match keywords, match title
339+
if not accepted:
340+
accepted = QSortFilterProxyModel.filterAcceptsRow(self, row, parent)
341+
342+
# if matches query, apply filter function (compatibility with paired widget)
327343
if accepted and self.__filterFunc is not None:
328344
model = self.sourceModel()
329345
index = model.index(row, self.filterKeyColumn(), parent)

0 commit comments

Comments
 (0)