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