X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient%2Fbuffermodel.cpp;h=b67a447da2509ccbc3d44e7336a4011ef324d525;hb=6cd120c0b28d9cca7e2465fad731977d532ce74d;hp=52d6d54c5073b05f1d2fc196a3186c487f271622;hpb=1b2d3ea62867220d7bffc3b23dda1dc14d429007;p=quassel.git diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index 52d6d54c..b67a447d 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -27,14 +27,13 @@ BufferModel::BufferModel(NetworkModel *parent) : QSortFilterProxyModel(parent), - _selectionModelSynchronizer(this), - _standardSelectionModel(this) + _selectionModelSynchronizer(this) { setSourceModel(parent); - _selectionModelSynchronizer.addRegularSelectionModel(standardSelectionModel()); -} - -BufferModel::~BufferModel() { + if(QCoreApplication::instance()->arguments().contains("--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 +64,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(); }