From e65835789c8022d7105f05679a64fd468c5b44d2 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 24 Apr 2013 13:26:51 +0200 Subject: 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 ++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'src/quick/util/qquickpath.cpp') diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 3aea724983..49b9e4c4e3 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 -- cgit v1.2.3