X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fabstractbuffercontainer.cpp;h=9861d14b35eb72515925fc2b7dd2f299d8e395c8;hp=f3ffbf8466da3237c0da95ac5f9ef8b104471494;hb=7de282e852c2b08c1cb166528a56eeef9d04e348;hpb=1736d7414b96efc1189e56f22bd0407989c3a7c9 diff --git a/src/uisupport/abstractbuffercontainer.cpp b/src/uisupport/abstractbuffercontainer.cpp index f3ffbf84..9861d14b 100644 --- a/src/uisupport/abstractbuffercontainer.cpp +++ b/src/uisupport/abstractbuffercontainer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -19,8 +19,8 @@ ***************************************************************************/ #include "abstractbuffercontainer.h" -#include "buffer.h" #include "client.h" +#include "clientbacklogmanager.h" #include "networkmodel.h" AbstractBufferContainer::AbstractBufferContainer(QWidget *parent) @@ -32,7 +32,6 @@ AbstractBufferContainer::AbstractBufferContainer(QWidget *parent) AbstractBufferContainer::~AbstractBufferContainer() { } - void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { Q_ASSERT(model()); if(!parent.isValid()) { @@ -60,7 +59,6 @@ void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex &parent, in } void AbstractBufferContainer::removeBuffer(BufferId bufferId) { - if(Client::buffer(bufferId)) Client::buffer(bufferId)->setVisible(false); if(!_chatViews.contains(bufferId)) return; @@ -74,61 +72,28 @@ void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const Q if(newBufferId != oldBufferId) { setCurrentBuffer(newBufferId); emit currentChanged(newBufferId); + emit currentChanged(current); } } void AbstractBufferContainer::setCurrentBuffer(BufferId bufferId) { - AbstractChatView *chatView = 0; - Buffer *prevBuffer = Client::buffer(currentBuffer()); - if(prevBuffer) prevBuffer->setVisible(false); + BufferId prevBufferId = currentBuffer(); + if(prevBufferId.isValid() && _chatViews.contains(prevBufferId)) { + Client::setBufferLastSeenMsg(prevBufferId, _chatViews[prevBufferId]->lastMsgId()); + } - Buffer *buf; - if(!bufferId.isValid() || !(buf = Client::buffer(bufferId))) { - if(bufferId.isValid()) - qWarning() << "AbstractBufferContainer::setBuffer(BufferId): Can't show unknown Buffer:" << bufferId; + if(!bufferId.isValid()) { _currentBuffer = 0; showChatView(0); return; } - if(_chatViews.contains(bufferId)) { - chatView = _chatViews[bufferId]; - } else { - chatView = createChatView(bufferId); - chatView->setContents(buf->contents()); - connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), this, SLOT(appendMsg(AbstractUiMsg *))); - connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), this, SLOT(prependMsg(AbstractUiMsg *))); - _chatViews[bufferId] = chatView; - } + + if(!_chatViews.contains(bufferId)) + _chatViews[bufferId] = createChatView(bufferId); + _currentBuffer = bufferId; showChatView(bufferId); - buf->setVisible(true); + Client::networkModel()->clearBufferActivity(bufferId); + Client::backlogManager()->checkForBacklog(bufferId); setFocus(); } - -void AbstractBufferContainer::appendMsg(AbstractUiMsg *msg) { - Buffer *buf = qobject_cast(sender()); - if(!buf) { - qWarning() << "AbstractBufferContainer::appendMsg(): Invalid slot caller!"; - return; - } - BufferId id = buf->bufferInfo().bufferId(); - if(!_chatViews.contains(id)) { - qWarning() << "AbstractBufferContainer::appendMsg(): Received message for unknown buffer!"; - return; - } - _chatViews[id]->appendMsg(msg); -} - -void AbstractBufferContainer::prependMsg(AbstractUiMsg *msg) { - Buffer *buf = qobject_cast(sender()); - if(!buf) { - qWarning() << "AbstractBufferContainer:prependMsg(): Invalid slot caller!"; - return; - } - BufferId id = buf->bufferInfo().bufferId(); - if(!_chatViews.contains(id)) { - qWarning() << "AbstractBufferContainer::prependMsg(): Received message for unknown buffer!"; - return; - } - _chatViews[id]->prependMsg(msg); -}