summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativegridview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-03-08 02:43:22 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-03-08 02:43:22 (GMT)
commiteb45d1cc264dbec26575b2bd6cd23b09e3ade653 (patch)
treec0556ca38ce7d60e9104c506590c6429539c8f71 /src/declarative/graphicsitems/qdeclarativegridview.cpp
parent0ad0e7aa99218a82d6c08fed27781282bfe355a2 (diff)
downloadQt-eb45d1cc264dbec26575b2bd6cd23b09e3ade653.zip
Qt-eb45d1cc264dbec26575b2bd6cd23b09e3ade653.tar.gz
Qt-eb45d1cc264dbec26575b2bd6cd23b09e3ade653.tar.bz2
Remove code dupliation in fixupX/Y(), flickX/Y()
Also some minor perf improvements by avoiding signal/slot connection
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativegridview.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 463b238..76ad9b7 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -236,6 +236,19 @@ public:
return -1; // Not in visibleList
}
+ void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
+ Q_Q(const QDeclarativeGridView);
+ QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry);
+ if (item == q) {
+ if (newGeometry.height() != oldGeometry.height()
+ || newGeometry.width() != oldGeometry.width()) {
+ if (q->isComponentComplete()) {
+ updateGrid();
+ layout();
+ }
+ }
+ }
+ }
// for debugging only
void checkVisible() const {
int skip = 0;
@@ -288,9 +301,8 @@ void QDeclarativeGridViewPrivate::init()
{
Q_Q(QDeclarativeGridView);
q->setFlag(QGraphicsItem::ItemIsFocusScope);
- QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(sizeChange()));
- QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(sizeChange()));
q->setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+ addItemChangeListener(this, Geometry);
}
void QDeclarativeGridViewPrivate::clear()
@@ -1142,15 +1154,6 @@ void QDeclarativeGridView::setCellHeight(int cellHeight)
}
}
-void QDeclarativeGridView::sizeChange()
-{
- Q_D(QDeclarativeGridView);
- if (isComponentComplete()) {
- d->updateGrid();
- d->layout();
- }
-}
-
void QDeclarativeGridView::viewportMoved()
{
Q_D(QDeclarativeGridView);
@@ -1158,16 +1161,16 @@ void QDeclarativeGridView::viewportMoved()
d->lazyRelease = true;
if (d->flicked) {
if (yflick()) {
- if (d->velocityY > 0)
+ if (d->vData.velocity > 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore;
- else if (d->velocityY < 0)
+ else if (d->vData.velocity < 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferAfter;
}
if (xflick()) {
- if (d->velocityX > 0)
+ if (d->hData.velocity > 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore;
- else if (d->velocityX < 0)
+ else if (d->hData.velocity < 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferAfter;
}
}