forked from qt-creator/qt-creator
MacroLocatorFilter: Remove the old matchesFor() implementation
Change-Id: I44869742c590125805eab277464ffde3df3a2bc2 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -73,50 +73,3 @@ LocatorMatcherTasks MacroLocatorFilter::matchers()
|
||||
};
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
||||
QList<LocatorFilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry)
|
||||
{
|
||||
Q_UNUSED(future)
|
||||
QList<LocatorFilterEntry> goodEntries;
|
||||
QList<LocatorFilterEntry> betterEntries;
|
||||
|
||||
const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry);
|
||||
|
||||
const QMap<QString, Macro*> ¯os = MacroManager::macros();
|
||||
|
||||
for (auto it = macros.cbegin(), end = macros.cend(); it != end; ++it) {
|
||||
const QString displayName = it.key();
|
||||
const QString description = it.value()->description();
|
||||
|
||||
int index = displayName.indexOf(entry, 0, entryCaseSensitivity);
|
||||
LocatorFilterEntry::HighlightInfo::DataType hDataType
|
||||
= LocatorFilterEntry::HighlightInfo::DisplayName;
|
||||
if (index < 0) {
|
||||
index = description.indexOf(entry, 0, entryCaseSensitivity);
|
||||
hDataType = LocatorFilterEntry::HighlightInfo::ExtraInfo;
|
||||
}
|
||||
|
||||
if (index >= 0) {
|
||||
LocatorFilterEntry filterEntry;
|
||||
filterEntry.displayName = displayName;
|
||||
filterEntry.acceptor = [displayName] {
|
||||
IEditor *editor = EditorManager::currentEditor();
|
||||
if (editor)
|
||||
editor->widget()->setFocus(Qt::OtherFocusReason);
|
||||
|
||||
MacroManager::instance()->executeMacro(displayName);
|
||||
return AcceptResult();
|
||||
};
|
||||
filterEntry.displayIcon = m_icon;
|
||||
filterEntry.extraInfo = description;
|
||||
filterEntry.highlightInfo = LocatorFilterEntry::HighlightInfo(index, entry.length(), hDataType);
|
||||
|
||||
if (index == 0)
|
||||
betterEntries.append(filterEntry);
|
||||
else
|
||||
goodEntries.append(filterEntry);
|
||||
}
|
||||
}
|
||||
betterEntries.append(goodEntries);
|
||||
return betterEntries;
|
||||
}
|
||||
|
||||
@@ -5,23 +5,17 @@
|
||||
|
||||
#include <coreplugin/locator/ilocatorfilter.h>
|
||||
|
||||
namespace Macros {
|
||||
namespace Internal {
|
||||
namespace Macros::Internal {
|
||||
|
||||
class MacroLocatorFilter : public Core::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MacroLocatorFilter();
|
||||
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
const QString &entry) override;
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() final;
|
||||
|
||||
const QIcon m_icon;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Macros
|
||||
} // namespace Macros::Internal
|
||||
|
||||
Reference in New Issue
Block a user