Make this API virtual to make selection proxying possible.

Change-Id: Ie93c8b38c59d347026a68eae03687d9017b3d048
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Stephen Kelly 2011-11-10 13:24:33 +01:00 committed by Qt by Nokia
parent af914694d8
commit 0b293e4afc
2 changed files with 10 additions and 1 deletions

View File

@ -195,7 +195,7 @@ public:
const QAbstractItemModel *model() const;
public Q_SLOTS:
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
virtual void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command);
virtual void clear();

View File

@ -2675,6 +2675,12 @@ public:
using QItemSelectionModel::select;
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
{
QItemSelectionModel::setCurrentIndex(index, command);
m_target->setCurrentIndex(index, command);
}
private:
QItemSelectionModel *m_target;
@ -2708,6 +2714,9 @@ void tst_QItemSelectionModel::testChainedSelectionClear()
QVERIFY(selectedIndexes.size() == 0);
}
duplicate.setCurrentIndex(model.index(0, 0), QItemSelectionModel::NoUpdate);
QVERIFY(selectionModel.currentIndex() == duplicate.currentIndex());
}
QTEST_MAIN(tst_QItemSelectionModel)