X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Faliasesmodel.cpp;h=251e9e269f019a71b17aafe3521ee4e53d3f4298;hp=baaaa9b9f17a20e3ee93c551369b9cef2f05b648;hb=9a717378a859383363ea519dd9de9c0138d0db73;hpb=641905d97d6858e3adb59bebf177b6964dd9066a diff --git a/src/qtui/settingspages/aliasesmodel.cpp b/src/qtui/settingspages/aliasesmodel.cpp index baaaa9b9..251e9e26 100644 --- a/src/qtui/settingspages/aliasesmodel.cpp +++ b/src/qtui/settingspages/aliasesmodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -53,9 +53,9 @@ QVariant AliasesModel::data(const QModelIndex &index, int role) const { case 1: return "The string the shortcut will be expanded to
" "special variables:
" - " - $i represenents the i'th parameter.
" - " - $i..j represenents the i'th to j'th parameter separated by spaces.
" - " - $i.. represenents all parameters from i on separated by spaces.
" + " - $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.
" " - $currentnick your current nickname
" @@ -117,6 +117,24 @@ void AliasesModel::newAlias() { endInsertRows(); } +void AliasesModel::loadDefaults() { + AliasManager &manager = cloneAliasManager(); + + if(!manager.isEmpty()) { + beginRemoveRows(QModelIndex(), 0, rowCount() - 1); + for(int i = rowCount() - 1; i >= 0; i--) + manager.removeAt(i); + endRemoveRows(); + } + + AliasManager::AliasList defaults = AliasManager::defaults(); + beginInsertRows(QModelIndex(), 0, defaults.count() - 1); + foreach(AliasManager::Alias alias, defaults) { + manager.addAlias(alias.name, alias.expansion); + } + endInsertRows(); +} + void AliasesModel::removeAlias(int index) { if(index < 0 || index >= rowCount()) return;