From e65835789c8022d7105f05679a64fd468c5b44d2 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 24 Apr 2013 13:26:51 +0200 Subject: [PATCH] Refactor QQuickPath componentComplete It is a prequel for the refactoring of the pathElements property. Change-Id: I56cc4b9b419fecf96e331a6cab58b33157742e70 Reviewed-by: Thomas Hartmann Reviewed-by: Aurindam Jana Reviewed-by: Alan Alpert --- src/quick/util/qquickpath.cpp | 44 ++++++++++++++++++++++++++++++----------- src/quick/util/qquickpath_p.h | 3 +++ src/quick/util/qquickpath_p_p.h | 3 +++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 3aea724..49b9e4c 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -373,27 +373,49 @@ void QQuickPath::classBegin() d->componentComplete = false; } -void QQuickPath::componentComplete() +void QQuickPath::disconnectPathElements() +{ + Q_D(QQuickPath); + + foreach (QQuickPathElement *pathElement, d->_pathElements) + disconnect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); +} + +void QQuickPath::connectPathElements() +{ + Q_D(QQuickPath); + + foreach (QQuickPathElement *pathElement, d->_pathElements) + connect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); +} + +void QQuickPath::gatherAttributes() { Q_D(QQuickPath); - QSet attrs; - d->componentComplete = true; + + QSet attributes; // First gather up all the attributes foreach (QQuickPathElement *pathElement, d->_pathElements) { - if (QQuickCurve *curve = - qobject_cast(pathElement)) + if (QQuickCurve *curve = qobject_cast(pathElement)) d->_pathCurves.append(curve); - else if (QQuickPathAttribute *attribute = - qobject_cast(pathElement)) - attrs.insert(attribute->name()); + else if (QQuickPathAttribute *attribute = qobject_cast(pathElement)) + attributes.insert(attribute->name()); } - d->_attributes = attrs.toList(); + + d->_attributes = attributes.toList(); +} + +void QQuickPath::componentComplete() +{ + Q_D(QQuickPath); + d->componentComplete = true; + + gatherAttributes(); processPath(); - foreach (QQuickPathElement *pathElement, d->_pathElements) - connect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); + connectPathElements(); } QPainterPath QQuickPath::path() const diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index 7154585..cbb8566 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -393,6 +393,9 @@ Q_SIGNALS: protected: virtual void componentComplete(); virtual void classBegin(); + void disconnectPathElements(); + void connectPathElements(); + void gatherAttributes(); private Q_SLOTS: void processPath(); diff --git a/src/quick/util/qquickpath_p_p.h b/src/quick/util/qquickpath_p_p.h index b4227e6..e376925 100644 --- a/src/quick/util/qquickpath_p_p.h +++ b/src/quick/util/qquickpath_p_p.h @@ -67,6 +67,9 @@ class QQuickPathPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickPath) public: + static QQuickPathPrivate* get(QQuickPath *path) { return path->d_func(); } + static const QQuickPathPrivate* get(const QQuickPath *path) { return path->d_func(); } + QQuickPathPrivate() : pathLength(0), closed(false), componentComplete(true) { } QPainterPath _path; -- 2.7.4