From: Marco Bubke Date: Wed, 24 Apr 2013 11:52:10 +0000 (+0200) Subject: Refactor the pathElements property in QQuickPath X-Git-Tag: upstream/5.2.1~798^2~131 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c683dd625421f33a5456c3bdd457c6e4072a64d;p=platform%2Fupstream%2Fqtdeclarative.git Refactor the pathElements property in QQuickPath A prequel to make QQuickPath pathElements designer ready. Change-Id: I1f3e30c699c958c827fdecfb57c35f5c24cd810a Reviewed-by: Alan Alpert --- 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();