+}
+*/
+
+void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
+{
+ Q_UNUSED(previous)
+
+ BufferId newBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
+ // To be able to reset the selected buffer, we don't check if buffer/index is valid here
+ if (currentBuffer() != newBufferId) {
+ setCurrentBuffer(newBufferId);
+ emit currentChanged(newBufferId);
+ emit currentChanged(current);
+ }
+}
+
+
+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;
+ }