summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-11-16 05:59:56 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-11-16 05:59:56 (GMT)
commit6cf397f7ac35a058096528a7ad8bfaf623b30747 (patch)
treed9069d508c29600f7a61621c6f133268b8ad0ad3 /tests
parentd02e604cc4d7999cc710b4572edb34236cc70800 (diff)
downloadQt-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.cpp24
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)
{