X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientuserinputhandler.cpp;h=7179515af02e3ed9e2a4510659877b0ccafc07ce;hp=97901cb080c0c4de5a27ee8fc7c9c12c13fdbb5c;hb=8582c2ad5708a1972c85bea1cf8d81ad3ece4814;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/client/clientuserinputhandler.cpp b/src/client/clientuserinputhandler.cpp index 97901cb0..7179515a 100644 --- a/src/client/clientuserinputhandler.cpp +++ b/src/client/clientuserinputhandler.cpp @@ -1,37 +1,39 @@ /*************************************************************************** -* Copyright (C) 2005-09 by the Quassel Project * -* devel@quassel-irc.org * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) version 3. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ + * Copyright (C) 2005-2018 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ #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 @@ -48,7 +50,7 @@ void ClientUserInputHandler::completionSuffixChanged(const QVariant &v) { QString suffix = v.toString(); QString letter = "A-Za-z"; - QString special = "\x5b-\x60\x7b-\x7d"; + QString special = "\x5b-\x60\x7b-\x7d"; // NOLINT(modernize-raw-string-literal) _nickRx = QRegExp(QString("^([%1%2][%1%2\\d-]*)%3").arg(letter, special, suffix).trimmed()); } @@ -62,7 +64,7 @@ void ClientUserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const if (!msg.startsWith('/')) { if (_nickRx.indexIn(msg) == 0) { const Network *net = Client::network(bufferInfo.networkId()); - IrcUser *user = net ? net->ircUser(_nickRx.cap(1)) : 0; + IrcUser *user = net ? net->ircUser(_nickRx.cap(1)) : nullptr; if (user) user->setLastSpokenTo(bufferInfo.bufferId(), QDateTime::currentDateTime().toUTC()); } @@ -87,7 +89,7 @@ void ClientUserInputHandler::defaultHandler(const QString &cmd, const BufferInfo void ClientUserInputHandler::handleExec(const BufferInfo &bufferInfo, const QString &execString) { - ExecWrapper *exec = new ExecWrapper(this); // gets suicidal when it's done + auto *exec = new ExecWrapper(this); // gets suicidal when it's done exec->start(bufferInfo, execString); } @@ -116,6 +118,35 @@ void ClientUserInputHandler::handleQuery(const BufferInfo &bufferInfo, const QSt } +void ClientUserInputHandler::handleIgnore(const BufferInfo &bufferInfo, const QString &text) +{ + if (text.isEmpty()) { + emit Client::instance()->displayIgnoreList(""); + 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::handleList(const BufferInfo &bufferInfo, const QString &text) +{ + // Pass along any potential search parameters, list channels immediately + Client::instance()->displayChannelList(bufferInfo.networkId(), text, true); +} + + void ClientUserInputHandler::switchBuffer(const NetworkId &networkId, const QString &bufferName) { BufferId newBufId = Client::networkModel()->bufferId(networkId, bufferName); @@ -129,7 +160,7 @@ void ClientUserInputHandler::switchBuffer(const NetworkId &networkId, const QStr QList bufferViewConfigList = clientBufferViewManager->clientBufferViewConfigs(); foreach(ClientBufferViewConfig *bufferViewConfig, bufferViewConfigList) { if (bufferViewConfig->temporarilyRemovedBuffers().contains(newBufId)) { - bufferViewConfig->addBuffer(newBufId, bufferViewConfig->bufferList().length()); + bufferViewConfig->requestAddBuffer(newBufId, bufferViewConfig->bufferList().length()); //if (bufferViewConfig->sortAlphabetically()) { // TODO we need to trigger a sort here, but can't reach the model required // to get a bufferviewfilter, as the bufferviewmanager only managers configs