-void AbstractBufferContainer::prependMsg(AbstractUiMsg *msg) {
- Buffer *buf = qobject_cast<Buffer *>(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);
+
+void AbstractBufferContainer::setCurrentBuffer(BufferId bufferId)
+{
+ BufferId prevBufferId = currentBuffer();
+ if (prevBufferId.isValid() && _chatViews.contains(prevBufferId)) {
+ MsgId msgId = _chatViews.value(prevBufferId)->lastMsgId();
+ Client::setBufferLastSeenMsg(prevBufferId, msgId);
+ }
+
+ if (!bufferId.isValid()) {
+ _currentBuffer = 0;
+ showChatView(0);
+ return;
+ }
+
+ if (!_chatViews.contains(bufferId))
+ _chatViews[bufferId] = createChatView(bufferId);
+
+ _currentBuffer = bufferId;
+ showChatView(bufferId);
+ Client::networkModel()->clearBufferActivity(bufferId);
+ Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
+ Client::backlogManager()->checkForBacklog(bufferId);
+ setFocus();