diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-09-02 10:29:24 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-09-05 17:42:35 +0000 |
commit | 425cfb35b680501c8c1e34c04c70be497d55f4cb (patch) | |
tree | 690bd852295b401f8b3f0b06429c16c45fc89148 | |
parent | 3ae1022f42982348c341c2f296e7e7d6d3667fe0 (diff) |
SwipeView: emit currentItemChanged().
Change-Id: Iacbc9cc7f89aeacbf1ce918eb28a1a5c7db7040d
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/extras/qquickswipeview.cpp | 1 | ||||
-rw-r--r-- | tests/auto/extras/data/tst_swipeview.qml | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/extras/qquickswipeview.cpp b/src/extras/qquickswipeview.cpp index ae23843c..c359a983 100644 --- a/src/extras/qquickswipeview.cpp +++ b/src/extras/qquickswipeview.cpp @@ -156,6 +156,7 @@ void QQuickSwipeView::setCurrentIndex(int index) if (d->currentIndex != index) { d->currentIndex = index; emit currentIndexChanged(); + emit currentItemChanged(); } } diff --git a/tests/auto/extras/data/tst_swipeview.qml b/tests/auto/extras/data/tst_swipeview.qml index dbd1c10b..f2694bcf 100644 --- a/tests/auto/extras/data/tst_swipeview.qml +++ b/tests/auto/extras/data/tst_swipeview.qml @@ -60,9 +60,21 @@ TestCase { Text { } } + SignalSpy { + id: currentItemChangedSpy + signalName: "currentItemChanged" + } + + function cleanup() { + currentItemChangedSpy.clear() + currentItemChangedSpy.target = null + } + function test_current() { var control = swipeView.createObject(testCase) + currentItemChangedSpy.target = control + compare(control.count, 0) compare(control.currentIndex, -1) compare(control.currentItem, null) @@ -71,24 +83,29 @@ TestCase { compare(control.count, 1) compare(control.currentIndex, 0) compare(control.currentItem.text, "0") + compare(currentItemChangedSpy.count, 1); control.addItem(page.createObject(control, {text: "1"})) compare(control.count, 2) compare(control.currentIndex, 0) compare(control.currentItem.text, "0") + compare(currentItemChangedSpy.count, 1); control.addItem(page.createObject(control, {text: "2"})) compare(control.count, 3) compare(control.currentIndex, 0) compare(control.currentItem.text, "0") + compare(currentItemChangedSpy.count, 1); control.currentIndex = 1 compare(control.currentIndex, 1) compare(control.currentItem.text, "1") + compare(currentItemChangedSpy.count, 2); control.currentIndex = 2 compare(control.currentIndex, 2) compare(control.currentItem.text, "2") + compare(currentItemChangedSpy.count, 3); control.destroy() } @@ -129,20 +146,26 @@ TestCase { control.currentIndexChanged.connect(verifyCurrentIndexCountDiff) control.countChanged.connect(verifyCurrentIndexCountDiff) + currentItemChangedSpy.target = control; + compare(control.count, 0) compare(control.currentIndex, -1) + compare(control.currentItem, null) control.addItem(page.createObject(control, {text: "1"})) compare(control.count, 1) compare(control.currentIndex, 0) + compare(currentItemChangedSpy.count, 1) compare(control.currentItem.text, "1") control.addItem(page.createObject(control, {text: "2"})) compare(control.count, 2) compare(control.currentIndex, 0) + compare(currentItemChangedSpy.count, 1) compare(control.currentItem.text, "1") compare(control.itemAt(0).text, "1") compare(control.itemAt(1).text, "2") control.currentIndex = 1 + compare(currentItemChangedSpy.count, 2) control.insertItem(1, page.createObject(control, {text: "3"})) compare(control.count, 3) @@ -195,15 +218,19 @@ TestCase { compare(control.itemAt(0).text, "1") compare(control.itemAt(1).text, "2") + currentItemChangedSpy.clear() + control.removeItem(1) compare(control.count, 1) compare(control.currentIndex, 0) + compare(currentItemChangedSpy.count, 1) compare(control.currentItem.text, "1") compare(control.itemAt(0).text, "1") control.removeItem(0) compare(control.count, 0) compare(control.currentIndex, -1) + compare(currentItemChangedSpy.count, 2) control.destroy() } |