X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Faliasesmodel.cpp;h=3896eb8f55d3b7c5714431b27b1265971ea6c5f8;hb=5992edbbfa5a6e4a3c72b07c6f08a464f87dd432;hp=6504fae5610f4413c7859aa08a659733a79af35c;hpb=82dd90f4684db4240311edc13bd3707772e0dbe8;p=quassel.git diff --git a/src/qtui/settingspages/aliasesmodel.cpp b/src/qtui/settingspages/aliasesmodel.cpp index 6504fae5..3896eb8f 100644 --- a/src/qtui/settingspages/aliasesmodel.cpp +++ b/src/qtui/settingspages/aliasesmodel.cpp @@ -54,6 +54,9 @@ QVariant AliasesModel::data(const QModelIndex &index, int role) const { 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: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
" " - $channelname the name of the selected channel

" @@ -114,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;