/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel IRC Team *
+ * Copyright (C) 2005-2010 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "abstractbuffercontainer.h"
#include "client.h"
+#include "clientbacklogmanager.h"
#include "networkmodel.h"
AbstractBufferContainer::AbstractBufferContainer(QWidget *parent)
_chatViews.take(bufferId);
}
+void AbstractBufferContainer::rowsInserted(const QModelIndex &parent, int start, int end) {
+ Q_UNUSED(end)
+
+ if(currentBuffer().isValid())
+ return;
+
+ // we want to make sure the very first valid buffer is selected
+ QModelIndex index = model()->index(start, 0, parent);
+ if(index.isValid()) {
+ BufferId id = index.data(NetworkModel::BufferIdRole).value<BufferId>();
+ if(id.isValid())
+ setCurrentBuffer(id);
+ }
+}
+
void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) {
+ Q_UNUSED(previous)
+
BufferId newBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
- BufferId oldBufferId = previous.data(NetworkModel::BufferIdRole).value<BufferId>();
- if(newBufferId != oldBufferId) {
+ if(newBufferId.isValid() && currentBuffer() != newBufferId) {
setCurrentBuffer(newBufferId);
emit currentChanged(newBufferId);
+ emit currentChanged(current);
}
}
void AbstractBufferContainer::setCurrentBuffer(BufferId bufferId) {
BufferId prevBufferId = currentBuffer();
if(prevBufferId.isValid() && _chatViews.contains(prevBufferId)) {
- Client::setBufferLastSeenMsg(prevBufferId, _chatViews[prevBufferId]->lastMsgId());
+ MsgId msgId = _chatViews.value(prevBufferId)->lastMsgId();
+ Client::setBufferLastSeenMsg(prevBufferId, msgId);
+ if(autoSetMarkerLine())
+ Client::setBufferMarkerLine(prevBufferId, msgId);
}
if(!bufferId.isValid()) {
_currentBuffer = bufferId;
showChatView(bufferId);
- Client::networkModel()->setBufferActivity(bufferId, BufferInfo::NoActivity);
- // Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
+ Client::networkModel()->clearBufferActivity(bufferId);
+ Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
+ Client::backlogManager()->checkForBacklog(bufferId);
setFocus();
}