void Console::registerAlias(const std::string &name, const std::string &cmd) { AliasRecord *a = findAlias(name); if (a == nullptr) { verifyRegistration(CON_Lang("Alias registration"), name, false); AliasRecord newAlias(name, cmd); // Zaradi novy alias tak, aby byly setridene podle abecedy size_t position = 0; for (const AliasRecord &alias : aliases) { if (alias.getName().compare(name) > 0) { break; } ++position; } aliases.insert(aliases.begin() + position, newAlias); } else { a->setCommand(cmd); } if (hasFlag(RegInfoFlag)) { print(CON_Format(CON_Lang("Alias registration: \"{0}\" as \"{1}\" has been successful\n")) << name << cmd); } }
AliasesSettingsPage::AliasesSettingsPage(QWidget *parent) : SettingsPage(tr("IRC"), tr("Aliases"), parent) { ui.setupUi(this); ui.newAliasButton->setIcon(icon::get("list-add")); ui.deleteAliasButton->setIcon(icon::get("edit-delete")); ui.aliasesView->setSelectionBehavior(QAbstractItemView::SelectRows); ui.aliasesView->setSelectionMode(QAbstractItemView::SingleSelection); ui.aliasesView->setAlternatingRowColors(true); ui.aliasesView->setTabKeyNavigation(false); ui.aliasesView->setModel(&_aliasesModel); // ui.aliasesView->setSortingEnabled(true); ui.aliasesView->verticalHeader()->hide(); ui.aliasesView->horizontalHeader()->setStretchLastSection(true); connect(ui.newAliasButton, SIGNAL(clicked()), &_aliasesModel, SLOT(newAlias())); connect(ui.deleteAliasButton, SIGNAL(clicked()), this, SLOT(deleteSelectedAlias())); connect(&_aliasesModel, SIGNAL(configChanged(bool)), this, SLOT(setChangedState(bool))); connect(&_aliasesModel, SIGNAL(modelReady(bool)), this, SLOT(enableDialog(bool))); enableDialog(_aliasesModel.isReady()); }