From 20a4954cbdb82861ba9ebb5ebe5030f5b5bac976 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 17 Apr 2023 09:16:36 +0000 Subject: [PATCH] Revert "CommandLocator: Use Acceptor for LocatorFilterEntry" This reverts commit 962888cb02f0b851d6c9945f96f71298f1be7dda. Reason for revert: Applied too early and produced a conflict Change-Id: I98a2895a81196b61cf7020a187d3740be231f671 Reviewed-by: Jarek Kobus --- .../coreplugin/locator/commandlocator.cpp | 34 ++++++++++++------- .../coreplugin/locator/commandlocator.h | 3 ++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/plugins/coreplugin/locator/commandlocator.cpp b/src/plugins/coreplugin/locator/commandlocator.cpp index 9c644f4f998..387cae9fef6 100644 --- a/src/plugins/coreplugin/locator/commandlocator.cpp +++ b/src/plugins/coreplugin/locator/commandlocator.cpp @@ -17,7 +17,7 @@ namespace Core { struct CommandLocatorPrivate { QList commands; - QList> commandsData; + QList> commandsData; }; /*! @@ -61,7 +61,7 @@ void CommandLocator::prepareSearch(const QString &entry) continue; QAction *action = command->action(); if (action && action->isEnabled()) - d->commandsData.append({action, action->text()}); + d->commandsData.append({i, action->text()}); } } @@ -77,17 +77,8 @@ QList CommandLocator::matchesFor(QFutureInterface= 0) { - QAction *action = pair.first; - LocatorFilterEntry filterEntry; - filterEntry.displayName = text; - filterEntry.acceptor = [action] { - // avoid nested stack trace and blocking locator by delayed triggering - QMetaObject::invokeMethod(action, [action] { - if (action->isEnabled()) - action->trigger(); - }, Qt::QueuedConnection); - return AcceptResult(); - }; + LocatorFilterEntry filterEntry(this, text); + filterEntry.internalData = QVariant(pair.first); filterEntry.highlightInfo = {index, int(entry.length())}; if (index == 0) @@ -100,4 +91,21 @@ QList CommandLocator::matchesFor(QFutureInterface= 0 && index < d->commands.size(), return); + QAction *action = d->commands.at(index)->action(); + // avoid nested stack trace and blocking locator by delayed triggering + QMetaObject::invokeMethod(action, [action] { + if (action->isEnabled()) + action->trigger(); + }, Qt::QueuedConnection); +} + } // namespace Core diff --git a/src/plugins/coreplugin/locator/commandlocator.h b/src/plugins/coreplugin/locator/commandlocator.h index e47fbde5c41..8199661bed6 100644 --- a/src/plugins/coreplugin/locator/commandlocator.h +++ b/src/plugins/coreplugin/locator/commandlocator.h @@ -26,6 +26,9 @@ public: void prepareSearch(const QString &entry) override; QList matchesFor(QFutureInterface &future, const QString &entry) override; + void accept(const LocatorFilterEntry &selection, + QString *newText, int *selectionStart, int *selectionLength) const override; + private: CommandLocatorPrivate *d = nullptr; };