From 859b27ddb7c1017199b5163430c2019163de1134 Mon Sep 17 00:00:00 2001 From: Srevin Saju Date: Sat, 1 May 2021 17:20:28 +0300 Subject: [PATCH] refactor: use the commands and prefix from actionhandler.cpp --- src/commandmodel.cpp | 11 ++--------- src/commandmodel.h | 2 -- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/commandmodel.cpp b/src/commandmodel.cpp index f647783c1..c4951a1fe 100644 --- a/src/commandmodel.cpp +++ b/src/commandmodel.cpp @@ -4,13 +4,14 @@ #include #include "commandmodel.h" +#include "actionshandler.h" QVariantList CommandModel::filterModel(const QString &filter) { QVariantList result; - for (const QVariant &e : matrix) { + for (const QVariant &e : ActionsHandler::commands()) { auto command = qvariant_cast(e); if (command.command.startsWith(filter)) { result.append(e); @@ -22,11 +23,3 @@ QVariantList CommandModel::filterModel(const QString &filter) return result; } - - -// the help messages are taken from Element (web matrix client, app.element.io) -const QVariantList CommandModel::matrix = { - QVariant::fromValue(Command{"/join", "Join a given room with address"}), - QVariant::fromValue(Command{"/me", "Displays action"}), - -}; diff --git a/src/commandmodel.h b/src/commandmodel.h index 63ef17409..43842d43a 100644 --- a/src/commandmodel.h +++ b/src/commandmodel.h @@ -58,6 +58,4 @@ public: Q_INVOKABLE static QVariantList filterModel(const QString &filter); -private: - static const QVariantList matrix; };