diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2013-11-28 11:18:45 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-03 21:32:22 +0100 |
commit | 423ee63b7be093abd047e0a35d02ecf371e92b3a (patch) | |
tree | 811b25fd3c63911dbac64c95526d3b4959053757 /src/widgets/graphicsview | |
parent | ae8948a0a9ed94962604918c32757518f562b271 (diff) |
Make the default vertical alignment configurable
This is a prerequisite of sharing the layout engine of QGraphicsLayout
with the engine of QtQuick.Layouts.
Change-Id: Iae566c0e51d234b836cf818b541d4284bd78bbee
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r-- | src/widgets/graphicsview/qgridlayoutengine.cpp | 5 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgridlayoutengine_p.h | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/widgets/graphicsview/qgridlayoutengine.cpp b/src/widgets/graphicsview/qgridlayoutengine.cpp index a1affdb55e..bac8d52c9a 100644 --- a/src/widgets/graphicsview/qgridlayoutengine.cpp +++ b/src/widgets/graphicsview/qgridlayoutengine.cpp @@ -800,9 +800,10 @@ void QGridLayoutRowInfo::dump(int indent) const } #endif -QGridLayoutEngine::QGridLayoutEngine() +QGridLayoutEngine::QGridLayoutEngine(Qt::Alignment defaultAlignment) { m_visualDirection = Qt::LeftToRight; + m_defaultAlignment = defaultAlignment; invalidate(); } @@ -990,6 +991,8 @@ Qt::Alignment QGridLayoutEngine::effectiveAlignment(const QGridLayoutItem *layou // no vertical alignment, respect the row alignment int y = layoutItem->firstRow(); align |= (rowAlignment(y, Qt::Vertical) & Qt::AlignVertical_Mask); + if (!(align & Qt::AlignVertical_Mask)) + align |= (m_defaultAlignment & Qt::AlignVertical_Mask); } if (!(align & Qt::AlignHorizontal_Mask)) { // no horizontal alignment, respect the column alignment diff --git a/src/widgets/graphicsview/qgridlayoutengine_p.h b/src/widgets/graphicsview/qgridlayoutengine_p.h index fbc5bd6ad2..309b58b3d9 100644 --- a/src/widgets/graphicsview/qgridlayoutengine_p.h +++ b/src/widgets/graphicsview/qgridlayoutengine_p.h @@ -331,7 +331,7 @@ public: class QGridLayoutEngine { public: - QGridLayoutEngine(); + QGridLayoutEngine(Qt::Alignment defaultAlignment = Qt::Alignment(0)); inline ~QGridLayoutEngine() { qDeleteAll(q_items); } int rowCount(Qt::Orientation orientation) const; @@ -430,6 +430,7 @@ private: QLayoutParameter<qreal> q_defaultSpacings[NOrientations]; QGridLayoutRowInfo q_infos[NOrientations]; Qt::LayoutDirection m_visualDirection; + Qt::Alignment m_defaultAlignment; // Lazily computed from the above user input mutable int q_cachedEffectiveFirstRows[NOrientations]; |