From: Janne Koschinski Date: Thu, 21 Dec 2017 22:22:52 +0000 (+0100) Subject: Implement /ignore functionality X-Git-Tag: travis-deploy-test~181 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=9f5158eab420977b42d8fc6b98d2eb0de66cbaa4 Implement /ignore functionality - If /ignore is used, a new rule for nickname!*@* is added, with dynamic strictness, limited to the current network. - If /ignore (where rule contains ! or @) is used, that rule is added, with dynamic strictness, limited to the current network. - If /ignore with no parameters is used, the ignore list is shown --- diff --git a/src/client/client.h b/src/client/client.h index 89ef829d..302689e8 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -163,6 +163,7 @@ signals: void requestNetworkStates(); void showConfigWizard(const QVariantMap &coredata); + void showIgnoreList(QString ignoreRule); void connected(); void disconnected(); diff --git a/src/client/clientuserinputhandler.cpp b/src/client/clientuserinputhandler.cpp index 6619931f..bddd5c7c 100644 --- a/src/client/clientuserinputhandler.cpp +++ b/src/client/clientuserinputhandler.cpp @@ -20,18 +20,20 @@ #include "clientuserinputhandler.h" +#include "bufferinfo.h" #include "buffermodel.h" #include "client.h" #include "clientaliasmanager.h" +#include "clientbufferviewconfig.h" +#include "clientbufferviewmanager.h" +#include "clientignorelistmanager.h" #include "clientsettings.h" #include "execwrapper.h" +#include "ignorelistmanager.h" #include "ircuser.h" +#include "messagemodel.h" #include "network.h" #include "types.h" -#include "bufferinfo.h" -#include "clientbufferviewconfig.h" -#include "clientbufferviewmanager.h" -#include "messagemodel.h" #include @@ -116,6 +118,29 @@ void ClientUserInputHandler::handleQuery(const BufferInfo &bufferInfo, const QSt } +void ClientUserInputHandler::handleIgnore(const BufferInfo &bufferInfo, const QString &text) +{ + if (text.isEmpty()) { + emit Client::instance()->showIgnoreList(""); + return; + } + // If rule contains no ! or @, we assume it is just a nickname, and turn it into an ignore rule for that nick + QString rule = (text.contains('!') || text.contains('@')) ? text : text + "!*@*"; + + Client::ignoreListManager()->requestAddIgnoreListItem( + IgnoreListManager::IgnoreType::SenderIgnore, + rule, + false, + // Use a dynamic ignore rule, for reversibility + IgnoreListManager::StrictnessType::SoftStrictness, + // Use current network as scope + IgnoreListManager::ScopeType::NetworkScope, + Client::network(bufferInfo.networkId())->networkName(), + true + ); +} + + void ClientUserInputHandler::switchBuffer(const NetworkId &networkId, const QString &bufferName) { BufferId newBufId = Client::networkModel()->bufferId(networkId, bufferName); diff --git a/src/client/clientuserinputhandler.h b/src/client/clientuserinputhandler.h index 5fbebd10..391a94a7 100644 --- a/src/client/clientuserinputhandler.h +++ b/src/client/clientuserinputhandler.h @@ -45,6 +45,7 @@ private slots: void handleExec(const BufferInfo &bufferInfo, const QString &execString); void handleJoin(const BufferInfo &bufferInfo, const QString &text); void handleQuery(const BufferInfo &bufferInfo, const QString &text); + void handleIgnore(const BufferInfo &bufferInfo, const QString &text); void defaultHandler(const QString &cmd, const BufferInfo &bufferInfo, const QString &text); private: diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index d3687c89..636f2136 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -204,6 +204,7 @@ void MainWin::init() SLOT(messagesInserted(const QModelIndex &, int, int))); connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId))); connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString))); + connect(Client::instance(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString))); connect(Client::coreConnection(), SIGNAL(startCoreSetup(QVariantList, QVariantList)), SLOT(showCoreConfigWizard(QVariantList, QVariantList))); connect(Client::coreConnection(), SIGNAL(connectionErrorPopup(QString)), SLOT(handleCoreConnectionError(QString)));