Refactor the pathElements property in QQuickPath
authorMarco Bubke <marco.bubke@digia.com>
Wed, 24 Apr 2013 11:52:10 +0000 (13:52 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 24 Apr 2013 19:36:01 +0000 (21:36 +0200)
A prequel to make QQuickPath pathElements designer ready.

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

index 49b9e4c..0b0c330 100644 (file)
@@ -188,8 +188,47 @@ bool QQuickPath::hasEnd() const
 
 QQmlListProperty<QQuickPathElement> QQuickPath::pathElements()
 {
-    Q_D(QQuickPath);
-    return QQmlListProperty<QQuickPathElement>(this, d->_pathElements);
+    return QQmlListProperty<QQuickPathElement>(this,
+                                               0,
+                                               pathElements_append,
+                                               pathElements_count,
+                                               pathElements_at,
+                                               pathElements_clear);
+}
+
+static QQuickPathPrivate *privatePath(QObject *object)
+{
+    QQuickPath *path = static_cast<QQuickPath*>(object);
+
+    return QQuickPathPrivate::get(path);
+}
+
+QQuickPathElement *QQuickPath::pathElements_at(QQmlListProperty<QQuickPathElement> *property, int index)
+{
+    QQuickPathPrivate *d = privatePath(property->object);
+
+    return d->_pathElements.at(index);
+}
+
+void QQuickPath::pathElements_append(QQmlListProperty<QQuickPathElement> *property, QQuickPathElement *pathElement)
+{
+    QQuickPathPrivate *d = privatePath(property->object);
+
+    d->_pathElements.append(pathElement);
+}
+
+int QQuickPath::pathElements_count(QQmlListProperty<QQuickPathElement> *property)
+{
+    QQuickPathPrivate *d = privatePath(property->object);
+
+    return d->_pathElements.count();
+}
+
+void QQuickPath::pathElements_clear(QQmlListProperty<QQuickPathElement> *property)
+{
+    QQuickPathPrivate *d = privatePath(property->object);
+
+    d->_pathElements.clear();
 }
 
 void QQuickPath::interpolate(int idx, const QString &name, qreal value)
index cbb8566..1a9be7c 100644 (file)
@@ -397,6 +397,12 @@ protected:
     void connectPathElements();
     void gatherAttributes();
 
+    // pathElements property
+    static QQuickPathElement *pathElements_at(QQmlListProperty<QQuickPathElement> *, int);
+    static void pathElements_append(QQmlListProperty<QQuickPathElement> *, QQuickPathElement *);
+    static int pathElements_count(QQmlListProperty<QQuickPathElement> *);
+    static void pathElements_clear(QQmlListProperty<QQuickPathElement> *);
+
 private Q_SLOTS:
     void processPath();