OSDN Git Service

make sure that the itemview's count property is reliable
authorIvailo Monev <xakepa10@gmail.com>
Wed, 6 Jan 2016 18:24:56 +0000 (20:24 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Wed, 6 Jan 2016 18:24:56 +0000 (20:24 +0200)
upstream commits:
https://github.com/qtproject/qtquick1/commit/f09b12cea1143f1b2763064bb0d3e6592081de2b

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/declarative/graphicsitems/qdeclarativegridview.cpp
src/declarative/graphicsitems/qdeclarativelistview.cpp
src/declarative/graphicsitems/qdeclarativepathview.cpp
src/declarative/graphicsitems/qdeclarativerepeater.cpp

index d4a962f..1d7da7f 100644 (file)
@@ -2766,8 +2766,10 @@ void QDeclarativeGridView::trackedPositionChanged()
 void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
 {
     Q_D(QDeclarativeGridView);
-    if (!isComponentComplete())
+    if (!isComponentComplete()) {
+        emit countChanged();
         return;
+    }
 
     int index = d->visibleItems.count() ? d->mapFromModel(modelIndex) : 0;
     if (index < 0) {
@@ -2902,8 +2904,10 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
 void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
 {
     Q_D(QDeclarativeGridView);
-    if (!isComponentComplete())
+    if (!isComponentComplete()) {
+        emit countChanged();
         return;
+    }
 
     d->itemCount -= count;
     bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
index 5939365..d545e4e 100644 (file)
@@ -3210,8 +3210,10 @@ void QDeclarativeListView::trackedPositionChanged()
 void QDeclarativeListView::itemsInserted(int modelIndex, int count)
 {
     Q_D(QDeclarativeListView);
-    if (!isComponentComplete())
+    if (!isComponentComplete()) {
+        emit countChanged();
         return;
+    }
     d->updateUnrequestedIndexes();
     d->moveReason = QDeclarativeListViewPrivate::Other;
 
@@ -3363,8 +3365,10 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
 void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
 {
     Q_D(QDeclarativeListView);
-    if (!isComponentComplete())
+    if (!isComponentComplete()) {
+        emit countChanged();
         return;
+    }
     d->moveReason = QDeclarativeListViewPrivate::Other;
     d->updateUnrequestedIndexes();
     d->itemCount -= count;
index 6eb1256..ef34fb4 100644 (file)
@@ -1474,8 +1474,13 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count)
 {
     //XXX support animated insertion
     Q_D(QDeclarativePathView);
-    if (!d->isValid() || !isComponentComplete())
+    if (!d->isValid())
+        return;
+
+    if (!isComponentComplete()) {
+        emit countChanged();
         return;
+    }
 
     if (d->modelCount) {
         d->itemCache += d->items;
@@ -1504,9 +1509,14 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
 {
     //XXX support animated removal
     Q_D(QDeclarativePathView);
-    if (!d->model || !d->modelCount || !d->model->isValid() || !d->path || !isComponentComplete())
+    if (!d->model || !d->modelCount || !d->model->isValid() || !d->path)
         return;
 
+    if (!isComponentComplete()) {
+        emit countChanged();
+        return;
+    }
+
     // fix current
     bool currentChanged = false;
     if (d->currentIndex >= modelIndex + count) {
index 796a7b6..682c1fe 100644 (file)
@@ -379,8 +379,10 @@ void QDeclarativeRepeater::regenerate()
 void QDeclarativeRepeater::itemsInserted(int index, int count)
 {
     Q_D(QDeclarativeRepeater);
-    if (!isComponentComplete())
+    if (!isComponentComplete()) {
+        emit countChanged();
         return;
+    }
     for (int i = 0; i < count; ++i) {
         int modelIndex = index + i;
         QDeclarativeItem *item = d->model->item(modelIndex);
@@ -401,8 +403,13 @@ void QDeclarativeRepeater::itemsInserted(int index, int count)
 void QDeclarativeRepeater::itemsRemoved(int index, int count)
 {
     Q_D(QDeclarativeRepeater);
-    if (!isComponentComplete() || count <= 0)
+    if (count <= 0)
         return;
+
+    if (!isComponentComplete()) {
+        emit countChanged();
+        return;
+    }
     while (count--) {
         QDeclarativeItem *item = d->deletables.takeAt(index);
         emit itemRemoved(index, item);