Something went wrong. Try again.
The agentic engineering control plane for the posthuman future
Something went wrong. Try again.
1.5 kB · 59 lines
C++
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960#include "CommandRowProvider.h"
#include <QVariantMap>
#include <utility>
#include "Commands.h"
CommandRowProvider::CommandRowProvider(QObject* parent) : FuzzyRowProvider(parent) {}
void CommandRowProvider::setCommands(Commands* commands){ if (m_commands == commands) { return; } m_commands = commands; emit commandsChanged(); invalidate();}
void CommandRowProvider::captureInputs(){ m_snapshot.clear(); if (m_commands == nullptr) { return; } const QVariantList commands = m_commands->paletteCommands(); m_snapshot.reserve(commands.size()); for (const QVariant& entry : commands) { const CommandDef* const command = entry.value<CommandDef*>(); if (command == nullptr) { continue; } QVariantMap row; row.insert(QStringLiteral("title"), command->title()); row.insert(QStringLiteral("subtitle"), command->shortcutHint()); row.insert(QStringLiteral("id"), command->commandId()); m_snapshot.append(row); }}
QVariantList CommandRowProvider::rowsForQuery(const QString& query){ if (query.isEmpty()) { return m_snapshot; } // The palette's original semantics: a case-insensitive substring match on // the title, declaration order preserved. const QString needle = query.toLower(); QVariantList out; for (const QVariant& row : m_snapshot) { if (row.toMap().value(QStringLiteral("title")).toString().toLower().contains( needle)) { out.append(row); } } return out;}