From 7c683dd625421f33a5456c3bdd457c6e4072a64d Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 24 Apr 2013 13:52:10 +0200 Subject: [PATCH] Refactor the pathElements property in QQuickPath A prequel to make QQuickPath pathElements designer ready. Change-Id: I1f3e30c699c958c827fdecfb57c35f5c24cd810a Reviewed-by: Alan Alpert --- src/quick/util/qquickpath.cpp | 43 +++++++++++++++++++++++++++++++++++++++- src/quick/util/qquickpath_p.h | 6 +++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 49b9e4c..0b0c330 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -188,8 +188,47 @@ bool QQuickPath::hasEnd() const QQmlListProperty QQuickPath::pathElements() { - Q_D(QQuickPath); - return QQmlListProperty(this, d->_pathElements); + return QQmlListProperty(this, + 0, + pathElements_append, + pathElements_count, + pathElements_at, + pathElements_clear); +} + +static QQuickPathPrivate *privatePath(QObject *object) +{ + QQuickPath *path = static_cast(object); + + return QQuickPathPrivate::get(path); +} + +QQuickPathElement *QQuickPath::pathElements_at(QQmlListProperty *property, int index) +{ + QQuickPathPrivate *d = privatePath(property->object); + + return d->_pathElements.at(index); +} + +void QQuickPath::pathElements_append(QQmlListProperty *property, QQuickPathElement *pathElement) +{ + QQuickPathPrivate *d = privatePath(property->object); + + d->_pathElements.append(pathElement); +} + +int QQuickPath::pathElements_count(QQmlListProperty *property) +{ + QQuickPathPrivate *d = privatePath(property->object); + + return d->_pathElements.count(); +} + +void QQuickPath::pathElements_clear(QQmlListProperty *property) +{ + QQuickPathPrivate *d = privatePath(property->object); + + d->_pathElements.clear(); } void QQuickPath::interpolate(int idx, const QString &name, qreal value) diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index cbb8566..1a9be7c 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -397,6 +397,12 @@ protected: void connectPathElements(); void gatherAttributes(); + // pathElements property + static QQuickPathElement *pathElements_at(QQmlListProperty *, int); + static void pathElements_append(QQmlListProperty *, QQuickPathElement *); + static int pathElements_count(QQmlListProperty *); + static void pathElements_clear(QQmlListProperty *); + private Q_SLOTS: void processPath(); -- 1.7.2.5