From 9dfba89c28bbff3316cb7aed6c07f90c0f2d5a22 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Sep 2012 18:16:08 +0200 Subject: Add implementations of QAIM::sibling in public APIs. Change-Id: I2248641f2ed8735c28bd9572470520995a4a5b62 Reviewed-by: Marc Mutz Reviewed-by: Stephen Kelly --- tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp | 11 +++++++++++ tests/auto/other/modeltest/modeltest.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 72a5c4a57b..633812f935 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -392,6 +392,8 @@ void checkChildren(QAbstractItemModel *currentModel, const QModelIndex &parent, int rows = currentModel->rowCount(parent); int columns = currentModel->columnCount(parent); + const QModelIndex topLeftChild = currentModel->index( 0, 0, parent ); + QCOMPARE(rows > 0, (currentModel->hasChildren(parent))); // Some reasuring testing against rows(),columns(), and hasChildren() @@ -423,6 +425,15 @@ void checkChildren(QAbstractItemModel *currentModel, const QModelIndex &parent, QModelIndex b = currentModel->index(r, c, parent); QVERIFY(a == b); + { + const QModelIndex sibling = currentModel->sibling( r, c, topLeftChild ); + QVERIFY( index == sibling ); + } + { + const QModelIndex sibling = topLeftChild.sibling( r, c ); + QVERIFY( index == sibling ); + } + // Some basic checking on the index that is returned QVERIFY(index.model() == currentModel); QCOMPARE(index.row(), r); diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp index f8338dc6fa..17f164b638 100644 --- a/tests/auto/other/modeltest/modeltest.cpp +++ b/tests/auto/other/modeltest/modeltest.cpp @@ -339,6 +339,8 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows // << "columns:" << columns << "parent column:" << parent.column(); + const QModelIndex topLeftChild = model->index( 0, 0, parent ); + QVERIFY( !model->hasIndex ( rows + 1, 0, parent ) ); for ( int r = 0; r < rows; ++r ) { if ( model->canFetchMore ( parent ) ) { @@ -362,6 +364,15 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) QModelIndex b = model->index ( r, c, parent ); QVERIFY( a == b ); + { + const QModelIndex sibling = model->sibling( r, c, topLeftChild ); + QVERIFY( index == sibling ); + } + { + const QModelIndex sibling = topLeftChild.sibling( r, c ); + QVERIFY( index == sibling ); + } + // Some basic checking on the index that is returned QVERIFY( index.model() == model ); QCOMPARE( index.row(), r ); -- cgit v1.2.3