X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient%2Fclient.cpp;h=8b954d395b8b074890408b707af19f9cbfdbb65c;hb=6869909402a4dc807ee5261cc2a0999ac33053ee;hp=a04361cc4a8535bc3ea3c497da5c5ff2a9dce04d;hpb=e7e564dcf469faa4c47383368a58cedbe3a204e6;p=quassel.git diff --git a/src/client/client.cpp b/src/client/client.cpp index a04361cc..8b954d39 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -20,8 +20,8 @@ #include "client.h" #include "clientproxy.h" -#include "mainwin.h" #include "buffer.h" +#include "buffertreemodel.h" #include "util.h" Client * Client::instanceptr = 0; @@ -38,7 +38,6 @@ QList Client::coreBuffers; Client *Client::instance() { if(instanceptr) return instanceptr; instanceptr = new Client(); - instanceptr->init(); return instanceptr; } @@ -50,8 +49,7 @@ void Client::destroy() { Client::Client() { clientProxy = ClientProxy::instance(); - //mainWin = new MainWin(); - _bufferModel = new BufferTreeModel(0); // FIXME + _bufferModel = new BufferTreeModel(this); connect(this, SIGNAL(bufferSelected(Buffer *)), _bufferModel, SLOT(selectBuffer(Buffer *))); connect(this, SIGNAL(bufferUpdated(Buffer *)), _bufferModel, SLOT(bufferUpdated(Buffer *))); @@ -62,6 +60,11 @@ Client::Client() { else clientMode = RemoteCore; } +void Client::init(AbstractUi *ui) { + instance()->mainUi = ui; + instance()->init(); +} + void Client::init() { blockSize = 0; @@ -77,7 +80,7 @@ void Client::init() { connect(clientProxy, SIGNAL(csServerState(QString, QVariant)), this, SLOT(recvNetworkState(QString, QVariant))); connect(clientProxy, SIGNAL(csServerConnected(QString)), this, SLOT(networkConnected(QString))); connect(clientProxy, SIGNAL(csServerDisconnected(QString)), this, SLOT(networkDisconnected(QString))); - connect(clientProxy, SIGNAL(csDisplayMsg(Message)), this, SLOT(recvMessage(Message))); + connect(clientProxy, SIGNAL(csDisplayMsg(Message)), this, SLOT(recvMessage(const Message &))); connect(clientProxy, SIGNAL(csDisplayStatusMsg(QString, QString)), this, SLOT(recvStatusMsg(QString, QString))); connect(clientProxy, SIGNAL(csTopicSet(QString, QString, QString)), this, SLOT(setTopic(QString, QString, QString))); connect(clientProxy, SIGNAL(csNickAdded(QString, QString, VarMap)), this, SLOT(addNick(QString, QString, VarMap))); @@ -85,7 +88,7 @@ void Client::init() { connect(clientProxy, SIGNAL(csNickRenamed(QString, QString, QString)), this, SLOT(renameNick(QString, QString, QString))); connect(clientProxy, SIGNAL(csNickUpdated(QString, QString, VarMap)), this, SLOT(updateNick(QString, QString, VarMap))); connect(clientProxy, SIGNAL(csOwnNickSet(QString, QString)), this, SLOT(setOwnNick(QString, QString))); - connect(clientProxy, SIGNAL(csBacklogData(BufferId, QList, bool)), this, SLOT(recvBacklogData(BufferId, QList, bool))); + connect(clientProxy, SIGNAL(csBacklogData(BufferId, const QList &, bool)), this, SLOT(recvBacklogData(BufferId, QList, bool))); connect(clientProxy, SIGNAL(csUpdateBufferId(BufferId)), this, SLOT(updateBufferId(BufferId))); connect(this, SIGNAL(sendInput(BufferId, QString)), clientProxy, SLOT(gsUserInput(BufferId, QString))); connect(this, SIGNAL(requestBacklog(BufferId, QVariant, QVariant)), clientProxy, SLOT(gsRequestBacklog(BufferId, QVariant, QVariant))); @@ -103,15 +106,11 @@ void Client::init() { buffer(id); // create all buffers, so we see them in the network views emit requestBacklog(id, -1, -1); // TODO: use custom settings for backlog request } - - mainWin = new MainWin(); - mainWin->init(); - } Client::~Client() { - delete mainWin; - delete _bufferModel; + //delete mainUi; + //delete _bufferModel; foreach(Buffer *buf, buffers.values()) delete buf; ClientProxy::destroy(); @@ -174,8 +173,6 @@ void Client::serverHasData() { } } -/*******************************************************************************************************************/ - void Client::networkConnected(QString net) { connected[net] = true; BufferId id = statusBufferId(net); @@ -244,7 +241,7 @@ void Client::recvNetworkState(QString net, QVariant state) { } } -void Client::recvMessage(Message msg) { +void Client::recvMessage(const Message &msg) { Buffer *b = buffer(msg.buffer); Buffer::ActivityLevel level = Buffer::OtherActivity; @@ -256,31 +253,36 @@ void Client::recvMessage(Message msg) { } emit bufferActivity(level, b); - //b->displayMsg(msg); - b->appendChatLine(new ChatLine(msg)); + b->appendMsg(msg); } -void Client::recvStatusMsg(QString net, QString msg) { +void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) { //recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg))); } -void Client::recvBacklogData(BufferId id, QList msgs, bool done) { +void Client::recvBacklogData(BufferId id, const QList &msgs, bool /*done*/) { + Buffer *b = buffer(id); foreach(QVariant v, msgs) { - layoutQueue.append(v.value()); + Message msg = v.value(); + b->prependMsg(msg); + if(!layoutQueue.contains(b)) layoutQueue.append(b); } - if(!layoutTimer->isActive()) layoutTimer->start(); + if(layoutQueue.count() && !layoutTimer->isActive()) layoutTimer->start(); } - void Client::layoutMsg() { if(layoutQueue.count()) { - ChatLine *line = new ChatLine(layoutQueue.takeFirst()); - buffer(line->bufferId())->prependChatLine(line); + Buffer *b = layoutQueue.takeFirst(); // TODO make this the current buffer + if(b->layoutMsg()) layoutQueue.append(b); // Buffer has more messages in its queue --> Round Robin } if(!layoutQueue.count()) layoutTimer->stop(); } +AbstractUiMsg *Client::layoutMsg(const Message &msg) { + return instance()->mainUi->layoutMsg(msg); +} + void Client::userInput(BufferId id, QString msg) { emit sendInput(id, msg); }