X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fbuffermodel.cpp;h=9c8df06f3286120336a339ae4f82deed74d8b10a;hb=e128a8ef50a0a3fce1d75d7d06121b2ea6c74d6a;hp=594dc83db7c8616bacb53c1f30f32de12c6d915d;hpb=533eaaeda64759c01daa624365b8fc63eeba5ccf;p=quassel.git diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index 594dc83d..9c8df06f 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -20,10 +20,10 @@ #include "buffermodel.h" -#include "networkmodel.h" -#include "mappedselectionmodel.h" -#include "buffer.h" +#include "client.h" #include "global.h" +#include "mappedselectionmodel.h" +#include "networkmodel.h" #include @@ -66,6 +66,26 @@ void BufferModel::setCurrentIndex(const QModelIndex &newCurrent) { _selectionModelSynchronizer.selectionModel()->select(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } +void BufferModel::switchToBuffer(const BufferId &bufferId) { + QModelIndex source_index = Client::networkModel()->bufferIndex(bufferId); + setCurrentIndex(mapFromSource(source_index)); +} + +void BufferModel::switchToBufferIndex(const QModelIndex &bufferIdx) { + // we accept indexes that directly belong to us or our parent - nothing else + if(bufferIdx.model() == this) { + setCurrentIndex(bufferIdx); + return; + } + + if(bufferIdx.model() == sourceModel()) { + setCurrentIndex(mapFromSource(bufferIdx)); + return; + } + + qWarning() << "BufferModel::switchToBufferIndex(const QModelIndex &):" << bufferIdx << "does not belong to BufferModel or NetworkModel"; +} + void BufferModel::debug_currentChanged(QModelIndex current, QModelIndex previous) { Q_UNUSED(previous); qDebug() << "Switched current Buffer: " << current << current.data().toString() << "Buffer:" << current.data(NetworkModel::BufferIdRole).value();