diff options
author | Stephen Kelly <steveire@gmail.com> | 2009-12-18 13:17:44 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-18 13:37:05 (GMT) |
commit | 315c09c3873f7c5d8b785443372bf975bae47ee7 (patch) | |
tree | 77fcbe5a16ec41b87192c7f1beb601f5abd50d0c /tests | |
parent | 1aa7d5922930c4195bc8747a19524a7e5021c4e6 (diff) | |
download | Qt-315c09c3873f7c5d8b785443372bf975bae47ee7.zip Qt-315c09c3873f7c5d8b785443372bf975bae47ee7.tar.gz Qt-315c09c3873f7c5d8b785443372bf975bae47ee7.tar.bz2 |
Make sure mappings are created for columns when indexes newly become parents.
Also move the modeltest related tests to the modeltest subdirectory
Merge-request: 2262
Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/headers/tst_headers.cpp | 4 | ||||
-rw-r--r-- | tests/auto/modeltest/dynamictreemodel.cpp (renamed from tests/auto/qabstractitemmodel/dynamictreemodel.cpp) | 0 | ||||
-rw-r--r-- | tests/auto/modeltest/dynamictreemodel.h (renamed from tests/auto/qabstractitemmodel/dynamictreemodel.h) | 0 | ||||
-rw-r--r-- | tests/auto/modeltest/modeltest.cpp | 20 | ||||
-rw-r--r-- | tests/auto/modeltest/modeltest.pro | 4 | ||||
-rw-r--r-- | tests/auto/modeltest/tst_modeltest.cpp | 35 | ||||
-rw-r--r-- | tests/auto/qabstractitemmodel/qabstractitemmodel.pro | 7 |
7 files changed, 53 insertions, 17 deletions
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 36d25fe..329143d 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -217,8 +217,8 @@ void tst_Headers::licenseCheck() QCOMPARE(content.at(i++), QString("/****************************************************************************")); if (licenseType != "3RDPARTY") { QCOMPARE(content.at(i++), QString("**")); - if (sourceFile.endsWith("/tests/auto/qabstractitemmodel/dynamictreemodel.cpp") - || sourceFile.endsWith("/tests/auto/qabstractitemmodel/dynamictreemodel.h") + if (sourceFile.endsWith("/tests/auto/modeltest/dynamictreemodel.cpp") + || sourceFile.endsWith("/tests/auto/modeltest/dynamictreemodel.h") || sourceFile.endsWith("/src/network/kernel/qnetworkproxy_p.h")) { // These files are not copyrighted by Nokia. diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp b/tests/auto/modeltest/dynamictreemodel.cpp index 24d3ab3..24d3ab3 100644 --- a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp +++ b/tests/auto/modeltest/dynamictreemodel.cpp diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.h b/tests/auto/modeltest/dynamictreemodel.h index 3f0d90d..3f0d90d 100644 --- a/tests/auto/qabstractitemmodel/dynamictreemodel.h +++ b/tests/auto/modeltest/dynamictreemodel.h diff --git a/tests/auto/modeltest/modeltest.cpp b/tests/auto/modeltest/modeltest.cpp index 39d00f6..0ca9e14 100644 --- a/tests/auto/modeltest/modeltest.cpp +++ b/tests/auto/modeltest/modeltest.cpp @@ -475,8 +475,8 @@ void ModelTest::data() void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int end ) { // Q_UNUSED(end); - qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).toString() - << "current count of parent=" << model->rowCount ( parent ); // << "display of last=" << model->data( model->index(start-1, 0, parent) ); +// qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).toString() +// << "current count of parent=" << model->rowCount ( parent ); // << "display of last=" << model->data( model->index(start-1, 0, parent) ); // qDebug() << model->index(start-1, 0, parent) << model->data( model->index(start-1, 0, parent) ); Changing c; c.parent = parent; @@ -495,14 +495,14 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) { Changing c = insert.pop(); Q_ASSERT ( c.parent == parent ); - qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize - << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent ); - - for (int ii=start; ii <= end; ii++) - { - qDebug() << "itemWasInserted:" << ii << model->data ( model->index ( ii, 0, parent )); - } - qDebug(); +// qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize +// << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent ); + +// for (int ii=start; ii <= end; ii++) +// { +// qDebug() << "itemWasInserted:" << ii << model->data ( model->index ( ii, 0, parent )); +// } +// qDebug(); Q_ASSERT ( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) ); Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); diff --git a/tests/auto/modeltest/modeltest.pro b/tests/auto/modeltest/modeltest.pro index 6655d85..f157da0 100644 --- a/tests/auto/modeltest/modeltest.pro +++ b/tests/auto/modeltest/modeltest.pro @@ -1,6 +1,6 @@ load(qttest_p4) -SOURCES += tst_modeltest.cpp modeltest.cpp -HEADERS += modeltest.h +SOURCES += tst_modeltest.cpp modeltest.cpp dynamictreemodel.cpp +HEADERS += modeltest.h dynamictreemodel.h diff --git a/tests/auto/modeltest/tst_modeltest.cpp b/tests/auto/modeltest/tst_modeltest.cpp index a719168..78aa79f 100644 --- a/tests/auto/modeltest/tst_modeltest.cpp +++ b/tests/auto/modeltest/tst_modeltest.cpp @@ -44,6 +44,7 @@ #include <QtGui/QtGui> #include "modeltest.h" +#include "dynamictreemodel.h" class tst_ModelTest : public QObject @@ -64,6 +65,7 @@ private slots: void stringListModel(); void treeWidgetModel(); void standardItemModel(); + void testInsertThroughProxy(); }; @@ -143,7 +145,38 @@ void tst_ModelTest::standardItemModel() model.insertRows(0,5, model.index(1,1)); model.insertColumns(0,5, model.index(1,3)); - +} + +void tst_ModelTest::testInsertThroughProxy() +{ + DynamicTreeModel *model = new DynamicTreeModel(this); + + QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); + proxy->setSourceModel(model); + + new ModelTest(proxy, this); + + ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this); + insertCommand->setNumCols(4); + insertCommand->setStartRow(0); + insertCommand->setEndRow(9); + // Parent is QModelIndex() + insertCommand->doCommand(); + + insertCommand = new ModelInsertCommand(model, this); + insertCommand->setNumCols(4); + insertCommand->setAncestorRowNumbers(QList<int>() << 5); + insertCommand->setStartRow(0); + insertCommand->setEndRow(9); + insertCommand->doCommand(); + + ModelMoveCommand *moveCommand = new ModelMoveCommand(model, this); + moveCommand->setNumCols(4); + moveCommand->setStartRow(0); + moveCommand->setEndRow(0); + moveCommand->setDestRow(9); + moveCommand->setDestAncestors(QList<int>() << 5); + moveCommand->doCommand(); } QTEST_MAIN(tst_ModelTest) diff --git a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro index a31868b..52c4e96 100644 --- a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro +++ b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro @@ -1,6 +1,9 @@ load(qttest_p4) -SOURCES += tst_qabstractitemmodel.cpp dynamictreemodel.cpp -HEADERS += dynamictreemodel.h + +INCLUDEPATH += $$PWD/../modeltest + +SOURCES += tst_qabstractitemmodel.cpp ../modeltest/dynamictreemodel.cpp ../modeltest/modeltest.cpp +HEADERS += ../modeltest/dynamictreemodel.h ../modeltest/modeltest.h |