+
+void NetworkModelController::handleNickAction(ActionType type, QAction *action)
+{
+ foreach(QModelIndex index, indexList()) {
+ NetworkId networkId = index.data(NetworkModel::NetworkIdRole).value<NetworkId>();
+ if (!networkId.isValid())
+ continue;
+ QString nick = nickName(index);
+ if (nick.isEmpty())
+ continue;
+ BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+ if (!bufferInfo.isValid())
+ continue;
+
+ switch (type) {
+ case NickWhois:
+ Client::userInput(bufferInfo, QString("/WHOIS %1 %1").arg(nick));
+ break;
+ case NickCtcpVersion:
+ Client::userInput(bufferInfo, QString("/CTCP %1 VERSION").arg(nick));
+ break;
+ case NickCtcpPing:
+ Client::userInput(bufferInfo, QString("/CTCP %1 PING").arg(nick));
+ break;
+ case NickCtcpTime:
+ Client::userInput(bufferInfo, QString("/CTCP %1 TIME").arg(nick));
+ break;
+ case NickCtcpClientinfo:
+ Client::userInput(bufferInfo, QString("/CTCP %1 CLIENTINFO").arg(nick));
+ break;
+ case NickOp:
+ Client::userInput(bufferInfo, QString("/OP %1").arg(nick));
+ break;
+ case NickDeop:
+ Client::userInput(bufferInfo, QString("/DEOP %1").arg(nick));
+ break;
+ case NickHalfop:
+ Client::userInput(bufferInfo, QString("/HALFOP %1").arg(nick));
+ break;
+ case NickDehalfop:
+ Client::userInput(bufferInfo, QString("/DEHALFOP %1").arg(nick));
+ break;
+ case NickVoice:
+ Client::userInput(bufferInfo, QString("/VOICE %1").arg(nick));
+ break;
+ case NickDevoice:
+ Client::userInput(bufferInfo, QString("/DEVOICE %1").arg(nick));
+ break;
+ case NickKick:
+ Client::userInput(bufferInfo, QString("/KICK %1").arg(nick));
+ break;
+ case NickBan:
+ Client::userInput(bufferInfo, QString("/BAN %1").arg(nick));
+ break;
+ case NickKickBan:
+ Client::userInput(bufferInfo, QString("/BAN %1").arg(nick));
+ Client::userInput(bufferInfo, QString("/KICK %1").arg(nick));
+ break;
+ case NickSwitchTo:
+ case NickQuery:
+ Client::bufferModel()->switchToOrStartQuery(networkId, nick);
+ break;
+ case NickIgnoreUser:
+ {
+ IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ if (!ircUser)
+ break;
+ Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
+ action->property("ignoreRule").toString(),
+ false, IgnoreListManager::SoftStrictness,
+ IgnoreListManager::NetworkScope,
+ ircUser->network()->networkName(), true);
+ break;
+ }
+ case NickIgnoreHost:
+ {
+ IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ if (!ircUser)
+ break;
+ Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
+ action->property("ignoreRule").toString(),
+ false, IgnoreListManager::SoftStrictness,
+ IgnoreListManager::NetworkScope,
+ ircUser->network()->networkName(), true);
+ break;
+ }
+ case NickIgnoreDomain:
+ {
+ IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ if (!ircUser)
+ break;
+ Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
+ action->property("ignoreRule").toString(),
+ false, IgnoreListManager::SoftStrictness,
+ IgnoreListManager::NetworkScope,
+ ircUser->network()->networkName(), true);
+ break;
+ }
+ case NickIgnoreCustom:
+ // forward that to mainwin since we can access the settingspage only from there
+ emit showIgnoreList(action->property("ignoreRule").toString());
+ break;
+ case NickIgnoreToggleEnabled0:
+ case NickIgnoreToggleEnabled1:
+ case NickIgnoreToggleEnabled2:
+ case NickIgnoreToggleEnabled3:
+ case NickIgnoreToggleEnabled4:
+ Client::ignoreListManager()->requestToggleIgnoreRule(action->property("ignoreRule").toString());
+ break;
+ default:
+ qWarning() << "Unhandled nick action";
+ }
+ }
+}
+
+