diff options
Diffstat (limited to 'src/quick/util')
-rw-r--r-- | src/quick/util/qquickanimation.cpp | 6 | ||||
-rw-r--r-- | src/quick/util/qquickbehavior.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquickimageprovider.cpp | 8 | ||||
-rw-r--r-- | src/quick/util/qquickpath.cpp | 109 | ||||
-rw-r--r-- | src/quick/util/qquickpath_p.h | 9 | ||||
-rw-r--r-- | src/quick/util/qquickpath_p_p.h | 3 | ||||
-rw-r--r-- | src/quick/util/qquickpixmapcache.cpp | 24 | ||||
-rw-r--r-- | src/quick/util/qquickpropertychanges.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquickstate.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquickstategroup.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquicksvgparser.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquicktransition.cpp | 2 |
12 files changed, 142 insertions, 29 deletions
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp index f74ad20bc6..c05b254b51 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -1025,7 +1025,7 @@ QAbstractAnimationJob* QQuickScriptAction::transition(QQuickStateActions &action PropertyAction object) so that the rotation animation begins with the correct transform origin. - \sa {Animation and Transitions in Qt Quick}, QtQml + \sa {Animation and Transitions in Qt Quick}, {Qt QML} */ QQuickPropertyAction::QQuickPropertyAction(QObject *parent) : QQuickAbstractAnimation(*(new QQuickPropertyActionPrivate), parent) @@ -1975,7 +1975,7 @@ void QQuickPropertyAnimation::setDuration(int duration) } /*! - \qmlproperty real QtQuick2::PropertyAnimation::from + \qmlproperty variant QtQuick2::PropertyAnimation::from This property holds the starting value for the animation. If the PropertyAnimation is defined within a \l Transition or \l Behavior, @@ -2002,7 +2002,7 @@ void QQuickPropertyAnimation::setFrom(const QVariant &f) } /*! - \qmlproperty real QtQuick2::PropertyAnimation::to + \qmlproperty variant QtQuick2::PropertyAnimation::to This property holds the end value for the animation. If the PropertyAnimation is defined within a \l Transition or \l Behavior, diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp index e332f37493..1e77084e42 100644 --- a/src/quick/util/qquickbehavior.cpp +++ b/src/quick/util/qquickbehavior.cpp @@ -98,7 +98,7 @@ public: state change. For general advice on using Behaviors to animate state changes, see \l{Using Qt Quick Behaviors with States}. - \sa {Animation and Transitions in Qt Quick}, {declarative/animation/behaviors}{Behavior example}, QtQml + \sa {Animation and Transitions in Qt Quick}, {declarative/animation/behaviors}{Behavior example}, {Qt QML} */ diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp index abdadaa5d3..6fbba8ca2f 100644 --- a/src/quick/util/qquickimageprovider.cpp +++ b/src/quick/util/qquickimageprovider.cpp @@ -169,7 +169,7 @@ QImage QQuickTextureFactory::image() const an image provider named "colors", and the images to be loaded are "yellow" and "red", respectively: - \snippet quick/imageprovider/imageprovider-example.qml 0 + \snippet imageprovider/imageprovider-example.qml 0 When these images are loaded by QML, it looks for a matching image provider and calls its requestImage() or requestPixmap() method (depending on its @@ -180,9 +180,9 @@ QImage QQuickTextureFactory::image() const requested by the above QML. This implementation dynamically generates QPixmap images that are filled with the requested color: - \snippet quick/imageprovider/imageprovider.cpp 0 + \snippet imageprovider/imageprovider.cpp 0 \codeline - \snippet quick/imageprovider/imageprovider.cpp 1 + \snippet imageprovider/imageprovider.cpp 1 To make this provider accessible to QML, it is registered with the QML engine with a "colors" identifier: @@ -242,7 +242,7 @@ QImage QQuickTextureFactory::image() const \c cache property to \c false for the relevant \l Image, \l BorderImage or \l AnimatedImage object. - The QtQuick 1 version of this class is named QDeclarativeImageProvider. + The \l {Qt Quick 1} version of this class is named QDeclarativeImageProvider. \sa QQmlEngine::addImageProvider() */ diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 3aea724983..2278fd25ba 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -188,8 +188,67 @@ 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); + 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) +{ + QQuickPathPrivate *d = privatePath(property->object); + + return d->_pathElements.count(); +} + +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) @@ -373,27 +432,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); - QSet<QString> attrs; - d->componentComplete = true; + + foreach (QQuickPathElement *pathElement, d->_pathElements) + connect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); +} + +void QQuickPath::gatherAttributes() +{ + Q_D(QQuickPath); + + QSet<QString> attributes; // First gather up all the attributes foreach (QQuickPathElement *pathElement, d->_pathElements) { - if (QQuickCurve *curve = - qobject_cast<QQuickCurve *>(pathElement)) + if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement)) d->_pathCurves.append(curve); - else if (QQuickPathAttribute *attribute = - qobject_cast<QQuickPathAttribute *>(pathElement)) - attrs.insert(attribute->name()); + else if (QQuickPathAttribute *attribute = qobject_cast<QQuickPathAttribute *>(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 @@ -1465,7 +1546,7 @@ void QQuickPathCatmullRomCurve::addToPath(QPainterPath &path, const QQuickPathDa nextData.curves = data.curves; next = positionForCurve(nextData, point); } else { - if (point == QPointF(path.elementAt(0)) && qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(0))) { + if (point == QPointF(path.elementAt(0)) && qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(0)) && path.elementCount() >= 3) { //this is a closed path starting and ending with catmull-rom segments. //we try to smooth the join point next = QPointF(path.elementAt(3)); //the first catmull-rom point diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index 71545851e4..1a9be7c82a 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -393,6 +393,15 @@ Q_SIGNALS: protected: virtual void componentComplete(); virtual void classBegin(); + void disconnectPathElements(); + 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(); diff --git a/src/quick/util/qquickpath_p_p.h b/src/quick/util/qquickpath_p_p.h index b4227e64f3..e376925f21 100644 --- a/src/quick/util/qquickpath_p_p.h +++ b/src/quick/util/qquickpath_p_p.h @@ -67,6 +67,9 @@ class QQuickPathPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QQuickPath) public: + static QQuickPathPrivate* get(QQuickPath *path) { return path->d_func(); } + static const QQuickPathPrivate* get(const QQuickPath *path) { return path->d_func(); } + QQuickPathPrivate() : pathLength(0), closed(false), componentComplete(true) { } QPainterPath _path; diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index c5968c2bc1..9cf8c5812d 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -71,6 +71,8 @@ #include <QQmlFile> #include <QMetaMethod> +#include <private/qqmlprofilerservice_p.h> + #define IMAGEREQUEST_MAX_REQUEST_COUNT 8 #define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16 #define CACHE_EXPIRE_TIME 30 @@ -890,11 +892,15 @@ bool QQuickPixmapReply::event(QEvent *event) if (data) { Event *de = static_cast<Event *>(event); data->pixmapStatus = (de->error == NoError) ? QQuickPixmap::Ready : QQuickPixmap::Error; - + QQmlPixmapProfiler pixmapProfiler; if (data->pixmapStatus == QQuickPixmap::Ready) { + pixmapProfiler.finishLoading(data->url); data->textureFactory = de->textureFactory; data->implicitSize = de->implicitSize; + if (data->implicitSize.width() > 0) + pixmapProfiler.setSize(url, data->implicitSize.width(), data->implicitSize.height()); } else { + pixmapProfiler.errorLoading(data->url); data->errorString = de->errorString; data->removeFromCache(); // We don't continue to cache error'd pixmaps } @@ -920,6 +926,7 @@ int QQuickPixmapData::cost() const void QQuickPixmapData::addref() { ++refCount; + QQmlPixmapProfiler().referenceCountChanged(url, refCount); if (prevUnreferencedPtr) pixmapStore()->referencePixmap(this); } @@ -928,6 +935,7 @@ void QQuickPixmapData::release() { Q_ASSERT(refCount > 0); --refCount; + QQmlPixmapProfiler().referenceCountChanged(url, refCount); if (refCount == 0) { if (reply) { QQuickPixmapReply *cancelReply = reply; @@ -958,6 +966,10 @@ void QQuickPixmapData::addToCache() QQuickPixmapKey key = { &url, &requestSize }; pixmapStore()->m_cache.insert(key, this); inCache = true; + QQmlPixmapProfiler pixmapProfiler; + pixmapProfiler.cacheCountChanged(url, pixmapStore()->m_cache.count()); + if (implicitSize.width() > 0) + pixmapProfiler.setSize(url, implicitSize.width(), implicitSize.height()); } } @@ -965,6 +977,7 @@ void QQuickPixmapData::removeFromCache() { if (inCache) { QQuickPixmapKey key = { &url, &requestSize }; + QQmlPixmapProfiler().cacheCountChanged(url, pixmapStore()->m_cache.count()); pixmapStore()->m_cache.remove(key); inCache = false; } @@ -1238,14 +1251,21 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques if (!(options & QQuickPixmap::Asynchronous)) { bool ok = false; + QQmlPixmapProfiler pixmapProfiler; + pixmapProfiler.startLoading(url); d = createPixmapDataSync(this, engine, url, requestSize, &ok); if (ok) { + pixmapProfiler.finishLoading(url); + if (d->implicitSize.width() > 0) + QQmlPixmapProfiler().setSize(url, d->implicitSize.width(), d->implicitSize.height()); if (options & QQuickPixmap::Cache) d->addToCache(); return; } - if (d) // loadable, but encountered error while loading + if (d) { // loadable, but encountered error while loading + pixmapProfiler.errorLoading(url); return; + } } if (!engine) diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp index c1173d70f5..ec3a2f8170 100644 --- a/src/quick/util/qquickpropertychanges.cpp +++ b/src/quick/util/qquickpropertychanges.cpp @@ -128,7 +128,7 @@ QT_BEGIN_NAMESPACE See the PropertyAction documentation for more details. - \sa {declarative/animation/states}{states example}, {Qt Quick States}{Qt Quick States}, QtQml + \sa {declarative/animation/states}{states example}, {Qt Quick States}{Qt Quick States}, {Qt QML} */ /*! diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp index 491146660b..c89cea6767 100644 --- a/src/quick/util/qquickstate.cpp +++ b/src/quick/util/qquickstate.cpp @@ -151,7 +151,7 @@ QQuickStateOperation::QQuickStateOperation(QObjectPrivate &dd, QObject *parent) not allowed. \sa {declarative/animation/states}{states example}, {Qt Quick States}{Qt Quick States}, - {Animation and Transitions in Qt Quick}{Transitions}, QtQml + {Animation and Transitions in Qt Quick}{Transitions}, {Qt QML} */ QQuickState::QQuickState(QObject *parent) : QObject(*(new QQuickStatePrivate), parent) diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp index b4c8f214b9..a72a45e96b 100644 --- a/src/quick/util/qquickstategroup.cpp +++ b/src/quick/util/qquickstategroup.cpp @@ -119,7 +119,7 @@ public: } \endqml - \sa {Qt Quick States}{Qt Quick States}, {Animation and Transitions in Qt Quick}{Transitions}, {QtQml} + \sa {Qt Quick States}{Qt Quick States}, {Animation and Transitions in Qt Quick}{Transitions}, {Qt QML} */ QQuickStateGroup::QQuickStateGroup(QObject *parent) diff --git a/src/quick/util/qquicksvgparser.cpp b/src/quick/util/qquicksvgparser.cpp index 760b4b0e2f..ece6d24ee1 100644 --- a/src/quick/util/qquicksvgparser.cpp +++ b/src/quick/util/qquicksvgparser.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE static const double Q_PI = 3.14159265358979323846; // pi -//copied from QtSvg (qsvghandler.cpp). +//copied from Qt SVG (qsvghandler.cpp). Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok); // '0' is 0x30 and '9' is 0x39 static inline bool isDigit(ushort ch) diff --git a/src/quick/util/qquicktransition.cpp b/src/quick/util/qquicktransition.cpp index 025c7d7b03..ead28fe496 100644 --- a/src/quick/util/qquicktransition.cpp +++ b/src/quick/util/qquicktransition.cpp @@ -94,7 +94,7 @@ QT_BEGIN_NAMESPACE \l Behavior, the Transition animation overrides the \l Behavior for that state change. - \sa {Animation and Transitions in Qt Quick}, {declarative/animation/states}{states example}, {Qt Quick States}{Qt Quick States}, {QtQml} + \sa {Animation and Transitions in Qt Quick}, {declarative/animation/states}{states example}, {Qt Quick States}{Qt Quick States}, {Qt QML} */ //ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting |