X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fbuffermodel.cpp;h=a03ae5bd4b69b0fc16d23ced779ea75bc5323630;hb=257ca0d5f944a8f63d002e1dcaaa3902258d85e0;hp=52d6d54c5073b05f1d2fc196a3186c487f271622;hpb=1b2d3ea62867220d7bffc3b23dda1dc14d429007;p=quassel.git diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index 52d6d54c..a03ae5bd 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -23,18 +23,19 @@ #include "networkmodel.h" #include "mappedselectionmodel.h" #include "buffer.h" +#include "global.h" + #include BufferModel::BufferModel(NetworkModel *parent) : QSortFilterProxyModel(parent), - _selectionModelSynchronizer(this), - _standardSelectionModel(this) + _selectionModelSynchronizer(this) { setSourceModel(parent); - _selectionModelSynchronizer.addRegularSelectionModel(standardSelectionModel()); -} - -BufferModel::~BufferModel() { + if(Global::parser.isSet("debugbufferswitches")) { + connect(_selectionModelSynchronizer.selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), + this, SLOT(debug_currentChanged(const QModelIndex &, const QModelIndex &))); + } } bool BufferModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) const { @@ -65,6 +66,11 @@ QModelIndex BufferModel::currentIndex() { } void BufferModel::setCurrentIndex(const QModelIndex &newCurrent) { - _standardSelectionModel.setCurrentIndex(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - _standardSelectionModel.select(newCurrent, QItemSelectionModel::ClearAndSelect); + _selectionModelSynchronizer.selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::Current); + _selectionModelSynchronizer.selectionModel()->select(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); +} + +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(); }