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-09-21 10:25:26 +0000 |
commit | 59f7b30d41b06b1d9da81aea5784d57ecd91ab04 (patch) | |
tree | 58b85593043000e7b2d0b2f62fbf713ce26a93c3 | |
parent | 655a8fbe51dc57d505acfa23cb0f27b67dd6ec05 (diff) | |
download | qtquickcontrols-59f7b30d41b06b1d9da81aea5784d57ecd91ab04.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.
Change-Id: I3f78c4463a815862139f43ef685c38b40139001c
Task-number: QTBUG-45152
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/layouts/qquicklayout.cpp | 13 | ||||
-rw-r--r-- | src/layouts/qquicklayout_p.h | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/layouts/qquicklayout.cpp b/src/layouts/qquicklayout.cpp index d812c112..559f8ff2 100644 --- a/src/layouts/qquicklayout.cpp +++ b/src/layouts/qquicklayout.cpp @@ -750,6 +750,11 @@ bool QQuickLayout::shouldIgnoreItem(QQuickItem *child, QQuickLayoutAttached *&in d->m_ignoredItems << child; return ignoreItem; } +struct QQuickItemPublic : public QQuickItem { + static bool isCompleted(QQuickItem *item) { + return static_cast<QQuickItemPublic*>(item)->isComponentComplete(); + } +}; void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value) { @@ -758,6 +763,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) { @@ -765,6 +771,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(); } @@ -796,6 +803,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; |