summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-04-13 06:34:06 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-04-14 01:06:05 (GMT)
commit52187b084491641ef80536c743c2261af8bfe11c (patch)
treede416ae39ce46f468651c8ce159677e624ddda92 /src
parentc7833b8f5ecc7a47e35bdf9fbb528e1869979ef5 (diff)
downloadQt-52187b084491641ef80536c743c2261af8bfe11c.zip
Qt-52187b084491641ef80536c743c2261af8bfe11c.tar.gz
Qt-52187b084491641ef80536c743c2261af8bfe11c.tar.bz2
Moving contentY by large values in List/GridView is slow
We needed to create/destroy every delegate between the current position and the new position. Now we estimate element at the new position and just create the elements from that item. Change-Id: I9da1354cbadb4e44fafc1a0bee619d058d1e06a2 Task-number: QTBUG-14974 Reviewed-by: Bea Lam
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp20
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp22
2 files changed, 42 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 3ec29c1..21bfc59 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -584,6 +584,26 @@ void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer)
--i;
modelIndex = visibleItems.at(i)->index + 1;
}
+
+ if (visibleItems.count() && (fillFrom > rowPos + rowSize()*2
+ || fillTo < rowPosAt(visibleIndex) - rowSize())) {
+ // We've jumped more than a page. Estimate which items are now
+ // visible and fill from there.
+ int count = (fillFrom - (rowPos + rowSize())) / (rowSize()) * columns;
+ for (int i = 0; i < visibleItems.count(); ++i)
+ releaseItem(visibleItems.at(i));
+ visibleItems.clear();
+ modelIndex += count;
+ if (modelIndex >= model->count())
+ modelIndex = model->count() - 1;
+ else if (modelIndex < 0)
+ modelIndex = 0;
+ modelIndex = modelIndex / columns * columns;
+ visibleIndex = modelIndex;
+ colPos = colPosAt(visibleIndex);
+ rowPos = rowPosAt(visibleIndex);
+ }
+
int colNum = colPos / colSize();
FxGridItem *item = 0;
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index cb751f6..7c01293 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -744,6 +744,28 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
if (visibleItems.at(i)->index != -1)
modelIndex = visibleItems.at(i)->index + 1;
}
+
+ if (visibleItems.count() && (fillFrom > itemEnd+averageSize+spacing
+ || fillTo < visiblePos - averageSize - spacing)) {
+ // We've jumped more than a page. Estimate which items are now
+ // visible and fill from there.
+ int count = (fillFrom - itemEnd) / (averageSize + spacing);
+ for (int i = 0; i < visibleItems.count(); ++i)
+ releaseItem(visibleItems.at(i));
+ visibleItems.clear();
+ modelIndex += count;
+ if (modelIndex >= model->count()) {
+ count -= modelIndex - model->count() + 1;
+ modelIndex = model->count() - 1;
+ } else if (modelIndex < 0) {
+ count -= modelIndex;
+ modelIndex = 0;
+ }
+ visibleIndex = modelIndex;
+ visiblePos = itemEnd + count * (averageSize + spacing) + 1;
+ itemEnd = visiblePos-1;
+ }
+
bool changed = false;
FxListItem *item = 0;
qreal pos = itemEnd + 1;