summaryrefslogtreecommitdiff
path: root/src/declarative/graphicsitems/qdeclarativepositioners.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativepositioners.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp120
1 files changed, 89 insertions, 31 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 27a1301b6c..84dcec6097 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -578,12 +578,14 @@ void QDeclarativeColumn::reportConflictingAnchors()
\sa Grid::spacing
*/
QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent)
-: QDeclarativeBasePositioner(Horizontal, parent), m_layoutDirection(Qt::LeftToRight)
+: QDeclarativeBasePositioner(Horizontal, parent)
{
}
/*!
\qmlproperty enumeration Row::layoutDirection
+ \since Quick 1.1
+
This property holds the layoutDirection of the row.
Possible values:
@@ -599,20 +601,39 @@ QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent)
*/
Qt::LayoutDirection QDeclarativeRow::layoutDirection() const
{
- return m_layoutDirection;
+ return QDeclarativeBasePositionerPrivate::getLayoutDirection(this);
}
void QDeclarativeRow::setLayoutDirection(Qt::LayoutDirection layoutDirection)
{
- if (m_layoutDirection != layoutDirection) {
- m_layoutDirection = layoutDirection;
+ QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate* >(QDeclarativeBasePositionerPrivate::get(this));
+ if (d->layoutDirection != layoutDirection) {
+ d->layoutDirection = layoutDirection;
prePositioning();
emit layoutDirectionChanged();
+ emit effectiveLayoutDirectionChanged();
}
}
+/*!
+ \qmlproperty enumeration Row::effectiveLayoutDirection
+ This property holds the effective layout direction of the row positioner.
+
+ When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts,
+ the visual layout direction of the row positioner will be mirrored. However, the
+ property \l {Row::layoutDirection}{layoutDirection} will remain unchanged.
+
+ \sa Row::layoutDirection, {LayoutMirroring}{LayoutMirroring}
+*/
+
+Qt::LayoutDirection QDeclarativeRow::effectiveLayoutDirection() const
+{
+ return QDeclarativeBasePositionerPrivate::getEffectiveLayoutDirection(this);
+}
+
void QDeclarativeRow::doPositioning(QSizeF *contentSize)
{
+ QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
int hoffset = 0;
QList<int> hoffsets;
@@ -621,7 +642,7 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize)
if (!child.item || !child.isVisible)
continue;
- if(m_layoutDirection == Qt::LeftToRight){
+ if(d->isLeftToRight()){
if(child.item->x() != hoffset)
positionX(hoffset, child);
}else{
@@ -636,7 +657,7 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize)
contentSize->setWidth(hoffset - spacing());
- if(m_layoutDirection == Qt::LeftToRight)
+ if(d->isLeftToRight())
return;
//Right to Left layout
@@ -790,7 +811,7 @@ void QDeclarativeRow::reportConflictingAnchors()
\sa rows, columns
*/
QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) :
- QDeclarativeBasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight), m_layoutDirection(Qt::LeftToRight)
+ QDeclarativeBasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight)
{
}
@@ -859,16 +880,18 @@ void QDeclarativeGrid::setFlow(Flow flow)
/*!
\qmlproperty enumeration Grid::layoutDirection
+ \since Quick 1.1
+
This property holds the layout direction of the layout.
Possible values are:
\list
- \o Qt.LeftToRight (default) - Items are positioned beginning
- from the top, left anchor. The flow direction is dependent
- on the \l Grid::flow property.
- \o Qt.RightToLeft - Items are positioned beginning from the
- top, right anchor. The flow direction is dependent on the
+ \o Qt.LeftToRight (default) - Items are positioned from the top to bottom,
+ and left to right. The flow direction is dependent on the
+ \l Grid::flow property.
+ \o Qt.RightToLeft - Items are positioned from the top to bottom,
+ and right to left. The flow direction is dependent on the
\l Grid::flow property.
\endlist
@@ -876,21 +899,39 @@ void QDeclarativeGrid::setFlow(Flow flow)
*/
Qt::LayoutDirection QDeclarativeGrid::layoutDirection() const
{
- return m_layoutDirection;
+ return QDeclarativeBasePositionerPrivate::getLayoutDirection(this);
}
void QDeclarativeGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection)
{
- if (m_layoutDirection != layoutDirection) {
- m_layoutDirection = layoutDirection;
+ QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
+ if (d->layoutDirection != layoutDirection) {
+ d->layoutDirection = layoutDirection;
prePositioning();
emit layoutDirectionChanged();
+ emit effectiveLayoutDirectionChanged();
}
}
-void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
+/*!
+ \qmlproperty enumeration Grid::effectiveLayoutDirection
+ This property holds the effective layout direction of the grid positioner.
+
+ When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts,
+ the visual layout direction of the grid positioner will be mirrored. However, the
+ property \l {Grid::layoutDirection}{layoutDirection} will remain unchanged.
+
+ \sa Grid::layoutDirection, {LayoutMirroring}{LayoutMirroring}
+*/
+
+Qt::LayoutDirection QDeclarativeGrid::effectiveLayoutDirection() const
{
+ return QDeclarativeBasePositionerPrivate::getEffectiveLayoutDirection(this);
+}
+void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
+{
+ QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
int c = m_columns;
int r = m_rows;
//Is allocating the extra QPODVector too much overhead?
@@ -980,7 +1021,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
end = widthSum;
int xoffset=0;
- if(m_layoutDirection == Qt::RightToLeft)
+ if(!d->isLeftToRight())
xoffset=end;
int yoffset=0;
int curRow =0;
@@ -988,7 +1029,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
for (int i = 0; i < visibleItems.count(); ++i) {
const PositionedItem &child = visibleItems.at(i);
int childXOffset = xoffset;
- if(m_layoutDirection == Qt::RightToLeft)
+ if(!d->isLeftToRight())
childXOffset -= QGraphicsItemPrivate::get(child.item)->width();
if((child.item->x()!=childXOffset)||(child.item->y()!=yoffset)){
positionX(childXOffset, child);
@@ -996,7 +1037,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
}
if (m_flow == LeftToRight) {
- if(m_layoutDirection == Qt::LeftToRight)
+ if(d->isLeftToRight())
xoffset+=maxColWidth[curCol]+spacing();
else
xoffset-=maxColWidth[curCol]+spacing();
@@ -1004,7 +1045,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
curCol%=c;
if (!curCol){
yoffset+=maxRowHeight[curRow]+spacing();
- if(m_layoutDirection == Qt::LeftToRight)
+ if(d->isLeftToRight())
xoffset=0;
else
xoffset=end;
@@ -1017,7 +1058,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
curRow++;
curRow%=r;
if (!curRow){
- if(m_layoutDirection == Qt::LeftToRight)
+ if(d->isLeftToRight())
xoffset+=maxColWidth[curCol]+spacing();
else
xoffset-=maxColWidth[curCol]+spacing();
@@ -1152,12 +1193,10 @@ class QDeclarativeFlowPrivate : public QDeclarativeBasePositionerPrivate
public:
QDeclarativeFlowPrivate()
- : QDeclarativeBasePositionerPrivate(), flow(QDeclarativeFlow::LeftToRight),
- layoutDirection(Qt::LeftToRight)
+ : QDeclarativeBasePositionerPrivate(), flow(QDeclarativeFlow::LeftToRight)
{}
QDeclarativeFlow::Flow flow;
- Qt::LayoutDirection layoutDirection;
};
QDeclarativeFlow::QDeclarativeFlow(QDeclarativeItem *parent)
@@ -1201,16 +1240,18 @@ void QDeclarativeFlow::setFlow(Flow flow)
/*!
\qmlproperty enumeration Flow::layoutDirection
+ \since Quick 1.1
+
This property holds the layout direction of the layout.
Possible values are:
\list
- \o Qt.LeftToRight (default) - Items are positioned beginning
- from the top, left anchor. The flow direction is dependent
- on the \l Flow::flow property.
- \o Qt.RightToLeft - Items are positioned beginning from the
- top, right anchor. The flow direction is dependent on the
+ \o Qt.LeftToRight (default) - Items are positioned from the top to bottom,
+ and left to right. The flow direction is dependent on the
+ \l Flow::flow property.
+ \o Qt.RightToLeft - Items are positioned from the top to bottom,
+ and right to left. The flow direction is dependent on the
\l Flow::flow property.
\endlist
@@ -1230,9 +1271,26 @@ void QDeclarativeFlow::setLayoutDirection(Qt::LayoutDirection layoutDirection)
d->layoutDirection = layoutDirection;
prePositioning();
emit layoutDirectionChanged();
+ emit effectiveLayoutDirectionChanged();
}
}
+/*!
+ \qmlproperty enumeration Flow::effectiveLayoutDirection
+ This property holds the effective layout direction of the flow positioner.
+
+ When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts,
+ the visual layout direction of the grid positioner will be mirrored. However, the
+ property \l {Flow::layoutDirection}{layoutDirection} will remain unchanged.
+
+ \sa Flow::layoutDirection, {LayoutMirroring}{LayoutMirroring}
+*/
+
+Qt::LayoutDirection QDeclarativeFlow::effectiveLayoutDirection() const
+{
+ return QDeclarativeBasePositionerPrivate::getEffectiveLayoutDirection(this);
+}
+
void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
{
Q_D(QDeclarativeFlow);
@@ -1262,7 +1320,7 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
}
}
- if(d->layoutDirection == Qt::LeftToRight){
+ if(d->isLeftToRight()){
if(child.item->x() != hoffset)
positionX(hoffset, child);
}else{
@@ -1285,7 +1343,7 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
}
}
- if(d->layoutDirection == Qt::LeftToRight)
+ if(d->isLeftToRight())
return;
int end;