Fix Column/Row size when no items being positioned

Change-Id: I0bf55c13e55856dd7292e5eda159086096dea86b
Reviewed-on: http://codereview.qt.nokia.com/2158
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
This commit is contained in:
Alan Alpert 2011-07-26 16:47:09 +10:00 committed by Qt by Nokia
parent 1a1ce3775b
commit d7630a80bd
3 changed files with 70 additions and 5 deletions

View File

@ -211,7 +211,7 @@ void QSGBasePositioner::prePositioning()
positionedItems.append(*item);
}
}
QSizeF contentSize;
QSizeF contentSize(0,0);
doPositioning(&contentSize);
if(d->addTransition || d->moveTransition)
finishApplyTransitions();
@ -288,10 +288,11 @@ void QSGColumn::doPositioning(QSizeF *contentSize)
contentSize->setWidth(qMax(contentSize->width(), child.item->width()));
voffset += child.item->height();
voffset += spacing();
if (ii != positionedItems.count() - 1)
voffset += spacing();
}
contentSize->setHeight(voffset - spacing());
contentSize->setHeight(voffset);
}
void QSGColumn::reportConflictingAnchors()
@ -370,10 +371,11 @@ void QSGRow::doPositioning(QSizeF *contentSize)
contentSize->setHeight(qMax(contentSize->height(), child.item->height()));
hoffset += child.item->width();
hoffset += spacing();
if (ii != positionedItems.count() - 1)
hoffset += spacing();
}
contentSize->setWidth(hoffset - spacing());
contentSize->setWidth(hoffset);
if (d->isLeftToRight())
return;

View File

@ -0,0 +1,44 @@
import QtQuick 2.0
Item{
width: 400
height: 400
Column{
spacing: 20
objectName: "column"
Item{
width: 0
height: 20
visible: false
}
Item{
width: 20
height: 0
visible: false
}
Item{
width: 20
height: 20
visible: false
}
}
Row{
spacing: 20
objectName: "row"
Item{
width: 0
height: 20
visible: false
}
Item{
width: 20
height: 0
visible: false
}
Item{
width: 20
height: 20
visible: false
}
}
}

View File

@ -88,6 +88,7 @@ private slots:
void test_flow_implicit_resize();
void test_conflictinganchors();
void test_mirroring();
void test_allInvisible();
private:
QSGView *createView(const QString &filename);
};
@ -1251,6 +1252,24 @@ void tst_qsgpositioners::test_mirroring()
}
}
void tst_qsgpositioners::test_allInvisible()
{
//QTBUG-19361
QSGView *canvas = createView(SRCDIR "/data/allInvisible.qml");
QSGItem *root = qobject_cast<QSGItem*>(canvas->rootObject());
QVERIFY(root);
QSGRow *row = canvas->rootObject()->findChild<QSGRow*>("row");
QVERIFY(row != 0);
QVERIFY(row->width() == 0);
QVERIFY(row->height() == 0);
QSGColumn *column = canvas->rootObject()->findChild<QSGColumn*>("column");
QVERIFY(column != 0);
QVERIFY(column->width() == 0);
QVERIFY(column->height() == 0);
}
QSGView *tst_qsgpositioners::createView(const QString &filename)
{
QSGView *canvas = new QSGView(0);