Make pathElements designer ready
authorMarco Bubke <marco.bubke@digia.com>
Wed, 24 Apr 2013 12:01:20 +0000 (14:01 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 24 Apr 2013 19:36:01 +0000 (21:36 +0200)
The append and clear case was not handled before but the designer is
changing the pathElements.

Change-Id: I373e26a7c597774c3e985a8c26a564700e9ee9de
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
src/quick/util/qquickpath.cpp

index 0b0c330..fc33f8f 100644 (file)
@@ -213,8 +213,24 @@ QQuickPathElement *QQuickPath::pathElements_at(QQmlListProperty<QQuickPathElemen
 void QQuickPath::pathElements_append(QQmlListProperty<QQuickPathElement> *property, QQuickPathElement *pathElement)
 {
     QQuickPathPrivate *d = privatePath(property->object);
+    QQuickPath *path = static_cast<QQuickPath*>(property->object);
 
     d->_pathElements.append(pathElement);
+
+    if (d->componentComplete) {
+        QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement);
+        if (curve)
+            d->_pathCurves.append(curve);
+        else {
+            QQuickPathAttribute *attribute = qobject_cast<QQuickPathAttribute *>(pathElement);
+            if (attribute && !d->_attributes.contains(attribute->name()))
+                d->_attributes.append(attribute->name());
+        }
+
+        path->processPath();
+
+        connect(pathElement, SIGNAL(changed()), path, SLOT(processPath()));
+    }
 }
 
 int QQuickPath::pathElements_count(QQmlListProperty<QQuickPathElement> *property)
@@ -227,8 +243,12 @@ int QQuickPath::pathElements_count(QQmlListProperty<QQuickPathElement> *property
 void QQuickPath::pathElements_clear(QQmlListProperty<QQuickPathElement> *property)
 {
     QQuickPathPrivate *d = privatePath(property->object);
+    QQuickPath *path = static_cast<QQuickPath*>(property->object);
 
+    path->disconnectPathElements();
     d->_pathElements.clear();
+    d->_pathCurves.clear();
+    d->_pointCache.clear();
 }
 
 void QQuickPath::interpolate(int idx, const QString &name, qreal value)