Use the base implementation of QAbstractItemModel::sibling in QSIM.

QStandardItemModel doesn't really benefit from a reimplementation of
sibling, and the current implementation is buggy.

Task-number: 29540
Change-Id: Icf8dca29b6e1394a378db5bf6abd884f2d7fd9b9
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
bb10
Stephen Kelly 2013-02-21 00:01:30 +01:00 committed by The Qt Project
parent 97e755945c
commit f136701bc5
3 changed files with 4 additions and 1 deletions

View File

@ -2714,7 +2714,7 @@ bool QStandardItemModel::hasChildren(const QModelIndex &parent) const
*/
QModelIndex QStandardItemModel::sibling(int row, int column, const QModelIndex &idx) const
{
return createIndex(row, column, idx.internalPointer());
return QAbstractItemModel::sibling(row, column, idx);
}
/*!

View File

@ -332,6 +332,7 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
// Qt 6: Remove
QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;

View File

@ -718,6 +718,8 @@ void tst_QStandardItemModel::checkChildren()
QVERIFY(!model.hasChildren());
QCOMPARE(model.rowCount(), 0);
QCOMPARE(model.columnCount(), 1);
QVERIFY(!model.index(0,0).sibling(100,100).isValid());
}
void tst_QStandardItemModel::data()