diff options
author | Jan Arve Saether <jan-arve.saether@theqtcompany.com> | 2015-09-17 14:24:03 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@theqtcompany.com> | 2015-10-30 15:52:05 +0000 |
commit | 42c04ed29c36eec70cdce58e5c2d19faec62d039 (patch) | |
tree | 94ddaa381efb5b117fd40d01d16b8457e4dd8506 /src/layouts | |
parent | afbf1fcb251c1f751758f62317f1cd9795b79310 (diff) | |
download | qtquickcontrols-42c04ed29c36eec70cdce58e5c2d19faec62d039.tar.gz |
Fix {Row|Grid}Layout to adhere to sibling order of its children
In order to reduce the number of temporary calls to updateLayoutItems,
I should postpone it until the item is completed.
This will be a separate patch.
This is a backport of change 59f7b30d41b06b1d9da81aea5784d57ecd91ab04
Change-Id: Iee495ee3d85a03407b06d06d8076c5c63d3d20cf
Task-number: QTBUG-45152
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
Diffstat (limited to 'src/layouts')
-rw-r--r-- | src/layouts/qquicklayout.cpp | 8 | ||||
-rw-r--r-- | src/layouts/qquicklayout_p.h | 7 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/layouts/qquicklayout.cpp b/src/layouts/qquicklayout.cpp index ddf44b7b..f28a7d07 100644 --- a/src/layouts/qquicklayout.cpp +++ b/src/layouts/qquicklayout.cpp @@ -759,6 +759,7 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value) QObject::connect(item, SIGNAL(implicitWidthChanged()), this, SLOT(invalidateSenderItem())); QObject::connect(item, SIGNAL(implicitHeightChanged()), this, SLOT(invalidateSenderItem())); QObject::connect(item, SIGNAL(baselineOffsetChanged(qreal)), this, SLOT(invalidateSenderItem())); + QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder); if (isReady()) updateLayoutItems(); } else if (change == ItemChildRemovedChange) { @@ -766,6 +767,7 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value) QObject::disconnect(item, SIGNAL(implicitWidthChanged()), this, SLOT(invalidateSenderItem())); QObject::disconnect(item, SIGNAL(implicitHeightChanged()), this, SLOT(invalidateSenderItem())); QObject::disconnect(item, SIGNAL(baselineOffsetChanged(qreal)), this, SLOT(invalidateSenderItem())); + QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder); if (isReady()) updateLayoutItems(); } @@ -797,6 +799,12 @@ bool QQuickLayout::isReady() const return d_func()->m_isReady; } +void QQuickLayout::itemSiblingOrderChanged(QQuickItem *item) +{ + Q_UNUSED(item); + updateLayoutItems(); +} + void QQuickLayout::rearrange(const QSizeF &/*size*/) { m_dirty = false; diff --git a/src/layouts/qquicklayout_p.h b/src/layouts/qquicklayout_p.h index d613f5bd..4379d7f8 100644 --- a/src/layouts/qquicklayout_p.h +++ b/src/layouts/qquicklayout_p.h @@ -40,6 +40,7 @@ #include <QPointer> #include <QQuickItem> #include <private/qquickitem_p.h> +#include <QtQuick/private/qquickitemchangelistener_p.h> #include <QtGui/private/qlayoutpolicy_p.h> QT_BEGIN_NAMESPACE @@ -53,7 +54,8 @@ class QQuickLayoutAttached; #endif class QQuickLayoutPrivate; -class QQuickLayout : public QQuickItem +class QQuickLayout : public QQuickItem, public QQuickItemChangeListener + { Q_OBJECT public: @@ -92,6 +94,9 @@ public: bool isReady() const; + /* QQuickItemChangeListener */ + void itemSiblingOrderChanged(QQuickItem *item) Q_DECL_OVERRIDE; + protected: void updatePolish() Q_DECL_OVERRIDE; |