Use meaningful variable names

Make the meaning of the code more obvious and avoid a compiler
warning about the variable "w" being overridden.

Change-Id: Ib76d3aa1cae46e263b2ab61b675d9ef74032aacc
Reviewed-by: Rohan McGovern
(cherry picked from commit 59634e825f1efa6f32befc8767cafedfeb9b7d59)
This commit is contained in:
Jason McDonald 2011-04-21 13:00:06 +10:00 committed by Rohan McGovern
parent 9e0049f656
commit 0ea9ffef43

View File

@ -132,33 +132,33 @@ static void setAnchor(QGraphicsAnchorLayout *l,
anchor->setSpacing(spacing); anchor->setSpacing(spacing);
} }
static bool checkReverseDirection(QGraphicsWidget *w) static bool checkReverseDirection(QGraphicsWidget *widget)
{ {
QGraphicsLayout *l = w->layout(); QGraphicsLayout *layout = widget->layout();
Q_ASSERT(l); Q_ASSERT(layout);
qreal left, top, right, bottom; qreal left, top, right, bottom;
l->getContentsMargins(&left, &top, &right, &bottom); layout->getContentsMargins(&left, &top, &right, &bottom);
w->setLayoutDirection(Qt::LeftToRight); widget->setLayoutDirection(Qt::LeftToRight);
QApplication::processEvents(); QApplication::processEvents();
const QRectF lg = l->geometry(); const QRectF layoutGeometry = layout->geometry();
QMap<QGraphicsLayoutItem *, QRectF> geometries; QMap<QGraphicsLayoutItem *, QRectF> geometries;
for (int i = 0; i < l->count(); ++i) { for (int i = 0; i < layout->count(); ++i) {
QGraphicsLayoutItem *w = l->itemAt(i); QGraphicsLayoutItem *item = layout->itemAt(i);
geometries.insert(w, w->geometry()); geometries.insert(item, item->geometry());
} }
w->setLayoutDirection(Qt::RightToLeft); widget->setLayoutDirection(Qt::RightToLeft);
QApplication::processEvents(); QApplication::processEvents();
lg.adjusted(+right, +top, -left, -bottom); layoutGeometry.adjusted(+right, +top, -left, -bottom);
for (int i = 0; i < l->count(); ++i) { for (int i = 0; i < layout->count(); ++i) {
QGraphicsLayoutItem *w = l->itemAt(i); QGraphicsLayoutItem *item = layout->itemAt(i);
const QRectF rtlGeom = w->geometry(); const QRectF rightToLeftGeometry = item->geometry();
const QRectF ltrGeom = geometries.value(w); const QRectF leftToRightGeometry = geometries.value(item);
QRectF expectedGeom = ltrGeom; QRectF expectedGeometry = leftToRightGeometry;
expectedGeom.moveRight(lg.right() - (0 + ltrGeom.left())); expectedGeometry.moveRight(layoutGeometry.right() - leftToRightGeometry.left());
if (expectedGeom != rtlGeom) { if (expectedGeometry != rightToLeftGeometry) {
qDebug() << "layout->geometry():" << lg qDebug() << "layout->geometry():" << layoutGeometry
<< "expected:" << expectedGeom << "expected:" << expectedGeometry
<< "actual:" << rtlGeom; << "actual:" << rightToLeftGeometry;
return false; return false;
} }
} }