Use join-and-switch with /join and /query
authorSebastian Goth <seezer@roath.org>
Sun, 31 Jan 2010 00:26:18 +0000 (01:26 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 31 Jan 2010 19:26:05 +0000 (20:26 +0100)
src/client/buffermodel.cpp
src/client/buffermodel.h
src/client/clientuserinputhandler.cpp

index f24d03f..57441a9 100644 (file)
@@ -142,3 +142,7 @@ void BufferModel::newBuffer(BufferId bufferId) {
     switchToBuffer(bufferId);
   }
 }
     switchToBuffer(bufferId);
   }
 }
+
+void BufferModel::switchToBufferAfterCreation(NetworkId network, const QString &name) {
+  _bufferToSwitchTo = qMakePair(network, name);
+}
index dbc614d..d1390c9 100644 (file)
@@ -57,6 +57,7 @@ public slots:
   void switchToOrStartQuery(NetworkId network, const QString &nick) {
     switchToOrJoinBuffer(network, nick, true);
   }
   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);
 
 private slots:
   void debug_currentChanged(QModelIndex current, QModelIndex previous);
index 610a702..3ecf3c4 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <QDateTime>
 
 
 #include <QDateTime>
 
+#include "buffermodel.h"
 #include "client.h"
 #include "clientaliasmanager.h"
 #include "clientuserinputhandler.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();
 
   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")
     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);
       emit sendInput(clist.at(i).first, clist.at(i).second);
+    }
   }
 }
 
   }
 }