aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2011-09-29 14:50:27 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-03 09:04:13 +0200
commitbd2eece4a68808c771d39cd53922ef538d0ba54d (patch)
tree50a819d9ae3fd662cb3799f19c79673fc9c40ad0 /src
parente59fbf997ece61b36180eb21f9c2cd6ea895b88f (diff)
currentIndex not updated correctly if list is initially empty
The currentIndex shouldn't be incremented when itemCount == 0 and also it should be default to 0 after the first item is added. Task-number: QTBUG-21643 Change-Id: Ia9418c0cd1cd659410123394c880dfe72557fa16 Reviewed-on: http://codereview.qt-project.org/5768 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/items/qsgitemview.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/declarative/items/qsgitemview.cpp b/src/declarative/items/qsgitemview.cpp
index 666b47198a..1791fb9dae 100644
--- a/src/declarative/items/qsgitemview.cpp
+++ b/src/declarative/items/qsgitemview.cpp
@@ -97,18 +97,21 @@ void QSGItemViewChangeSet::applyChanges(const QDeclarativeChangeSet &changeSet)
}
}
foreach (const QDeclarativeChangeSet::Insert &i, changeSet.inserts()) {
- itemCount += i.count;
if (moveId == -1) {
- if (newCurrentIndex >= i.index) {
+ if (itemCount && newCurrentIndex >= i.index) {
newCurrentIndex += i.count;
currentChanged = true;
} else if (newCurrentIndex < 0) {
newCurrentIndex = 0;
currentChanged = true;
+ } else if (newCurrentIndex == 0 && !itemCount) {
+ // this is the first item, set the initial current index
+ currentChanged = true;
}
} else if (moveId == i.moveId) {
newCurrentIndex = i.index + moveOffset;
}
+ itemCount += i.count;
}
}