X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fnetworkmodelcontroller.cpp;h=0112ed18964c785e8be72c55cc632e8f78f7e133;hp=1259b6ae62d077092142df192959f6d0fcff0266;hb=f9cd845a9119e0abf450a91d8802f5c1822dd638;hpb=9fc57dc2c000e80fb8bd746a090e2e8210e1278e diff --git a/src/uisupport/networkmodelcontroller.cpp b/src/uisupport/networkmodelcontroller.cpp index 1259b6ae..0112ed18 100644 --- a/src/uisupport/networkmodelcontroller.cpp +++ b/src/uisupport/networkmodelcontroller.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 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,48 +18,42 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "networkmodelcontroller.h" + #include #include #include +#include #include #include #include #include #include -#include "networkmodelcontroller.h" - #include "buffermodel.h" #include "buffersettings.h" -#include "iconloader.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) + _actionCollection(new ActionCollection(this)) { connect(_actionCollection, SIGNAL(actionTriggered(QAction *)), SLOT(actionTriggered(QAction *))); } -NetworkModelController::~NetworkModelController() -{ -} - - Action *NetworkModelController::registerAction(ActionType type, const QString &text, bool checkable) { return registerAction(type, QPixmap(), text, checkable); } -Action *NetworkModelController::registerAction(ActionType type, const QPixmap &icon, const QString &text, bool checkable) +Action *NetworkModelController::registerAction(ActionType type, const QIcon &icon, const QString &text, bool checkable) { Action *act; if (icon.isNull()) @@ -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()); } @@ -236,12 +230,16 @@ void NetworkModelController::actionTriggered(QAction *action) void NetworkModelController::handleNetworkAction(ActionType type, QAction *) { - if (type == NetworkConnectAll || type == NetworkDisconnectAll) { + if (type == NetworkConnectAllWithDropdown || type == NetworkDisconnectAllWithDropdown || type == NetworkConnectAll || type == NetworkDisconnectAll) { + 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(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); - if (type == NetworkConnectAll && net->connectionState() == Network::Disconnected) + if ((type == NetworkConnectAllWithDropdown || type == NetworkConnectAll) && net->connectionState() == Network::Disconnected) net->requestConnect(); - if (type == NetworkDisconnectAll && net->connectionState() != Network::Disconnected) + if ((type == NetworkDisconnectAllWithDropdown || type == NetworkDisconnectAll) && net->connectionState() != Network::Disconnected) net->requestDisconnect(); } return; @@ -307,6 +305,19 @@ void NetworkModelController::handleHideAction(ActionType type, QAction *action) { Q_UNUSED(action) + if (type == HideJoinPartQuit) { + bool anyChecked = NetworkModelController::action(HideJoin)->isChecked(); + anyChecked |= NetworkModelController::action(HidePart)->isChecked(); + anyChecked |= NetworkModelController::action(HideQuit)->isChecked(); + + // If any are checked, uncheck them all. + // If none are checked, check them all. + bool newCheckedState = !anyChecked; + NetworkModelController::action(HideJoin)->setChecked(newCheckedState); + NetworkModelController::action(HidePart)->setChecked(newCheckedState); + NetworkModelController::action(HideQuit)->setChecked(newCheckedState); + } + int filter = 0; if (NetworkModelController::action(HideJoin)->isChecked()) filter |= Message::Join | Message::NetsplitJoin; @@ -324,6 +335,7 @@ void NetworkModelController::handleHideAction(ActionType type, QAction *action) filter |= Message::Topic; switch (type) { + case HideJoinPartQuit: case HideJoin: case HidePart: case HideQuit: @@ -344,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(); @@ -392,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()) @@ -468,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, @@ -480,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, @@ -492,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, @@ -526,10 +545,10 @@ void NetworkModelController::handleNickAction(ActionType type, QAction *action) NetworkModelController::JoinDlg::JoinDlg(const QModelIndex &index, QWidget *parent) : QDialog(parent) { - setWindowIcon(SmallIcon("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);