aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquickpathview.cpp5
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview4.qml20
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp22
3 files changed, 47 insertions, 0 deletions
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 00a5400eb2..825845eca9 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -1987,12 +1987,14 @@ void QQuickPathView::refill()
}
}
+ bool currentChanged = false;
if (!currentVisible) {
d->currentItemOffset = 1.0;
if (d->currentItem) {
d->updateItem(d->currentItem, 1.0);
} else if (!waiting && d->currentIndex >= 0 && d->currentIndex < d->modelCount) {
if ((d->currentItem = d->getItem(d->currentIndex, d->currentIndex))) {
+ currentChanged = true;
d->updateItem(d->currentItem, 1.0);
if (QQuickPathViewAttached *att = d->attached(d->currentItem))
att->setIsCurrentItem(true);
@@ -2000,6 +2002,7 @@ void QQuickPathView::refill()
}
} else if (!waiting && !d->currentItem) {
if ((d->currentItem = d->getItem(d->currentIndex, d->currentIndex))) {
+ currentChanged = true;
d->currentItem->setFocus(true);
if (QQuickPathViewAttached *att = d->attached(d->currentItem))
att->setIsCurrentItem(true);
@@ -2019,6 +2022,8 @@ void QQuickPathView::refill()
d->releaseItem(d->itemCache.takeLast());
d->inRefill = false;
+ if (currentChanged)
+ emit currentItemChanged();
}
void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
diff --git a/tests/auto/quick/qquickpathview/data/pathview4.qml b/tests/auto/quick/qquickpathview/data/pathview4.qml
new file mode 100644
index 0000000000..c42986d5a3
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/pathview4.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ property bool currentItemIsNull: view.currentItem === null
+
+ PathView {
+ id: view
+ objectName: "view"
+ model: testModel
+ delegate: Item {}
+
+ path: Path {
+ PathLine {
+ y: 0
+ x: 0
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index fd6dc4da60..0e9994899f 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -90,6 +90,7 @@ private slots:
void pathview2();
void pathview3();
void initialCurrentIndex();
+ void initialCurrentItem();
void insertModel_data();
void insertModel();
void removeModel_data();
@@ -237,6 +238,27 @@ void tst_QQuickPathView::items()
QCOMPARE(pathview->highlightItem()->position() + offset, start);
}
+void tst_QQuickPathView::initialCurrentItem()
+{
+ QScopedPointer<QQuickView> window(createView());
+
+ QaimModel model;
+ model.addItem("Jules", "12345");
+ model.addItem("Vicent", "2345");
+ model.addItem("Marvin", "54321");
+
+ QQmlContext *ctxt = window->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ window->setSource(testFileUrl("pathview4.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(window->rootObject(), "view");
+ QVERIFY(pathview != 0);
+ QVERIFY(pathview->currentIndex() != -1);
+ QVERIFY(!window->rootObject()->property("currentItemIsNull").toBool());
+}
+
void tst_QQuickPathView::pathview2()
{
QQmlEngine engine;