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 {
}
void BufferModel::setCurrentIndex(const QModelIndex &newCurrent) {
- _standardSelectionModel.setCurrentIndex(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
- _standardSelectionModel.select(newCurrent, QItemSelectionModel::ClearAndSelect);
+ _selectionModelSynchronizer.selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ _selectionModelSynchronizer.selectionModel()->select(newCurrent, QItemSelectionModel::Current);
+}
+
+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<BufferId>();
}