// SPDX-FileCopyrightText: 2021 Srevin Saju // SPDX-License-Identifier: GPL-3.0-or-later #include #include "actionshandler.h" #include "commandmodel.h" QVariantList CommandModel::filterModel(const QString &filter) { QVariantList result; for (const QVariant &e : CommandModel::commands()) { auto command = qvariant_cast(e); if (command.command.startsWith(filter)) { result.append(e); if (result.length() > 10) { return result; } } } return result; } QVariantList CommandModel::commands() { QVariantList commands; // Messages commands commands.append(QVariant::fromValue(Command{ QStringLiteral("/me "), QStringLiteral(""), i18n("Displays action")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/shrug "), QStringLiteral(""), i18n("Prepends ¯\\_(ツ)_/¯ to a plain-text message")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/lenny "), QStringLiteral(""), i18n("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/plain "), QStringLiteral(""), i18n("Sends a message as plain text, without interpreting it as markdown")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/html "), QStringLiteral(""), i18n("Sends a message as html, without interpreting it as markdown")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/rainbow "), QStringLiteral(""), i18n("Sends the given message coloured as a rainbow")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/rainbowme "), QStringLiteral(""), i18n("Sends the given emote coloured as a rainbow")})); // Actions commands commands.append(QVariant::fromValue(Command{ QStringLiteral("/join "), QStringLiteral(""), i18n("Joins room with given address")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/part "), QStringLiteral("[]"), i18n("Leave room")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/invite "), QStringLiteral(""), i18n("Invites user with given id to current room")})); commands.append(QVariant::fromValue(Command{ QStringLiteral("/react "), QStringLiteral(""), i18n("React to this message with a text")})); // TODO more see elements /help action return commands; }