Revert "Positioners: allow distinguishing between implicit/explicit child size"
This reverts commit 2556bfdab4
.
This is no longer necessary, as there are now no users of this
functionality in other modules.
Change-Id: If92bbdb3e5e95b4103610d68d22e929cf30c4e5e
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
This commit is contained in:
parent
fa01610d6b
commit
315f368986
|
@ -48,19 +48,8 @@
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
// The default item change types that positioners are interested in.
|
static const QQuickItemPrivate::ChangeTypes watchedChanges
|
||||||
static const QQuickItemPrivate::ChangeTypes explicitSizeItemChangeTypes =
|
= QQuickItemPrivate::Geometry
|
||||||
QQuickItemPrivate::Geometry
|
|
||||||
| QQuickItemPrivate::SiblingOrder
|
|
||||||
| QQuickItemPrivate::Visibility
|
|
||||||
| QQuickItemPrivate::Destroyed;
|
|
||||||
|
|
||||||
// The item change types for positioners that are only interested in the implicit
|
|
||||||
// size of the items they manage. These are used if useImplicitSize is true.
|
|
||||||
// useImplicitSize should be set in the constructor, before any items are added.
|
|
||||||
static const QQuickItemPrivate::ChangeTypes implicitSizeItemChangeTypes =
|
|
||||||
QQuickItemPrivate::ImplicitWidth
|
|
||||||
| QQuickItemPrivate::ImplicitHeight
|
|
||||||
| QQuickItemPrivate::SiblingOrder
|
| QQuickItemPrivate::SiblingOrder
|
||||||
| QQuickItemPrivate::Visibility
|
| QQuickItemPrivate::Visibility
|
||||||
| QQuickItemPrivate::Destroyed;
|
| QQuickItemPrivate::Destroyed;
|
||||||
|
@ -68,15 +57,13 @@ static const QQuickItemPrivate::ChangeTypes implicitSizeItemChangeTypes =
|
||||||
void QQuickBasePositionerPrivate::watchChanges(QQuickItem *other)
|
void QQuickBasePositionerPrivate::watchChanges(QQuickItem *other)
|
||||||
{
|
{
|
||||||
QQuickItemPrivate *otherPrivate = QQuickItemPrivate::get(other);
|
QQuickItemPrivate *otherPrivate = QQuickItemPrivate::get(other);
|
||||||
otherPrivate->addItemChangeListener(this, useImplicitSize
|
otherPrivate->addItemChangeListener(this, watchedChanges);
|
||||||
? implicitSizeItemChangeTypes : explicitSizeItemChangeTypes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQuickBasePositionerPrivate::unwatchChanges(QQuickItem* other)
|
void QQuickBasePositionerPrivate::unwatchChanges(QQuickItem* other)
|
||||||
{
|
{
|
||||||
QQuickItemPrivate *otherPrivate = QQuickItemPrivate::get(other);
|
QQuickItemPrivate *otherPrivate = QQuickItemPrivate::get(other);
|
||||||
otherPrivate->removeItemChangeListener(this, useImplicitSize
|
otherPrivate->removeItemChangeListener(this, watchedChanges);
|
||||||
? implicitSizeItemChangeTypes : explicitSizeItemChangeTypes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -336,7 +323,7 @@ void QQuickBasePositioner::prePositioning()
|
||||||
if (wIdx < 0) {
|
if (wIdx < 0) {
|
||||||
d->watchChanges(child);
|
d->watchChanges(child);
|
||||||
posItem.isNew = true;
|
posItem.isNew = true;
|
||||||
if (!childPrivate->explicitVisible || !d->itemWidth(child) || !d->itemHeight(child)) {
|
if (!childPrivate->explicitVisible || !child->width() || !child->height()) {
|
||||||
posItem.isVisible = false;
|
posItem.isVisible = false;
|
||||||
posItem.index = -1;
|
posItem.index = -1;
|
||||||
unpositionedItems.append(posItem);
|
unpositionedItems.append(posItem);
|
||||||
|
@ -358,7 +345,7 @@ void QQuickBasePositioner::prePositioning()
|
||||||
PositionedItem *item = &oldItems[wIdx];
|
PositionedItem *item = &oldItems[wIdx];
|
||||||
// Items are only omitted from positioning if they are explicitly hidden
|
// Items are only omitted from positioning if they are explicitly hidden
|
||||||
// i.e. their positioning is not affected if an ancestor is hidden.
|
// i.e. their positioning is not affected if an ancestor is hidden.
|
||||||
if (!childPrivate->explicitVisible || !d->itemWidth(child) || !d->itemHeight(child)) {
|
if (!childPrivate->explicitVisible || !child->width() || !child->height()) {
|
||||||
item->isVisible = false;
|
item->isVisible = false;
|
||||||
item->index = -1;
|
item->index = -1;
|
||||||
unpositionedItems.append(*item);
|
unpositionedItems.append(*item);
|
||||||
|
@ -957,7 +944,6 @@ QQuickColumn::QQuickColumn(QQuickItem *parent)
|
||||||
void QQuickColumn::doPositioning(QSizeF *contentSize)
|
void QQuickColumn::doPositioning(QSizeF *contentSize)
|
||||||
{
|
{
|
||||||
//Precondition: All items in the positioned list have a valid item pointer and should be positioned
|
//Precondition: All items in the positioned list have a valid item pointer and should be positioned
|
||||||
QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate*>(QQuickBasePositionerPrivate::get(this));
|
|
||||||
qreal voffset = topPadding();
|
qreal voffset = topPadding();
|
||||||
const qreal padding = leftPadding() + rightPadding();
|
const qreal padding = leftPadding() + rightPadding();
|
||||||
contentSize->setWidth(qMax(contentSize->width(), padding));
|
contentSize->setWidth(qMax(contentSize->width(), padding));
|
||||||
|
@ -966,9 +952,9 @@ void QQuickColumn::doPositioning(QSizeF *contentSize)
|
||||||
PositionedItem &child = positionedItems[ii];
|
PositionedItem &child = positionedItems[ii];
|
||||||
positionItem(child.itemX() + leftPadding() - child.leftPadding, voffset, &child);
|
positionItem(child.itemX() + leftPadding() - child.leftPadding, voffset, &child);
|
||||||
child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding());
|
child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding());
|
||||||
contentSize->setWidth(qMax(contentSize->width(), d->itemWidth(child.item) + padding));
|
contentSize->setWidth(qMax(contentSize->width(), child.item->width() + padding));
|
||||||
|
|
||||||
voffset += d->itemHeight(child.item);
|
voffset += child.item->height();
|
||||||
voffset += spacing();
|
voffset += spacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1236,9 +1222,9 @@ void QQuickRow::doPositioning(QSizeF *contentSize)
|
||||||
hoffsets << hoffset;
|
hoffsets << hoffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
contentSize->setHeight(qMax(contentSize->height(), d->itemHeight(child.item) + padding));
|
contentSize->setHeight(qMax(contentSize->height(), child.item->height() + padding));
|
||||||
|
|
||||||
hoffset += d->itemWidth(child.item);
|
hoffset += child.item->width();
|
||||||
hoffset += spacing();
|
hoffset += spacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1259,7 +1245,7 @@ void QQuickRow::doPositioning(QSizeF *contentSize)
|
||||||
int acc = 0;
|
int acc = 0;
|
||||||
for (int ii = 0; ii < positionedItems.count(); ++ii) {
|
for (int ii = 0; ii < positionedItems.count(); ++ii) {
|
||||||
PositionedItem &child = positionedItems[ii];
|
PositionedItem &child = positionedItems[ii];
|
||||||
hoffset = end - hoffsets[acc++] - d->itemWidth(child.item);
|
hoffset = end - hoffsets[acc++] - child.item->width();
|
||||||
positionItem(hoffset, child.itemY() + topPadding() - child.topPadding, &child);
|
positionItem(hoffset, child.itemY() + topPadding() - child.topPadding, &child);
|
||||||
child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding());
|
child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding());
|
||||||
}
|
}
|
||||||
|
@ -1760,12 +1746,10 @@ void QQuickGrid::doPositioning(QSizeF *contentSize)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const PositionedItem &child = positionedItems.at(childIndex++);
|
const PositionedItem &child = positionedItems.at(childIndex++);
|
||||||
const qreal childWidth = d->itemWidth(child.item);
|
if (child.item->width() > maxColWidth[j])
|
||||||
const qreal childHeight = d->itemHeight(child.item);
|
maxColWidth[j] = child.item->width();
|
||||||
if (childWidth > maxColWidth[j])
|
if (child.item->height() > maxRowHeight[i])
|
||||||
maxColWidth[j] = childWidth;
|
maxRowHeight[i] = child.item->height();
|
||||||
if (childHeight > maxRowHeight[i])
|
|
||||||
maxRowHeight[i] = childHeight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1780,12 +1764,10 @@ void QQuickGrid::doPositioning(QSizeF *contentSize)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const PositionedItem &child = positionedItems.at(childIndex++);
|
const PositionedItem &child = positionedItems.at(childIndex++);
|
||||||
const qreal childWidth = d->itemWidth(child.item);
|
if (child.item->width() > maxColWidth[j])
|
||||||
const qreal childHeight = d->itemHeight(child.item);
|
maxColWidth[j] = child.item->width();
|
||||||
if (childWidth > maxColWidth[j])
|
if (child.item->height() > maxRowHeight[i])
|
||||||
maxColWidth[j] = childWidth;
|
maxRowHeight[i] = child.item->height();
|
||||||
if (childHeight > maxRowHeight[i])
|
|
||||||
maxRowHeight[i] = childHeight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1827,22 +1809,20 @@ void QQuickGrid::doPositioning(QSizeF *contentSize)
|
||||||
for (int i = 0; i < positionedItems.count(); ++i) {
|
for (int i = 0; i < positionedItems.count(); ++i) {
|
||||||
PositionedItem &child = positionedItems[i];
|
PositionedItem &child = positionedItems[i];
|
||||||
qreal childXOffset = xoffset;
|
qreal childXOffset = xoffset;
|
||||||
const qreal childWidth = d->itemWidth(child.item);
|
|
||||||
const qreal childHeight = d->itemHeight(child.item);
|
|
||||||
|
|
||||||
if (effectiveHAlign() == AlignRight)
|
if (effectiveHAlign() == AlignRight)
|
||||||
childXOffset += maxColWidth[curCol] - childWidth;
|
childXOffset += maxColWidth[curCol] - child.item->width();
|
||||||
else if (hItemAlign() == AlignHCenter)
|
else if (hItemAlign() == AlignHCenter)
|
||||||
childXOffset += (maxColWidth[curCol] - childWidth)/2.0;
|
childXOffset += (maxColWidth[curCol] - child.item->width())/2.0;
|
||||||
|
|
||||||
if (!d->isLeftToRight())
|
if (!d->isLeftToRight())
|
||||||
childXOffset -= maxColWidth[curCol];
|
childXOffset -= maxColWidth[curCol];
|
||||||
|
|
||||||
qreal alignYOffset = yoffset;
|
qreal alignYOffset = yoffset;
|
||||||
if (m_vItemAlign == AlignVCenter)
|
if (m_vItemAlign == AlignVCenter)
|
||||||
alignYOffset += (maxRowHeight[curRow] - childHeight)/2.0;
|
alignYOffset += (maxRowHeight[curRow] - child.item->height())/2.0;
|
||||||
else if (m_vItemAlign == AlignBottom)
|
else if (m_vItemAlign == AlignBottom)
|
||||||
alignYOffset += maxRowHeight[curRow] - childHeight;
|
alignYOffset += maxRowHeight[curRow] - child.item->height();
|
||||||
|
|
||||||
positionItem(childXOffset, alignYOffset, &child);
|
positionItem(childXOffset, alignYOffset, &child);
|
||||||
child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding());
|
child.updatePadding(leftPadding(), topPadding(), rightPadding(), bottomPadding());
|
||||||
|
@ -2160,17 +2140,15 @@ void QQuickFlow::doPositioning(QSizeF *contentSize)
|
||||||
|
|
||||||
for (int i = 0; i < positionedItems.count(); ++i) {
|
for (int i = 0; i < positionedItems.count(); ++i) {
|
||||||
PositionedItem &child = positionedItems[i];
|
PositionedItem &child = positionedItems[i];
|
||||||
const qreal childWidth = d->itemWidth(child.item);
|
|
||||||
const qreal childHeight = d->itemHeight(child.item);
|
|
||||||
|
|
||||||
if (d->flow == LeftToRight) {
|
if (d->flow == LeftToRight) {
|
||||||
if (widthValid() && hoffset != hoffset1 && hoffset + childWidth + hoffset2 > width()) {
|
if (widthValid() && hoffset != hoffset1 && hoffset + child.item->width() + hoffset2 > width()) {
|
||||||
hoffset = hoffset1;
|
hoffset = hoffset1;
|
||||||
voffset += linemax + spacing();
|
voffset += linemax + spacing();
|
||||||
linemax = 0;
|
linemax = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (heightValid() && voffset != voffset1 && voffset + childHeight + bottomPadding() > height()) {
|
if (heightValid() && voffset != voffset1 && voffset + child.item->height() + bottomPadding() > height()) {
|
||||||
voffset = voffset1;
|
voffset = voffset1;
|
||||||
hoffset += linemax + spacing();
|
hoffset += linemax + spacing();
|
||||||
linemax = 0;
|
linemax = 0;
|
||||||
|
@ -2187,17 +2165,17 @@ void QQuickFlow::doPositioning(QSizeF *contentSize)
|
||||||
child.bottomPadding = bottomPadding();
|
child.bottomPadding = bottomPadding();
|
||||||
}
|
}
|
||||||
|
|
||||||
contentSize->setWidth(qMax(contentSize->width(), hoffset + childWidth + hoffset2));
|
contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width() + hoffset2));
|
||||||
contentSize->setHeight(qMax(contentSize->height(), voffset + childHeight + bottomPadding()));
|
contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height() + bottomPadding()));
|
||||||
|
|
||||||
if (d->flow == LeftToRight) {
|
if (d->flow == LeftToRight) {
|
||||||
hoffset += childWidth;
|
hoffset += child.item->width();
|
||||||
hoffset += spacing();
|
hoffset += spacing();
|
||||||
linemax = qMax(linemax, childHeight);
|
linemax = qMax(linemax, child.item->height());
|
||||||
} else {
|
} else {
|
||||||
voffset += childHeight;
|
voffset += child.item->height();
|
||||||
voffset += spacing();
|
voffset += spacing();
|
||||||
linemax = qMax(linemax, childWidth);
|
linemax = qMax(linemax, child.item->width());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2212,7 +2190,7 @@ void QQuickFlow::doPositioning(QSizeF *contentSize)
|
||||||
int acc = 0;
|
int acc = 0;
|
||||||
for (int i = 0; i < positionedItems.count(); ++i) {
|
for (int i = 0; i < positionedItems.count(); ++i) {
|
||||||
PositionedItem &child = positionedItems[i];
|
PositionedItem &child = positionedItems[i];
|
||||||
hoffset = end - hoffsets[acc++] - d->itemWidth(child.item);
|
hoffset = end - hoffsets[acc++] - child.item->width();
|
||||||
positionItemX(hoffset, &child);
|
positionItemX(hoffset, &child);
|
||||||
child.leftPadding = leftPadding();
|
child.leftPadding = leftPadding();
|
||||||
child.rightPadding = rightPadding();
|
child.rightPadding = rightPadding();
|
||||||
|
@ -2236,18 +2214,4 @@ void QQuickFlow::reportConflictingAnchors()
|
||||||
qmlWarning(this) << "Cannot specify anchors for items inside Flow." << " Flow will not function.";
|
qmlWarning(this) << "Cannot specify anchors for items inside Flow." << " Flow will not function.";
|
||||||
}
|
}
|
||||||
|
|
||||||
QQuickImplicitRow::QQuickImplicitRow(QQuickItem *parent)
|
|
||||||
: QQuickRow(parent)
|
|
||||||
{
|
|
||||||
QQuickBasePositionerPrivate *d = QQuickBasePositioner::get(this);
|
|
||||||
d->useImplicitSize = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QQuickImplicitGrid::QQuickImplicitGrid(QQuickItem *parent)
|
|
||||||
: QQuickGrid(parent)
|
|
||||||
{
|
|
||||||
QQuickBasePositionerPrivate *d = QQuickBasePositioner::get(this);
|
|
||||||
d->useImplicitSize = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
|
@ -132,11 +132,6 @@ public:
|
||||||
|
|
||||||
static QQuickPositionerAttached *qmlAttachedProperties(QObject *obj);
|
static QQuickPositionerAttached *qmlAttachedProperties(QObject *obj);
|
||||||
|
|
||||||
static QQuickBasePositionerPrivate* get(QQuickBasePositioner *positioner)
|
|
||||||
{
|
|
||||||
return positioner->d_func();
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateAttachedProperties(QQuickPositionerAttached *specificProperty = 0, QQuickItem *specificPropertyOwner = 0) const;
|
void updateAttachedProperties(QQuickPositionerAttached *specificProperty = 0, QQuickItem *specificPropertyOwner = 0) const;
|
||||||
|
|
||||||
qreal padding() const;
|
qreal padding() const;
|
||||||
|
@ -187,7 +182,7 @@ protected:
|
||||||
virtual void doPositioning(QSizeF *contentSize)=0;
|
virtual void doPositioning(QSizeF *contentSize)=0;
|
||||||
virtual void reportConflictingAnchors()=0;
|
virtual void reportConflictingAnchors()=0;
|
||||||
|
|
||||||
class Q_QUICK_PRIVATE_EXPORT PositionedItem
|
class PositionedItem
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
PositionedItem(QQuickItem *i);
|
PositionedItem(QQuickItem *i);
|
||||||
|
@ -232,7 +227,7 @@ private:
|
||||||
Q_DECLARE_PRIVATE(QQuickBasePositioner)
|
Q_DECLARE_PRIVATE(QQuickBasePositioner)
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_QUICK_PRIVATE_EXPORT QQuickColumn : public QQuickBasePositioner
|
class Q_AUTOTEST_EXPORT QQuickColumn : public QQuickBasePositioner
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -246,7 +241,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class QQuickRowPrivate;
|
class QQuickRowPrivate;
|
||||||
class Q_QUICK_PRIVATE_EXPORT QQuickRow: public QQuickBasePositioner
|
class Q_AUTOTEST_EXPORT QQuickRow: public QQuickBasePositioner
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
|
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
|
||||||
|
@ -271,7 +266,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class QQuickGridPrivate;
|
class QQuickGridPrivate;
|
||||||
class Q_QUICK_PRIVATE_EXPORT QQuickGrid : public QQuickBasePositioner
|
class Q_AUTOTEST_EXPORT QQuickGrid : public QQuickBasePositioner
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
|
Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
|
||||||
|
@ -358,7 +353,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class QQuickFlowPrivate;
|
class QQuickFlowPrivate;
|
||||||
class Q_QUICK_PRIVATE_EXPORT QQuickFlow: public QQuickBasePositioner
|
class Q_AUTOTEST_EXPORT QQuickFlow: public QQuickBasePositioner
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
|
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
|
||||||
|
@ -391,22 +386,6 @@ private:
|
||||||
Q_DECLARE_PRIVATE(QQuickFlow)
|
Q_DECLARE_PRIVATE(QQuickFlow)
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_QUICK_PRIVATE_EXPORT QQuickImplicitRow : public QQuickRow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
QQuickImplicitRow(QQuickItem *parent = nullptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
class Q_QUICK_PRIVATE_EXPORT QQuickImplicitGrid : public QQuickGrid
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
QQuickImplicitGrid(QQuickItem *parent = nullptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
@ -414,8 +393,6 @@ QML_DECLARE_TYPE(QQuickColumn)
|
||||||
QML_DECLARE_TYPE(QQuickRow)
|
QML_DECLARE_TYPE(QQuickRow)
|
||||||
QML_DECLARE_TYPE(QQuickGrid)
|
QML_DECLARE_TYPE(QQuickGrid)
|
||||||
QML_DECLARE_TYPE(QQuickFlow)
|
QML_DECLARE_TYPE(QQuickFlow)
|
||||||
QML_DECLARE_TYPE(QQuickImplicitRow)
|
|
||||||
QML_DECLARE_TYPE(QQuickImplicitGrid)
|
|
||||||
|
|
||||||
QML_DECLARE_TYPE(QQuickBasePositioner)
|
QML_DECLARE_TYPE(QQuickBasePositioner)
|
||||||
QML_DECLARE_TYPEINFO(QQuickBasePositioner, QML_HAS_ATTACHED_PROPERTIES)
|
QML_DECLARE_TYPEINFO(QQuickBasePositioner, QML_HAS_ATTACHED_PROPERTIES)
|
||||||
|
|
|
@ -89,14 +89,10 @@ public:
|
||||||
QLazilyAllocated<ExtraData> extra;
|
QLazilyAllocated<ExtraData> extra;
|
||||||
|
|
||||||
QQuickBasePositionerPrivate()
|
QQuickBasePositionerPrivate()
|
||||||
: spacing(0)
|
: spacing(0), type(QQuickBasePositioner::None)
|
||||||
, type(QQuickBasePositioner::None)
|
, transitioner(0), positioningDirty(false)
|
||||||
, transitioner(0)
|
, doingPositioning(false), anchorConflict(false), layoutDirection(Qt::LeftToRight)
|
||||||
, positioningDirty(false)
|
|
||||||
, doingPositioning(false)
|
|
||||||
, anchorConflict(false)
|
|
||||||
, useImplicitSize(false)
|
|
||||||
, layoutDirection(Qt::LeftToRight)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +119,6 @@ public:
|
||||||
bool positioningDirty : 1;
|
bool positioningDirty : 1;
|
||||||
bool doingPositioning : 1;
|
bool doingPositioning : 1;
|
||||||
bool anchorConflict : 1;
|
bool anchorConflict : 1;
|
||||||
bool useImplicitSize : 1;
|
|
||||||
|
|
||||||
Qt::LayoutDirection layoutDirection;
|
Qt::LayoutDirection layoutDirection;
|
||||||
|
|
||||||
|
@ -179,34 +174,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void itemImplicitWidthChanged(QQuickItem *) override
|
|
||||||
{
|
|
||||||
Q_ASSERT(useImplicitSize);
|
|
||||||
setPositioningDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void itemImplicitHeightChanged(QQuickItem *) override
|
|
||||||
{
|
|
||||||
Q_ASSERT(useImplicitSize);
|
|
||||||
setPositioningDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal itemWidth(QQuickItem *item) const
|
|
||||||
{
|
|
||||||
if (Q_LIKELY(!useImplicitSize))
|
|
||||||
return item->width();
|
|
||||||
|
|
||||||
return item->implicitWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal itemHeight(QQuickItem *item) const
|
|
||||||
{
|
|
||||||
if (Q_LIKELY(!useImplicitSize))
|
|
||||||
return item->height();
|
|
||||||
|
|
||||||
return item->implicitHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; }
|
inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; }
|
||||||
void setTopPadding(qreal value, bool reset = false);
|
void setTopPadding(qreal value, bool reset = false);
|
||||||
void setLeftPadding(qreal value, bool reset = false);
|
void setLeftPadding(qreal value, bool reset = false);
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
import QtQuick 2.9
|
|
||||||
import PositionerTest 1.0
|
|
||||||
|
|
||||||
ImplicitGrid {
|
|
||||||
columns: 2
|
|
||||||
rows: 1
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: "Text"
|
|
||||||
width: parent.width
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
import QtQuick 2.9
|
|
||||||
import PositionerTest 1.0
|
|
||||||
|
|
||||||
ImplicitRow {
|
|
||||||
Text {
|
|
||||||
text: "Text"
|
|
||||||
width: parent.width
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -98,8 +98,6 @@ private slots:
|
||||||
void test_attachedproperties();
|
void test_attachedproperties();
|
||||||
void test_attachedproperties_data();
|
void test_attachedproperties_data();
|
||||||
void test_attachedproperties_dynamic();
|
void test_attachedproperties_dynamic();
|
||||||
void test_useImplicitSize_oneItem_data();
|
|
||||||
void test_useImplicitSize_oneItem();
|
|
||||||
|
|
||||||
void populateTransitions_row();
|
void populateTransitions_row();
|
||||||
void populateTransitions_row_data();
|
void populateTransitions_row_data();
|
||||||
|
@ -306,8 +304,6 @@ void tst_qquickpositioners::moveTransitions_flow_data()
|
||||||
|
|
||||||
tst_qquickpositioners::tst_qquickpositioners()
|
tst_qquickpositioners::tst_qquickpositioners()
|
||||||
{
|
{
|
||||||
qmlRegisterType<QQuickImplicitRow>("PositionerTest", 1, 0, "ImplicitRow");
|
|
||||||
qmlRegisterType<QQuickImplicitGrid>("PositionerTest", 1, 0, "ImplicitGrid");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_qquickpositioners::test_horizontal()
|
void tst_qquickpositioners::test_horizontal()
|
||||||
|
@ -4008,46 +4004,6 @@ void tst_qquickpositioners::test_attachedproperties_dynamic()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_qquickpositioners::test_useImplicitSize_oneItem_data()
|
|
||||||
{
|
|
||||||
QTest::addColumn<QString>("positionerType");
|
|
||||||
|
|
||||||
QTest::newRow("Grid") << "Grid";
|
|
||||||
QTest::newRow("Row") << "Row";
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_qquickpositioners::test_useImplicitSize_oneItem()
|
|
||||||
{
|
|
||||||
QFETCH(QString, positionerType);
|
|
||||||
|
|
||||||
QQuickView view;
|
|
||||||
view.setSource(testFileUrl(QString::fromLatin1("implicit%1OneItem.qml").arg(positionerType)));
|
|
||||||
QCOMPARE(view.status(), QQuickView::Ready);
|
|
||||||
view.show();
|
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&view));
|
|
||||||
|
|
||||||
QQuickItem *positioner = view.rootObject();
|
|
||||||
QVERIFY(positioner);
|
|
||||||
const qreal oldPositionerImplicitWidth = positioner->implicitWidth();
|
|
||||||
|
|
||||||
QQuickText *text = qobject_cast<QQuickText*>(positioner->childItems().first());
|
|
||||||
QVERIFY(text);
|
|
||||||
const qreal oldTextImplicitWidth = text->implicitWidth();
|
|
||||||
QCOMPARE(positioner->implicitWidth(), text->implicitWidth());
|
|
||||||
|
|
||||||
// Ensure that the implicit size of the positioner changes when the implicit size
|
|
||||||
// of one of its children changes.
|
|
||||||
text->setText(QLatin1String("Even More Text"));
|
|
||||||
const qreal textImplicitWidthIncrease = text->implicitWidth() - oldTextImplicitWidth;
|
|
||||||
QVERIFY(textImplicitWidthIncrease > 0);
|
|
||||||
QTRY_COMPARE(positioner->implicitWidth(), oldPositionerImplicitWidth + textImplicitWidthIncrease);
|
|
||||||
|
|
||||||
// Ensure that the implicit size of the positioner does not change when the
|
|
||||||
// explicit size of one of its children changes.
|
|
||||||
text->setWidth(10);
|
|
||||||
QTRY_COMPARE(positioner->implicitWidth(), oldPositionerImplicitWidth + textImplicitWidthIncrease);
|
|
||||||
}
|
|
||||||
|
|
||||||
QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
|
QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
|
||||||
{
|
{
|
||||||
QQuickView *window = new QQuickView(0);
|
QQuickView *window = new QQuickView(0);
|
||||||
|
|
Loading…
Reference in New Issue