X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fabstractbuffercontainer.cpp;h=8b89e8c4ea8c2c058222f473693037d2b67d4126;hp=14440271fe06a5dc0b04ebff7259d6dd6a3b4336;hb=ed2415135359b4f8a3f75f2634e028500c08c1fe;hpb=1ef542382777aa0af9f9d1d6835bf6b1af880089 diff --git a/src/uisupport/abstractbuffercontainer.cpp b/src/uisupport/abstractbuffercontainer.cpp index 14440271..8b89e8c4 100644 --- a/src/uisupport/abstractbuffercontainer.cpp +++ b/src/uisupport/abstractbuffercontainer.cpp @@ -19,20 +19,18 @@ ***************************************************************************/ #include "abstractbuffercontainer.h" -#include "buffer.h" #include "client.h" #include "networkmodel.h" -AbstractBufferContainer::AbstractBufferContainer(QWidget *parent) : AbstractItemView(parent), _currentBuffer(0) +AbstractBufferContainer::AbstractBufferContainer(QWidget *parent) + : AbstractItemView(parent), + _currentBuffer(0) { - } AbstractBufferContainer::~AbstractBufferContainer() { - } - void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { Q_ASSERT(model()); if(!parent.isValid()) { @@ -60,7 +58,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; @@ -78,58 +75,23 @@ void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const Q } void AbstractBufferContainer::setCurrentBuffer(BufferId bufferId) { + BufferId prevBufferId = currentBuffer(); + if(prevBufferId.isValid() && _chatViews.contains(prevBufferId)) { + Client::setBufferLastSeenMsg(prevBufferId, _chatViews[prevBufferId]->lastMsgId()); + } + if(!bufferId.isValid()) { + _currentBuffer = 0; showChatView(0); return; } - AbstractChatView *chatView = 0; - Buffer *buf = Client::buffer(bufferId); - if(!buf) { - qWarning() << "AbstractBufferContainer::setBuffer(BufferId): Can't show unknown Buffer:" << bufferId; - return; - } - Buffer *prevBuffer = Client::buffer(currentBuffer()); - if(prevBuffer) prevBuffer->setVisible(false); - 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()->setBufferActivity(bufferId, BufferInfo::NoActivity); + // Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId()); 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); -}