aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickpositioners.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquickpositioners.cpp')
-rw-r--r--src/quick/items/qquickpositioners.cpp106
1 files changed, 62 insertions, 44 deletions
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index 4a74c0bfba..b07a38cdaf 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -452,7 +452,6 @@ void QQuickBasePositioner::updateAttachedProperties(QQuickPositionerAttached *sp
QQuickPositionerAttached *prevLastProperty = 0;
QQuickPositionerAttached *lastProperty = 0;
- int visibleItemIndex = 0;
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
if (!child.item)
@@ -468,28 +467,47 @@ void QQuickBasePositioner::updateAttachedProperties(QQuickPositionerAttached *sp
property = static_cast<QQuickPositionerAttached *>(qmlAttachedPropertiesObject<QQuickBasePositioner>(child.item, false));
}
- if (child.isVisible) {
- if (property) {
- property->setIndex(visibleItemIndex);
- property->setIsFirstItem(visibleItemIndex == 0);
+ if (property) {
+ property->setIndex(ii);
+ property->setIsFirstItem(ii == 0);
- if (property->isLastItem())
+ if (property->isLastItem()) {
+ if (prevLastProperty)
+ prevLastProperty->setIsLastItem(false); // there can be only one last property
prevLastProperty = property;
}
-
- lastProperty = property;
- ++visibleItemIndex;
- } else if (property) {
- property->setIndex(-1);
- property->setIsFirstItem(false);
- property->setIsLastItem(false);
}
+
+ lastProperty = property;
}
if (prevLastProperty && prevLastProperty != lastProperty)
prevLastProperty->setIsLastItem(false);
if (lastProperty)
lastProperty->setIsLastItem(true);
+
+ // clear attached properties for unpositioned items
+ for (int ii = 0; ii < unpositionedItems.count(); ++ii) {
+ const PositionedItem &child = unpositionedItems.at(ii);
+ if (!child.item)
+ continue;
+
+ QQuickPositionerAttached *property = 0;
+
+ if (specificProperty) {
+ if (specificPropertyOwner == child.item) {
+ property = specificProperty;
+ }
+ } else {
+ property = static_cast<QQuickPositionerAttached *>(qmlAttachedPropertiesObject<QQuickBasePositioner>(child.item, false));
+ }
+
+ if (property) {
+ property->setIndex(-1);
+ property->setIsFirstItem(false);
+ property->setIsLastItem(false);
+ }
+ }
}
/*!
@@ -608,7 +626,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
more information about its position within the Column.
For more information on using Column and other related positioner-types, see
- \l{Item Layouts}.
+ \l{Item Positioners}.
\section1 Using Transitions
@@ -626,7 +644,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
\image verticalpositioner_transition.gif
- \sa Row, Grid, Flow, Positioner, {qml/positioners}{Positioners example}
+ \sa Row, Grid, Flow, Positioner, ColumnLayout, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Column::populate
@@ -639,7 +657,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
the item that is being added. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \sa add, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa add, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Column::add
@@ -661,7 +679,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
\note This transition is not applied to the items that already part of the positioner
at the time of its creation. In this case, the \l populate transition is applied instead.
- \sa populate, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa populate, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Column::move
@@ -682,11 +700,11 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
cases, these lists will be empty. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note In QtQuick 1, this transition was applied to all items that were part of the
- positioner at the time of its creation. From QtQuick 2 onwards, positioners apply the
+ \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the
+ positioner at the time of its creation. From \l {Qt Quick}{Qt Quick 2} onwards, positioners apply the
\l populate transition to these items instead.
- \sa add, ViewTransition, {qml/positioners}{Positioners example}
+ \sa add, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty real QtQuick2::Column::spacing
@@ -777,10 +795,10 @@ void QQuickColumn::reportConflictingAnchors()
more information about its position within the Row.
For more information on using Row and other related positioner-types, see
- \l{Item Layouts}.
+ \l{Item Positioners}.
- \sa Column, Grid, Flow, Positioner, {qml/positioners}{Positioners example}
+ \sa Column, Grid, Flow, Positioner, RowLayout, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Row::populate
@@ -793,7 +811,7 @@ void QQuickColumn::reportConflictingAnchors()
the item that is being added. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \sa add, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa add, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Row::add
@@ -815,7 +833,7 @@ void QQuickColumn::reportConflictingAnchors()
\note This transition is not applied to the items that already part of the positioner
at the time of its creation. In this case, the \l populate transition is applied instead.
- \sa populate, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa populate, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Row::move
@@ -836,11 +854,11 @@ void QQuickColumn::reportConflictingAnchors()
cases, these lists will be empty. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note In QtQuick 1, this transition was applied to all items that were part of the
- positioner at the time of its creation. From QtQuick 2 onwards, positioners apply the
+ \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the
+ positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the
\l populate transition to these items instead.
- \sa add, ViewTransition, {qml/positioners}{Positioners example}
+ \sa add, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty real QtQuick2::Row::spacing
@@ -869,7 +887,7 @@ QQuickRow::QQuickRow(QQuickItem *parent)
the right anchor remains to the right of the row.
\endlist
- \sa Grid::layoutDirection, Flow::layoutDirection, {qml/righttoleft/layoutdirection}{Layout directions example}
+ \sa Grid::layoutDirection, Flow::layoutDirection, {Qt Quick Examples - Right to Left}
*/
Qt::LayoutDirection QQuickRow::layoutDirection() const
@@ -1010,10 +1028,10 @@ void QQuickRow::reportConflictingAnchors()
or anchor itself with any of the \l {Item::anchors}{anchor} properties.
For more information on using Grid and other related positioner-types, see
- \l{Item Layouts}.
+ \l{Item Positioners}.
- \sa Flow, Row, Column, Positioner, {qml/positioners}{Positioners example}
+ \sa Flow, Row, Column, Positioner, GridLayout, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Grid::populate
@@ -1026,7 +1044,7 @@ void QQuickRow::reportConflictingAnchors()
the item that is being added. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \sa add, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa add, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Grid::add
@@ -1048,7 +1066,7 @@ void QQuickRow::reportConflictingAnchors()
\note This transition is not applied to the items that already part of the positioner
at the time of its creation. In this case, the \l populate transition is applied instead.
- \sa populate, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa populate, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Grid::move
@@ -1069,11 +1087,11 @@ void QQuickRow::reportConflictingAnchors()
cases, these lists will be empty. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note In QtQuick 1, this transition was applied to all items that were part of the
- positioner at the time of its creation. From QtQuick 2 onwards, positioners apply the
+ \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the
+ positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the
\l populate transition to these items instead.
- \sa add, ViewTransition, {qml/positioners}{Positioners example}
+ \sa add, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty qreal QtQuick2::Grid::spacing
@@ -1230,7 +1248,7 @@ void QQuickGrid::setColumnSpacing(const qreal columnSpacing)
\l Grid::flow property.
\endlist
- \sa Flow::layoutDirection, Row::layoutDirection, {qml/righttoleft/layoutdirection}{Layout directions example}
+ \sa Flow::layoutDirection, Row::layoutDirection, {Qt Quick Examples - Right to Left}
*/
Qt::LayoutDirection QQuickGrid::layoutDirection() const
{
@@ -1552,9 +1570,9 @@ void QQuickGrid::reportConflictingAnchors()
or anchor itself with any of the \l {Item::anchors}{anchor} properties.
For more information on using Flow and other related positioner-types, see
- \l{Item Layouts}.
+ \l{Item Positioners}.
- \sa Column, Row, Grid, Positioner, {qml/positioners}{Positioners example}
+ \sa Column, Row, Grid, Positioner, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Flow::populate
@@ -1567,7 +1585,7 @@ void QQuickGrid::reportConflictingAnchors()
the item that is being added. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \sa add, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa add, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Flow::add
@@ -1589,7 +1607,7 @@ void QQuickGrid::reportConflictingAnchors()
\note This transition is not applied to the items that already part of the positioner
at the time of its creation. In this case, the \l populate transition is applied instead.
- \sa populate, ViewTransition, {declarative/positioners}{Positioners example}
+ \sa populate, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty Transition QtQuick2::Flow::move
@@ -1610,11 +1628,11 @@ void QQuickGrid::reportConflictingAnchors()
cases, these lists will be empty. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note In QtQuick 1, this transition was applied to all items that were part of the
- positioner at the time of its creation. From QtQuick 2 onwards, positioners apply the
+ \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the
+ positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the
\l populate transition to these items instead.
- \sa add, ViewTransition, {qml/positioners}{Positioners example}
+ \sa add, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty real QtQuick2::Flow::spacing
@@ -1692,7 +1710,7 @@ void QQuickFlow::setFlow(Flow flow)
\l Flow::flow property.
\endlist
- \sa Grid::layoutDirection, Row::layoutDirection, {qml/righttoleft/layoutdirection}{Layout directions example}
+ \sa Grid::layoutDirection, Row::layoutDirection, {Qt Quick Examples - Right to Left}
*/
Qt::LayoutDirection QQuickFlow::layoutDirection() const