summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-01-06 05:48:52 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-01-06 05:55:00 (GMT)
commit1ba3e41f09ea719249286fede5d3fe96621ccb61 (patch)
treefca572fbeea4ad92aa1d0fdd7172098a9bcca873
parent1d7b672fd46abab51a0124ad19aad18e5d14f1a8 (diff)
downloadQt-1ba3e41f09ea719249286fede5d3fe96621ccb61.zip
Qt-1ba3e41f09ea719249286fede5d3fe96621ccb61.tar.gz
Qt-1ba3e41f09ea719249286fede5d3fe96621ccb61.tar.bz2
PathView: update modelCount before attempting to regenerate delegates.
If the model is a VisualDataModel, the count will initally be zero and modelCount is not updated due to itemsInserted() before the component is completed. Task-number: QTBUG-16357 Reviewed-by: Bea Lam
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/vdm.qml28
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp14
3 files changed, 45 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index e3987d0..74d3418 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -1318,8 +1318,10 @@ void QDeclarativePathView::componentComplete()
// It is possible that a refill has already happended to to Path
// bindings being handled in the componentComplete(). If so
// don't do it again.
- if (d->items.count() == 0)
+ if (d->items.count() == 0 && d->model) {
+ d->modelCount = d->model->count();
d->regenerate();
+ }
d->updateHighlight();
}
diff --git a/tests/auto/declarative/qdeclarativepathview/data/vdm.qml b/tests/auto/declarative/qdeclarativepathview/data/vdm.qml
new file mode 100644
index 0000000..012db3f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/vdm.qml
@@ -0,0 +1,28 @@
+import QtQuick 1.0
+
+PathView {
+ id: pathView
+ width: 240; height: 320
+
+ pathItemCount: 4
+ preferredHighlightBegin : 0.5
+ preferredHighlightEnd : 0.5
+
+ path: Path {
+ startX: 120; startY: 20;
+ PathLine { x: 120; y: 300 }
+ }
+
+ ListModel {
+ id: mo
+ ListElement { value: "one" }
+ ListElement { value: "two" }
+ ListElement { value: "three" }
+ }
+
+ model: VisualDataModel {
+ delegate: Text { text: model.value }
+ model : mo
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 9193707..90b1056 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -87,6 +87,7 @@ private slots:
void emptyModel();
void closed();
void pathUpdate();
+ void visualDataModel();
private:
QDeclarativeView *createView();
@@ -839,6 +840,19 @@ void tst_QDeclarativePathView::pathUpdate()
delete canvas;
}
+void tst_QDeclarativePathView::visualDataModel()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/vdm.qml"));
+
+ QDeclarativePathView *obj = qobject_cast<QDeclarativePathView*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->count(), 3);
+
+ delete obj;
+}
+
QDeclarativeView *tst_QDeclarativePathView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);