X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Faliasesmodel.cpp;h=47a701eacde5ad7efe9e6d491cbf097c56306f01;hp=46daed838a77b520f8c8003f575b4551d0db1257;hb=fcacaaf16551524c7ebb6114254d005274cc3d63;hpb=695758015a80eb8c158a9ac4c0f1c0b547e70df3 diff --git a/src/qtui/settingspages/aliasesmodel.cpp b/src/qtui/settingspages/aliasesmodel.cpp index 46daed83..47a701ea 100644 --- a/src/qtui/settingspages/aliasesmodel.cpp +++ b/src/qtui/settingspages/aliasesmodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -27,13 +27,11 @@ #include "signalproxy.h" AliasesModel::AliasesModel(QObject *parent) - : QAbstractItemModel(parent), - _configChanged(false), - _modelReady(false) + : QAbstractItemModel(parent) { // we need this signal for future connects to reset the data; - connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected())); - connect(Client::instance(), SIGNAL(disconnected()), this, SLOT(clientDisconnected())); + connect(Client::instance(), &Client::connected, this, &AliasesModel::clientConnected); + connect(Client::instance(), &Client::disconnected, this, &AliasesModel::clientDisconnected); if (Client::isConnected()) clientConnected(); @@ -58,17 +56,78 @@ QVariant AliasesModel::data(const QModelIndex &index, int role) const "It can be used as a regular slash command.

" "Example: \"foo\" can be used per /foo"); case 1: - return tr("The string the shortcut will be expanded to
" - "special variables:
" - " - $i represents the i'th parameter.
" - " - $i..j represents the i'th to j'th parameter separated by spaces.
" - " - $i.. represents all parameters from i on separated by spaces.
" - " - $i:hostname represents the hostname of the user identified by the i'th parameter or a * if unknown.
" - " - $0 the whole string.
" - " - $nick your current nickname
" - " - $channel the name of the selected channel

" - "Multiple commands can be separated with semicolons

" - "Example: \"Test $1; Test $2; Test All $0\" will be expanded to three separate messages \"Test 1\", \"Test 2\" and \"Test All 1 2 3\" when called like /test 1 2 3"); + { + // To avoid overwhelming the user, organize things into a table + QString strTooltip; + QTextStream tooltip( &strTooltip, QIODevice::WriteOnly ); + tooltip << ""; + + // Function to add a row to the tooltip table + auto addRow = [&]( + const QString& key, const QString& value = QString(), bool condition = true) { + if (condition) { + if (value.isEmpty()) { + tooltip << "" + << key << ""; + } else { + tooltip << "" + << key << "" << value << ""; + } + } + }; + + tooltip << "

" + << tr("The string the shortcut will be expanded to") << "

"; + + tooltip << "

" + << tr("Special variables") << "

"; + + // Variable option table + tooltip << ""; + + // Parameter variables + addRow(tr("Parameter variables")); + addRow("$i", tr("i'th parameter")); + addRow("$i..j", tr("i'th to j'th parameter separated by spaces")); + addRow("$i..", tr("all parameters from i on separated by spaces")); + + // IrcUser handling + addRow(tr("Nickname parameter variables")); + addRow("$i:account", + tr("account of user identified by i'th parameter, or a '*' if logged out or " + "unknown")); + addRow("$i:hostname", + tr("hostname of user identified by i'th parameter, or a '*' if unknown")); + addRow("$i:ident", + tr("ident of user identified by i'th parameter, or a '*' if unknown")); + addRow("$i:identd", + tr("ident of user identified by i'th parameter if verified, or a '*' if unknown " + "or unverified (prefixed with '~')")); + + // General variables + addRow(tr("General variables")); + addRow("$0", tr("the whole string")); + addRow("$nick", tr("your current nickname")); + addRow("$channel", tr("the name of the selected channel")); + + // End table + tooltip << "
"; + + // Example header + tooltip << "

" + << tr("Multiple commands can be separated with semicolons") << "

"; + // Example + tooltip << "

"; + tooltip << QString("

%1 %2
").arg( + tr("Example:"), tr("\"Test $1; Test $2; Test All $0\"")); + tooltip << tr("...will be expanded to three separate messages \"Test 1\", \"Test 2\" " + "and \"Test All 1 2 3\" when called like /test 1 2 3") + << "

"; + + // End tooltip + tooltip << "
"; + return strTooltip; + } default: return QVariant(); } @@ -196,7 +255,7 @@ QModelIndex AliasesModel::index(int row, int column, const QModelIndex &parent) { Q_UNUSED(parent); if (row >= rowCount() || column >= columnCount()) - return QModelIndex(); + return {}; return createIndex(row, column); } @@ -268,7 +327,7 @@ void AliasesModel::clientConnected() if (Client::aliasManager()->isInitialized()) initDone(); else - connect(Client::aliasManager(), SIGNAL(initDone()), SLOT(initDone())); + connect(Client::aliasManager(), &SyncableObject::initDone, this, &AliasesModel::initDone); }