";
+
+ // 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();
+ }
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ switch (index.column()) {
+ case 0:
+ return aliasManager()[index.row()].name;
+ case 1:
+ return aliasManager()[index.row()].expansion;
+ default:
+ return QVariant();
+ }
+ default:
+ return QVariant();
+ }
}
-QVariant AliasesModel::data(const QModelIndex &index, int role) const {
- if(!_modelReady)
- return QVariant();
- if(!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount())
- return QVariant();
+bool AliasesModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (!_modelReady)
+ return false;
+
+ if (!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount() || role != Qt::EditRole)
+ return false;
+
+ QString newValue = value.toString();
+ if (newValue.isEmpty())
+ return false;
- switch(role) {
- case Qt::ToolTipRole:
- switch(index.column()) {
+ switch (index.column()) {
case 0:
- return "