diff options
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativepositioners.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativepositioners.cpp | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index b23b8c9..d33a8be 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qdeclarativepositioners_p.h" -#include "qdeclarativepositioners_p_p.h" +#include "private/qdeclarativepositioners_p.h" +#include "private/qdeclarativepositioners_p_p.h" #include <qdeclarative.h> #include <qdeclarativestate_p.h> @@ -237,21 +237,13 @@ void QDeclarativeBasePositioner::prePositioning() positionedItems.append(*item); } } - doPositioning(); + QSizeF contentSize; + doPositioning(&contentSize); if(d->addTransition || d->moveTransition) finishApplyTransitions(); //Set implicit size to the size of its children - qreal h = 0.0f; - qreal w = 0.0f; - for (int i = 0; i < positionedItems.count(); ++i) { - const PositionedItem &posItem = positionedItems.at(i); - if (posItem.isVisible) { - h = qMax(h, posItem.item->y() + posItem.item->height()); - w = qMax(w, posItem.item->x() + posItem.item->width()); - } - } - setImplicitHeight(h); - setImplicitWidth(w); + setImplicitHeight(contentSize.height()); + setImplicitWidth(contentSize.width()); } void QDeclarativeBasePositioner::positionX(int x, const PositionedItem &target) @@ -423,7 +415,7 @@ static inline bool isInvisible(QDeclarativeItem *child) return child->opacity() == 0.0 || !child->isVisible() || !child->width() || !child->height(); } -void QDeclarativeColumn::doPositioning() +void QDeclarativeColumn::doPositioning(QSizeF *contentSize) { int voffset = 0; @@ -435,9 +427,13 @@ void QDeclarativeColumn::doPositioning() if(child.item->y() != voffset) positionY(voffset, child); + contentSize->setWidth(qMax(contentSize->width(), child.item->width())); + voffset += child.item->height(); voffset += spacing(); } + + contentSize->setHeight(voffset - spacing()); } /*! @@ -534,7 +530,7 @@ QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent) { } -void QDeclarativeRow::doPositioning() +void QDeclarativeRow::doPositioning(QSizeF *contentSize) { int hoffset = 0; @@ -546,9 +542,13 @@ void QDeclarativeRow::doPositioning() if(child.item->x() != hoffset) positionX(hoffset, child); + contentSize->setHeight(qMax(contentSize->height(), child.item->height())); + hoffset += child.item->width(); hoffset += spacing(); } + + contentSize->setWidth(hoffset - spacing()); } @@ -698,7 +698,7 @@ void QDeclarativeGrid::setRows(const int rows) emit rowsChanged(); } -void QDeclarativeGrid::doPositioning() +void QDeclarativeGrid::doPositioning(QSizeF *contentSize) { int c=_columns,r=_rows;//Actual number of rows/columns int numVisible = positionedItems.count(); @@ -745,6 +745,10 @@ void QDeclarativeGrid::doPositioning() positionX(xoffset, child); positionY(yoffset, child); } + + contentSize->setWidth(qMax(contentSize->width(), xoffset + child.item->width())); + contentSize->setHeight(yoffset + maxRowHeight[curRow]); + xoffset+=maxColWidth[curCol]+spacing(); curCol++; curCol%=c; @@ -854,7 +858,7 @@ void QDeclarativeFlow::setFlow(Flow flow) } } -void QDeclarativeFlow::doPositioning() +void QDeclarativeFlow::doPositioning(QSizeF *contentSize) { Q_D(QDeclarativeFlow); @@ -886,6 +890,9 @@ void QDeclarativeFlow::doPositioning() positionY(voffset, child); } + contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width())); + contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height())); + if (d->flow == LeftToRight) { hoffset += child.item->width(); hoffset += spacing(); |