Skip to content

Commit

Permalink
Filter menu items additionally using item notes
Browse files Browse the repository at this point in the history
Fixes hluk#2170
  • Loading branch information
hluk committed Nov 19, 2022
1 parent 47c8a53 commit e4ffc9b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ bool syncInternalCommandChanges(const Command &command, QVector<Command> *allCom
return true;
}

bool menuItemMatches(const QModelIndex &index, const QString &searchText)
{
for (const int type : {contentType::text, contentType::notes}) {
const QString itemText = index.data(type).toString().toLower();
if ( itemText.contains(searchText.toLower()) )
return true;
}
return false;
}

} // namespace

#ifdef WITH_NATIVE_NOTIFICATIONS
Expand Down Expand Up @@ -1821,11 +1831,8 @@ void MainWindow::addMenuItems(TrayMenu *menu, ClipboardBrowserPlaceholder *place
int itemCount = 0;
for ( int i = 0; i < c->length() && itemCount < maxItemCount; ++i ) {
const QModelIndex index = c->model()->index(i, 0);
if ( !searchText.isEmpty() ) {
const QString itemText = index.data(contentType::text).toString().toLower();
if ( !itemText.contains(searchText.toLower()) )
continue;
}
if ( !searchText.isEmpty() && !menuItemMatches(index, searchText) )
continue;
const QVariantMap data = index.data(contentType::data).toMap();
menu->addClipboardItemAction(data, m_options.trayImages);
++itemCount;
Expand Down

0 comments on commit e4ffc9b

Please sign in to comment.