diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-04-01 00:36:49 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-04-01 01:23:34 (GMT) |
commit | 1f38d41854fa2daa51d938a4eb398752b1751e0b (patch) | |
tree | 0f8cb5b1e7982258098c782c3674c435f39bdd14 | |
parent | 1ff7c423308feeaa73e1eab6e20147f5c3d2ccd3 (diff) | |
download | Qt-1f38d41854fa2daa51d938a4eb398752b1751e0b.zip Qt-1f38d41854fa2daa51d938a4eb398752b1751e0b.tar.gz Qt-1f38d41854fa2daa51d938a4eb398752b1751e0b.tar.bz2 |
Changing width of RTL positioner doesn't relayout
If the width of the layout changes then the items must be laid out
again.
Change-Id: I2b97bd45d07842fd3da2a0637391473ed6d78aa8
Task-number: QTBUG-18501
Reviewed-by: Michael Brasser
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativepositioners.cpp | 10 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp | 22 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 8a9bdb3..e76fc03 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -609,6 +609,11 @@ void QDeclarativeRow::setLayoutDirection(Qt::LayoutDirection layoutDirection) QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate* >(QDeclarativeBasePositionerPrivate::get(this)); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; + // For RTL layout the positioning changes when the width changes. + if (d->layoutDirection == Qt::RightToLeft) + d->addItemChangeListener(d, QDeclarativeItemPrivate::Geometry); + else + d->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry); prePositioning(); emit layoutDirectionChanged(); emit effectiveLayoutDirectionChanged(); @@ -907,6 +912,11 @@ void QDeclarativeGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection) QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this)); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; + // For RTL layout the positioning changes when the width changes. + if (d->layoutDirection == Qt::RightToLeft) + d->addItemChangeListener(d, QDeclarativeItemPrivate::Geometry); + else + d->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry); prePositioning(); emit layoutDirectionChanged(); emit effectiveLayoutDirectionChanged(); diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 92ab722..78821cb 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -154,6 +154,15 @@ void tst_QDeclarativePositioners::test_horizontal_rtl() QCOMPARE(row->width(), 110.0); QCOMPARE(row->height(), 50.0); + // Change the width of the row and check that items stay to the right + row->setWidth(200); + QCOMPARE(one->x(), 150.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 130.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 90.0); + QCOMPARE(three->y(), 0.0); + delete canvas; } @@ -527,6 +536,19 @@ void tst_QDeclarativePositioners::test_grid_rightToLeft() QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 100.0); + // Change the width of the grid and check that items stay to the right + grid->setWidth(200); + QCOMPARE(one->x(), 150.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 130.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 100.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 150.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 140.0); + QCOMPARE(five->y(), 50.0); + delete canvas; } |