refactor: use the commands and prefix from actionhandler.cpp
This commit is contained in:
@@ -4,13 +4,14 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "commandmodel.h"
|
#include "commandmodel.h"
|
||||||
|
#include "actionshandler.h"
|
||||||
|
|
||||||
|
|
||||||
QVariantList CommandModel::filterModel(const QString &filter)
|
QVariantList CommandModel::filterModel(const QString &filter)
|
||||||
{
|
{
|
||||||
QVariantList result;
|
QVariantList result;
|
||||||
|
|
||||||
for (const QVariant &e : matrix) {
|
for (const QVariant &e : ActionsHandler::commands()) {
|
||||||
auto command = qvariant_cast<Command>(e);
|
auto command = qvariant_cast<Command>(e);
|
||||||
if (command.command.startsWith(filter)) {
|
if (command.command.startsWith(filter)) {
|
||||||
result.append(e);
|
result.append(e);
|
||||||
@@ -22,11 +23,3 @@ QVariantList CommandModel::filterModel(const QString &filter)
|
|||||||
|
|
||||||
return result;
|
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"}),
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -58,6 +58,4 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE static QVariantList filterModel(const QString &filter);
|
Q_INVOKABLE static QVariantList filterModel(const QString &filter);
|
||||||
|
|
||||||
private:
|
|
||||||
static const QVariantList matrix;
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user