From b619ad78665f63b798389d0f7a33a22da7d93718 Mon Sep 17 00:00:00 2001 From: Sebastian Goth Date: Sun, 31 Jan 2010 01:26:18 +0100 Subject: [PATCH] Use join-and-switch with /join and /query --- src/client/buffermodel.cpp | 4 ++++ src/client/buffermodel.h | 1 + src/client/clientuserinputhandler.cpp | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index f24d03f0..57441a91 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -142,3 +142,7 @@ void BufferModel::newBuffer(BufferId bufferId) { switchToBuffer(bufferId); } } + +void BufferModel::switchToBufferAfterCreation(NetworkId network, const QString &name) { + _bufferToSwitchTo = qMakePair(network, name); +} diff --git a/src/client/buffermodel.h b/src/client/buffermodel.h index dbc614de..d1390c9b 100644 --- a/src/client/buffermodel.h +++ b/src/client/buffermodel.h @@ -57,6 +57,7 @@ public slots: void switchToOrStartQuery(NetworkId network, const QString &nick) { switchToOrJoinBuffer(network, nick, true); } + void switchToBufferAfterCreation(NetworkId network, const QString &name); private slots: void debug_currentChanged(QModelIndex current, QModelIndex previous); diff --git a/src/client/clientuserinputhandler.cpp b/src/client/clientuserinputhandler.cpp index 610a7021..3ecf3c42 100644 --- a/src/client/clientuserinputhandler.cpp +++ b/src/client/clientuserinputhandler.cpp @@ -20,6 +20,7 @@ #include +#include "buffermodel.h" #include "client.h" #include "clientaliasmanager.h" #include "clientuserinputhandler.h" @@ -59,10 +60,21 @@ void ClientUserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const for(int i = 0; i < clist.count(); i++) { QString cmd = clist.at(i).second.section(' ', 0, 0).remove(0, 1).toUpper(); + QString args = clist.at(i).second.section(' ', 1); if(cmd == "EXEC") - handleExec(clist.at(i).first, clist.at(i).second.section(' ', 1)); - else + handleExec(clist.at(i).first, args); + else { + if(cmd == "JOIN" || cmd == "QUERY") { + BufferId newBufId = Client::networkModel()->bufferId(bufferInfo.networkId(), args.section(' ', 0, 0)); + if(!newBufId.isValid()) { + Client::bufferModel()->switchToBufferAfterCreation(bufferInfo.networkId(), args.section(' ', 0, 0)); + } + else { + Client::bufferModel()->switchToBuffer(newBufId); + } + } emit sendInput(clist.at(i).first, clist.at(i).second); + } } } -- 2.20.1