diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-11-16 05:59:56 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-11-16 05:59:56 (GMT) |
commit | 6cf397f7ac35a058096528a7ad8bfaf623b30747 (patch) | |
tree | d9069d508c29600f7a61621c6f133268b8ad0ad3 /tests | |
parent | d02e604cc4d7999cc710b4572edb34236cc70800 (diff) | |
download | Qt-6cf397f7ac35a058096528a7ad8bfaf623b30747.zip Qt-6cf397f7ac35a058096528a7ad8bfaf623b30747.tar.gz Qt-6cf397f7ac35a058096528a7ad8bfaf623b30747.tar.bz2 |
VisualDataModel::count should be 0 until a valid delegate is set.
There are no visual items if there is no delegate.
Task-number: QTBUG-14781
Reviewed-by: Robert Griebl
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index 0aad099..29a065c 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -121,6 +121,7 @@ private slots: void objectListModel(); void singleRole(); void modelProperties(); + void noDelegate(); private: QDeclarativeEngine engine; @@ -472,6 +473,29 @@ void tst_qdeclarativevisualdatamodel::modelProperties() //### should also test QStringList and QVariantList } +void tst_qdeclarativevisualdatamodel::noDelegate() +{ + QDeclarativeView view; + + QStandardItemModel model; + initStandardTreeModel(&model); + + view.rootContext()->setContextProperty("myModel", &model); + + view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml")); + + QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject()); + QVERIFY(listview != 0); + + QDeclarativeVisualDataModel *vdm = listview->findChild<QDeclarativeVisualDataModel*>("visualModel"); + QVERIFY(vdm != 0); + QCOMPARE(vdm->count(), 3); + + vdm->setDelegate(0); + QCOMPARE(vdm->count(), 0); +} + + template<typename T> T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QString &objectName, int index) { |