X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fnetworkmodelcontroller.cpp;h=0f948f245c34d62b66642b06571f6c5255ac11df;hp=aaccc05f380a1d39d724eb8591c2ab1de3367858;hb=fcacaaf16551524c7ebb6114254d005274cc3d63;hpb=aebc2f7d1808b4ead2e0370f064ae3935c585840 diff --git a/src/uisupport/networkmodelcontroller.cpp b/src/uisupport/networkmodelcontroller.cpp index aaccc05f..0f948f24 100644 --- a/src/uisupport/networkmodelcontroller.cpp +++ b/src/uisupport/networkmodelcontroller.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 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 * @@ -18,6 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "networkmodelcontroller.h" + #include #include #include @@ -28,28 +30,20 @@ #include #include -#include "networkmodelcontroller.h" - #include "buffermodel.h" #include "buffersettings.h" +#include "client.h" #include "clientidentity.h" +#include "clientignorelistmanager.h" +#include "icon.h" #include "network.h" #include "util.h" -#include "clientignorelistmanager.h" -#include "client.h" NetworkModelController::NetworkModelController(QObject *parent) : QObject(parent), - _actionCollection(new ActionCollection(this)), - _messageFilter(0), - _receiver(0) -{ - connect(_actionCollection, SIGNAL(actionTriggered(QAction *)), SLOT(actionTriggered(QAction *))); -} - - -NetworkModelController::~NetworkModelController() + _actionCollection(new ActionCollection(this)) { + connect(_actionCollection, &ActionCollection::actionTriggered, this, &NetworkModelController::actionTriggered); } @@ -127,7 +121,7 @@ bool NetworkModelController::checkRequirements(const QModelIndex &index, ItemAct QString NetworkModelController::nickName(const QModelIndex &index) const { - IrcUser *ircUser = qobject_cast(index.data(NetworkModel::IrcUserRole).value()); + auto *ircUser = qobject_cast(index.data(NetworkModel::IrcUserRole).value()); if (ircUser) return ircUser->nick(); @@ -145,11 +139,11 @@ BufferId NetworkModelController::findQueryBuffer(const QModelIndex &index, const { NetworkId networkId = index.data(NetworkModel::NetworkIdRole).value(); if (!networkId.isValid()) - return BufferId(); + return {}; QString nick = predefinedNick.isEmpty() ? nickName(index) : predefinedNick; if (nick.isEmpty()) - return BufferId(); + return {}; return findQueryBuffer(networkId, nick); } @@ -174,7 +168,7 @@ void NetworkModelController::removeBuffers(const QModelIndexList &indexList) } QString msg; if (inactive.count()) { - msg = tr("Do you want to delete the following buffer(s) permanently?", 0, inactive.count()); + msg = tr("Do you want to delete the following buffer(s) permanently?", "", inactive.count()); msg += "
    "; int count = 0; foreach(BufferInfo info, inactive) { @@ -192,7 +186,7 @@ void NetworkModelController::removeBuffers(const QModelIndexList &indexList) if (inactive.count() != indexList.count()) msg += tr("
    Active channel buffers cannot be deleted, please part the channel first."); - if (QMessageBox::question(0, tr("Remove buffers permanently?"), msg, QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { + if (QMessageBox::question(nullptr, tr("Remove buffers permanently?"), msg, QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { foreach(BufferInfo info, inactive) Client::removeBuffer(info.bufferId()); } @@ -237,9 +231,9 @@ void NetworkModelController::actionTriggered(QAction *action) void NetworkModelController::handleNetworkAction(ActionType type, QAction *) { if (type == NetworkConnectAllWithDropdown || type == NetworkDisconnectAllWithDropdown || type == NetworkConnectAll || type == NetworkDisconnectAll) { - if (type == NetworkConnectAllWithDropdown && QMessageBox::question(0, tr("Question"), tr("Really Connect to all IRC Networks?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No) + if (type == NetworkConnectAllWithDropdown && QMessageBox::question(nullptr, tr("Question"), tr("Really Connect to all IRC Networks?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No) return; - if (type == NetworkDisconnectAllWithDropdown && QMessageBox::question(0, tr("Question"), tr("Really disconnect from all IRC Networks?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) + if (type == NetworkDisconnectAllWithDropdown && QMessageBox::question(nullptr, tr("Question"), tr("Really disconnect from all IRC Networks?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) return; foreach(NetworkId id, Client::networkIds()) { const Network *net = Client::network(id); @@ -362,6 +356,7 @@ void NetworkModelController::handleHideAction(ActionType type, QAction *action) return; case HideApplyToAll: BufferSettings().setMessageFilter(filter); + // fallthrough case HideUseDefaults: if (_messageFilter) BufferSettings(_messageFilter->idString()).removeFilter(); @@ -410,8 +405,14 @@ void NetworkModelController::handleGeneralAction(ActionType type, QAction *actio break; } case ShowChannelList: + if (networkId.isValid()) { + // Don't immediately list channels, allowing customization of filter first + emit showChannelList(networkId, {}, false); + } + break; + case ShowNetworkConfig: if (networkId.isValid()) - emit showChannelList(networkId); + emit showNetworkConfig(networkId); break; case ShowIgnoreList: if (networkId.isValid()) @@ -486,7 +487,7 @@ void NetworkModelController::handleNickAction(ActionType type, QAction *action) break; case NickIgnoreUser: { - IrcUser *ircUser = qobject_cast(index.data(NetworkModel::IrcUserRole).value()); + auto *ircUser = qobject_cast(index.data(NetworkModel::IrcUserRole).value()); if (!ircUser) break; Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore, @@ -498,7 +499,7 @@ void NetworkModelController::handleNickAction(ActionType type, QAction *action) } case NickIgnoreHost: { - IrcUser *ircUser = qobject_cast(index.data(NetworkModel::IrcUserRole).value()); + auto *ircUser = qobject_cast(index.data(NetworkModel::IrcUserRole).value()); if (!ircUser) break; Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore, @@ -510,7 +511,7 @@ void NetworkModelController::handleNickAction(ActionType type, QAction *action) } case NickIgnoreDomain: { - IrcUser *ircUser = qobject_cast(index.data(NetworkModel::IrcUserRole).value()); + auto *ircUser = qobject_cast(index.data(NetworkModel::IrcUserRole).value()); if (!ircUser) break; Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore, @@ -544,10 +545,10 @@ void NetworkModelController::handleNickAction(ActionType type, QAction *action) NetworkModelController::JoinDlg::JoinDlg(const QModelIndex &index, QWidget *parent) : QDialog(parent) { - setWindowIcon(QIcon::fromTheme("irc-join-channel")); + setWindowIcon(icon::get("irc-join-channel")); setWindowTitle(tr("Join Channel")); - QGridLayout *layout = new QGridLayout(this); + auto *layout = new QGridLayout(this); layout->addWidget(new QLabel(tr("Network:")), 0, 0); layout->addWidget(networks = new QComboBox, 0, 1); layout->addWidget(new QLabel(tr("Channel:")), 1, 0); @@ -562,9 +563,9 @@ NetworkModelController::JoinDlg::JoinDlg(const QModelIndex &index, QWidget *pare networks->setInsertPolicy(QComboBox::InsertAlphabetically); password->setEchoMode(QLineEdit::Password); - connect(buttonBox, SIGNAL(accepted()), SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), SLOT(reject())); - connect(channel, SIGNAL(textChanged(QString)), SLOT(on_channel_textChanged(QString))); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(channel, &QLineEdit::textChanged, this, &JoinDlg::on_channel_textChanged); foreach(NetworkId id, Client::networkIds()) { const Network *net = Client::network(id);