forked from qt-creator/qt-creator
ExecuteFilter: Reimplement matchers()
Change-Id: I4a916164d1a81e0bed678ed1579a5da1cbb57f50 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -39,6 +39,43 @@ ExecuteFilter::~ExecuteFilter()
|
|||||||
removeProcess();
|
removeProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LocatorMatcherTasks ExecuteFilter::matchers()
|
||||||
|
{
|
||||||
|
using namespace Tasking;
|
||||||
|
|
||||||
|
TreeStorage<LocatorStorage> storage;
|
||||||
|
|
||||||
|
const auto onSetup = [=] {
|
||||||
|
const QString input = storage->input();
|
||||||
|
LocatorFilterEntries entries;
|
||||||
|
if (!input.isEmpty()) { // avoid empty entry
|
||||||
|
LocatorFilterEntry entry;
|
||||||
|
entry.displayName = input;
|
||||||
|
entry.acceptor = [this, input] { acceptCommand(input); return AcceptResult(); };
|
||||||
|
entries.append(entry);
|
||||||
|
}
|
||||||
|
LocatorFilterEntries others;
|
||||||
|
const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(input);
|
||||||
|
for (const QString &cmd : std::as_const(m_commandHistory)) {
|
||||||
|
if (cmd == input) // avoid repeated entry
|
||||||
|
continue;
|
||||||
|
LocatorFilterEntry entry;
|
||||||
|
entry.displayName = cmd;
|
||||||
|
entry.acceptor = [this, cmd] { acceptCommand(cmd); return AcceptResult(); };
|
||||||
|
const int index = cmd.indexOf(input, 0, entryCaseSensitivity);
|
||||||
|
if (index >= 0) {
|
||||||
|
entry.highlightInfo = {index, int(input.length())};
|
||||||
|
entries.append(entry);
|
||||||
|
} else {
|
||||||
|
others.append(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
storage->reportOutput(entries + others);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
return {{Sync(onSetup), storage}};
|
||||||
|
}
|
||||||
|
|
||||||
void ExecuteFilter::acceptCommand(const QString &cmd)
|
void ExecuteFilter::acceptCommand(const QString &cmd)
|
||||||
{
|
{
|
||||||
const QString displayName = cmd.trimmed();
|
const QString displayName = cmd.trimmed();
|
||||||
|
@@ -32,6 +32,7 @@ public:
|
|||||||
QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &future,
|
QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &future,
|
||||||
const QString &entry) override;
|
const QString &entry) override;
|
||||||
private:
|
private:
|
||||||
|
LocatorMatcherTasks matchers() final;
|
||||||
void acceptCommand(const QString &cmd);
|
void acceptCommand(const QString &cmd);
|
||||||
void done();
|
void done();
|
||||||
void readStandardOutput();
|
void readStandardOutput();
|
||||||
|
Reference in New Issue
Block a user