aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsggridview.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-05-04 10:21:47 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-05-04 10:21:47 +0200
commit16f58282bc5a1f81f7346ac6560df68761ad277d (patch)
tree38cc24d17ea4d868ee3cffd8ca99e96ac08e76dd /src/declarative/items/qsggridview.cpp
parent280242a5a14a99cc10857e35da61ac5b894d5f6b (diff)
parent1b7c1b6ef86d3d56ff01b2eab118062a229b0d19 (diff)
Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qtdeclarative-staging into qtquick2
Diffstat (limited to 'src/declarative/items/qsggridview.cpp')
-rw-r--r--src/declarative/items/qsggridview.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/declarative/items/qsggridview.cpp b/src/declarative/items/qsggridview.cpp
index 9beac05d72..43f7f982a4 100644
--- a/src/declarative/items/qsggridview.cpp
+++ b/src/declarative/items/qsggridview.cpp
@@ -1,4 +1,4 @@
-// Commit: cc6408ccd5453d1bed9f98b9caa14861cea5742b
+// Commit: fda9cc1d8a0e49817d1c6192c52d18dffcecf327
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
@@ -488,6 +488,7 @@ public:
void QSGGridViewPrivate::init()
{
Q_Q(QSGGridView);
+ QSGItemPrivate::get(contentItem)->childrenDoNotOverlap = true;
QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped()));
q->setFlag(QSGItem::ItemIsFocusScope);
q->setFlickableDirection(QSGFlickable::VerticalFlick);
@@ -580,6 +581,26 @@ void QSGGridViewPrivate::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();
FxGridItemSG *item = 0;
@@ -1111,6 +1132,7 @@ void QSGGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)
} else {
QSGFlickablePrivate::fixup(data, minExtent, maxExtent);
}
+ data.inOvershoot = false;
fixupMode = Normal;
}
@@ -1189,7 +1211,7 @@ void QSGGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent,
accel = v2 / (2.0f * qAbs(dist));
} else {
data.flickTarget = velocity > 0 ? minExtent : maxExtent;
- overshootDist = overShoot ? overShootDistance(v, vSize) : 0;
+ overshootDist = overShoot ? overShootDistance(vSize) : 0;
}
timeline.reset(data.move);
timeline.accel(data.move, v, accel, maxDistance + overshootDist);
@@ -1868,7 +1890,7 @@ qreal QSGGridView::maxXExtent() const
qreal extent;
qreal highlightStart;
qreal highlightEnd;
- qreal lastItemPosition;
+ qreal lastItemPosition = 0;
if (d->isRightToLeftTopToBottom()){
highlightStart = d->highlightRangeStartValid ? d->highlightRangeEnd : d->size();
highlightEnd = d->highlightRangeEndValid ? d->highlightRangeStart : d->size();
@@ -1876,6 +1898,7 @@ qreal QSGGridView::maxXExtent() const
} else {
highlightStart = d->highlightRangeStart;
highlightEnd = d->highlightRangeEnd;
+ lastItemPosition = 0;
if (d->model && d->model->count())
lastItemPosition = d->rowPosAt(d->model->count()-1);
}
@@ -2366,11 +2389,9 @@ void QSGGridView::itemsInserted(int modelIndex, int count)
if (d->currentItem) {
d->currentItem->index = d->currentIndex;
d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex));
- } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) {
- d->updateCurrent(0);
}
emit currentIndexChanged();
- } else if (d->itemCount == 0 && d->currentIndex == -1) {
+ } else if (d->itemCount == 0 && (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared))) {
setCurrentIndex(0);
}
@@ -2438,6 +2459,8 @@ void QSGGridView::itemsRemoved(int modelIndex, int count)
d->currentIndex = -1;
if (d->itemCount)
d->updateCurrent(qMin(modelIndex, d->itemCount-1));
+ else
+ emit currentIndexChanged();
}
// update visibleIndex