aboutsummaryrefslogtreecommitdiffstats
path: root/src/qtquick1/util
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-01-31 16:52:36 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-03 00:39:18 +0100
commit01dc7e2ea476e0e6dcdce2e72979bbc858f4057d (patch)
treed8796f7695bbf8ad42abf47cd84c1b5e000ef795 /src/qtquick1/util
parent5e07b57b818326da47a46d384415041fa4cea0ba (diff)
Remove QtQuick1 elements from qtdeclarative
QtQuick1 is now contained in a separate repository. Task-number: QTBUG-23737 Change-Id: I09eae67af5693a22b896b916f816f73ccc3a89b1 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/qtquick1/util')
-rw-r--r--src/qtquick1/util/qdeclarativeanimation.cpp2969
-rw-r--r--src/qtquick1/util/qdeclarativeanimation_p.h527
-rw-r--r--src/qtquick1/util/qdeclarativeanimation_p_p.h396
-rw-r--r--src/qtquick1/util/qdeclarativeapplication.cpp116
-rw-r--r--src/qtquick1/util/qdeclarativeapplication_p.h85
-rw-r--r--src/qtquick1/util/qdeclarativebehavior.cpp235
-rw-r--r--src/qtquick1/util/qdeclarativebehavior_p.h97
-rw-r--r--src/qtquick1/util/qdeclarativebind.cpp216
-rw-r--r--src/qtquick1/util/qdeclarativebind_p.h95
-rw-r--r--src/qtquick1/util/qdeclarativeconnections.cpp294
-rw-r--r--src/qtquick1/util/qdeclarativeconnections_p.h101
-rw-r--r--src/qtquick1/util/qdeclarativefontloader.cpp343
-rw-r--r--src/qtquick1/util/qdeclarativefontloader_p.h96
-rw-r--r--src/qtquick1/util/qdeclarativelistaccessor.cpp142
-rw-r--r--src/qtquick1/util/qdeclarativelistaccessor_p.h80
-rw-r--r--src/qtquick1/util/qdeclarativelistmodel.cpp1634
-rw-r--r--src/qtquick1/util/qdeclarativelistmodel_p.h155
-rw-r--r--src/qtquick1/util/qdeclarativelistmodel_p_p.h280
-rw-r--r--src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp282
-rw-r--r--src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h161
-rw-r--r--src/qtquick1/util/qdeclarativeopenmetaobject.cpp384
-rw-r--r--src/qtquick1/util/qdeclarativeopenmetaobject_p.h129
-rw-r--r--src/qtquick1/util/qdeclarativepackage.cpp206
-rw-r--r--src/qtquick1/util/qdeclarativepackage_p.h97
-rw-r--r--src/qtquick1/util/qdeclarativepixmapcache.cpp1090
-rw-r--r--src/qtquick1/util/qdeclarativepixmapcache_p.h122
-rw-r--r--src/qtquick1/util/qdeclarativepropertychanges.cpp801
-rw-r--r--src/qtquick1/util/qdeclarativepropertychanges_p.h110
-rw-r--r--src/qtquick1/util/qdeclarativesmoothedanimation.cpp498
-rw-r--r--src/qtquick1/util/qdeclarativesmoothedanimation_p.h103
-rw-r--r--src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h135
-rw-r--r--src/qtquick1/util/qdeclarativespringanimation.cpp469
-rw-r--r--src/qtquick1/util/qdeclarativespringanimation_p.h110
-rw-r--r--src/qtquick1/util/qdeclarativestate.cpp735
-rw-r--r--src/qtquick1/util/qdeclarativestate_p.h210
-rw-r--r--src/qtquick1/util/qdeclarativestate_p_p.h253
-rw-r--r--src/qtquick1/util/qdeclarativestategroup.cpp511
-rw-r--r--src/qtquick1/util/qdeclarativestategroup_p.h95
-rw-r--r--src/qtquick1/util/qdeclarativestateoperations.cpp1594
-rw-r--r--src/qtquick1/util/qdeclarativestateoperations_p.h298
-rw-r--r--src/qtquick1/util/qdeclarativestyledtext.cpp351
-rw-r--r--src/qtquick1/util/qdeclarativestyledtext_p.h70
-rw-r--r--src/qtquick1/util/qdeclarativesystempalette.cpp317
-rw-r--r--src/qtquick1/util/qdeclarativesystempalette_p.h121
-rw-r--r--src/qtquick1/util/qdeclarativetimeline.cpp951
-rw-r--r--src/qtquick1/util/qdeclarativetimeline_p_p.h200
-rw-r--r--src/qtquick1/util/qdeclarativetimer.cpp329
-rw-r--r--src/qtquick1/util/qdeclarativetimer_p.h114
-rw-r--r--src/qtquick1/util/qdeclarativetransition.cpp352
-rw-r--r--src/qtquick1/util/qdeclarativetransition_p.h105
-rw-r--r--src/qtquick1/util/qdeclarativetransitionmanager.cpp280
-rw-r--r--src/qtquick1/util/qdeclarativetransitionmanager_p_p.h85
-rw-r--r--src/qtquick1/util/qdeclarativeutilmodule.cpp178
-rw-r--r--src/qtquick1/util/qdeclarativeutilmodule_p.h63
-rw-r--r--src/qtquick1/util/qdeclarativeview.cpp752
-rw-r--r--src/qtquick1/util/qdeclarativeview.h125
-rw-r--r--src/qtquick1/util/qdeclarativexmllistmodel.cpp1060
-rw-r--r--src/qtquick1/util/qdeclarativexmllistmodel_p.h212
-rw-r--r--src/qtquick1/util/util.pri69
59 files changed, 0 insertions, 21988 deletions
diff --git a/src/qtquick1/util/qdeclarativeanimation.cpp b/src/qtquick1/util/qdeclarativeanimation.cpp
deleted file mode 100644
index 46ac6be94c..0000000000
--- a/src/qtquick1/util/qdeclarativeanimation.cpp
+++ /dev/null
@@ -1,2969 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-#include "QtQuick1/private/qdeclarativeanimation_p_p.h"
-
-#include "QtQuick1/private/qdeclarativebehavior_p.h"
-#include "QtQuick1/private/qdeclarativestateoperations_p.h"
-#include "QtDeclarative/private/qdeclarativecontext_p.h"
-
-#include <QtDeclarative/qdeclarativepropertyvaluesource.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/private/qdeclarativestringconverters_p.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-#include <QtDeclarative/private/qdeclarativemetatype_p.h>
-#include <QtDeclarative/private/qdeclarativevaluetype_p.h>
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-
-#include <qvariant.h>
-#include <qcolor.h>
-#include <qfile.h>
-#include <QParallelAnimationGroup>
-#include <QSequentialAnimationGroup>
-#include <QtCore/qset.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qmath.h>
-
-#include <private/qvariantanimation_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-/*!
- \qmlclass Animation QDeclarative1AbstractAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \brief The Animation element is the base of all QML animations.
-
- The Animation element cannot be used directly in a QML file. It exists
- to provide a set of common properties and methods, available across all the
- other animation types that inherit from it. Attempting to use the Animation
- element directly will result in an error.
-*/
-
-QDeclarative1AbstractAnimation::QDeclarative1AbstractAnimation(QObject *parent)
-: QObject(*(new QDeclarative1AbstractAnimationPrivate), parent)
-{
-}
-
-QDeclarative1AbstractAnimation::~QDeclarative1AbstractAnimation()
-{
-}
-
-QDeclarative1AbstractAnimation::QDeclarative1AbstractAnimation(QDeclarative1AbstractAnimationPrivate &dd, QObject *parent)
-: QObject(dd, parent)
-{
-}
-
-/*!
- \qmlproperty bool QtQuick1::Animation::running
- This property holds whether the animation is currently running.
-
- The \c running property can be set to declaratively control whether or not
- an animation is running. The following example will animate a rectangle
- whenever the \l MouseArea is pressed.
-
- \code
- Rectangle {
- width: 100; height: 100
- NumberAnimation on x {
- running: myMouse.pressed
- from: 0; to: 100
- }
- MouseArea { id: myMouse }
- }
- \endcode
-
- Likewise, the \c running property can be read to determine if the animation
- is running. In the following example the text element will indicate whether
- or not the animation is running.
-
- \code
- NumberAnimation { id: myAnimation }
- Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" }
- \endcode
-
- Animations can also be started and stopped imperatively from JavaScript
- using the \c start() and \c stop() methods.
-
- By default, animations are not running. Though, when the animations are assigned to properties,
- as property value sources using the \e on syntax, they are set to running by default.
-*/
-bool QDeclarative1AbstractAnimation::isRunning() const
-{
- Q_D(const QDeclarative1AbstractAnimation);
- return d->running;
-}
-
-// the behavior calls this function
-void QDeclarative1AbstractAnimation::notifyRunningChanged(bool running)
-{
- Q_D(QDeclarative1AbstractAnimation);
- if (d->disableUserControl && d->running != running) {
- d->running = running;
- emit runningChanged(running);
- }
-}
-
-//commence is called to start an animation when it is used as a
-//simple animation, and not as part of a transition
-void QDeclarative1AbstractAnimationPrivate::commence()
-{
- Q_Q(QDeclarative1AbstractAnimation);
-
- QDeclarative1StateActions actions;
- QDeclarativeProperties properties;
- q->transition(actions, properties, QDeclarative1AbstractAnimation::Forward);
-
- q->qtAnimation()->start();
- if (q->qtAnimation()->state() == QAbstractAnimation::Stopped) {
- running = false;
- emit q->completed();
- }
-}
-
-QDeclarativeProperty QDeclarative1AbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj)
-{
- QDeclarativeProperty prop(obj, str, qmlContext(infoObj));
- if (!prop.isValid()) {
- qmlInfo(infoObj) << QDeclarative1AbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str);
- return QDeclarativeProperty();
- } else if (!prop.isWritable()) {
- qmlInfo(infoObj) << QDeclarative1AbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str);
- return QDeclarativeProperty();
- }
- return prop;
-}
-
-void QDeclarative1AbstractAnimation::setRunning(bool r)
-{
- Q_D(QDeclarative1AbstractAnimation);
- if (!d->componentComplete) {
- d->running = r;
- if (r == false)
- d->avoidPropertyValueSourceStart = true;
- else if (!d->registered) {
- d->registered = true;
- QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
- engPriv->registerFinalizeCallback(this, this->metaObject()->indexOfSlot("componentFinalized()"));
- }
- return;
- }
-
- if (d->running == r)
- return;
-
- if (d->group || d->disableUserControl) {
- qmlInfo(this) << "setRunning() cannot be used on non-root animation nodes.";
- return;
- }
-
- d->running = r;
- if (d->running) {
- bool supressStart = false;
- if (d->alwaysRunToEnd && d->loopCount != 1
- && qtAnimation()->state() == QAbstractAnimation::Running) {
- //we've restarted before the final loop finished; restore proper loop count
- if (d->loopCount == -1)
- qtAnimation()->setLoopCount(d->loopCount);
- else
- qtAnimation()->setLoopCount(qtAnimation()->currentLoop() + d->loopCount);
- supressStart = true; //we want the animation to continue, rather than restart
- }
-
- if (!d->connectedTimeLine) {
- QObject::connect(qtAnimation(), SIGNAL(finished()),
- this, SLOT(timelineComplete()));
- d->connectedTimeLine = true;
- }
- if (!supressStart)
- d->commence();
- emit started();
- } else {
- if (d->alwaysRunToEnd) {
- if (d->loopCount != 1)
- qtAnimation()->setLoopCount(qtAnimation()->currentLoop()+1); //finish the current loop
- } else
- qtAnimation()->stop();
-
- emit completed();
- }
-
- emit runningChanged(d->running);
-}
-
-/*!
- \qmlproperty bool QtQuick1::Animation::paused
- This property holds whether the animation is currently paused.
-
- The \c paused property can be set to declaratively control whether or not
- an animation is paused.
-
- Animations can also be paused and resumed imperatively from JavaScript
- using the \c pause() and \c resume() methods.
-
- By default, animations are not paused.
-*/
-bool QDeclarative1AbstractAnimation::isPaused() const
-{
- Q_D(const QDeclarative1AbstractAnimation);
- return d->paused;
-}
-
-void QDeclarative1AbstractAnimation::setPaused(bool p)
-{
- Q_D(QDeclarative1AbstractAnimation);
- if (d->paused == p)
- return;
-
- if (d->group || d->disableUserControl) {
- qmlInfo(this) << "setPaused() cannot be used on non-root animation nodes.";
- return;
- }
-
- d->paused = p;
- if (d->paused)
- qtAnimation()->pause();
- else
- qtAnimation()->resume();
-
- emit pausedChanged(d->paused);
-}
-
-void QDeclarative1AbstractAnimation::classBegin()
-{
- Q_D(QDeclarative1AbstractAnimation);
- d->componentComplete = false;
-}
-
-void QDeclarative1AbstractAnimation::componentComplete()
-{
- Q_D(QDeclarative1AbstractAnimation);
- d->componentComplete = true;
-}
-
-void QDeclarative1AbstractAnimation::componentFinalized()
-{
- Q_D(QDeclarative1AbstractAnimation);
- if (d->running) {
- d->running = false;
- setRunning(true);
- }
-}
-
-/*!
- \qmlproperty bool QtQuick1::Animation::alwaysRunToEnd
- This property holds whether the animation should run to completion when it is stopped.
-
- If this true the animation will complete its current iteration when it
- is stopped - either by setting the \c running property to false, or by
- calling the \c stop() method. The \c complete() method is not effected
- by this value.
-
- This behavior is most useful when the \c repeat property is set, as the
- animation will finish playing normally but not restart.
-
- By default, the alwaysRunToEnd property is not set.
-
- \note alwaysRunToEnd has no effect on animations in a Transition.
-*/
-bool QDeclarative1AbstractAnimation::alwaysRunToEnd() const
-{
- Q_D(const QDeclarative1AbstractAnimation);
- return d->alwaysRunToEnd;
-}
-
-void QDeclarative1AbstractAnimation::setAlwaysRunToEnd(bool f)
-{
- Q_D(QDeclarative1AbstractAnimation);
- if (d->alwaysRunToEnd == f)
- return;
-
- d->alwaysRunToEnd = f;
- emit alwaysRunToEndChanged(f);
-}
-
-/*!
- \qmlproperty int QtQuick1::Animation::loops
- This property holds the number of times the animation should play.
-
- By default, \c loops is 1: the animation will play through once and then stop.
-
- If set to Animation.Infinite, the animation will continuously repeat until it is explicitly
- stopped - either by setting the \c running property to false, or by calling
- the \c stop() method.
-
- In the following example, the rectangle will spin indefinitely.
-
- \code
- Rectangle {
- width: 100; height: 100; color: "green"
- RotationAnimation on rotation {
- loops: Animation.Infinite
- from: 0
- to: 360
- }
- }
- \endcode
-*/
-int QDeclarative1AbstractAnimation::loops() const
-{
- Q_D(const QDeclarative1AbstractAnimation);
- return d->loopCount;
-}
-
-void QDeclarative1AbstractAnimation::setLoops(int loops)
-{
- Q_D(QDeclarative1AbstractAnimation);
- if (loops < 0)
- loops = -1;
-
- if (loops == d->loopCount)
- return;
-
- d->loopCount = loops;
- qtAnimation()->setLoopCount(loops);
- emit loopCountChanged(loops);
-}
-
-
-int QDeclarative1AbstractAnimation::currentTime()
-{
- return qtAnimation()->currentLoopTime();
-}
-
-void QDeclarative1AbstractAnimation::setCurrentTime(int time)
-{
- qtAnimation()->setCurrentTime(time);
-}
-
-QDeclarative1AnimationGroup *QDeclarative1AbstractAnimation::group() const
-{
- Q_D(const QDeclarative1AbstractAnimation);
- return d->group;
-}
-
-void QDeclarative1AbstractAnimation::setGroup(QDeclarative1AnimationGroup *g)
-{
- Q_D(QDeclarative1AbstractAnimation);
- if (d->group == g)
- return;
- if (d->group)
- static_cast<QDeclarative1AnimationGroupPrivate *>(d->group->d_func())->animations.removeAll(this);
-
- d->group = g;
-
- if (d->group && !static_cast<QDeclarative1AnimationGroupPrivate *>(d->group->d_func())->animations.contains(this))
- static_cast<QDeclarative1AnimationGroupPrivate *>(d->group->d_func())->animations.append(this);
-
- //if (g) //if removed from a group, then the group should no longer be the parent
- setParent(g);
-}
-
-/*!
- \qmlmethod QtQuick1::Animation::start()
- \brief Starts the animation.
-
- If the animation is already running, calling this method has no effect. The
- \c running property will be true following a call to \c start().
-*/
-void QDeclarative1AbstractAnimation::start()
-{
- setRunning(true);
-}
-
-/*!
- \qmlmethod QtQuick1::Animation::pause()
- \brief Pauses the animation.
-
- If the animation is already paused, calling this method has no effect. The
- \c paused property will be true following a call to \c pause().
-*/
-void QDeclarative1AbstractAnimation::pause()
-{
- setPaused(true);
-}
-
-/*!
- \qmlmethod QtQuick1::Animation::resume()
- \brief Resumes a paused animation.
-
- If the animation is not paused, calling this method has no effect. The
- \c paused property will be false following a call to \c resume().
-*/
-void QDeclarative1AbstractAnimation::resume()
-{
- setPaused(false);
-}
-
-/*!
- \qmlmethod QtQuick1::Animation::stop()
- \brief Stops the animation.
-
- If the animation is not running, calling this method has no effect. The
- \c running property will be false following a call to \c stop().
-
- Normally \c stop() stops the animation immediately, and the animation has
- no further influence on property values. In this example animation
- \code
- Rectangle {
- NumberAnimation on x { from: 0; to: 100; duration: 500 }
- }
- \endcode
- was stopped at time 250ms, the \c x property will have a value of 50.
-
- However, if the \c alwaysRunToEnd property is set, the animation will
- continue running until it completes and then stop. The \c running property
- will still become false immediately.
-*/
-void QDeclarative1AbstractAnimation::stop()
-{
- setRunning(false);
-}
-
-/*!
- \qmlmethod QtQuick1::Animation::restart()
- \brief Restarts the animation.
-
- This is a convenience method, and is equivalent to calling \c stop() and
- then \c start().
-*/
-void QDeclarative1AbstractAnimation::restart()
-{
- stop();
- start();
-}
-
-/*!
- \qmlmethod QtQuick1::Animation::complete()
- \brief Stops the animation, jumping to the final property values.
-
- If the animation is not running, calling this method has no effect. The
- \c running property will be false following a call to \c complete().
-
- Unlike \c stop(), \c complete() immediately fast-forwards the animation to
- its end. In the following example,
- \code
- Rectangle {
- NumberAnimation on x { from: 0; to: 100; duration: 500 }
- }
- \endcode
- calling \c stop() at time 250ms will result in the \c x property having
- a value of 50, while calling \c complete() will set the \c x property to
- 100, exactly as though the animation had played the whole way through.
-*/
-void QDeclarative1AbstractAnimation::complete()
-{
- if (isRunning()) {
- qtAnimation()->setCurrentTime(qtAnimation()->duration());
- }
-}
-
-void QDeclarative1AbstractAnimation::setTarget(const QDeclarativeProperty &p)
-{
- Q_D(QDeclarative1AbstractAnimation);
- d->defaultProperty = p;
-
- if (!d->avoidPropertyValueSourceStart)
- setRunning(true);
-}
-
-/*
- we rely on setTarget only being called when used as a value source
- so this function allows us to do the same thing as setTarget without
- that assumption
-*/
-void QDeclarative1AbstractAnimation::setDefaultTarget(const QDeclarativeProperty &p)
-{
- Q_D(QDeclarative1AbstractAnimation);
- d->defaultProperty = p;
-}
-
-/*
- don't allow start/stop/pause/resume to be manually invoked,
- because something else (like a Behavior) already has control
- over the animation.
-*/
-void QDeclarative1AbstractAnimation::setDisableUserControl()
-{
- Q_D(QDeclarative1AbstractAnimation);
- d->disableUserControl = true;
-}
-
-void QDeclarative1AbstractAnimation::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_UNUSED(actions);
- Q_UNUSED(modified);
- Q_UNUSED(direction);
-}
-
-void QDeclarative1AbstractAnimation::timelineComplete()
-{
- Q_D(QDeclarative1AbstractAnimation);
- setRunning(false);
- if (d->alwaysRunToEnd && d->loopCount != 1) {
- //restore the proper loopCount for the next run
- qtAnimation()->setLoopCount(d->loopCount);
- }
-}
-
-/*!
- \qmlclass PauseAnimation QDeclarative1PauseAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits Animation
- \brief The PauseAnimation element provides a pause for an animation.
-
- When used in a SequentialAnimation, PauseAnimation is a step when
- nothing happens, for a specified duration.
-
- A 500ms animation sequence, with a 100ms pause between two animations:
- \code
- SequentialAnimation {
- NumberAnimation { ... duration: 200 }
- PauseAnimation { duration: 100 }
- NumberAnimation { ... duration: 200 }
- }
- \endcode
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarative1PauseAnimation::QDeclarative1PauseAnimation(QObject *parent)
-: QDeclarative1AbstractAnimation(*(new QDeclarative1PauseAnimationPrivate), parent)
-{
- Q_D(QDeclarative1PauseAnimation);
- d->init();
-}
-
-QDeclarative1PauseAnimation::~QDeclarative1PauseAnimation()
-{
-}
-
-void QDeclarative1PauseAnimationPrivate::init()
-{
- Q_Q(QDeclarative1PauseAnimation);
- pa = new QPauseAnimation;
- QDeclarative_setParent_noEvent(pa, q);
-}
-
-/*!
- \qmlproperty int QtQuick1::PauseAnimation::duration
- This property holds the duration of the pause in milliseconds
-
- The default value is 250.
-*/
-int QDeclarative1PauseAnimation::duration() const
-{
- Q_D(const QDeclarative1PauseAnimation);
- return d->pa->duration();
-}
-
-void QDeclarative1PauseAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QDeclarative1PauseAnimation);
- if (d->pa->duration() == duration)
- return;
- d->pa->setDuration(duration);
- emit durationChanged(duration);
-}
-
-QAbstractAnimation *QDeclarative1PauseAnimation::qtAnimation()
-{
- Q_D(QDeclarative1PauseAnimation);
- return d->pa;
-}
-
-/*!
- \qmlclass ColorAnimation QDeclarative1ColorAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits PropertyAnimation
- \brief The ColorAnimation element animates changes in color values.
-
- ColorAnimation is a specialized PropertyAnimation that defines an
- animation to be applied when a color value changes.
-
- Here is a ColorAnimation applied to the \c color property of a \l Rectangle
- as a property value source. It animates the \c color property's value from
- its current value to a value of "red", over 1000 milliseconds:
-
- \snippet doc/src/snippets/qtquick1/coloranimation.qml 0
-
- Like any other animation element, a ColorAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- For convenience, when a ColorAnimation is used in a \l Transition, it will
- animate any \c color properties that have been modified during the state
- change. If a \l{PropertyAnimation::}{property} or
- \l{PropertyAnimation::}{properties} are explicitly set for the animation,
- then those are used instead.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarative1ColorAnimation::QDeclarative1ColorAnimation(QObject *parent)
-: QDeclarative1PropertyAnimation(parent)
-{
- Q_D(QDeclarative1PropertyAnimation);
- d->interpolatorType = QMetaType::QColor;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultToInterpolatorType = true;
-}
-
-QDeclarative1ColorAnimation::~QDeclarative1ColorAnimation()
-{
-}
-
-/*!
- \qmlproperty color QtQuick1::ColorAnimation::from
- This property holds the color value at which the animation should begin.
-
- For example, the following animation is not applied until a color value
- has reached "#c0c0c0":
-
- \qml
- Item {
- states: [
- // States are defined here...
- ]
-
- transition: Transition {
- NumberAnimation { from: "#c0c0c0"; duration: 2000 }
- }
- }
- \endqml
-
- If the ColorAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-QColor QDeclarative1ColorAnimation::from() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->from.value<QColor>();
-}
-
-void QDeclarative1ColorAnimation::setFrom(const QColor &f)
-{
- QDeclarative1PropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty color QtQuick1::ColorAnimation::to
-
- This property holds the color value at which the animation should end.
-
- If the ColorAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-QColor QDeclarative1ColorAnimation::to() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->to.value<QColor>();
-}
-
-void QDeclarative1ColorAnimation::setTo(const QColor &t)
-{
- QDeclarative1PropertyAnimation::setTo(t);
-}
-
-
-
-/*!
- \qmlclass ScriptAction QDeclarative1ScriptAction
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits Animation
- \brief The ScriptAction element allows scripts to be run during an animation.
-
- ScriptAction can be used to run a script at a specific point in an animation.
-
- \qml
- SequentialAnimation {
- NumberAnimation {
- // ...
- }
- ScriptAction { script: doSomething(); }
- NumberAnimation {
- // ...
- }
- }
- \endqml
-
- When used as part of a Transition, you can also target a specific
- StateChangeScript to run using the \c scriptName property.
-
- \snippet doc/src/snippets/qtquick1/states/statechangescript.qml state and transition
-
- \sa StateChangeScript
-*/
-QDeclarative1ScriptAction::QDeclarative1ScriptAction(QObject *parent)
- :QDeclarative1AbstractAnimation(*(new QDeclarative1ScriptActionPrivate), parent)
-{
- Q_D(QDeclarative1ScriptAction);
- d->init();
-}
-
-QDeclarative1ScriptAction::~QDeclarative1ScriptAction()
-{
-}
-
-void QDeclarative1ScriptActionPrivate::init()
-{
- Q_Q(QDeclarative1ScriptAction);
- rsa = new QActionAnimation_1(&proxy);
- QDeclarative_setParent_noEvent(rsa, q);
-}
-
-/*!
- \qmlproperty script QtQuick1::ScriptAction::script
- This property holds the script to run.
-*/
-QDeclarativeScriptString QDeclarative1ScriptAction::script() const
-{
- Q_D(const QDeclarative1ScriptAction);
- return d->script;
-}
-
-void QDeclarative1ScriptAction::setScript(const QDeclarativeScriptString &script)
-{
- Q_D(QDeclarative1ScriptAction);
- d->script = script;
-}
-
-/*!
- \qmlproperty string QtQuick1::ScriptAction::scriptName
- This property holds the the name of the StateChangeScript to run.
-
- This property is only valid when ScriptAction is used as part of a transition.
- If both script and scriptName are set, scriptName will be used.
-
- \note When using scriptName in a reversible transition, the script will only
- be run when the transition is being run forwards.
-*/
-QString QDeclarative1ScriptAction::stateChangeScriptName() const
-{
- Q_D(const QDeclarative1ScriptAction);
- return d->name;
-}
-
-void QDeclarative1ScriptAction::setStateChangeScriptName(const QString &name)
-{
- Q_D(QDeclarative1ScriptAction);
- d->name = name;
-}
-
-void QDeclarative1ScriptActionPrivate::execute()
-{
- Q_Q(QDeclarative1ScriptAction);
- if (hasRunScriptScript && reversing)
- return;
-
- QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script;
-
- const QString &str = scriptStr.script();
- if (!str.isEmpty()) {
- QDeclarativeExpression expr(scriptStr.context(), scriptStr.scopeObject(), str);
- QDeclarativeData *ddata = QDeclarativeData::get(q);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
- expr.evaluate();
- if (expr.hasError())
- qmlInfo(q) << expr.error();
- }
-}
-
-void QDeclarative1ScriptAction::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarative1ScriptAction);
- Q_UNUSED(modified);
-
- d->hasRunScriptScript = false;
- d->reversing = (direction == Backward);
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarative1Action &action = actions[ii];
-
- if (action.event && action.event->typeName() == QLatin1String("StateChangeScript")
- && static_cast<QDeclarative1StateChangeScript*>(action.event)->name() == d->name) {
- d->runScriptScript = static_cast<QDeclarative1StateChangeScript*>(action.event)->script();
- d->hasRunScriptScript = true;
- action.actionDone = true;
- break; //only match one (names should be unique)
- }
- }
-}
-
-QAbstractAnimation *QDeclarative1ScriptAction::qtAnimation()
-{
- Q_D(QDeclarative1ScriptAction);
- return d->rsa;
-}
-
-
-
-/*!
- \qmlclass PropertyAction QDeclarative1PropertyAction
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits Animation
- \brief The PropertyAction element allows immediate property changes during animation.
-
- PropertyAction is used to specify an immediate property change during an
- animation. The property change is not animated.
-
- It is useful for setting non-animated property values during an animation.
-
- For example, here is a SequentialAnimation that sets the image's
- \l {Image::}{smooth} property to \c true, animates the width of the image,
- then sets \l {Image::}{smooth} back to \c false:
-
- \snippet doc/src/snippets/qtquick1/propertyaction.qml standalone
-
- PropertyAction is also useful for setting the exact point at which a property
- change should occur during a \l Transition. For example, if PropertyChanges
- was used in a \l State to rotate an item around a particular
- \l {Item::}{transformOrigin}, it might be implemented like this:
-
- \snippet doc/src/snippets/qtquick1/propertyaction.qml transition
-
- However, with this code, the \c transformOrigin is not set until \e after
- the animation, as a \l State is taken to define the values at the \e end of
- a transition. The animation would rotate at the default \c transformOrigin,
- then jump to \c Item.BottomRight. To fix this, insert a PropertyAction
- before the RotationAnimation begins:
-
- \snippet doc/src/snippets/qtquick1/propertyaction-sequential.qml sequential
-
- This immediately sets the \c transformOrigin property to the value defined
- in the end state of the \l Transition (i.e. the value defined in the
- PropertyAction object) so that the rotation animation begins with the
- correct transform origin.
-
- \sa {QML Animation and Transitions}, QtDeclarative
-*/
-QDeclarative1PropertyAction::QDeclarative1PropertyAction(QObject *parent)
-: QDeclarative1AbstractAnimation(*(new QDeclarative1PropertyActionPrivate), parent)
-{
- Q_D(QDeclarative1PropertyAction);
- d->init();
-}
-
-QDeclarative1PropertyAction::~QDeclarative1PropertyAction()
-{
-}
-
-void QDeclarative1PropertyActionPrivate::init()
-{
- Q_Q(QDeclarative1PropertyAction);
- spa = new QActionAnimation_1;
- QDeclarative_setParent_noEvent(spa, q);
-}
-
-QObject *QDeclarative1PropertyAction::target() const
-{
- Q_D(const QDeclarative1PropertyAction);
- return d->target;
-}
-
-void QDeclarative1PropertyAction::setTarget(QObject *o)
-{
- Q_D(QDeclarative1PropertyAction);
- if (d->target == o)
- return;
- d->target = o;
- emit targetChanged();
-}
-
-QString QDeclarative1PropertyAction::property() const
-{
- Q_D(const QDeclarative1PropertyAction);
- return d->propertyName;
-}
-
-void QDeclarative1PropertyAction::setProperty(const QString &n)
-{
- Q_D(QDeclarative1PropertyAction);
- if (d->propertyName == n)
- return;
- d->propertyName = n;
- emit propertyChanged();
-}
-
-/*!
- \qmlproperty Object QtQuick1::PropertyAction::target
- \qmlproperty list<Object> QtQuick1::PropertyAction::targets
- \qmlproperty string QtQuick1::PropertyAction::property
- \qmlproperty string QtQuick1::PropertyAction::properties
-
- These properties determine the items and their properties that are
- affected by this action.
-
- The details of how these properties are interpreted in different situations
- is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
- documentation.
-
- \sa exclude
-*/
-QString QDeclarative1PropertyAction::properties() const
-{
- Q_D(const QDeclarative1PropertyAction);
- return d->properties;
-}
-
-void QDeclarative1PropertyAction::setProperties(const QString &p)
-{
- Q_D(QDeclarative1PropertyAction);
- if (d->properties == p)
- return;
- d->properties = p;
- emit propertiesChanged(p);
-}
-
-QDeclarativeListProperty<QObject> QDeclarative1PropertyAction::targets()
-{
- Q_D(QDeclarative1PropertyAction);
- return QDeclarativeListProperty<QObject>(this, d->targets);
-}
-
-/*!
- \qmlproperty list<Object> QtQuick1::PropertyAction::exclude
- This property holds the objects that should not be affected by this action.
-
- \sa targets
-*/
-QDeclarativeListProperty<QObject> QDeclarative1PropertyAction::exclude()
-{
- Q_D(QDeclarative1PropertyAction);
- return QDeclarativeListProperty<QObject>(this, d->exclude);
-}
-
-/*!
- \qmlproperty any QtQuick1::PropertyAction::value
- This property holds the value to be set on the property.
-
- If the PropertyAction is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-*/
-QVariant QDeclarative1PropertyAction::value() const
-{
- Q_D(const QDeclarative1PropertyAction);
- return d->value;
-}
-
-void QDeclarative1PropertyAction::setValue(const QVariant &v)
-{
- Q_D(QDeclarative1PropertyAction);
- if (d->value.isNull || d->value != v) {
- d->value = v;
- emit valueChanged(v);
- }
-}
-
-QAbstractAnimation *QDeclarative1PropertyAction::qtAnimation()
-{
- Q_D(QDeclarative1PropertyAction);
- return d->spa;
-}
-
-void QDeclarative1PropertyAction::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarative1PropertyAction);
- Q_UNUSED(direction);
-
- struct QDeclarative1SetPropertyAnimationAction : public QAbstractAnimationAction
- {
- QDeclarative1StateActions actions;
- virtual void doAction()
- {
- for (int ii = 0; ii < actions.count(); ++ii) {
- const QDeclarative1Action &action = actions.at(ii);
- QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- }
- }
- };
-
- QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
- props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty())
- props << d->propertyName;
-
- QList<QObject*> targets = d->targets;
- if (d->target)
- targets.append(d->target);
-
- bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
-
- if (d->defaultProperty.isValid() && !hasSelectors) {
- props << d->defaultProperty.name();
- targets << d->defaultProperty.object();
- }
-
- QDeclarative1SetPropertyAnimationAction *data = new QDeclarative1SetPropertyAnimationAction;
-
- bool hasExplicit = false;
- //an explicit animation has been specified
- if (d->value.isValid()) {
- for (int i = 0; i < props.count(); ++i) {
- for (int j = 0; j < targets.count(); ++j) {
- QDeclarative1Action myAction;
- myAction.property = d->createProperty(targets.at(j), props.at(i), this);
- if (myAction.property.isValid()) {
- myAction.toValue = d->value;
- QDeclarative1PropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarative1Action &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
- }
- }
- }
- }
- }
- }
-
- if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarative1Action &action = actions[ii];
-
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
- QObject *sObj = action.specifiedObject;
- QString sPropertyName = action.specifiedProperty;
- bool same = (obj == sObj);
-
- if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
- (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) {
- QDeclarative1Action myAction = action;
-
- if (d->value.isValid())
- myAction.toValue = d->value;
- QDeclarative1PropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
-
- modified << action.property;
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
-
- if (data->actions.count()) {
- d->spa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
- } else {
- delete data;
- }
-}
-
-/*!
- \qmlclass NumberAnimation QDeclarative1NumberAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits PropertyAnimation
- \brief The NumberAnimation element animates changes in qreal-type values.
-
- NumberAnimation is a specialized PropertyAnimation that defines an
- animation to be applied when a numerical value changes.
-
- Here is a NumberAnimation applied to the \c x property of a \l Rectangle
- as a property value source. It animates the \c x value from its current
- value to a value of 50, over 1000 milliseconds:
-
- \snippet doc/src/snippets/qtquick1/numberanimation.qml 0
-
- Like any other animation element, a NumberAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- Note that NumberAnimation may not animate smoothly if there are irregular
- changes in the number value that it is tracking. If this is the case, use
- SmoothedAnimation instead.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarative1NumberAnimation::QDeclarative1NumberAnimation(QObject *parent)
-: QDeclarative1PropertyAnimation(parent)
-{
- init();
-}
-
-QDeclarative1NumberAnimation::QDeclarative1NumberAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent)
-: QDeclarative1PropertyAnimation(dd, parent)
-{
- init();
-}
-
-QDeclarative1NumberAnimation::~QDeclarative1NumberAnimation()
-{
-}
-
-void QDeclarative1NumberAnimation::init()
-{
- Q_D(QDeclarative1PropertyAnimation);
- d->interpolatorType = QMetaType::QReal;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
-}
-
-/*!
- \qmlproperty real QtQuick1::NumberAnimation::from
- This property holds the starting value for the animation.
-
- For example, the following animation is not applied until the \c x value
- has reached 100:
-
- \qml
- Item {
- states: [
- // ...
- ]
-
- transition: Transition {
- NumberAnimation { properties: "x"; from: 100; duration: 200 }
- }
- }
- \endqml
-
- If the NumberAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-
-qreal QDeclarative1NumberAnimation::from() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->from.toReal();
-}
-
-void QDeclarative1NumberAnimation::setFrom(qreal f)
-{
- QDeclarative1PropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real QtQuick1::NumberAnimation::to
- This property holds the end value for the animation.
-
- If the NumberAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-qreal QDeclarative1NumberAnimation::to() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->to.toReal();
-}
-
-void QDeclarative1NumberAnimation::setTo(qreal t)
-{
- QDeclarative1PropertyAnimation::setTo(t);
-}
-
-
-
-/*!
- \qmlclass Vector3dAnimation QDeclarative1Vector3dAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits PropertyAnimation
- \brief The Vector3dAnimation element animates changes in QVector3d values.
-
- Vector3dAnimation is a specialized PropertyAnimation that defines an
- animation to be applied when a Vector3d value changes.
-
- Like any other animation element, a Vector3dAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarative1Vector3dAnimation::QDeclarative1Vector3dAnimation(QObject *parent)
-: QDeclarative1PropertyAnimation(parent)
-{
- Q_D(QDeclarative1PropertyAnimation);
- d->interpolatorType = QMetaType::QVector3D;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultToInterpolatorType = true;
-}
-
-QDeclarative1Vector3dAnimation::~QDeclarative1Vector3dAnimation()
-{
-}
-
-/*!
- \qmlproperty real QtQuick1::Vector3dAnimation::from
- This property holds the starting value for the animation.
-
- If the Vector3dAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-QVector3D QDeclarative1Vector3dAnimation::from() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->from.value<QVector3D>();
-}
-
-void QDeclarative1Vector3dAnimation::setFrom(QVector3D f)
-{
- QDeclarative1PropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real QtQuick1::Vector3dAnimation::to
- This property holds the end value for the animation.
-
- If the Vector3dAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-QVector3D QDeclarative1Vector3dAnimation::to() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->to.value<QVector3D>();
-}
-
-void QDeclarative1Vector3dAnimation::setTo(QVector3D t)
-{
- QDeclarative1PropertyAnimation::setTo(t);
-}
-
-
-
-/*!
- \qmlclass RotationAnimation QDeclarative1RotationAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits PropertyAnimation
- \brief The RotationAnimation element animates changes in rotation values.
-
- RotationAnimation is a specialized PropertyAnimation that gives control
- over the direction of rotation during an animation.
-
- By default, it rotates in the direction
- of the numerical change; a rotation from 0 to 240 will rotate 240 degrees
- clockwise, while a rotation from 240 to 0 will rotate 240 degrees
- counterclockwise. The \l direction property can be set to specify the
- direction in which the rotation should occur.
-
- In the following example we use RotationAnimation to animate the rotation
- between states via the shortest path:
-
- \snippet doc/src/snippets/qtquick1/rotationanimation.qml 0
-
- Notice the RotationAnimation did not need to set a \l target
- value. As a convenience, when used in a transition, RotationAnimation will rotate all
- properties named "rotation" or "angle". You can override this by providing
- your own properties via \l {PropertyAnimation::properties}{properties} or
- \l {PropertyAnimation::property}{property}.
-
- Also, note the \l Rectangle will be rotated around its default
- \l {Item::}{transformOrigin} (which is \c Item.Center). To use a different
- transform origin, set the origin in the PropertyChanges object and apply
- the change at the start of the animation using PropertyAction. See the
- PropertyAction documentation for more details.
-
- Like any other animation element, a RotationAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff > 180.0){
- newt -= 360.0;
- diff -= 360.0;
- }
- while(diff < -180.0){
- newt += 360.0;
- diff += 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff < 0.0){
- newt += 360.0;
- diff += 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff > 0.0){
- newt -= 360.0;
- diff -= 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QDeclarative1RotationAnimation::QDeclarative1RotationAnimation(QObject *parent)
-: QDeclarative1PropertyAnimation(*(new QDeclarative1RotationAnimationPrivate), parent)
-{
- Q_D(QDeclarative1RotationAnimation);
- d->interpolatorType = QMetaType::QReal;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultProperties = QLatin1String("rotation,angle");
-}
-
-QDeclarative1RotationAnimation::~QDeclarative1RotationAnimation()
-{
-}
-
-/*!
- \qmlproperty real QtQuick1::RotationAnimation::from
- This property holds the starting value for the animation.
-
- For example, the following animation is not applied until the \c angle value
- has reached 100:
-
- \qml
- Item {
- states: [
- // ...
- ]
-
- transition: Transition {
- RotationAnimation { properties: "angle"; from: 100; duration: 2000 }
- }
- }
- \endqml
-
- If the RotationAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-qreal QDeclarative1RotationAnimation::from() const
-{
- Q_D(const QDeclarative1RotationAnimation);
- return d->from.toReal();
-}
-
-void QDeclarative1RotationAnimation::setFrom(qreal f)
-{
- QDeclarative1PropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real QtQuick1::RotationAnimation::to
- This property holds the end value for the animation..
-
- If the RotationAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-qreal QDeclarative1RotationAnimation::to() const
-{
- Q_D(const QDeclarative1RotationAnimation);
- return d->to.toReal();
-}
-
-void QDeclarative1RotationAnimation::setTo(qreal t)
-{
- QDeclarative1PropertyAnimation::setTo(t);
-}
-
-/*!
- \qmlproperty enumeration QtQuick1::RotationAnimation::direction
- This property holds the direction of the rotation.
-
- Possible values are:
-
- \list
- \o RotationAnimation.Numerical (default) - Rotate by linearly interpolating between the two numbers.
- A rotation from 10 to 350 will rotate 340 degrees clockwise.
- \o RotationAnimation.Clockwise - Rotate clockwise between the two values
- \o RotationAnimation.Counterclockwise - Rotate counterclockwise between the two values
- \o RotationAnimation.Shortest - Rotate in the direction that produces the shortest animation path.
- A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
- \endlist
-*/
-QDeclarative1RotationAnimation::RotationDirection QDeclarative1RotationAnimation::direction() const
-{
- Q_D(const QDeclarative1RotationAnimation);
- return d->direction;
-}
-
-void QDeclarative1RotationAnimation::setDirection(QDeclarative1RotationAnimation::RotationDirection direction)
-{
- Q_D(QDeclarative1RotationAnimation);
- if (d->direction == direction)
- return;
-
- d->direction = direction;
- switch(d->direction) {
- case Clockwise:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation);
- break;
- case Counterclockwise:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation);
- break;
- case Shortest:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
- break;
- default:
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- break;
- }
-
- emit directionChanged();
-}
-
-
-
-QDeclarative1AnimationGroup::QDeclarative1AnimationGroup(QObject *parent)
-: QDeclarative1AbstractAnimation(*(new QDeclarative1AnimationGroupPrivate), parent)
-{
-}
-
-QDeclarative1AnimationGroup::QDeclarative1AnimationGroup(QDeclarative1AnimationGroupPrivate &dd, QObject *parent)
- : QDeclarative1AbstractAnimation(dd, parent)
-{
-}
-
-void QDeclarative1AnimationGroupPrivate::append_animation(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list, QDeclarative1AbstractAnimation *a)
-{
- QDeclarative1AnimationGroup *q = qobject_cast<QDeclarative1AnimationGroup *>(list->object);
- if (q) {
- a->setGroup(q);
- // This is an optimization for the parenting that already occurs via addAnimation
- QDeclarative_setParent_noEvent(a->qtAnimation(), q->d_func()->ag);
- q->d_func()->ag->addAnimation(a->qtAnimation());
- }
-}
-
-void QDeclarative1AnimationGroupPrivate::clear_animation(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list)
-{
- QDeclarative1AnimationGroup *q = qobject_cast<QDeclarative1AnimationGroup *>(list->object);
- if (q) {
- while (q->d_func()->animations.count()) {
- QDeclarative1AbstractAnimation *firstAnim = q->d_func()->animations.at(0);
- QDeclarative_setParent_noEvent(firstAnim->qtAnimation(), 0);
- q->d_func()->ag->removeAnimation(firstAnim->qtAnimation());
- firstAnim->setGroup(0);
- }
- }
-}
-
-QDeclarative1AnimationGroup::~QDeclarative1AnimationGroup()
-{
-}
-
-QDeclarativeListProperty<QDeclarative1AbstractAnimation> QDeclarative1AnimationGroup::animations()
-{
- Q_D(QDeclarative1AnimationGroup);
- QDeclarativeListProperty<QDeclarative1AbstractAnimation> list(this, d->animations);
- list.append = &QDeclarative1AnimationGroupPrivate::append_animation;
- list.clear = &QDeclarative1AnimationGroupPrivate::clear_animation;
- return list;
-}
-
-/*!
- \qmlclass SequentialAnimation QDeclarative1SequentialAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits Animation
- \brief The SequentialAnimation element allows animations to be run sequentially.
-
- The SequentialAnimation and ParallelAnimation elements allow multiple
- animations to be run together. Animations defined in a SequentialAnimation
- are run one after the other, while animations defined in a ParallelAnimation
- are run at the same time.
-
- The following example runs two number animations in a sequence. The \l Rectangle
- animates to a \c x position of 50, then to a \c y position of 50.
-
- \snippet doc/src/snippets/qtquick1/sequentialanimation.qml 0
-
- Animations defined within a \l Transition are automatically run in parallel,
- so SequentialAnimation can be used to enclose the animations in a \l Transition
- if this is the preferred behavior.
-
- Like any other animation element, a SequentialAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \note Once an animation has been grouped into a SequentialAnimation or
- ParallelAnimation, it cannot be individually started and stopped; the
- SequentialAnimation or ParallelAnimation must be started and stopped as a group.
-
- \sa ParallelAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-
-QDeclarative1SequentialAnimation::QDeclarative1SequentialAnimation(QObject *parent) :
- QDeclarative1AnimationGroup(parent)
-{
- Q_D(QDeclarative1AnimationGroup);
- d->ag = new QSequentialAnimationGroup;
- QDeclarative_setParent_noEvent(d->ag, this);
-}
-
-QDeclarative1SequentialAnimation::~QDeclarative1SequentialAnimation()
-{
-}
-
-QAbstractAnimation *QDeclarative1SequentialAnimation::qtAnimation()
-{
- Q_D(QDeclarative1AnimationGroup);
- return d->ag;
-}
-
-void QDeclarative1SequentialAnimation::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarative1AnimationGroup);
-
- int inc = 1;
- int from = 0;
- if (direction == Backward) {
- inc = -1;
- from = d->animations.count() - 1;
- }
-
- bool valid = d->defaultProperty.isValid();
- for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
- if (valid)
- d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
- d->animations.at(ii)->transition(actions, modified, direction);
- }
-}
-
-
-
-/*!
- \qmlclass ParallelAnimation QDeclarative1ParallelAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits Animation
- \brief The ParallelAnimation element allows animations to be run in parallel.
-
- The SequentialAnimation and ParallelAnimation elements allow multiple
- animations to be run together. Animations defined in a SequentialAnimation
- are run one after the other, while animations defined in a ParallelAnimation
- are run at the same time.
-
- The following animation runs two number animations in parallel. The \l Rectangle
- moves to (50,50) by animating its \c x and \c y properties at the same time.
-
- \snippet doc/src/snippets/qtquick1/parallelanimation.qml 0
-
- Like any other animation element, a ParallelAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \note Once an animation has been grouped into a SequentialAnimation or
- ParallelAnimation, it cannot be individually started and stopped; the
- SequentialAnimation or ParallelAnimation must be started and stopped as a group.
-
- \sa SequentialAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarative1ParallelAnimation::QDeclarative1ParallelAnimation(QObject *parent) :
- QDeclarative1AnimationGroup(parent)
-{
- Q_D(QDeclarative1AnimationGroup);
- d->ag = new QParallelAnimationGroup;
- QDeclarative_setParent_noEvent(d->ag, this);
-}
-
-QDeclarative1ParallelAnimation::~QDeclarative1ParallelAnimation()
-{
-}
-
-QAbstractAnimation *QDeclarative1ParallelAnimation::qtAnimation()
-{
- Q_D(QDeclarative1AnimationGroup);
- return d->ag;
-}
-
-void QDeclarative1ParallelAnimation::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarative1AnimationGroup);
- bool valid = d->defaultProperty.isValid();
- for (int ii = 0; ii < d->animations.count(); ++ii) {
- if (valid)
- d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
- d->animations.at(ii)->transition(actions, modified, direction);
- }
-}
-
-
-
-//convert a variant from string type to another animatable type
-void QDeclarative1PropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
-{
- if (variant.userType() != QVariant::String) {
- variant.convert((QVariant::Type)type);
- return;
- }
-
- switch (type) {
- case QVariant::Rect: {
- variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()).toRect());
- break;
- }
- case QVariant::RectF: {
- variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()));
- break;
- }
- case QVariant::Point: {
- variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()).toPoint());
- break;
- }
- case QVariant::PointF: {
- variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()));
- break;
- }
- case QVariant::Size: {
- variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()).toSize());
- break;
- }
- case QVariant::SizeF: {
- variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()));
- break;
- }
- case QVariant::Color: {
- variant.setValue(QDeclarativeStringConverters::colorFromString(variant.toString()));
- break;
- }
- case QVariant::Vector3D: {
- variant.setValue(QDeclarativeStringConverters::vector3DFromString(variant.toString()));
- break;
- }
- default:
- if (QDeclarativeValueTypeFactory::isValueType((uint)type)) {
- variant.convert((QVariant::Type)type);
- } else {
- QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
- if (converter)
- variant = converter(variant.toString());
- }
- break;
- }
-}
-
-/*!
- \qmlclass PropertyAnimation QDeclarative1PropertyAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits Animation
- \brief The PropertyAnimation element animates changes in property values.
-
- PropertyAnimation provides a way to animate changes to a property's value.
-
- It can be used to define animations in a number of ways:
-
- \list
- \o In a \l Transition
-
- For example, to animate any objects that have changed their \c x or \c y properties
- as a result of a state change, using an \c InOutQuad easing curve:
-
- \snippet doc/src/snippets/qtquick1/propertyanimation.qml transition
-
-
- \o In a \l Behavior
-
- For example, to animate all changes to a rectangle's \c x property:
-
- \snippet doc/src/snippets/qtquick1/propertyanimation.qml behavior
-
-
- \o As a property value source
-
- For example, to repeatedly animate the rectangle's \c x property:
-
- \snippet doc/src/snippets/qtquick1/propertyanimation.qml propertyvaluesource
-
-
- \o In a signal handler
-
- For example, to fade out \c theObject when clicked:
- \qml
- MouseArea {
- anchors.fill: theObject
- onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
- }
- \endqml
-
- \o Standalone
-
- For example, to animate \c rect's \c width property over 500ms, from its current width to 30:
-
- \snippet doc/src/snippets/qtquick1/propertyanimation.qml standalone
-
- \endlist
-
- Depending on how the animation is used, the set of properties normally used will be
- different. For more information see the individual property documentation, as well
- as the \l{QML Animation and Transitions} introduction.
-
- Note that PropertyAnimation inherits the abstract \l Animation element.
- This includes additional properties and methods for controlling the animation.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-
-QDeclarative1PropertyAnimation::QDeclarative1PropertyAnimation(QObject *parent)
-: QDeclarative1AbstractAnimation(*(new QDeclarative1PropertyAnimationPrivate), parent)
-{
- Q_D(QDeclarative1PropertyAnimation);
- d->init();
-}
-
-QDeclarative1PropertyAnimation::QDeclarative1PropertyAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent)
-: QDeclarative1AbstractAnimation(dd, parent)
-{
- Q_D(QDeclarative1PropertyAnimation);
- d->init();
-}
-
-QDeclarative1PropertyAnimation::~QDeclarative1PropertyAnimation()
-{
-}
-
-void QDeclarative1PropertyAnimationPrivate::init()
-{
- Q_Q(QDeclarative1PropertyAnimation);
- va = new QDeclarative1BulkValueAnimator;
- QDeclarative_setParent_noEvent(va, q);
-}
-
-/*!
- \qmlproperty int QtQuick1::PropertyAnimation::duration
- This property holds the duration of the animation, in milliseconds.
-
- The default value is 250.
-*/
-int QDeclarative1PropertyAnimation::duration() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->va->duration();
-}
-
-void QDeclarative1PropertyAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QDeclarative1PropertyAnimation);
- if (d->va->duration() == duration)
- return;
- d->va->setDuration(duration);
- emit durationChanged(duration);
-}
-
-/*!
- \qmlproperty real QtQuick1::PropertyAnimation::from
- This property holds the starting value for the animation.
-
- If the PropertyAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the starting state of the
- \l Transition, or the current value of the property at the moment the
- \l Behavior is triggered.
-
- \sa {QML Animation and Transitions}
-*/
-QVariant QDeclarative1PropertyAnimation::from() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->from;
-}
-
-void QDeclarative1PropertyAnimation::setFrom(const QVariant &f)
-{
- Q_D(QDeclarative1PropertyAnimation);
- if (d->fromIsDefined && f == d->from)
- return;
- d->from = f;
- d->fromIsDefined = f.isValid();
- emit fromChanged(f);
-}
-
-/*!
- \qmlproperty real QtQuick1::PropertyAnimation::to
- This property holds the end value for the animation.
-
- If the PropertyAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-
- \sa {QML Animation and Transitions}
-*/
-QVariant QDeclarative1PropertyAnimation::to() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->to;
-}
-
-void QDeclarative1PropertyAnimation::setTo(const QVariant &t)
-{
- Q_D(QDeclarative1PropertyAnimation);
- if (d->toIsDefined && t == d->to)
- return;
- d->to = t;
- d->toIsDefined = t.isValid();
- emit toChanged(t);
-}
-
-/*!
- \qmlproperty enumeration QtQuick1::PropertyAnimation::easing.type
- \qmlproperty real QtQuick1::PropertyAnimation::easing.amplitude
- \qmlproperty real QtQuick1::PropertyAnimation::easing.overshoot
- \qmlproperty real QtQuick1::PropertyAnimation::easing.period
- \brief the easing curve used for the animation.
-
- To specify an easing curve you need to specify at least the type. For some curves you can also specify
- amplitude, period and/or overshoot (more details provided after the table). The default easing curve is
- \c Easing.Linear.
-
- \qml
- PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 }
- \endqml
-
- Available types are:
-
- \table
- \row
- \o \c Easing.Linear
- \o Easing curve for a linear (t) function: velocity is constant.
- \o \inlineimage qeasingcurve-linear.png
- \row
- \o \c Easing.InQuad
- \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquad.png
- \row
- \o \c Easing.OutQuad
- \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity.
- \o \inlineimage qeasingcurve-outquad.png
- \row
- \o \c Easing.InOutQuad
- \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquad.png
- \row
- \o \c Easing.OutInQuad
- \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquad.png
- \row
- \o \c Easing.InCubic
- \o Easing curve for a cubic (t^3) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-incubic.png
- \row
- \o \c Easing.OutCubic
- \o Easing curve for a cubic (t^3) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outcubic.png
- \row
- \o \c Easing.InOutCubic
- \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutcubic.png
- \row
- \o \c Easing.OutInCubic
- \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outincubic.png
- \row
- \o \c Easing.InQuart
- \o Easing curve for a quartic (t^4) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquart.png
- \row
- \o \c Easing.OutQuart
- \o Easing curve for a quartic (t^4) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outquart.png
- \row
- \o \c Easing.InOutQuart
- \o Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquart.png
- \row
- \o \c Easing.OutInQuart
- \o Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquart.png
- \row
- \o \c Easing.InQuint
- \o Easing curve for a quintic (t^5) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquint.png
- \row
- \o \c Easing.OutQuint
- \o Easing curve for a quintic (t^5) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outquint.png
- \row
- \o \c Easing.InOutQuint
- \o Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquint.png
- \row
- \o \c Easing.OutInQuint
- \o Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquint.png
- \row
- \o \c Easing.InSine
- \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-insine.png
- \row
- \o \c Easing.OutSine
- \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outsine.png
- \row
- \o \c Easing.InOutSine
- \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutsine.png
- \row
- \o \c Easing.OutInSine
- \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinsine.png
- \row
- \o \c Easing.InExpo
- \o Easing curve for an exponential (2^t) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inexpo.png
- \row
- \o \c Easing.OutExpo
- \o Easing curve for an exponential (2^t) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outexpo.png
- \row
- \o \c Easing.InOutExpo
- \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutexpo.png
- \row
- \o \c Easing.OutInExpo
- \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinexpo.png
- \row
- \o \c Easing.InCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-incirc.png
- \row
- \o \c Easing.OutCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outcirc.png
- \row
- \o \c Easing.InOutCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutcirc.png
- \row
- \o \c Easing.OutInCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outincirc.png
- \row
- \o \c Easing.InElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity.
- \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
- \o \inlineimage qeasingcurve-inelastic.png
- \row
- \o \c Easing.OutElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity.
- \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
- \o \inlineimage qeasingcurve-outelastic.png
- \row
- \o \c Easing.InOutElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutelastic.png
- \row
- \o \c Easing.OutInElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinelastic.png
- \row
- \o \c Easing.InBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inback.png
- \row
- \o \c Easing.OutBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.
- \o \inlineimage qeasingcurve-outback.png
- \row
- \o \c Easing.InOutBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutback.png
- \row
- \o \c Easing.OutInBack
- \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinback.png
- \row
- \o \c Easing.InBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inbounce.png
- \row
- \o \c Easing.OutBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outbounce.png
- \row
- \o \c Easing.InOutBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutbounce.png
- \row
- \o \c Easing.OutInBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinbounce.png
- \endtable
-
- \c easing.amplitude is only applicable for bounce and elastic curves (curves of type
- \c Easing.InBounce, \c Easing.OutBounce, \c Easing.InOutBounce, \c Easing.OutInBounce, \c Easing.InElastic,
- \c Easing.OutElastic, \c Easing.InOutElastic or \c Easing.OutInElastic).
-
- \c easing.overshoot is only applicable if \c easing.type is: \c Easing.InBack, \c Easing.OutBack,
- \c Easing.InOutBack or \c Easing.OutInBack.
-
- \c easing.period is only applicable if easing.type is: \c Easing.InElastic, \c Easing.OutElastic,
- \c Easing.InOutElastic or \c Easing.OutInElastic.
-
- See the \l {declarative/animation/easing}{easing} example for a demonstration of
- the different easing settings.
-*/
-QEasingCurve QDeclarative1PropertyAnimation::easing() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->va->easingCurve();
-}
-
-void QDeclarative1PropertyAnimation::setEasing(const QEasingCurve &e)
-{
- Q_D(QDeclarative1PropertyAnimation);
- if (d->va->easingCurve() == e)
- return;
-
- d->va->setEasingCurve(e);
- emit easingChanged(e);
-}
-
-QObject *QDeclarative1PropertyAnimation::target() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->target;
-}
-
-void QDeclarative1PropertyAnimation::setTarget(QObject *o)
-{
- Q_D(QDeclarative1PropertyAnimation);
- if (d->target == o)
- return;
- d->target = o;
- emit targetChanged();
-}
-
-QString QDeclarative1PropertyAnimation::property() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->propertyName;
-}
-
-void QDeclarative1PropertyAnimation::setProperty(const QString &n)
-{
- Q_D(QDeclarative1PropertyAnimation);
- if (d->propertyName == n)
- return;
- d->propertyName = n;
- emit propertyChanged();
-}
-
-QString QDeclarative1PropertyAnimation::properties() const
-{
- Q_D(const QDeclarative1PropertyAnimation);
- return d->properties;
-}
-
-void QDeclarative1PropertyAnimation::setProperties(const QString &prop)
-{
- Q_D(QDeclarative1PropertyAnimation);
- if (d->properties == prop)
- return;
-
- d->properties = prop;
- emit propertiesChanged(prop);
-}
-
-/*!
- \qmlproperty string QtQuick1::PropertyAnimation::properties
- \qmlproperty list<Object> QtQuick1::PropertyAnimation::targets
- \qmlproperty string QtQuick1::PropertyAnimation::property
- \qmlproperty Object QtQuick1::PropertyAnimation::target
-
- These properties are used as a set to determine which properties should be animated.
- The singular and plural forms are functionally identical, e.g.
- \qml
- NumberAnimation { target: theItem; property: "x"; to: 500 }
- \endqml
- has the same meaning as
- \qml
- NumberAnimation { targets: theItem; properties: "x"; to: 500 }
- \endqml
- The singular forms are slightly optimized, so if you do have only a single target/property
- to animate you should try to use them.
-
- The \c targets property allows multiple targets to be set. For example, this animates the
- \c x property of both \c itemA and \c itemB:
-
- \qml
- NumberAnimation { targets: [itemA, itemB]; properties: "x"; to: 500 }
- \endqml
-
- In many cases these properties do not need to be explicitly specified, as they can be
- inferred from the animation framework:
-
- \table 80%
- \row
- \o Value Source / Behavior
- \o When an animation is used as a value source or in a Behavior, the default target and property
- name to be animated can both be inferred.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- NumberAnimation on x { to: 500; loops: Animation.Infinite } //animate theRect's x property
- Behavior on y { NumberAnimation {} } //animate theRect's y property
- }
- \endqml
- \row
- \o Transition
- \o When used in a transition, a property animation is assumed to match \e all targets
- but \e no properties. In practice, that means you need to specify at least the properties
- in order for the animation to do anything.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- Item { id: uselessItem }
- states: State {
- name: "state1"
- PropertyChanges { target: theRect; x: 200; y: 200; z: 4 }
- PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 }
- }
- transitions: Transition {
- //animate both theRect's and uselessItem's x and y to their final values
- NumberAnimation { properties: "x,y" }
-
- //animate theRect's z to its final value
- NumberAnimation { target: theRect; property: "z" }
- }
- }
- \endqml
- \row
- \o Standalone
- \o When an animation is used standalone, both the target and property need to be
- explicitly specified.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- //need to explicitly specify target and property
- NumberAnimation { id: theAnim; target: theRect; property: "x"; to: 500 }
- MouseArea {
- anchors.fill: parent
- onClicked: theAnim.start()
- }
- }
- \endqml
- \endtable
-
- As seen in the above example, properties is specified as a comma-separated string of property names to animate.
-
- \sa exclude, {QML Animation and Transitions}
-*/
-QDeclarativeListProperty<QObject> QDeclarative1PropertyAnimation::targets()
-{
- Q_D(QDeclarative1PropertyAnimation);
- return QDeclarativeListProperty<QObject>(this, d->targets);
-}
-
-/*!
- \qmlproperty list<Object> QtQuick1::PropertyAnimation::exclude
- This property holds the items not to be affected by this animation.
- \sa PropertyAnimation::targets
-*/
-QDeclarativeListProperty<QObject> QDeclarative1PropertyAnimation::exclude()
-{
- Q_D(QDeclarative1PropertyAnimation);
- return QDeclarativeListProperty<QObject>(this, d->exclude);
-}
-
-QAbstractAnimation *QDeclarative1PropertyAnimation::qtAnimation()
-{
- Q_D(QDeclarative1PropertyAnimation);
- return d->va;
-}
-
-void QDeclarative1AnimationPropertyUpdater::setValue(qreal v)
-{
- bool deleted = false;
- wasDeleted = &deleted;
- if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
- v = 1 - v;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarative1Action &action = actions[ii];
-
- if (v == 1.)
- QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- else {
- if (!fromSourced && !fromDefined) {
- action.fromValue = action.property.read();
- if (interpolatorType)
- QDeclarative1PropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
- }
- if (!interpolatorType) {
- int propType = action.property.propertyType();
- if (!prevInterpolatorType || prevInterpolatorType != propType) {
- prevInterpolatorType = propType;
- interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
- }
- }
- if (interpolator)
- QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- }
- if (deleted)
- return;
- }
- wasDeleted = 0;
- fromSourced = true;
-}
-
-void QDeclarative1PropertyAnimation::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarative1PropertyAnimation);
-
- QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
- props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty())
- props << d->propertyName;
-
- QList<QObject*> targets = d->targets;
- if (d->target)
- targets.append(d->target);
-
- bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
- bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
-
- if (d->defaultProperty.isValid() && !hasSelectors) {
- props << d->defaultProperty.name();
- targets << d->defaultProperty.object();
- }
-
- if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
- props << d->defaultProperties.split(QLatin1Char(','));
- }
-
- QDeclarative1AnimationPropertyUpdater *data = new QDeclarative1AnimationPropertyUpdater;
- data->interpolatorType = d->interpolatorType;
- data->interpolator = d->interpolator;
- data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = d->fromIsDefined;
-
- bool hasExplicit = false;
- //an explicit animation has been specified
- if (d->toIsDefined) {
- for (int i = 0; i < props.count(); ++i) {
- for (int j = 0; j < targets.count(); ++j) {
- QDeclarative1Action myAction;
- myAction.property = d->createProperty(targets.at(j), props.at(i), this);
- if (myAction.property.isValid()) {
- if (d->fromIsDefined) {
- myAction.fromValue = d->from;
- d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- }
- myAction.toValue = d->to;
- d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarative1Action &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
- }
- }
- }
- }
- }
- }
-
- if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarative1Action &action = actions[ii];
-
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
- QObject *sObj = action.specifiedObject;
- QString sPropertyName = action.specifiedProperty;
- bool same = (obj == sObj);
-
- if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
- (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName))
- || (useType && action.property.propertyType() == d->interpolatorType))) {
- QDeclarative1Action myAction = action;
-
- if (d->fromIsDefined)
- myAction.fromValue = d->from;
- else
- myAction.fromValue = QVariant();
- if (d->toIsDefined)
- myAction.toValue = d->to;
-
- d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
-
- modified << action.property;
-
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
-
- if (data->actions.count()) {
- if (!d->rangeIsSet) {
- d->va->setStartValue(qreal(0));
- d->va->setEndValue(qreal(1));
- d->rangeIsSet = true;
- }
- d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
- d->va->setFromSourcedValue(&data->fromSourced);
- d->actions = &data->actions;
- } else {
- delete data;
- d->va->setFromSourcedValue(0); //clear previous data
- d->va->setAnimValue(0, QAbstractAnimation::DeleteWhenStopped); //clear previous data
- d->actions = 0;
- }
-}
-
-/*!
- \qmlclass ParentAnimation QDeclarative1ParentAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits Animation
- \brief The ParentAnimation element animates changes in parent values.
-
- ParentAnimation is used to animate a parent change for an \l Item.
-
- For example, the following ParentChange changes \c blueRect to become
- a child of \c redRect when it is clicked. The inclusion of the
- ParentAnimation, which defines a NumberAnimation to be applied during
- the transition, ensures the item animates smoothly as it moves to
- its new parent:
-
- \snippet doc/src/snippets/qtquick1/parentanimation.qml 0
-
- A ParentAnimation can contain any number of animations. These animations will
- be run in parallel; to run them sequentially, define them within a
- SequentialAnimation.
-
- In some cases, such as when reparenting between items with clipping enabled, it is useful
- to animate the parent change via another item that does not have clipping
- enabled. Such an item can be set using the \l via property.
-
- For convenience, when a ParentAnimation is used in a \l Transition, it will
- animate any ParentChange that has occurred during the state change.
- This can be overridden by setting a specific target item using the
- \l target property.
-
- Like any other animation element, a ParentAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-QDeclarative1ParentAnimation::QDeclarative1ParentAnimation(QObject *parent)
- : QDeclarative1AnimationGroup(*(new QDeclarative1ParentAnimationPrivate), parent)
-{
- Q_D(QDeclarative1ParentAnimation);
- d->topLevelGroup = new QSequentialAnimationGroup;
- QDeclarative_setParent_noEvent(d->topLevelGroup, this);
-
- d->startAction = new QActionAnimation_1;
- QDeclarative_setParent_noEvent(d->startAction, d->topLevelGroup);
- d->topLevelGroup->addAnimation(d->startAction);
-
- d->ag = new QParallelAnimationGroup;
- QDeclarative_setParent_noEvent(d->ag, d->topLevelGroup);
- d->topLevelGroup->addAnimation(d->ag);
-
- d->endAction = new QActionAnimation_1;
- QDeclarative_setParent_noEvent(d->endAction, d->topLevelGroup);
- d->topLevelGroup->addAnimation(d->endAction);
-}
-
-QDeclarative1ParentAnimation::~QDeclarative1ParentAnimation()
-{
-}
-
-/*!
- \qmlproperty Item QtQuick1::ParentAnimation::target
- The item to reparent.
-
- When used in a transition, if no target is specified, all
- ParentChange occurrences are animated by the ParentAnimation.
-*/
-QDeclarativeItem *QDeclarative1ParentAnimation::target() const
-{
- Q_D(const QDeclarative1ParentAnimation);
- return d->target;
-}
-
-void QDeclarative1ParentAnimation::setTarget(QDeclarativeItem *target)
-{
- Q_D(QDeclarative1ParentAnimation);
- if (target == d->target)
- return;
-
- d->target = target;
- emit targetChanged();
-}
-
-/*!
- \qmlproperty Item QtQuick1::ParentAnimation::newParent
- The new parent to animate to.
-
- If the ParentAnimation is defined within a \l Transition or \l Behavior,
- this value defaults to the value defined in the end state of the
- \l Transition, or the value of the property change that triggered the
- \l Behavior.
-*/
-QDeclarativeItem *QDeclarative1ParentAnimation::newParent() const
-{
- Q_D(const QDeclarative1ParentAnimation);
- return d->newParent;
-}
-
-void QDeclarative1ParentAnimation::setNewParent(QDeclarativeItem *newParent)
-{
- Q_D(QDeclarative1ParentAnimation);
- if (newParent == d->newParent)
- return;
-
- d->newParent = newParent;
- emit newParentChanged();
-}
-
-/*!
- \qmlproperty Item QtQuick1::ParentAnimation::via
- The item to reparent via. This provides a way to do an unclipped animation
- when both the old parent and new parent are clipped.
-
- \qml
- ParentAnimation {
- target: myItem
- via: topLevelItem
- // ...
- }
- \endqml
-*/
-QDeclarativeItem *QDeclarative1ParentAnimation::via() const
-{
- Q_D(const QDeclarative1ParentAnimation);
- return d->via;
-}
-
-void QDeclarative1ParentAnimation::setVia(QDeclarativeItem *via)
-{
- Q_D(QDeclarative1ParentAnimation);
- if (via == d->via)
- return;
-
- d->via = via;
- emit viaChanged();
-}
-
-//### mirrors same-named function in QDeclarativeItem
-QPointF QDeclarative1ParentAnimationPrivate::computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const
-{
- switch(origin) {
- default:
- case QDeclarativeItem::TopLeft:
- return QPointF(0, 0);
- case QDeclarativeItem::Top:
- return QPointF(width / 2., 0);
- case QDeclarativeItem::TopRight:
- return QPointF(width, 0);
- case QDeclarativeItem::Left:
- return QPointF(0, height / 2.);
- case QDeclarativeItem::Center:
- return QPointF(width / 2., height / 2.);
- case QDeclarativeItem::Right:
- return QPointF(width, height / 2.);
- case QDeclarativeItem::BottomLeft:
- return QPointF(0, height);
- case QDeclarativeItem::Bottom:
- return QPointF(width / 2., height);
- case QDeclarativeItem::BottomRight:
- return QPointF(width, height);
- }
-}
-
-void QDeclarative1ParentAnimation::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarative1ParentAnimation);
-
- struct QDeclarative1ParentAnimationData : public QAbstractAnimationAction
- {
- QDeclarative1ParentAnimationData() {}
- ~QDeclarative1ParentAnimationData() { qDeleteAll(pc); }
-
- QDeclarative1StateActions actions;
- //### reverse should probably apply on a per-action basis
- bool reverse;
- QList<QDeclarative1ParentChange *> pc;
- virtual void doAction()
- {
- for (int ii = 0; ii < actions.count(); ++ii) {
- const QDeclarative1Action &action = actions.at(ii);
- if (reverse)
- action.event->reverse();
- else
- action.event->execute();
- }
- }
- };
-
- QDeclarative1ParentAnimationData *data = new QDeclarative1ParentAnimationData;
- QDeclarative1ParentAnimationData *viaData = new QDeclarative1ParentAnimationData;
-
- bool hasExplicit = false;
- if (d->target && d->newParent) {
- data->reverse = false;
- QDeclarative1Action myAction;
- QDeclarative1ParentChange *pc = new QDeclarative1ParentChange;
- pc->setObject(d->target);
- pc->setParent(d->newParent);
- myAction.event = pc;
- data->pc << pc;
- data->actions << myAction;
- hasExplicit = true;
- if (d->via) {
- viaData->reverse = false;
- QDeclarative1Action myVAction;
- QDeclarative1ParentChange *vpc = new QDeclarative1ParentChange;
- vpc->setObject(d->target);
- vpc->setParent(d->via);
- myVAction.event = vpc;
- viaData->pc << vpc;
- viaData->actions << myVAction;
- }
- //### once actions have concept of modified,
- // loop to match appropriate ParentChanges and mark as modified
- }
-
- if (!hasExplicit)
- for (int i = 0; i < actions.size(); ++i) {
- QDeclarative1Action &action = actions[i];
- if (action.event && action.event->typeName() == QLatin1String("ParentChange")
- && (!d->target || static_cast<QDeclarative1ParentChange*>(action.event)->object() == d->target)) {
-
- QDeclarative1ParentChange *pc = static_cast<QDeclarative1ParentChange*>(action.event);
- QDeclarative1Action myAction = action;
- data->reverse = action.reverseEvent;
-
- //### this logic differs from PropertyAnimation
- // (probably a result of modified vs. done)
- if (d->newParent) {
- QDeclarative1ParentChange *epc = new QDeclarative1ParentChange;
- epc->setObject(static_cast<QDeclarative1ParentChange*>(action.event)->object());
- epc->setParent(d->newParent);
- myAction.event = epc;
- data->pc << epc;
- data->actions << myAction;
- pc = epc;
- } else {
- action.actionDone = true;
- data->actions << myAction;
- }
-
- if (d->via) {
- viaData->reverse = false;
- QDeclarative1Action myAction;
- QDeclarative1ParentChange *vpc = new QDeclarative1ParentChange;
- vpc->setObject(pc->object());
- vpc->setParent(d->via);
- myAction.event = vpc;
- viaData->pc << vpc;
- viaData->actions << myAction;
- QDeclarative1Action dummyAction;
- QDeclarative1Action &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
- QDeclarative1Action &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
- QDeclarative1Action &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
- QDeclarative1Action &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
- QDeclarativeItem *target = pc->object();
- QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent();
-
- //### this mirrors the logic in QDeclarative1ParentChange.
- bool ok;
- const QTransform &transform = targetParent->itemTransform(d->via, &ok);
- if (transform.type() >= QTransform::TxShear || !ok) {
- qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under complex transform");
- ok = false;
- }
-
- qreal scale = 1;
- qreal rotation = 0;
- bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0);
- if (ok && !isRotate) {
- if (transform.m11() == transform.m22())
- scale = transform.m11();
- else {
- qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
- ok = false;
- }
- } else if (ok && isRotate) {
- if (transform.m11() == transform.m22())
- scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
- else {
- qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
- ok = false;
- }
-
- if (scale != 0)
- rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
- else {
- qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under scale of 0");
- ok = false;
- }
- }
-
- const QPointF &point = transform.map(QPointF(xAction.toValue.toReal(),yAction.toValue.toReal()));
- qreal x = point.x();
- qreal y = point.y();
- if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) {
- qreal w = target->width();
- qreal h = target->height();
- if (pc->widthIsSet() && i < actions.size() - 1)
- w = actions[++i].toValue.toReal();
- if (pc->heightIsSet() && i < actions.size() - 1)
- h = actions[++i].toValue.toReal();
- const QPointF &transformOrigin
- = d->computeTransformOrigin(target->transformOrigin(), w,h);
- qreal tempxt = transformOrigin.x();
- qreal tempyt = transformOrigin.y();
- QTransform t;
- t.translate(-tempxt, -tempyt);
- t.rotate(rotation);
- t.scale(scale, scale);
- t.translate(tempxt, tempyt);
- const QPointF &offset = t.map(QPointF(0,0));
- x += offset.x();
- y += offset.y();
- }
-
- if (ok) {
- //qDebug() << x << y << rotation << scale;
- xAction.toValue = x;
- yAction.toValue = y;
- sAction.toValue = sAction.toValue.toReal() * scale;
- rAction.toValue = rAction.toValue.toReal() + rotation;
- }
- }
- }
- }
-
- if (data->actions.count()) {
- if (direction == QDeclarative1AbstractAnimation::Forward) {
- d->startAction->setAnimAction(d->via ? viaData : data, QActionAnimation_1::DeleteWhenStopped);
- d->endAction->setAnimAction(d->via ? data : 0, QActionAnimation_1::DeleteWhenStopped);
- } else {
- d->endAction->setAnimAction(d->via ? viaData : data, QActionAnimation_1::DeleteWhenStopped);
- d->startAction->setAnimAction(d->via ? data : 0, QActionAnimation_1::DeleteWhenStopped);
- }
- if (!d->via)
- delete viaData;
- } else {
- delete data;
- delete viaData;
- }
-
- //take care of any child animations
- bool valid = d->defaultProperty.isValid();
- for (int ii = 0; ii < d->animations.count(); ++ii) {
- if (valid)
- d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
- d->animations.at(ii)->transition(actions, modified, direction);
- }
-
-}
-
-QAbstractAnimation *QDeclarative1ParentAnimation::qtAnimation()
-{
- Q_D(QDeclarative1ParentAnimation);
- return d->topLevelGroup;
-}
-
-/*!
- \qmlclass AnchorAnimation QDeclarative1AnchorAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits Animation
- \brief The AnchorAnimation element animates changes in anchor values.
-
- AnchorAnimation is used to animate an anchor change.
-
- In the following snippet we animate the addition of a right anchor to a \l Rectangle:
-
- \snippet doc/src/snippets/qtquick1/anchoranimation.qml 0
-
- For convenience, when an AnchorAnimation is used in a \l Transition, it will
- animate any AnchorChanges that have occurred during the state change.
- This can be overridden by setting a specific target item using the
- \l target property.
-
- Like any other animation element, an AnchorAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa {QML Animation and Transitions}, AnchorChanges
-*/
-
-QDeclarative1AnchorAnimation::QDeclarative1AnchorAnimation(QObject *parent)
-: QDeclarative1AbstractAnimation(*(new QDeclarative1AnchorAnimationPrivate), parent)
-{
- Q_D(QDeclarative1AnchorAnimation);
- d->va = new QDeclarative1BulkValueAnimator;
- QDeclarative_setParent_noEvent(d->va, this);
-}
-
-QDeclarative1AnchorAnimation::~QDeclarative1AnchorAnimation()
-{
-}
-
-QAbstractAnimation *QDeclarative1AnchorAnimation::qtAnimation()
-{
- Q_D(QDeclarative1AnchorAnimation);
- return d->va;
-}
-
-/*!
- \qmlproperty list<Item> QtQuick1::AnchorAnimation::targets
- The items to reanchor.
-
- If no targets are specified all AnchorChanges will be
- animated by the AnchorAnimation.
-*/
-QDeclarativeListProperty<QDeclarativeItem> QDeclarative1AnchorAnimation::targets()
-{
- Q_D(QDeclarative1AnchorAnimation);
- return QDeclarativeListProperty<QDeclarativeItem>(this, d->targets);
-}
-
-/*!
- \qmlproperty int QtQuick1::AnchorAnimation::duration
- This property holds the duration of the animation, in milliseconds.
-
- The default value is 250.
-*/
-int QDeclarative1AnchorAnimation::duration() const
-{
- Q_D(const QDeclarative1AnchorAnimation);
- return d->va->duration();
-}
-
-void QDeclarative1AnchorAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QDeclarative1AnchorAnimation);
- if (d->va->duration() == duration)
- return;
- d->va->setDuration(duration);
- emit durationChanged(duration);
-}
-
-/*!
- \qmlproperty enumeration QtQuick1::AnchorAnimation::easing.type
- \qmlproperty real QtQuick1::AnchorAnimation::easing.amplitude
- \qmlproperty real QtQuick1::AnchorAnimation::easing.overshoot
- \qmlproperty real QtQuick1::AnchorAnimation::easing.period
- \brief the easing curve used for the animation.
-
- To specify an easing curve you need to specify at least the type. For some curves you can also specify
- amplitude, period and/or overshoot. The default easing curve is
- Linear.
-
- \qml
- AnchorAnimation { easing.type: Easing.InOutQuad }
- \endqml
-
- See the \l{PropertyAnimation::easing.type} documentation for information
- about the different types of easing curves.
-*/
-
-QEasingCurve QDeclarative1AnchorAnimation::easing() const
-{
- Q_D(const QDeclarative1AnchorAnimation);
- return d->va->easingCurve();
-}
-
-void QDeclarative1AnchorAnimation::setEasing(const QEasingCurve &e)
-{
- Q_D(QDeclarative1AnchorAnimation);
- if (d->va->easingCurve() == e)
- return;
-
- d->va->setEasingCurve(e);
- emit easingChanged(e);
-}
-
-void QDeclarative1AnchorAnimation::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_UNUSED(modified);
- Q_D(QDeclarative1AnchorAnimation);
- QDeclarative1AnimationPropertyUpdater *data = new QDeclarative1AnimationPropertyUpdater;
- data->interpolatorType = QMetaType::QReal;
- data->interpolator = d->interpolator;
-
- data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = false;
-
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarative1Action &action = actions[ii];
- if (action.event && action.event->typeName() == QLatin1String("AnchorChanges")
- && (d->targets.isEmpty() || d->targets.contains(static_cast<QDeclarative1AnchorChanges*>(action.event)->object()))) {
- data->actions << static_cast<QDeclarative1AnchorChanges*>(action.event)->additionalActions();
- }
- }
-
- if (data->actions.count()) {
- if (!d->rangeIsSet) {
- d->va->setStartValue(qreal(0));
- d->va->setEndValue(qreal(1));
- d->rangeIsSet = true;
- }
- d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
- d->va->setFromSourcedValue(&data->fromSourced);
- } else {
- delete data;
- }
-}
-
-QDeclarative1ScriptActionPrivate::QDeclarative1ScriptActionPrivate()
- : QDeclarative1AbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false), proxy(this), rsa(0) {}
-
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativeanimation_p.h b/src/qtquick1/util/qdeclarativeanimation_p.h
deleted file mode 100644
index a88d848436..0000000000
--- a/src/qtquick1/util/qdeclarativeanimation_p.h
+++ /dev/null
@@ -1,527 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEANIMATION_H
-#define QDECLARATIVEANIMATION_H
-
-#include "QtQuick1/private/qdeclarativetransition_p.h"
-#include "QtQuick1/private/qdeclarativestate_p.h"
-#include <QtGui/qvector3d.h>
-
-#include <QtDeclarative/qdeclarativepropertyvaluesource.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-
-#include <QtCore/qvariant.h>
-#include <QtCore/qeasingcurve.h>
-#include <QtCore/QAbstractAnimation>
-#include <QtGui/qcolor.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeItem;
-class QDeclarative1AbstractAnimationPrivate;
-class QDeclarative1AnimationGroup;
-class Q_QTQUICK1_EXPORT QDeclarative1AbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1AbstractAnimation)
-
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_INTERFACES(QDeclarativePropertyValueSource)
- Q_ENUMS(Loops)
- Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged)
- Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged)
- Q_CLASSINFO("DefaultMethod", "start()")
-
-public:
- QDeclarative1AbstractAnimation(QObject *parent=0);
- virtual ~QDeclarative1AbstractAnimation();
-
- enum Loops { Infinite = -2 };
-
- bool isRunning() const;
- void setRunning(bool);
- bool isPaused() const;
- void setPaused(bool);
- bool alwaysRunToEnd() const;
- void setAlwaysRunToEnd(bool);
-
- int loops() const;
- void setLoops(int);
-
- int currentTime();
- void setCurrentTime(int);
-
- QDeclarative1AnimationGroup *group() const;
- void setGroup(QDeclarative1AnimationGroup *);
-
- void setDefaultTarget(const QDeclarativeProperty &);
- void setDisableUserControl();
-
- void classBegin();
- void componentComplete();
-
-Q_SIGNALS:
- void started();
- void completed();
- void runningChanged(bool);
- void pausedChanged(bool);
- void alwaysRunToEndChanged(bool);
- void loopCountChanged(int);
-
-public Q_SLOTS:
- void restart();
- void start();
- void pause();
- void resume();
- void stop();
- void complete();
-
-protected:
- QDeclarative1AbstractAnimation(QDeclarative1AbstractAnimationPrivate &dd, QObject *parent);
-
-public:
- enum TransitionDirection { Forward, Backward };
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation() = 0;
-
-private Q_SLOTS:
- void timelineComplete();
- void componentFinalized();
-private:
- virtual void setTarget(const QDeclarativeProperty &);
- void notifyRunningChanged(bool running);
- friend class QDeclarative1Behavior;
-
-
-};
-
-class QDeclarative1PauseAnimationPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1PauseAnimation : public QDeclarative1AbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1PauseAnimation)
-
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
-
-public:
- QDeclarative1PauseAnimation(QObject *parent=0);
- virtual ~QDeclarative1PauseAnimation();
-
- int duration() const;
- void setDuration(int);
-
-Q_SIGNALS:
- void durationChanged(int);
-
-protected:
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QDeclarative1ScriptActionPrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1ScriptAction : public QDeclarative1AbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1ScriptAction)
-
- Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
-
-public:
- QDeclarative1ScriptAction(QObject *parent=0);
- virtual ~QDeclarative1ScriptAction();
-
- QDeclarativeScriptString script() const;
- void setScript(const QDeclarativeScriptString &);
-
- QString stateChangeScriptName() const;
- void setStateChangeScriptName(const QString &);
-
-protected:
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QDeclarative1PropertyActionPrivate;
-class QDeclarative1PropertyAction : public QDeclarative1AbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1PropertyAction)
-
- Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets)
- Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude)
- Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
-
-public:
- QDeclarative1PropertyAction(QObject *parent=0);
- virtual ~QDeclarative1PropertyAction();
-
- QObject *target() const;
- void setTarget(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QString properties() const;
- void setProperties(const QString &);
-
- QDeclarativeListProperty<QObject> targets();
- QDeclarativeListProperty<QObject> exclude();
-
- QVariant value() const;
- void setValue(const QVariant &);
-
-Q_SIGNALS:
- void valueChanged(const QVariant &);
- void propertiesChanged(const QString &);
- void targetChanged();
- void propertyChanged();
-
-protected:
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QDeclarative1PropertyAnimationPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1PropertyAnimation : public QDeclarative1AbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation)
-
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
- Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
- Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets)
- Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude)
-
-public:
- QDeclarative1PropertyAnimation(QObject *parent=0);
- virtual ~QDeclarative1PropertyAnimation();
-
- virtual int duration() const;
- virtual void setDuration(int);
-
- QVariant from() const;
- void setFrom(const QVariant &);
-
- QVariant to() const;
- void setTo(const QVariant &);
-
- QEasingCurve easing() const;
- void setEasing(const QEasingCurve &);
-
- QObject *target() const;
- void setTarget(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QString properties() const;
- void setProperties(const QString &);
-
- QDeclarativeListProperty<QObject> targets();
- QDeclarativeListProperty<QObject> exclude();
-
-protected:
- QDeclarative1PropertyAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent);
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-
-Q_SIGNALS:
- void durationChanged(int);
- void fromChanged(QVariant);
- void toChanged(QVariant);
- void easingChanged(const QEasingCurve &);
- void propertiesChanged(const QString &);
- void targetChanged();
- void propertyChanged();
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1ColorAnimation : public QDeclarative1PropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation)
- Q_PROPERTY(QColor from READ from WRITE setFrom)
- Q_PROPERTY(QColor to READ to WRITE setTo)
-
-public:
- QDeclarative1ColorAnimation(QObject *parent=0);
- virtual ~QDeclarative1ColorAnimation();
-
- QColor from() const;
- void setFrom(const QColor &);
-
- QColor to() const;
- void setTo(const QColor &);
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1NumberAnimation : public QDeclarative1PropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation)
-
- Q_PROPERTY(qreal from READ from WRITE setFrom)
- Q_PROPERTY(qreal to READ to WRITE setTo)
-
-public:
- QDeclarative1NumberAnimation(QObject *parent=0);
- virtual ~QDeclarative1NumberAnimation();
-
- qreal from() const;
- void setFrom(qreal);
-
- qreal to() const;
- void setTo(qreal);
-
-protected:
- QDeclarative1NumberAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent);
-
-private:
- void init();
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1Vector3dAnimation : public QDeclarative1PropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation)
-
- Q_PROPERTY(QVector3D from READ from WRITE setFrom)
- Q_PROPERTY(QVector3D to READ to WRITE setTo)
-
-public:
- QDeclarative1Vector3dAnimation(QObject *parent=0);
- virtual ~QDeclarative1Vector3dAnimation();
-
- QVector3D from() const;
- void setFrom(QVector3D);
-
- QVector3D to() const;
- void setTo(QVector3D);
-};
-
-class QDeclarative1RotationAnimationPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1RotationAnimation : public QDeclarative1PropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1RotationAnimation)
- Q_ENUMS(RotationDirection)
-
- Q_PROPERTY(qreal from READ from WRITE setFrom)
- Q_PROPERTY(qreal to READ to WRITE setTo)
- Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
-
-public:
- QDeclarative1RotationAnimation(QObject *parent=0);
- virtual ~QDeclarative1RotationAnimation();
-
- qreal from() const;
- void setFrom(qreal);
-
- qreal to() const;
- void setTo(qreal);
-
- enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
- RotationDirection direction() const;
- void setDirection(RotationDirection direction);
-
-Q_SIGNALS:
- void directionChanged();
-};
-
-class QDeclarative1AnimationGroupPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1AnimationGroup : public QDeclarative1AbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup)
-
- Q_CLASSINFO("DefaultProperty", "animations")
- Q_PROPERTY(QDeclarativeListProperty<QDeclarative1AbstractAnimation> animations READ animations)
-
-public:
- QDeclarative1AnimationGroup(QObject *parent);
- virtual ~QDeclarative1AnimationGroup();
-
- QDeclarativeListProperty<QDeclarative1AbstractAnimation> animations();
- friend class QDeclarative1AbstractAnimation;
-
-protected:
- QDeclarative1AnimationGroup(QDeclarative1AnimationGroupPrivate &dd, QObject *parent);
-};
-
-class QDeclarative1SequentialAnimation : public QDeclarative1AnimationGroup
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup)
-
-public:
- QDeclarative1SequentialAnimation(QObject *parent=0);
- virtual ~QDeclarative1SequentialAnimation();
-
-protected:
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QDeclarative1ParallelAnimation : public QDeclarative1AnimationGroup
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup)
-
-public:
- QDeclarative1ParallelAnimation(QObject *parent=0);
- virtual ~QDeclarative1ParallelAnimation();
-
-protected:
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QDeclarative1ParentAnimationPrivate;
-class QDeclarative1ParentAnimation : public QDeclarative1AnimationGroup
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1ParentAnimation)
-
- Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged)
- Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia NOTIFY viaChanged)
-
-public:
- QDeclarative1ParentAnimation(QObject *parent=0);
- virtual ~QDeclarative1ParentAnimation();
-
- QDeclarativeItem *target() const;
- void setTarget(QDeclarativeItem *);
-
- QDeclarativeItem *newParent() const;
- void setNewParent(QDeclarativeItem *);
-
- QDeclarativeItem *via() const;
- void setVia(QDeclarativeItem *);
-
-Q_SIGNALS:
- void targetChanged();
- void newParentChanged();
- void viaChanged();
-
-protected:
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QDeclarative1AnchorAnimationPrivate;
-class QDeclarative1AnchorAnimation : public QDeclarative1AbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1AnchorAnimation)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> targets READ targets)
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
-
-public:
- QDeclarative1AnchorAnimation(QObject *parent=0);
- virtual ~QDeclarative1AnchorAnimation();
-
- QDeclarativeListProperty<QDeclarativeItem> targets();
-
- int duration() const;
- void setDuration(int);
-
- QEasingCurve easing() const;
- void setEasing(const QEasingCurve &);
-
-Q_SIGNALS:
- void durationChanged(int);
- void easingChanged(const QEasingCurve&);
-
-protected:
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1AbstractAnimation)
-QML_DECLARE_TYPE(QDeclarative1PauseAnimation)
-QML_DECLARE_TYPE(QDeclarative1ScriptAction)
-QML_DECLARE_TYPE(QDeclarative1PropertyAction)
-QML_DECLARE_TYPE(QDeclarative1PropertyAnimation)
-QML_DECLARE_TYPE(QDeclarative1ColorAnimation)
-QML_DECLARE_TYPE(QDeclarative1NumberAnimation)
-QML_DECLARE_TYPE(QDeclarative1SequentialAnimation)
-QML_DECLARE_TYPE(QDeclarative1ParallelAnimation)
-QML_DECLARE_TYPE(QDeclarative1Vector3dAnimation)
-QML_DECLARE_TYPE(QDeclarative1RotationAnimation)
-QML_DECLARE_TYPE(QDeclarative1ParentAnimation)
-QML_DECLARE_TYPE(QDeclarative1AnchorAnimation)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEANIMATION_H
diff --git a/src/qtquick1/util/qdeclarativeanimation_p_p.h b/src/qtquick1/util/qdeclarativeanimation_p_p.h
deleted file mode 100644
index 6e490dc7a1..0000000000
--- a/src/qtquick1/util/qdeclarativeanimation_p_p.h
+++ /dev/null
@@ -1,396 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEANIMATION_P_H
-#define QDECLARATIVEANIMATION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-
-#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h"
-#include "QtQuick1/private/qdeclarativetimeline_p_p.h"
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-#include <QtCore/QPauseAnimation>
-#include <QtCore/QVariantAnimation>
-#include <QtCore/QAnimationGroup>
-#include <QDebug>
-
-#include <private/qobject_p.h>
-#include <private/qvariantanimation_p.h>
-
-QT_BEGIN_NAMESPACE
-
-//interface for classes that provide animation actions for QActionAnimation_1
-class QAbstractAnimationAction
-{
-public:
- virtual ~QAbstractAnimationAction() {}
- virtual void doAction() = 0;
-};
-
-//templated animation action
-//allows us to specify an action that calls a function of a class.
-//(so that class doesn't have to inherit QDeclarative1AbstractAnimationAction)
-template<class T, void (T::*method)()>
-class QAnimationActionProxy_1 : public QAbstractAnimationAction
-{
-public:
- QAnimationActionProxy_1(T *p) : m_p(p) {}
- virtual void doAction() { (m_p->*method)(); }
-
-private:
- T *m_p;
-};
-
-//performs an action of type QAbstractAnimationAction
-class Q_AUTOTEST_EXPORT QActionAnimation_1 : public QAbstractAnimation
-{
- Q_OBJECT
-public:
- QActionAnimation_1(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped) {}
- QActionAnimation_1(QAbstractAnimationAction *action, QObject *parent = 0)
- : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped) {}
- ~QActionAnimation_1() { if (policy == DeleteWhenStopped) { delete animAction; animAction = 0; } }
- virtual int duration() const { return 0; }
- void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p)
- {
- if (state() == Running)
- stop();
- if (policy == DeleteWhenStopped)
- delete animAction;
- animAction = action;
- policy = p;
- }
-protected:
- virtual void updateCurrentTime(int) {}
-
- virtual void updateState(State newState, State /*oldState*/)
- {
- if (newState == Running) {
- if (animAction) {
- animAction->doAction();
- if (state() == Stopped && policy == DeleteWhenStopped) {
- delete animAction;
- animAction = 0;
- }
- }
- }
- }
-
-private:
- QAbstractAnimationAction *animAction;
- DeletionPolicy policy;
-};
-
-class QDeclarative1BulkValueUpdater
-{
-public:
- virtual ~QDeclarative1BulkValueUpdater() {}
- virtual void setValue(qreal value) = 0;
-};
-
-//animates QDeclarative1BulkValueUpdater (assumes start and end values will be reals or compatible)
-class Q_AUTOTEST_EXPORT QDeclarative1BulkValueAnimator : public QVariantAnimation
-{
- Q_OBJECT
-public:
- QDeclarative1BulkValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
- ~QDeclarative1BulkValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } }
- void setAnimValue(QDeclarative1BulkValueUpdater *value, DeletionPolicy p)
- {
- if (state() == Running)
- stop();
- if (policy == DeleteWhenStopped)
- delete animValue;
- animValue = value;
- policy = p;
- }
- void setFromSourcedValue(bool *value)
- {
- fromSourced = value;
- }
-protected:
- virtual void updateCurrentValue(const QVariant &value)
- {
- if (state() == QAbstractAnimation::Stopped)
- return;
-
- if (animValue)
- animValue->setValue(value.toReal());
- }
- virtual void updateState(State newState, State oldState)
- {
- QVariantAnimation::updateState(newState, oldState);
- if (newState == Running) {
- //check for new from every loop
- if (fromSourced)
- *fromSourced = false;
- }
- }
-
-private:
- QDeclarative1BulkValueUpdater *animValue;
- bool *fromSourced;
- DeletionPolicy policy;
-};
-
-//an animation that just gives a tick
-template<class T, void (T::*method)(int)>
-class QTickAnimationProxy_1 : public QAbstractAnimation
-{
- //Q_OBJECT //doesn't work with templating
-public:
- QTickAnimationProxy_1(T *p, QObject *parent = 0) : QAbstractAnimation(parent), m_p(p) {}
- virtual int duration() const { return -1; }
-protected:
- virtual void updateCurrentTime(int msec) { (m_p->*method)(msec); }
-
-private:
- T *m_p;
-};
-
-class QDeclarative1AbstractAnimationPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1AbstractAnimation)
-public:
- QDeclarative1AbstractAnimationPrivate()
- : running(false), paused(false), alwaysRunToEnd(false),
- connectedTimeLine(false), componentComplete(true),
- avoidPropertyValueSourceStart(false), disableUserControl(false),
- registered(false), loopCount(1), group(0) {}
-
- bool running:1;
- bool paused:1;
- bool alwaysRunToEnd:1;
- bool connectedTimeLine:1;
- bool componentComplete:1;
- bool avoidPropertyValueSourceStart:1;
- bool disableUserControl:1;
- bool registered:1;
-
- int loopCount;
-
- void commence();
-
- QDeclarativeProperty defaultProperty;
-
- QDeclarative1AnimationGroup *group;
-
- static QDeclarativeProperty createProperty(QObject *obj, const QString &str, QObject *infoObj);
-};
-
-class QDeclarative1PauseAnimationPrivate : public QDeclarative1AbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1PauseAnimation)
-public:
- QDeclarative1PauseAnimationPrivate()
- : QDeclarative1AbstractAnimationPrivate(), pa(0) {}
-
- void init();
-
- QPauseAnimation *pa;
-};
-
-class QDeclarative1ScriptActionPrivate : public QDeclarative1AbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1ScriptAction)
-public:
- QDeclarative1ScriptActionPrivate();
-
- void init();
-
- QDeclarativeScriptString script;
- QString name;
- QDeclarativeScriptString runScriptScript;
- bool hasRunScriptScript;
- bool reversing;
-
- void execute();
-
- QAnimationActionProxy_1<QDeclarative1ScriptActionPrivate,
- &QDeclarative1ScriptActionPrivate::execute> proxy;
- QActionAnimation_1 *rsa;
-};
-
-class QDeclarative1PropertyActionPrivate : public QDeclarative1AbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1PropertyAction)
-public:
- QDeclarative1PropertyActionPrivate()
- : QDeclarative1AbstractAnimationPrivate(), target(0), spa(0) {}
-
- void init();
-
- QObject *target;
- QString propertyName;
- QString properties;
- QList<QObject *> targets;
- QList<QObject *> exclude;
-
- QDeclarativeNullableValue<QVariant> value;
-
- QActionAnimation_1 *spa;
-};
-
-class QDeclarative1AnimationGroupPrivate : public QDeclarative1AbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1AnimationGroup)
-public:
- QDeclarative1AnimationGroupPrivate()
- : QDeclarative1AbstractAnimationPrivate(), ag(0) {}
-
- static void append_animation(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list, QDeclarative1AbstractAnimation *role);
- static void clear_animation(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list);
- QList<QDeclarative1AbstractAnimation *> animations;
- QAnimationGroup *ag;
-};
-
-class QDeclarative1PropertyAnimationPrivate : public QDeclarative1AbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1PropertyAnimation)
-public:
- QDeclarative1PropertyAnimationPrivate()
- : QDeclarative1AbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), actions(0) {}
-
- void init();
-
- QVariant from;
- QVariant to;
-
- QObject *target;
- QString propertyName;
- QString properties;
- QList<QObject *> targets;
- QList<QObject *> exclude;
- QString defaultProperties;
-
- bool fromSourced;
- bool fromIsDefined:1;
- bool toIsDefined:1;
- bool rangeIsSet:1;
- bool defaultToInterpolatorType:1;
- int interpolatorType;
- QVariantAnimation::Interpolator interpolator;
-
- QDeclarative1BulkValueAnimator *va;
-
- // for animations that don't use the QDeclarative1BulkValueAnimator
- QDeclarative1StateActions *actions;
-
- static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
- static void convertVariant(QVariant &variant, int type);
-};
-
-class QDeclarative1RotationAnimationPrivate : public QDeclarative1PropertyAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1RotationAnimation)
-public:
- QDeclarative1RotationAnimationPrivate() : direction(QDeclarative1RotationAnimation::Numerical) {}
-
- QDeclarative1RotationAnimation::RotationDirection direction;
-};
-
-class QDeclarative1ParentAnimationPrivate : public QDeclarative1AnimationGroupPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1ParentAnimation)
-public:
- QDeclarative1ParentAnimationPrivate()
- : QDeclarative1AnimationGroupPrivate(), target(0), newParent(0),
- via(0), topLevelGroup(0), startAction(0), endAction(0) {}
-
- QDeclarativeItem *target;
- QDeclarativeItem *newParent;
- QDeclarativeItem *via;
-
- QSequentialAnimationGroup *topLevelGroup;
- QActionAnimation_1 *startAction;
- QActionAnimation_1 *endAction;
-
- QPointF computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const;
-};
-
-class QDeclarative1AnchorAnimationPrivate : public QDeclarative1AbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1AnchorAnimation)
-public:
- QDeclarative1AnchorAnimationPrivate() : rangeIsSet(false), va(0),
- interpolator(QVariantAnimationPrivate::getInterpolator(QMetaType::QReal)) {}
-
- bool rangeIsSet;
- QDeclarative1BulkValueAnimator *va;
- QVariantAnimation::Interpolator interpolator;
- QList<QDeclarativeItem*> targets;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1AnimationPropertyUpdater : public QDeclarative1BulkValueUpdater
-{
-public:
- QDeclarative1StateActions actions;
- int interpolatorType; //for Number/ColorAnimation
- int prevInterpolatorType; //for generic
- QVariantAnimation::Interpolator interpolator;
- bool reverse;
- bool fromSourced;
- bool fromDefined;
- bool *wasDeleted;
- QDeclarative1AnimationPropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {}
- ~QDeclarative1AnimationPropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
- void setValue(qreal v);
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEANIMATION_P_H
diff --git a/src/qtquick1/util/qdeclarativeapplication.cpp b/src/qtquick1/util/qdeclarativeapplication.cpp
deleted file mode 100644
index ce87299a13..0000000000
--- a/src/qtquick1/util/qdeclarativeapplication.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativeapplication_p.h"
-#include <private/qobject_p.h>
-#include <QtWidgets/QApplication>
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarative1ApplicationPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1Application)
-public:
- QDeclarative1ApplicationPrivate() : active(QApplication::activeWindow() != 0),
- layoutDirection(QApplication::layoutDirection()) {}
- bool active;
- Qt::LayoutDirection layoutDirection;
-};
-
-/*
- This object and its properties are documented as part of the Qt object,
- in qdeclarativengine.cpp
-*/
-
-QDeclarative1Application::QDeclarative1Application(QObject *parent) : QObject(*new QDeclarative1ApplicationPrivate(), parent)
-{
- if (qApp)
- qApp->installEventFilter(this);
-}
-
-QDeclarative1Application::~QDeclarative1Application()
-{
-}
-
-bool QDeclarative1Application::active() const
-{
- Q_D(const QDeclarative1Application);
- return d->active;
-}
-
-Qt::LayoutDirection QDeclarative1Application::layoutDirection() const
-{
- Q_D(const QDeclarative1Application);
- return d->layoutDirection;
-}
-
-bool QDeclarative1Application::eventFilter(QObject *obj, QEvent *event)
-{
- Q_UNUSED(obj)
- Q_D(QDeclarative1Application);
- if (event->type() == QEvent::ApplicationActivate
- || event->type() == QEvent::ApplicationDeactivate) {
- bool active = d->active;
- if (event->type() == QEvent::ApplicationActivate)
- active = true;
- else if (event->type() == QEvent::ApplicationDeactivate)
- active = false;
-
- if (d->active != active) {
- d->active = active;
- emit activeChanged();
- }
- }
- if (event->type() == QEvent::LayoutDirectionChange) {
- Qt::LayoutDirection direction = QApplication::layoutDirection();
- if (d->layoutDirection != direction) {
- d->layoutDirection = direction;
- emit layoutDirectionChanged();
- }
- }
- return false;
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativeapplication_p.h b/src/qtquick1/util/qdeclarativeapplication_p.h
deleted file mode 100644
index 7438f6075c..0000000000
--- a/src/qtquick1/util/qdeclarativeapplication_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEAPPLICATION_P_H
-#define QDECLARATIVEAPPLICATION_P_H
-
-#include <QtCore/QObject>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1ApplicationPrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1Application : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(bool active READ active NOTIFY activeChanged)
- Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged)
-
-public:
- explicit QDeclarative1Application(QObject *parent = 0);
- virtual ~QDeclarative1Application();
- bool active() const;
- Qt::LayoutDirection layoutDirection() const;
-
-protected:
- bool eventFilter(QObject *obj, QEvent *event);
-
-Q_SIGNALS:
- void activeChanged();
- void layoutDirectionChanged();
-
-private:
- Q_DISABLE_COPY(QDeclarative1Application)
- Q_DECLARE_PRIVATE(QDeclarative1Application)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1Application)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEAPPLICATION_P_H
diff --git a/src/qtquick1/util/qdeclarativebehavior.cpp b/src/qtquick1/util/qdeclarativebehavior.cpp
deleted file mode 100644
index c10f0816dc..0000000000
--- a/src/qtquick1/util/qdeclarativebehavior.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativebehavior_p.h"
-
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-#include "QtQuick1/private/qdeclarativetransition_p.h"
-
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-#include <QtDeclarative/private/qdeclarativeguard_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarative1BehaviorPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1Behavior)
-public:
- QDeclarative1BehaviorPrivate() : animation(0), enabled(true), finalized(false)
- , blockRunningChanged(false) {}
-
- QDeclarativeProperty property;
- QVariant currentValue;
- QVariant targetValue;
- QDeclarativeGuard<QDeclarative1AbstractAnimation> animation;
- bool enabled;
- bool finalized;
- bool blockRunningChanged;
-};
-
-/*!
- \qmlclass Behavior QDeclarative1Behavior
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \brief The Behavior element allows you to specify a default animation for a property change.
-
- A Behavior defines the default animation to be applied whenever a
- particular property value changes.
-
- For example, the following Behavior defines a NumberAnimation to be run
- whenever the \l Rectangle's \c width value changes. When the MouseArea
- is clicked, the \c width is changed, triggering the behavior's animation:
-
- \snippet doc/src/snippets/qtquick1/behavior.qml 0
-
- Note that a property cannot have more than one assigned Behavior. To provide
- multiple animations within a Behavior, use ParallelAnimation or
- SequentialAnimation.
-
- If a \l{QML States}{state change} has a \l Transition that matches the same property as a
- Behavior, the \l Transition animation overrides the Behavior for that
- state change. For general advice on using Behaviors to animate state changes, see
- \l{Using QML Behaviors with States}.
-
- \sa {QML Animation and Transitions}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative
-*/
-
-
-QDeclarative1Behavior::QDeclarative1Behavior(QObject *parent)
- : QObject(*(new QDeclarative1BehaviorPrivate), parent)
-{
-}
-
-QDeclarative1Behavior::~QDeclarative1Behavior()
-{
-}
-
-/*!
- \qmlproperty Animation QtQuick1::Behavior::animation
- \default
-
- This property holds the animation to run when the behavior is triggered.
-*/
-
-QDeclarative1AbstractAnimation *QDeclarative1Behavior::animation()
-{
- Q_D(QDeclarative1Behavior);
- return d->animation;
-}
-
-void QDeclarative1Behavior::setAnimation(QDeclarative1AbstractAnimation *animation)
-{
- Q_D(QDeclarative1Behavior);
- if (d->animation) {
- qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior.");
- return;
- }
-
- d->animation = animation;
- if (d->animation) {
- d->animation->setDefaultTarget(d->property);
- d->animation->setDisableUserControl();
- connect(d->animation->qtAnimation(),
- SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)),
- this,
- SLOT(qtAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- }
-}
-
-
-void QDeclarative1Behavior::qtAnimationStateChanged(QAbstractAnimation::State newState,QAbstractAnimation::State)
-{
- Q_D(QDeclarative1Behavior);
- if (!d->blockRunningChanged)
- d->animation->notifyRunningChanged(newState == QAbstractAnimation::Running);
-}
-
-
-/*!
- \qmlproperty bool QtQuick1::Behavior::enabled
-
- This property holds whether the behavior will be triggered when the tracked
- property changes value.
-
- By default a Behavior is enabled.
-*/
-
-bool QDeclarative1Behavior::enabled() const
-{
- Q_D(const QDeclarative1Behavior);
- return d->enabled;
-}
-
-void QDeclarative1Behavior::setEnabled(bool enabled)
-{
- Q_D(QDeclarative1Behavior);
- if (d->enabled == enabled)
- return;
- d->enabled = enabled;
- emit enabledChanged();
-}
-
-void QDeclarative1Behavior::write(const QVariant &value)
-{
- Q_D(QDeclarative1Behavior);
- qmlExecuteDeferred(this);
- if (!d->animation || !d->enabled || !d->finalized) {
- QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- d->targetValue = value;
- return;
- }
-
- if (d->animation->isRunning() && value == d->targetValue)
- return;
-
- d->currentValue = d->property.read();
- d->targetValue = value;
-
- if (d->animation->qtAnimation()->duration() != -1
- && d->animation->qtAnimation()->state() != QAbstractAnimation::Stopped) {
- d->blockRunningChanged = true;
- d->animation->qtAnimation()->stop();
- }
-
- QDeclarative1StateOperation::ActionList actions;
- QDeclarative1Action action;
- action.property = d->property;
- action.fromValue = d->currentValue;
- action.toValue = value;
- actions << action;
-
- QList<QDeclarativeProperty> after;
- d->animation->transition(actions, after, QDeclarative1AbstractAnimation::Forward);
- d->animation->qtAnimation()->start();
- d->blockRunningChanged = false;
- if (!after.contains(d->property))
- QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
-}
-
-void QDeclarative1Behavior::setTarget(const QDeclarativeProperty &property)
-{
- Q_D(QDeclarative1Behavior);
- d->property = property;
- d->currentValue = property.read();
- if (d->animation)
- d->animation->setDefaultTarget(property);
-
- QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
- engPriv->registerFinalizeCallback(this, this->metaObject()->indexOfSlot("componentFinalized()"));
-}
-
-void QDeclarative1Behavior::componentFinalized()
-{
- Q_D(QDeclarative1Behavior);
- d->finalized = true;
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativebehavior_p.h b/src/qtquick1/util/qdeclarativebehavior_p.h
deleted file mode 100644
index 454cc8ebd3..0000000000
--- a/src/qtquick1/util/qdeclarativebehavior_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEBEHAVIOR_H
-#define QDECLARATIVEBEHAVIOR_H
-
-#include "QtQuick1/private/qdeclarativestate_p.h"
-
-#include <QtDeclarative/qdeclarativepropertyvaluesource.h>
-#include <private/qdeclarativepropertyvalueinterceptor_p.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtCore/QAbstractAnimation>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1AbstractAnimation;
-class QDeclarative1BehaviorPrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1Behavior : public QObject, public QDeclarativePropertyValueInterceptor
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1Behavior)
-
- Q_INTERFACES(QDeclarativePropertyValueInterceptor)
- Q_CLASSINFO("DefaultProperty", "animation")
- Q_PROPERTY(QDeclarative1AbstractAnimation *animation READ animation WRITE setAnimation)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_CLASSINFO("DeferredPropertyNames", "animation")
-
-public:
- QDeclarative1Behavior(QObject *parent=0);
- ~QDeclarative1Behavior();
-
- virtual void setTarget(const QDeclarativeProperty &);
- virtual void write(const QVariant &value);
-
- QDeclarative1AbstractAnimation *animation();
- void setAnimation(QDeclarative1AbstractAnimation *);
-
- bool enabled() const;
- void setEnabled(bool enabled);
-
-Q_SIGNALS:
- void enabledChanged();
-
-private Q_SLOTS:
- void componentFinalized();
- void qtAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1Behavior)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEBEHAVIOR_H
diff --git a/src/qtquick1/util/qdeclarativebind.cpp b/src/qtquick1/util/qdeclarativebind.cpp
deleted file mode 100644
index f8ad891fae..0000000000
--- a/src/qtquick1/util/qdeclarativebind.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativebind_p.h"
-
-#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h"
-#include "QtDeclarative/private/qdeclarativeguard_p.h"
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-
-#include <QtCore/qfile.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarative1BindPrivate : public QObjectPrivate
-{
-public:
- QDeclarative1BindPrivate() : when(true), componentComplete(true), obj(0) {}
-
- bool when : 1;
- bool componentComplete : 1;
- QDeclarativeGuard<QObject> obj;
- QString prop;
- QDeclarativeNullableValue<QVariant> value;
-};
-
-
-/*!
- \qmlclass Binding QDeclarative1Bind
- \inqmlmodule QtQuick 1
- \ingroup qml-working-with-data
- \since QtQuick 1.0
- \brief The Binding element allows arbitrary property bindings to be created.
-
- Sometimes it is necessary to bind to a property of an object that wasn't
- directly instantiated by QML - generally a property of a class exported
- to QML by C++. In these cases, regular property binding doesn't work. Binding
- allows you to bind any value to any property.
-
- For example, imagine a C++ application that maps an "app.enteredText"
- property into QML. You could use Binding to update the enteredText property
- like this.
- \code
- TextEdit { id: myTextField; text: "Please type here..." }
- Binding { target: app; property: "enteredText"; value: myTextField.text }
- \endcode
- Whenever the text in the TextEdit is updated, the C++ property will be
- updated also.
-
- If the binding target or binding property is changed, the bound value is
- immediately pushed onto the new target.
-
- \sa QtDeclarative
-*/
-QDeclarative1Bind::QDeclarative1Bind(QObject *parent)
- : QObject(*(new QDeclarative1BindPrivate), parent)
-{
-}
-
-QDeclarative1Bind::~QDeclarative1Bind()
-{
-}
-
-/*!
- \qmlproperty bool QtQuick1::Binding::when
-
- This property holds when the binding is active.
- This should be set to an expression that evaluates to true when you want the binding to be active.
-
- \code
- Binding {
- target: contactName; property: 'text'
- value: name; when: list.ListView.isCurrentItem
- }
- \endcode
-*/
-bool QDeclarative1Bind::when() const
-{
- Q_D(const QDeclarative1Bind);
- return d->when;
-}
-
-void QDeclarative1Bind::setWhen(bool v)
-{
- Q_D(QDeclarative1Bind);
- d->when = v;
- eval();
-}
-
-/*!
- \qmlproperty Object QtQuick1::Binding::target
-
- The object to be updated.
-*/
-QObject *QDeclarative1Bind::object()
-{
- Q_D(const QDeclarative1Bind);
- return d->obj;
-}
-
-void QDeclarative1Bind::setObject(QObject *obj)
-{
- Q_D(QDeclarative1Bind);
- d->obj = obj;
- eval();
-}
-
-/*!
- \qmlproperty string QtQuick1::Binding::property
-
- The property to be updated.
-*/
-QString QDeclarative1Bind::property() const
-{
- Q_D(const QDeclarative1Bind);
- return d->prop;
-}
-
-void QDeclarative1Bind::setProperty(const QString &p)
-{
- Q_D(QDeclarative1Bind);
- d->prop = p;
- eval();
-}
-
-/*!
- \qmlproperty any QtQuick1::Binding::value
-
- The value to be set on the target object and property. This can be a
- constant (which isn't very useful), or a bound expression.
-*/
-QVariant QDeclarative1Bind::value() const
-{
- Q_D(const QDeclarative1Bind);
- return d->value.value;
-}
-
-void QDeclarative1Bind::setValue(const QVariant &v)
-{
- Q_D(QDeclarative1Bind);
- d->value.value = v;
- d->value.isNull = false;
- eval();
-}
-
-void QDeclarative1Bind::classBegin()
-{
- Q_D(QDeclarative1Bind);
- d->componentComplete = false;
-}
-
-void QDeclarative1Bind::componentComplete()
-{
- Q_D(QDeclarative1Bind);
- d->componentComplete = true;
- eval();
-}
-
-void QDeclarative1Bind::eval()
-{
- Q_D(QDeclarative1Bind);
- if (!d->obj || d->value.isNull || !d->when || !d->componentComplete)
- return;
-
- QDeclarativeProperty prop(d->obj, d->prop);
- prop.write(d->value.value);
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativebind_p.h b/src/qtquick1/util/qdeclarativebind_p.h
deleted file mode 100644
index af17dc508e..0000000000
--- a/src/qtquick1/util/qdeclarativebind_p.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEBIND_H
-#define QDECLARATIVEBIND_H
-
-#include <QtDeclarative/qdeclarative.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1BindPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1Bind : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1Bind)
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(QObject *target READ object WRITE setObject)
- Q_PROPERTY(QString property READ property WRITE setProperty)
- Q_PROPERTY(QVariant value READ value WRITE setValue)
- Q_PROPERTY(bool when READ when WRITE setWhen)
-
-public:
- QDeclarative1Bind(QObject *parent=0);
- ~QDeclarative1Bind();
-
- bool when() const;
- void setWhen(bool);
-
- QObject *object();
- void setObject(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QVariant value() const;
- void setValue(const QVariant &);
-
-protected:
- virtual void classBegin();
- virtual void componentComplete();
-
-private:
- void eval();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1Bind)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/qtquick1/util/qdeclarativeconnections.cpp b/src/qtquick1/util/qdeclarativeconnections.cpp
deleted file mode 100644
index 7d48954288..0000000000
--- a/src/qtquick1/util/qdeclarativeconnections.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativeconnections_p.h"
-
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-#include <QtDeclarative/private/qdeclarativeboundsignal_p.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/private/qdeclarativecontext_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstringlist.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarative1ConnectionsPrivate : public QObjectPrivate
-{
-public:
- QDeclarative1ConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {}
-
- QList<QDeclarativeBoundSignal*> boundsignals;
- QObject *target;
-
- bool targetSet;
- bool ignoreUnknownSignals;
- bool componentcomplete;
-
- QByteArray data;
-};
-
-/*!
- \qmlclass Connections QDeclarative1Connections
- \inqmlmodule QtQuick 1
- \ingroup qml-utility-elements
- \since QtQuick 1.0
- \brief A Connections element describes generalized connections to signals.
-
- A Connections object creates a connection to a QML signal.
-
- When connecting to signals in QML, the usual way is to create an
- "on<Signal>" handler that reacts when a signal is received, like this:
-
- \qml
- MouseArea {
- onClicked: { foo(parameters) }
- }
- \endqml
-
- However, it is not possible to connect to a signal in this way in some
- cases, such as when:
-
- \list
- \i Multiple connections to the same signal are required
- \i Creating connections outside the scope of the signal sender
- \i Connecting to targets not defined in QML
- \endlist
-
- When any of these are needed, the Connections element can be used instead.
-
- For example, the above code can be changed to use a Connections object,
- like this:
-
- \qml
- MouseArea {
- Connections {
- onClicked: foo(parameters)
- }
- }
- \endqml
-
- More generally, the Connections object can be a child of some object other than
- the sender of the signal:
-
- \qml
- MouseArea {
- id: area
- }
- // ...
- \endqml
- \qml
- Connections {
- target: area
- onClicked: foo(parameters)
- }
- \endqml
-
- \sa QtDeclarative
-*/
-QDeclarative1Connections::QDeclarative1Connections(QObject *parent) :
- QObject(*(new QDeclarative1ConnectionsPrivate), parent)
-{
-}
-
-QDeclarative1Connections::~QDeclarative1Connections()
-{
-}
-
-/*!
- \qmlproperty Object QtQuick1::Connections::target
- This property holds the object that sends the signal.
-
- If this property is not set, the \c target defaults to the parent of the Connection.
-
- If set to null, no connection is made and any signal handlers are ignored
- until the target is not null.
-*/
-QObject *QDeclarative1Connections::target() const
-{
- Q_D(const QDeclarative1Connections);
- return d->targetSet ? d->target : parent();
-}
-
-void QDeclarative1Connections::setTarget(QObject *obj)
-{
- Q_D(QDeclarative1Connections);
- d->targetSet = true; // even if setting to 0, it is *set*
- if (d->target == obj)
- return;
- foreach (QDeclarativeBoundSignal *s, d->boundsignals) {
- // It is possible that target is being changed due to one of our signal
- // handlers -> use deleteLater().
- if (s->isEvaluating())
- s->deleteLater();
- else
- delete s;
- }
- d->boundsignals.clear();
- d->target = obj;
- connectSignals();
- emit targetChanged();
-}
-
-/*!
- \qmlproperty bool QtQuick1::Connections::ignoreUnknownSignals
-
- Normally, a connection to a non-existent signal produces runtime errors.
-
- If this property is set to \c true, such errors are ignored.
- This is useful if you intend to connect to different types of objects, handling
- a different set of signals for each object.
-*/
-bool QDeclarative1Connections::ignoreUnknownSignals() const
-{
- Q_D(const QDeclarative1Connections);
- return d->ignoreUnknownSignals;
-}
-
-void QDeclarative1Connections::setIgnoreUnknownSignals(bool ignore)
-{
- Q_D(QDeclarative1Connections);
- d->ignoreUnknownSignals = ignore;
-}
-
-
-
-QByteArray
-QDeclarative1ConnectionsParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
-{
- QByteArray rv;
- QDataStream ds(&rv, QIODevice::WriteOnly);
-
- for(int ii = 0; ii < props.count(); ++ii)
- {
- QString propName = props.at(ii).name();
- if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) {
- error(props.at(ii), QDeclarative1Connections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
- return QByteArray();
- }
-
- QList<QVariant> values = props.at(ii).assignedValues();
-
- for (int i = 0; i < values.count(); ++i) {
- const QVariant &value = values.at(i);
-
- if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
- error(props.at(ii), QDeclarative1Connections::tr("Connections: nested objects not allowed"));
- return QByteArray();
- } else if (value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
- error(props.at(ii), QDeclarative1Connections::tr("Connections: syntax error"));
- return QByteArray();
- } else {
- QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(value);
- if (v.isScript()) {
- ds << propName;
- ds << v.asScript();
- } else {
- error(props.at(ii), QDeclarative1Connections::tr("Connections: script expected"));
- return QByteArray();
- }
- }
- }
- }
-
- return rv;
-}
-
-void QDeclarative1ConnectionsParser::setCustomData(QObject *object,
- const QByteArray &data)
-{
- QDeclarative1ConnectionsPrivate *p =
- static_cast<QDeclarative1ConnectionsPrivate *>(QObjectPrivate::get(object));
- p->data = data;
-}
-
-
-void QDeclarative1Connections::connectSignals()
-{
- Q_D(QDeclarative1Connections);
- if (!d->componentcomplete || (d->targetSet && !target()))
- return;
-
- QDataStream ds(d->data);
- while (!ds.atEnd()) {
- QString propName;
- ds >> propName;
- QString script;
- ds >> script;
- QDeclarativeProperty prop(target(), propName);
- if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) {
- QDeclarativeBoundSignal *signal =
- new QDeclarativeBoundSignal(target(), prop.method(), this);
- QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(this), 0, script);
- QDeclarativeData *ddata = QDeclarativeData::get(this);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
- signal->setExpression(expression);
- d->boundsignals += signal;
- } else {
- if (!d->ignoreUnknownSignals)
- qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName);
- }
- }
-}
-
-void QDeclarative1Connections::classBegin()
-{
- Q_D(QDeclarative1Connections);
- d->componentcomplete=false;
-}
-
-void QDeclarative1Connections::componentComplete()
-{
- Q_D(QDeclarative1Connections);
- d->componentcomplete=true;
- connectSignals();
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativeconnections_p.h b/src/qtquick1/util/qdeclarativeconnections_p.h
deleted file mode 100644
index b93afec849..0000000000
--- a/src/qtquick1/util/qdeclarativeconnections_p.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECONNECTIONS_H
-#define QDECLARATIVECONNECTIONS_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-#include <QtDeclarative/private/qdeclarativecustomparser_p.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeBoundSignal;
-class QDeclarativeContext;
-class QDeclarative1ConnectionsPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1Connections : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1Connections)
-
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals)
-
-public:
- QDeclarative1Connections(QObject *parent=0);
- ~QDeclarative1Connections();
-
- QObject *target() const;
- void setTarget(QObject *);
-
- bool ignoreUnknownSignals() const;
- void setIgnoreUnknownSignals(bool ignore);
-
-Q_SIGNALS:
- void targetChanged();
-
-private:
- void connectSignals();
- void classBegin();
- void componentComplete();
-};
-
-class QDeclarative1ConnectionsParser : public QDeclarativeCustomParser
-{
-public:
- virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
- virtual void setCustomData(QObject *, const QByteArray &);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1Connections)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/qtquick1/util/qdeclarativefontloader.cpp b/src/qtquick1/util/qdeclarativefontloader.cpp
deleted file mode 100644
index fbd2c4cd26..0000000000
--- a/src/qtquick1/util/qdeclarativefontloader.cpp
+++ /dev/null
@@ -1,343 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativefontloader_p.h"
-
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <QStringList>
-#include <QUrl>
-#include <QDebug>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QFontDatabase>
-
-#include <private/qobject_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-#define FONTLOADER_MAXIMUM_REDIRECT_RECURSION 16
-
-class QDeclarative1FontObject : public QObject
-{
-Q_OBJECT
-
-public:
- QDeclarative1FontObject(int _id);
-
- void download(const QUrl &url, QNetworkAccessManager *manager);
-
-Q_SIGNALS:
- void fontDownloaded(const QString&, QDeclarative1FontLoader::Status);
-
-private Q_SLOTS:
- void replyFinished();
-
-public:
- int id;
-
-private:
- QNetworkReply *reply;
- int redirectCount;
-
- Q_DISABLE_COPY(QDeclarative1FontObject)
-};
-
-QDeclarative1FontObject::QDeclarative1FontObject(int _id = -1)
- : QObject(0), id(_id), reply(0), redirectCount(0) {}
-
-
-void QDeclarative1FontObject::download(const QUrl &url, QNetworkAccessManager *manager)
-{
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- reply = manager->get(req);
- QObject::connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
-}
-
-void QDeclarative1FontObject::replyFinished()
-{
- if (reply) {
- redirectCount++;
- if (redirectCount < FONTLOADER_MAXIMUM_REDIRECT_RECURSION) {
- QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- QUrl url = reply->url().resolved(redirect.toUrl());
- QNetworkAccessManager *manager = reply->manager();
- reply->deleteLater();
- reply = 0;
- download(url, manager);
- return;
- }
- }
- redirectCount = 0;
-
- if (!reply->error()) {
- id = QFontDatabase::addApplicationFontFromData(reply->readAll());
- if (id != -1)
- emit fontDownloaded(QFontDatabase::applicationFontFamilies(id).at(0), QDeclarative1FontLoader::Ready);
- else
- emit fontDownloaded(QString(), QDeclarative1FontLoader::Error);
- } else {
- emit fontDownloaded(QString(), QDeclarative1FontLoader::Error);
- }
- reply->deleteLater();
- reply = 0;
- }
-}
-
-
-class QDeclarative1FontLoaderPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1FontLoader)
-
-public:
- QDeclarative1FontLoaderPrivate() : status(QDeclarative1FontLoader::Null) {}
-
- QUrl url;
- QString name;
- QDeclarative1FontLoader::Status status;
- static QHash<QUrl, QDeclarative1FontObject*> fonts;
-};
-
-QHash<QUrl, QDeclarative1FontObject*> QDeclarative1FontLoaderPrivate::fonts;
-
-/*!
- \qmlclass FontLoader QDeclarative1FontLoader
- \inqmlmodule QtQuick 1
- \ingroup qml-utility-elements
- \since QtQuick 1.0
- \brief The FontLoader element allows fonts to be loaded by name or URL.
-
- The FontLoader element is used to load fonts by name or URL.
-
- The \l status indicates when the font has been loaded, which is useful
- for fonts loaded from remote sources.
-
- For example:
- \qml
- import QtQuick 1.0
-
- Column {
- FontLoader { id: fixedFont; name: "Courier" }
- FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
-
- Text { text: "Fixed-size font"; font.family: fixedFont.name }
- Text { text: "Fancy font"; font.family: webFont.name }
- }
- \endqml
-
- \sa {declarative/text/fonts}{Fonts example}
-*/
-QDeclarative1FontLoader::QDeclarative1FontLoader(QObject *parent)
- : QObject(*(new QDeclarative1FontLoaderPrivate), parent)
-{
-}
-
-QDeclarative1FontLoader::~QDeclarative1FontLoader()
-{
-}
-
-/*!
- \qmlproperty url QtQuick1::FontLoader::source
- The url of the font to load.
-*/
-QUrl QDeclarative1FontLoader::source() const
-{
- Q_D(const QDeclarative1FontLoader);
- return d->url;
-}
-
-void QDeclarative1FontLoader::setSource(const QUrl &url)
-{
- Q_D(QDeclarative1FontLoader);
- if (url == d->url)
- return;
- d->url = qmlContext(this)->resolvedUrl(url);
- emit sourceChanged();
-
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
- if (!localFile.isEmpty()) {
- if (!d->fonts.contains(d->url)) {
- int id = QFontDatabase::addApplicationFont(localFile);
- if (id != -1) {
- updateFontInfo(QFontDatabase::applicationFontFamilies(id).at(0), Ready);
- QDeclarative1FontObject *fo = new QDeclarative1FontObject(id);
- d->fonts[d->url] = fo;
- } else {
- updateFontInfo(QString(), Error);
- }
- } else {
- updateFontInfo(QFontDatabase::applicationFontFamilies(d->fonts[d->url]->id).at(0), Ready);
- }
- } else
-#endif
- {
- if (!d->fonts.contains(d->url)) {
- QDeclarative1FontObject *fo = new QDeclarative1FontObject;
- d->fonts[d->url] = fo;
- fo->download(d->url, qmlEngine(this)->networkAccessManager());
- d->status = Loading;
- emit statusChanged();
- QObject::connect(fo, SIGNAL(fontDownloaded(QString,QDeclarative1FontLoader::Status)),
- this, SLOT(updateFontInfo(QString,QDeclarative1FontLoader::Status)));
- } else {
- QDeclarative1FontObject *fo = d->fonts[d->url];
- if (fo->id == -1) {
- d->status = Loading;
- emit statusChanged();
- QObject::connect(fo, SIGNAL(fontDownloaded(QString,QDeclarative1FontLoader::Status)),
- this, SLOT(updateFontInfo(QString,QDeclarative1FontLoader::Status)));
- }
- else
- updateFontInfo(QFontDatabase::applicationFontFamilies(fo->id).at(0), Ready);
- }
- }
-}
-
-void QDeclarative1FontLoader::updateFontInfo(const QString& name, QDeclarative1FontLoader::Status status)
-{
- Q_D(QDeclarative1FontLoader);
-
- if (name != d->name) {
- d->name = name;
- emit nameChanged();
- }
- if (status != d->status) {
- if (status == Error)
- qmlInfo(this) << "Cannot load font: \"" << d->url.toString() << "\"";
- d->status = status;
- emit statusChanged();
- }
-}
-
-/*!
- \qmlproperty string QtQuick1::FontLoader::name
-
- This property holds the name of the font family.
- It is set automatically when a font is loaded using the \c url property.
-
- Use this to set the \c font.family property of a \c Text item.
-
- Example:
- \qml
- Item {
- width: 200; height: 50
-
- FontLoader {
- id: webFont
- source: "http://www.mysite.com/myfont.ttf"
- }
- Text {
- text: "Fancy font"
- font.family: webFont.name
- }
- }
- \endqml
-*/
-QString QDeclarative1FontLoader::name() const
-{
- Q_D(const QDeclarative1FontLoader);
- return d->name;
-}
-
-void QDeclarative1FontLoader::setName(const QString &name)
-{
- Q_D(QDeclarative1FontLoader);
- if (d->name == name)
- return;
- d->name = name;
- emit nameChanged();
- d->status = Ready;
- emit statusChanged();
-}
-
-/*!
- \qmlproperty enumeration QtQuick1::FontLoader::status
-
- This property holds the status of font loading. It can be one of:
- \list
- \o FontLoader.Null - no font has been set
- \o FontLoader.Ready - the font has been loaded
- \o FontLoader.Loading - the font is currently being loaded
- \o FontLoader.Error - an error occurred while loading the font
- \endlist
-
- Use this status to provide an update or respond to the status change in some way.
- For example, you could:
-
- \list
- \o Trigger a state change:
- \qml
- State { name: 'loaded'; when: loader.status == FontLoader.Ready }
- \endqml
-
- \o Implement an \c onStatusChanged signal handler:
- \qml
- FontLoader {
- id: loader
- onStatusChanged: if (loader.status == FontLoader.Ready) console.log('Loaded')
- }
- \endqml
-
- \o Bind to the status value:
- \qml
- Text { text: loader.status == FontLoader.Ready ? 'Loaded' : 'Not loaded' }
- \endqml
- \endlist
-*/
-QDeclarative1FontLoader::Status QDeclarative1FontLoader::status() const
-{
- Q_D(const QDeclarative1FontLoader);
- return d->status;
-}
-
-
-
-QT_END_NAMESPACE
-
-#include <qdeclarativefontloader.moc>
diff --git a/src/qtquick1/util/qdeclarativefontloader_p.h b/src/qtquick1/util/qdeclarativefontloader_p.h
deleted file mode 100644
index 585c221113..0000000000
--- a/src/qtquick1/util/qdeclarativefontloader_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEFONTLOADER_H
-#define QDECLARATIVEFONTLOADER_H
-
-#include <QtDeclarative/qdeclarative.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1FontLoaderPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1FontLoader : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1FontLoader)
- Q_ENUMS(Status)
-
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
-
-public:
- enum Status { Null = 0, Ready, Loading, Error };
-
- QDeclarative1FontLoader(QObject *parent = 0);
- ~QDeclarative1FontLoader();
-
- QUrl source() const;
- void setSource(const QUrl &url);
-
- QString name() const;
- void setName(const QString &name);
-
- Status status() const;
-
-private Q_SLOTS:
- void updateFontInfo(const QString&, QDeclarative1FontLoader::Status);
-
-Q_SIGNALS:
- void sourceChanged();
- void nameChanged();
- void statusChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1FontLoader)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEFONTLOADER_H
-
diff --git a/src/qtquick1/util/qdeclarativelistaccessor.cpp b/src/qtquick1/util/qdeclarativelistaccessor.cpp
deleted file mode 100644
index 426f584192..0000000000
--- a/src/qtquick1/util/qdeclarativelistaccessor.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativelistaccessor_p.h"
-
-#include <QtDeclarative/private/qdeclarativemetatype_p.h>
-
-#include <QtCore/qstringlist.h>
-#include <QtCore/qdebug.h>
-
-// ### Remove me
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-QDeclarative1ListAccessor::QDeclarative1ListAccessor()
-: m_type(Invalid)
-{
-}
-
-QDeclarative1ListAccessor::~QDeclarative1ListAccessor()
-{
-}
-
-QVariant QDeclarative1ListAccessor::list() const
-{
- return d;
-}
-
-void QDeclarative1ListAccessor::setList(const QVariant &v, QDeclarativeEngine *engine)
-{
- d = v;
-
- QDeclarativeEnginePrivate *enginePrivate = engine?QDeclarativeEnginePrivate::get(engine):0;
-
- if (!d.isValid()) {
- m_type = Invalid;
- } else if (d.userType() == QVariant::StringList) {
- m_type = StringList;
- } else if (d.userType() == QMetaType::QVariantList) {
- m_type = VariantList;
- } else if (d.canConvert(QVariant::Int)) {
- m_type = Integer;
- } else if ((!enginePrivate && QDeclarativeMetaType::isQObject(d.userType())) ||
- (enginePrivate && enginePrivate->isQObject(d.userType()))) {
- QObject *data = enginePrivate?enginePrivate->toQObject(v):QDeclarativeMetaType::toQObject(v);
- d = QVariant::fromValue(data);
- m_type = Instance;
- } else if (d.userType() == qMetaTypeId<QDeclarativeListReference>()) {
- m_type = ListProperty;
- } else {
- m_type = Instance;
- }
-}
-
-int QDeclarative1ListAccessor::count() const
-{
- switch(m_type) {
- case StringList:
- return qvariant_cast<QStringList>(d).count();
- case VariantList:
- return qvariant_cast<QVariantList>(d).count();
- case ListProperty:
- return ((QDeclarativeListReference *)d.constData())->count();
- case Instance:
- return 1;
- case Integer:
- return d.toInt();
- default:
- case Invalid:
- return 0;
- }
-}
-
-QVariant QDeclarative1ListAccessor::at(int idx) const
-{
- Q_ASSERT(idx >= 0 && idx < count());
- switch(m_type) {
- case StringList:
- return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx));
- case VariantList:
- return qvariant_cast<QVariantList>(d).at(idx);
- case ListProperty:
- return QVariant::fromValue(((QDeclarativeListReference *)d.constData())->at(idx));
- case Instance:
- return d;
- case Integer:
- return QVariant(idx);
- default:
- case Invalid:
- return QVariant();
- }
-}
-
-bool QDeclarative1ListAccessor::isValid() const
-{
- return m_type != Invalid;
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativelistaccessor_p.h b/src/qtquick1/util/qdeclarativelistaccessor_p.h
deleted file mode 100644
index 4cc44f8bfc..0000000000
--- a/src/qtquick1/util/qdeclarativelistaccessor_p.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTACCESSOR_H
-#define QDECLARATIVELISTACCESSOR_H
-
-#include <QtCore/QVariant>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-
-
-class Q_AUTOTEST_EXPORT QDeclarative1ListAccessor
-{
-public:
- QDeclarative1ListAccessor();
- ~QDeclarative1ListAccessor();
-
- QVariant list() const;
- void setList(const QVariant &, QDeclarativeEngine * = 0);
-
- bool isValid() const;
-
- int count() const;
- QVariant at(int) const;
-
- enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer };
- Type type() const { return m_type; }
-
-private:
- Type m_type;
- QVariant d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVELISTACCESSOR_H
diff --git a/src/qtquick1/util/qdeclarativelistmodel.cpp b/src/qtquick1/util/qdeclarativelistmodel.cpp
deleted file mode 100644
index 12367364f6..0000000000
--- a/src/qtquick1/util/qdeclarativelistmodel.cpp
+++ /dev/null
@@ -1,1634 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativelistmodel_p_p.h"
-#include "QtQuick1/private/qdeclarativelistmodelworkeragent_p.h"
-#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h"
-
-#include <QtDeclarative/private/qdeclarativecustomparser_p.h>
-#include <QtDeclarative/private/qdeclarativescript_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstack.h>
-#include <QXmlStreamReader>
-#include <QtDeclarative/qscriptvalueiterator.h>
-
-Q_DECLARE_METATYPE(QListModelInterface *)
-
-QT_BEGIN_NAMESPACE
-
-
-
-template<typename T>
-void qdeclarativelistmodel_move(int from, int to, int n, T *items)
-{
- if (n == 1) {
- items->move(from, to);
- } else {
- T replaced;
- int i=0;
- typename T::ConstIterator it=items->begin(); it += from+n;
- for (; i<to-from; ++i,++it)
- replaced.append(*it);
- i=0;
- it=items->begin(); it += from;
- for (; i<n; ++i,++it)
- replaced.append(*it);
- typename T::ConstIterator f=replaced.begin();
- typename T::Iterator t=items->begin(); t += from;
- for (; f != replaced.end(); ++f, ++t)
- *t = *f;
- }
-}
-
-QDeclarative1ListModelParser::ListInstruction *QDeclarative1ListModelParser::ListModelData::instructions() const
-{
- return (QDeclarative1ListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData));
-}
-
-/*!
- \qmlclass ListModel QDeclarative1ListModel
- \inqmlmodule QtQuick 1
- \ingroup qml-working-with-data
- \since QtQuick 1.0
- \brief The ListModel element defines a free-form list data source.
-
- The ListModel is a simple container of ListElement definitions, each containing data roles.
- The contents can be defined dynamically, or explicitly in QML.
-
- The number of elements in the model can be obtained from its \l count property.
- A number of familiar methods are also provided to manipulate the contents of the
- model, including append(), insert(), move(), remove() and set(). These methods
- accept dictionaries as their arguments; these are translated to ListElement objects
- by the model.
-
- Elements can be manipulated via the model using the setProperty() method, which
- allows the roles of the specified element to be set and changed.
-
- \section1 Example Usage
-
- The following example shows a ListModel containing three elements, with the roles
- "name" and "cost".
-
- \div {class="float-right"}
- \inlineimage listmodel.png
- \enddiv
-
- \snippet doc/src/snippets/qtquick1/listmodel.qml 0
-
- \clearfloat
- Roles (properties) in each element must begin with a lower-case letter and
- should be common to all elements in a model. The ListElement documentation
- provides more guidelines for how elements should be defined.
-
- Since the example model contains an \c id property, it can be referenced
- by views, such as the ListView in this example:
-
- \snippet doc/src/snippets/qtquick1/listmodel-simple.qml 0
- \dots 8
- \snippet doc/src/snippets/qtquick1/listmodel-simple.qml 1
-
- It is possible for roles to contain list data. In the following example we
- create a list of fruit attributes:
-
- \snippet doc/src/snippets/qtquick1/listmodel-nested.qml model
-
- The delegate displays all the fruit attributes:
-
- \div {class="float-right"}
- \inlineimage listmodel-nested.png
- \enddiv
-
- \snippet doc/src/snippets/qtquick1/listmodel-nested.qml delegate
-
- \clearfloat
- \section1 Modifying List Models
-
- The content of a ListModel may be created and modified using the clear(),
- append(), set(), insert() and setProperty() methods. For example:
-
- \snippet doc/src/snippets/qtquick1/listmodel-modify.qml delegate
-
- Note that when creating content dynamically the set of available properties
- cannot be changed once set. Whatever properties are first added to the model
- are the only permitted properties in the model.
-
- \section1 Using Threaded List Models with WorkerScript
-
- ListModel can be used together with WorkerScript access a list model
- from multiple threads. This is useful if list modifications are
- synchronous and take some time: the list operations can be moved to a
- different thread to avoid blocking of the main GUI thread.
-
- Here is an example that uses WorkerScript to periodically append the
- current time to a list model:
-
- \snippet examples/declarative/threading/threadedlistmodel/timedisplay.qml 0
-
- The included file, \tt dataloader.js, looks like this:
-
- \snippet examples/declarative/threading/threadedlistmodel/dataloader.js 0
-
- The timer in the main example sends messages to the worker script by calling
- \l WorkerScript::sendMessage(). When this message is received,
- \l{WorkerScript::onMessage}{WorkerScript.onMessage()} is invoked in \c dataloader.js,
- which appends the current time to the list model.
-
- Note the call to sync() from the \l{WorkerScript::onMessage}{WorkerScript.onMessage()}
- handler. You must call sync() or else the changes made to the list from the external
- thread will not be reflected in the list model in the main thread.
-
- \section1 Restrictions
-
- If a list model is to be accessed from a WorkerScript, it cannot
- contain list-type data. So, the following model cannot be used from a WorkerScript
- because of the list contained in the "attributes" property:
-
- \code
- ListModel {
- id: fruitModel
- ListElement {
- name: "Apple"
- cost: 2.45
- attributes: [
- ListElement { description: "Core" },
- ListElement { description: "Deciduous" }
- ]
- }
- }
- \endcode
-
- In addition, the WorkerScript cannot add list-type data to the model.
-
- \sa {qmlmodels}{Data Models}, {declarative/threading/threadedlistmodel}{Threaded ListModel example}, QtDeclarative
-*/
-
-
-/*
- A ListModel internally uses either a NestedListModel_1 or FlatListModel_1.
-
- A NestedListModel_1 can contain lists of ListElements (which
- when retrieved from get() is accessible as a list model within the list
- model) whereas a FlatListModel_1 cannot.
-
- ListModel uses a NestedListModel_1 to begin with, and if the model is later
- used from a WorkerScript, it changes to use a FlatListModel_1 instead. This
- is because ModelNode (which abstracts the nested list model data) needs
- access to the declarative engine and script engine, which cannot be
- safely used from outside of the main thread.
-*/
-
-QDeclarative1ListModel::QDeclarative1ListModel(QObject *parent)
-: QListModelInterface(parent), m_agent(0), m_nested(new NestedListModel_1(this)), m_flat(0)
-{
-}
-
-QDeclarative1ListModel::QDeclarative1ListModel(const QDeclarative1ListModel *orig, QDeclarative1ListModelWorkerAgent *parent)
-: QListModelInterface(parent), m_agent(0), m_nested(0), m_flat(0)
-{
- m_flat = new FlatListModel_1(this);
- m_flat->m_parentAgent = parent;
-
- if (orig->m_flat) {
- m_flat->m_roles = orig->m_flat->m_roles;
- m_flat->m_strings = orig->m_flat->m_strings;
- m_flat->m_values = orig->m_flat->m_values;
-
- m_flat->m_nodeData.reserve(m_flat->m_values.count());
- for (int i=0; i<m_flat->m_values.count(); i++)
- m_flat->m_nodeData << 0;
- }
-}
-
-QDeclarative1ListModel::~QDeclarative1ListModel()
-{
- if (m_agent)
- m_agent->release();
-
- delete m_nested;
- delete m_flat;
-}
-
-bool QDeclarative1ListModel::flatten()
-{
- if (m_flat)
- return true;
-
- QList<int> roles = m_nested->roles();
-
- QList<QHash<int, QVariant> > values;
- bool hasNested = false;
- for (int i=0; i<m_nested->count(); i++) {
- values.append(m_nested->data(i, roles, &hasNested));
- if (hasNested)
- return false;
- }
-
- FlatListModel_1 *flat = new FlatListModel_1(this);
- flat->m_values = values;
-
- for (int i=0; i<roles.count(); i++) {
- QString s = m_nested->toString(roles[i]);
- flat->m_roles.insert(roles[i], s);
- flat->m_strings.insert(s, roles[i]);
- }
-
- flat->m_nodeData.reserve(flat->m_values.count());
- for (int i=0; i<flat->m_values.count(); i++)
- flat->m_nodeData << 0;
-
- m_flat = flat;
- delete m_nested;
- m_nested = 0;
- return true;
-}
-
-bool QDeclarative1ListModel::inWorkerThread() const
-{
- return m_flat && m_flat->m_parentAgent;
-}
-
-QDeclarative1ListModelWorkerAgent *QDeclarative1ListModel::agent()
-{
- if (m_agent)
- return m_agent;
-
- if (!flatten()) {
- qmlInfo(this) << "List contains list-type data and cannot be used from a worker script";
- return 0;
- }
-
- m_agent = new QDeclarative1ListModelWorkerAgent(this);
- return m_agent;
-}
-
-QList<int> QDeclarative1ListModel::roles() const
-{
- return m_flat ? m_flat->roles() : m_nested->roles();
-}
-
-QString QDeclarative1ListModel::toString(int role) const
-{
- return m_flat ? m_flat->toString(role) : m_nested->toString(role);
-}
-
-QVariant QDeclarative1ListModel::data(int index, int role) const
-{
- if (index >= count() || index < 0)
- return QVariant();
-
- return m_flat ? m_flat->data(index, role) : m_nested->data(index, role);
-}
-
-/*!
- \qmlproperty int QtQuick1::ListModel::count
- The number of data entries in the model.
-*/
-int QDeclarative1ListModel::count() const
-{
- return m_flat ? m_flat->count() : m_nested->count();
-}
-
-/*!
- \qmlmethod QtQuick1::ListModel::clear()
-
- Deletes all content from the model.
-
- \sa append() remove()
-*/
-void QDeclarative1ListModel::clear()
-{
- int cleared = count();
- if (m_flat)
- m_flat->clear();
- else
- m_nested->clear();
-
- if (!inWorkerThread()) {
- emit itemsRemoved(0, cleared);
- emit countChanged();
- }
-}
-
-QDeclarative1ListModel *ModelNode::model(const NestedListModel_1 *model)
-{
- if (!modelCache) {
- modelCache = new QDeclarative1ListModel;
- QDeclarativeEngine::setContextForObject(modelCache,QDeclarativeEngine::contextForObject(model->m_listModel));
- modelCache->m_nested->_root = this; // ListModel defaults to nestable model
-
- for (int i=0; i<values.count(); ++i) {
- ModelNode *subNode = qvariant_cast<ModelNode *>(values.at(i));
- if (subNode)
- subNode->m_model = modelCache->m_nested;
- }
- }
- return modelCache;
-}
-
-ModelObject_1 *ModelNode::object(const NestedListModel_1 *model)
-{
- if (!objectCache) {
- objectCache = new ModelObject_1(this,
- const_cast<NestedListModel_1*>(model),
- QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(model->m_listModel)));
- QHash<QString, ModelNode *>::iterator it;
- for (it = properties.begin(); it != properties.end(); ++it) {
- objectCache->setValue(it.key().toUtf8(), model->valueForNode(*it));
- }
- objectCache->setNodeUpdatesEnabled(true);
- }
- return objectCache;
-}
-
-/*!
- \qmlmethod QtQuick1::ListModel::remove(int index)
-
- Deletes the content at \a index from the model.
-
- \sa clear()
-*/
-void QDeclarative1ListModel::remove(int index)
-{
- if (index < 0 || index >= count()) {
- qmlInfo(this) << tr("remove: index %1 out of range").arg(index);
- return;
- }
-
- if (m_flat)
- m_flat->remove(index);
- else
- m_nested->remove(index);
-
- if (!inWorkerThread()) {
- emit itemsRemoved(index, 1);
- emit countChanged();
- }
-}
-
-/*!
- \qmlmethod QtQuick1::ListModel::insert(int index, jsobject dict)
-
- Adds a new item to the list model at position \a index, with the
- values in \a dict.
-
- \code
- fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
- \endcode
-
- The \a index must be to an existing item in the list, or one past
- the end of the list (equivalent to append).
-
- \sa set() append()
-*/
-void QDeclarative1ListModel::insert(int index, const QScriptValue& valuemap)
-{
- if (!valuemap.isObject() || valuemap.isArray()) {
- qmlInfo(this) << tr("insert: value is not an object");
- return;
- }
-
- if (index < 0 || index > count()) {
- qmlInfo(this) << tr("insert: index %1 out of range").arg(index);
- return;
- }
-
- bool ok = m_flat ? m_flat->insert(index, valuemap) : m_nested->insert(index, valuemap);
- if (ok && !inWorkerThread()) {
- emit itemsInserted(index, 1);
- emit countChanged();
- }
-}
-
-/*!
- \qmlmethod QtQuick1::ListModel::move(int from, int to, int n)
-
- Moves \a n items \a from one position \a to another.
-
- The from and to ranges must exist; for example, to move the first 3 items
- to the end of the list:
-
- \code
- fruitModel.move(0, fruitModel.count - 3, 3)
- \endcode
-
- \sa append()
-*/
-void QDeclarative1ListModel::move(int from, int to, int n)
-{
- if (n==0 || from==to)
- return;
- if (!canMove(from, to, n)) {
- qmlInfo(this) << tr("move: out of range");
- return;
- }
-
- int origfrom = from;
- int origto = to;
- int orign = n;
- if (from > to) {
- // Only move forwards - flip if backwards moving
- int tfrom = from;
- int tto = to;
- from = tto;
- to = tto+n;
- n = tfrom-tto;
- }
-
- if (m_flat)
- m_flat->move(from, to, n);
- else
- m_nested->move(from, to, n);
-
- if (!inWorkerThread())
- emit itemsMoved(origfrom, origto, orign);
-}
-
-/*!
- \qmlmethod QtQuick1::ListModel::append(jsobject dict)
-
- Adds a new item to the end of the list model, with the
- values in \a dict.
-
- \code
- fruitModel.append({"cost": 5.95, "name":"Pizza"})
- \endcode
-
- \sa set() remove()
-*/
-void QDeclarative1ListModel::append(const QScriptValue& valuemap)
-{
- if (!valuemap.isObject() || valuemap.isArray()) {
- qmlInfo(this) << tr("append: value is not an object");
- return;
- }
-
- insert(count(), valuemap);
-}
-
-/*!
- \qmlmethod object QtQuick1::ListModel::get(int index)
-
- Returns the item at \a index in the list model. This allows the item
- data to be accessed or modified from JavaScript:
-
- \code
- Component.onCompleted: {
- fruitModel.append({"cost": 5.95, "name":"Jackfruit"});
- console.log(fruitModel.get(0).cost);
- fruitModel.get(0).cost = 10.95;
- }
- \endcode
-
- The \a index must be an element in the list.
-
- Note that properties of the returned object that are themselves objects
- will also be models, and this get() method is used to access elements:
-
- \code
- fruitModel.append(..., "attributes":
- [{"name":"spikes","value":"7mm"},
- {"name":"color","value":"green"}]);
- fruitModel.get(0).attributes.get(1).value; // == "green"
- \endcode
-
- \warning The returned object is not guaranteed to remain valid. It
- should not be used in \l{Property Binding}{property bindings}.
-
- \sa append()
-*/
-QScriptValue QDeclarative1ListModel::get(int index) const
-{
- // the internal flat/nested class checks for bad index
- return m_flat ? m_flat->get(index) : m_nested->get(index);
-}
-
-/*!
- \qmlmethod QtQuick1::ListModel::set(int index, jsobject dict)
-
- Changes the item at \a index in the list model with the
- values in \a dict. Properties not appearing in \a dict
- are left unchanged.
-
- \code
- fruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
- \endcode
-
- If \a index is equal to count() then a new item is appended to the
- list. Otherwise, \a index must be an element in the list.
-
- \sa append()
-*/
-void QDeclarative1ListModel::set(int index, const QScriptValue& valuemap)
-{
- QList<int> roles;
- set(index, valuemap, &roles);
- if (!roles.isEmpty() && !inWorkerThread())
- emit itemsChanged(index, 1, roles);
-}
-
-void QDeclarative1ListModel::set(int index, const QScriptValue& valuemap, QList<int> *roles)
-{
- if (!valuemap.isObject() || valuemap.isArray()) {
- qmlInfo(this) << tr("set: value is not an object");
- return;
- }
- if (index > count() || index < 0) {
- qmlInfo(this) << tr("set: index %1 out of range").arg(index);
- return;
- }
-
- if (index == count()) {
- append(valuemap);
- } else {
- if (m_flat)
- m_flat->set(index, valuemap, roles);
- else
- m_nested->set(index, valuemap, roles);
- }
-}
-
-/*!
- \qmlmethod QtQuick1::ListModel::setProperty(int index, string property, variant value)
-
- Changes the \a property of the item at \a index in the list model to \a value.
-
- \code
- fruitModel.setProperty(3, "cost", 5.95)
- \endcode
-
- The \a index must be an element in the list.
-
- \sa append()
-*/
-void QDeclarative1ListModel::setProperty(int index, const QString& property, const QVariant& value)
-{
- QList<int> roles;
- setProperty(index, property, value, &roles);
- if (!roles.isEmpty() && !inWorkerThread())
- emit itemsChanged(index, 1, roles);
-}
-
-void QDeclarative1ListModel::setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles)
-{
- if (count() == 0 || index >= count() || index < 0) {
- qmlInfo(this) << tr("set: index %1 out of range").arg(index);
- return;
- }
-
- if (m_flat)
- m_flat->setProperty(index, property, value, roles);
- else
- m_nested->setProperty(index, property, value, roles);
-}
-
-/*!
- \qmlmethod QtQuick1::ListModel::sync()
-
- Writes any unsaved changes to the list model after it has been modified
- from a worker script.
-*/
-void QDeclarative1ListModel::sync()
-{
- // This is just a dummy method to make it look like sync() exists in
- // ListModel (and not just QDeclarative1ListModelWorkerAgent) and to let
- // us document sync().
- qmlInfo(this) << "List sync() can only be called from a WorkerScript";
-}
-
-bool QDeclarative1ListModelParser::compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
-{
- QList<QVariant> values = prop.assignedValues();
- for(int ii = 0; ii < values.count(); ++ii) {
- const QVariant &value = values.at(ii);
-
- if(value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
- QDeclarativeCustomParserNode node =
- qvariant_cast<QDeclarativeCustomParserNode>(value);
-
- if (node.name() != listElementTypeName) {
- const QMetaObject *mo = resolveType(node.name());
- if (mo != &QDeclarative1ListElement::staticMetaObject) {
- error(node, QDeclarative1ListModel::tr("ListElement: cannot contain nested elements"));
- return false;
- }
- listElementTypeName = node.name(); // cache right name for next time
- }
-
- {
- ListInstruction li;
- li.type = ListInstruction::Push;
- li.dataIdx = -1;
- instr << li;
- }
-
- QList<QDeclarativeCustomParserProperty> props = node.properties();
- for(int jj = 0; jj < props.count(); ++jj) {
- const QDeclarativeCustomParserProperty &nodeProp = props.at(jj);
- if (nodeProp.name().isEmpty()) {
- error(nodeProp, QDeclarative1ListModel::tr("ListElement: cannot contain nested elements"));
- return false;
- }
- if (nodeProp.name() == "id") {
- error(nodeProp, QDeclarative1ListModel::tr("ListElement: cannot use reserved \"id\" property"));
- return false;
- }
-
- ListInstruction li;
- int ref = data.count();
- data.append(nodeProp.name());
- data.append('\0');
- li.type = ListInstruction::Set;
- li.dataIdx = ref;
- instr << li;
-
- if(!compileProperty(nodeProp, instr, data))
- return false;
-
- li.type = ListInstruction::Pop;
- li.dataIdx = -1;
- instr << li;
- }
-
- {
- ListInstruction li;
- li.type = ListInstruction::Pop;
- li.dataIdx = -1;
- instr << li;
- }
-
- } else {
-
- QDeclarativeParser::Variant variant =
- qvariant_cast<QDeclarativeParser::Variant>(value);
-
- int ref = data.count();
-
- QByteArray d;
- d += char(variant.type()); // type tag
- if (variant.isString()) {
- d += variant.asString().toUtf8();
- } else if (variant.isNumber()) {
- d += QByteArray::number(variant.asNumber(),'g',20);
- } else if (variant.isBoolean()) {
- d += char(variant.asBoolean());
- } else if (variant.isScript()) {
- if (definesEmptyList(variant.asScript())) {
- d[0] = char(QDeclarativeParser::Variant::Invalid); // marks empty list
- } else {
- QByteArray script = variant.asScript().toUtf8();
- int v = evaluateEnum(script);
- if (v<0) {
- if (script.startsWith("QT_TR_NOOP(\"") && script.endsWith("\")")) {
- d[0] = char(QDeclarativeParser::Variant::String);
- d += script.mid(12,script.length()-14);
- } else {
- error(prop, QDeclarative1ListModel::tr("ListElement: cannot use script for property value"));
- return false;
- }
- } else {
- d[0] = char(QDeclarativeParser::Variant::Number);
- d += QByteArray::number(v);
- }
- }
- }
- d.append('\0');
- data.append(d);
-
- ListInstruction li;
- li.type = ListInstruction::Value;
- li.dataIdx = ref;
- instr << li;
- }
- }
-
- return true;
-}
-
-QByteArray QDeclarative1ListModelParser::compile(const QList<QDeclarativeCustomParserProperty> &customProps)
-{
- QList<ListInstruction> instr;
- QByteArray data;
- listElementTypeName = QByteArray(); // unknown
-
- for(int ii = 0; ii < customProps.count(); ++ii) {
- const QDeclarativeCustomParserProperty &prop = customProps.at(ii);
- if(!prop.name().isEmpty()) { // isn't default property
- error(prop, QDeclarative1ListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name())));
- return QByteArray();
- }
-
- if(!compileProperty(prop, instr, data)) {
- return QByteArray();
- }
- }
-
- int size = sizeof(ListModelData) +
- instr.count() * sizeof(ListInstruction) +
- data.count();
-
- QByteArray rv;
- rv.resize(size);
-
- ListModelData *lmd = (ListModelData *)rv.data();
- lmd->dataOffset = sizeof(ListModelData) +
- instr.count() * sizeof(ListInstruction);
- lmd->instrCount = instr.count();
- for (int ii = 0; ii < instr.count(); ++ii)
- lmd->instructions()[ii] = instr.at(ii);
- ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count());
-
- return rv;
-}
-
-void QDeclarative1ListModelParser::setCustomData(QObject *obj, const QByteArray &d)
-{
- QDeclarative1ListModel *rv = static_cast<QDeclarative1ListModel *>(obj);
-
- ModelNode *root = new ModelNode(rv->m_nested);
- rv->m_nested->m_ownsRoot = true;
- rv->m_nested->_root = root;
- QStack<ModelNode *> nodes;
- nodes << root;
-
- bool processingSet = false;
-
- const ListModelData *lmd = (const ListModelData *)d.constData();
- const char *data = ((const char *)lmd) + lmd->dataOffset;
-
- for (int ii = 0; ii < lmd->instrCount; ++ii) {
- const ListInstruction &instr = lmd->instructions()[ii];
-
- switch(instr.type) {
- case ListInstruction::Push:
- {
- ModelNode *n = nodes.top();
- ModelNode *n2 = new ModelNode(rv->m_nested);
- n->values << QVariant::fromValue(n2);
- nodes.push(n2);
- if (processingSet)
- n->isArray = true;
- }
- break;
-
- case ListInstruction::Pop:
- nodes.pop();
- break;
-
- case ListInstruction::Value:
- {
- ModelNode *n = nodes.top();
- switch (QDeclarativeParser::Variant::Type(data[instr.dataIdx])) {
- case QDeclarativeParser::Variant::Invalid:
- n->isArray = true;
- break;
- case QDeclarativeParser::Variant::Boolean:
- n->values.append(bool(data[1 + instr.dataIdx]));
- break;
- case QDeclarativeParser::Variant::Number:
- n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble());
- break;
- case QDeclarativeParser::Variant::String:
- n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx));
- break;
- default:
- Q_ASSERT("Format error in ListInstruction");
- }
-
- processingSet = false;
- }
- break;
-
- case ListInstruction::Set:
- {
- ModelNode *n = nodes.top();
- ModelNode *n2 = new ModelNode(rv->m_nested);
- n->properties.insert(QString::fromUtf8(data + instr.dataIdx), n2);
- nodes.push(n2);
- processingSet = true;
- }
- break;
- }
- }
-
- ModelNode *rootNode = rv->m_nested->_root;
- for (int i=0; i<rootNode->values.count(); ++i) {
- ModelNode *node = qvariant_cast<ModelNode *>(rootNode->values[i]);
- node->listIndex = i;
- node->updateListIndexes();
- }
-}
-
-bool QDeclarative1ListModelParser::definesEmptyList(const QString &s)
-{
- if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) {
- for (int i=1; i<s.length()-1; i++) {
- if (!s[i].isSpace())
- return false;
- }
- return true;
- }
- return false;
-}
-
-
-/*!
- \qmlclass ListElement QDeclarative1ListElement
- \inqmlmodule QtQuick 1
- \ingroup qml-working-with-data
- \since QtQuick 1.0
- \brief The ListElement element defines a data item in a ListModel.
-
- List elements are defined inside ListModel definitions, and represent items in a
- list that will be displayed using ListView or \l Repeater items.
-
- List elements are defined like other QML elements except that they contain
- a collection of \e role definitions instead of properties. Using the same
- syntax as property definitions, roles both define how the data is accessed
- and include the data itself.
-
- The names used for roles must begin with a lower-case letter and should be
- common to all elements in a given model. Values must be simple constants; either
- strings (quoted and optionally within a call to QT_TR_NOOP), boolean values
- (true, false), numbers, or enumeration values (such as AlignText.AlignHCenter).
-
- \section1 Referencing Roles
-
- The role names are used by delegates to obtain data from list elements.
- Each role name is accessible in the delegate's scope, and refers to the
- corresponding role in the current element. Where a role name would be
- ambiguous to use, it can be accessed via the \l{ListView::}{model}
- property (e.g., \c{model.cost} instead of \c{cost}).
-
- \section1 Example Usage
-
- The following model defines a series of list elements, each of which
- contain "name" and "cost" roles and their associated values.
-
- \snippet doc/src/snippets/qtquick1/qml-data-models/listelements.qml model
-
- The delegate obtains the name and cost for each element by simply referring
- to \c name and \c cost:
-
- \snippet doc/src/snippets/qtquick1/qml-data-models/listelements.qml view
-
- \sa ListModel
-*/
-
-FlatListModel_1::FlatListModel_1(QDeclarative1ListModel *base)
- : m_scriptEngine(0), m_listModel(base), m_scriptClass(0), m_parentAgent(0)
-{
-}
-
-FlatListModel_1::~FlatListModel_1()
-{
- qDeleteAll(m_nodeData);
-}
-
-QVariant FlatListModel_1::data(int index, int role) const
-{
- Q_ASSERT(index >= 0 && index < m_values.count());
- if (m_values[index].contains(role))
- return m_values[index][role];
- return QVariant();
-}
-
-QList<int> FlatListModel_1::roles() const
-{
- return m_roles.keys();
-}
-
-QString FlatListModel_1::toString(int role) const
-{
- if (m_roles.contains(role))
- return m_roles[role];
- return QString();
-}
-
-int FlatListModel_1::count() const
-{
- return m_values.count();
-}
-
-void FlatListModel_1::clear()
-{
- m_values.clear();
-
- qDeleteAll(m_nodeData);
- m_nodeData.clear();
-}
-
-void FlatListModel_1::remove(int index)
-{
- m_values.removeAt(index);
- removedNode(index);
-}
-
-bool FlatListModel_1::insert(int index, const QScriptValue &value)
-{
- Q_ASSERT(index >= 0 && index <= m_values.count());
-
- QHash<int, QVariant> row;
- if (!addValue(value, &row, 0))
- return false;
-
- m_values.insert(index, row);
- insertedNode(index);
-
- return true;
-}
-
-QScriptValue FlatListModel_1::get(int index) const
-{
- QScriptEngine *scriptEngine = m_scriptEngine ? m_scriptEngine : QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(m_listModel));
-
- if (!scriptEngine)
- return 0;
-
- if (index < 0 || index >= m_values.count())
- return scriptEngine->undefinedValue();
-
- FlatListModel_1 *that = const_cast<FlatListModel_1*>(this);
- if (!m_scriptClass)
- that->m_scriptClass = new FlatListScriptClass_1(that, scriptEngine);
-
- FlatNodeData_1 *data = m_nodeData.value(index);
- if (!data) {
- data = new FlatNodeData_1(index);
- that->m_nodeData.replace(index, data);
- }
-
- return QScriptDeclarativeClass::newObject(scriptEngine, m_scriptClass, new FlatNodeObjectData(data));
-}
-
-void FlatListModel_1::set(int index, const QScriptValue &value, QList<int> *roles)
-{
- Q_ASSERT(index >= 0 && index < m_values.count());
-
- QHash<int, QVariant> row = m_values[index];
- if (addValue(value, &row, roles))
- m_values[index] = row;
-}
-
-void FlatListModel_1::setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles)
-{
- Q_ASSERT(index >= 0 && index < m_values.count());
-
- QHash<QString, int>::Iterator iter = m_strings.find(property);
- int role;
- if (iter == m_strings.end()) {
- role = m_roles.count();
- m_roles.insert(role, property);
- m_strings.insert(property, role);
- } else {
- role = iter.value();
- }
-
- if (m_values[index][role] != value) {
- roles->append(role);
- m_values[index][role] = value;
- }
-}
-
-void FlatListModel_1::move(int from, int to, int n)
-{
- qdeclarativelistmodel_move<QList<QHash<int, QVariant> > >(from, to, n, &m_values);
- moveNodes(from, to, n);
-}
-
-bool FlatListModel_1::addValue(const QScriptValue &value, QHash<int, QVariant> *row, QList<int> *roles)
-{
- QScriptValueIterator it(value);
- while (it.hasNext()) {
- it.next();
- QScriptValue value = it.value();
- if (!value.isVariant() && !value.isRegExp() && !value.isDate() && value.isObject()) {
- qmlInfo(m_listModel) << "Cannot add list-type data when modifying or after modification from a worker script";
- return false;
- }
-
- QString name = it.name();
- QVariant v = it.value().toVariant();
-
- QHash<QString, int>::Iterator iter = m_strings.find(name);
- if (iter == m_strings.end()) {
- int role = m_roles.count();
- m_roles.insert(role, name);
- iter = m_strings.insert(name, role);
- if (roles)
- roles->append(role);
- } else {
- int role = iter.value();
- if (roles && row->contains(role) && row->value(role) != v)
- roles->append(role);
- }
- row->insert(*iter, v);
- }
- return true;
-}
-
-void FlatListModel_1::insertedNode(int index)
-{
- if (index >= 0 && index <= m_values.count()) {
- m_nodeData.insert(index, 0);
-
- for (int i=index + 1; i<m_nodeData.count(); i++) {
- if (m_nodeData[i])
- m_nodeData[i]->index = i;
- }
- }
-}
-
-void FlatListModel_1::removedNode(int index)
-{
- if (index >= 0 && index < m_nodeData.count()) {
- delete m_nodeData.takeAt(index);
-
- for (int i=index; i<m_nodeData.count(); i++) {
- if (m_nodeData[i])
- m_nodeData[i]->index = i;
- }
- }
-}
-
-void FlatListModel_1::moveNodes(int from, int to, int n)
-{
- if (!m_listModel->canMove(from, to, n))
- return;
-
- qdeclarativelistmodel_move<QList<FlatNodeData_1 *> >(from, to, n, &m_nodeData);
-
- for (int i=from; i<from + (to-from); i++) {
- if (m_nodeData[i])
- m_nodeData[i]->index = i;
- }
-}
-
-
-
-FlatNodeData_1::~FlatNodeData_1()
-{
- for (QSet<FlatNodeObjectData *>::Iterator iter = objects.begin(); iter != objects.end(); ++iter) {
- FlatNodeObjectData *data = *iter;
- data->nodeData = 0;
- }
-}
-
-void FlatNodeData_1::addData(FlatNodeObjectData *data)
-{
- objects.insert(data);
-}
-
-void FlatNodeData_1::removeData(FlatNodeObjectData *data)
-{
- objects.remove(data);
-}
-
-
-FlatListScriptClass_1::FlatListScriptClass_1(FlatListModel_1 *model, QScriptEngine *seng)
- : QScriptDeclarativeClass(seng),
- m_model(model)
-{
-}
-
-QScriptDeclarativeClass::Value FlatListScriptClass_1::property(Object *obj, const Identifier &name)
-{
- FlatNodeObjectData *objData = static_cast<FlatNodeObjectData*>(obj);
- if (!objData->nodeData) // item at this index has been deleted
- return QScriptDeclarativeClass::Value(engine(), engine()->undefinedValue());
-
- int index = objData->nodeData->index;
- QString propName = toString(name);
- int role = m_model->m_strings.value(propName, -1);
-
- if (role >= 0 && index >=0 ) {
- const QHash<int, QVariant> &row = m_model->m_values[index];
- QScriptValue sv = engine()->toScriptValue<QVariant>(row[role]);
- return QScriptDeclarativeClass::Value(engine(), sv);
- }
-
- return QScriptDeclarativeClass::Value(engine(), engine()->undefinedValue());
-}
-
-void FlatListScriptClass_1::setProperty(Object *obj, const Identifier &name, const QScriptValue &value)
-{
- if (!value.isVariant() && !value.isRegExp() && !value.isDate() && value.isObject()) {
- qmlInfo(m_model->m_listModel) << "Cannot add list-type data when modifying or after modification from a worker script";
- return;
- }
-
- FlatNodeObjectData *objData = static_cast<FlatNodeObjectData*>(obj);
- if (!objData->nodeData) // item at this index has been deleted
- return;
-
- int index = objData->nodeData->index;
- QString propName = toString(name);
-
- int role = m_model->m_strings.value(propName, -1);
- if (role >= 0 && index >= 0) {
- QHash<int, QVariant> &row = m_model->m_values[index];
- row[role] = value.toVariant();
-
- QList<int> roles;
- roles << role;
- if (m_model->m_parentAgent) {
- // This is the list in the worker thread, so tell the agent to
- // emit itemsChanged() later
- m_model->m_parentAgent->changedData(index, 1, roles);
- } else {
- // This is the list in the main thread, so emit itemsChanged()
- emit m_model->m_listModel->itemsChanged(index, 1, roles);
- }
- }
-}
-
-QScriptClass::QueryFlags FlatListScriptClass_1::queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags)
-{
- return (QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess);
-}
-
-bool FlatListScriptClass_1::compare(Object *obj1, Object *obj2)
-{
- FlatNodeObjectData *data1 = static_cast<FlatNodeObjectData*>(obj1);
- FlatNodeObjectData *data2 = static_cast<FlatNodeObjectData*>(obj2);
-
- if (!data1->nodeData || !data2->nodeData)
- return false;
-
- return data1->nodeData->index == data2->nodeData->index;
-}
-
-
-
-NestedListModel_1::NestedListModel_1(QDeclarative1ListModel *base)
- : _root(0), m_ownsRoot(false), m_listModel(base), _rolesOk(false)
-{
-}
-
-NestedListModel_1::~NestedListModel_1()
-{
- if (m_ownsRoot)
- delete _root;
-}
-
-QVariant NestedListModel_1::valueForNode(ModelNode *node, bool *hasNested) const
-{
- QObject *rv = 0;
- if (hasNested)
- *hasNested = false;
-
- if (node->isArray) {
- // List
- rv = node->model(this);
- if (hasNested)
- *hasNested = true;
- } else {
- if (!node->properties.isEmpty()) {
- // Object
- rv = node->object(this);
- } else if (node->values.count() == 0) {
- // Invalid
- return QVariant();
- } else if (node->values.count() == 1) {
- // Value
- QVariant &var = node->values[0];
- ModelNode *valueNode = qvariant_cast<ModelNode *>(var);
- if (valueNode) {
- if (!valueNode->properties.isEmpty())
- rv = valueNode->object(this);
- else
- rv = valueNode->model(this);
- } else {
- return var;
- }
- }
- }
-
- if (rv) {
- return QVariant::fromValue(rv);
- } else {
- return QVariant();
- }
-}
-
-QHash<int,QVariant> NestedListModel_1::data(int index, const QList<int> &roles, bool *hasNested) const
-{
- Q_ASSERT(_root && index >= 0 && index < _root->values.count());
- checkRoles();
- QHash<int, QVariant> rv;
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- if (!node)
- return rv;
-
- for (int ii = 0; ii < roles.count(); ++ii) {
- const QString &roleString = roleStrings.at(roles.at(ii));
-
- QHash<QString, ModelNode *>::ConstIterator iter = node->properties.find(roleString);
- if (iter != node->properties.end()) {
- ModelNode *row = *iter;
- rv.insert(roles.at(ii), valueForNode(row, hasNested));
- }
- }
-
- return rv;
-}
-
-QVariant NestedListModel_1::data(int index, int role) const
-{
- Q_ASSERT(_root && index >= 0 && index < _root->values.count());
- checkRoles();
- QVariant rv;
- if (roleStrings.count() < role)
- return rv;
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- if (!node)
- return rv;
-
- const QString &roleString = roleStrings.at(role);
-
- QHash<QString, ModelNode *>::ConstIterator iter = node->properties.find(roleString);
- if (iter != node->properties.end()) {
- ModelNode *row = *iter;
- rv = valueForNode(row);
- }
-
- return rv;
-}
-
-int NestedListModel_1::count() const
-{
- if (!_root) return 0;
- return _root->values.count();
-}
-
-void NestedListModel_1::clear()
-{
- if (_root)
- _root->clear();
-}
-
-void NestedListModel_1::remove(int index)
-{
- if (!_root)
- return;
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- _root->values.removeAt(index);
- if (node)
- delete node;
-}
-
-bool NestedListModel_1::insert(int index, const QScriptValue& valuemap)
-{
- if (!_root) {
- _root = new ModelNode(this);
- m_ownsRoot = true;
- }
-
- ModelNode *mn = new ModelNode(this);
- mn->listIndex = index;
- mn->setObjectValue(valuemap);
- _root->values.insert(index,QVariant::fromValue(mn));
- return true;
-}
-
-void NestedListModel_1::move(int from, int to, int n)
-{
- if (!_root)
- return;
- qdeclarativelistmodel_move<QVariantList>(from, to, n, &_root->values);
-}
-
-QScriptValue NestedListModel_1::get(int index) const
-{
- QDeclarativeEngine *eng = qmlEngine(m_listModel);
- if (!eng)
- return 0;
-
- if (index < 0 || index >= count()) {
- QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(eng);
- if (seng)
- return seng->undefinedValue();
- return 0;
- }
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- if (!node)
- return 0;
-
- return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng);
-}
-
-void NestedListModel_1::set(int index, const QScriptValue& valuemap, QList<int> *roles)
-{
- Q_ASSERT(index >=0 && index < count());
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- bool emitItemsChanged = node->setObjectValue(valuemap);
- if (!emitItemsChanged)
- return;
-
- QScriptValueIterator it(valuemap);
- while (it.hasNext()) {
- it.next();
- int r = roleStrings.indexOf(it.name());
- if (r < 0) {
- r = roleStrings.count();
- roleStrings << it.name();
- }
- roles->append(r);
- }
-}
-
-void NestedListModel_1::setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles)
-{
- Q_ASSERT(index >=0 && index < count());
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- bool emitItemsChanged = node->setProperty(property, value);
- if (!emitItemsChanged)
- return;
-
- int r = roleStrings.indexOf(property);
- if (r < 0) {
- r = roleStrings.count();
- roleStrings << property;
- }
- roles->append(r);
-}
-
-void NestedListModel_1::checkRoles() const
-{
- if (_rolesOk || !_root)
- return;
-
- for (int i = 0; i<_root->values.count(); ++i) {
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(i));
- if (node) {
- foreach (const QString &role, node->properties.keys()) {
- if (!roleStrings.contains(role))
- roleStrings.append(role);
- }
- }
- }
-
- _rolesOk = true;
-}
-
-QList<int> NestedListModel_1::roles() const
-{
- checkRoles();
- QList<int> rv;
- for (int ii = 0; ii < roleStrings.count(); ++ii)
- rv << ii;
- return rv;
-}
-
-QString NestedListModel_1::toString(int role) const
-{
- checkRoles();
- if (role < roleStrings.count())
- return roleStrings.at(role);
- else
- return QString();
-}
-
-
-ModelNode::ModelNode(NestedListModel_1 *model)
-: modelCache(0), objectCache(0), isArray(false), m_model(model), listIndex(-1)
-{
-}
-
-ModelNode::~ModelNode()
-{
- clear();
- if (modelCache) { modelCache->m_nested->_root = 0/* ==this */; delete modelCache; modelCache = 0; }
- if (objectCache) { delete objectCache; objectCache = 0; }
-}
-
-void ModelNode::clear()
-{
- ModelNode *node;
- for (int ii = 0; ii < values.count(); ++ii) {
- node = qvariant_cast<ModelNode *>(values.at(ii));
- if (node) { delete node; node = 0; }
- }
- values.clear();
-
- qDeleteAll(properties.values());
- properties.clear();
-}
-
-bool ModelNode::setObjectValue(const QScriptValue& valuemap, bool writeToCache)
-{
- bool emitItemsChanged = false;
-
- QScriptValueIterator it(valuemap);
- while (it.hasNext()) {
- it.next();
- ModelNode *prev = properties.value(it.name());
- ModelNode *value = new ModelNode(m_model);
- QScriptValue v = it.value();
-
- if (v.isArray()) {
- value->isArray = true;
- value->setListValue(v);
- if (writeToCache && objectCache)
- objectCache->setValue(it.name().toUtf8(), QVariant::fromValue(value->model(m_model)));
- emitItemsChanged = true; // for now, too inefficient to check whether list and sublists have changed
- } else {
- value->values << v.toVariant();
- if (writeToCache && objectCache)
- objectCache->setValue(it.name().toUtf8(), value->values.last());
- if (!emitItemsChanged && prev && prev->values.count() == 1
- && prev->values[0] != value->values.last()) {
- emitItemsChanged = true;
- }
- }
- if (properties.contains(it.name()))
- delete properties[it.name()];
- properties.insert(it.name(), value);
- }
- return emitItemsChanged;
-}
-
-void ModelNode::setListValue(const QScriptValue& valuelist) {
- values.clear();
- int size = valuelist.property(QLatin1String("length")).toInt32();
- for (int i=0; i<size; i++) {
- ModelNode *value = new ModelNode(m_model);
- QScriptValue v = valuelist.property(i);
- if (v.isArray()) {
- value->isArray = true;
- value->setListValue(v);
- } else if (v.isObject()) {
- value->listIndex = i;
- value->setObjectValue(v);
- } else {
- value->listIndex = i;
- value->values << v.toVariant();
- }
- values.append(QVariant::fromValue(value));
- }
-}
-
-bool ModelNode::setProperty(const QString& prop, const QVariant& val) {
- QHash<QString, ModelNode *>::const_iterator it = properties.find(prop);
- bool emitItemsChanged = false;
- if (it != properties.end()) {
- if (val != (*it)->values[0])
- emitItemsChanged = true;
- (*it)->values[0] = val;
- } else {
- ModelNode *n = new ModelNode(m_model);
- n->values << val;
- properties.insert(prop,n);
- }
- if (objectCache)
- objectCache->setValue(prop.toUtf8(), val);
- return emitItemsChanged;
-}
-
-void ModelNode::updateListIndexes()
-{
- for (QHash<QString, ModelNode *>::ConstIterator iter = properties.begin(); iter != properties.end(); ++iter) {
- ModelNode *node = iter.value();
- if (node->isArray) {
- for (int i=0; i<node->values.count(); ++i) {
- ModelNode *subNode = qvariant_cast<ModelNode *>(node->values.at(i));
- if (subNode)
- subNode->listIndex = i;
- }
- }
- node->updateListIndexes();
- }
-}
-
-/*
- Need to call this to emit itemsChanged() for modifications outside of set()
- and setProperty(), i.e. if an item returned from get() is modified
-*/
-void ModelNode::changedProperty(const QString &name) const
-{
- if (listIndex < 0)
- return;
-
- m_model->checkRoles();
- QList<int> roles;
- int role = m_model->roleStrings.indexOf(name);
- if (role < 0)
- roles = m_model->roles();
- else
- roles << role;
- emit m_model->m_listModel->itemsChanged(listIndex, 1, roles);
-}
-
-void ModelNode::dump(ModelNode *node, int ind)
-{
- QByteArray indentBa(ind * 4, ' ');
- const char *indent = indentBa.constData();
-
- for (int ii = 0; ii < node->values.count(); ++ii) {
- ModelNode *subNode = qvariant_cast<ModelNode *>(node->values.at(ii));
- if (subNode) {
- qWarning().nospace() << indent << "Sub-node " << ii;
- dump(subNode, ind + 1);
- } else {
- qWarning().nospace() << indent << "Sub-node " << ii << ": " << node->values.at(ii).toString();
- }
- }
-
- for (QHash<QString, ModelNode *>::ConstIterator iter = node->properties.begin(); iter != node->properties.end(); ++iter) {
- qWarning().nospace() << indent << "Property " << iter.key() << ':';
- dump(iter.value(), ind + 1);
- }
-}
-
-ModelObject_1::ModelObject_1(ModelNode *node, NestedListModel_1 *model, QScriptEngine *seng)
- : m_model(model),
- m_node(node),
- m_meta(new ModelNodeMetaObject_1(seng, this))
-{
-}
-
-void ModelObject_1::setValue(const QByteArray &name, const QVariant &val)
-{
- m_meta->setValue(name, val);
- //setProperty(name.constData(), val);
-}
-
-void ModelObject_1::setNodeUpdatesEnabled(bool enable)
-{
- m_meta->m_enabled = enable;
-}
-
-
-ModelNodeMetaObject_1::ModelNodeMetaObject_1(QScriptEngine *seng, ModelObject_1 *object)
- : QDeclarative1OpenMetaObject(object),
- m_enabled(false),
- m_seng(seng),
- m_obj(object)
-{
-}
-
-void ModelNodeMetaObject_1::propertyWritten(int index)
-{
- if (!m_enabled)
- return;
-
- QString propName = QString::fromUtf8(name(index));
- QVariant value = operator[](index);
-
- QScriptValue sv = m_seng->newObject();
- sv.setProperty(propName, m_seng->newVariant(value));
- bool changed = m_obj->m_node->setObjectValue(sv, false);
- if (changed)
- m_obj->m_node->changedProperty(propName);
-}
-
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativelistmodel_p.h b/src/qtquick1/util/qdeclarativelistmodel_p.h
deleted file mode 100644
index c2b433f079..0000000000
--- a/src/qtquick1/util/qdeclarativelistmodel_p.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTMODEL_H
-#define QDECLARATIVELISTMODEL_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/private/qdeclarativecustomparser_p.h>
-
-#include <QtCore/QObject>
-#include <QtCore/QStringList>
-#include <QtCore/QHash>
-#include <QtCore/QList>
-#include <QtCore/QVariant>
-#include <QtQuick1/private/qlistmodelinterface_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class FlatListModel_1;
-class NestedListModel_1;
-class QDeclarative1ListModelWorkerAgent;
-struct ModelNode;
-class FlatListScriptClass_1;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1ListModel : public QListModelInterface
-{
- Q_OBJECT
- Q_PROPERTY(int count READ count NOTIFY countChanged)
-
-public:
- QDeclarative1ListModel(QObject *parent=0);
- ~QDeclarative1ListModel();
-
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
- virtual int count() const;
- virtual QVariant data(int index, int role) const;
-
- Q_INVOKABLE void clear();
- Q_INVOKABLE void remove(int index);
- Q_INVOKABLE void append(const QScriptValue&);
- Q_INVOKABLE void insert(int index, const QScriptValue&);
- Q_INVOKABLE QScriptValue get(int index) const;
- Q_INVOKABLE void set(int index, const QScriptValue&);
- Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);
- Q_INVOKABLE void move(int from, int to, int count);
- Q_INVOKABLE void sync();
-
- QDeclarative1ListModelWorkerAgent *agent();
-
-Q_SIGNALS:
- void countChanged();
-
-private:
- friend class QDeclarative1ListModelParser;
- friend class QDeclarative1ListModelWorkerAgent;
- friend class FlatListModel_1;
- friend class FlatListScriptClass_1;
- friend struct ModelNode;
-
- // Constructs a flat list model for a worker agent
- QDeclarative1ListModel(const QDeclarative1ListModel *orig, QDeclarative1ListModelWorkerAgent *parent);
-
- void set(int index, const QScriptValue&, QList<int> *roles);
- void setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles);
-
- bool flatten();
- bool inWorkerThread() const;
-
- inline bool canMove(int from, int to, int n) const { return !(from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0); }
-
- QDeclarative1ListModelWorkerAgent *m_agent;
- NestedListModel_1 *m_nested;
- FlatListModel_1 *m_flat;
-};
-
-// ### FIXME
-class QDeclarative1ListElement : public QObject
-{
-Q_OBJECT
-};
-
-class QDeclarative1ListModelParser : public QDeclarativeCustomParser
-{
-public:
- QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
- void setCustomData(QObject *, const QByteArray &);
-
-private:
- struct ListInstruction
- {
- enum { Push, Pop, Value, Set } type;
- int dataIdx;
- };
- struct ListModelData
- {
- int dataOffset;
- int instrCount;
- ListInstruction *instructions() const;
- };
- bool compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data);
-
- bool definesEmptyList(const QString &);
-
- QByteArray listElementTypeName;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1ListModel)
-QML_DECLARE_TYPE(QDeclarative1ListElement)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVELISTMODEL_H
diff --git a/src/qtquick1/util/qdeclarativelistmodel_p_p.h b/src/qtquick1/util/qdeclarativelistmodel_p_p.h
deleted file mode 100644
index 6cf452dfe3..0000000000
--- a/src/qtquick1/util/qdeclarativelistmodel_p_p.h
+++ /dev/null
@@ -1,280 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTMODEL_P_P_H
-#define QDECLARATIVELISTMODEL_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-#include "QtQuick1/private/qdeclarativelistmodel_p.h"
-#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h"
-#include <QtDeclarative/qdeclarative.h>
-
-#include <QtDeclarative/private/qscriptdeclarativeclass_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QScriptEngine;
-
-
-class QDeclarative1OpenMetaObject;
-class QDeclarative1ListModelWorkerAgent;
-struct ModelNode;
-class FlatListScriptClass_1;
-class FlatNodeData_1;
-
-class FlatListModel_1
-{
-public:
- FlatListModel_1(QDeclarative1ListModel *base);
- ~FlatListModel_1();
-
- QVariant data(int index, int role) const;
-
- QList<int> roles() const;
- QString toString(int role) const;
-
- int count() const;
- void clear();
- void remove(int index);
- bool insert(int index, const QScriptValue&);
- QScriptValue get(int index) const;
- void set(int index, const QScriptValue&, QList<int> *roles);
- void setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles);
- void move(int from, int to, int count);
-
-private:
- friend class QDeclarative1ListModelWorkerAgent;
- friend class QDeclarative1ListModel;
- friend class FlatListScriptClass_1;
- friend class FlatNodeData_1;
-
- bool addValue(const QScriptValue &value, QHash<int, QVariant> *row, QList<int> *roles);
- void insertedNode(int index);
- void removedNode(int index);
- void moveNodes(int from, int to, int n);
-
- QScriptEngine *m_scriptEngine;
- QHash<int, QString> m_roles;
- QHash<QString, int> m_strings;
- QList<QHash<int, QVariant> > m_values;
- QDeclarative1ListModel *m_listModel;
-
- FlatListScriptClass_1 *m_scriptClass;
- QList<FlatNodeData_1 *> m_nodeData;
- QDeclarative1ListModelWorkerAgent *m_parentAgent;
-};
-
-
-/*
- Created when get() is called on a FlatListModel_1. This allows changes to the
- object returned by get() to be tracked, and passed onto the model.
-*/
-class FlatListScriptClass_1 : public QScriptDeclarativeClass
-{
-public:
- FlatListScriptClass_1(FlatListModel_1 *model, QScriptEngine *seng);
-
- Value property(Object *, const Identifier &);
- void setProperty(Object *, const Identifier &name, const QScriptValue &);
- QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags);
- bool compare(Object *, Object *);
-
-private:
- FlatListModel_1 *m_model;
-};
-
-/*
- FlatNodeData_1 and FlatNodeObjectData allow objects returned by get() to still
- point to the correct list index if move(), insert() or remove() are called.
-*/
-struct FlatNodeObjectData;
-class FlatNodeData_1
-{
-public:
- FlatNodeData_1(int i)
- : index(i) {}
-
- ~FlatNodeData_1();
-
- void addData(FlatNodeObjectData *data);
- void removeData(FlatNodeObjectData *data);
-
- int index;
-
-private:
- QSet<FlatNodeObjectData*> objects;
-};
-
-struct FlatNodeObjectData : public QScriptDeclarativeClass::Object
-{
- FlatNodeObjectData(FlatNodeData_1 *data) : nodeData(data) {
- nodeData->addData(this);
- }
-
- ~FlatNodeObjectData() {
- if (nodeData)
- nodeData->removeData(this);
- }
-
- FlatNodeData_1 *nodeData;
-};
-
-
-
-class NestedListModel_1
-{
-public:
- NestedListModel_1(QDeclarative1ListModel *base);
- ~NestedListModel_1();
-
- QHash<int,QVariant> data(int index, const QList<int> &roles, bool *hasNested = 0) const;
- QVariant data(int index, int role) const;
-
- QList<int> roles() const;
- QString toString(int role) const;
-
- int count() const;
- void clear();
- void remove(int index);
- bool insert(int index, const QScriptValue&);
- QScriptValue get(int index) const;
- void set(int index, const QScriptValue&, QList<int> *roles);
- void setProperty(int index, const QString& property, const QVariant& value, QList<int> *roles);
- void move(int from, int to, int count);
-
- QVariant valueForNode(ModelNode *, bool *hasNested = 0) const;
- void checkRoles() const;
-
- ModelNode *_root;
- bool m_ownsRoot;
- QDeclarative1ListModel *m_listModel;
-
-private:
- friend struct ModelNode;
- mutable QStringList roleStrings;
- mutable bool _rolesOk;
-};
-
-
-class ModelNodeMetaObject_1;
-class ModelObject_1 : public QObject
-{
- Q_OBJECT
-public:
- ModelObject_1(ModelNode *node, NestedListModel_1 *model, QScriptEngine *seng);
- void setValue(const QByteArray &name, const QVariant &val);
- void setNodeUpdatesEnabled(bool enable);
-
- NestedListModel_1 *m_model;
- ModelNode *m_node;
-
-private:
- ModelNodeMetaObject_1 *m_meta;
-};
-
-class ModelNodeMetaObject_1 : public QDeclarative1OpenMetaObject
-{
-public:
- ModelNodeMetaObject_1(QScriptEngine *seng, ModelObject_1 *object);
-
- bool m_enabled;
-
-protected:
- void propertyWritten(int index);
-
-private:
- QScriptEngine *m_seng;
- ModelObject_1 *m_obj;
-};
-
-
-/*
- A ModelNode is created for each item in a NestedListModel_1.
-*/
-struct ModelNode
-{
- ModelNode(NestedListModel_1 *model);
- ~ModelNode();
-
- QList<QVariant> values;
- QHash<QString, ModelNode *> properties;
-
- void clear();
-
- QDeclarative1ListModel *model(const NestedListModel_1 *model);
- ModelObject_1 *object(const NestedListModel_1 *model);
-
- bool setObjectValue(const QScriptValue& valuemap, bool writeToCache = true);
- void setListValue(const QScriptValue& valuelist);
- bool setProperty(const QString& prop, const QVariant& val);
- void changedProperty(const QString &name) const;
- void updateListIndexes();
- static void dump(ModelNode *node, int ind);
-
- QDeclarative1ListModel *modelCache;
- ModelObject_1 *objectCache;
- bool isArray;
-
- NestedListModel_1 *m_model;
- int listIndex; // only used for top-level nodes within a list
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(ModelNode *)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVELISTMODEL_P_P_H
-
diff --git a/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp b/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp
deleted file mode 100644
index 5dc52ec7f7..0000000000
--- a/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativelistmodelworkeragent_p.h"
-#include "QtQuick1/private/qdeclarativelistmodel_p_p.h"
-#include <QtDeclarative/private/qdeclarativedata_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qdebug.h>
-
-
-QT_BEGIN_NAMESPACE
-
-
-
-
-void QDeclarative1ListModelWorkerAgent::Data::clearChange()
-{
- changes.clear();
-}
-
-void QDeclarative1ListModelWorkerAgent::Data::insertChange(int index, int count)
-{
- Change c = { Change::Inserted, index, count, 0, QList<int>() };
- changes << c;
-}
-
-void QDeclarative1ListModelWorkerAgent::Data::removeChange(int index, int count)
-{
- Change c = { Change::Removed, index, count, 0, QList<int>() };
- changes << c;
-}
-
-void QDeclarative1ListModelWorkerAgent::Data::moveChange(int index, int count, int to)
-{
- Change c = { Change::Moved, index, count, to, QList<int>() };
- changes << c;
-}
-
-void QDeclarative1ListModelWorkerAgent::Data::changedChange(int index, int count, const QList<int> &roles)
-{
- Change c = { Change::Changed, index, count, 0, roles };
- changes << c;
-}
-
-QDeclarative1ListModelWorkerAgent::QDeclarative1ListModelWorkerAgent(QDeclarative1ListModel *model)
- : m_engine(0),
- m_ref(1),
- m_orig(model),
- m_copy(new QDeclarative1ListModel(model, this))
-{
-}
-
-QDeclarative1ListModelWorkerAgent::~QDeclarative1ListModelWorkerAgent()
-{
-}
-
-void QDeclarative1ListModelWorkerAgent::setScriptEngine(QScriptEngine *eng)
-{
- m_engine = eng;
- if (m_copy->m_flat)
- m_copy->m_flat->m_scriptEngine = eng;
-}
-
-QScriptEngine *QDeclarative1ListModelWorkerAgent::scriptEngine() const
-{
- return m_engine;
-}
-
-void QDeclarative1ListModelWorkerAgent::addref()
-{
- m_ref.ref();
-}
-
-void QDeclarative1ListModelWorkerAgent::release()
-{
- bool del = !m_ref.deref();
-
- if (del)
- delete this;
-}
-
-int QDeclarative1ListModelWorkerAgent::count() const
-{
- return m_copy->count();
-}
-
-void QDeclarative1ListModelWorkerAgent::clear()
-{
- data.clearChange();
- data.removeChange(0, m_copy->count());
- m_copy->clear();
-}
-
-void QDeclarative1ListModelWorkerAgent::remove(int index)
-{
- int count = m_copy->count();
- m_copy->remove(index);
-
- if (m_copy->count() != count)
- data.removeChange(index, 1);
-}
-
-void QDeclarative1ListModelWorkerAgent::append(const QScriptValue &value)
-{
- int count = m_copy->count();
- m_copy->append(value);
-
- if (m_copy->count() != count)
- data.insertChange(m_copy->count() - 1, 1);
-}
-
-void QDeclarative1ListModelWorkerAgent::insert(int index, const QScriptValue &value)
-{
- int count = m_copy->count();
- m_copy->insert(index, value);
-
- if (m_copy->count() != count)
- data.insertChange(index, 1);
-}
-
-QScriptValue QDeclarative1ListModelWorkerAgent::get(int index) const
-{
- return m_copy->get(index);
-}
-
-void QDeclarative1ListModelWorkerAgent::set(int index, const QScriptValue &value)
-{
- QList<int> roles;
- m_copy->set(index, value, &roles);
- if (!roles.isEmpty())
- data.changedChange(index, 1, roles);
-}
-
-void QDeclarative1ListModelWorkerAgent::setProperty(int index, const QString& property, const QVariant& value)
-{
- QList<int> roles;
- m_copy->setProperty(index, property, value, &roles);
- if (!roles.isEmpty())
- data.changedChange(index, 1, roles);
-}
-
-void QDeclarative1ListModelWorkerAgent::move(int from, int to, int count)
-{
- m_copy->move(from, to, count);
- data.moveChange(from, to, count);
-}
-
-void QDeclarative1ListModelWorkerAgent::sync()
-{
- Sync *s = new Sync;
- s->data = data;
- s->list = m_copy;
- data.changes.clear();
-
- mutex.lock();
- QCoreApplication::postEvent(this, s);
- syncDone.wait(&mutex);
- mutex.unlock();
-}
-
-void QDeclarative1ListModelWorkerAgent::changedData(int index, int count, const QList<int> &roles)
-{
- data.changedChange(index, count, roles);
-}
-
-bool QDeclarative1ListModelWorkerAgent::event(QEvent *e)
-{
- if (e->type() == QEvent::User) {
- QMutexLocker locker(&mutex);
- Sync *s = static_cast<Sync *>(e);
-
- const QList<Change> &changes = s->data.changes;
-
- if (m_copy) {
- bool cc = m_orig->count() != s->list->count();
-
- FlatListModel_1 *orig = m_orig->m_flat;
- FlatListModel_1 *copy = s->list->m_flat;
- if (!orig || !copy) {
- syncDone.wakeAll();
- return QObject::event(e);
- }
-
- orig->m_roles = copy->m_roles;
- orig->m_strings = copy->m_strings;
- orig->m_values = copy->m_values;
-
- // update the orig->m_nodeData list
- for (int ii = 0; ii < changes.count(); ++ii) {
- const Change &change = changes.at(ii);
- switch (change.type) {
- case Change::Inserted:
- orig->insertedNode(change.index);
- break;
- case Change::Removed:
- orig->removedNode(change.index);
- break;
- case Change::Moved:
- orig->moveNodes(change.index, change.to, change.count);
- break;
- case Change::Changed:
- break;
- }
- }
-
- syncDone.wakeAll();
- locker.unlock();
-
- for (int ii = 0; ii < changes.count(); ++ii) {
- const Change &change = changes.at(ii);
- switch (change.type) {
- case Change::Inserted:
- emit m_orig->itemsInserted(change.index, change.count);
- break;
- case Change::Removed:
- emit m_orig->itemsRemoved(change.index, change.count);
- break;
- case Change::Moved:
- emit m_orig->itemsMoved(change.index, change.to, change.count);
- break;
- case Change::Changed:
- emit m_orig->itemsChanged(change.index, change.count, change.roles);
- break;
- }
- }
-
- if (cc)
- emit m_orig->countChanged();
- } else {
- syncDone.wakeAll();
- }
- }
-
- return QObject::event(e);
-}
-
-
-
-QT_END_NAMESPACE
-
diff --git a/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h b/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h
deleted file mode 100644
index ac7500c638..0000000000
--- a/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVELISTMODELWORKERAGENT_P_H
-#define QDECLARATIVELISTMODELWORKERAGENT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtDeclarative/qdeclarative.h>
-
-#include <QtGui/qevent.h>
-#include <QMutex>
-#include <QWaitCondition>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1ListModel;
-class FlatListScriptClass_1;
-
-class QDeclarative1ListModelWorkerAgent : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int count READ count)
-
-public:
- QDeclarative1ListModelWorkerAgent(QDeclarative1ListModel *);
- ~QDeclarative1ListModelWorkerAgent();
-
- void setScriptEngine(QScriptEngine *eng);
- QScriptEngine *scriptEngine() const;
-
- void addref();
- void release();
-
- int count() const;
-
- Q_INVOKABLE void clear();
- Q_INVOKABLE void remove(int index);
- Q_INVOKABLE void append(const QScriptValue &);
- Q_INVOKABLE void insert(int index, const QScriptValue&);
- Q_INVOKABLE QScriptValue get(int index) const;
- Q_INVOKABLE void set(int index, const QScriptValue &);
- Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);
- Q_INVOKABLE void move(int from, int to, int count);
- Q_INVOKABLE void sync();
-
- struct VariantRef
- {
- VariantRef() : a(0) {}
- VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); }
- VariantRef(QDeclarative1ListModelWorkerAgent *_a) : a(_a) { if (a) a->addref(); }
- ~VariantRef() { if (a) a->release(); }
-
- VariantRef &operator=(const VariantRef &o) {
- if (o.a) o.a->addref();
- if (a) a->release(); a = o.a;
- return *this;
- }
-
- QDeclarative1ListModelWorkerAgent *a;
- };
-protected:
- virtual bool event(QEvent *);
-
-private:
- friend class QDeclarative1WorkerScriptEnginePrivate;
- friend class FlatListScriptClass_1;
- QScriptEngine *m_engine;
-
- struct Change {
- enum { Inserted, Removed, Moved, Changed } type;
- int index; // Inserted/Removed/Moved/Changed
- int count; // Inserted/Removed/Moved/Changed
- int to; // Moved
- QList<int> roles;
- };
-
- struct Data {
- QList<Change> changes;
-
- void clearChange();
- void insertChange(int index, int count);
- void removeChange(int index, int count);
- void moveChange(int index, int count, int to);
- void changedChange(int index, int count, const QList<int> &roles);
- };
- Data data;
-
- struct Sync : public QEvent {
- Sync() : QEvent(QEvent::User) {}
- Data data;
- QDeclarative1ListModel *list;
- };
-
- void changedData(int index, int count, const QList<int> &roles);
-
- QAtomicInt m_ref;
- QDeclarative1ListModel *m_orig;
- QDeclarative1ListModel *m_copy;
- QMutex mutex;
- QWaitCondition syncDone;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QDeclarative1ListModelWorkerAgent::VariantRef)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEWORKERSCRIPT_P_H
-
diff --git a/src/qtquick1/util/qdeclarativeopenmetaobject.cpp b/src/qtquick1/util/qdeclarativeopenmetaobject.cpp
deleted file mode 100644
index 60c3f8eef9..0000000000
--- a/src/qtquick1/util/qdeclarativeopenmetaobject.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h"
-#include "QtDeclarative/private/qdeclarativepropertycache_p.h"
-#include "QtDeclarative/private/qdeclarativedata_p.h"
-#include <private/qmetaobjectbuilder_p.h>
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-
-class QDeclarative1OpenMetaObjectTypePrivate
-{
-public:
- QDeclarative1OpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {}
-
- void init(const QMetaObject *metaObj);
-
- int propertyOffset;
- int signalOffset;
- QHash<QByteArray, int> names;
- QMetaObjectBuilder mob;
- QMetaObject *mem;
- QDeclarativePropertyCache *cache;
- QDeclarativeEngine *engine;
- QSet<QDeclarative1OpenMetaObject*> referers;
-};
-
-QDeclarative1OpenMetaObjectType::QDeclarative1OpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine)
- : d(new QDeclarative1OpenMetaObjectTypePrivate)
-{
- d->engine = engine;
- d->init(base);
-}
-
-QDeclarative1OpenMetaObjectType::~QDeclarative1OpenMetaObjectType()
-{
- if (d->mem)
- free(d->mem);
- if (d->cache)
- d->cache->release();
- delete d;
-}
-
-
-int QDeclarative1OpenMetaObjectType::propertyOffset() const
-{
- return d->propertyOffset;
-}
-
-int QDeclarative1OpenMetaObjectType::signalOffset() const
-{
- return d->signalOffset;
-}
-
-int QDeclarative1OpenMetaObjectType::createProperty(const QByteArray &name)
-{
- int id = d->mob.propertyCount();
- d->mob.addSignal("__" + QByteArray::number(id) + "()");
- QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
- propertyCreated(id, build);
- free(d->mem);
- d->mem = d->mob.toMetaObject();
- d->names.insert(name, id);
- QSet<QDeclarative1OpenMetaObject*>::iterator it = d->referers.begin();
- while (it != d->referers.end()) {
- QDeclarative1OpenMetaObject *omo = *it;
- *static_cast<QMetaObject *>(omo) = *d->mem;
- if (d->cache)
- d->cache->update(d->engine, omo);
- ++it;
- }
-
- return d->propertyOffset + id;
-}
-
-void QDeclarative1OpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder)
-{
- if (d->referers.count())
- (*d->referers.begin())->propertyCreated(id, builder);
-}
-
-void QDeclarative1OpenMetaObjectTypePrivate::init(const QMetaObject *metaObj)
-{
- if (!mem) {
- mob.setSuperClass(metaObj);
- mob.setClassName(metaObj->className());
- mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
-
- mem = mob.toMetaObject();
-
- propertyOffset = mem->propertyOffset();
- signalOffset = mem->methodOffset();
- }
-}
-
-//----------------------------------------------------------------------------
-
-class QDeclarative1OpenMetaObjectPrivate
-{
-public:
- QDeclarative1OpenMetaObjectPrivate(QDeclarative1OpenMetaObject *_q)
- : q(_q), parent(0), type(0), cacheProperties(false) {}
-
- inline QVariant &getData(int idx) {
- while (data.count() <= idx)
- data << QPair<QVariant, bool>(QVariant(), false);
- QPair<QVariant, bool> &prop = data[idx];
- if (!prop.second) {
- prop.first = q->initialValue(idx);
- prop.second = true;
- }
- return prop.first;
- }
-
- inline void writeData(int idx, const QVariant &value) {
- while (data.count() <= idx)
- data << QPair<QVariant, bool>(QVariant(), false);
- QPair<QVariant, bool> &prop = data[idx];
- prop.first = value;
- prop.second = true;
- }
-
- inline bool hasData(int idx) const {
- if (idx >= data.count())
- return false;
- return data[idx].second;
- }
-
- bool autoCreate;
- QDeclarative1OpenMetaObject *q;
- QAbstractDynamicMetaObject *parent;
- QList<QPair<QVariant, bool> > data;
- QObject *object;
- QDeclarative1OpenMetaObjectType *type;
- bool cacheProperties;
-};
-
-QDeclarative1OpenMetaObject::QDeclarative1OpenMetaObject(QObject *obj, bool automatic)
-: d(new QDeclarative1OpenMetaObjectPrivate(this))
-{
- d->autoCreate = automatic;
- d->object = obj;
-
- d->type = new QDeclarative1OpenMetaObjectType(obj->metaObject(), 0);
- d->type->d->referers.insert(this);
-
- QObjectPrivate *op = QObjectPrivate::get(obj);
- d->parent = static_cast<QAbstractDynamicMetaObject *>(op->metaObject);
- *static_cast<QMetaObject *>(this) = *d->type->d->mem;
- op->metaObject = this;
-}
-
-QDeclarative1OpenMetaObject::QDeclarative1OpenMetaObject(QObject *obj, QDeclarative1OpenMetaObjectType *type, bool automatic)
-: d(new QDeclarative1OpenMetaObjectPrivate(this))
-{
- d->autoCreate = automatic;
- d->object = obj;
-
- d->type = type;
- d->type->addref();
- d->type->d->referers.insert(this);
-
- QObjectPrivate *op = QObjectPrivate::get(obj);
- d->parent = static_cast<QAbstractDynamicMetaObject *>(op->metaObject);
- *static_cast<QMetaObject *>(this) = *d->type->d->mem;
- op->metaObject = this;
-}
-
-QDeclarative1OpenMetaObject::~QDeclarative1OpenMetaObject()
-{
- if (d->parent)
- delete d->parent;
- d->type->d->referers.remove(this);
- d->type->release();
- delete d;
-}
-
-QDeclarative1OpenMetaObjectType *QDeclarative1OpenMetaObject::type() const
-{
- return d->type;
-}
-
-int QDeclarative1OpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
-{
- if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty)
- && id >= d->type->d->propertyOffset) {
- int propId = id - d->type->d->propertyOffset;
- if (c == QMetaObject::ReadProperty) {
- propertyRead(propId);
- *reinterpret_cast<QVariant *>(a[0]) = d->getData(propId);
- } else if (c == QMetaObject::WriteProperty) {
- if (propId <= d->data.count() || d->data[propId].first != *reinterpret_cast<QVariant *>(a[0])) {
- propertyWrite(propId);
- d->writeData(propId, *reinterpret_cast<QVariant *>(a[0]));
- propertyWritten(propId);
- activate(d->object, d->type->d->signalOffset + propId, 0);
- }
- }
- return -1;
- } else {
- if (d->parent)
- return d->parent->metaCall(c, id, a);
- else
- return d->object->qt_metacall(c, id, a);
- }
-}
-
-QAbstractDynamicMetaObject *QDeclarative1OpenMetaObject::parent() const
-{
- return d->parent;
-}
-
-QVariant QDeclarative1OpenMetaObject::value(int id) const
-{
- return d->getData(id);
-}
-
-void QDeclarative1OpenMetaObject::setValue(int id, const QVariant &value)
-{
- d->writeData(id, value);
- activate(d->object, id + d->type->d->signalOffset, 0);
-}
-
-QVariant QDeclarative1OpenMetaObject::value(const QByteArray &name) const
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
- if (iter == d->type->d->names.end())
- return QVariant();
-
- return d->getData(*iter);
-}
-
-QVariant &QDeclarative1OpenMetaObject::operator[](const QByteArray &name)
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
- Q_ASSERT(iter != d->type->d->names.end());
-
- return d->getData(*iter);
-}
-
-QVariant &QDeclarative1OpenMetaObject::operator[](int id)
-{
- return d->getData(id);
-}
-
-void QDeclarative1OpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
-
- int id = -1;
- if (iter == d->type->d->names.end()) {
- id = createProperty(name.constData(), "") - d->type->d->propertyOffset;
- } else {
- id = *iter;
- }
-
- if (id >= 0) {
- QVariant &dataVal = d->getData(id);
- if (dataVal == val)
- return;
-
- dataVal = val;
- activate(d->object, id + d->type->d->signalOffset, 0);
- }
-}
-
-// returns true if this value has been initialized by a call to either value() or setValue()
-bool QDeclarative1OpenMetaObject::hasValue(int id) const
-{
- return d->hasData(id);
-}
-
-void QDeclarative1OpenMetaObject::setCached(bool c)
-{
- if (c == d->cacheProperties || !d->type->d->engine)
- return;
-
- d->cacheProperties = c;
-
- QDeclarativeData *qmldata = QDeclarativeData::get(d->object, true);
- if (d->cacheProperties) {
- if (!d->type->d->cache)
- d->type->d->cache = new QDeclarativePropertyCache(d->type->d->engine, this);
- qmldata->propertyCache = d->type->d->cache;
- d->type->d->cache->addref();
- } else {
- if (d->type->d->cache)
- d->type->d->cache->release();
- qmldata->propertyCache = 0;
- }
-}
-
-
-int QDeclarative1OpenMetaObject::createProperty(const char *name, const char *)
-{
- if (d->autoCreate)
- return d->type->createProperty(name);
- else
- return -1;
-}
-
-void QDeclarative1OpenMetaObject::propertyRead(int)
-{
-}
-
-void QDeclarative1OpenMetaObject::propertyWrite(int)
-{
-}
-
-void QDeclarative1OpenMetaObject::propertyWritten(int)
-{
-}
-
-void QDeclarative1OpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &)
-{
-}
-
-QVariant QDeclarative1OpenMetaObject::initialValue(int)
-{
- return QVariant();
-}
-
-int QDeclarative1OpenMetaObject::count() const
-{
- return d->type->d->names.count();
-}
-
-QByteArray QDeclarative1OpenMetaObject::name(int idx) const
-{
- Q_ASSERT(idx >= 0 && idx < d->type->d->names.count());
-
- return d->type->d->mob.property(idx).name();
-}
-
-QObject *QDeclarative1OpenMetaObject::object() const
-{
- return d->object;
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativeopenmetaobject_p.h b/src/qtquick1/util/qdeclarativeopenmetaobject_p.h
deleted file mode 100644
index 77f37591c3..0000000000
--- a/src/qtquick1/util/qdeclarativeopenmetaobject_p.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEOPENMETAOBJECT_H
-#define QDECLARATIVEOPENMETAOBJECT_H
-
-#include <QtCore/QMetaObject>
-#include <QtCore/QObject>
-
-#include <QtDeclarative/private/qdeclarativerefcount_p.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-#include <QtCore/private/qobject_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-class QMetaPropertyBuilder;
-
-
-class QDeclarative1OpenMetaObjectTypePrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1OpenMetaObjectType : public QDeclarativeRefCount
-{
-public:
- QDeclarative1OpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine);
- ~QDeclarative1OpenMetaObjectType();
-
- int createProperty(const QByteArray &name);
-
- int propertyOffset() const;
- int signalOffset() const;
-
-protected:
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
-
-private:
- QDeclarative1OpenMetaObjectTypePrivate *d;
- friend class QDeclarative1OpenMetaObject;
- friend class QDeclarative1OpenMetaObjectPrivate;
-};
-
-class QDeclarative1OpenMetaObjectPrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1OpenMetaObject : public QAbstractDynamicMetaObject
-{
-public:
- QDeclarative1OpenMetaObject(QObject *, bool = true);
- QDeclarative1OpenMetaObject(QObject *, QDeclarative1OpenMetaObjectType *, bool = true);
- ~QDeclarative1OpenMetaObject();
-
- QVariant value(const QByteArray &) const;
- void setValue(const QByteArray &, const QVariant &);
- QVariant value(int) const;
- void setValue(int, const QVariant &);
- QVariant &operator[](const QByteArray &);
- QVariant &operator[](int);
- bool hasValue(int) const;
-
- int count() const;
- QByteArray name(int) const;
-
- QObject *object() const;
- virtual QVariant initialValue(int);
-
- // Be careful - once setCached(true) is called createProperty() is no
- // longer automatically called for new properties.
- void setCached(bool);
-
- QDeclarative1OpenMetaObjectType *type() const;
-
-protected:
- virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
- virtual int createProperty(const char *, const char *);
-
- virtual void propertyRead(int);
- virtual void propertyWrite(int);
- virtual void propertyWritten(int);
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
-
- QAbstractDynamicMetaObject *parent() const;
-
-private:
- QDeclarative1OpenMetaObjectPrivate *d;
- friend class QDeclarative1OpenMetaObjectType;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEOPENMETAOBJECT_H
diff --git a/src/qtquick1/util/qdeclarativepackage.cpp b/src/qtquick1/util/qdeclarativepackage.cpp
deleted file mode 100644
index 70e3a5e386..0000000000
--- a/src/qtquick1/util/qdeclarativepackage.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativepackage_p.h"
-
-#include <private/qobject_p.h>
-#include <QtDeclarative/private/qdeclarativeguard_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-/*!
- \qmlclass Package QDeclarative1Package
- \inqmlmodule QtQuick 1
- \ingroup qml-working-with-data
- \brief Package provides a collection of named items.
-
- The Package class is used in conjunction with
- VisualDataModel to enable delegates with a shared context
- to be provided to multiple views.
-
- Any item within a Package may be assigned a name via the
- \l{Package::name}{Package.name} attached property.
-
- The example below creates a Package containing two named items;
- \e list and \e grid. The third element in the package (the \l Rectangle) is parented to whichever
- delegate it should appear in. This allows an item to move
- between views.
-
- \snippet examples/declarative/modelviews/package/Delegate.qml 0
-
- These named items are used as the delegates by the two views who
- reference the special \l{VisualDataModel::parts} property to select
- a model which provides the chosen delegate.
-
- \snippet examples/declarative/modelviews/package/view.qml 0
-
- \sa {declarative/modelviews/package}{Package example}, {demos/declarative/photoviewer}{Photo Viewer demo}, QtDeclarative
-*/
-
-/*!
- \qmlattachedproperty string Package::name
- This attached property holds the name of an item within a Package.
-*/
-
-
-class QDeclarative1PackagePrivate : public QObjectPrivate
-{
-public:
- QDeclarative1PackagePrivate() {}
-
- struct DataGuard : public QDeclarativeGuard<QObject>
- {
- DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QDeclarativeGuard<QObject>&)*this = obj; }
- QList<DataGuard> *list;
- void objectDestroyed(QObject *) {
- // we assume priv will always be destroyed after objectDestroyed calls
- list->removeOne(*this);
- }
- };
-
- QList<DataGuard> dataList;
- static void data_append(QDeclarativeListProperty<QObject> *prop, QObject *o) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- list->append(DataGuard(o, list));
- }
- static void data_clear(QDeclarativeListProperty<QObject> *prop) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- list->clear();
- }
- static QObject *data_at(QDeclarativeListProperty<QObject> *prop, int index) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- return list->at(index);
- }
- static int data_count(QDeclarativeListProperty<QObject> *prop) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- return list->count();
- }
-};
-
-QHash<QObject *, QDeclarative1PackageAttached *> QDeclarative1PackageAttached::attached;
-
-QDeclarative1PackageAttached::QDeclarative1PackageAttached(QObject *parent)
-: QObject(parent)
-{
- attached.insert(parent, this);
-}
-
-QDeclarative1PackageAttached::~QDeclarative1PackageAttached()
-{
- attached.remove(parent());
-}
-
-QString QDeclarative1PackageAttached::name() const
-{
- return _name;
-}
-
-void QDeclarative1PackageAttached::setName(const QString &n)
-{
- _name = n;
-}
-
-QDeclarative1Package::QDeclarative1Package(QObject *parent)
- : QObject(*(new QDeclarative1PackagePrivate), parent)
-{
-}
-
-QDeclarative1Package::~QDeclarative1Package()
-{
- Q_D(QDeclarative1Package);
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- obj->setParent(this);
- }
-}
-
-QDeclarativeListProperty<QObject> QDeclarative1Package::data()
-{
- Q_D(QDeclarative1Package);
- return QDeclarativeListProperty<QObject>(this, &d->dataList, QDeclarative1PackagePrivate::data_append,
- QDeclarative1PackagePrivate::data_count,
- QDeclarative1PackagePrivate::data_at,
- QDeclarative1PackagePrivate::data_clear);
-}
-
-bool QDeclarative1Package::hasPart(const QString &name)
-{
- Q_D(QDeclarative1Package);
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- QDeclarative1PackageAttached *a = QDeclarative1PackageAttached::attached.value(obj);
- if (a && a->name() == name)
- return true;
- }
- return false;
-}
-
-QObject *QDeclarative1Package::part(const QString &name)
-{
- Q_D(QDeclarative1Package);
- if (name.isEmpty() && !d->dataList.isEmpty())
- return d->dataList.at(0);
-
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- QDeclarative1PackageAttached *a = QDeclarative1PackageAttached::attached.value(obj);
- if (a && a->name() == name)
- return obj;
- }
-
- if (name == QLatin1String("default") && !d->dataList.isEmpty())
- return d->dataList.at(0);
-
- return 0;
-}
-
-QDeclarative1PackageAttached *QDeclarative1Package::qmlAttachedProperties(QObject *o)
-{
- return new QDeclarative1PackageAttached(o);
-}
-
-
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativepackage_p.h b/src/qtquick1/util/qdeclarativepackage_p.h
deleted file mode 100644
index 6930cf6712..0000000000
--- a/src/qtquick1/util/qdeclarativepackage_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPACKAGE_H
-#define QDECLARATIVEPACKAGE_H
-
-#include <QtDeclarative/qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1PackagePrivate;
-class QDeclarative1PackageAttached;
-class Q_AUTOTEST_EXPORT QDeclarative1Package : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1Package)
-
- Q_CLASSINFO("DefaultProperty", "data")
- Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data SCRIPTABLE false)
-
-public:
- QDeclarative1Package(QObject *parent=0);
- virtual ~QDeclarative1Package();
-
- QDeclarativeListProperty<QObject> data();
-
- QObject *part(const QString & = QString());
- bool hasPart(const QString &);
-
- static QDeclarative1PackageAttached *qmlAttachedProperties(QObject *);
-};
-
-class QDeclarative1PackageAttached : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(QString name READ name WRITE setName)
-public:
- QDeclarative1PackageAttached(QObject *parent);
- virtual ~QDeclarative1PackageAttached();
-
- QString name() const;
- void setName(const QString &n);
-
- static QHash<QObject *, QDeclarative1PackageAttached *> attached;
-private:
- QString _name;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1Package)
-QML_DECLARE_TYPEINFO(QDeclarative1Package, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPACKAGE_H
diff --git a/src/qtquick1/util/qdeclarativepixmapcache.cpp b/src/qtquick1/util/qdeclarativepixmapcache.cpp
deleted file mode 100644
index ea9de6771c..0000000000
--- a/src/qtquick1/util/qdeclarativepixmapcache.cpp
+++ /dev/null
@@ -1,1090 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativepixmapcache_p.h"
-#include "QtDeclarative/qdeclarativenetworkaccessmanagerfactory.h"
-#include "QtDeclarative/qdeclarativeimageprovider.h"
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-
-#include <QCoreApplication>
-#include <QImageReader>
-#include <QHash>
-#include <QNetworkReply>
-#include <QPixmapCache>
-#include <QFile>
-#include <QThread>
-#include <QMutex>
-#include <QMutexLocker>
-#include <QWaitCondition>
-#include <QBuffer>
-#include <QWaitCondition>
-#include <QtCore/qdebug.h>
-#include <private/qobject_p.h>
-#include <QSslError>
-
-#define IMAGEREQUEST_MAX_REQUEST_COUNT 8
-#define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16
-#define CACHE_EXPIRE_TIME 30
-#define CACHE_REMOVAL_FRACTION 4
-
-QT_BEGIN_NAMESPACE
-
-
-
-// The cache limit describes the maximum "junk" in the cache.
-// These are the same defaults as QPixmapCache
-#if defined(Q_WS_QWS) || defined(Q_WS_WINCE)
-static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded
-#else
-static int cache_limit = 10240 * 1024; // 10 MB cache limit for desktop
-#endif
-
-class QDeclarative1PixmapReader;
-class QDeclarative1PixmapData;
-class QDeclarative1PixmapReply : public QObject
-{
- Q_OBJECT
-public:
- enum ReadError { NoError, Loading, Decoding };
-
- QDeclarative1PixmapReply(QDeclarative1PixmapData *);
- ~QDeclarative1PixmapReply();
-
- QDeclarative1PixmapData *data;
- QDeclarative1PixmapReader *reader;
- QSize requestSize;
-
- bool loading;
- int redirectCount;
-
- class Event : public QEvent {
- public:
- Event(ReadError, const QString &, const QSize &, const QImage &);
-
- ReadError error;
- QString errorString;
- QSize implicitSize;
- QImage image;
- };
- void postReply(ReadError, const QString &, const QSize &, const QImage &);
-
-
-Q_SIGNALS:
- void finished();
- void downloadProgress(qint64, qint64);
-
-protected:
- bool event(QEvent *event);
-
-private:
- Q_DISABLE_COPY(QDeclarative1PixmapReply)
-
-public:
- static int finishedIndex;
- static int downloadProgressIndex;
-};
-
-class QDeclarative1PixmapReaderThreadObject : public QObject {
- Q_OBJECT
-public:
- QDeclarative1PixmapReaderThreadObject(QDeclarative1PixmapReader *);
- void processJobs();
- virtual bool event(QEvent *e);
-private slots:
- void networkRequestDone();
-private:
- QDeclarative1PixmapReader *reader;
-};
-
-class QDeclarative1PixmapData;
-class QDeclarative1PixmapReader : public QThread
-{
- Q_OBJECT
-public:
- QDeclarative1PixmapReader(QDeclarativeEngine *eng);
- ~QDeclarative1PixmapReader();
-
- QDeclarative1PixmapReply *getImage(QDeclarative1PixmapData *);
- void cancel(QDeclarative1PixmapReply *rep);
-
- static QDeclarative1PixmapReader *instance(QDeclarativeEngine *engine);
-
-protected:
- void run();
-
-private:
- friend class QDeclarative1PixmapReaderThreadObject;
- void processJobs();
- void processJob(QDeclarative1PixmapReply *, const QUrl &, const QSize &);
- void networkRequestDone(QNetworkReply *);
-
- QList<QDeclarative1PixmapReply*> jobs;
- QList<QDeclarative1PixmapReply*> cancelled;
- QDeclarativeEngine *engine;
- QObject *eventLoopQuitHack;
-
- QMutex mutex;
- QDeclarative1PixmapReaderThreadObject *threadObject;
- QWaitCondition waitCondition;
-
- QNetworkAccessManager *networkAccessManager();
- QNetworkAccessManager *accessManager;
-
- QHash<QNetworkReply*,QDeclarative1PixmapReply*> replies;
-
- static int replyDownloadProgress;
- static int replyFinished;
- static int downloadProgress;
- static int threadNetworkRequestDone;
- static QHash<QDeclarativeEngine *,QDeclarative1PixmapReader*> readers;
- static QMutex readerMutex;
-};
-
-class QDeclarative1PixmapData
-{
-public:
- QDeclarative1PixmapData(const QUrl &u, const QSize &s, const QString &e)
- : refCount(1), inCache(false), pixmapStatus(QDeclarative1Pixmap::Error),
- url(u), errorString(e), requestSize(s), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
- {
- }
-
- QDeclarative1PixmapData(const QUrl &u, const QSize &r)
- : refCount(1), inCache(false), pixmapStatus(QDeclarative1Pixmap::Loading),
- url(u), requestSize(r), reply(0), prevUnreferenced(0), prevUnreferencedPtr(0),
- nextUnreferenced(0)
- {
- }
-
- QDeclarative1PixmapData(const QUrl &u, const QPixmap &p, const QSize &s, const QSize &r)
- : refCount(1), inCache(false), privatePixmap(false), pixmapStatus(QDeclarative1Pixmap::Ready),
- url(u), pixmap(p), implicitSize(s), requestSize(r), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
- {
- }
-
- QDeclarative1PixmapData(const QPixmap &p)
- : refCount(1), inCache(false), privatePixmap(true), pixmapStatus(QDeclarative1Pixmap::Ready),
- pixmap(p), implicitSize(p.size()), requestSize(p.size()), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
- {
- }
-
- int cost() const;
- void addref();
- void release();
- void addToCache();
- void removeFromCache();
-
- uint refCount;
-
- bool inCache:1;
- bool privatePixmap:1;
-
- QDeclarative1Pixmap::Status pixmapStatus;
- QUrl url;
- QString errorString;
- QPixmap pixmap;
- QSize implicitSize;
- QSize requestSize;
-
- QDeclarative1PixmapReply *reply;
-
- QDeclarative1PixmapData *prevUnreferenced;
- QDeclarative1PixmapData**prevUnreferencedPtr;
- QDeclarative1PixmapData *nextUnreferenced;
-};
-
-int QDeclarative1PixmapReply::finishedIndex = -1;
-int QDeclarative1PixmapReply::downloadProgressIndex = -1;
-
-// XXX
-QHash<QDeclarativeEngine *,QDeclarative1PixmapReader*> QDeclarative1PixmapReader::readers;
-QMutex QDeclarative1PixmapReader::readerMutex;
-
-int QDeclarative1PixmapReader::replyDownloadProgress = -1;
-int QDeclarative1PixmapReader::replyFinished = -1;
-int QDeclarative1PixmapReader::downloadProgress = -1;
-int QDeclarative1PixmapReader::threadNetworkRequestDone = -1;
-
-
-void QDeclarative1PixmapReply::postReply(ReadError error, const QString &errorString,
- const QSize &implicitSize, const QImage &image)
-{
- loading = false;
- QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, image));
-}
-
-QDeclarative1PixmapReply::Event::Event(ReadError e, const QString &s, const QSize &iSize, const QImage &i)
-: QEvent(QEvent::User), error(e), errorString(s), implicitSize(iSize), image(i)
-{
-}
-
-QNetworkAccessManager *QDeclarative1PixmapReader::networkAccessManager()
-{
- if (!accessManager) {
- Q_ASSERT(threadObject);
- accessManager = QDeclarativeEnginePrivate::get(engine)->createNetworkAccessManager(threadObject);
- }
- return accessManager;
-}
-
-static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize,
- const QSize &requestSize)
-{
- QImageReader imgio(dev);
-
- bool force_scale = false;
- if (url.path().endsWith(QLatin1String(".svg"),Qt::CaseInsensitive)) {
- imgio.setFormat("svg"); // QSvgPlugin::capabilities bug QTBUG-9053
- force_scale = true;
- }
-
- bool scaled = false;
- if (requestSize.width() > 0 || requestSize.height() > 0) {
- QSize s = imgio.size();
- if (requestSize.width() && (force_scale || requestSize.width() < s.width())) {
- if (requestSize.height() <= 0)
- s.setHeight(s.height()*requestSize.width()/s.width());
- s.setWidth(requestSize.width()); scaled = true;
- }
- if (requestSize.height() && (force_scale || requestSize.height() < s.height())) {
- if (requestSize.width() <= 0)
- s.setWidth(s.width()*requestSize.height()/s.height());
- s.setHeight(requestSize.height()); scaled = true;
- }
- if (scaled) { imgio.setScaledSize(s); }
- }
-
- if (impsize)
- *impsize = imgio.size();
-
- if (imgio.read(image)) {
- if (impsize && impsize->width() < 0)
- *impsize = image->size();
- return true;
- } else {
- if (errorString)
- *errorString = QDeclarative1Pixmap::tr("Error decoding: %1: %2").arg(url.toString())
- .arg(imgio.errorString());
- return false;
- }
-}
-
-QDeclarative1PixmapReader::QDeclarative1PixmapReader(QDeclarativeEngine *eng)
-: QThread(eng), engine(eng), threadObject(0), accessManager(0)
-{
- eventLoopQuitHack = new QObject;
- eventLoopQuitHack->moveToThread(this);
- connect(eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection);
- start(QThread::IdlePriority);
-}
-
-QDeclarative1PixmapReader::~QDeclarative1PixmapReader()
-{
- readerMutex.lock();
- readers.remove(engine);
- readerMutex.unlock();
-
- eventLoopQuitHack->deleteLater();
- wait();
-}
-
-void QDeclarative1PixmapReader::networkRequestDone(QNetworkReply *reply)
-{
- QDeclarative1PixmapReply *job = replies.take(reply);
-
- if (job) {
- job->redirectCount++;
- if (job->redirectCount < IMAGEREQUEST_MAX_REDIRECT_RECURSION) {
- QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- QUrl url = reply->url().resolved(redirect.toUrl());
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
-
- reply->deleteLater();
- reply = networkAccessManager()->get(req);
-
- QMetaObject::connect(reply, replyDownloadProgress, job, downloadProgress);
- QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
-
- replies.insert(reply, job);
- return;
- }
- }
-
- QImage image;
- QDeclarative1PixmapReply::ReadError error = QDeclarative1PixmapReply::NoError;
- QString errorString;
- QSize readSize;
- if (reply->error()) {
- error = QDeclarative1PixmapReply::Loading;
- errorString = reply->errorString();
- } else {
- QByteArray all = reply->readAll();
- QBuffer buff(&all);
- buff.open(QIODevice::ReadOnly);
- if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize)) {
- error = QDeclarative1PixmapReply::Decoding;
- }
- }
- // send completion event to the QDeclarative1PixmapReply
- mutex.lock();
- if (!cancelled.contains(job)) job->postReply(error, errorString, readSize, image);
- mutex.unlock();
- }
- reply->deleteLater();
-
- // kick off event loop again incase we have dropped below max request count
- threadObject->processJobs();
-}
-
-QDeclarative1PixmapReaderThreadObject::QDeclarative1PixmapReaderThreadObject(QDeclarative1PixmapReader *i)
-: reader(i)
-{
-}
-
-void QDeclarative1PixmapReaderThreadObject::processJobs()
-{
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
-}
-
-bool QDeclarative1PixmapReaderThreadObject::event(QEvent *e)
-{
- if (e->type() == QEvent::User) {
- reader->processJobs();
- return true;
- } else {
- return QObject::event(e);
- }
-}
-
-void QDeclarative1PixmapReaderThreadObject::networkRequestDone()
-{
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
- reader->networkRequestDone(reply);
-}
-
-void QDeclarative1PixmapReader::processJobs()
-{
- QMutexLocker locker(&mutex);
-
- while (true) {
- if (cancelled.isEmpty() && (jobs.isEmpty() || replies.count() >= IMAGEREQUEST_MAX_REQUEST_COUNT))
- return; // Nothing else to do
-
- // Clean cancelled jobs
- if (cancelled.count()) {
- for (int i = 0; i < cancelled.count(); ++i) {
- QDeclarative1PixmapReply *job = cancelled.at(i);
- QNetworkReply *reply = replies.key(job, 0);
- if (reply && reply->isRunning()) {
- // cancel any jobs already started
- replies.remove(reply);
- reply->close();
- }
- // deleteLater, since not owned by this thread
- job->deleteLater();
- }
- cancelled.clear();
- }
-
- if (!jobs.isEmpty() && replies.count() < IMAGEREQUEST_MAX_REQUEST_COUNT) {
- QDeclarative1PixmapReply *runningJob = jobs.takeLast();
- runningJob->loading = true;
-
- QUrl url = runningJob->data->url;
- QSize requestSize = runningJob->data->requestSize;
- locker.unlock();
- processJob(runningJob, url, requestSize);
- locker.relock();
- }
- }
-}
-
-void QDeclarative1PixmapReader::processJob(QDeclarative1PixmapReply *runningJob, const QUrl &url,
- const QSize &requestSize)
-{
- // fetch
- if (url.scheme() == QLatin1String("image")) {
- // Use QmlImageProvider
- QSize readSize;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- QImage image = ep->getImageFromProvider(url, &readSize, requestSize);
-
- QDeclarative1PixmapReply::ReadError errorCode = QDeclarative1PixmapReply::NoError;
- QString errorStr;
- if (image.isNull()) {
- errorCode = QDeclarative1PixmapReply::Loading;
- errorStr = QDeclarative1Pixmap::tr("Failed to get image from provider: %1").arg(url.toString());
- }
-
- mutex.lock();
- if (!cancelled.contains(runningJob)) runningJob->postReply(errorCode, errorStr, readSize, image);
- mutex.unlock();
- } else {
- QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
- if (!lf.isEmpty()) {
- // Image is local - load/decode immediately
- QImage image;
- QDeclarative1PixmapReply::ReadError errorCode = QDeclarative1PixmapReply::NoError;
- QString errorStr;
- QFile f(lf);
- QSize readSize;
- if (f.open(QIODevice::ReadOnly)) {
- if (!readImage(url, &f, &image, &errorStr, &readSize, requestSize))
- errorCode = QDeclarative1PixmapReply::Loading;
- } else {
- errorStr = QDeclarative1Pixmap::tr("Cannot open: %1").arg(url.toString());
- errorCode = QDeclarative1PixmapReply::Loading;
- }
- mutex.lock();
- if (!cancelled.contains(runningJob)) runningJob->postReply(errorCode, errorStr, readSize, image);
- mutex.unlock();
- } else {
- // Network resource
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- QNetworkReply *reply = networkAccessManager()->get(req);
-
- QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
- QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
-
- replies.insert(reply, runningJob);
- }
- }
-}
-
-QDeclarative1PixmapReader *QDeclarative1PixmapReader::instance(QDeclarativeEngine *engine)
-{
- readerMutex.lock();
- QDeclarative1PixmapReader *reader = readers.value(engine);
- if (!reader) {
- reader = new QDeclarative1PixmapReader(engine);
- readers.insert(engine, reader);
- }
- readerMutex.unlock();
-
- return reader;
-}
-
-QDeclarative1PixmapReply *QDeclarative1PixmapReader::getImage(QDeclarative1PixmapData *data)
-{
- mutex.lock();
- QDeclarative1PixmapReply *reply = new QDeclarative1PixmapReply(data);
- reply->reader = this;
- jobs.append(reply);
- // XXX
- if (threadObject) threadObject->processJobs();
- mutex.unlock();
- return reply;
-}
-
-void QDeclarative1PixmapReader::cancel(QDeclarative1PixmapReply *reply)
-{
- mutex.lock();
- if (reply->loading) {
- cancelled.append(reply);
- reply->data = 0;
- // XXX
- if (threadObject) threadObject->processJobs();
- } else {
- jobs.removeAll(reply);
- delete reply;
- }
- mutex.unlock();
-}
-
-void QDeclarative1PixmapReader::run()
-{
- if (replyDownloadProgress == -1) {
- const QMetaObject *nr = &QNetworkReply::staticMetaObject;
- const QMetaObject *pr = &QDeclarative1PixmapReply::staticMetaObject;
- const QMetaObject *ir = &QDeclarative1PixmapReaderThreadObject::staticMetaObject;
- replyDownloadProgress = nr->indexOfSignal("downloadProgress(qint64,qint64)");
- replyFinished = nr->indexOfSignal("finished()");
- downloadProgress = pr->indexOfSignal("downloadProgress(qint64,qint64)");
- threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()");
- }
-
- mutex.lock();
- threadObject = new QDeclarative1PixmapReaderThreadObject(this);
- mutex.unlock();
-
- processJobs();
- exec();
-
- delete threadObject;
- threadObject = 0;
-}
-
-class QDeclarative1PixmapKey
-{
-public:
- const QUrl *url;
- const QSize *size;
-};
-
-inline bool operator==(const QDeclarative1PixmapKey &lhs, const QDeclarative1PixmapKey &rhs)
-{
- return *lhs.size == *rhs.size && *lhs.url == *rhs.url;
-}
-
-inline uint qHash(const QDeclarative1PixmapKey &key)
-{
- return qHash(*key.url) ^ key.size->width() ^ key.size->height();
-}
-
-class QDeclarative1PixmapStore : public QObject
-{
- Q_OBJECT
-public:
- QDeclarative1PixmapStore();
-
- void unreferencePixmap(QDeclarative1PixmapData *);
- void referencePixmap(QDeclarative1PixmapData *);
-
-protected:
- virtual void timerEvent(QTimerEvent *);
-
-public:
- QHash<QDeclarative1PixmapKey, QDeclarative1PixmapData *> m_cache;
-
-private:
- void shrinkCache(int remove);
-
- QDeclarative1PixmapData *m_unreferencedPixmaps;
- QDeclarative1PixmapData *m_lastUnreferencedPixmap;
-
- int m_unreferencedCost;
- int m_timerId;
-};
-
-Q_GLOBAL_STATIC(QDeclarative1PixmapStore, pixmapStore)
-
-QDeclarative1PixmapStore::QDeclarative1PixmapStore()
-: m_unreferencedPixmaps(0), m_lastUnreferencedPixmap(0), m_unreferencedCost(0), m_timerId(-1)
-{
-}
-
-void QDeclarative1PixmapStore::unreferencePixmap(QDeclarative1PixmapData *data)
-{
- Q_ASSERT(data->prevUnreferenced == 0);
- Q_ASSERT(data->prevUnreferencedPtr == 0);
- Q_ASSERT(data->nextUnreferenced == 0);
-
- data->nextUnreferenced = m_unreferencedPixmaps;
- data->prevUnreferencedPtr = &m_unreferencedPixmaps;
-
- m_unreferencedPixmaps = data;
- if (m_unreferencedPixmaps->nextUnreferenced) {
- m_unreferencedPixmaps->nextUnreferenced->prevUnreferenced = m_unreferencedPixmaps;
- m_unreferencedPixmaps->nextUnreferenced->prevUnreferencedPtr = &m_unreferencedPixmaps->nextUnreferenced;
- }
-
- if (!m_lastUnreferencedPixmap)
- m_lastUnreferencedPixmap = data;
-
- m_unreferencedCost += data->cost();
-
- shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit
-
- if (m_timerId == -1 && m_unreferencedPixmaps)
- m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000);
-}
-
-void QDeclarative1PixmapStore::referencePixmap(QDeclarative1PixmapData *data)
-{
- Q_ASSERT(data->prevUnreferencedPtr);
-
- *data->prevUnreferencedPtr = data->nextUnreferenced;
- if (data->nextUnreferenced) {
- data->nextUnreferenced->prevUnreferencedPtr = data->prevUnreferencedPtr;
- data->nextUnreferenced->prevUnreferenced = data->prevUnreferenced;
- }
- if (m_lastUnreferencedPixmap == data)
- m_lastUnreferencedPixmap = data->prevUnreferenced;
-
- data->nextUnreferenced = 0;
- data->prevUnreferencedPtr = 0;
- data->prevUnreferenced = 0;
-
- m_unreferencedCost -= data->cost();
-}
-
-void QDeclarative1PixmapStore::shrinkCache(int remove)
-{
- while ((remove > 0 || m_unreferencedCost > cache_limit) && m_lastUnreferencedPixmap) {
- QDeclarative1PixmapData *data = m_lastUnreferencedPixmap;
- Q_ASSERT(data->nextUnreferenced == 0);
-
- *data->prevUnreferencedPtr = 0;
- m_lastUnreferencedPixmap = data->prevUnreferenced;
- data->prevUnreferencedPtr = 0;
- data->prevUnreferenced = 0;
-
- remove -= data->cost();
- m_unreferencedCost -= data->cost();
- data->removeFromCache();
- delete data;
- }
-}
-
-void QDeclarative1PixmapStore::timerEvent(QTimerEvent *)
-{
- int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION;
-
- shrinkCache(removalCost);
-
- if (m_unreferencedPixmaps == 0) {
- killTimer(m_timerId);
- m_timerId = -1;
- }
-}
-
-QDeclarative1PixmapReply::QDeclarative1PixmapReply(QDeclarative1PixmapData *d)
-: data(d), reader(0), requestSize(d->requestSize), loading(false), redirectCount(0)
-{
- if (finishedIndex == -1) {
- finishedIndex = QDeclarative1PixmapReply::staticMetaObject.indexOfSignal("finished()");
- downloadProgressIndex = QDeclarative1PixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
- }
-}
-
-QDeclarative1PixmapReply::~QDeclarative1PixmapReply()
-{
-}
-
-bool QDeclarative1PixmapReply::event(QEvent *event)
-{
- if (event->type() == QEvent::User) {
-
- if (data) {
- Event *de = static_cast<Event *>(event);
- data->pixmapStatus = (de->error == NoError) ? QDeclarative1Pixmap::Ready : QDeclarative1Pixmap::Error;
-
- if (data->pixmapStatus == QDeclarative1Pixmap::Ready) {
- data->pixmap = QPixmap::fromImage(de->image);
- data->implicitSize = de->implicitSize;
- } else {
- data->errorString = de->errorString;
- data->removeFromCache(); // We don't continue to cache error'd pixmaps
- }
-
- data->reply = 0;
- emit finished();
- }
-
- delete this;
- return true;
- } else {
- return QObject::event(event);
- }
-}
-
-int QDeclarative1PixmapData::cost() const
-{
- return (pixmap.width() * pixmap.height() * pixmap.depth()) / 8;
-}
-
-void QDeclarative1PixmapData::addref()
-{
- ++refCount;
- if (prevUnreferencedPtr)
- pixmapStore()->referencePixmap(this);
-}
-
-void QDeclarative1PixmapData::release()
-{
- Q_ASSERT(refCount > 0);
- --refCount;
-
- if (refCount == 0) {
- if (reply) {
- reply->reader->cancel(reply);
- reply = 0;
- }
-
- if (pixmapStatus == QDeclarative1Pixmap::Ready) {
- pixmapStore()->unreferencePixmap(this);
- } else {
- removeFromCache();
- delete this;
- }
- }
-}
-
-void QDeclarative1PixmapData::addToCache()
-{
- if (!inCache) {
- QDeclarative1PixmapKey key = { &url, &requestSize };
- pixmapStore()->m_cache.insert(key, this);
- inCache = true;
- }
-}
-
-void QDeclarative1PixmapData::removeFromCache()
-{
- if (inCache) {
- QDeclarative1PixmapKey key = { &url, &requestSize };
- pixmapStore()->m_cache.remove(key);
- inCache = false;
- }
-}
-
-static QDeclarative1PixmapData* createPixmapDataSync(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, bool *ok)
-{
- if (url.scheme() == QLatin1String("image")) {
- QSize readSize;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- QDeclarativeImageProvider::ImageType imageType = ep->getImageProviderType(url);
-
- switch (imageType) {
- case QDeclarativeImageProvider::Image:
- {
- QImage image = ep->getImageFromProvider(url, &readSize, requestSize);
- if (!image.isNull()) {
- *ok = true;
- return new QDeclarative1PixmapData(url, QPixmap::fromImage(image), readSize, requestSize);
- }
- }
- break;
- case QDeclarativeImageProvider::Pixmap:
- {
- QPixmap pixmap = ep->getPixmapFromProvider(url, &readSize, requestSize);
- if (!pixmap.isNull()) {
- *ok = true;
- return new QDeclarative1PixmapData(url, pixmap, readSize, requestSize);
- }
- }
- break;
- case QDeclarativeImageProvider::Texture:
- case QDeclarativeImageProvider::Invalid:
- break;
- }
-
- // no matching provider, or provider has bad image type, or provider returned null image
- return new QDeclarative1PixmapData(url, requestSize,
- QDeclarative1Pixmap::tr("Failed to get image from provider: %1").arg(url.toString()));
- }
-
- QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
- if (localFile.isEmpty())
- return 0;
-
- QFile f(localFile);
- QSize readSize;
- QString errorString;
-
- if (f.open(QIODevice::ReadOnly)) {
- QImage image;
- if (readImage(url, &f, &image, &errorString, &readSize, requestSize)) {
- *ok = true;
- return new QDeclarative1PixmapData(url, QPixmap::fromImage(image), readSize, requestSize);
- }
- } else {
- errorString = QDeclarative1Pixmap::tr("Cannot open: %1").arg(url.toString());
- }
- return new QDeclarative1PixmapData(url, requestSize, errorString);
-}
-
-
-struct QDeclarative1PixmapNull {
- QUrl url;
- QPixmap pixmap;
- QSize size;
-};
-Q_GLOBAL_STATIC(QDeclarative1PixmapNull, nullPixmap);
-
-QDeclarative1Pixmap::QDeclarative1Pixmap()
-: d(0)
-{
-}
-
-QDeclarative1Pixmap::QDeclarative1Pixmap(QDeclarativeEngine *engine, const QUrl &url)
-: d(0)
-{
- load(engine, url);
-}
-
-QDeclarative1Pixmap::QDeclarative1Pixmap(QDeclarativeEngine *engine, const QUrl &url, const QSize &size)
-: d(0)
-{
- load(engine, url, size);
-}
-
-QDeclarative1Pixmap::~QDeclarative1Pixmap()
-{
- if (d) {
- d->release();
- d = 0;
- }
-}
-
-bool QDeclarative1Pixmap::isNull() const
-{
- return d == 0;
-}
-
-bool QDeclarative1Pixmap::isReady() const
-{
- return status() == Ready;
-}
-
-bool QDeclarative1Pixmap::isError() const
-{
- return status() == Error;
-}
-
-bool QDeclarative1Pixmap::isLoading() const
-{
- return status() == Loading;
-}
-
-QString QDeclarative1Pixmap::error() const
-{
- if (d)
- return d->errorString;
- else
- return QString();
-}
-
-QDeclarative1Pixmap::Status QDeclarative1Pixmap::status() const
-{
- if (d)
- return d->pixmapStatus;
- else
- return Null;
-}
-
-const QUrl &QDeclarative1Pixmap::url() const
-{
- if (d)
- return d->url;
- else
- return nullPixmap()->url;
-}
-
-const QSize &QDeclarative1Pixmap::implicitSize() const
-{
- if (d)
- return d->implicitSize;
- else
- return nullPixmap()->size;
-}
-
-const QSize &QDeclarative1Pixmap::requestSize() const
-{
- if (d)
- return d->requestSize;
- else
- return nullPixmap()->size;
-}
-
-const QPixmap &QDeclarative1Pixmap::pixmap() const
-{
- if (d)
- return d->pixmap;
- else
- return nullPixmap()->pixmap;
-}
-
-void QDeclarative1Pixmap::setPixmap(const QPixmap &p)
-{
- clear();
-
- if (!p.isNull())
- d = new QDeclarative1PixmapData(p);
-}
-
-int QDeclarative1Pixmap::width() const
-{
- if (d)
- return d->pixmap.width();
- else
- return 0;
-}
-
-int QDeclarative1Pixmap::height() const
-{
- if (d)
- return d->pixmap.height();
- else
- return 0;
-}
-
-QRect QDeclarative1Pixmap::rect() const
-{
- if (d)
- return d->pixmap.rect();
- else
- return QRect();
-}
-
-void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url)
-{
- load(engine, url, QSize(), QDeclarative1Pixmap::Cache);
-}
-
-void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, QDeclarative1Pixmap::Options options)
-{
- load(engine, url, QSize(), options);
-}
-
-void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &size)
-{
- load(engine, url, size, QDeclarative1Pixmap::Cache);
-}
-
-void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, QDeclarative1Pixmap::Options options)
-{
- if (d) { d->release(); d = 0; }
-
- QDeclarative1PixmapKey key = { &url, &requestSize };
- QDeclarative1PixmapStore *store = pixmapStore();
-
- QHash<QDeclarative1PixmapKey, QDeclarative1PixmapData *>::Iterator iter = store->m_cache.find(key);
-
- if (iter == store->m_cache.end()) {
- if (options & QDeclarative1Pixmap::Asynchronous) {
- // pixmaps can only be loaded synchronously
- if (url.scheme() == QLatin1String("image")
- && QDeclarativeEnginePrivate::get(engine)->getImageProviderType(url) == QDeclarativeImageProvider::Pixmap) {
- options &= ~QDeclarative1Pixmap::Asynchronous;
- }
- }
-
- if (!(options & QDeclarative1Pixmap::Asynchronous)) {
- bool ok = false;
- d = createPixmapDataSync(engine, url, requestSize, &ok);
- if (ok) {
- if (options & QDeclarative1Pixmap::Cache)
- d->addToCache();
- return;
- }
- if (d) // loadable, but encountered error while loading
- return;
- }
-
- if (!engine)
- return;
-
- QDeclarative1PixmapReader *reader = QDeclarative1PixmapReader::instance(engine);
-
- d = new QDeclarative1PixmapData(url, requestSize);
- if (options & QDeclarative1Pixmap::Cache)
- d->addToCache();
-
- d->reply = reader->getImage(d);
- } else {
- d = *iter;
- d->addref();
- }
-}
-
-void QDeclarative1Pixmap::clear()
-{
- if (d) {
- d->release();
- d = 0;
- }
-}
-
-void QDeclarative1Pixmap::clear(QObject *obj)
-{
- if (d) {
- if (d->reply)
- QObject::disconnect(d->reply, 0, obj, 0);
- d->release();
- d = 0;
- }
-}
-
-bool QDeclarative1Pixmap::connectFinished(QObject *object, const char *method)
-{
- if (!d || !d->reply) {
- qWarning("QDeclarative1Pixmap: connectFinished() called when not loading.");
- return false;
- }
-
- return QObject::connect(d->reply, SIGNAL(finished()), object, method);
-}
-
-bool QDeclarative1Pixmap::connectFinished(QObject *object, int method)
-{
- if (!d || !d->reply) {
- qWarning("QDeclarative1Pixmap: connectFinished() called when not loading.");
- return false;
- }
-
- return QMetaObject::connect(d->reply, QDeclarative1PixmapReply::finishedIndex, object, method);
-}
-
-bool QDeclarative1Pixmap::connectDownloadProgress(QObject *object, const char *method)
-{
- if (!d || !d->reply) {
- qWarning("QDeclarative1Pixmap: connectDownloadProgress() called when not loading.");
- return false;
- }
-
- return QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), object, method);
-}
-
-bool QDeclarative1Pixmap::connectDownloadProgress(QObject *object, int method)
-{
- if (!d || !d->reply) {
- qWarning("QDeclarative1Pixmap: connectDownloadProgress() called when not loading.");
- return false;
- }
-
- return QMetaObject::connect(d->reply, QDeclarative1PixmapReply::downloadProgressIndex, object, method);
-}
-
-
-
-QT_END_NAMESPACE
-
-#include <qdeclarativepixmapcache.moc>
diff --git a/src/qtquick1/util/qdeclarativepixmapcache_p.h b/src/qtquick1/util/qdeclarativepixmapcache_p.h
deleted file mode 100644
index bc2cb9452a..0000000000
--- a/src/qtquick1/util/qdeclarativepixmapcache_p.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPIXMAPCACHE_H
-#define QDECLARATIVEPIXMAPCACHE_H
-
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qpixmap.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeEngine;
-
-
-class QDeclarative1PixmapData;
-class Q_QTQUICK1_EXPORT QDeclarative1Pixmap
-{
- Q_DECLARE_TR_FUNCTIONS(QDeclarative1Pixmap)
-public:
- QDeclarative1Pixmap();
- QDeclarative1Pixmap(QDeclarativeEngine *, const QUrl &);
- QDeclarative1Pixmap(QDeclarativeEngine *, const QUrl &, const QSize &);
- ~QDeclarative1Pixmap();
-
- enum Status { Null, Ready, Error, Loading };
-
- enum Option {
- Asynchronous = 0x00000001,
- Cache = 0x00000002
- };
- Q_DECLARE_FLAGS(Options, Option)
-
- bool isNull() const;
- bool isReady() const;
- bool isError() const;
- bool isLoading() const;
-
- Status status() const;
- QString error() const;
- const QUrl &url() const;
- const QSize &implicitSize() const;
- const QSize &requestSize() const;
- const QPixmap &pixmap() const;
- void setPixmap(const QPixmap &);
-
- QRect rect() const;
- int width() const;
- int height() const;
- inline operator const QPixmap &() const;
-
- void load(QDeclarativeEngine *, const QUrl &);
- void load(QDeclarativeEngine *, const QUrl &, QDeclarative1Pixmap::Options options);
- void load(QDeclarativeEngine *, const QUrl &, const QSize &);
- void load(QDeclarativeEngine *, const QUrl &, const QSize &, QDeclarative1Pixmap::Options options);
-
- void clear();
- void clear(QObject *);
-
- bool connectFinished(QObject *, const char *);
- bool connectFinished(QObject *, int);
- bool connectDownloadProgress(QObject *, const char *);
- bool connectDownloadProgress(QObject *, int);
-
-private:
- Q_DISABLE_COPY(QDeclarative1Pixmap)
- QDeclarative1PixmapData *d;
-};
-
-inline QDeclarative1Pixmap::operator const QPixmap &() const
-{
- return pixmap();
-}
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarative1Pixmap::Options)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPIXMAPCACHE_H
diff --git a/src/qtquick1/util/qdeclarativepropertychanges.cpp b/src/qtquick1/util/qdeclarativepropertychanges.cpp
deleted file mode 100644
index 9950915fd4..0000000000
--- a/src/qtquick1/util/qdeclarativepropertychanges.cpp
+++ /dev/null
@@ -1,801 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativepropertychanges_p.h"
-
-#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h"
-#include "QtDeclarative/private/qdeclarativerewrite_p.h"
-#include "QtDeclarative/private/qdeclarativeengine_p.h"
-#include "QtDeclarative/private/qdeclarativecompiler_p.h"
-
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include <QtDeclarative/private/qdeclarativecustomparser_p.h>
-#include <QtDeclarative/private/qdeclarativescript_p.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/private/qdeclarativebinding_p.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/private/qdeclarativeguard_p.h>
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-#include <QtDeclarative/private/qdeclarativecontext_p.h>
-#include <QtQuick1/private/qdeclarativestate_p_p.h>
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-/*!
- \qmlclass PropertyChanges QDeclarative1PropertyChanges
- \inqmlmodule QtQuick 1
- \ingroup qml-state-elements
- \since QtQuick 1.0
- \brief The PropertyChanges element describes new property bindings or values for a state.
-
- PropertyChanges is used to define the property values or bindings in a
- \l State. This enables an item's property values to be changed when it
- \l {QML States}{changes between states}.
-
- To create a PropertyChanges object, specify the \l target item whose
- properties are to be modified, and define the new property values or
- bindings. For example:
-
- \snippet doc/src/snippets/qtquick1/propertychanges.qml import
- \codeline
- \snippet doc/src/snippets/qtquick1/propertychanges.qml 0
-
- When the mouse is pressed, the \l Rectangle changes to the \e resized
- state. In this state, the PropertyChanges object sets the rectangle's
- color to blue and the \c height value to that of \c container.height.
-
- Note this automatically binds \c rect.height to \c container.height
- in the \e resized state. If a property binding should not be
- established, and the height should just be set to the value of
- \c container.height at the time of the state change, set the \l explicit
- property to \c true.
-
- A PropertyChanges object can also override the default signal handler
- for an object to implement a signal handler specific to the new state:
-
- \qml
- PropertyChanges {
- target: myMouseArea
- onClicked: doSomethingDifferent()
- }
- \endqml
-
- \note PropertyChanges can be used to change anchor margins, but not other anchor
- values; use AnchorChanges for this instead. Similarly, to change an \l Item's
- \l {Item::}{parent} value, use ParentChanges instead.
-
-
- \section2 Resetting property values
-
- The \c undefined value can be used to reset the property value for a state.
- In the following example, when \c theText changes to the \e widerText
- state, its \c width property is reset, giving the text its natural width
- and displaying the whole string on a single line.
-
- \snippet doc/src/snippets/qtquick1/propertychanges.qml reset
-
-
- \section2 Immediate property changes in transitions
-
- When \l{QML Animation and Transitions}{Transitions} are used to animate
- state changes, they animate properties from their values in the current
- state to those defined in the new state (as defined by PropertyChanges
- objects). However, it is sometimes desirable to set a property value
- \e immediately during a \l Transition, without animation; in these cases,
- the PropertyAction element can be used to force an immediate property
- change.
-
- See the PropertyAction documentation for more details.
-
- \sa {declarative/animation/states}{states example}, {qmlstate}{States}, QtDeclarative
-*/
-
-/*!
- \qmlproperty Object QtQuick1::PropertyChanges::target
- This property holds the object which contains the properties to be changed.
-*/
-
-class QDeclarative1ReplaceSignalHandler : public QDeclarative1ActionEvent
-{
-public:
- QDeclarative1ReplaceSignalHandler() : expression(0), reverseExpression(0),
- rewindExpression(0), ownedExpression(0) {}
- ~QDeclarative1ReplaceSignalHandler() {
- delete ownedExpression;
- }
-
- virtual QString typeName() const { return QLatin1String("ReplaceSignalHandler"); }
-
- QDeclarativeProperty property;
- QDeclarativeExpression *expression;
- QDeclarativeExpression *reverseExpression;
- QDeclarativeExpression *rewindExpression;
- QDeclarativeGuard<QDeclarativeExpression> ownedExpression;
-
- virtual void execute(Reason) {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression);
- if (ownedExpression == expression)
- ownedExpression = 0;
- }
-
- virtual bool isReversable() { return true; }
- virtual void reverse(Reason) {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression);
- if (ownedExpression == reverseExpression)
- ownedExpression = 0;
- }
-
- virtual void saveOriginals() {
- saveCurrentValues();
- reverseExpression = rewindExpression;
- }
-
- virtual bool needsCopy() { return true; }
- virtual void copyOriginals(QDeclarative1ActionEvent *other)
- {
- QDeclarative1ReplaceSignalHandler *rsh = static_cast<QDeclarative1ReplaceSignalHandler*>(other);
- saveCurrentValues();
- if (rsh == this)
- return;
- reverseExpression = rsh->reverseExpression;
- if (rsh->ownedExpression == reverseExpression) {
- ownedExpression = rsh->ownedExpression;
- rsh->ownedExpression = 0;
- }
- }
-
- virtual void rewind() {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression);
- if (ownedExpression == rewindExpression)
- ownedExpression = 0;
- }
- virtual void saveCurrentValues() {
- rewindExpression = QDeclarativePropertyPrivate::signalExpression(property);
- }
-
- virtual bool override(QDeclarative1ActionEvent*other) {
- if (other == this)
- return true;
- if (other->typeName() != typeName())
- return false;
- if (static_cast<QDeclarative1ReplaceSignalHandler*>(other)->property == property)
- return true;
- return false;
- }
-};
-
-
-class QDeclarative1PropertyChangesPrivate : public QDeclarative1StateOperationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1PropertyChanges)
-public:
- QDeclarative1PropertyChangesPrivate() : decoded(true), restore(true),
- isExplicit(false) {}
-
- QDeclarativeGuard<QObject> object;
- QByteArray data;
-
- bool decoded : 1;
- bool restore : 1;
- bool isExplicit : 1;
-
- void decode();
-
- class ExpressionChange {
- public:
- ExpressionChange(const QString &_name,
- QDeclarativeBinding::Identifier _id,
- QDeclarativeExpression *_expr)
- : name(_name), id(_id), expression(_expr) {}
- QString name;
- QDeclarativeBinding::Identifier id;
- QDeclarativeExpression *expression;
- };
-
- QList<QPair<QString, QVariant> > properties;
- QList<ExpressionChange> expressions;
- QList<QDeclarative1ReplaceSignalHandler*> signalReplacements;
-
- QDeclarativeProperty property(const QString &);
-};
-
-void
-QDeclarative1PropertyChangesParser::compileList(QList<QPair<QString, QVariant> > &list,
- const QString &pre,
- const QDeclarativeCustomParserProperty &prop)
-{
- QString propName = pre + prop.name();
-
- QList<QVariant> values = prop.assignedValues();
- for (int ii = 0; ii < values.count(); ++ii) {
- const QVariant &value = values.at(ii);
-
- if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
- error(qvariant_cast<QDeclarativeCustomParserNode>(value),
- QDeclarative1PropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
- continue;
- } else if(value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
-
- QDeclarativeCustomParserProperty prop =
- qvariant_cast<QDeclarativeCustomParserProperty>(value);
- QString pre = propName + QLatin1Char('.');
- compileList(list, pre, prop);
-
- } else {
- list << qMakePair(propName, value);
- }
- }
-}
-
-QByteArray
-QDeclarative1PropertyChangesParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
-{
- QList<QPair<QString, QVariant> > data;
- for(int ii = 0; ii < props.count(); ++ii)
- compileList(data, QString(), props.at(ii));
-
- QByteArray rv;
- QDataStream ds(&rv, QIODevice::WriteOnly);
-
- ds << data.count();
- for(int ii = 0; ii < data.count(); ++ii) {
- QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(data.at(ii).second);
- QVariant var;
- bool isScript = v.isScript();
- QDeclarativeBinding::Identifier id = 0;
- switch(v.type()) {
- case QDeclarativeScript::Variant::Boolean:
- var = QVariant(v.asBoolean());
- break;
- case QDeclarativeScript::Variant::Number:
- var = QVariant(v.asNumber());
- break;
- case QDeclarativeScript::Variant::String:
- var = QVariant(v.asString());
- break;
- case QDeclarativeScript::Variant::Invalid:
- case QDeclarativeScript::Variant::Script:
- var = QVariant(v.asScript());
- {
- id = rewriteBinding(v, data.at(ii).first);
- }
- break;
- }
-
- ds << data.at(ii).first << isScript << var;
- if (isScript)
- ds << id;
- }
-
- return rv;
-}
-
-void QDeclarative1PropertyChangesPrivate::decode()
-{
- Q_Q(QDeclarative1PropertyChanges);
- if (decoded)
- return;
-
- QDataStream ds(&data, QIODevice::ReadOnly);
-
- int count;
- ds >> count;
- for (int ii = 0; ii < count; ++ii) {
- QString name;
- bool isScript;
- QVariant data;
- QDeclarativeBinding::Identifier id = QDeclarativeBinding::Invalid;
- ds >> name;
- ds >> isScript;
- ds >> data;
- if (isScript)
- ds >> id;
-
- QDeclarativeProperty prop = property(name); //### better way to check for signal property?
- if (prop.type() & QDeclarativeProperty::SignalProperty) {
- QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString());
- QDeclarativeData *ddata = QDeclarativeData::get(q);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
- QDeclarative1ReplaceSignalHandler *handler = new QDeclarative1ReplaceSignalHandler;
- handler->property = prop;
- handler->expression = expression;
- signalReplacements << handler;
- } else if (isScript) {
- QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString());
- QDeclarativeData *ddata = QDeclarativeData::get(q);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
- expressions << ExpressionChange(name, id, expression);
- } else {
- properties << qMakePair(name, data);
- }
- }
-
- decoded = true;
- data.clear();
-}
-
-void QDeclarative1PropertyChangesParser::setCustomData(QObject *object,
- const QByteArray &data)
-{
- QDeclarative1PropertyChangesPrivate *p =
- static_cast<QDeclarative1PropertyChangesPrivate *>(QObjectPrivate::get(object));
- p->data = data;
- p->decoded = false;
-}
-
-QDeclarative1PropertyChanges::QDeclarative1PropertyChanges()
-: QDeclarative1StateOperation(*(new QDeclarative1PropertyChangesPrivate))
-{
-}
-
-QDeclarative1PropertyChanges::~QDeclarative1PropertyChanges()
-{
- Q_D(QDeclarative1PropertyChanges);
- for(int ii = 0; ii < d->expressions.count(); ++ii)
- delete d->expressions.at(ii).expression;
- for(int ii = 0; ii < d->signalReplacements.count(); ++ii)
- delete d->signalReplacements.at(ii);
-}
-
-QObject *QDeclarative1PropertyChanges::object() const
-{
- Q_D(const QDeclarative1PropertyChanges);
- return d->object;
-}
-
-void QDeclarative1PropertyChanges::setObject(QObject *o)
-{
- Q_D(QDeclarative1PropertyChanges);
- d->object = o;
-}
-
-/*!
- \qmlproperty bool QtQuick1::PropertyChanges::restoreEntryValues
-
- This property holds whether the previous values should be restored when
- leaving the state.
-
- The default value is \c true. Setting this value to \c false creates a
- temporary state that has permanent effects on property values.
-*/
-bool QDeclarative1PropertyChanges::restoreEntryValues() const
-{
- Q_D(const QDeclarative1PropertyChanges);
- return d->restore;
-}
-
-void QDeclarative1PropertyChanges::setRestoreEntryValues(bool v)
-{
- Q_D(QDeclarative1PropertyChanges);
- d->restore = v;
-}
-
-QDeclarativeProperty
-QDeclarative1PropertyChangesPrivate::property(const QString &property)
-{
- Q_Q(QDeclarative1PropertyChanges);
- QDeclarativeProperty prop(object, property, qmlContext(q));
- if (!prop.isValid()) {
- qmlInfo(q) << QDeclarative1PropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(property);
- return QDeclarativeProperty();
- } else if (!(prop.type() & QDeclarativeProperty::SignalProperty) && !prop.isWritable()) {
- qmlInfo(q) << QDeclarative1PropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(property);
- return QDeclarativeProperty();
- }
- return prop;
-}
-
-QDeclarative1PropertyChanges::ActionList QDeclarative1PropertyChanges::actions()
-{
- Q_D(QDeclarative1PropertyChanges);
-
- d->decode();
-
- ActionList list;
-
- for (int ii = 0; ii < d->properties.count(); ++ii) {
-
- QDeclarative1Action a(d->object, d->properties.at(ii).first,
- qmlContext(this), d->properties.at(ii).second);
-
- if (a.property.isValid()) {
- a.restore = restoreEntryValues();
- list << a;
- }
- }
-
- for (int ii = 0; ii < d->signalReplacements.count(); ++ii) {
-
- QDeclarative1ReplaceSignalHandler *handler = d->signalReplacements.at(ii);
-
- if (handler->property.isValid()) {
- QDeclarative1Action a;
- a.event = handler;
- list << a;
- }
- }
-
- for (int ii = 0; ii < d->expressions.count(); ++ii) {
-
- const QString &property = d->expressions.at(ii).name;
- QDeclarativeProperty prop = d->property(property);
-
- if (prop.isValid()) {
- QDeclarative1Action a;
- a.restore = restoreEntryValues();
- a.property = prop;
- a.fromValue = a.property.read();
- a.specifiedObject = d->object;
- a.specifiedProperty = property;
-
- if (d->isExplicit) {
- a.toValue = d->expressions.at(ii).expression->evaluate();
- } else {
- QDeclarativeExpression *e = d->expressions.at(ii).expression;
-
- QDeclarativeBinding::Identifier id = d->expressions.at(ii).id;
- QDeclarativeBinding *newBinding = id != QDeclarativeBinding::Invalid ? QDeclarativeBinding::createBinding(id, object(), qmlContext(this), e->sourceFile(), e->lineNumber()) : 0;
- if (!newBinding) {
- newBinding = new QDeclarativeBinding(e->expression(), object(), qmlContext(this));
- newBinding->setSourceLocation(e->sourceFile(), e->lineNumber(), e->columnNumber());
- }
- newBinding->setTarget(prop);
- a.toBinding = newBinding;
- a.deletableToBinding = true;
- }
-
- list << a;
- }
- }
-
- return list;
-}
-
-/*!
- \qmlproperty bool QtQuick1::PropertyChanges::explicit
-
- If explicit is set to true, any potential bindings will be interpreted as
- once-off assignments that occur when the state is entered.
-
- In the following example, the addition of explicit prevents \c myItem.width from
- being bound to \c parent.width. Instead, it is assigned the value of \c parent.width
- at the time of the state change.
- \qml
- PropertyChanges {
- target: myItem
- explicit: true
- width: parent.width
- }
- \endqml
-
- By default, explicit is false.
-*/
-bool QDeclarative1PropertyChanges::isExplicit() const
-{
- Q_D(const QDeclarative1PropertyChanges);
- return d->isExplicit;
-}
-
-void QDeclarative1PropertyChanges::setIsExplicit(bool e)
-{
- Q_D(QDeclarative1PropertyChanges);
- d->isExplicit = e;
-}
-
-bool QDeclarative1PropertyChanges::containsValue(const QString &name) const
-{
- Q_D(const QDeclarative1PropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
-
- QListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- const PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- return true;
- }
- }
-
- return false;
-}
-
-bool QDeclarative1PropertyChanges::containsExpression(const QString &name) const
-{
- Q_D(const QDeclarative1PropertyChanges);
- typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- return true;
- }
- }
-
- return false;
-}
-
-bool QDeclarative1PropertyChanges::containsProperty(const QString &name) const
-{
- return containsValue(name) || containsExpression(name);
-}
-
-void QDeclarative1PropertyChanges::changeValue(const QString &name, const QVariant &value)
-{
- Q_D(QDeclarative1PropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
- typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- expressionIterator.remove();
- if (state() && state()->isStateActive()) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name));
- if (oldBinding) {
- QDeclarativePropertyPrivate::setBinding(d->property(name), 0);
- oldBinding->destroy();
- }
- d->property(name).write(value);
- }
-
- d->properties.append(PropertyEntry(name, value));
- return;
- }
- }
-
- QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- entry.second = value;
- if (state() && state()->isStateActive())
- d->property(name).write(value);
- return;
- }
- }
-
- QDeclarative1Action action;
- action.restore = restoreEntryValues();
- action.property = d->property(name);
- action.fromValue = action.property.read();
- action.specifiedObject = object();
- action.specifiedProperty = name;
- action.toValue = value;
-
- propertyIterator.insert(PropertyEntry(name, value));
- if (state() && state()->isStateActive()) {
- state()->addEntryToRevertList(action);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(action.property);
- if (oldBinding)
- oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- d->property(name).write(value);
- }
-}
-
-void QDeclarative1PropertyChanges::changeExpression(const QString &name, const QString &expression)
-{
- Q_D(QDeclarative1PropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
- typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- bool hadValue = false;
-
- QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- propertyIterator.remove();
- hadValue = true;
- break;
- }
- }
-
- QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- entry.expression->setExpression(expression);
- if (state() && state()->isStateActive()) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name));
- if (oldBinding) {
- QDeclarativePropertyPrivate::setBinding(d->property(name), 0);
- oldBinding->destroy();
- }
-
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(expression, object(), qmlContext(this));
- newBinding->setTarget(d->property(name));
- QDeclarativePropertyPrivate::setBinding(d->property(name), newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- }
- return;
- }
- }
-
- QDeclarativeExpression *newExpression = new QDeclarativeExpression(qmlContext(this), d->object, expression);
- expressionIterator.insert(ExpressionEntry(name, QDeclarativeBinding::Invalid, newExpression));
-
- if (state() && state()->isStateActive()) {
- if (hadValue) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name));
- if (oldBinding) {
- oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- state()->changeBindingInRevertList(object(), name, oldBinding);
- }
-
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(expression, object(), qmlContext(this));
- newBinding->setTarget(d->property(name));
- QDeclarativePropertyPrivate::setBinding(d->property(name), newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- } else {
- QDeclarative1Action action;
- action.restore = restoreEntryValues();
- action.property = d->property(name);
- action.fromValue = action.property.read();
- action.specifiedObject = object();
- action.specifiedProperty = name;
-
-
- if (d->isExplicit) {
- action.toValue = newExpression->evaluate();
- } else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(newExpression->expression(), object(), qmlContext(this));
- newBinding->setTarget(d->property(name));
- action.toBinding = newBinding;
- action.deletableToBinding = true;
-
- state()->addEntryToRevertList(action);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(action.property);
- if (oldBinding)
- oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
-
- QDeclarativePropertyPrivate::setBinding(action.property, newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor);
- }
- }
- }
- // what about the signal handler?
-}
-
-QVariant QDeclarative1PropertyChanges::property(const QString &name) const
-{
- Q_D(const QDeclarative1PropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
- typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- const PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- return entry.second;
- }
- }
-
- QListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- return QVariant(entry.expression->expression());
- }
- }
-
- return QVariant();
-}
-
-void QDeclarative1PropertyChanges::removeProperty(const QString &name)
-{
- Q_D(QDeclarative1PropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
- typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QMutableListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- expressionIterator.remove();
- state()->removeEntryFromRevertList(object(), name);
- return;
- }
- }
-
- QMutableListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- const PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- propertyIterator.remove();
- state()->removeEntryFromRevertList(object(), name);
- return;
- }
- }
-}
-
-QVariant QDeclarative1PropertyChanges::value(const QString &name) const
-{
- Q_D(const QDeclarative1PropertyChanges);
- typedef QPair<QString, QVariant> PropertyEntry;
-
- QListIterator<PropertyEntry> propertyIterator(d->properties);
- while (propertyIterator.hasNext()) {
- const PropertyEntry &entry = propertyIterator.next();
- if (entry.first == name) {
- return entry.second;
- }
- }
-
- return QVariant();
-}
-
-QString QDeclarative1PropertyChanges::expression(const QString &name) const
-{
- Q_D(const QDeclarative1PropertyChanges);
- typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry;
-
- QListIterator<ExpressionEntry> expressionIterator(d->expressions);
- while (expressionIterator.hasNext()) {
- const ExpressionEntry &entry = expressionIterator.next();
- if (entry.name == name) {
- return entry.expression->expression();
- }
- }
-
- return QString();
-}
-
-void QDeclarative1PropertyChanges::detachFromState()
-{
- if (state())
- state()->removeAllEntriesFromRevertList(object());
-}
-
-void QDeclarative1PropertyChanges::attachToState()
-{
- if (state())
- state()->addEntriesToRevertList(actions());
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativepropertychanges_p.h b/src/qtquick1/util/qdeclarativepropertychanges_p.h
deleted file mode 100644
index 7335cb034d..0000000000
--- a/src/qtquick1/util/qdeclarativepropertychanges_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPROPERTYCHANGES_H
-#define QDECLARATIVEPROPERTYCHANGES_H
-
-#include "QtQuick1/private/qdeclarativestateoperations_p.h"
-#include <QtDeclarative/private/qdeclarativecustomparser_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1PropertyChangesPrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1PropertyChanges : public QDeclarative1StateOperation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1PropertyChanges)
-
- Q_PROPERTY(QObject *target READ object WRITE setObject)
- Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
- Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
-public:
- QDeclarative1PropertyChanges();
- ~QDeclarative1PropertyChanges();
-
- QObject *object() const;
- void setObject(QObject *);
-
- bool restoreEntryValues() const;
- void setRestoreEntryValues(bool);
-
- bool isExplicit() const;
- void setIsExplicit(bool);
-
- virtual ActionList actions();
-
- bool containsProperty(const QString &name) const;
- bool containsValue(const QString &name) const;
- bool containsExpression(const QString &name) const;
- void changeValue(const QString &name, const QVariant &value);
- void changeExpression(const QString &name, const QString &expression);
- void removeProperty(const QString &name);
- QVariant value(const QString &name) const;
- QString expression(const QString &name) const;
-
- void detachFromState();
- void attachToState();
-
- QVariant property(const QString &name) const;
-};
-
-class QDeclarative1PropertyChangesParser : public QDeclarativeCustomParser
-{
-public:
- QDeclarative1PropertyChangesParser()
- : QDeclarativeCustomParser(AcceptsAttachedProperties) {}
-
- void compileList(QList<QPair<QString, QVariant> > &list, const QString &pre, const QDeclarativeCustomParserProperty &prop);
-
- virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
- virtual void setCustomData(QObject *, const QByteArray &);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1PropertyChanges)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEPROPERTYCHANGES_H
diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation.cpp b/src/qtquick1/util/qdeclarativesmoothedanimation.cpp
deleted file mode 100644
index 451441ed14..0000000000
--- a/src/qtquick1/util/qdeclarativesmoothedanimation.cpp
+++ /dev/null
@@ -1,498 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h"
-#include "QtQuick1/private/qdeclarativesmoothedanimation_p_p.h"
-
-#include "QtQuick1/private/qdeclarativeanimation_p_p.h"
-
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include "QtDeclarative/private/qdeclarativeproperty_p.h"
-
-#include "QtDeclarative/private/qdeclarativeglobal_p.h"
-
-#include <QtCore/qdebug.h>
-
-#include <math.h>
-
-#define DELAY_STOP_TIMER_INTERVAL 32
-
-QT_BEGIN_NAMESPACE
-
-
-
-QSmoothedAnimation_1::QSmoothedAnimation_1(QObject *parent)
- : QAbstractAnimation(parent), to(0), velocity(200), userDuration(-1), maximumEasingTime(-1),
- reversingMode(QDeclarative1SmoothedAnimation::Eased), initialVelocity(0),
- trackVelocity(0), initialValue(0), invert(false), finalDuration(-1), lastTime(0)
-{
- delayedStopTimer.setInterval(DELAY_STOP_TIMER_INTERVAL);
- delayedStopTimer.setSingleShot(true);
- connect(&delayedStopTimer, SIGNAL(timeout()), this, SLOT(stop()));
-}
-
-void QSmoothedAnimation_1::restart()
-{
- initialVelocity = trackVelocity;
- if (state() != QAbstractAnimation::Running)
- start();
- else
- init();
-}
-
-void QSmoothedAnimation_1::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State /*oldState*/)
-{
- if (newState == QAbstractAnimation::Running)
- init();
-}
-
-void QSmoothedAnimation_1::delayedStop()
-{
- if (!delayedStopTimer.isActive())
- delayedStopTimer.start();
-}
-
-int QSmoothedAnimation_1::duration() const
-{
- return -1;
-}
-
-bool QSmoothedAnimation_1::recalc()
-{
- s = to - initialValue;
- vi = initialVelocity;
-
- s = (invert? -1.0: 1.0) * s;
-
- if (userDuration > 0 && velocity > 0) {
- tf = s / velocity;
- if (tf > (userDuration / 1000.)) tf = (userDuration / 1000.);
- } else if (userDuration > 0) {
- tf = userDuration / 1000.;
- } else if (velocity > 0) {
- tf = s / velocity;
- } else {
- return false;
- }
-
- finalDuration = ceil(tf * 1000.0);
-
- if (maximumEasingTime == 0) {
- a = 0;
- d = 0;
- tp = 0;
- td = tf;
- vp = velocity;
- sp = 0;
- sd = s;
- } else if (maximumEasingTime != -1 && tf > (maximumEasingTime / 1000.)) {
- qreal met = maximumEasingTime / 1000.;
- td = tf - met;
-
- qreal c1 = td;
- qreal c2 = (tf - td) * vi - tf * velocity;
- qreal c3 = -0.5 * (tf - td) * vi * vi;
-
- qreal vp1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
-
- vp = vp1;
- a = vp / met;
- d = a;
- tp = (vp - vi) / a;
- sp = vi * tp + 0.5 * a * tp * tp;
- sd = sp + (td - tp) * vp;
- } else {
- qreal c1 = 0.25 * tf * tf;
- qreal c2 = 0.5 * vi * tf - s;
- qreal c3 = -0.25 * vi * vi;
-
- qreal a1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
-
- qreal tp1 = 0.5 * tf - 0.5 * vi / a1;
- qreal vp1 = a1 * tp1 + vi;
-
- qreal sp1 = 0.5 * a1 * tp1 * tp1 + vi * tp1;
-
- a = a1;
- d = a1;
- tp = tp1;
- td = tp1;
- vp = vp1;
- sp = sp1;
- sd = sp1;
- }
- return true;
-}
-
-qreal QSmoothedAnimation_1::easeFollow(qreal time_seconds)
-{
- qreal value;
- if (time_seconds < tp) {
- trackVelocity = vi + time_seconds * a;
- value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds;
- } else if (time_seconds < td) {
- time_seconds -= tp;
- trackVelocity = vp;
- value = sp + time_seconds * vp;
- } else if (time_seconds < tf) {
- time_seconds -= td;
- trackVelocity = vp - time_seconds * a;
- value = sd - 0.5 * d * time_seconds * time_seconds + vp * time_seconds;
- } else {
- trackVelocity = 0;
- value = s;
- delayedStop();
- }
-
- // to normalize 's' between [0..1], divide 'value' by 's'
- return value;
-}
-
-void QSmoothedAnimation_1::updateCurrentTime(int t)
-{
- qreal time_seconds = qreal(t - lastTime) / 1000.;
-
- qreal value = easeFollow(time_seconds);
- value *= (invert? -1.0: 1.0);
- QDeclarativePropertyPrivate::write(target, initialValue + value,
- QDeclarativePropertyPrivate::BypassInterceptor
- | QDeclarativePropertyPrivate::DontRemoveBinding);
-}
-
-void QSmoothedAnimation_1::init()
-{
- if (velocity == 0) {
- stop();
- return;
- }
-
- if (delayedStopTimer.isActive())
- delayedStopTimer.stop();
-
- initialValue = target.read().toReal();
- lastTime = this->currentTime();
-
- if (to == initialValue) {
- stop();
- return;
- }
-
- bool hasReversed = trackVelocity != 0. &&
- ((!invert) == ((initialValue - to) > 0));
-
- if (hasReversed) {
- switch (reversingMode) {
- default:
- case QDeclarative1SmoothedAnimation::Eased:
- initialVelocity = -trackVelocity;
- break;
- case QDeclarative1SmoothedAnimation::Sync:
- QDeclarativePropertyPrivate::write(target, to,
- QDeclarativePropertyPrivate::BypassInterceptor
- | QDeclarativePropertyPrivate::DontRemoveBinding);
- trackVelocity = 0;
- stop();
- return;
- case QDeclarative1SmoothedAnimation::Immediate:
- initialVelocity = 0;
- break;
- }
- }
-
- trackVelocity = initialVelocity;
-
- invert = (to < initialValue);
-
- if (!recalc()) {
- QDeclarativePropertyPrivate::write(target, to,
- QDeclarativePropertyPrivate::BypassInterceptor
- | QDeclarativePropertyPrivate::DontRemoveBinding);
- stop();
- return;
- }
-}
-
-/*!
- \qmlclass SmoothedAnimation QDeclarative1SmoothedAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \inherits NumberAnimation
- \brief The SmoothedAnimation element allows a property to smoothly track a value.
-
- A SmoothedAnimation animates a property's value to a set target value
- using an ease in/out quad easing curve. When the target value changes,
- the easing curves used to animate between the old and new target values
- are smoothly spliced together to create a smooth movement to the new
- target value that maintains the current velocity.
-
- The follow example shows one \l Rectangle tracking the position of another
- using SmoothedAnimation. The green rectangle's \c x and \c y values are
- bound to those of the red rectangle. Whenever these values change, the
- green rectangle smoothly animates to its new position:
-
- \snippet doc/src/snippets/qtquick1/smoothedanimation.qml 0
-
- A SmoothedAnimation can be configured by setting the \l velocity at which the
- animation should occur, or the \l duration that the animation should take.
- If both the \l velocity and \l duration are specified, the one that results in
- the quickest animation is chosen for each change in the target value.
-
- For example, animating from 0 to 800 will take 4 seconds if a velocity
- of 200 is set, will take 8 seconds with a duration of 8000 set, and will
- take 4 seconds with both a velocity of 200 and a duration of 8000 set.
- Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
- will take 8 seconds with a duration of 8000 set, and will take 8 seconds
- with both a velocity of 200 and a duration of 8000 set.
-
- The default velocity of SmoothedAnimation is 200 units/second. Note that if the range of the
- value being animated is small, then the velocity will need to be adjusted
- appropriately. For example, the opacity of an item ranges from 0 - 1.0.
- To enable a smooth animation in this range the velocity will need to be
- set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity
- of 0.5 will take 2000 ms to complete.
-
- Like any other animation element, a SmoothedAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa SpringAnimation, NumberAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}
-*/
-
-QDeclarative1SmoothedAnimation::QDeclarative1SmoothedAnimation(QObject *parent)
-: QDeclarative1NumberAnimation(*(new QDeclarative1SmoothedAnimationPrivate), parent)
-{
-}
-
-QDeclarative1SmoothedAnimation::~QDeclarative1SmoothedAnimation()
-{
-}
-
-QDeclarative1SmoothedAnimationPrivate::QDeclarative1SmoothedAnimationPrivate()
- : wrapperGroup(new QParallelAnimationGroup), anim(new QSmoothedAnimation_1)
-{
- Q_Q(QDeclarative1SmoothedAnimation);
- QDeclarative_setParent_noEvent(wrapperGroup, q);
- QDeclarative_setParent_noEvent(anim, q);
-}
-
-void QDeclarative1SmoothedAnimationPrivate::updateRunningAnimations()
-{
- foreach(QSmoothedAnimation_1* ease, activeAnimations.values()){
- ease->maximumEasingTime = anim->maximumEasingTime;
- ease->reversingMode = anim->reversingMode;
- ease->velocity = anim->velocity;
- ease->userDuration = anim->userDuration;
- ease->init();
- }
-}
-
-QAbstractAnimation* QDeclarative1SmoothedAnimation::qtAnimation()
-{
- Q_D(QDeclarative1SmoothedAnimation);
- return d->wrapperGroup;
-}
-
-void QDeclarative1SmoothedAnimation::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarative1SmoothedAnimation);
- QDeclarative1NumberAnimation::transition(actions, modified, direction);
-
- if (!d->actions)
- return;
-
- QSet<QAbstractAnimation*> anims;
- for (int i = 0; i < d->actions->size(); i++) {
- QSmoothedAnimation_1 *ease;
- bool needsRestart;
- if (!d->activeAnimations.contains((*d->actions)[i].property)) {
- ease = new QSmoothedAnimation_1();
- d->wrapperGroup->addAnimation(ease);
- d->activeAnimations.insert((*d->actions)[i].property, ease);
- needsRestart = false;
- } else {
- ease = d->activeAnimations.value((*d->actions)[i].property);
- needsRestart = true;
- }
- ease->target = (*d->actions)[i].property;
- ease->to = (*d->actions)[i].toValue.toReal();
-
- // copying public members from main value holder animation
- ease->maximumEasingTime = d->anim->maximumEasingTime;
- ease->reversingMode = d->anim->reversingMode;
- ease->velocity = d->anim->velocity;
- ease->userDuration = d->anim->userDuration;
-
- ease->initialVelocity = ease->trackVelocity;
-
- if (needsRestart)
- ease->init();
- anims.insert(ease);
- }
-
- for (int i = d->wrapperGroup->animationCount() - 1; i >= 0 ; --i) {
- if (!anims.contains(d->wrapperGroup->animationAt(i))) {
- QSmoothedAnimation_1 *ease = static_cast<QSmoothedAnimation_1*>(d->wrapperGroup->animationAt(i));
- d->activeAnimations.remove(ease->target);
- d->wrapperGroup->takeAnimation(i);
- delete ease;
- }
- }
-}
-
-/*!
- \qmlproperty enumeration QtQuick1::SmoothedAnimation::reversingMode
-
- Sets how the SmoothedAnimation behaves if an animation direction is reversed.
-
- Possible values are:
-
- \list
- \o SmoothedAnimation.Eased (default) - the animation will smoothly decelerate, and then reverse direction
- \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, beginning with a velocity of 0
- \o SmoothedAnimation.Sync - the property is immediately set to the target value
- \endlist
-*/
-QDeclarative1SmoothedAnimation::ReversingMode QDeclarative1SmoothedAnimation::reversingMode() const
-{
- Q_D(const QDeclarative1SmoothedAnimation);
- return (QDeclarative1SmoothedAnimation::ReversingMode) d->anim->reversingMode;
-}
-
-void QDeclarative1SmoothedAnimation::setReversingMode(ReversingMode m)
-{
- Q_D(QDeclarative1SmoothedAnimation);
- if (d->anim->reversingMode == m)
- return;
-
- d->anim->reversingMode = m;
- emit reversingModeChanged();
- d->updateRunningAnimations();
-}
-
-/*!
- \qmlproperty int QtQuick1::SmoothedAnimation::duration
-
- This property holds the animation duration, in msecs, used when tracking the source.
-
- Setting this to -1 (the default) disables the duration value.
-
- If the velocity value and the duration value are both enabled, then the animation will
- use whichever gives the shorter duration.
-*/
-int QDeclarative1SmoothedAnimation::duration() const
-{
- Q_D(const QDeclarative1SmoothedAnimation);
- return d->anim->userDuration;
-}
-
-void QDeclarative1SmoothedAnimation::setDuration(int duration)
-{
- Q_D(QDeclarative1SmoothedAnimation);
- if (duration != -1)
- QDeclarative1NumberAnimation::setDuration(duration);
- if(duration == d->anim->userDuration)
- return;
- d->anim->userDuration = duration;
- d->updateRunningAnimations();
-}
-
-qreal QDeclarative1SmoothedAnimation::velocity() const
-{
- Q_D(const QDeclarative1SmoothedAnimation);
- return d->anim->velocity;
-}
-
-/*!
- \qmlproperty real QtQuick1::SmoothedAnimation::velocity
-
- This property holds the average velocity allowed when tracking the 'to' value.
-
- The default velocity of SmoothedAnimation is 200 units/second.
-
- Setting this to -1 disables the velocity value.
-
- If the velocity value and the duration value are both enabled, then the animation will
- use whichever gives the shorter duration.
-*/
-void QDeclarative1SmoothedAnimation::setVelocity(qreal v)
-{
- Q_D(QDeclarative1SmoothedAnimation);
- if (d->anim->velocity == v)
- return;
-
- d->anim->velocity = v;
- emit velocityChanged();
- d->updateRunningAnimations();
-}
-
-/*!
- \qmlproperty int QtQuick1::SmoothedAnimation::maximumEasingTime
-
- This property specifies the maximum time, in msecs, any "eases" during the follow should take.
- Setting this property causes the velocity to "level out" after at a time. Setting
- a negative value reverts to the normal mode of easing over the entire animation
- duration.
-
- The default value is -1.
-*/
-int QDeclarative1SmoothedAnimation::maximumEasingTime() const
-{
- Q_D(const QDeclarative1SmoothedAnimation);
- return d->anim->maximumEasingTime;
-}
-
-void QDeclarative1SmoothedAnimation::setMaximumEasingTime(int v)
-{
- Q_D(QDeclarative1SmoothedAnimation);
- if(v == d->anim->maximumEasingTime)
- return;
- d->anim->maximumEasingTime = v;
- emit maximumEasingTimeChanged();
- d->updateRunningAnimations();
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation_p.h b/src/qtquick1/util/qdeclarativesmoothedanimation_p.h
deleted file mode 100644
index 6ae712c872..0000000000
--- a/src/qtquick1/util/qdeclarativesmoothedanimation_p.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESMOOTHEDANIMATION_H
-#define QDECLARATIVESMOOTHEDANIMATION_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeProperty;
-
-
-class QDeclarative1SmoothedAnimationPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1SmoothedAnimation : public QDeclarative1NumberAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1SmoothedAnimation)
- Q_ENUMS(ReversingMode)
-
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
- Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged)
- Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged)
-
-public:
- enum ReversingMode { Eased, Immediate, Sync };
-
- QDeclarative1SmoothedAnimation(QObject *parent = 0);
- ~QDeclarative1SmoothedAnimation();
-
- ReversingMode reversingMode() const;
- void setReversingMode(ReversingMode);
-
- virtual int duration() const;
- virtual void setDuration(int);
-
- qreal velocity() const;
- void setVelocity(qreal);
-
- int maximumEasingTime() const;
- void setMaximumEasingTime(int);
-
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- QAbstractAnimation* qtAnimation();
-
-Q_SIGNALS:
- void velocityChanged();
- void reversingModeChanged();
- void maximumEasingTimeChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1SmoothedAnimation)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESMOOTHEDANIMATION_H
diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h b/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h
deleted file mode 100644
index 5891cac9ba..0000000000
--- a/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESMOOTHEDANIMATION_P_H
-#define QDECLARATIVESMOOTHEDANIMATION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h"
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-
-#include "QtQuick1/private/qdeclarativeanimation_p_p.h"
-
-#include <qparallelanimationgroup.h>
-
-#include <QtCore/private/qobject_p.h>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-class Q_AUTOTEST_EXPORT QSmoothedAnimation_1 : public QAbstractAnimation
-{
-public:
- QSmoothedAnimation_1(QObject *parent=0);
-
- qreal to;
- qreal velocity;
- int userDuration;
-
- int maximumEasingTime;
- QDeclarative1SmoothedAnimation::ReversingMode reversingMode;
-
- qreal initialVelocity;
- qreal trackVelocity;
-
- QDeclarativeProperty target;
-
- int duration() const;
- void restart();
- void init();
-
-protected:
- virtual void updateCurrentTime(int);
- virtual void updateState(QAbstractAnimation::State, QAbstractAnimation::State);
-
-private:
- qreal easeFollow(qreal);
- qreal initialValue;
-
- bool invert;
-
- int finalDuration;
-
- // Parameters for use in updateCurrentTime()
- qreal a; // Acceleration
- qreal d; // Deceleration
- qreal tf; // Total time
- qreal tp; // Time at which peak velocity occurs
- qreal td; // Time at which decelleration begins
- qreal vp; // Velocity at tp
- qreal sp; // Displacement at tp
- qreal sd; // Displacement at td
- qreal vi; // "Normalized" initialvelocity
- qreal s; // Total s
-
- int lastTime;
-
- bool recalc();
- void delayedStop();
-
- QTimer delayedStopTimer;
-};
-
-class QDeclarative1SmoothedAnimationPrivate : public QDeclarative1PropertyAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1SmoothedAnimation)
-public:
- QDeclarative1SmoothedAnimationPrivate();
- void updateRunningAnimations();
-
- QParallelAnimationGroup *wrapperGroup;
- QSmoothedAnimation_1 *anim;
- QHash<QDeclarativeProperty, QSmoothedAnimation_1*> activeAnimations;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVESMOOTHEDANIMATION_P_H
diff --git a/src/qtquick1/util/qdeclarativespringanimation.cpp b/src/qtquick1/util/qdeclarativespringanimation.cpp
deleted file mode 100644
index d99f0d04bf..0000000000
--- a/src/qtquick1/util/qdeclarativespringanimation.cpp
+++ /dev/null
@@ -1,469 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativespringanimation_p.h"
-
-#include "QtQuick1/private/qdeclarativeanimation_p_p.h"
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-#include <limits.h>
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-
-class QDeclarative1SpringAnimationPrivate : public QDeclarative1PropertyAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1SpringAnimation)
-public:
-
-
- struct SpringAnimation {
- SpringAnimation()
- : currentValue(0), to(0), velocity(0), start(0), duration(0) {}
- qreal currentValue;
- qreal to;
- qreal velocity;
- int start;
- int duration;
- };
- QHash<QDeclarativeProperty, SpringAnimation> activeAnimations;
-
- qreal maxVelocity;
- qreal velocityms;
- int lastTime;
- qreal mass;
- qreal spring;
- qreal damping;
- qreal epsilon;
- qreal modulus;
-
- bool useMass : 1;
- bool haveModulus : 1;
-
- enum Mode {
- Track,
- Velocity,
- Spring
- };
- Mode mode;
-
- QDeclarative1SpringAnimationPrivate()
- : maxVelocity(0), velocityms(0), lastTime(0)
- , mass(1.0), spring(0.), damping(0.), epsilon(0.01)
- , modulus(0.0), useMass(false), haveModulus(false)
- , mode(Track), clock(0)
- { }
-
- void tick(int time);
- bool animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed);
- void updateMode();
-
- typedef QTickAnimationProxy_1<QDeclarative1SpringAnimationPrivate, &QDeclarative1SpringAnimationPrivate::tick> Clock;
- Clock *clock;
-};
-
-void QDeclarative1SpringAnimationPrivate::tick(int time)
-{
- if (mode == Track) {
- clock->stop();
- return;
- }
- int elapsed = time - lastTime;
- if (!elapsed)
- return;
-
- if (mode == Spring) {
- if (elapsed < 16) // capped at 62fps.
- return;
- int count = elapsed / 16;
- lastTime = time - (elapsed - count * 16);
- } else {
- lastTime = time;
- }
-
- QMutableHashIterator<QDeclarativeProperty, SpringAnimation> it(activeAnimations);
- while (it.hasNext()) {
- it.next();
- if (animate(it.key(), it.value(), elapsed))
- it.remove();
- }
-
- if (activeAnimations.isEmpty())
- clock->stop();
-}
-
-bool QDeclarative1SpringAnimationPrivate::animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed)
-{
- qreal srcVal = animation.to;
-
- bool stop = false;
-
- if (haveModulus) {
- animation.currentValue = fmod(animation.currentValue, modulus);
- srcVal = fmod(srcVal, modulus);
- }
- if (mode == Spring) {
- // Real men solve the spring DEs using RK4.
- // We'll do something much simpler which gives a result that looks fine.
- int count = elapsed / 16;
- for (int i = 0; i < count; ++i) {
- qreal diff = srcVal - animation.currentValue;
- if (haveModulus && qAbs(diff) > modulus / 2) {
- if (diff < 0)
- diff += modulus;
- else
- diff -= modulus;
- }
- if (useMass)
- animation.velocity = animation.velocity + (spring * diff - damping * animation.velocity) / mass;
- else
- animation.velocity = animation.velocity + spring * diff - damping * animation.velocity;
- if (maxVelocity > 0.) {
- // limit velocity
- if (animation.velocity > maxVelocity)
- animation.velocity = maxVelocity;
- else if (animation.velocity < -maxVelocity)
- animation.velocity = -maxVelocity;
- }
- animation.currentValue += animation.velocity * 16.0 / 1000.0;
- if (haveModulus) {
- animation.currentValue = fmod(animation.currentValue, modulus);
- if (animation.currentValue < 0.0)
- animation.currentValue += modulus;
- }
- }
- if (qAbs(animation.velocity) < epsilon && qAbs(srcVal - animation.currentValue) < epsilon) {
- animation.velocity = 0.0;
- animation.currentValue = srcVal;
- stop = true;
- }
- } else {
- qreal moveBy = elapsed * velocityms;
- qreal diff = srcVal - animation.currentValue;
- if (haveModulus && qAbs(diff) > modulus / 2) {
- if (diff < 0)
- diff += modulus;
- else
- diff -= modulus;
- }
- if (diff > 0) {
- animation.currentValue += moveBy;
- if (haveModulus)
- animation.currentValue = fmod(animation.currentValue, modulus);
- } else {
- animation.currentValue -= moveBy;
- if (haveModulus && animation.currentValue < 0.0)
- animation.currentValue = fmod(animation.currentValue, modulus) + modulus;
- }
- if (lastTime - animation.start >= animation.duration) {
- animation.currentValue = animation.to;
- stop = true;
- }
- }
-
- qreal old_to = animation.to;
-
- QDeclarativePropertyPrivate::write(property, animation.currentValue,
- QDeclarativePropertyPrivate::BypassInterceptor |
- QDeclarativePropertyPrivate::DontRemoveBinding);
-
- return (stop && old_to == animation.to); // do not stop if we got restarted
-}
-
-void QDeclarative1SpringAnimationPrivate::updateMode()
-{
- if (spring == 0. && maxVelocity == 0.)
- mode = Track;
- else if (spring > 0.)
- mode = Spring;
- else {
- mode = Velocity;
- QHash<QDeclarativeProperty, SpringAnimation>::iterator it;
- for (it = activeAnimations.begin(); it != activeAnimations.end(); ++it) {
- SpringAnimation &animation = *it;
- animation.start = lastTime;
- qreal dist = qAbs(animation.currentValue - animation.to);
- if (haveModulus && dist > modulus / 2)
- dist = modulus - fmod(dist, modulus);
- animation.duration = dist / velocityms;
- }
- }
-}
-
-/*!
- \qmlclass SpringAnimation QDeclarative1SpringAnimation
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \inherits NumberAnimation
- \since QtQuick 1.0
-
- \brief The SpringAnimation element allows a property to track a value in a spring-like motion.
-
- SpringAnimation mimics the oscillatory behavior of a spring, with the appropriate \l spring constant to
- control the acceleration and the \l damping to control how quickly the effect dies away.
-
- You can also limit the maximum \l velocity of the animation.
-
- The following \l Rectangle moves to the position of the mouse using a
- SpringAnimation when the mouse is clicked. The use of the \l Behavior
- on the \c x and \c y values indicates that whenever these values are
- changed, a SpringAnimation should be applied.
-
- \snippet doc/src/snippets/qtquick1/springanimation.qml 0
-
- Like any other animation element, a SpringAnimation can be applied in a
- number of ways, including transitions, behaviors and property value
- sources. The \l {QML Animation and Transitions} documentation shows a
- variety of methods for creating animations.
-
- \sa SmoothedAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example}
-*/
-
-QDeclarative1SpringAnimation::QDeclarative1SpringAnimation(QObject *parent)
-: QDeclarative1NumberAnimation(*(new QDeclarative1SpringAnimationPrivate),parent)
-{
- Q_D(QDeclarative1SpringAnimation);
- d->clock = new QDeclarative1SpringAnimationPrivate::Clock(d, this);
-}
-
-QDeclarative1SpringAnimation::~QDeclarative1SpringAnimation()
-{
-}
-
-/*!
- \qmlproperty real QtQuick1::SpringAnimation::velocity
-
- This property holds the maximum velocity allowed when tracking the source.
-
- The default value is 0 (no maximum velocity).
-*/
-
-qreal QDeclarative1SpringAnimation::velocity() const
-{
- Q_D(const QDeclarative1SpringAnimation);
- return d->maxVelocity;
-}
-
-void QDeclarative1SpringAnimation::setVelocity(qreal velocity)
-{
- Q_D(QDeclarative1SpringAnimation);
- d->maxVelocity = velocity;
- d->velocityms = velocity / 1000.0;
- d->updateMode();
-}
-
-/*!
- \qmlproperty real QtQuick1::SpringAnimation::spring
-
- This property describes how strongly the target is pulled towards the
- source. The default value is 0 (that is, the spring-like motion is disabled).
-
- The useful value range is 0 - 5.0.
-
- When this property is set and the \l velocity value is greater than 0,
- the \l velocity limits the maximum speed.
-*/
-qreal QDeclarative1SpringAnimation::spring() const
-{
- Q_D(const QDeclarative1SpringAnimation);
- return d->spring;
-}
-
-void QDeclarative1SpringAnimation::setSpring(qreal spring)
-{
- Q_D(QDeclarative1SpringAnimation);
- d->spring = spring;
- d->updateMode();
-}
-
-/*!
- \qmlproperty real QtQuick1::SpringAnimation::damping
- This property holds the spring damping value.
-
- This parameter can be used to tweak the spring behaviour by exerting a resisting force
- (like friction).
-
- The default value is 0.
-
- The useful value range is 0 - 1.0. The higher the value, the faster it
- usually comes to rest.
-*/
-qreal QDeclarative1SpringAnimation::damping() const
-{
- Q_D(const QDeclarative1SpringAnimation);
- return d->damping;
-}
-
-void QDeclarative1SpringAnimation::setDamping(qreal damping)
-{
- Q_D(QDeclarative1SpringAnimation);
- if (damping > 1.)
- damping = 1.;
-
- d->damping = damping;
-}
-
-
-/*!
- \qmlproperty real QtQuick1::SpringAnimation::epsilon
- This property holds the spring epsilon.
-
- The epsilon is the rate and amount of change in the value which is close enough
- to 0 to be considered equal to zero. This will depend on the usage of the value.
- For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
-
- The default is 0.01. Tuning this value can provide small performance improvements.
-*/
-qreal QDeclarative1SpringAnimation::epsilon() const
-{
- Q_D(const QDeclarative1SpringAnimation);
- return d->epsilon;
-}
-
-void QDeclarative1SpringAnimation::setEpsilon(qreal epsilon)
-{
- Q_D(QDeclarative1SpringAnimation);
- d->epsilon = epsilon;
-}
-
-/*!
- \qmlproperty real QtQuick1::SpringAnimation::modulus
- This property holds the modulus value. The default value is 0.
-
- Setting a \a modulus forces the target value to "wrap around" at the modulus.
- For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10.
-*/
-qreal QDeclarative1SpringAnimation::modulus() const
-{
- Q_D(const QDeclarative1SpringAnimation);
- return d->modulus;
-}
-
-void QDeclarative1SpringAnimation::setModulus(qreal modulus)
-{
- Q_D(QDeclarative1SpringAnimation);
- if (d->modulus != modulus) {
- d->haveModulus = modulus != 0.0;
- d->modulus = modulus;
- d->updateMode();
- emit modulusChanged();
- }
-}
-
-/*!
- \qmlproperty real QtQuick1::SpringAnimation::mass
- This property holds the "mass" of the property being moved.
-
- The value is 1.0 by default.
-
- A greater mass causes slower movement and a greater spring-like
- motion when an item comes to rest.
-*/
-qreal QDeclarative1SpringAnimation::mass() const
-{
- Q_D(const QDeclarative1SpringAnimation);
- return d->mass;
-}
-
-void QDeclarative1SpringAnimation::setMass(qreal mass)
-{
- Q_D(QDeclarative1SpringAnimation);
- if (d->mass != mass && mass > 0.0) {
- d->useMass = mass != 1.0;
- d->mass = mass;
- emit massChanged();
- }
-}
-
-void QDeclarative1SpringAnimation::transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarative1SpringAnimation);
- Q_UNUSED(direction);
-
- if (d->clock->state() != QAbstractAnimation::Running) {
- d->lastTime = 0;
- }
-
- QDeclarative1NumberAnimation::transition(actions, modified, direction);
-
- if (!d->actions)
- return;
-
- if (!d->actions->isEmpty()) {
- for (int i = 0; i < d->actions->size(); ++i) {
- const QDeclarativeProperty &property = d->actions->at(i).property;
- QDeclarative1SpringAnimationPrivate::SpringAnimation &animation
- = d->activeAnimations[property];
- animation.to = d->actions->at(i).toValue.toReal();
- animation.start = d->lastTime;
- if (d->fromIsDefined)
- animation.currentValue = d->actions->at(i).fromValue.toReal();
- else
- animation.currentValue = property.read().toReal();
- if (d->mode == QDeclarative1SpringAnimationPrivate::Velocity) {
- qreal dist = qAbs(animation.currentValue - animation.to);
- if (d->haveModulus && dist > d->modulus / 2)
- dist = d->modulus - fmod(dist, d->modulus);
- animation.duration = dist / d->velocityms;
- }
- }
- }
-}
-
-
-QAbstractAnimation *QDeclarative1SpringAnimation::qtAnimation()
-{
- Q_D(QDeclarative1SpringAnimation);
- return d->clock;
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativespringanimation_p.h b/src/qtquick1/util/qdeclarativespringanimation_p.h
deleted file mode 100644
index c589f0e2a7..0000000000
--- a/src/qtquick1/util/qdeclarativespringanimation_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESPRINGANIMATION_H
-#define QDECLARATIVESPRINGANIMATION_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1SpringAnimationPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1SpringAnimation : public QDeclarative1NumberAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1SpringAnimation)
- Q_INTERFACES(QDeclarativePropertyValueSource)
-
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
- Q_PROPERTY(qreal spring READ spring WRITE setSpring)
- Q_PROPERTY(qreal damping READ damping WRITE setDamping)
- Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon)
- Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
- Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
-
-public:
- QDeclarative1SpringAnimation(QObject *parent=0);
- ~QDeclarative1SpringAnimation();
-
- qreal velocity() const;
- void setVelocity(qreal velocity);
-
- qreal spring() const;
- void setSpring(qreal spring);
-
- qreal damping() const;
- void setDamping(qreal damping);
-
- qreal epsilon() const;
- void setEpsilon(qreal epsilon);
-
- qreal mass() const;
- void setMass(qreal modulus);
-
- qreal modulus() const;
- void setModulus(qreal modulus);
-
- virtual void transition(QDeclarative1StateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
-
-protected:
- virtual QAbstractAnimation *qtAnimation();
-
-Q_SIGNALS:
- void modulusChanged();
- void massChanged();
- void syncChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1SpringAnimation)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESPRINGANIMATION_H
diff --git a/src/qtquick1/util/qdeclarativestate.cpp b/src/qtquick1/util/qdeclarativestate.cpp
deleted file mode 100644
index ad7e71c588..0000000000
--- a/src/qtquick1/util/qdeclarativestate.cpp
+++ /dev/null
@@ -1,735 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativestate_p_p.h"
-#include "QtQuick1/private/qdeclarativestate_p.h"
-
-#include "QtQuick1/private/qdeclarativetransition_p.h"
-#include "QtQuick1/private/qdeclarativestategroup_p.h"
-#include "QtQuick1/private/qdeclarativestateoperations_p.h"
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-#include "QtQuick1/private/qdeclarativeanimation_p_p.h"
-
-#include <QtDeclarative/private/qdeclarativebinding_p.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-QDeclarative1Action::QDeclarative1Action()
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), event(0),
- specifiedObject(0)
-{
-}
-
-QDeclarative1Action::QDeclarative1Action(QObject *target, const QString &propertyName,
- const QVariant &value)
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
- property(target, propertyName, qmlEngine(target)), toValue(value),
- fromBinding(0), event(0),
- specifiedObject(target), specifiedProperty(propertyName)
-{
- if (property.isValid())
- fromValue = property.read();
-}
-
-QDeclarative1Action::QDeclarative1Action(QObject *target, const QString &propertyName,
- QDeclarativeContext *context, const QVariant &value)
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
- property(target, propertyName, context), toValue(value),
- fromBinding(0), event(0),
- specifiedObject(target), specifiedProperty(propertyName)
-{
- if (property.isValid())
- fromValue = property.read();
-}
-
-
-QDeclarative1ActionEvent::~QDeclarative1ActionEvent()
-{
-}
-
-QString QDeclarative1ActionEvent::typeName() const
-{
- return QString();
-}
-
-void QDeclarative1ActionEvent::execute(Reason)
-{
-}
-
-bool QDeclarative1ActionEvent::isReversable()
-{
- return false;
-}
-
-void QDeclarative1ActionEvent::reverse(Reason)
-{
-}
-
-bool QDeclarative1ActionEvent::changesBindings()
-{
- return false;
-}
-
-void QDeclarative1ActionEvent::clearBindings()
-{
-}
-
-bool QDeclarative1ActionEvent::override(QDeclarative1ActionEvent *other)
-{
- Q_UNUSED(other);
- return false;
-}
-
-QDeclarative1StateOperation::QDeclarative1StateOperation(QObjectPrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
-}
-
-/*!
- \qmlclass State QDeclarative1State
- \inqmlmodule QtQuick 1
- \ingroup qml-state-elements
- \since QtQuick 1.0
- \brief The State element defines configurations of objects and properties.
-
- A \e state is a set of batched changes from the default configuration.
-
- All items have a default state that defines the default configuration of objects
- and property values. New states can be defined by adding State items to the \l {Item::states}{states} property to
- allow items to switch between different configurations. These configurations
- can, for example, be used to apply different sets of property values or execute
- different scripts.
-
- The following example displays a single \l Rectangle. In the default state, the rectangle
- is colored black. In the "clicked" state, a PropertyChanges element changes the
- rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state
- between the default state and the "clicked" state, thus toggling the color of the
- rectangle between black and red.
-
- \snippet doc/src/snippets/qtquick1/state.qml 0
-
- Notice the default state is referred to using an empty string ("").
-
- States are commonly used together with \l{QML Animation and Transitions}{Transitions} to provide
- animations when state changes occur.
-
- \note Setting the state of an object from within another state of the same object is
- not allowed.
-
- \sa {declarative/animation/states}{states example}, {qmlstates}{States},
- {QML Animation and Transitions}{Transitions}, QtDeclarative
-*/
-QDeclarative1State::QDeclarative1State(QObject *parent)
-: QObject(*(new QDeclarative1StatePrivate), parent)
-{
- Q_D(QDeclarative1State);
- d->transitionManager.setState(this);
-}
-
-QDeclarative1State::~QDeclarative1State()
-{
- Q_D(QDeclarative1State);
- if (d->group)
- d->group->removeState(this);
-}
-
-/*!
- \qmlproperty string QtQuick1::State::name
- This property holds the name of the state.
-
- Each state should have a unique name within its item.
-*/
-QString QDeclarative1State::name() const
-{
- Q_D(const QDeclarative1State);
- return d->name;
-}
-
-void QDeclarative1State::setName(const QString &n)
-{
- Q_D(QDeclarative1State);
- d->name = n;
- d->named = true;
-}
-
-bool QDeclarative1State::isNamed() const
-{
- Q_D(const QDeclarative1State);
- return d->named;
-}
-
-bool QDeclarative1State::isWhenKnown() const
-{
- Q_D(const QDeclarative1State);
- return d->when != 0;
-}
-
-/*!
- \qmlproperty bool QtQuick1::State::when
- This property holds when the state should be applied.
-
- This should be set to an expression that evaluates to \c true when you want the state to
- be applied. For example, the following \l Rectangle changes in and out of the "hidden"
- state when the \l MouseArea is pressed:
-
- \snippet doc/src/snippets/qtquick1/state-when.qml 0
-
- If multiple states in a group have \c when clauses that evaluate to \c true
- at the same time, the first matching state will be applied. For example, in
- the following snippet \c state1 will always be selected rather than
- \c state2 when sharedCondition becomes \c true.
- \qml
- Item {
- states: [
- State { name: "state1"; when: sharedCondition },
- State { name: "state2"; when: sharedCondition }
- ]
- // ...
- }
- \endqml
-*/
-QDeclarativeBinding *QDeclarative1State::when() const
-{
- Q_D(const QDeclarative1State);
- return d->when;
-}
-
-void QDeclarative1State::setWhen(QDeclarativeBinding *when)
-{
- Q_D(QDeclarative1State);
- d->when = when;
- if (d->group)
- d->group->updateAutoState();
-}
-
-/*!
- \qmlproperty string QtQuick1::State::extend
- This property holds the state that this state extends.
-
- When a state extends another state, it inherits all the changes of that state.
-
- The state being extended is treated as the base state in regards to
- the changes specified by the extending state.
-*/
-QString QDeclarative1State::extends() const
-{
- Q_D(const QDeclarative1State);
- return d->extends;
-}
-
-void QDeclarative1State::setExtends(const QString &extends)
-{
- Q_D(QDeclarative1State);
- d->extends = extends;
-}
-
-/*!
- \qmlproperty list<Change> QtQuick1::State::changes
- This property holds the changes to apply for this state
- \default
-
- By default these changes are applied against the default state. If the state
- extends another state, then the changes are applied against the state being
- extended.
-*/
-QDeclarativeListProperty<QDeclarative1StateOperation> QDeclarative1State::changes()
-{
- Q_D(QDeclarative1State);
- return QDeclarativeListProperty<QDeclarative1StateOperation>(this, &d->operations, QDeclarative1StatePrivate::operations_append,
- QDeclarative1StatePrivate::operations_count, QDeclarative1StatePrivate::operations_at,
- QDeclarative1StatePrivate::operations_clear);
-}
-
-int QDeclarative1State::operationCount() const
-{
- Q_D(const QDeclarative1State);
- return d->operations.count();
-}
-
-QDeclarative1StateOperation *QDeclarative1State::operationAt(int index) const
-{
- Q_D(const QDeclarative1State);
- return d->operations.at(index);
-}
-
-QDeclarative1State &QDeclarative1State::operator<<(QDeclarative1StateOperation *op)
-{
- Q_D(QDeclarative1State);
- d->operations.append(QDeclarative1StatePrivate::OperationGuard(op, &d->operations));
- return *this;
-}
-
-void QDeclarative1StatePrivate::complete()
-{
- Q_Q(QDeclarative1State);
-
- for (int ii = 0; ii < reverting.count(); ++ii) {
- for (int jj = 0; jj < revertList.count(); ++jj) {
- if (revertList.at(jj).property() == reverting.at(ii)) {
- revertList.removeAt(jj);
- break;
- }
- }
- }
- reverting.clear();
-
- emit q->completed();
-}
-
-// Generate a list of actions for this state. This includes coelescing state
-// actions that this state "extends"
-QDeclarative1StateOperation::ActionList
-QDeclarative1StatePrivate::generateActionList(QDeclarative1StateGroup *group) const
-{
- QDeclarative1StateOperation::ActionList applyList;
- if (inState)
- return applyList;
-
- // Prevent "extends" recursion
- inState = true;
-
- if (!extends.isEmpty()) {
- QList<QDeclarative1State *> states = group->states();
- for (int ii = 0; ii < states.count(); ++ii)
- if (states.at(ii)->name() == extends) {
- qmlExecuteDeferred(states.at(ii));
- applyList = static_cast<QDeclarative1StatePrivate*>(states.at(ii)->d_func())->generateActionList(group);
- }
- }
-
- foreach(QDeclarative1StateOperation *op, operations)
- applyList << op->actions();
-
- inState = false;
- return applyList;
-}
-
-QDeclarative1StateGroup *QDeclarative1State::stateGroup() const
-{
- Q_D(const QDeclarative1State);
- return d->group;
-}
-
-void QDeclarative1State::setStateGroup(QDeclarative1StateGroup *group)
-{
- Q_D(QDeclarative1State);
- d->group = group;
-}
-
-void QDeclarative1State::cancel()
-{
- Q_D(QDeclarative1State);
- d->transitionManager.cancel();
-}
-
-void QDeclarative1Action::deleteFromBinding()
-{
- if (fromBinding) {
- QDeclarativePropertyPrivate::setBinding(property, 0);
- fromBinding->destroy();
- fromBinding = 0;
- }
-}
-
-bool QDeclarative1State::containsPropertyInRevertList(QObject *target, const QString &name) const
-{
- Q_D(const QDeclarative1State);
-
- if (isStateActive()) {
- QListIterator<QDeclarative1SimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- const QDeclarative1SimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
- return true;
- }
- }
-
- return false;
-}
-
-bool QDeclarative1State::changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue)
-{
- Q_D(QDeclarative1State);
-
- if (isStateActive()) {
- QMutableListIterator<QDeclarative1SimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- QDeclarative1SimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
- simpleAction.setValue(revertValue);
- return true;
- }
- }
- }
-
- return false;
-}
-
-bool QDeclarative1State::changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding)
-{
- Q_D(QDeclarative1State);
-
- if (isStateActive()) {
- QMutableListIterator<QDeclarative1SimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- QDeclarative1SimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) {
- if (simpleAction.binding())
- simpleAction.binding()->destroy();
-
- simpleAction.setBinding(binding);
- return true;
- }
- }
- }
-
- return false;
-}
-
-bool QDeclarative1State::removeEntryFromRevertList(QObject *target, const QString &name)
-{
- Q_D(QDeclarative1State);
-
- if (isStateActive()) {
- QMutableListIterator<QDeclarative1SimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- QDeclarative1SimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.property().object() == target && simpleAction.property().name() == name) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property());
- if (oldBinding) {
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0);
- oldBinding->destroy();
- }
-
- simpleAction.property().write(simpleAction.value());
- if (simpleAction.binding())
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding());
-
- revertListIterator.remove();
- return true;
- }
- }
- }
-
- return false;
-}
-
-void QDeclarative1State::addEntryToRevertList(const QDeclarative1Action &action)
-{
- Q_D(QDeclarative1State);
-
- QDeclarative1SimpleAction simpleAction(action);
-
- d->revertList.append(simpleAction);
-}
-
-void QDeclarative1State::removeAllEntriesFromRevertList(QObject *target)
-{
- Q_D(QDeclarative1State);
-
- if (isStateActive()) {
- QMutableListIterator<QDeclarative1SimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- QDeclarative1SimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.property().object() == target) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property());
- if (oldBinding) {
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0);
- oldBinding->destroy();
- }
-
- simpleAction.property().write(simpleAction.value());
- if (simpleAction.binding())
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding());
-
- revertListIterator.remove();
- }
- }
- }
-}
-
-void QDeclarative1State::addEntriesToRevertList(const QList<QDeclarative1Action> &actionList)
-{
- Q_D(QDeclarative1State);
- if (isStateActive()) {
- QList<QDeclarative1SimpleAction> simpleActionList;
-
- QListIterator<QDeclarative1Action> actionListIterator(actionList);
- while(actionListIterator.hasNext()) {
- const QDeclarative1Action &action = actionListIterator.next();
- QDeclarative1SimpleAction simpleAction(action);
- action.property.write(action.toValue);
- if (!action.toBinding.isNull()) {
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property());
- if (oldBinding)
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0);
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), action.toBinding.data(), QDeclarativePropertyPrivate::DontRemoveBinding);
- }
-
- simpleActionList.append(simpleAction);
- }
-
- d->revertList.append(simpleActionList);
- }
-}
-
-QVariant QDeclarative1State::valueInRevertList(QObject *target, const QString &name) const
-{
- Q_D(const QDeclarative1State);
-
- if (isStateActive()) {
- QListIterator<QDeclarative1SimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- const QDeclarative1SimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
- return simpleAction.value();
- }
- }
-
- return QVariant();
-}
-
-QDeclarativeAbstractBinding *QDeclarative1State::bindingInRevertList(QObject *target, const QString &name) const
-{
- Q_D(const QDeclarative1State);
-
- if (isStateActive()) {
- QListIterator<QDeclarative1SimpleAction> revertListIterator(d->revertList);
-
- while (revertListIterator.hasNext()) {
- const QDeclarative1SimpleAction &simpleAction = revertListIterator.next();
- if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name)
- return simpleAction.binding();
- }
- }
-
- return 0;
-}
-
-bool QDeclarative1State::isStateActive() const
-{
- return stateGroup() && stateGroup()->state() == name();
-}
-
-void QDeclarative1State::apply(QDeclarative1StateGroup *group, QDeclarative1Transition *trans, QDeclarative1State *revert)
-{
- Q_D(QDeclarative1State);
-
- qmlExecuteDeferred(this);
-
- cancel();
- if (revert)
- revert->cancel();
- d->revertList.clear();
- d->reverting.clear();
-
- if (revert) {
- QDeclarative1StatePrivate *revertPrivate =
- static_cast<QDeclarative1StatePrivate*>(revert->d_func());
- d->revertList = revertPrivate->revertList;
- revertPrivate->revertList.clear();
- }
-
- // List of actions caused by this state
- QDeclarative1StateOperation::ActionList applyList = d->generateActionList(group);
-
- // List of actions that need to be reverted to roll back (just) this state
- QDeclarative1StatePrivate::SimpleActionList additionalReverts;
- // First add the reverse of all the applyList actions
- for (int ii = 0; ii < applyList.count(); ++ii) {
- QDeclarative1Action &action = applyList[ii];
-
- if (action.event) {
- if (!action.event->isReversable())
- continue;
- bool found = false;
- for (int jj = 0; jj < d->revertList.count(); ++jj) {
- QDeclarative1ActionEvent *event = d->revertList.at(jj).event();
- if (event && event->typeName() == action.event->typeName()) {
- if (action.event->override(event)) {
- found = true;
-
- if (action.event != d->revertList.at(jj).event() && action.event->needsCopy()) {
- action.event->copyOriginals(d->revertList.at(jj).event());
-
- QDeclarative1SimpleAction r(action);
- additionalReverts << r;
- d->revertList.removeAt(jj);
- --jj;
- } else if (action.event->isRewindable()) //###why needed?
- action.event->saveCurrentValues();
-
- break;
- }
- }
- }
- if (!found) {
- action.event->saveOriginals();
- // Only need to revert the applyList action if the previous
- // state doesn't have a higher priority revert already
- QDeclarative1SimpleAction r(action);
- additionalReverts << r;
- }
- } else {
- bool found = false;
- action.fromBinding = QDeclarativePropertyPrivate::binding(action.property);
-
- for (int jj = 0; jj < d->revertList.count(); ++jj) {
- if (d->revertList.at(jj).property() == action.property) {
- found = true;
- if (d->revertList.at(jj).binding() != action.fromBinding) {
- action.deleteFromBinding();
- }
- break;
- }
- }
-
- if (!found) {
- if (!action.restore) {
- action.deleteFromBinding();;
- } else {
- // Only need to revert the applyList action if the previous
- // state doesn't have a higher priority revert already
- QDeclarative1SimpleAction r(action);
- additionalReverts << r;
- }
- }
- }
- }
-
- // Any reverts from a previous state that aren't carried forth
- // into this state need to be translated into apply actions
- for (int ii = 0; ii < d->revertList.count(); ++ii) {
- bool found = false;
- if (d->revertList.at(ii).event()) {
- QDeclarative1ActionEvent *event = d->revertList.at(ii).event();
- if (!event->isReversable())
- continue;
- for (int jj = 0; !found && jj < applyList.count(); ++jj) {
- const QDeclarative1Action &action = applyList.at(jj);
- if (action.event && action.event->typeName() == event->typeName()) {
- if (action.event->override(event))
- found = true;
- }
- }
- } else {
- for (int jj = 0; !found && jj < applyList.count(); ++jj) {
- const QDeclarative1Action &action = applyList.at(jj);
- if (action.property == d->revertList.at(ii).property())
- found = true;
- }
- }
- if (!found) {
- QVariant cur = d->revertList.at(ii).property().read();
- QDeclarativeAbstractBinding *delBinding =
- QDeclarativePropertyPrivate::setBinding(d->revertList.at(ii).property(), 0);
- if (delBinding)
- delBinding->destroy();
-
- QDeclarative1Action a;
- a.property = d->revertList.at(ii).property();
- a.fromValue = cur;
- a.toValue = d->revertList.at(ii).value();
- a.toBinding = QDeclarativeAbstractBinding::getPointer(d->revertList.at(ii).binding());
- a.specifiedObject = d->revertList.at(ii).specifiedObject();
- a.specifiedProperty = d->revertList.at(ii).specifiedProperty();
- a.event = d->revertList.at(ii).event();
- a.reverseEvent = d->revertList.at(ii).reverseEvent();
- if (a.event && a.event->isRewindable())
- a.event->saveCurrentValues();
- applyList << a;
- // Store these special reverts in the reverting list
- d->reverting << d->revertList.at(ii).property();
- }
- }
- // All the local reverts now become part of the ongoing revertList
- d->revertList << additionalReverts;
-
-#ifndef QT_NO_DEBUG_STREAM
- // Output for debugging
- if (stateChangeDebug()) {
- foreach(const QDeclarative1Action &action, applyList) {
- if (action.event)
- qWarning() << " QDeclarative1Action event:" << action.event->typeName();
- else
- qWarning() << " QDeclarative1Action:" << action.property.object()
- << action.property.name() << "From:" << action.fromValue
- << "To:" << action.toValue;
- }
- }
-#endif
-
- d->transitionManager.transition(applyList, trans);
-}
-
-QDeclarative1StateOperation::ActionList QDeclarative1StateOperation::actions()
-{
- return ActionList();
-}
-
-QDeclarative1State *QDeclarative1StateOperation::state() const
-{
- Q_D(const QDeclarative1StateOperation);
- return d->m_state;
-}
-
-void QDeclarative1StateOperation::setState(QDeclarative1State *state)
-{
- Q_D(QDeclarative1StateOperation);
- d->m_state = state;
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativestate_p.h b/src/qtquick1/util/qdeclarativestate_p.h
deleted file mode 100644
index 3dc7facd68..0000000000
--- a/src/qtquick1/util/qdeclarativestate_p.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTATE_H
-#define QDECLARATIVESTATE_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qsharedpointer.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeAbstractBinding;
-class QDeclarativeBinding;
-class QDeclarativeExpression;
-
-
-class QDeclarative1ActionEvent;
-class Q_QTQUICK1_EXPORT QDeclarative1Action
-{
-public:
- QDeclarative1Action();
- QDeclarative1Action(QObject *, const QString &, const QVariant &);
- QDeclarative1Action(QObject *, const QString &,
- QDeclarativeContext *, const QVariant &);
-
- bool restore:1;
- bool actionDone:1;
- bool reverseEvent:1;
- bool deletableToBinding:1;
-
- QDeclarativeProperty property;
- QVariant fromValue;
- QVariant toValue;
-
- QDeclarativeAbstractBinding *fromBinding;
- QWeakPointer<QDeclarativeAbstractBinding> toBinding;
- QDeclarative1ActionEvent *event;
-
- //strictly for matching
- QObject *specifiedObject;
- QString specifiedProperty;
-
- void deleteFromBinding();
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1ActionEvent
-{
-public:
- virtual ~QDeclarative1ActionEvent();
- virtual QString typeName() const;
-
- enum Reason { ActualChange, FastForward };
-
- virtual void execute(Reason reason = ActualChange);
- virtual bool isReversable();
- virtual void reverse(Reason reason = ActualChange);
- virtual void saveOriginals() {}
- virtual bool needsCopy() { return false; }
- virtual void copyOriginals(QDeclarative1ActionEvent *) {}
-
- virtual bool isRewindable() { return isReversable(); }
- virtual void rewind() {}
- virtual void saveCurrentValues() {}
- virtual void saveTargetValues() {}
-
- virtual bool changesBindings();
- virtual void clearBindings();
- virtual bool override(QDeclarative1ActionEvent*other);
-};
-
-//### rename to QDeclarative1StateChange?
-class QDeclarative1StateGroup;
-class QDeclarative1State;
-class QDeclarative1StateOperationPrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1StateOperation : public QObject
-{
- Q_OBJECT
-public:
- QDeclarative1StateOperation(QObject *parent = 0)
- : QObject(parent) {}
- typedef QList<QDeclarative1Action> ActionList;
-
- virtual ActionList actions();
-
- QDeclarative1State *state() const;
- void setState(QDeclarative1State *state);
-
-protected:
- QDeclarative1StateOperation(QObjectPrivate &dd, QObject *parent = 0);
-
-private:
- Q_DECLARE_PRIVATE(QDeclarative1StateOperation)
- Q_DISABLE_COPY(QDeclarative1StateOperation)
-};
-
-typedef QDeclarative1StateOperation::ActionList QDeclarative1StateActions;
-
-class QDeclarative1Transition;
-class QDeclarative1StatePrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1State : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen)
- Q_PROPERTY(QString extend READ extends WRITE setExtends)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarative1StateOperation> changes READ changes)
- Q_CLASSINFO("DefaultProperty", "changes")
- Q_CLASSINFO("DeferredPropertyNames", "changes")
-
-public:
- QDeclarative1State(QObject *parent=0);
- virtual ~QDeclarative1State();
-
- QString name() const;
- void setName(const QString &);
- bool isNamed() const;
-
- /*'when' is a QDeclarativeBinding to limit state changes oscillation
- due to the unpredictable order of evaluation of bound expressions*/
- bool isWhenKnown() const;
- QDeclarativeBinding *when() const;
- void setWhen(QDeclarativeBinding *);
-
- QString extends() const;
- void setExtends(const QString &);
-
- QDeclarativeListProperty<QDeclarative1StateOperation> changes();
- int operationCount() const;
- QDeclarative1StateOperation *operationAt(int) const;
-
- QDeclarative1State &operator<<(QDeclarative1StateOperation *);
-
- void apply(QDeclarative1StateGroup *, QDeclarative1Transition *, QDeclarative1State *revert);
- void cancel();
-
- QDeclarative1StateGroup *stateGroup() const;
- void setStateGroup(QDeclarative1StateGroup *);
-
- bool containsPropertyInRevertList(QObject *target, const QString &name) const;
- bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
- bool changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding);
- bool removeEntryFromRevertList(QObject *target, const QString &name);
- void addEntryToRevertList(const QDeclarative1Action &action);
- void removeAllEntriesFromRevertList(QObject *target);
- void addEntriesToRevertList(const QList<QDeclarative1Action> &actions);
- QVariant valueInRevertList(QObject *target, const QString &name) const;
- QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const;
-
- bool isStateActive() const;
-
-Q_SIGNALS:
- void completed();
-
-private:
- Q_DECLARE_PRIVATE(QDeclarative1State)
- Q_DISABLE_COPY(QDeclarative1State)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1StateOperation)
-QML_DECLARE_TYPE(QDeclarative1State)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESTATE_H
diff --git a/src/qtquick1/util/qdeclarativestate_p_p.h b/src/qtquick1/util/qdeclarativestate_p_p.h
deleted file mode 100644
index 529cb3f4a8..0000000000
--- a/src/qtquick1/util/qdeclarativestate_p_p.h
+++ /dev/null
@@ -1,253 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTATE_P_H
-#define QDECLARATIVESTATE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtQuick1/private/qdeclarativestate_p.h"
-
-#include "QtQuick1/private/qdeclarativeanimation_p_p.h"
-#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h"
-
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-#include <QtDeclarative/private/qdeclarativeguard_p.h>
-
-#include <QtDeclarative/private/qdeclarativebinding_p.h>
-
-#include <QtCore/private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarative1SimpleAction
-{
-public:
- enum State { StartState, EndState };
- QDeclarative1SimpleAction(const QDeclarative1Action &a, State state = StartState)
- {
- m_property = a.property;
- m_specifiedObject = a.specifiedObject;
- m_specifiedProperty = a.specifiedProperty;
- m_event = a.event;
- if (state == StartState) {
- m_value = a.fromValue;
- if (QDeclarativePropertyPrivate::binding(m_property)) {
- m_binding = QDeclarativeAbstractBinding::getPointer(QDeclarativePropertyPrivate::binding(m_property));
- }
- m_reverseEvent = true;
- } else {
- m_value = a.toValue;
- m_binding = a.toBinding;
- m_reverseEvent = false;
- }
- }
-
- ~QDeclarative1SimpleAction()
- {
- }
-
- QDeclarative1SimpleAction(const QDeclarative1SimpleAction &other)
- : m_property(other.m_property),
- m_value(other.m_value),
- m_binding(QDeclarativeAbstractBinding::getPointer(other.binding())),
- m_specifiedObject(other.m_specifiedObject),
- m_specifiedProperty(other.m_specifiedProperty),
- m_event(other.m_event),
- m_reverseEvent(other.m_reverseEvent)
- {
- }
-
- QDeclarative1SimpleAction &operator =(const QDeclarative1SimpleAction &other)
- {
- m_property = other.m_property;
- m_value = other.m_value;
- m_binding = QDeclarativeAbstractBinding::getPointer(other.binding());
- m_specifiedObject = other.m_specifiedObject;
- m_specifiedProperty = other.m_specifiedProperty;
- m_event = other.m_event;
- m_reverseEvent = other.m_reverseEvent;
-
- return *this;
- }
-
- void setProperty(const QDeclarativeProperty &property)
- {
- m_property = property;
- }
-
- const QDeclarativeProperty &property() const
- {
- return m_property;
- }
-
- void setValue(const QVariant &value)
- {
- m_value = value;
- }
-
- const QVariant &value() const
- {
- return m_value;
- }
-
- void setBinding(QDeclarativeAbstractBinding *binding)
- {
- m_binding = QDeclarativeAbstractBinding::getPointer(binding);
- }
-
- QDeclarativeAbstractBinding *binding() const
- {
- return m_binding.data();
- }
-
- QObject *specifiedObject() const
- {
- return m_specifiedObject;
- }
-
- const QString &specifiedProperty() const
- {
- return m_specifiedProperty;
- }
-
- QDeclarative1ActionEvent *event() const
- {
- return m_event;
- }
-
- bool reverseEvent() const
- {
- return m_reverseEvent;
- }
-
-private:
- QDeclarativeProperty m_property;
- QVariant m_value;
- QDeclarativeAbstractBinding::Pointer m_binding;
- QObject *m_specifiedObject;
- QString m_specifiedProperty;
- QDeclarative1ActionEvent *m_event;
- bool m_reverseEvent;
-};
-
-class QDeclarative1StateOperationPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1StateOperation)
-
-public:
-
- QDeclarative1StateOperationPrivate()
- : m_state(0) {}
-
- QDeclarative1State *m_state;
-};
-
-class QDeclarative1StatePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1State)
-
-public:
- QDeclarative1StatePrivate()
- : when(0), named(false), inState(false), group(0) {}
-
- typedef QList<QDeclarative1SimpleAction> SimpleActionList;
-
- QString name;
- QDeclarativeBinding *when;
- bool named;
-
- struct OperationGuard : public QDeclarativeGuard<QDeclarative1StateOperation>
- {
- OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) { (QDeclarativeGuard<QObject>&)*this = obj; }
- QList<OperationGuard> *list;
- void objectDestroyed(QDeclarative1StateOperation *) {
- // we assume priv will always be destroyed after objectDestroyed calls
- list->removeOne(*this);
- }
- };
- QList<OperationGuard> operations;
-
- static void operations_append(QDeclarativeListProperty<QDeclarative1StateOperation> *prop, QDeclarative1StateOperation *op) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- op->setState(qobject_cast<QDeclarative1State*>(prop->object));
- list->append(OperationGuard(op, list));
- }
- static void operations_clear(QDeclarativeListProperty<QDeclarative1StateOperation> *prop) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- QMutableListIterator<OperationGuard> listIterator(*list);
- while(listIterator.hasNext())
- listIterator.next()->setState(0);
- list->clear();
- }
- static int operations_count(QDeclarativeListProperty<QDeclarative1StateOperation> *prop) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- return list->count();
- }
- static QDeclarative1StateOperation *operations_at(QDeclarativeListProperty<QDeclarative1StateOperation> *prop, int index) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- return list->at(index);
- }
-
- QDeclarative1TransitionManager transitionManager;
-
- SimpleActionList revertList;
- QList<QDeclarativeProperty> reverting;
- QString extends;
- mutable bool inState;
- QDeclarative1StateGroup *group;
-
- QDeclarative1StateOperation::ActionList generateActionList(QDeclarative1StateGroup *) const;
- void complete();
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVESTATE_P_H
diff --git a/src/qtquick1/util/qdeclarativestategroup.cpp b/src/qtquick1/util/qdeclarativestategroup.cpp
deleted file mode 100644
index 168d16faad..0000000000
--- a/src/qtquick1/util/qdeclarativestategroup.cpp
+++ /dev/null
@@ -1,511 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativestategroup_p.h"
-
-#include "QtQuick1/private/qdeclarativetransition_p.h"
-#include "QtQuick1/private/qdeclarativestate_p_p.h"
-
-#include <QtDeclarative/private/qdeclarativebinding_p.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-
-#include <QtCore/qstringbuilder.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-class QDeclarative1StateGroupPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1StateGroup)
-public:
- QDeclarative1StateGroupPrivate()
- : nullState(0), componentComplete(true),
- ignoreTrans(false), applyingState(false), unnamedCount(0) {}
-
- QString currentState;
- QDeclarative1State *nullState;
-
- static void append_state(QDeclarativeListProperty<QDeclarative1State> *list, QDeclarative1State *state);
- static int count_state(QDeclarativeListProperty<QDeclarative1State> *list);
- static QDeclarative1State *at_state(QDeclarativeListProperty<QDeclarative1State> *list, int index);
- static void clear_states(QDeclarativeListProperty<QDeclarative1State> *list);
-
- static void append_transition(QDeclarativeListProperty<QDeclarative1Transition> *list, QDeclarative1Transition *state);
- static int count_transitions(QDeclarativeListProperty<QDeclarative1Transition> *list);
- static QDeclarative1Transition *at_transition(QDeclarativeListProperty<QDeclarative1Transition> *list, int index);
- static void clear_transitions(QDeclarativeListProperty<QDeclarative1Transition> *list);
-
- QList<QDeclarative1State *> states;
- QList<QDeclarative1Transition *> transitions;
-
- bool componentComplete;
- bool ignoreTrans;
- bool applyingState;
- int unnamedCount;
-
- QDeclarative1Transition *findTransition(const QString &from, const QString &to);
- void setCurrentStateInternal(const QString &state, bool = false);
- bool updateAutoState();
-};
-
-/*!
- \qmlclass StateGroup QDeclarative1StateGroup
- \inqmlmodule QtQuick 1
- \ingroup qml-state-elements
- \since QtQuick 1.0
- \brief The StateGroup element provides state support for non-Item elements.
-
- Item (and all derived elements) provides built in support for states and transitions
- via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to
- use this support in other (non-Item-derived) elements.
-
- \qml
- MyCustomObject {
- StateGroup {
- id: myStateGroup
- states: State {
- name: "state1"
- // ...
- }
- transitions: Transition {
- // ...
- }
- }
-
- onSomethingHappened: myStateGroup.state = "state1";
- }
- \endqml
-
- \sa {qmlstate}{States} {QML Animation and Transitions}{Transitions}, {QtDeclarative}
-*/
-
-QDeclarative1StateGroup::QDeclarative1StateGroup(QObject *parent)
- : QObject(*(new QDeclarative1StateGroupPrivate), parent)
-{
-}
-
-QDeclarative1StateGroup::~QDeclarative1StateGroup()
-{
- Q_D(const QDeclarative1StateGroup);
- for (int i = 0; i < d->states.count(); ++i)
- d->states.at(i)->setStateGroup(0);
-}
-
-QList<QDeclarative1State *> QDeclarative1StateGroup::states() const
-{
- Q_D(const QDeclarative1StateGroup);
- return d->states;
-}
-
-/*!
- \qmlproperty list<State> QtQuick1::StateGroup::states
- This property holds a list of states defined by the state group.
-
- \qml
- StateGroup {
- states: [
- State {
- // State definition...
- },
- State {
- // ...
- }
- // Other states...
- ]
- }
- \endqml
-
- \sa {qmlstate}{States}
-*/
-QDeclarativeListProperty<QDeclarative1State> QDeclarative1StateGroup::statesProperty()
-{
- Q_D(QDeclarative1StateGroup);
- return QDeclarativeListProperty<QDeclarative1State>(this, &d->states, &QDeclarative1StateGroupPrivate::append_state,
- &QDeclarative1StateGroupPrivate::count_state,
- &QDeclarative1StateGroupPrivate::at_state,
- &QDeclarative1StateGroupPrivate::clear_states);
-}
-
-void QDeclarative1StateGroupPrivate::append_state(QDeclarativeListProperty<QDeclarative1State> *list, QDeclarative1State *state)
-{
- QDeclarative1StateGroup *_this = static_cast<QDeclarative1StateGroup *>(list->object);
- if (state) {
- _this->d_func()->states.append(state);
- state->setStateGroup(_this);
- }
-
-}
-
-int QDeclarative1StateGroupPrivate::count_state(QDeclarativeListProperty<QDeclarative1State> *list)
-{
- QDeclarative1StateGroup *_this = static_cast<QDeclarative1StateGroup *>(list->object);
- return _this->d_func()->states.count();
-}
-
-QDeclarative1State *QDeclarative1StateGroupPrivate::at_state(QDeclarativeListProperty<QDeclarative1State> *list, int index)
-{
- QDeclarative1StateGroup *_this = static_cast<QDeclarative1StateGroup *>(list->object);
- return _this->d_func()->states.at(index);
-}
-
-void QDeclarative1StateGroupPrivate::clear_states(QDeclarativeListProperty<QDeclarative1State> *list)
-{
- QDeclarative1StateGroup *_this = static_cast<QDeclarative1StateGroup *>(list->object);
- _this->d_func()->setCurrentStateInternal(QString(), true);
- for (int i = 0; i < _this->d_func()->states.count(); ++i) {
- _this->d_func()->states.at(i)->setStateGroup(0);
- }
- _this->d_func()->states.clear();
-}
-
-/*!
- \qmlproperty list<Transition> QtQuick1::StateGroup::transitions
- This property holds a list of transitions defined by the state group.
-
- \qml
- StateGroup {
- transitions: [
- Transition {
- // ...
- },
- Transition {
- // ...
- }
- // ...
- ]
- }
- \endqml
-
- \sa {QML Animation and Transitions}{Transitions}
-*/
-QDeclarativeListProperty<QDeclarative1Transition> QDeclarative1StateGroup::transitionsProperty()
-{
- Q_D(QDeclarative1StateGroup);
- return QDeclarativeListProperty<QDeclarative1Transition>(this, &d->transitions, &QDeclarative1StateGroupPrivate::append_transition,
- &QDeclarative1StateGroupPrivate::count_transitions,
- &QDeclarative1StateGroupPrivate::at_transition,
- &QDeclarative1StateGroupPrivate::clear_transitions);
-}
-
-void QDeclarative1StateGroupPrivate::append_transition(QDeclarativeListProperty<QDeclarative1Transition> *list, QDeclarative1Transition *trans)
-{
- QDeclarative1StateGroup *_this = static_cast<QDeclarative1StateGroup *>(list->object);
- if (trans)
- _this->d_func()->transitions.append(trans);
-}
-
-int QDeclarative1StateGroupPrivate::count_transitions(QDeclarativeListProperty<QDeclarative1Transition> *list)
-{
- QDeclarative1StateGroup *_this = static_cast<QDeclarative1StateGroup *>(list->object);
- return _this->d_func()->transitions.count();
-}
-
-QDeclarative1Transition *QDeclarative1StateGroupPrivate::at_transition(QDeclarativeListProperty<QDeclarative1Transition> *list, int index)
-{
- QDeclarative1StateGroup *_this = static_cast<QDeclarative1StateGroup *>(list->object);
- return _this->d_func()->transitions.at(index);
-}
-
-void QDeclarative1StateGroupPrivate::clear_transitions(QDeclarativeListProperty<QDeclarative1Transition> *list)
-{
- QDeclarative1StateGroup *_this = static_cast<QDeclarative1StateGroup *>(list->object);
- _this->d_func()->transitions.clear();
-}
-
-/*!
- \qmlproperty string QtQuick1::StateGroup::state
-
- This property holds the name of the current state of the state group.
-
- This property is often used in scripts to change between states. For
- example:
-
- \js
- function toggle() {
- if (button.state == 'On')
- button.state = 'Off';
- else
- button.state = 'On';
- }
- \endjs
-
- If the state group is in its base state (i.e. no explicit state has been
- set), \c state will be a blank string. Likewise, you can return a
- state group to its base state by setting its current state to \c ''.
-
- \sa {qmlstates}{States}
-*/
-QString QDeclarative1StateGroup::state() const
-{
- Q_D(const QDeclarative1StateGroup);
- return d->currentState;
-}
-
-void QDeclarative1StateGroup::setState(const QString &state)
-{
- Q_D(QDeclarative1StateGroup);
- if (d->currentState == state)
- return;
-
- d->setCurrentStateInternal(state);
-}
-
-void QDeclarative1StateGroup::classBegin()
-{
- Q_D(QDeclarative1StateGroup);
- d->componentComplete = false;
-}
-
-void QDeclarative1StateGroup::componentComplete()
-{
- Q_D(QDeclarative1StateGroup);
- d->componentComplete = true;
-
- for (int ii = 0; ii < d->states.count(); ++ii) {
- QDeclarative1State *state = d->states.at(ii);
- if (!state->isNamed())
- state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount));
- }
-
- if (d->updateAutoState()) {
- return;
- } else if (!d->currentState.isEmpty()) {
- QString cs = d->currentState;
- d->currentState.clear();
- d->setCurrentStateInternal(cs, true);
- }
-}
-
-/*!
- Returns true if the state was changed, otherwise false.
-*/
-bool QDeclarative1StateGroup::updateAutoState()
-{
- Q_D(QDeclarative1StateGroup);
- return d->updateAutoState();
-}
-
-bool QDeclarative1StateGroupPrivate::updateAutoState()
-{
- Q_Q(QDeclarative1StateGroup);
- if (!componentComplete)
- return false;
-
- bool revert = false;
- for (int ii = 0; ii < states.count(); ++ii) {
- QDeclarative1State *state = states.at(ii);
- if (state->isWhenKnown()) {
- if (state->isNamed()) {
- if (state->when() && state->when()->evaluate().toBool()) {
- if (stateChangeDebug())
- qWarning() << "Setting auto state due to:"
- << state->when()->expression();
- if (currentState != state->name()) {
- q->setState(state->name());
- return true;
- } else {
- return false;
- }
- } else if (state->name() == currentState) {
- revert = true;
- }
- }
- }
- }
- if (revert) {
- bool rv = !currentState.isEmpty();
- q->setState(QString());
- return rv;
- } else {
- return false;
- }
-}
-
-QDeclarative1Transition *QDeclarative1StateGroupPrivate::findTransition(const QString &from, const QString &to)
-{
- QDeclarative1Transition *highest = 0;
- int score = 0;
- bool reversed = false;
- bool done = false;
-
- for (int ii = 0; !done && ii < transitions.count(); ++ii) {
- QDeclarative1Transition *t = transitions.at(ii);
- for (int ii = 0; ii < 2; ++ii)
- {
- if (ii && (!t->reversible() ||
- (t->fromState() == QLatin1String("*") &&
- t->toState() == QLatin1String("*"))))
- break;
- QStringList fromState;
- QStringList toState;
-
- fromState = t->fromState().split(QLatin1Char(','));
- for (int jj = 0; jj < fromState.count(); ++jj)
- fromState[jj] = fromState.at(jj).trimmed();
- toState = t->toState().split(QLatin1Char(','));
- for (int jj = 0; jj < toState.count(); ++jj)
- toState[jj] = toState.at(jj).trimmed();
- if (ii == 1)
- qSwap(fromState, toState);
- int tScore = 0;
- if (fromState.contains(from))
- tScore += 2;
- else if (fromState.contains(QLatin1String("*")))
- tScore += 1;
- else
- continue;
-
- if (toState.contains(to))
- tScore += 2;
- else if (toState.contains(QLatin1String("*")))
- tScore += 1;
- else
- continue;
-
- if (ii == 1)
- reversed = true;
- else
- reversed = false;
-
- if (tScore == 4) {
- highest = t;
- done = true;
- break;
- } else if (tScore > score) {
- score = tScore;
- highest = t;
- }
- }
- }
-
- if (highest)
- highest->setReversed(reversed);
-
- return highest;
-}
-
-void QDeclarative1StateGroupPrivate::setCurrentStateInternal(const QString &state,
- bool ignoreTrans)
-{
- Q_Q(QDeclarative1StateGroup);
- if (!componentComplete) {
- currentState = state;
- return;
- }
-
- if (applyingState) {
- qmlInfo(q) << "Can't apply a state change as part of a state definition.";
- return;
- }
-
- applyingState = true;
-
- QDeclarative1Transition *transition = ignoreTrans ? 0 : findTransition(currentState, state);
- if (stateChangeDebug()) {
- qWarning() << this << "Changing state. From" << currentState << ". To" << state;
- if (transition)
- qWarning() << " using transition" << transition->fromState()
- << transition->toState();
- }
-
- QDeclarative1State *oldState = 0;
- if (!currentState.isEmpty()) {
- for (int ii = 0; ii < states.count(); ++ii) {
- if (states.at(ii)->name() == currentState) {
- oldState = states.at(ii);
- break;
- }
- }
- }
-
- currentState = state;
- emit q->stateChanged(currentState);
-
- QDeclarative1State *newState = 0;
- for (int ii = 0; ii < states.count(); ++ii) {
- if (states.at(ii)->name() == currentState) {
- newState = states.at(ii);
- break;
- }
- }
-
- if (oldState == 0 || newState == 0) {
- if (!nullState) { nullState = new QDeclarative1State; QDeclarative_setParent_noEvent(nullState, q); }
- if (!oldState) oldState = nullState;
- if (!newState) newState = nullState;
- }
-
- newState->apply(q, transition, oldState);
- applyingState = false;
- if (!transition)
- static_cast<QDeclarative1StatePrivate*>(QObjectPrivate::get(newState))->complete();
-}
-
-QDeclarative1State *QDeclarative1StateGroup::findState(const QString &name) const
-{
- Q_D(const QDeclarative1StateGroup);
- for (int i = 0; i < d->states.count(); ++i) {
- QDeclarative1State *state = d->states.at(i);
- if (state->name() == name)
- return state;
- }
-
- return 0;
-}
-
-void QDeclarative1StateGroup::removeState(QDeclarative1State *state)
-{
- Q_D(QDeclarative1StateGroup);
- d->states.removeOne(state);
-}
-
-
-
-QT_END_NAMESPACE
-
-
diff --git a/src/qtquick1/util/qdeclarativestategroup_p.h b/src/qtquick1/util/qdeclarativestategroup_p.h
deleted file mode 100644
index fe0f933c9c..0000000000
--- a/src/qtquick1/util/qdeclarativestategroup_p.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTATEGROUP_H
-#define QDECLARATIVESTATEGROUP_H
-
-#include "QtQuick1/private/qdeclarativestate_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarative1StateGroupPrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1StateGroup : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_DECLARE_PRIVATE(QDeclarative1StateGroup)
-
- Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarative1State> states READ statesProperty DESIGNABLE false)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarative1Transition> transitions READ transitionsProperty DESIGNABLE false)
-
-public:
- QDeclarative1StateGroup(QObject * = 0);
- virtual ~QDeclarative1StateGroup();
-
- QString state() const;
- void setState(const QString &);
-
- QDeclarativeListProperty<QDeclarative1State> statesProperty();
- QList<QDeclarative1State *> states() const;
-
- QDeclarativeListProperty<QDeclarative1Transition> transitionsProperty();
-
- QDeclarative1State *findState(const QString &name) const;
-
- virtual void classBegin();
- virtual void componentComplete();
-Q_SIGNALS:
- void stateChanged(const QString &);
-
-private:
- friend class QDeclarative1State;
- bool updateAutoState();
- void removeState(QDeclarative1State *state);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1StateGroup)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESTATEGROUP_H
diff --git a/src/qtquick1/util/qdeclarativestateoperations.cpp b/src/qtquick1/util/qdeclarativestateoperations.cpp
deleted file mode 100644
index c11b199045..0000000000
--- a/src/qtquick1/util/qdeclarativestateoperations.cpp
+++ /dev/null
@@ -1,1594 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativestateoperations_p.h"
-#include "QtQuick1/private/qdeclarativeanchors_p_p.h"
-#include "QtQuick1/private/qdeclarativeitem_p.h"
-#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h"
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include <QtDeclarative/private/qdeclarativeguard_p.h>
-#include <QtDeclarative/private/qdeclarativecontext_p.h>
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-#include <QtDeclarative/private/qdeclarativebinding_p.h>
-#include <QtQuick1/private/qdeclarativestate_p_p.h>
-
-#include <QtCore/qdebug.h>
-#include <QtWidgets/qgraphicsitem.h>
-#include <QtCore/qmath.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarative1ParentChangePrivate : public QDeclarative1StateOperationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1ParentChange)
-public:
- QDeclarative1ParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0),
- rewindParent(0), rewindStackBefore(0) {}
-
- QDeclarativeItem *target;
- QDeclarativeGuard<QDeclarativeItem> parent;
- QDeclarativeGuard<QDeclarativeItem> origParent;
- QDeclarativeGuard<QDeclarativeItem> origStackBefore;
- QDeclarativeItem *rewindParent;
- QDeclarativeItem *rewindStackBefore;
-
- QDeclarativeNullableValue<QDeclarativeScriptString> xString;
- QDeclarativeNullableValue<QDeclarativeScriptString> yString;
- QDeclarativeNullableValue<QDeclarativeScriptString> widthString;
- QDeclarativeNullableValue<QDeclarativeScriptString> heightString;
- QDeclarativeNullableValue<QDeclarativeScriptString> scaleString;
- QDeclarativeNullableValue<QDeclarativeScriptString> rotationString;
-
- QDeclarativeNullableValue<qreal> x;
- QDeclarativeNullableValue<qreal> y;
- QDeclarativeNullableValue<qreal> width;
- QDeclarativeNullableValue<qreal> height;
- QDeclarativeNullableValue<qreal> scale;
- QDeclarativeNullableValue<qreal> rotation;
-
- void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0);
-};
-
-void QDeclarative1ParentChangePrivate::doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore)
-{
- if (targetParent && target && target->parentItem()) {
- Q_Q(QDeclarative1ParentChange);
- bool ok;
- const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok);
- if (transform.type() >= QTransform::TxShear || !ok) {
- qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under complex transform");
- ok = false;
- }
-
- qreal scale = 1;
- qreal rotation = 0;
- bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0);
- if (ok && !isRotate) {
- if (transform.m11() == transform.m22())
- scale = transform.m11();
- else {
- qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under non-uniform scale");
- ok = false;
- }
- } else if (ok && isRotate) {
- if (transform.m11() == transform.m22())
- scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
- else {
- qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under non-uniform scale");
- ok = false;
- }
-
- if (scale != 0)
- rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
- else {
- qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under scale of 0");
- ok = false;
- }
- }
-
- const QPointF &point = transform.map(QPointF(target->x(),target->y()));
- qreal x = point.x();
- qreal y = point.y();
-
- // setParentItem will update the transformOriginPoint if needed
- target->setParentItem(targetParent);
-
- if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) {
- qreal tempxt = target->transformOriginPoint().x();
- qreal tempyt = target->transformOriginPoint().y();
- QTransform t;
- t.translate(-tempxt, -tempyt);
- t.rotate(rotation);
- t.scale(scale, scale);
- t.translate(tempxt, tempyt);
- const QPointF &offset = t.map(QPointF(0,0));
- x += offset.x();
- y += offset.y();
- }
-
- if (ok) {
- //qDebug() << x << y << rotation << scale;
- target->setX(x);
- target->setY(y);
- target->setRotation(target->rotation() + rotation);
- target->setScale(target->scale() * scale);
- }
- } else if (target) {
- target->setParentItem(targetParent);
- }
-
- //restore the original stack position.
- //### if stackBefore has also been reparented this won't work
- if (stackBefore)
- target->stackBefore(stackBefore);
-}
-
-/*!
- \preliminary
- \qmlclass ParentChange QDeclarative1ParentChange
- \inqmlmodule QtQuick 1
- \ingroup qml-state-elements
- \brief The ParentChange element allows you to reparent an Item in a state change.
-
- ParentChange reparents an item while preserving its visual appearance (position, size,
- rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale
- the item to its final intended appearance.
-
- ParentChange can only preserve visual appearance if no complex transforms are involved.
- More specifically, it will not work if the transform property has been set for any
- items involved in the reparenting (i.e. items in the common ancestor tree
- for the original and new parent).
-
- The example below displays a large red rectangle and a small blue rectangle, side by side.
- When the \c blueRect is clicked, it changes to the "reparented" state: its parent is changed to \c redRect and it is
- positioned at (10, 10) within the red rectangle, as specified in the ParentChange.
-
- \snippet doc/src/snippets/qtquick1/parentchange.qml 0
-
- \image parentchange.png
-
- You can specify at which point in a transition you want a ParentChange to occur by
- using a ParentAnimation.
-*/
-
-
-QDeclarative1ParentChange::QDeclarative1ParentChange(QObject *parent)
- : QDeclarative1StateOperation(*(new QDeclarative1ParentChangePrivate), parent)
-{
-}
-
-QDeclarative1ParentChange::~QDeclarative1ParentChange()
-{
-}
-
-/*!
- \qmlproperty real QtQuick1::ParentChange::x
- \qmlproperty real QtQuick1::ParentChange::y
- \qmlproperty real QtQuick1::ParentChange::width
- \qmlproperty real QtQuick1::ParentChange::height
- \qmlproperty real QtQuick1::ParentChange::scale
- \qmlproperty real QtQuick1::ParentChange::rotation
- These properties hold the new position, size, scale, and rotation
- for the item in this state.
-*/
-QDeclarativeScriptString QDeclarative1ParentChange::x() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->xString.value;
-}
-
-void tryReal(QDeclarativeNullableValue<qreal> &value, const QString &string)
-{
- bool ok = false;
- qreal realValue = string.toFloat(&ok);
- if (ok)
- value = realValue;
- else
- value.invalidate();
-}
-
-void QDeclarative1ParentChange::setX(QDeclarativeScriptString x)
-{
- Q_D(QDeclarative1ParentChange);
- d->xString = x;
- tryReal(d->x, x.script());
-}
-
-bool QDeclarative1ParentChange::xIsSet() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->xString.isValid();
-}
-
-QDeclarativeScriptString QDeclarative1ParentChange::y() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->yString.value;
-}
-
-void QDeclarative1ParentChange::setY(QDeclarativeScriptString y)
-{
- Q_D(QDeclarative1ParentChange);
- d->yString = y;
- tryReal(d->y, y.script());
-}
-
-bool QDeclarative1ParentChange::yIsSet() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->yString.isValid();
-}
-
-QDeclarativeScriptString QDeclarative1ParentChange::width() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->widthString.value;
-}
-
-void QDeclarative1ParentChange::setWidth(QDeclarativeScriptString width)
-{
- Q_D(QDeclarative1ParentChange);
- d->widthString = width;
- tryReal(d->width, width.script());
-}
-
-bool QDeclarative1ParentChange::widthIsSet() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->widthString.isValid();
-}
-
-QDeclarativeScriptString QDeclarative1ParentChange::height() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->heightString.value;
-}
-
-void QDeclarative1ParentChange::setHeight(QDeclarativeScriptString height)
-{
- Q_D(QDeclarative1ParentChange);
- d->heightString = height;
- tryReal(d->height, height.script());
-}
-
-bool QDeclarative1ParentChange::heightIsSet() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->heightString.isValid();
-}
-
-QDeclarativeScriptString QDeclarative1ParentChange::scale() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->scaleString.value;
-}
-
-void QDeclarative1ParentChange::setScale(QDeclarativeScriptString scale)
-{
- Q_D(QDeclarative1ParentChange);
- d->scaleString = scale;
- tryReal(d->scale, scale.script());
-}
-
-bool QDeclarative1ParentChange::scaleIsSet() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->scaleString.isValid();
-}
-
-QDeclarativeScriptString QDeclarative1ParentChange::rotation() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->rotationString.value;
-}
-
-void QDeclarative1ParentChange::setRotation(QDeclarativeScriptString rotation)
-{
- Q_D(QDeclarative1ParentChange);
- d->rotationString = rotation;
- tryReal(d->rotation, rotation.script());
-}
-
-bool QDeclarative1ParentChange::rotationIsSet() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->rotationString.isValid();
-}
-
-QDeclarativeItem *QDeclarative1ParentChange::originalParent() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->origParent;
-}
-
-/*!
- \qmlproperty Item QtQuick1::ParentChange::target
- This property holds the item to be reparented
-*/
-
-QDeclarativeItem *QDeclarative1ParentChange::object() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->target;
-}
-
-void QDeclarative1ParentChange::setObject(QDeclarativeItem *target)
-{
- Q_D(QDeclarative1ParentChange);
- d->target = target;
-}
-
-/*!
- \qmlproperty Item QtQuick1::ParentChange::parent
- This property holds the new parent for the item in this state.
-*/
-
-QDeclarativeItem *QDeclarative1ParentChange::parent() const
-{
- Q_D(const QDeclarative1ParentChange);
- return d->parent;
-}
-
-void QDeclarative1ParentChange::setParent(QDeclarativeItem *parent)
-{
- Q_D(QDeclarative1ParentChange);
- d->parent = parent;
-}
-
-QDeclarative1StateOperation::ActionList QDeclarative1ParentChange::actions()
-{
- Q_D(QDeclarative1ParentChange);
- if (!d->target || !d->parent)
- return ActionList();
-
- ActionList actions;
-
- QDeclarative1Action a;
- a.event = this;
- actions << a;
-
- QDeclarativeContext *ctxt = qmlContext(this);
-
- if (d->xString.isValid()) {
- if (d->x.isValid()) {
- QDeclarative1Action xa(d->target, QLatin1String("x"), ctxt, d->x.value);
- actions << xa;
- } else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->xString.value.script(), d->target, ctxt);
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("x"), ctxt));
- QDeclarative1Action xa;
- xa.property = newBinding->property();
- xa.toBinding = newBinding;
- xa.fromValue = xa.property.read();
- xa.deletableToBinding = true;
- actions << xa;
- }
- }
-
- if (d->yString.isValid()) {
- if (d->y.isValid()) {
- QDeclarative1Action ya(d->target, QLatin1String("y"), ctxt, d->y.value);
- actions << ya;
- } else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->yString.value.script(), d->target, ctxt);
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("y"), ctxt));
- QDeclarative1Action ya;
- ya.property = newBinding->property();
- ya.toBinding = newBinding;
- ya.fromValue = ya.property.read();
- ya.deletableToBinding = true;
- actions << ya;
- }
- }
-
- if (d->scaleString.isValid()) {
- if (d->scale.isValid()) {
- QDeclarative1Action sa(d->target, QLatin1String("scale"), ctxt, d->scale.value);
- actions << sa;
- } else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->scaleString.value.script(), d->target, ctxt);
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("scale"), ctxt));
- QDeclarative1Action sa;
- sa.property = newBinding->property();
- sa.toBinding = newBinding;
- sa.fromValue = sa.property.read();
- sa.deletableToBinding = true;
- actions << sa;
- }
- }
-
- if (d->rotationString.isValid()) {
- if (d->rotation.isValid()) {
- QDeclarative1Action ra(d->target, QLatin1String("rotation"), ctxt, d->rotation.value);
- actions << ra;
- } else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->rotationString.value.script(), d->target, ctxt);
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("rotation"), ctxt));
- QDeclarative1Action ra;
- ra.property = newBinding->property();
- ra.toBinding = newBinding;
- ra.fromValue = ra.property.read();
- ra.deletableToBinding = true;
- actions << ra;
- }
- }
-
- if (d->widthString.isValid()) {
- if (d->width.isValid()) {
- QDeclarative1Action wa(d->target, QLatin1String("width"), ctxt, d->width.value);
- actions << wa;
- } else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->widthString.value.script(), d->target, ctxt);
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("width"), ctxt));
- QDeclarative1Action wa;
- wa.property = newBinding->property();
- wa.toBinding = newBinding;
- wa.fromValue = wa.property.read();
- wa.deletableToBinding = true;
- actions << wa;
- }
- }
-
- if (d->heightString.isValid()) {
- if (d->height.isValid()) {
- QDeclarative1Action ha(d->target, QLatin1String("height"), ctxt, d->height.value);
- actions << ha;
- } else {
- QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->heightString.value.script(), d->target, ctxt);
- newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("height"), ctxt));
- QDeclarative1Action ha;
- ha.property = newBinding->property();
- ha.toBinding = newBinding;
- ha.fromValue = ha.property.read();
- ha.deletableToBinding = true;
- actions << ha;
- }
- }
-
- return actions;
-}
-
-class AccessibleFxItem : public QDeclarativeItem
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem)
-public:
- int siblingIndex() {
- Q_D(QDeclarativeItem);
- return d->siblingIndex;
- }
-};
-
-void QDeclarative1ParentChange::saveOriginals()
-{
- Q_D(QDeclarative1ParentChange);
- saveCurrentValues();
- d->origParent = d->rewindParent;
- d->origStackBefore = d->rewindStackBefore;
-}
-
-/*void QDeclarative1ParentChange::copyOriginals(QDeclarative1ActionEvent *other)
-{
- Q_D(QDeclarative1ParentChange);
- QDeclarative1ParentChange *pc = static_cast<QDeclarative1ParentChange*>(other);
-
- d->origParent = pc->d_func()->rewindParent;
- d->origStackBefore = pc->d_func()->rewindStackBefore;
-
- saveCurrentValues();
-}*/
-
-void QDeclarative1ParentChange::execute(Reason)
-{
- Q_D(QDeclarative1ParentChange);
- d->doChange(d->parent);
-}
-
-bool QDeclarative1ParentChange::isReversable()
-{
- return true;
-}
-
-void QDeclarative1ParentChange::reverse(Reason)
-{
- Q_D(QDeclarative1ParentChange);
- d->doChange(d->origParent, d->origStackBefore);
-}
-
-QString QDeclarative1ParentChange::typeName() const
-{
- return QLatin1String("ParentChange");
-}
-
-bool QDeclarative1ParentChange::override(QDeclarative1ActionEvent*other)
-{
- Q_D(QDeclarative1ParentChange);
- if (other->typeName() != QLatin1String("ParentChange"))
- return false;
- if (QDeclarative1ParentChange *otherPC = static_cast<QDeclarative1ParentChange*>(other))
- return (d->target == otherPC->object());
- return false;
-}
-
-void QDeclarative1ParentChange::saveCurrentValues()
-{
- Q_D(QDeclarative1ParentChange);
- if (!d->target) {
- d->rewindParent = 0;
- d->rewindStackBefore = 0;
- return;
- }
-
- d->rewindParent = d->target->parentItem();
- d->rewindStackBefore = 0;
-
- if (!d->rewindParent)
- return;
-
- //try to determine the item's original stack position so we can restore it
- int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1;
- QList<QGraphicsItem*> children = d->rewindParent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QDeclarativeItem *child = qobject_cast<QDeclarativeItem*>(children.at(i));
- if (!child)
- continue;
- if (((AccessibleFxItem*)child)->siblingIndex() == siblingIndex) {
- d->rewindStackBefore = child;
- break;
- }
- }
-}
-
-void QDeclarative1ParentChange::rewind()
-{
- Q_D(QDeclarative1ParentChange);
- d->doChange(d->rewindParent, d->rewindStackBefore);
-}
-
-class QDeclarative1StateChangeScriptPrivate : public QDeclarative1StateOperationPrivate
-{
-public:
- QDeclarative1StateChangeScriptPrivate() {}
-
- QDeclarativeScriptString script;
- QString name;
-};
-
-/*!
- \qmlclass StateChangeScript QDeclarative1StateChangeScript
- \inqmlmodule QtQuick 1
- \ingroup qml-state-elements
- \brief The StateChangeScript element allows you to run a script in a state.
-
- A StateChangeScript is run upon entering a state. You can optionally use
- ScriptAction to specify the point in the transition at which
- the StateChangeScript should to be run.
-
- \snippet snippets/declarative/states/statechangescript.qml state and transition
-
- \sa ScriptAction
-*/
-
-QDeclarative1StateChangeScript::QDeclarative1StateChangeScript(QObject *parent)
-: QDeclarative1StateOperation(*(new QDeclarative1StateChangeScriptPrivate), parent)
-{
-}
-
-QDeclarative1StateChangeScript::~QDeclarative1StateChangeScript()
-{
-}
-
-/*!
- \qmlproperty script QtQuick1::StateChangeScript::script
- This property holds the script to run when the state is current.
-*/
-QDeclarativeScriptString QDeclarative1StateChangeScript::script() const
-{
- Q_D(const QDeclarative1StateChangeScript);
- return d->script;
-}
-
-void QDeclarative1StateChangeScript::setScript(const QDeclarativeScriptString &s)
-{
- Q_D(QDeclarative1StateChangeScript);
- d->script = s;
-}
-
-/*!
- \qmlproperty string QtQuick1::StateChangeScript::name
- This property holds the name of the script. This name can be used by a
- ScriptAction to target a specific script.
-
- \sa ScriptAction::scriptName
-*/
-QString QDeclarative1StateChangeScript::name() const
-{
- Q_D(const QDeclarative1StateChangeScript);
- return d->name;
-}
-
-void QDeclarative1StateChangeScript::setName(const QString &n)
-{
- Q_D(QDeclarative1StateChangeScript);
- d->name = n;
-}
-
-void QDeclarative1StateChangeScript::execute(Reason)
-{
- Q_D(QDeclarative1StateChangeScript);
- const QString &script = d->script.script();
- if (!script.isEmpty()) {
- QDeclarativeExpression expr(d->script.context(), d->script.scopeObject(), script);
- QDeclarativeData *ddata = QDeclarativeData::get(this);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber);
- expr.evaluate();
- if (expr.hasError())
- qmlInfo(this, expr.error());
- }
-}
-
-QDeclarative1StateChangeScript::ActionList QDeclarative1StateChangeScript::actions()
-{
- ActionList rv;
- QDeclarative1Action a;
- a.event = this;
- rv << a;
- return rv;
-}
-
-QString QDeclarative1StateChangeScript::typeName() const
-{
- return QLatin1String("StateChangeScript");
-}
-
-/*!
- \qmlclass AnchorChanges QDeclarative1AnchorChanges
- \inqmlmodule QtQuick 1
- \ingroup qml-state-elements
- \brief The AnchorChanges element allows you to change the anchors of an item in a state.
-
- The AnchorChanges element is used to modify the anchors of an item in a \l State.
-
- AnchorChanges cannot be used to modify the margins on an item. For this, use
- PropertyChanges intead.
-
- In the following example we change the top and bottom anchors of an item
- using AnchorChanges, and the top and bottom anchor margins using
- PropertyChanges:
-
- \snippet doc/src/snippets/qtquick1/anchorchanges.qml 0
-
- \image anchorchanges.png
-
- AnchorChanges can be animated using AnchorAnimation.
- \qml
- //animate our anchor changes
- Transition {
- AnchorAnimation {}
- }
- \endqml
-
- Margin animations can be animated using NumberAnimation.
-
- For more information on anchors see \l {anchor-layout}{Anchor Layouts}.
-*/
-
-class QDeclarative1AnchorSetPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1AnchorSet)
-public:
- QDeclarative1AnchorSetPrivate()
- : usedAnchors(0), resetAnchors(0), fill(0),
- centerIn(0)/*, leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
- margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)*/
- {
- }
-
- QDeclarative1Anchors::Anchors usedAnchors;
- QDeclarative1Anchors::Anchors resetAnchors;
-
- QDeclarativeItem *fill;
- QDeclarativeItem *centerIn;
-
- QDeclarativeScriptString leftScript;
- QDeclarativeScriptString rightScript;
- QDeclarativeScriptString topScript;
- QDeclarativeScriptString bottomScript;
- QDeclarativeScriptString hCenterScript;
- QDeclarativeScriptString vCenterScript;
- QDeclarativeScriptString baselineScript;
-
- /*qreal leftMargin;
- qreal rightMargin;
- qreal topMargin;
- qreal bottomMargin;
- qreal margins;
- qreal vCenterOffset;
- qreal hCenterOffset;
- qreal baselineOffset;*/
-};
-
-QDeclarative1AnchorSet::QDeclarative1AnchorSet(QObject *parent)
- : QObject(*new QDeclarative1AnchorSetPrivate, parent)
-{
-}
-
-QDeclarative1AnchorSet::~QDeclarative1AnchorSet()
-{
-}
-
-QDeclarativeScriptString QDeclarative1AnchorSet::top() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->topScript;
-}
-
-void QDeclarative1AnchorSet::setTop(const QDeclarativeScriptString &edge)
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors |= QDeclarative1Anchors::TopAnchor;
- d->topScript = edge;
- if (edge.script() == QLatin1String("undefined"))
- resetTop();
-}
-
-void QDeclarative1AnchorSet::resetTop()
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors &= ~QDeclarative1Anchors::TopAnchor;
- d->topScript = QDeclarativeScriptString();
- d->resetAnchors |= QDeclarative1Anchors::TopAnchor;
-}
-
-QDeclarativeScriptString QDeclarative1AnchorSet::bottom() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->bottomScript;
-}
-
-void QDeclarative1AnchorSet::setBottom(const QDeclarativeScriptString &edge)
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors |= QDeclarative1Anchors::BottomAnchor;
- d->bottomScript = edge;
- if (edge.script() == QLatin1String("undefined"))
- resetBottom();
-}
-
-void QDeclarative1AnchorSet::resetBottom()
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors &= ~QDeclarative1Anchors::BottomAnchor;
- d->bottomScript = QDeclarativeScriptString();
- d->resetAnchors |= QDeclarative1Anchors::BottomAnchor;
-}
-
-QDeclarativeScriptString QDeclarative1AnchorSet::verticalCenter() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->vCenterScript;
-}
-
-void QDeclarative1AnchorSet::setVerticalCenter(const QDeclarativeScriptString &edge)
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors |= QDeclarative1Anchors::VCenterAnchor;
- d->vCenterScript = edge;
- if (edge.script() == QLatin1String("undefined"))
- resetVerticalCenter();
-}
-
-void QDeclarative1AnchorSet::resetVerticalCenter()
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors &= ~QDeclarative1Anchors::VCenterAnchor;
- d->vCenterScript = QDeclarativeScriptString();
- d->resetAnchors |= QDeclarative1Anchors::VCenterAnchor;
-}
-
-QDeclarativeScriptString QDeclarative1AnchorSet::baseline() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->baselineScript;
-}
-
-void QDeclarative1AnchorSet::setBaseline(const QDeclarativeScriptString &edge)
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors |= QDeclarative1Anchors::BaselineAnchor;
- d->baselineScript = edge;
- if (edge.script() == QLatin1String("undefined"))
- resetBaseline();
-}
-
-void QDeclarative1AnchorSet::resetBaseline()
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors &= ~QDeclarative1Anchors::BaselineAnchor;
- d->baselineScript = QDeclarativeScriptString();
- d->resetAnchors |= QDeclarative1Anchors::BaselineAnchor;
-}
-
-QDeclarativeScriptString QDeclarative1AnchorSet::left() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->leftScript;
-}
-
-void QDeclarative1AnchorSet::setLeft(const QDeclarativeScriptString &edge)
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors |= QDeclarative1Anchors::LeftAnchor;
- d->leftScript = edge;
- if (edge.script() == QLatin1String("undefined"))
- resetLeft();
-}
-
-void QDeclarative1AnchorSet::resetLeft()
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors &= ~QDeclarative1Anchors::LeftAnchor;
- d->leftScript = QDeclarativeScriptString();
- d->resetAnchors |= QDeclarative1Anchors::LeftAnchor;
-}
-
-QDeclarativeScriptString QDeclarative1AnchorSet::right() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->rightScript;
-}
-
-void QDeclarative1AnchorSet::setRight(const QDeclarativeScriptString &edge)
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors |= QDeclarative1Anchors::RightAnchor;
- d->rightScript = edge;
- if (edge.script() == QLatin1String("undefined"))
- resetRight();
-}
-
-void QDeclarative1AnchorSet::resetRight()
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors &= ~QDeclarative1Anchors::RightAnchor;
- d->rightScript = QDeclarativeScriptString();
- d->resetAnchors |= QDeclarative1Anchors::RightAnchor;
-}
-
-QDeclarativeScriptString QDeclarative1AnchorSet::horizontalCenter() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->hCenterScript;
-}
-
-void QDeclarative1AnchorSet::setHorizontalCenter(const QDeclarativeScriptString &edge)
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors |= QDeclarative1Anchors::HCenterAnchor;
- d->hCenterScript = edge;
- if (edge.script() == QLatin1String("undefined"))
- resetHorizontalCenter();
-}
-
-void QDeclarative1AnchorSet::resetHorizontalCenter()
-{
- Q_D(QDeclarative1AnchorSet);
- d->usedAnchors &= ~QDeclarative1Anchors::HCenterAnchor;
- d->hCenterScript = QDeclarativeScriptString();
- d->resetAnchors |= QDeclarative1Anchors::HCenterAnchor;
-}
-
-QDeclarativeItem *QDeclarative1AnchorSet::fill() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->fill;
-}
-
-void QDeclarative1AnchorSet::setFill(QDeclarativeItem *f)
-{
- Q_D(QDeclarative1AnchorSet);
- d->fill = f;
-}
-
-void QDeclarative1AnchorSet::resetFill()
-{
- setFill(0);
-}
-
-QDeclarativeItem *QDeclarative1AnchorSet::centerIn() const
-{
- Q_D(const QDeclarative1AnchorSet);
- return d->centerIn;
-}
-
-void QDeclarative1AnchorSet::setCenterIn(QDeclarativeItem* c)
-{
- Q_D(QDeclarative1AnchorSet);
- d->centerIn = c;
-}
-
-void QDeclarative1AnchorSet::resetCenterIn()
-{
- setCenterIn(0);
-}
-
-
-class QDeclarative1AnchorChangesPrivate : public QDeclarative1StateOperationPrivate
-{
-public:
- QDeclarative1AnchorChangesPrivate()
- : target(0), anchorSet(new QDeclarative1AnchorSet),
- leftBinding(0), rightBinding(0), hCenterBinding(0),
- topBinding(0), bottomBinding(0), vCenterBinding(0), baselineBinding(0),
- origLeftBinding(0), origRightBinding(0), origHCenterBinding(0),
- origTopBinding(0), origBottomBinding(0), origVCenterBinding(0),
- origBaselineBinding(0)
- {
-
- }
- ~QDeclarative1AnchorChangesPrivate() { delete anchorSet; }
-
- QDeclarativeItem *target;
- QDeclarative1AnchorSet *anchorSet;
-
- QDeclarativeBinding *leftBinding;
- QDeclarativeBinding *rightBinding;
- QDeclarativeBinding *hCenterBinding;
- QDeclarativeBinding *topBinding;
- QDeclarativeBinding *bottomBinding;
- QDeclarativeBinding *vCenterBinding;
- QDeclarativeBinding *baselineBinding;
-
- QDeclarativeAbstractBinding *origLeftBinding;
- QDeclarativeAbstractBinding *origRightBinding;
- QDeclarativeAbstractBinding *origHCenterBinding;
- QDeclarativeAbstractBinding *origTopBinding;
- QDeclarativeAbstractBinding *origBottomBinding;
- QDeclarativeAbstractBinding *origVCenterBinding;
- QDeclarativeAbstractBinding *origBaselineBinding;
-
- QDeclarative1AnchorLine rewindLeft;
- QDeclarative1AnchorLine rewindRight;
- QDeclarative1AnchorLine rewindHCenter;
- QDeclarative1AnchorLine rewindTop;
- QDeclarative1AnchorLine rewindBottom;
- QDeclarative1AnchorLine rewindVCenter;
- QDeclarative1AnchorLine rewindBaseline;
-
- qreal fromX;
- qreal fromY;
- qreal fromWidth;
- qreal fromHeight;
-
- qreal toX;
- qreal toY;
- qreal toWidth;
- qreal toHeight;
-
- qreal rewindX;
- qreal rewindY;
- qreal rewindWidth;
- qreal rewindHeight;
-
- bool applyOrigLeft;
- bool applyOrigRight;
- bool applyOrigHCenter;
- bool applyOrigTop;
- bool applyOrigBottom;
- bool applyOrigVCenter;
- bool applyOrigBaseline;
-
- QDeclarativeNullableValue<qreal> origWidth;
- QDeclarativeNullableValue<qreal> origHeight;
- qreal origX;
- qreal origY;
-
- QList<QDeclarativeAbstractBinding*> oldBindings;
-
- QDeclarativeProperty leftProp;
- QDeclarativeProperty rightProp;
- QDeclarativeProperty hCenterProp;
- QDeclarativeProperty topProp;
- QDeclarativeProperty bottomProp;
- QDeclarativeProperty vCenterProp;
- QDeclarativeProperty baselineProp;
-};
-
-/*!
- \qmlproperty Item QtQuick1::AnchorChanges::target
- This property holds the \l Item for which the anchor changes will be applied.
-*/
-
-QDeclarative1AnchorChanges::QDeclarative1AnchorChanges(QObject *parent)
- : QDeclarative1StateOperation(*(new QDeclarative1AnchorChangesPrivate), parent)
-{
-}
-
-QDeclarative1AnchorChanges::~QDeclarative1AnchorChanges()
-{
-}
-
-QDeclarative1AnchorChanges::ActionList QDeclarative1AnchorChanges::actions()
-{
- Q_D(QDeclarative1AnchorChanges);
- d->leftBinding = d->rightBinding = d->hCenterBinding = d->topBinding
- = d->bottomBinding = d->vCenterBinding = d->baselineBinding = 0;
-
- d->leftProp = QDeclarativeProperty(d->target, QLatin1String("anchors.left"));
- d->rightProp = QDeclarativeProperty(d->target, QLatin1String("anchors.right"));
- d->hCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.horizontalCenter"));
- d->topProp = QDeclarativeProperty(d->target, QLatin1String("anchors.top"));
- d->bottomProp = QDeclarativeProperty(d->target, QLatin1String("anchors.bottom"));
- d->vCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.verticalCenter"));
- d->baselineProp = QDeclarativeProperty(d->target, QLatin1String("anchors.baseline"));
-
- QDeclarativeContext *ctxt = qmlContext(this);
-
- if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::LeftAnchor) {
- d->leftBinding = new QDeclarativeBinding(d->anchorSet->d_func()->leftScript.script(), d->target, ctxt);
- d->leftBinding->setTarget(d->leftProp);
- }
- if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::RightAnchor) {
- d->rightBinding = new QDeclarativeBinding(d->anchorSet->d_func()->rightScript.script(), d->target, ctxt);
- d->rightBinding->setTarget(d->rightProp);
- }
- if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::HCenterAnchor) {
- d->hCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, ctxt);
- d->hCenterBinding->setTarget(d->hCenterProp);
- }
- if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::TopAnchor) {
- d->topBinding = new QDeclarativeBinding(d->anchorSet->d_func()->topScript.script(), d->target, ctxt);
- d->topBinding->setTarget(d->topProp);
- }
- if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::BottomAnchor) {
- d->bottomBinding = new QDeclarativeBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, ctxt);
- d->bottomBinding->setTarget(d->bottomProp);
- }
- if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::VCenterAnchor) {
- d->vCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, ctxt);
- d->vCenterBinding->setTarget(d->vCenterProp);
- }
- if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::BaselineAnchor) {
- d->baselineBinding = new QDeclarativeBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, ctxt);
- d->baselineBinding->setTarget(d->baselineProp);
- }
-
- QDeclarative1Action a;
- a.event = this;
- return ActionList() << a;
-}
-
-QDeclarative1AnchorSet *QDeclarative1AnchorChanges::anchors()
-{
- Q_D(QDeclarative1AnchorChanges);
- return d->anchorSet;
-}
-
-QDeclarativeItem *QDeclarative1AnchorChanges::object() const
-{
- Q_D(const QDeclarative1AnchorChanges);
- return d->target;
-}
-
-void QDeclarative1AnchorChanges::setObject(QDeclarativeItem *target)
-{
- Q_D(QDeclarative1AnchorChanges);
- d->target = target;
-}
-
-/*!
- \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.left
- \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.right
- \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.horizontalCenter
- \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.top
- \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.bottom
- \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.verticalCenter
- \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.baseline
-
- These properties change the respective anchors of the item.
-
- To reset an anchor you can assign \c undefined:
- \qml
- AnchorChanges {
- target: myItem
- anchors.left: undefined //remove myItem's left anchor
- anchors.right: otherItem.right
- }
- \endqml
-*/
-
-void QDeclarative1AnchorChanges::execute(Reason reason)
-{
- Q_D(QDeclarative1AnchorChanges);
- if (!d->target)
- return;
-
- QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
- //incorporate any needed "reverts"
- if (d->applyOrigLeft) {
- if (!d->origLeftBinding)
- targetPrivate->anchors()->resetLeft();
- QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding);
- }
- if (d->applyOrigRight) {
- if (!d->origRightBinding)
- targetPrivate->anchors()->resetRight();
- QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding);
- }
- if (d->applyOrigHCenter) {
- if (!d->origHCenterBinding)
- targetPrivate->anchors()->resetHorizontalCenter();
- QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding);
- }
- if (d->applyOrigTop) {
- if (!d->origTopBinding)
- targetPrivate->anchors()->resetTop();
- QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding);
- }
- if (d->applyOrigBottom) {
- if (!d->origBottomBinding)
- targetPrivate->anchors()->resetBottom();
- QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding);
- }
- if (d->applyOrigVCenter) {
- if (!d->origVCenterBinding)
- targetPrivate->anchors()->resetVerticalCenter();
- QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding);
- }
- if (d->applyOrigBaseline) {
- if (!d->origBaselineBinding)
- targetPrivate->anchors()->resetBaseline();
- QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding);
- }
-
- //destroy old bindings
- if (reason == ActualChange) {
- for (int i = 0; i < d->oldBindings.size(); ++i) {
- QDeclarativeAbstractBinding *binding = d->oldBindings.at(i);
- if (binding)
- binding->destroy();
- }
- d->oldBindings.clear();
- }
-
- //reset any anchors that have been specified as "undefined"
- if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::LeftAnchor) {
- targetPrivate->anchors()->resetLeft();
- QDeclarativePropertyPrivate::setBinding(d->leftProp, 0);
- }
- if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::RightAnchor) {
- targetPrivate->anchors()->resetRight();
- QDeclarativePropertyPrivate::setBinding(d->rightProp, 0);
- }
- if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::HCenterAnchor) {
- targetPrivate->anchors()->resetHorizontalCenter();
- QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0);
- }
- if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::TopAnchor) {
- targetPrivate->anchors()->resetTop();
- QDeclarativePropertyPrivate::setBinding(d->topProp, 0);
- }
- if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::BottomAnchor) {
- targetPrivate->anchors()->resetBottom();
- QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0);
- }
- if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::VCenterAnchor) {
- targetPrivate->anchors()->resetVerticalCenter();
- QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0);
- }
- if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::BaselineAnchor) {
- targetPrivate->anchors()->resetBaseline();
- QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0);
- }
-
- //set any anchors that have been specified
- if (d->leftBinding)
- QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), d->leftBinding);
- if (d->rightBinding)
- QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), d->rightBinding);
- if (d->hCenterBinding)
- QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), d->hCenterBinding);
- if (d->topBinding)
- QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), d->topBinding);
- if (d->bottomBinding)
- QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), d->bottomBinding);
- if (d->vCenterBinding)
- QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), d->vCenterBinding);
- if (d->baselineBinding)
- QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), d->baselineBinding);
-}
-
-bool QDeclarative1AnchorChanges::isReversable()
-{
- return true;
-}
-
-void QDeclarative1AnchorChanges::reverse(Reason reason)
-{
- Q_D(QDeclarative1AnchorChanges);
- if (!d->target)
- return;
-
- QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
- //reset any anchors set by the state
- if (d->leftBinding) {
- targetPrivate->anchors()->resetLeft();
- QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), 0);
- if (reason == ActualChange) {
- d->leftBinding->destroy(); d->leftBinding = 0;
- }
- }
- if (d->rightBinding) {
- targetPrivate->anchors()->resetRight();
- QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), 0);
- if (reason == ActualChange) {
- d->rightBinding->destroy(); d->rightBinding = 0;
- }
- }
- if (d->hCenterBinding) {
- targetPrivate->anchors()->resetHorizontalCenter();
- QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), 0);
- if (reason == ActualChange) {
- d->hCenterBinding->destroy(); d->hCenterBinding = 0;
- }
- }
- if (d->topBinding) {
- targetPrivate->anchors()->resetTop();
- QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), 0);
- if (reason == ActualChange) {
- d->topBinding->destroy(); d->topBinding = 0;
- }
- }
- if (d->bottomBinding) {
- targetPrivate->anchors()->resetBottom();
- QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), 0);
- if (reason == ActualChange) {
- d->bottomBinding->destroy(); d->bottomBinding = 0;
- }
- }
- if (d->vCenterBinding) {
- targetPrivate->anchors()->resetVerticalCenter();
- QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), 0);
- if (reason == ActualChange) {
- d->vCenterBinding->destroy(); d->vCenterBinding = 0;
- }
- }
- if (d->baselineBinding) {
- targetPrivate->anchors()->resetBaseline();
- QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), 0);
- if (reason == ActualChange) {
- d->baselineBinding->destroy(); d->baselineBinding = 0;
- }
- }
-
- //restore previous anchors
- if (d->origLeftBinding)
- QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding);
- if (d->origRightBinding)
- QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding);
- if (d->origHCenterBinding)
- QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding);
- if (d->origTopBinding)
- QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding);
- if (d->origBottomBinding)
- QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding);
- if (d->origVCenterBinding)
- QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding);
- if (d->origBaselineBinding)
- QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding);
-
- //restore any absolute geometry changed by the state's anchors
- QDeclarative1Anchors::Anchors stateVAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::Vertical_Mask;
- QDeclarative1Anchors::Anchors origVAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarative1Anchors::Vertical_Mask;
- QDeclarative1Anchors::Anchors stateHAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::Horizontal_Mask;
- QDeclarative1Anchors::Anchors origHAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarative1Anchors::Horizontal_Mask;
-
- bool stateSetWidth = (stateHAnchors &&
- stateHAnchors != QDeclarative1Anchors::LeftAnchor &&
- stateHAnchors != QDeclarative1Anchors::RightAnchor &&
- stateHAnchors != QDeclarative1Anchors::HCenterAnchor);
- bool origSetWidth = (origHAnchors &&
- origHAnchors != QDeclarative1Anchors::LeftAnchor &&
- origHAnchors != QDeclarative1Anchors::RightAnchor &&
- origHAnchors != QDeclarative1Anchors::HCenterAnchor);
- if (d->origWidth.isValid() && stateSetWidth && !origSetWidth)
- d->target->setWidth(d->origWidth.value);
-
- bool stateSetHeight = (stateVAnchors &&
- stateVAnchors != QDeclarative1Anchors::TopAnchor &&
- stateVAnchors != QDeclarative1Anchors::BottomAnchor &&
- stateVAnchors != QDeclarative1Anchors::VCenterAnchor &&
- stateVAnchors != QDeclarative1Anchors::BaselineAnchor);
- bool origSetHeight = (origVAnchors &&
- origVAnchors != QDeclarative1Anchors::TopAnchor &&
- origVAnchors != QDeclarative1Anchors::BottomAnchor &&
- origVAnchors != QDeclarative1Anchors::VCenterAnchor &&
- origVAnchors != QDeclarative1Anchors::BaselineAnchor);
- if (d->origHeight.isValid() && stateSetHeight && !origSetHeight)
- d->target->setHeight(d->origHeight.value);
-
- if (stateHAnchors && !origHAnchors)
- d->target->setX(d->origX);
-
- if (stateVAnchors && !origVAnchors)
- d->target->setY(d->origY);
-}
-
-QString QDeclarative1AnchorChanges::typeName() const
-{
- return QLatin1String("AnchorChanges");
-}
-
-QList<QDeclarative1Action> QDeclarative1AnchorChanges::additionalActions()
-{
- Q_D(QDeclarative1AnchorChanges);
- QList<QDeclarative1Action> extra;
-
- QDeclarative1Anchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors;
- bool hChange = combined & QDeclarative1Anchors::Horizontal_Mask;
- bool vChange = combined & QDeclarative1Anchors::Vertical_Mask;
-
- if (d->target) {
- QDeclarativeContext *ctxt = qmlContext(this);
- QDeclarative1Action a;
- if (hChange && d->fromX != d->toX) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("x"), ctxt);
- a.toValue = d->toX;
- extra << a;
- }
- if (vChange && d->fromY != d->toY) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("y"), ctxt);
- a.toValue = d->toY;
- extra << a;
- }
- if (hChange && d->fromWidth != d->toWidth) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("width"), ctxt);
- a.toValue = d->toWidth;
- extra << a;
- }
- if (vChange && d->fromHeight != d->toHeight) {
- a.property = QDeclarativeProperty(d->target, QLatin1String("height"), ctxt);
- a.toValue = d->toHeight;
- extra << a;
- }
- }
-
- return extra;
-}
-
-bool QDeclarative1AnchorChanges::changesBindings()
-{
- return true;
-}
-
-void QDeclarative1AnchorChanges::saveOriginals()
-{
- Q_D(QDeclarative1AnchorChanges);
- if (!d->target)
- return;
-
- d->origLeftBinding = QDeclarativePropertyPrivate::binding(d->leftProp);
- d->origRightBinding = QDeclarativePropertyPrivate::binding(d->rightProp);
- d->origHCenterBinding = QDeclarativePropertyPrivate::binding(d->hCenterProp);
- d->origTopBinding = QDeclarativePropertyPrivate::binding(d->topProp);
- d->origBottomBinding = QDeclarativePropertyPrivate::binding(d->bottomProp);
- d->origVCenterBinding = QDeclarativePropertyPrivate::binding(d->vCenterProp);
- d->origBaselineBinding = QDeclarativePropertyPrivate::binding(d->baselineProp);
-
- QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
- if (targetPrivate->widthValid)
- d->origWidth = d->target->width();
- if (targetPrivate->heightValid)
- d->origHeight = d->target->height();
- d->origX = d->target->x();
- d->origY = d->target->y();
-
- d->applyOrigLeft = d->applyOrigRight = d->applyOrigHCenter = d->applyOrigTop
- = d->applyOrigBottom = d->applyOrigVCenter = d->applyOrigBaseline = false;
-
- saveCurrentValues();
-}
-
-void QDeclarative1AnchorChanges::copyOriginals(QDeclarative1ActionEvent *other)
-{
- Q_D(QDeclarative1AnchorChanges);
- QDeclarative1AnchorChanges *ac = static_cast<QDeclarative1AnchorChanges*>(other);
- QDeclarative1AnchorChangesPrivate *acp = ac->d_func();
-
- QDeclarative1Anchors::Anchors combined = acp->anchorSet->d_func()->usedAnchors |
- acp->anchorSet->d_func()->resetAnchors;
-
- //probably also need to revert some things
- d->applyOrigLeft = (combined & QDeclarative1Anchors::LeftAnchor);
- d->applyOrigRight = (combined & QDeclarative1Anchors::RightAnchor);
- d->applyOrigHCenter = (combined & QDeclarative1Anchors::HCenterAnchor);
- d->applyOrigTop = (combined & QDeclarative1Anchors::TopAnchor);
- d->applyOrigBottom = (combined & QDeclarative1Anchors::BottomAnchor);
- d->applyOrigVCenter = (combined & QDeclarative1Anchors::VCenterAnchor);
- d->applyOrigBaseline = (combined & QDeclarative1Anchors::BaselineAnchor);
-
- d->origLeftBinding = acp->origLeftBinding;
- d->origRightBinding = acp->origRightBinding;
- d->origHCenterBinding = acp->origHCenterBinding;
- d->origTopBinding = acp->origTopBinding;
- d->origBottomBinding = acp->origBottomBinding;
- d->origVCenterBinding = acp->origVCenterBinding;
- d->origBaselineBinding = acp->origBaselineBinding;
-
- d->origWidth = acp->origWidth;
- d->origHeight = acp->origHeight;
- d->origX = acp->origX;
- d->origY = acp->origY;
-
- d->oldBindings.clear();
- d->oldBindings << acp->leftBinding << acp->rightBinding << acp->hCenterBinding
- << acp->topBinding << acp->bottomBinding << acp->baselineBinding;
-
- saveCurrentValues();
-}
-
-void QDeclarative1AnchorChanges::clearBindings()
-{
- Q_D(QDeclarative1AnchorChanges);
- if (!d->target)
- return;
-
- //### should this (saving "from" values) be moved to saveCurrentValues()?
- d->fromX = d->target->x();
- d->fromY = d->target->y();
- d->fromWidth = d->target->width();
- d->fromHeight = d->target->height();
-
- QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
- //reset any anchors with corresponding reverts
- //reset any anchors that have been specified as "undefined"
- //reset any anchors that we'll be setting in the state
- QDeclarative1Anchors::Anchors combined = d->anchorSet->d_func()->resetAnchors |
- d->anchorSet->d_func()->usedAnchors;
- if (d->applyOrigLeft || (combined & QDeclarative1Anchors::LeftAnchor)) {
- targetPrivate->anchors()->resetLeft();
- QDeclarativePropertyPrivate::setBinding(d->leftProp, 0);
- }
- if (d->applyOrigRight || (combined & QDeclarative1Anchors::RightAnchor)) {
- targetPrivate->anchors()->resetRight();
- QDeclarativePropertyPrivate::setBinding(d->rightProp, 0);
- }
- if (d->applyOrigHCenter || (combined & QDeclarative1Anchors::HCenterAnchor)) {
- targetPrivate->anchors()->resetHorizontalCenter();
- QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0);
- }
- if (d->applyOrigTop || (combined & QDeclarative1Anchors::TopAnchor)) {
- targetPrivate->anchors()->resetTop();
- QDeclarativePropertyPrivate::setBinding(d->topProp, 0);
- }
- if (d->applyOrigBottom || (combined & QDeclarative1Anchors::BottomAnchor)) {
- targetPrivate->anchors()->resetBottom();
- QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0);
- }
- if (d->applyOrigVCenter || (combined & QDeclarative1Anchors::VCenterAnchor)) {
- targetPrivate->anchors()->resetVerticalCenter();
- QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0);
- }
- if (d->applyOrigBaseline || (combined & QDeclarative1Anchors::BaselineAnchor)) {
- targetPrivate->anchors()->resetBaseline();
- QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0);
- }
-}
-
-bool QDeclarative1AnchorChanges::override(QDeclarative1ActionEvent*other)
-{
- if (other->typeName() != QLatin1String("AnchorChanges"))
- return false;
- if (static_cast<QDeclarative1ActionEvent*>(this) == other)
- return true;
- if (static_cast<QDeclarative1AnchorChanges*>(other)->object() == object())
- return true;
- return false;
-}
-
-void QDeclarative1AnchorChanges::rewind()
-{
- Q_D(QDeclarative1AnchorChanges);
- if (!d->target)
- return;
-
- QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
-
- //restore previous values (but not previous bindings, i.e. anchors)
- d->target->setX(d->rewindX);
- d->target->setY(d->rewindY);
- if (targetPrivate->widthValid) {
- d->target->setWidth(d->rewindWidth);
- }
- if (targetPrivate->heightValid) {
- d->target->setHeight(d->rewindHeight);
- }
-}
-
-void QDeclarative1AnchorChanges::saveCurrentValues()
-{
- Q_D(QDeclarative1AnchorChanges);
- if (!d->target)
- return;
-
- QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
- d->rewindLeft = targetPrivate->anchors()->left();
- d->rewindRight = targetPrivate->anchors()->right();
- d->rewindHCenter = targetPrivate->anchors()->horizontalCenter();
- d->rewindTop = targetPrivate->anchors()->top();
- d->rewindBottom = targetPrivate->anchors()->bottom();
- d->rewindVCenter = targetPrivate->anchors()->verticalCenter();
- d->rewindBaseline = targetPrivate->anchors()->baseline();
-
- d->rewindX = d->target->x();
- d->rewindY = d->target->y();
- d->rewindWidth = d->target->width();
- d->rewindHeight = d->target->height();
-}
-
-void QDeclarative1AnchorChanges::saveTargetValues()
-{
- Q_D(QDeclarative1AnchorChanges);
- if (!d->target)
- return;
-
- d->toX = d->target->x();
- d->toY = d->target->y();
- d->toWidth = d->target->width();
- d->toHeight = d->target->height();
-}
-
-#include <qdeclarativestateoperations.moc>
-#include <moc_qdeclarativestateoperations_p.cpp>
-
-
-
-QT_END_NAMESPACE
-
diff --git a/src/qtquick1/util/qdeclarativestateoperations_p.h b/src/qtquick1/util/qdeclarativestateoperations_p.h
deleted file mode 100644
index 951f7b4168..0000000000
--- a/src/qtquick1/util/qdeclarativestateoperations_p.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTATEOPERATIONS_H
-#define QDECLARATIVESTATEOPERATIONS_H
-
-#include "QtQuick1/private/qdeclarativestate_p.h"
-
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QtQuick1/private/qdeclarativeanchors_p.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1ParentChangePrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1ParentChange : public QDeclarative1StateOperation, public QDeclarative1ActionEvent
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1ParentChange)
-
- Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
- Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent)
- Q_PROPERTY(QDeclarativeScriptString x READ x WRITE setX)
- Q_PROPERTY(QDeclarativeScriptString y READ y WRITE setY)
- Q_PROPERTY(QDeclarativeScriptString width READ width WRITE setWidth)
- Q_PROPERTY(QDeclarativeScriptString height READ height WRITE setHeight)
- Q_PROPERTY(QDeclarativeScriptString scale READ scale WRITE setScale)
- Q_PROPERTY(QDeclarativeScriptString rotation READ rotation WRITE setRotation)
-public:
- QDeclarative1ParentChange(QObject *parent=0);
- ~QDeclarative1ParentChange();
-
- QDeclarativeItem *object() const;
- void setObject(QDeclarativeItem *);
-
- QDeclarativeItem *parent() const;
- void setParent(QDeclarativeItem *);
-
- QDeclarativeItem *originalParent() const;
-
- QDeclarativeScriptString x() const;
- void setX(QDeclarativeScriptString x);
- bool xIsSet() const;
-
- QDeclarativeScriptString y() const;
- void setY(QDeclarativeScriptString y);
- bool yIsSet() const;
-
- QDeclarativeScriptString width() const;
- void setWidth(QDeclarativeScriptString width);
- bool widthIsSet() const;
-
- QDeclarativeScriptString height() const;
- void setHeight(QDeclarativeScriptString height);
- bool heightIsSet() const;
-
- QDeclarativeScriptString scale() const;
- void setScale(QDeclarativeScriptString scale);
- bool scaleIsSet() const;
-
- QDeclarativeScriptString rotation() const;
- void setRotation(QDeclarativeScriptString rotation);
- bool rotationIsSet() const;
-
- virtual ActionList actions();
-
- virtual void saveOriginals();
- //virtual void copyOriginals(QDeclarative1ActionEvent*);
- virtual void execute(Reason reason = ActualChange);
- virtual bool isReversable();
- virtual void reverse(Reason reason = ActualChange);
- virtual QString typeName() const;
- virtual bool override(QDeclarative1ActionEvent*other);
- virtual void rewind();
- virtual void saveCurrentValues();
-};
-
-class QDeclarative1StateChangeScriptPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1StateChangeScript : public QDeclarative1StateOperation, public QDeclarative1ActionEvent
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1StateChangeScript)
-
- Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString name READ name WRITE setName)
-
-public:
- QDeclarative1StateChangeScript(QObject *parent=0);
- ~QDeclarative1StateChangeScript();
-
- virtual ActionList actions();
-
- virtual QString typeName() const;
-
- QDeclarativeScriptString script() const;
- void setScript(const QDeclarativeScriptString &);
-
- QString name() const;
- void setName(const QString &);
-
- virtual void execute(Reason reason = ActualChange);
-};
-
-class QDeclarative1AnchorChanges;
-class QDeclarative1AnchorSetPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1AnchorSet : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QDeclarativeScriptString left READ left WRITE setLeft RESET resetLeft)
- Q_PROPERTY(QDeclarativeScriptString right READ right WRITE setRight RESET resetRight)
- Q_PROPERTY(QDeclarativeScriptString horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter)
- Q_PROPERTY(QDeclarativeScriptString top READ top WRITE setTop RESET resetTop)
- Q_PROPERTY(QDeclarativeScriptString bottom READ bottom WRITE setBottom RESET resetBottom)
- Q_PROPERTY(QDeclarativeScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
- Q_PROPERTY(QDeclarativeScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline)
- //Q_PROPERTY(QDeclarativeItem *fill READ fill WRITE setFill RESET resetFill)
- //Q_PROPERTY(QDeclarativeItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn)
-
- /*Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
- Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
- Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
- Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
- Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
- Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
- Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
- Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())*/
-
-public:
- QDeclarative1AnchorSet(QObject *parent=0);
- virtual ~QDeclarative1AnchorSet();
-
- QDeclarativeScriptString left() const;
- void setLeft(const QDeclarativeScriptString &edge);
- void resetLeft();
-
- QDeclarativeScriptString right() const;
- void setRight(const QDeclarativeScriptString &edge);
- void resetRight();
-
- QDeclarativeScriptString horizontalCenter() const;
- void setHorizontalCenter(const QDeclarativeScriptString &edge);
- void resetHorizontalCenter();
-
- QDeclarativeScriptString top() const;
- void setTop(const QDeclarativeScriptString &edge);
- void resetTop();
-
- QDeclarativeScriptString bottom() const;
- void setBottom(const QDeclarativeScriptString &edge);
- void resetBottom();
-
- QDeclarativeScriptString verticalCenter() const;
- void setVerticalCenter(const QDeclarativeScriptString &edge);
- void resetVerticalCenter();
-
- QDeclarativeScriptString baseline() const;
- void setBaseline(const QDeclarativeScriptString &edge);
- void resetBaseline();
-
- QDeclarativeItem *fill() const;
- void setFill(QDeclarativeItem *);
- void resetFill();
-
- QDeclarativeItem *centerIn() const;
- void setCenterIn(QDeclarativeItem *);
- void resetCenterIn();
-
- /*qreal leftMargin() const;
- void setLeftMargin(qreal);
-
- qreal rightMargin() const;
- void setRightMargin(qreal);
-
- qreal horizontalCenterOffset() const;
- void setHorizontalCenterOffset(qreal);
-
- qreal topMargin() const;
- void setTopMargin(qreal);
-
- qreal bottomMargin() const;
- void setBottomMargin(qreal);
-
- qreal margins() const;
- void setMargins(qreal);
-
- qreal verticalCenterOffset() const;
- void setVerticalCenterOffset(qreal);
-
- qreal baselineOffset() const;
- void setBaselineOffset(qreal);*/
-
- QDeclarative1Anchors::Anchors usedAnchors() const;
-
-/*Q_SIGNALS:
- void leftMarginChanged();
- void rightMarginChanged();
- void topMarginChanged();
- void bottomMarginChanged();
- void marginsChanged();
- void verticalCenterOffsetChanged();
- void horizontalCenterOffsetChanged();
- void baselineOffsetChanged();*/
-
-private:
- friend class QDeclarative1AnchorChanges;
- Q_DISABLE_COPY(QDeclarative1AnchorSet)
- Q_DECLARE_PRIVATE(QDeclarative1AnchorSet)
-};
-
-class QDeclarative1AnchorChangesPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1AnchorChanges : public QDeclarative1StateOperation, public QDeclarative1ActionEvent
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1AnchorChanges)
-
- Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
- Q_PROPERTY(QDeclarative1AnchorSet *anchors READ anchors CONSTANT)
-
-public:
- QDeclarative1AnchorChanges(QObject *parent=0);
- ~QDeclarative1AnchorChanges();
-
- virtual ActionList actions();
-
- QDeclarative1AnchorSet *anchors();
-
- QDeclarativeItem *object() const;
- void setObject(QDeclarativeItem *);
-
- virtual void execute(Reason reason = ActualChange);
- virtual bool isReversable();
- virtual void reverse(Reason reason = ActualChange);
- virtual QString typeName() const;
- virtual bool override(QDeclarative1ActionEvent*other);
- virtual bool changesBindings();
- virtual void saveOriginals();
- virtual bool needsCopy() { return true; }
- virtual void copyOriginals(QDeclarative1ActionEvent*);
- virtual void clearBindings();
- virtual void rewind();
- virtual void saveCurrentValues();
-
- QList<QDeclarative1Action> additionalActions();
- virtual void saveTargetValues();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1ParentChange)
-QML_DECLARE_TYPE(QDeclarative1StateChangeScript)
-QML_DECLARE_TYPE(QDeclarative1AnchorSet)
-QML_DECLARE_TYPE(QDeclarative1AnchorChanges)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESTATEOPERATIONS_H
diff --git a/src/qtquick1/util/qdeclarativestyledtext.cpp b/src/qtquick1/util/qdeclarativestyledtext.cpp
deleted file mode 100644
index 2f94dd5348..0000000000
--- a/src/qtquick1/util/qdeclarativestyledtext.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QStack>
-#include <QVector>
-#include <QPainter>
-#include <QTextLayout>
-#include <QDebug>
-#include <qmath.h>
-#include "QtQuick1/private/qdeclarativestyledtext_p.h"
-
-/*
- QDeclarative1StyledText supports few tags:
-
- <b></b> - bold
- <i></i> - italic
- <br> - new line
- <font color="color_name" size="1-7"></font>
-
- The opening and closing tags must be correctly nested.
-*/
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarative1StyledTextPrivate
-{
-public:
- QDeclarative1StyledTextPrivate(const QString &t, QTextLayout &l) : text(t), layout(l), baseFont(layout.font()) {}
-
- void parse();
- bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format);
- bool parseCloseTag(const QChar *&ch, const QString &textIn);
- void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut);
- bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
- QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn);
- QStringRef parseValue(const QChar *&ch, const QString &textIn);
-
- inline void skipSpace(const QChar *&ch) {
- while (ch->isSpace() && !ch->isNull())
- ++ch;
- }
-
- QString text;
- QTextLayout &layout;
- QFont baseFont;
-
- static const QChar lessThan;
- static const QChar greaterThan;
- static const QChar equals;
- static const QChar singleQuote;
- static const QChar doubleQuote;
- static const QChar slash;
- static const QChar ampersand;
-};
-
-const QChar QDeclarative1StyledTextPrivate::lessThan(QLatin1Char('<'));
-const QChar QDeclarative1StyledTextPrivate::greaterThan(QLatin1Char('>'));
-const QChar QDeclarative1StyledTextPrivate::equals(QLatin1Char('='));
-const QChar QDeclarative1StyledTextPrivate::singleQuote(QLatin1Char('\''));
-const QChar QDeclarative1StyledTextPrivate::doubleQuote(QLatin1Char('\"'));
-const QChar QDeclarative1StyledTextPrivate::slash(QLatin1Char('/'));
-const QChar QDeclarative1StyledTextPrivate::ampersand(QLatin1Char('&'));
-
-QDeclarative1StyledText::QDeclarative1StyledText(const QString &string, QTextLayout &layout)
-: d(new QDeclarative1StyledTextPrivate(string, layout))
-{
-}
-
-QDeclarative1StyledText::~QDeclarative1StyledText()
-{
- delete d;
-}
-
-void QDeclarative1StyledText::parse(const QString &string, QTextLayout &layout)
-{
- if (string.isEmpty())
- return;
- QDeclarative1StyledText styledText(string, layout);
- styledText.d->parse();
-}
-
-void QDeclarative1StyledTextPrivate::parse()
-{
- QList<QTextLayout::FormatRange> ranges;
- QStack<QTextCharFormat> formatStack;
-
- QString drawText;
- drawText.reserve(text.count());
-
- int textStart = 0;
- int textLength = 0;
- int rangeStart = 0;
- const QChar *ch = text.constData();
- while (!ch->isNull()) {
- if (*ch == lessThan) {
- if (textLength)
- drawText.append(QStringRef(&text, textStart, textLength));
- if (rangeStart != drawText.length() && formatStack.count()) {
- QTextLayout::FormatRange formatRange;
- formatRange.format = formatStack.top();
- formatRange.start = rangeStart;
- formatRange.length = drawText.length() - rangeStart;
- ranges.append(formatRange);
- }
- rangeStart = drawText.length();
- ++ch;
- if (*ch == slash) {
- ++ch;
- if (parseCloseTag(ch, text)) {
- if (formatStack.count())
- formatStack.pop();
- }
- } else {
- QTextCharFormat format;
- if (formatStack.count())
- format = formatStack.top();
- if (parseTag(ch, text, drawText, format))
- formatStack.push(format);
- }
- textStart = ch - text.constData() + 1;
- textLength = 0;
- } else if (*ch == ampersand) {
- ++ch;
- drawText.append(QStringRef(&text, textStart, textLength));
- parseEntity(ch, text, drawText);
- textStart = ch - text.constData() + 1;
- textLength = 0;
- } else {
- ++textLength;
- }
- if (!ch->isNull())
- ++ch;
- }
- if (textLength)
- drawText.append(QStringRef(&text, textStart, textLength));
- if (rangeStart != drawText.length() && formatStack.count()) {
- QTextLayout::FormatRange formatRange;
- formatRange.format = formatStack.top();
- formatRange.start = rangeStart;
- formatRange.length = drawText.length() - rangeStart;
- ranges.append(formatRange);
- }
-
- layout.setText(drawText);
- layout.setAdditionalFormats(ranges);
-}
-
-bool QDeclarative1StyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format)
-{
- skipSpace(ch);
-
- int tagStart = ch - textIn.constData();
- int tagLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- QStringRef tag(&textIn, tagStart, tagLength);
- const QChar char0 = tag.at(0);
- if (char0 == QLatin1Char('b')) {
- if (tagLength == 1)
- format.setFontWeight(QFont::Bold);
- else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) {
- textOut.append(QChar(QChar::LineSeparator));
- return false;
- }
- } else if (char0 == QLatin1Char('i')) {
- if (tagLength == 1)
- format.setFontItalic(true);
- }
- return true;
- } else if (ch->isSpace()) {
- // may have params.
- QStringRef tag(&textIn, tagStart, tagLength);
- if (tag == QLatin1String("font"))
- return parseFontAttributes(ch, textIn, format);
- if (*ch == greaterThan || ch->isNull())
- continue;
- } else if (*ch != slash){
- tagLength++;
- }
- ++ch;
- }
-
- return false;
-}
-
-bool QDeclarative1StyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn)
-{
- skipSpace(ch);
-
- int tagStart = ch - textIn.constData();
- int tagLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- QStringRef tag(&textIn, tagStart, tagLength);
- const QChar char0 = tag.at(0);
- if (char0 == QLatin1Char('b')) {
- if (tagLength == 1)
- return true;
- else if (tag.at(1) == QLatin1Char('r') && tagLength == 2)
- return true;
- } else if (char0 == QLatin1Char('i')) {
- if (tagLength == 1)
- return true;
- } else if (tag == QLatin1String("font")) {
- return true;
- }
- return false;
- } else if (!ch->isSpace()){
- tagLength++;
- }
- ++ch;
- }
-
- return false;
-}
-
-void QDeclarative1StyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut)
-{
- int entityStart = ch - textIn.constData();
- int entityLength = 0;
- while (!ch->isNull()) {
- if (*ch == QLatin1Char(';')) {
- QStringRef entity(&textIn, entityStart, entityLength);
- if (entity == QLatin1String("gt"))
- textOut += QChar(62);
- else if (entity == QLatin1String("lt"))
- textOut += QChar(60);
- else if (entity == QLatin1String("amp"))
- textOut += QChar(38);
- return;
- }
- ++entityLength;
- ++ch;
- }
-}
-
-bool QDeclarative1StyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
-{
- bool valid = false;
- QPair<QStringRef,QStringRef> attr;
- do {
- attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("color")) {
- valid = true;
- format.setForeground(QColor(attr.second.toString()));
- } else if (attr.first == QLatin1String("size")) {
- valid = true;
- int size = attr.second.toString().toInt();
- if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+'))
- size += 3;
- if (size >= 1 && size <= 7) {
- static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 };
- format.setFontPointSize(baseFont.pointSize() * scaling[size-1]);
- }
- }
- } while (!ch->isNull() && !attr.first.isEmpty());
-
- return valid;
-}
-
-QPair<QStringRef,QStringRef> QDeclarative1StyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
-{
- skipSpace(ch);
-
- int attrStart = ch - textIn.constData();
- int attrLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- break;
- } else if (*ch == equals) {
- ++ch;
- if (*ch != singleQuote && *ch != doubleQuote) {
- while (*ch != greaterThan && !ch->isNull())
- ++ch;
- break;
- }
- ++ch;
- if (!attrLength)
- break;
- QStringRef attr(&textIn, attrStart, attrLength);
- QStringRef val = parseValue(ch, textIn);
- if (!val.isEmpty())
- return QPair<QStringRef,QStringRef>(attr,val);
- break;
- } else {
- ++attrLength;
- }
- ++ch;
- }
-
- return QPair<QStringRef,QStringRef>();
-}
-
-QStringRef QDeclarative1StyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
-{
- int valStart = ch - textIn.constData();
- int valLength = 0;
- while (*ch != singleQuote && *ch != doubleQuote && !ch->isNull()) {
- ++valLength;
- ++ch;
- }
- if (ch->isNull())
- return QStringRef();
- ++ch; // skip quote
-
- return QStringRef(&textIn, valStart, valLength);
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativestyledtext_p.h b/src/qtquick1/util/qdeclarativestyledtext_p.h
deleted file mode 100644
index 0725b5a4be..0000000000
--- a/src/qtquick1/util/qdeclarativestyledtext_p.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESTYLEDTEXT_H
-#define QDECLARATIVESTYLEDTEXT_H
-
-#include <QSizeF>
-
-QT_BEGIN_NAMESPACE
-
-class QPainter;
-class QPointF;
-class QString;
-class QTextLayout;
-
-class QDeclarative1StyledTextPrivate;
-
-class Q_AUTOTEST_EXPORT QDeclarative1StyledText
-{
-public:
- static void parse(const QString &string, QTextLayout &layout);
-
-private:
- QDeclarative1StyledText(const QString &string, QTextLayout &layout);
- ~QDeclarative1StyledText();
-
- QDeclarative1StyledTextPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/qtquick1/util/qdeclarativesystempalette.cpp b/src/qtquick1/util/qdeclarativesystempalette.cpp
deleted file mode 100644
index 3db83fb7ee..0000000000
--- a/src/qtquick1/util/qdeclarativesystempalette.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativesystempalette_p.h"
-
-#include <QApplication>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QDeclarative1SystemPalettePrivate : public QObjectPrivate
-{
-public:
- QPalette palette;
- QPalette::ColorGroup group;
-};
-
-
-
-/*!
- \qmlclass SystemPalette QDeclarative1SystemPalette
- \inqmlmodule QtQuick 1
- \ingroup qml-utility-elements
- \since QtQuick 1.0
- \brief The SystemPalette element provides access to the Qt palettes.
-
- The SystemPalette element provides access to the Qt application
- palettes. This provides information about the standard colors used
- for application windows, buttons and other features. These colors
- are grouped into three \e {color groups}: \c Active, \c Inactive,
- and \c Disabled. See the QPalette documentation for details about
- color groups and the properties provided by SystemPalette.
-
- This can be used to color items in a way that provides a more
- native look and feel.
-
- The following example creates a palette from the \c Active color
- group and uses this to color the window and text items
- appropriately:
-
- \snippet doc/src/snippets/qtquick1/systempalette.qml 0
-
- \sa QPalette
-*/
-QDeclarative1SystemPalette::QDeclarative1SystemPalette(QObject *parent)
- : QObject(*(new QDeclarative1SystemPalettePrivate), parent)
-{
- Q_D(QDeclarative1SystemPalette);
- d->palette = QApplication::palette();
- d->group = QPalette::Active;
- qApp->installEventFilter(this);
-}
-
-QDeclarative1SystemPalette::~QDeclarative1SystemPalette()
-{
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::window
- The window (general background) color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::window() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Window);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::windowText
- The window text (general foreground) color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::windowText() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::WindowText);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::base
- The base color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::base() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Base);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::text
- The text color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::text() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Text);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::alternateBase
- The alternate base color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::alternateBase() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::AlternateBase);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::button
- The button color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::button() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Button);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::buttonText
- The button text foreground color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::buttonText() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::ButtonText);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::light
- The light color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::light() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Light);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::midlight
- The midlight color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::midlight() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Midlight);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::dark
- The dark color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::dark() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Dark);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::mid
- The mid color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::mid() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Mid);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::shadow
- The shadow color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::shadow() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Shadow);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::highlight
- The highlight color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::highlight() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::Highlight);
-}
-
-/*!
- \qmlproperty color QtQuick1::SystemPalette::highlightedText
- The highlighted text color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QDeclarative1SystemPalette::highlightedText() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return d->palette.color(d->group, QPalette::HighlightedText);
-}
-
-/*!
- \qmlproperty enumeration QtQuick1::SystemPalette::colorGroup
-
- The color group of the palette. This can be one of:
-
- \list
- \o SystemPalette.Active (default)
- \o SystemPalette.Inactive
- \o SystemPalette.Disabled
- \endlist
-
- \sa QPalette::ColorGroup
-*/
-QDeclarative1SystemPalette::ColorGroup QDeclarative1SystemPalette::colorGroup() const
-{
- Q_D(const QDeclarative1SystemPalette);
- return (QDeclarative1SystemPalette::ColorGroup)d->group;
-}
-
-void QDeclarative1SystemPalette::setColorGroup(QDeclarative1SystemPalette::ColorGroup colorGroup)
-{
- Q_D(QDeclarative1SystemPalette);
- d->group = (QPalette::ColorGroup)colorGroup;
- emit paletteChanged();
-}
-
-bool QDeclarative1SystemPalette::eventFilter(QObject *watched, QEvent *event)
-{
- if (watched == qApp) {
- if (event->type() == QEvent::ApplicationPaletteChange) {
- QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
- return false;
- }
- }
- return QObject::eventFilter(watched, event);
-}
-
-bool QDeclarative1SystemPalette::event(QEvent *event)
-{
- Q_D(QDeclarative1SystemPalette);
- if (event->type() == QEvent::ApplicationPaletteChange) {
- d->palette = QApplication::palette();
- emit paletteChanged();
- return true;
- }
- return QObject::event(event);
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativesystempalette_p.h b/src/qtquick1/util/qdeclarativesystempalette_p.h
deleted file mode 100644
index 439fb30a92..0000000000
--- a/src/qtquick1/util/qdeclarativesystempalette_p.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESYSTEMPALETTE_H
-#define QDECLARATIVESYSTEMPALETTE_H
-
-#include <QtDeclarative/qdeclarative.h>
-
-#include <QtCore/qobject.h>
-#include <QPalette>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1SystemPalettePrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1SystemPalette : public QObject
-{
- Q_OBJECT
- Q_ENUMS(ColorGroup)
- Q_DECLARE_PRIVATE(QDeclarative1SystemPalette)
-
- Q_PROPERTY(QDeclarative1SystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
- Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
- Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
- Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
- Q_PROPERTY(QColor text READ text NOTIFY paletteChanged)
- Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged)
- Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
- Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
- Q_PROPERTY(QColor light READ light NOTIFY paletteChanged)
- Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged)
- Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged)
- Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged)
- Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
- Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
- Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
-
-public:
- QDeclarative1SystemPalette(QObject *parent=0);
- ~QDeclarative1SystemPalette();
-
- enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled };
-
- QColor window() const;
- QColor windowText() const;
-
- QColor base() const;
- QColor text() const;
- QColor alternateBase() const;
-
- QColor button() const;
- QColor buttonText() const;
-
- QColor light() const;
- QColor midlight() const;
- QColor dark() const;
- QColor mid() const;
- QColor shadow() const;
-
- QColor highlight() const;
- QColor highlightedText() const;
-
- QDeclarative1SystemPalette::ColorGroup colorGroup() const;
- void setColorGroup(QDeclarative1SystemPalette::ColorGroup);
-
-Q_SIGNALS:
- void paletteChanged();
-
-private:
- bool eventFilter(QObject *watched, QEvent *event);
- bool event(QEvent *event);
-
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1SystemPalette)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVESYSTEMPALETTE_H
diff --git a/src/qtquick1/util/qdeclarativetimeline.cpp b/src/qtquick1/util/qdeclarativetimeline.cpp
deleted file mode 100644
index 87b63770e0..0000000000
--- a/src/qtquick1/util/qdeclarativetimeline.cpp
+++ /dev/null
@@ -1,951 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativetimeline_p_p.h"
-
-#include <QDebug>
-#include <QMutex>
-#include <QThread>
-#include <QWaitCondition>
-#include <QEvent>
-#include <QCoreApplication>
-#include <QEasingCurve>
-#include <QTime>
-
-QT_BEGIN_NAMESPACE
-
-
-
-struct Update {
- Update(QDeclarative1TimeLineValue *_g, qreal _v)
- : g(_g), v(_v) {}
- Update(const QDeclarative1TimeLineCallback &_e)
- : g(0), v(0), e(_e) {}
-
- QDeclarative1TimeLineValue *g;
- qreal v;
- QDeclarative1TimeLineCallback e;
-};
-
-struct QDeclarative1TimeLinePrivate
-{
- QDeclarative1TimeLinePrivate(QDeclarative1TimeLine *);
-
- struct Op {
- enum Type {
- Pause,
- Set,
- Move,
- MoveBy,
- Accel,
- AccelDistance,
- Execute
- };
- Op() {}
- Op(Type t, int l, qreal v, qreal v2, int o,
- const QDeclarative1TimeLineCallback &ev = QDeclarative1TimeLineCallback(), const QEasingCurve &es = QEasingCurve())
- : type(t), length(l), value(v), value2(v2), order(o), event(ev),
- easing(es) {}
- Op(const Op &o)
- : type(o.type), length(o.length), value(o.value), value2(o.value2),
- order(o.order), event(o.event), easing(o.easing) {}
- Op &operator=(const Op &o) {
- type = o.type; length = o.length; value = o.value;
- value2 = o.value2; order = o.order; event = o.event;
- easing = o.easing;
- return *this;
- }
-
- Type type;
- int length;
- qreal value;
- qreal value2;
-
- int order;
- QDeclarative1TimeLineCallback event;
- QEasingCurve easing;
- };
- struct TimeLine
- {
- TimeLine() : length(0), consumedOpLength(0), base(0.) {}
- QList<Op> ops;
- int length;
- int consumedOpLength;
- qreal base;
- };
-
- int length;
- int syncPoint;
- typedef QHash<QDeclarative1TimeLineObject *, TimeLine> Ops;
- Ops ops;
- QDeclarative1TimeLine *q;
-
- void add(QDeclarative1TimeLineObject &, const Op &);
- qreal value(const Op &op, int time, qreal base, bool *) const;
-
- int advance(int);
-
- bool clockRunning;
- int prevTime;
-
- int order;
-
- QDeclarative1TimeLine::SyncMode syncMode;
- int syncAdj;
- QList<QPair<int, Update> > *updateQueue;
-};
-
-QDeclarative1TimeLinePrivate::QDeclarative1TimeLinePrivate(QDeclarative1TimeLine *parent)
-: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QDeclarative1TimeLine::LocalSync), syncAdj(0), updateQueue(0)
-{
-}
-
-void QDeclarative1TimeLinePrivate::add(QDeclarative1TimeLineObject &g, const Op &o)
-{
- if (g._t && g._t != q) {
- qWarning() << "QDeclarative1TimeLine: Cannot modify a QDeclarative1TimeLineValue owned by"
- << "another timeline.";
- return;
- }
- g._t = q;
-
- Ops::Iterator iter = ops.find(&g);
- if (iter == ops.end()) {
- iter = ops.insert(&g, TimeLine());
- if (syncPoint > 0)
- q->pause(g, syncPoint);
- }
- if (!iter->ops.isEmpty() &&
- o.type == Op::Pause &&
- iter->ops.last().type == Op::Pause) {
- iter->ops.last().length += o.length;
- iter->length += o.length;
- } else {
- iter->ops.append(o);
- iter->length += o.length;
- }
-
- if (iter->length > length)
- length = iter->length;
-
- if (!clockRunning) {
- q->stop();
- prevTime = 0;
- clockRunning = true;
-
- if (syncMode == QDeclarative1TimeLine::LocalSync) {
- syncAdj = -1;
- } else {
- syncAdj = 0;
- }
- q->start();
-/* q->tick(0);
- if (syncMode == QDeclarative1TimeLine::LocalSync) {
- syncAdj = -1;
- } else {
- syncAdj = 0;
- }
- */
- }
-}
-
-qreal QDeclarative1TimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const
-{
- Q_ASSERT(time >= 0);
- Q_ASSERT(time <= op.length);
- *changed = true;
-
- switch(op.type) {
- case Op::Pause:
- *changed = false;
- return base;
- case Op::Set:
- return op.value;
- case Op::Move:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return op.value;
- } else {
- qreal delta = op.value - base;
- qreal pTime = (qreal)(time) / (qreal)op.length;
- if (op.easing.type() == QEasingCurve::Linear)
- return base + delta * pTime;
- else
- return base + delta * op.easing.valueForProgress(pTime);
- }
- case Op::MoveBy:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return base + op.value;
- } else {
- qreal delta = op.value;
- qreal pTime = (qreal)(time) / (qreal)op.length;
- if (op.easing.type() == QEasingCurve::Linear)
- return base + delta * pTime;
- else
- return base + delta * op.easing.valueForProgress(pTime);
- }
- case Op::Accel:
- if (time == 0) {
- return base;
- } else {
- qreal t = (qreal)(time) / 1000.0f;
- qreal delta = op.value * t + 0.5f * op.value2 * t * t;
- return base + delta;
- }
- case Op::AccelDistance:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return base + op.value2;
- } else {
- qreal t = (qreal)(time) / 1000.0f;
- qreal accel = -1.0f * 1000.0f * op.value / (qreal)op.length;
- qreal delta = op.value * t + 0.5f * accel * t * t;
- return base + delta;
-
- }
- case Op::Execute:
- op.event.d0(op.event.d1);
- *changed = false;
- return -1;
- }
-
- return base;
-}
-
-/*!
- \internal
- \class QDeclarative1TimeLine
- \brief The QDeclarative1TimeLine class provides a timeline for controlling animations.
-
- QDeclarative1TimeLine is similar to QTimeLine except:
- \list
- \i It updates QDeclarative1TimeLineValue instances directly, rather than maintaining a single
- current value.
-
- For example, the following animates a simple value over 200 milliseconds:
- \code
- QDeclarative1TimeLineValue v(<starting value>);
- QDeclarative1TimeLine tl;
- tl.move(v, 100., 200);
- tl.start()
- \endcode
-
- If your program needs to know when values are changed, it can either
- connect to the QDeclarative1TimeLine's updated() signal, or inherit from QDeclarative1TimeLineValue
- and reimplement the QDeclarative1TimeLineValue::setValue() method.
-
- \i Supports multiple QDeclarative1TimeLineValue, arbitrary start and end values and allows
- animations to be strung together for more complex effects.
-
- For example, the following animation moves the x and y coordinates of
- an object from wherever they are to the position (100, 100) in 50
- milliseconds and then further animates them to (100, 200) in 50
- milliseconds:
-
- \code
- QDeclarative1TimeLineValue x(<starting value>);
- QDeclarative1TimeLineValue y(<starting value>);
-
- QDeclarative1TimeLine tl;
- tl.start();
-
- tl.move(x, 100., 50);
- tl.move(y, 100., 50);
- tl.move(y, 200., 50);
- \endcode
-
- \i All QDeclarative1TimeLine instances share a single, synchronized clock.
-
- Actions scheduled within the same event loop tick are scheduled
- synchronously against each other, regardless of the wall time between the
- scheduling. Synchronized scheduling applies both to within the same
- QDeclarative1TimeLine and across separate QDeclarative1TimeLine's within the same process.
-
- \endlist
-
- Currently easing functions are not supported.
-*/
-
-
-/*!
- Construct a new QDeclarative1TimeLine with the specified \a parent.
-*/
-QDeclarative1TimeLine::QDeclarative1TimeLine(QObject *parent)
-: QAbstractAnimation(parent)
-{
- d = new QDeclarative1TimeLinePrivate(this);
-}
-
-/*!
- Destroys the time line. Any inprogress animations are canceled, but not
- completed.
-*/
-QDeclarative1TimeLine::~QDeclarative1TimeLine()
-{
- for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter)
- iter.key()->_t = 0;
-
- delete d; d = 0;
-}
-
-/*!
- \enum QDeclarative1TimeLine::SyncMode
- */
-
-/*!
- Return the timeline's synchronization mode.
- */
-QDeclarative1TimeLine::SyncMode QDeclarative1TimeLine::syncMode() const
-{
- return d->syncMode;
-}
-
-/*!
- Set the timeline's synchronization mode to \a syncMode.
- */
-void QDeclarative1TimeLine::setSyncMode(SyncMode syncMode)
-{
- d->syncMode = syncMode;
-}
-
-/*!
- Pause \a obj for \a time milliseconds.
-*/
-void QDeclarative1TimeLine::pause(QDeclarative1TimeLineObject &obj, int time)
-{
- if (time <= 0) return;
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Pause, time, 0., 0., d->order++);
- d->add(obj, op);
-}
-
-/*!
- Execute the \a event.
- */
-void QDeclarative1TimeLine::callback(const QDeclarative1TimeLineCallback &callback)
-{
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback);
- d->add(*callback.callbackObject(), op);
-}
-
-/*!
- Set the \a value of \a timeLineValue.
-*/
-void QDeclarative1TimeLine::set(QDeclarative1TimeLineValue &timeLineValue, qreal value)
-{
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Set, 0, value, 0., d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Decelerate \a timeLineValue from the starting \a velocity to zero at the
- given \a acceleration rate. Although the \a acceleration is technically
- a deceleration, it should always be positive. The QDeclarative1TimeLine will ensure
- that the deceleration is in the opposite direction to the initial velocity.
-*/
-int QDeclarative1TimeLine::accel(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal acceleration)
-{
- if (acceleration == 0.0f)
- return -1;
-
- if ((velocity > 0.0f) == (acceleration > 0.0f))
- acceleration = acceleration * -1.0f;
-
- int time = static_cast<int>(-1000 * velocity / acceleration);
-
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- \overload
-
- Decelerate \a timeLineValue from the starting \a velocity to zero at the
- given \a acceleration rate over a maximum distance of maxDistance.
-
- If necessary, QDeclarative1TimeLine will reduce the acceleration to ensure that the
- entire operation does not require a move of more than \a maxDistance.
- \a maxDistance should always be positive.
-*/
-int QDeclarative1TimeLine::accel(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance)
-{
- if (maxDistance == 0.0f || acceleration == 0.0f)
- return -1;
-
- Q_ASSERT(acceleration > 0.0f && maxDistance > 0.0f);
-
- qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance);
- if (maxAccel > acceleration)
- acceleration = maxAccel;
-
- if ((velocity > 0.0f) == (acceleration > 0.0f))
- acceleration = acceleration * -1.0f;
-
- int time = static_cast<int>(-1000 * velocity / acceleration);
-
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- Decelerate \a timeLineValue from the starting \a velocity to zero over the given
- \a distance. This is like accel(), but the QDeclarative1TimeLine calculates the exact
- deceleration to use.
-
- \a distance should be positive.
-*/
-int QDeclarative1TimeLine::accelDistance(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal distance)
-{
- if (distance == 0.0f || velocity == 0.0f)
- return -1;
-
- Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f));
-
- int time = static_cast<int>(1000 * (2.0f * distance) / velocity);
-
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- Linearly change the \a timeLineValue from its current value to the given
- \a destination value over \a time milliseconds.
-*/
-void QDeclarative1TimeLine::move(QDeclarative1TimeLineValue &timeLineValue, qreal destination, int time)
-{
- if (time <= 0) return;
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Change the \a timeLineValue from its current value to the given \a destination
- value over \a time milliseconds using the \a easing curve.
- */
-void QDeclarative1TimeLine::move(QDeclarative1TimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
-{
- if (time <= 0) return;
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QDeclarative1TimeLineCallback(), easing);
- d->add(timeLineValue, op);
-}
-
-/*!
- Linearly change the \a timeLineValue from its current value by the \a change amount
- over \a time milliseconds.
-*/
-void QDeclarative1TimeLine::moveBy(QDeclarative1TimeLineValue &timeLineValue, qreal change, int time)
-{
- if (time <= 0) return;
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Change the \a timeLineValue from its current value by the \a change amount over
- \a time milliseconds using the \a easing curve.
- */
-void QDeclarative1TimeLine::moveBy(QDeclarative1TimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
-{
- if (time <= 0) return;
- QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QDeclarative1TimeLineCallback(), easing);
- d->add(timeLineValue, op);
-}
-
-/*!
- Cancel (but don't complete) all scheduled actions for \a timeLineValue.
-*/
-void QDeclarative1TimeLine::reset(QDeclarative1TimeLineValue &timeLineValue)
-{
- if (!timeLineValue._t)
- return;
- if (timeLineValue._t != this) {
- qWarning() << "QDeclarative1TimeLine: Cannot reset a QDeclarative1TimeLineValue owned by another timeline.";
- return;
- }
- remove(&timeLineValue);
- timeLineValue._t = 0;
-}
-
-int QDeclarative1TimeLine::duration() const
-{
- return -1;
-}
-
-/*!
- Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo
- within this timeline.
-
- Following operations on \a timeLineValue in this timeline will be scheduled after
- all the currently scheduled actions on \a syncTo are complete. In
- pseudo-code this is equivalent to:
- \code
- QDeclarative1TimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))
- \endcode
-*/
-void QDeclarative1TimeLine::sync(QDeclarative1TimeLineValue &timeLineValue, QDeclarative1TimeLineValue &syncTo)
-{
- QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo);
- if (iter == d->ops.end())
- return;
- int length = iter->length;
-
- iter = d->ops.find(&timeLineValue);
- if (iter == d->ops.end()) {
- pause(timeLineValue, length);
- } else {
- int glength = iter->length;
- pause(timeLineValue, length - glength);
- }
-}
-
-/*!
- Synchronize the end point of \a timeLineValue to the endpoint of the longest
- action cursrently scheduled in the timeline.
-
- In pseudo-code, this is equivalent to:
- \code
- QDeclarative1TimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))
- \endcode
-*/
-void QDeclarative1TimeLine::sync(QDeclarative1TimeLineValue &timeLineValue)
-{
- QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue);
- if (iter == d->ops.end()) {
- pause(timeLineValue, d->length);
- } else {
- pause(timeLineValue, d->length - iter->length);
- }
-}
-
-/*
- Synchronize all currently and future scheduled values in this timeline to
- the longest action currently scheduled.
-
- For example:
- \code
- value1->setValue(0.);
- value2->setValue(0.);
- value3->setValue(0.);
- QDeclarative1TimeLine tl;
- ...
- tl.move(value1, 10, 200);
- tl.move(value2, 10, 100);
- tl.sync();
- tl.move(value2, 20, 100);
- tl.move(value3, 20, 100);
- \endcode
-
- will result in:
-
- \table
- \header \o \o 0ms \o 50ms \o 100ms \o 150ms \o 200ms \o 250ms \o 300ms
- \row \o value1 \o 0 \o 2.5 \o 5.0 \o 7.5 \o 10 \o 10 \o 10
- \row \o value2 \o 0 \o 5.0 \o 10.0 \o 10.0 \o 10.0 \o 15.0 \o 20.0
- \row \o value2 \o 0 \o 0 \o 0 \o 0 \o 0 \o 10.0 \o 20.0
- \endtable
-*/
-
-/*void QDeclarative1TimeLine::sync()
-{
- for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter)
- pause(*iter.key(), d->length - iter->length);
- d->syncPoint = d->length;
-}*/
-
-/*!
- \internal
-
- Temporary hack.
- */
-void QDeclarative1TimeLine::setSyncPoint(int sp)
-{
- d->syncPoint = sp;
-}
-
-/*!
- \internal
-
- Temporary hack.
- */
-int QDeclarative1TimeLine::syncPoint() const
-{
- return d->syncPoint;
-}
-
-/*!
- Returns true if the timeline is active. An active timeline is one where
- QDeclarative1TimeLineValue actions are still pending.
-*/
-bool QDeclarative1TimeLine::isActive() const
-{
- return !d->ops.isEmpty();
-}
-
-/*!
- Completes the timeline. All queued actions are played to completion, and then discarded. For example,
- \code
- QDeclarative1TimeLineValue v(0.);
- QDeclarative1TimeLine tl;
- tl.move(v, 100., 1000.);
- // 500 ms passes
- // v.value() == 50.
- tl.complete();
- // v.value() == 100.
- \endcode
-*/
-void QDeclarative1TimeLine::complete()
-{
- d->advance(d->length);
-}
-
-/*!
- Resets the timeline. All queued actions are discarded and QDeclarative1TimeLineValue's retain their current value. For example,
- \code
- QDeclarative1TimeLineValue v(0.);
- QDeclarative1TimeLine tl;
- tl.move(v, 100., 1000.);
- // 500 ms passes
- // v.value() == 50.
- tl.clear();
- // v.value() == 50.
- \endcode
-*/
-void QDeclarative1TimeLine::clear()
-{
- for (QDeclarative1TimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter)
- iter.key()->_t = 0;
- d->ops.clear();
- d->length = 0;
- d->syncPoint = 0;
- //XXX need stop here?
-}
-
-int QDeclarative1TimeLine::time() const
-{
- return d->prevTime;
-}
-
-/*!
- \fn void QDeclarative1TimeLine::updated()
-
- Emitted each time the timeline modifies QDeclarative1TimeLineValues. Even if multiple
- QDeclarative1TimeLineValues are changed, this signal is only emitted once for each clock tick.
-*/
-
-void QDeclarative1TimeLine::updateCurrentTime(int v)
-{
- if (d->syncAdj == -1)
- d->syncAdj = v;
- v -= d->syncAdj;
-
- int timeChanged = v - d->prevTime;
-#if 0
- if (!timeChanged)
- return;
-#endif
- d->prevTime = v;
- d->advance(timeChanged);
- emit updated();
-
- // Do we need to stop the clock?
- if (d->ops.isEmpty()) {
- stop();
- d->prevTime = 0;
- d->clockRunning = false;
- emit completed();
- } /*else if (pauseTime > 0) {
- GfxClock::cancelClock();
- d->prevTime = 0;
- GfxClock::pauseFor(pauseTime);
- d->syncAdj = 0;
- d->clockRunning = false;
- }*/ else if (/*!GfxClock::isActive()*/ state() != Running) {
- stop();
- d->prevTime = 0;
- d->clockRunning = true;
- d->syncAdj = 0;
- start();
- }
-}
-
-bool operator<(const QPair<int, Update> &lhs,
- const QPair<int, Update> &rhs)
-{
- return lhs.first < rhs.first;
-}
-
-int QDeclarative1TimeLinePrivate::advance(int t)
-{
- int pauseTime = -1;
-
- // XXX - surely there is a more efficient way?
- do {
- pauseTime = -1;
- // Minimal advance time
- int advanceTime = t;
- for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) {
- TimeLine &tl = *iter;
- Op &op = tl.ops.first();
- int length = op.length - tl.consumedOpLength;
-
- if (length < advanceTime) {
- advanceTime = length;
- if (advanceTime == 0)
- break;
- }
- }
- t -= advanceTime;
-
- // Process until then. A zero length advance time will only process
- // sets.
- QList<QPair<int, Update> > updates;
-
- for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) {
- QDeclarative1TimeLineValue *v = static_cast<QDeclarative1TimeLineValue *>(iter.key());
- TimeLine &tl = *iter;
- Q_ASSERT(!tl.ops.isEmpty());
-
- do {
- Op &op = tl.ops.first();
- if (advanceTime == 0 && op.length != 0)
- continue;
-
- if (tl.consumedOpLength == 0 &&
- op.type != Op::Pause &&
- op.type != Op::Execute)
- tl.base = v->value();
-
- if ((tl.consumedOpLength + advanceTime) == op.length) {
- if (op.type == Op::Execute) {
- updates << qMakePair(op.order, Update(op.event));
- } else {
- bool changed = false;
- qreal val = value(op, op.length, tl.base, &changed);
- if (changed)
- updates << qMakePair(op.order, Update(v, val));
- }
- tl.length -= qMin(advanceTime, tl.length);
- tl.consumedOpLength = 0;
- tl.ops.removeFirst();
- } else {
- tl.consumedOpLength += advanceTime;
- bool changed = false;
- qreal val = value(op, tl.consumedOpLength, tl.base, &changed);
- if (changed)
- updates << qMakePair(op.order, Update(v, val));
- tl.length -= qMin(advanceTime, tl.length);
- break;
- }
-
- } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0);
-
-
- if (tl.ops.isEmpty()) {
- iter = ops.erase(iter);
- v->_t = 0;
- } else {
- if (tl.ops.first().type == Op::Pause && pauseTime != 0) {
- int opPauseTime = tl.ops.first().length - tl.consumedOpLength;
- if (pauseTime == -1 || opPauseTime < pauseTime)
- pauseTime = opPauseTime;
- } else {
- pauseTime = 0;
- }
- ++iter;
- }
- }
-
- length -= qMin(length, advanceTime);
- syncPoint -= advanceTime;
-
- qSort(updates.begin(), updates.end());
- updateQueue = &updates;
- for (int ii = 0; ii < updates.count(); ++ii) {
- const Update &v = updates.at(ii).second;
- if (v.g) {
- v.g->setValue(v.v);
- } else {
- v.e.d0(v.e.d1);
- }
- }
- updateQueue = 0;
- } while(t);
-
- return pauseTime;
-}
-
-void QDeclarative1TimeLine::remove(QDeclarative1TimeLineObject *v)
-{
- QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(v);
- Q_ASSERT(iter != d->ops.end());
-
- int len = iter->length;
- d->ops.erase(iter);
- if (len == d->length) {
- // We need to recalculate the length
- d->length = 0;
- for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter) {
-
- if (iter->length > d->length)
- d->length = iter->length;
-
- }
- }
- if (d->ops.isEmpty()) {
- stop();
- d->clockRunning = false;
- } else if (/*!GfxClock::isActive()*/ state() != Running) {
- stop();
- d->prevTime = 0;
- d->clockRunning = true;
-
- if (d->syncMode == QDeclarative1TimeLine::LocalSync) {
- d->syncAdj = -1;
- } else {
- d->syncAdj = 0;
- }
- start();
- }
-
- if (d->updateQueue) {
- for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
- if (d->updateQueue->at(ii).second.g == v ||
- d->updateQueue->at(ii).second.e.callbackObject() == v) {
- d->updateQueue->removeAt(ii);
- --ii;
- }
- }
- }
-
-
-}
-
-/*!
- \internal
- \class QDeclarative1TimeLineValue
- \brief The QDeclarative1TimeLineValue class provides a value that can be modified by QDeclarative1TimeLine.
-*/
-
-/*!
- \fn QDeclarative1TimeLineValue::QDeclarative1TimeLineValue(qreal value = 0)
-
- Construct a new QDeclarative1TimeLineValue with an initial \a value.
-*/
-
-/*!
- \fn qreal QDeclarative1TimeLineValue::value() const
-
- Return the current value.
-*/
-
-/*!
- \fn void QDeclarative1TimeLineValue::setValue(qreal value)
-
- Set the current \a value.
-*/
-
-/*!
- \fn QDeclarative1TimeLine *QDeclarative1TimeLineValue::timeLine() const
-
- If a QDeclarative1TimeLine is operating on this value, return a pointer to it,
- otherwise return null.
-*/
-
-
-QDeclarative1TimeLineObject::QDeclarative1TimeLineObject()
-: _t(0)
-{
-}
-
-QDeclarative1TimeLineObject::~QDeclarative1TimeLineObject()
-{
- if (_t) {
- _t->remove(this);
- _t = 0;
- }
-}
-
-QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback()
-: d0(0), d1(0), d2(0)
-{
-}
-
-QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback(QDeclarative1TimeLineObject *b, Callback f, void *d)
-: d0(f), d1(d), d2(b)
-{
-}
-
-QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback(const QDeclarative1TimeLineCallback &o)
-: d0(o.d0), d1(o.d1), d2(o.d2)
-{
-}
-
-QDeclarative1TimeLineCallback &QDeclarative1TimeLineCallback::operator=(const QDeclarative1TimeLineCallback &o)
-{
- d0 = o.d0;
- d1 = o.d1;
- d2 = o.d2;
- return *this;
-}
-
-QDeclarative1TimeLineObject *QDeclarative1TimeLineCallback::callbackObject() const
-{
- return d2;
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativetimeline_p_p.h b/src/qtquick1/util/qdeclarativetimeline_p_p.h
deleted file mode 100644
index 75f1cc74a4..0000000000
--- a/src/qtquick1/util/qdeclarativetimeline_p_p.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETIMELINE_H
-#define QDECLARATIVETIMELINE_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QObject>
-#include <QtCore/QAbstractAnimation>
-
-QT_BEGIN_NAMESPACE
-
-class QEasingCurve;
-class QDeclarative1TimeLineValue;
-class QDeclarative1TimeLineCallback;
-struct QDeclarative1TimeLinePrivate;
-class QDeclarative1TimeLineObject;
-class Q_AUTOTEST_EXPORT QDeclarative1TimeLine : public QAbstractAnimation
-{
-Q_OBJECT
-public:
- QDeclarative1TimeLine(QObject *parent = 0);
- ~QDeclarative1TimeLine();
-
- enum SyncMode { LocalSync, GlobalSync };
- SyncMode syncMode() const;
- void setSyncMode(SyncMode);
-
- void pause(QDeclarative1TimeLineObject &, int);
- void callback(const QDeclarative1TimeLineCallback &);
- void set(QDeclarative1TimeLineValue &, qreal);
-
- int accel(QDeclarative1TimeLineValue &, qreal velocity, qreal accel);
- int accel(QDeclarative1TimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
- int accelDistance(QDeclarative1TimeLineValue &, qreal velocity, qreal distance);
-
- void move(QDeclarative1TimeLineValue &, qreal destination, int time = 500);
- void move(QDeclarative1TimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
- void moveBy(QDeclarative1TimeLineValue &, qreal change, int time = 500);
- void moveBy(QDeclarative1TimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
-
- void sync();
- void setSyncPoint(int);
- int syncPoint() const;
-
- void sync(QDeclarative1TimeLineValue &);
- void sync(QDeclarative1TimeLineValue &, QDeclarative1TimeLineValue &);
-
- void reset(QDeclarative1TimeLineValue &);
-
- void complete();
- void clear();
- bool isActive() const;
-
- int time() const;
-
- virtual int duration() const;
-Q_SIGNALS:
- void updated();
- void completed();
-
-protected:
- virtual void updateCurrentTime(int);
-
-private:
- void remove(QDeclarative1TimeLineObject *);
- friend class QDeclarative1TimeLineObject;
- friend struct QDeclarative1TimeLinePrivate;
- QDeclarative1TimeLinePrivate *d;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1TimeLineObject
-{
-public:
- QDeclarative1TimeLineObject();
- virtual ~QDeclarative1TimeLineObject();
-
-protected:
- friend class QDeclarative1TimeLine;
- friend struct QDeclarative1TimeLinePrivate;
- QDeclarative1TimeLine *_t;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1TimeLineValue : public QDeclarative1TimeLineObject
-{
-public:
- QDeclarative1TimeLineValue(qreal v = 0.) : _v(v) {}
-
- virtual qreal value() const { return _v; }
- virtual void setValue(qreal v) { _v = v; }
-
- QDeclarative1TimeLine *timeLine() const { return _t; }
-
- operator qreal() const { return _v; }
- QDeclarative1TimeLineValue &operator=(qreal v) { setValue(v); return *this; }
-private:
- friend class QDeclarative1TimeLine;
- friend struct QDeclarative1TimeLinePrivate;
- qreal _v;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1TimeLineCallback
-{
-public:
- typedef void (*Callback)(void *);
-
- QDeclarative1TimeLineCallback();
- QDeclarative1TimeLineCallback(QDeclarative1TimeLineObject *b, Callback, void * = 0);
- QDeclarative1TimeLineCallback(const QDeclarative1TimeLineCallback &o);
-
- QDeclarative1TimeLineCallback &operator=(const QDeclarative1TimeLineCallback &o);
- QDeclarative1TimeLineObject *callbackObject() const;
-
-private:
- friend struct QDeclarative1TimeLinePrivate;
- Callback d0;
- void *d1;
- QDeclarative1TimeLineObject *d2;
-};
-
-template<class T>
-class QDeclarative1TimeLineValueProxy : public QDeclarative1TimeLineValue
-{
-public:
- QDeclarative1TimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
- : QDeclarative1TimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
- {
- Q_ASSERT(_class);
- }
-
- QDeclarative1TimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
- : QDeclarative1TimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
- {
- Q_ASSERT(_class);
- }
-
- virtual void setValue(qreal v)
- {
- QDeclarative1TimeLineValue::setValue(v);
- if (_setFunctionReal) (_class->*_setFunctionReal)(v);
- else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v);
- }
-
-private:
- T *_class;
- void (T::*_setFunctionReal)(qreal);
- void (T::*_setFunctionInt)(int);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/qtquick1/util/qdeclarativetimer.cpp b/src/qtquick1/util/qdeclarativetimer.cpp
deleted file mode 100644
index 79968d4ed9..0000000000
--- a/src/qtquick1/util/qdeclarativetimer.cpp
+++ /dev/null
@@ -1,329 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativetimer_p.h"
-
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qpauseanimation.h>
-#include <qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-
-
-class QDeclarative1TimerPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1Timer)
-public:
- QDeclarative1TimerPrivate()
- : interval(1000), running(false), repeating(false), triggeredOnStart(false)
- , classBegun(false), componentComplete(false), firstTick(true) {}
- int interval;
- QPauseAnimation pause;
- bool running : 1;
- bool repeating : 1;
- bool triggeredOnStart : 1;
- bool classBegun : 1;
- bool componentComplete : 1;
- bool firstTick : 1;
-};
-
-/*!
- \qmlclass Timer QDeclarative1Timer
- \inqmlmodule QtQuick 1
- \ingroup qml-utility-elements
- \since QtQuick 1.0
- \brief The Timer item triggers a handler at a specified interval.
-
- A Timer can be used to trigger an action either once, or repeatedly
- at a given interval.
-
- Here is a Timer that shows the current date and time, and updates
- the text every 500 milliseconds. It uses the JavaScript \c Date
- object to access the current time.
-
- \qml
- import QtQuick 1.0
-
- Item {
- Timer {
- interval: 500; running: true; repeat: true
- onTriggered: time.text = Date().toString()
- }
-
- Text { id: time }
- }
- \endqml
-
- The Timer element is synchronized with the animation timer. Since the animation
- timer is usually set to 60fps, the resolution of Timer will be
- at best 16ms.
-
- If the Timer is running and one of its properties is changed, the
- elapsed time will be reset. For example, if a Timer with interval of
- 1000ms has its \e repeat property changed 500ms after starting, the
- elapsed time will be reset to 0, and the Timer will be triggered
- 1000ms later.
-
- \sa {declarative/toys/clocks}{Clocks example}
-*/
-
-QDeclarative1Timer::QDeclarative1Timer(QObject *parent)
- : QObject(*(new QDeclarative1TimerPrivate), parent)
-{
- Q_D(QDeclarative1Timer);
- connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked()));
- connect(&d->pause, SIGNAL(finished()), this, SLOT(finished()));
- d->pause.setLoopCount(1);
- d->pause.setDuration(d->interval);
-}
-
-/*!
- \qmlproperty int QtQuick1::Timer::interval
-
- Sets the \a interval between triggers, in milliseconds.
-
- The default interval is 1000 milliseconds.
-*/
-void QDeclarative1Timer::setInterval(int interval)
-{
- Q_D(QDeclarative1Timer);
- if (interval != d->interval) {
- d->interval = interval;
- update();
- emit intervalChanged();
- }
-}
-
-int QDeclarative1Timer::interval() const
-{
- Q_D(const QDeclarative1Timer);
- return d->interval;
-}
-
-/*!
- \qmlproperty bool QtQuick1::Timer::running
-
- If set to true, starts the timer; otherwise stops the timer.
- For a non-repeating timer, \a running is set to false after the
- timer has been triggered.
-
- \a running defaults to false.
-
- \sa repeat
-*/
-bool QDeclarative1Timer::isRunning() const
-{
- Q_D(const QDeclarative1Timer);
- return d->running;
-}
-
-void QDeclarative1Timer::setRunning(bool running)
-{
- Q_D(QDeclarative1Timer);
- if (d->running != running) {
- d->running = running;
- d->firstTick = true;
- emit runningChanged();
- update();
- }
-}
-
-/*!
- \qmlproperty bool QtQuick1::Timer::repeat
-
- If \a repeat is true the timer is triggered repeatedly at the
- specified interval; otherwise, the timer will trigger once at the
- specified interval and then stop (i.e. running will be set to false).
-
- \a repeat defaults to false.
-
- \sa running
-*/
-bool QDeclarative1Timer::isRepeating() const
-{
- Q_D(const QDeclarative1Timer);
- return d->repeating;
-}
-
-void QDeclarative1Timer::setRepeating(bool repeating)
-{
- Q_D(QDeclarative1Timer);
- if (repeating != d->repeating) {
- d->repeating = repeating;
- update();
- emit repeatChanged();
- }
-}
-
-/*!
- \qmlproperty bool QtQuick1::Timer::triggeredOnStart
-
- When a timer is started, the first trigger is usually after the specified
- interval has elapsed. It is sometimes desirable to trigger immediately
- when the timer is started; for example, to establish an initial
- state.
-
- If \a triggeredOnStart is true, the timer is triggered immediately
- when started, and subsequently at the specified interval. Note that if
- \e repeat is set to false, the timer is triggered twice; once on start,
- and again at the interval.
-
- \a triggeredOnStart defaults to false.
-
- \sa running
-*/
-bool QDeclarative1Timer::triggeredOnStart() const
-{
- Q_D(const QDeclarative1Timer);
- return d->triggeredOnStart;
-}
-
-void QDeclarative1Timer::setTriggeredOnStart(bool triggeredOnStart)
-{
- Q_D(QDeclarative1Timer);
- if (d->triggeredOnStart != triggeredOnStart) {
- d->triggeredOnStart = triggeredOnStart;
- update();
- emit triggeredOnStartChanged();
- }
-}
-
-/*!
- \qmlmethod QtQuick1::Timer::start()
- \brief Starts the timer.
-
- If the timer is already running, calling this method has no effect. The
- \c running property will be true following a call to \c start().
-*/
-void QDeclarative1Timer::start()
-{
- setRunning(true);
-}
-
-/*!
- \qmlmethod QtQuick1::Timer::stop()
- \brief Stops the timer.
-
- If the timer is not running, calling this method has no effect. The
- \c running property will be false following a call to \c stop().
-*/
-void QDeclarative1Timer::stop()
-{
- setRunning(false);
-}
-
-/*!
- \qmlmethod QtQuick1::Timer::restart()
- \brief Restarts the timer.
-
- If the Timer is not running it will be started, otherwise it will be
- stopped, reset to initial state and started. The \c running property
- will be true following a call to \c restart().
-*/
-void QDeclarative1Timer::restart()
-{
- setRunning(false);
- setRunning(true);
-}
-
-void QDeclarative1Timer::update()
-{
- Q_D(QDeclarative1Timer);
- if (d->classBegun && !d->componentComplete)
- return;
- d->pause.stop();
- if (d->running) {
- d->pause.setCurrentTime(0);
- d->pause.setLoopCount(d->repeating ? -1 : 1);
- d->pause.setDuration(d->interval);
- d->pause.start();
- if (d->triggeredOnStart && d->firstTick) {
- QCoreApplication::removePostedEvents(this, QEvent::MetaCall);
- QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection);
- }
- }
-}
-
-void QDeclarative1Timer::classBegin()
-{
- Q_D(QDeclarative1Timer);
- d->classBegun = true;
-}
-
-void QDeclarative1Timer::componentComplete()
-{
- Q_D(QDeclarative1Timer);
- d->componentComplete = true;
- update();
-}
-
-/*!
- \qmlsignal QtQuick1::Timer::onTriggered()
-
- This handler is called when the Timer is triggered.
-*/
-void QDeclarative1Timer::ticked()
-{
- Q_D(QDeclarative1Timer);
- if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick)))
- emit triggered();
- d->firstTick = false;
-}
-
-void QDeclarative1Timer::finished()
-{
- Q_D(QDeclarative1Timer);
- if (d->repeating || !d->running)
- return;
- emit triggered();
- d->running = false;
- d->firstTick = false;
- emit runningChanged();
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativetimer_p.h b/src/qtquick1/util/qdeclarativetimer_p.h
deleted file mode 100644
index 1942e72589..0000000000
--- a/src/qtquick1/util/qdeclarativetimer_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETIMER_H
-#define QDECLARATIVETIMER_H
-
-#include <QtDeclarative/qdeclarative.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qabstractanimation.h>
-
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1TimerPrivate;
-class Q_QTQUICK1_EXPORT QDeclarative1Timer : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1Timer)
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
- Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged)
- Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged)
- Q_PROPERTY(QObject *parent READ parent CONSTANT)
-
-public:
- QDeclarative1Timer(QObject *parent=0);
-
- void setInterval(int interval);
- int interval() const;
-
- bool isRunning() const;
- void setRunning(bool running);
-
- bool isRepeating() const;
- void setRepeating(bool repeating);
-
- bool triggeredOnStart() const;
- void setTriggeredOnStart(bool triggeredOnStart);
-
-protected:
- void classBegin();
- void componentComplete();
-
-public Q_SLOTS:
- void start();
- void stop();
- void restart();
-
-Q_SIGNALS:
- void triggered();
- void runningChanged();
- void intervalChanged();
- void repeatChanged();
- void triggeredOnStartChanged();
-
-private:
- void update();
-
-private Q_SLOTS:
- void ticked();
- void finished();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1Timer)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/qtquick1/util/qdeclarativetransition.cpp b/src/qtquick1/util/qdeclarativetransition.cpp
deleted file mode 100644
index ab3fb6cf70..0000000000
--- a/src/qtquick1/util/qdeclarativetransition.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativestate_p.h"
-#include "QtQuick1/private/qdeclarativestategroup_p.h"
-#include "QtQuick1/private/qdeclarativestate_p_p.h"
-#include "QtQuick1/private/qdeclarativestateoperations_p.h"
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-#include "QtQuick1/private/qdeclarativeanimation_p_p.h"
-#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h"
-
-#include <QParallelAnimationGroup>
-
-QT_BEGIN_NAMESPACE
-
-
-
-/*!
- \qmlclass Transition QDeclarative1Transition
- \inqmlmodule QtQuick 1
- \ingroup qml-animation-transition
- \since QtQuick 1.0
- \brief The Transition element defines animated transitions that occur on state changes.
-
- A Transition defines the animations to be applied when a \l State change occurs.
-
- For example, the following \l Rectangle has two states: the default state, and
- an added "moved" state. In the "moved state, the rectangle's position changes
- to (50, 50). The added Transition specifies that when the rectangle
- changes between the default and the "moved" state, any changes
- to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad.
-
- \snippet doc/src/snippets/qtquick1/transition.qml 0
-
- Notice the example does not require \l{PropertyAnimation::}{to} and
- \l{PropertyAnimation::}{from} values for the NumberAnimation. As a convenience,
- these properties are automatically set to the values of \c x and \c y before
- and after the state change; the \c from values are provided by
- the current values of \c x and \c y, and the \c to values are provided by
- the PropertyChanges object. If you wish, you can provide \l{PropertyAnimation::}{to} and
- \l{PropertyAnimation::}{from} values anyway to override the default values.
-
- By default, a Transition's animations are applied for any state change in the
- parent item. The Transition \l {Transition::}{from} and \l {Transition::}{to}
- values can be set to restrict the animations to only be applied when changing
- from one particular state to another.
-
- To define multiple transitions, specify \l Item::transitions as a list:
-
- \snippet doc/src/snippets/qtquick1/transitions-list.qml list of transitions
-
- If multiple Transitions are specified, only a single (best-matching) Transition will be applied for any particular
- state change. In the example above, when changing to \c state1, the first transition will be used, rather
- than the more generic second transition.
-
- If a state change has a Transition that matches the same property as a
- \l Behavior, the Transition animation overrides the \l Behavior for that
- state change.
-
- \sa {QML Animation and Transitions}, {declarative/animation/states}{states example}, {qmlstates}{States}, {QtDeclarative}
-*/
-
-//ParallelAnimationWrapper_1 allows us to do a "callback" when the animation finishes, rather than connecting
-//and disconnecting signals and slots frequently
-class ParallelAnimationWrapper_1 : public QParallelAnimationGroup
-{
- Q_OBJECT
-public:
- ParallelAnimationWrapper_1(QObject *parent = 0) : QParallelAnimationGroup(parent) {}
- QDeclarative1TransitionPrivate *trans;
-protected:
- virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
-};
-
-class QDeclarative1TransitionPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1Transition)
-public:
- QDeclarative1TransitionPrivate()
- : fromState(QLatin1String("*")), toState(QLatin1String("*")),
- reversed(false), reversible(false), endState(0)
- {
- group.trans = this;
- }
-
- QString fromState;
- QString toState;
- bool reversed;
- bool reversible;
- ParallelAnimationWrapper_1 group;
- QDeclarative1TransitionManager *endState;
-
- void complete()
- {
- endState->complete();
- }
- static void append_animation(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list, QDeclarative1AbstractAnimation *a);
- static int animation_count(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list);
- static QDeclarative1AbstractAnimation* animation_at(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list, int pos);
- static void clear_animations(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list);
- QList<QDeclarative1AbstractAnimation *> animations;
-};
-
-void QDeclarative1TransitionPrivate::append_animation(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list, QDeclarative1AbstractAnimation *a)
-{
- QDeclarative1Transition *q = static_cast<QDeclarative1Transition *>(list->object);
- q->d_func()->animations.append(a);
- q->d_func()->group.addAnimation(a->qtAnimation());
- a->setDisableUserControl();
-}
-
-int QDeclarative1TransitionPrivate::animation_count(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list)
-{
- QDeclarative1Transition *q = static_cast<QDeclarative1Transition *>(list->object);
- return q->d_func()->animations.count();
-}
-
-QDeclarative1AbstractAnimation* QDeclarative1TransitionPrivate::animation_at(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list, int pos)
-{
- QDeclarative1Transition *q = static_cast<QDeclarative1Transition *>(list->object);
- return q->d_func()->animations.at(pos);
-}
-
-void QDeclarative1TransitionPrivate::clear_animations(QDeclarativeListProperty<QDeclarative1AbstractAnimation> *list)
-{
- QDeclarative1Transition *q = static_cast<QDeclarative1Transition *>(list->object);
- while (q->d_func()->animations.count()) {
- QDeclarative1AbstractAnimation *firstAnim = q->d_func()->animations.at(0);
- q->d_func()->group.removeAnimation(firstAnim->qtAnimation());
- q->d_func()->animations.removeAll(firstAnim);
- }
-}
-
-void ParallelAnimationWrapper_1::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
-{
- QParallelAnimationGroup::updateState(newState, oldState);
- if (newState == Stopped && (duration() == -1
- || (direction() == QAbstractAnimation::Forward && currentLoopTime() == duration())
- || (direction() == QAbstractAnimation::Backward && currentLoopTime() == 0)))
- {
- trans->complete();
- }
-}
-
-
-
-QDeclarative1Transition::QDeclarative1Transition(QObject *parent)
- : QObject(*(new QDeclarative1TransitionPrivate), parent)
-{
-}
-
-QDeclarative1Transition::~QDeclarative1Transition()
-{
-}
-
-void QDeclarative1Transition::stop()
-{
- Q_D(QDeclarative1Transition);
- d->group.stop();
-}
-
-void QDeclarative1Transition::setReversed(bool r)
-{
- Q_D(QDeclarative1Transition);
- d->reversed = r;
-}
-
-void QDeclarative1Transition::prepare(QDeclarative1StateOperation::ActionList &actions,
- QList<QDeclarativeProperty> &after,
- QDeclarative1TransitionManager *endState)
-{
- Q_D(QDeclarative1Transition);
-
- qmlExecuteDeferred(this);
-
- if (d->reversed) {
- for (int ii = d->animations.count() - 1; ii >= 0; --ii) {
- d->animations.at(ii)->transition(actions, after, QDeclarative1AbstractAnimation::Backward);
- }
- } else {
- for (int ii = 0; ii < d->animations.count(); ++ii) {
- d->animations.at(ii)->transition(actions, after, QDeclarative1AbstractAnimation::Forward);
- }
- }
-
- d->endState = endState;
- d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
- d->group.start();
-}
-
-/*!
- \qmlproperty string QtQuick1::Transition::from
- \qmlproperty string QtQuick1::Transition::to
-
- These properties indicate the state changes that trigger the transition.
-
- The default values for these properties is "*" (that is, any state).
-
- For example, the following transition has not set the \c to and \c from
- properties, so the animation is always applied when changing between
- the two states (i.e. when the mouse is pressed and released).
-
- \snippet doc/src/snippets/qtquick1/transition-from-to.qml 0
-
- If the transition was changed to this:
-
- \snippet doc/src/snippets/qtquick1/transition-from-to-modified.qml modified transition
-
- The animation would only be applied when changing from the default state to
- the "brighter" state (i.e. when the mouse is pressed, but not on release).
-
- Multiple \c to and \from values can be set by using a comma-separated string.
-
- \sa reversible
-*/
-QString QDeclarative1Transition::fromState() const
-{
- Q_D(const QDeclarative1Transition);
- return d->fromState;
-}
-
-void QDeclarative1Transition::setFromState(const QString &f)
-{
- Q_D(QDeclarative1Transition);
- if (f == d->fromState)
- return;
-
- d->fromState = f;
- emit fromChanged();
-}
-
-/*!
- \qmlproperty bool QtQuick1::Transition::reversible
- This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed.
-
- The default value is false.
-
- By default, transitions run in parallel and are applied to all state
- changes if the \l from and \l to states have not been set. In this
- situation, the transition is automatically applied when a state change
- is reversed, and it is not necessary to set this property to reverse
- the transition.
-
- However, if a SequentialAnimation is used, or if the \l from or \l to
- properties have been set, this property will need to be set to reverse
- a transition when a state change is reverted. For example, the following
- transition applies a sequential animation when the mouse is pressed,
- and reverses the sequence of the animation when the mouse is released:
-
- \snippet doc/src/snippets/qtquick1/transition-reversible.qml 0
-
- If the transition did not set the \c to and \c reversible values, then
- on the mouse release, the transition would play the PropertyAnimation
- before the ColorAnimation instead of reversing the sequence.
-*/
-bool QDeclarative1Transition::reversible() const
-{
- Q_D(const QDeclarative1Transition);
- return d->reversible;
-}
-
-void QDeclarative1Transition::setReversible(bool r)
-{
- Q_D(QDeclarative1Transition);
- if (r == d->reversible)
- return;
-
- d->reversible = r;
- emit reversibleChanged();
-}
-
-QString QDeclarative1Transition::toState() const
-{
- Q_D(const QDeclarative1Transition);
- return d->toState;
-}
-
-void QDeclarative1Transition::setToState(const QString &t)
-{
- Q_D(QDeclarative1Transition);
- if (t == d->toState)
- return;
-
- d->toState = t;
- emit toChanged();
-}
-
-/*!
- \qmlproperty list<Animation> QtQuick1::Transition::animations
- \default
-
- This property holds a list of the animations to be run for this transition.
-
- \snippet examples/declarative/toys/dynamicscene/dynamicscene.qml top-level transitions
-
- The top-level animations are run in parallel. To run them sequentially,
- define them within a SequentialAnimation:
-
- \snippet doc/src/snippets/qtquick1/transition-reversible.qml sequential animations
-*/
-QDeclarativeListProperty<QDeclarative1AbstractAnimation> QDeclarative1Transition::animations()
-{
- Q_D(QDeclarative1Transition);
- return QDeclarativeListProperty<QDeclarative1AbstractAnimation>(this, &d->animations, QDeclarative1TransitionPrivate::append_animation,
- QDeclarative1TransitionPrivate::animation_count,
- QDeclarative1TransitionPrivate::animation_at,
- QDeclarative1TransitionPrivate::clear_animations);
-}
-
-
-
-QT_END_NAMESPACE
-
-#include <qdeclarativetransition.moc>
diff --git a/src/qtquick1/util/qdeclarativetransition_p.h b/src/qtquick1/util/qdeclarativetransition_p.h
deleted file mode 100644
index c87aa70071..0000000000
--- a/src/qtquick1/util/qdeclarativetransition_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETRANSITION_H
-#define QDECLARATIVETRANSITION_H
-
-#include "QtQuick1/private/qdeclarativestate_p.h"
-
-#include <QtDeclarative/qdeclarative.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1AbstractAnimation;
-class QDeclarative1TransitionPrivate;
-class QDeclarative1TransitionManager;
-class Q_QTQUICK1_EXPORT QDeclarative1Transition : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarative1Transition)
-
- Q_PROPERTY(QString from READ fromState WRITE setFromState NOTIFY fromChanged)
- Q_PROPERTY(QString to READ toState WRITE setToState NOTIFY toChanged)
- Q_PROPERTY(bool reversible READ reversible WRITE setReversible NOTIFY reversibleChanged)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarative1AbstractAnimation> animations READ animations)
- Q_CLASSINFO("DefaultProperty", "animations")
- Q_CLASSINFO("DeferredPropertyNames", "animations")
-
-public:
- QDeclarative1Transition(QObject *parent=0);
- ~QDeclarative1Transition();
-
- QString fromState() const;
- void setFromState(const QString &);
-
- QString toState() const;
- void setToState(const QString &);
-
- bool reversible() const;
- void setReversible(bool);
-
- QDeclarativeListProperty<QDeclarative1AbstractAnimation> animations();
-
- void prepare(QDeclarative1StateOperation::ActionList &actions,
- QList<QDeclarativeProperty> &after,
- QDeclarative1TransitionManager *end);
-
- void setReversed(bool r);
- void stop();
-
-Q_SIGNALS:
- void fromChanged();
- void toChanged();
- void reversibleChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1Transition)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVETRANSITION_H
diff --git a/src/qtquick1/util/qdeclarativetransitionmanager.cpp b/src/qtquick1/util/qdeclarativetransitionmanager.cpp
deleted file mode 100644
index 8487909c86..0000000000
--- a/src/qtquick1/util/qdeclarativetransitionmanager.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h"
-
-#include "QtQuick1/private/qdeclarativestate_p_p.h"
-#include "QtQuick1/private/qdeclarativestate_p.h"
-
-#include <QtDeclarative/private/qdeclarativebinding_p.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-class QDeclarative1TransitionManagerPrivate
-{
-public:
- QDeclarative1TransitionManagerPrivate()
- : state(0) {}
-
- void applyBindings();
- typedef QList<QDeclarative1SimpleAction> SimpleActionList;
- QDeclarative1State *state;
- QDeclarativeGuard<QDeclarative1Transition> transition;
- QDeclarative1StateOperation::ActionList bindingsList;
- SimpleActionList completeList;
-};
-
-QDeclarative1TransitionManager::QDeclarative1TransitionManager()
-: d(new QDeclarative1TransitionManagerPrivate)
-{
-}
-
-void QDeclarative1TransitionManager::setState(QDeclarative1State *s)
-{
- d->state = s;
-}
-
-QDeclarative1TransitionManager::~QDeclarative1TransitionManager()
-{
- delete d; d = 0;
-}
-
-void QDeclarative1TransitionManager::complete()
-{
- d->applyBindings();
-
- for (int ii = 0; ii < d->completeList.count(); ++ii) {
- const QDeclarativeProperty &prop = d->completeList.at(ii).property();
- prop.write(d->completeList.at(ii).value());
- }
-
- d->completeList.clear();
-
- if (d->state)
- static_cast<QDeclarative1StatePrivate*>(QObjectPrivate::get(d->state))->complete();
-}
-
-void QDeclarative1TransitionManagerPrivate::applyBindings()
-{
- foreach(const QDeclarative1Action &action, bindingsList) {
- if (!action.toBinding.isNull()) {
- QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data());
- } else if (action.event) {
- if (action.reverseEvent)
- action.event->reverse();
- else
- action.event->execute();
- }
-
- }
-
- bindingsList.clear();
-}
-
-void QDeclarative1TransitionManager::transition(const QList<QDeclarative1Action> &list,
- QDeclarative1Transition *transition)
-{
- cancel();
-
- QDeclarative1StateOperation::ActionList applyList = list;
- // Determine which actions are binding changes.
- foreach(const QDeclarative1Action &action, applyList) {
- if (action.toBinding)
- d->bindingsList << action;
- if (action.fromBinding)
- QDeclarativePropertyPrivate::setBinding(action.property, 0); // Disable current binding
- if (action.event && action.event->changesBindings()) { //### assume isReversable()?
- d->bindingsList << action;
- action.event->clearBindings();
- }
- }
-
- // Animated transitions need both the start and the end value for
- // each property change. In the presence of bindings, the end values
- // are non-trivial to calculate. As a "best effort" attempt, we first
- // apply all the property and binding changes, then read all the actual
- // final values, then roll back the changes and proceed as normal.
- //
- // This doesn't catch everything, and it might be a little fragile in
- // some cases - but whatcha going to do?
-
- if (!d->bindingsList.isEmpty()) {
-
- // Apply all the property and binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- const QDeclarative1Action &action = applyList.at(ii);
- if (!action.toBinding.isNull()) {
- QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- } else if (!action.event) {
- QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- } else if (action.event->isReversable()) {
- if (action.reverseEvent)
- action.event->reverse(QDeclarative1ActionEvent::FastForward);
- else
- action.event->execute(QDeclarative1ActionEvent::FastForward);
- }
- }
-
- // Read all the end values for binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- QDeclarative1Action *action = &applyList[ii];
- if (action->event) {
- action->event->saveTargetValues();
- continue;
- }
- const QDeclarativeProperty &prop = action->property;
- if (!action->toBinding.isNull() || !action->toValue.isValid()) {
- action->toValue = prop.read();
- }
- }
-
- // Revert back to the original values
- foreach(const QDeclarative1Action &action, applyList) {
- if (action.event) {
- if (action.event->isReversable()) {
- action.event->clearBindings();
- action.event->rewind();
- action.event->clearBindings(); //### shouldn't be needed
- }
- continue;
- }
-
- if (action.toBinding)
- QDeclarativePropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition
-
- QDeclarativePropertyPrivate::write(action.property, action.fromValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
- }
- }
-
- if (transition) {
- QList<QDeclarativeProperty> touched;
- d->transition = transition;
- d->transition->prepare(applyList, touched, this);
-
- // Modify the action list to remove actions handled in the transition
- for (int ii = 0; ii < applyList.count(); ++ii) {
- const QDeclarative1Action &action = applyList.at(ii);
-
- if (action.event) {
-
- if (action.actionDone) {
- applyList.removeAt(ii);
- --ii;
- }
-
- } else {
-
- if (touched.contains(action.property)) {
- if (action.toValue != action.fromValue)
- d->completeList <<
- QDeclarative1SimpleAction(action, QDeclarative1SimpleAction::EndState);
-
- applyList.removeAt(ii);
- --ii;
- }
-
- }
- }
- }
-
- // Any actions remaining have not been handled by the transition and should
- // be applied immediately. We skip applying bindings, as they are all
- // applied at the end in applyBindings() to avoid any nastiness mid
- // transition
- foreach(const QDeclarative1Action &action, applyList) {
- if (action.event && !action.event->changesBindings()) {
- if (action.event->isReversable() && action.reverseEvent)
- action.event->reverse();
- else
- action.event->execute();
- } else if (!action.event && !action.toBinding) {
- action.property.write(action.toValue);
- }
- }
-#ifndef QT_NO_DEBUG_STREAM
- if (stateChangeDebug()) {
- foreach(const QDeclarative1Action &action, applyList) {
- if (action.event)
- qWarning() << " No transition for event:" << action.event->typeName();
- else
- qWarning() << " No transition for:" << action.property.object()
- << action.property.name() << "From:" << action.fromValue
- << "To:" << action.toValue;
- }
- }
-#endif
- if (!transition)
- d->applyBindings();
-}
-
-void QDeclarative1TransitionManager::cancel()
-{
- if (d->transition) {
- // ### this could potentially trigger a complete in rare circumstances
- d->transition->stop();
- d->transition = 0;
- }
-
- for(int i = 0; i < d->bindingsList.count(); ++i) {
- QDeclarative1Action action = d->bindingsList[i];
- if (!action.toBinding.isNull() && action.deletableToBinding) {
- QDeclarativePropertyPrivate::setBinding(action.property, 0);
- action.toBinding.data()->destroy();
- action.toBinding.clear();
- action.deletableToBinding = false;
- } else if (action.event) {
- //### what do we do here?
- }
-
- }
- d->bindingsList.clear();
- d->completeList.clear();
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h b/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h
deleted file mode 100644
index 948627b7e9..0000000000
--- a/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVETRANSITIONMANAGER_P_H
-#define QDECLARATIVETRANSITIONMANAGER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtQuick1/private/qdeclarativestateoperations_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarative1StatePrivate;
-class QDeclarative1TransitionManagerPrivate;
-class Q_AUTOTEST_EXPORT QDeclarative1TransitionManager
-{
-public:
- QDeclarative1TransitionManager();
- ~QDeclarative1TransitionManager();
-
- void transition(const QList<QDeclarative1Action> &, QDeclarative1Transition *transition);
-
- void cancel();
-
-private:
- Q_DISABLE_COPY(QDeclarative1TransitionManager)
- QDeclarative1TransitionManagerPrivate *d;
-
- void complete();
- void setState(QDeclarative1State *);
-
- friend class QDeclarative1State;
- friend class QDeclarative1TransitionPrivate;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVETRANSITIONMANAGER_P_H
diff --git a/src/qtquick1/util/qdeclarativeutilmodule.cpp b/src/qtquick1/util/qdeclarativeutilmodule.cpp
deleted file mode 100644
index 895b727f50..0000000000
--- a/src/qtquick1/util/qdeclarativeutilmodule.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativeutilmodule_p.h"
-#include "QtQuick1/private/qdeclarativeanimation_p.h"
-#include "QtQuick1/private/qdeclarativeanimation_p_p.h"
-#include "QtQuick1/private/qdeclarativebehavior_p.h"
-#include "QtQuick1/private/qdeclarativebind_p.h"
-#include "QtQuick1/private/qdeclarativeconnections_p.h"
-#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h"
-#include "QtQuick1/private/qdeclarativefontloader_p.h"
-#include "QtQuick1/private/qdeclarativelistaccessor_p.h"
-//#include "QtQuick1/private/qdeclarativelistmodel_p.h"
-#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h"
-#include "QtQuick1/private/qdeclarativepackage_p.h"
-#include "QtQuick1/private/qdeclarativepixmapcache_p.h"
-#include "QtQuick1/private/qdeclarativepropertychanges_p.h"
-#include "QtQuick1/private/qdeclarativespringanimation_p.h"
-#include "QtQuick1/private/qdeclarativestategroup_p.h"
-#include "QtQuick1/private/qdeclarativestateoperations_p.h"
-#include "QtQuick1/private/qdeclarativestate_p.h"
-#include "QtQuick1/private/qdeclarativestate_p_p.h"
-#include "QtQuick1/private/qdeclarativestyledtext_p.h"
-#include "QtQuick1/private/qdeclarativesystempalette_p.h"
-#include "QtQuick1/private/qdeclarativetimeline_p_p.h"
-#include "QtQuick1/private/qdeclarativetimer_p.h"
-#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h"
-#include "QtQuick1/private/qdeclarativetransition_p.h"
-#include "QtQuick1/private/qdeclarativeapplication_p.h"
-#include "QtQuick1/qdeclarativeview.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
-#include <QtDeclarative/private/qdeclarativetypenotavailable_p.h>
-#ifndef QT_NO_XMLPATTERNS
-#include "QtQuick1/private/qdeclarativexmllistmodel_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-void QDeclarative1UtilModule::defineModule(QDeclarativeQtQuick1Module::Module module)
-{
- qmlRegisterType<QDeclarative1Anchors>();
- qmlRegisterType<QDeclarative1StateOperation>();
- qmlRegisterType<QDeclarative1AnchorSet>();
-
- if (module == QDeclarativeQtQuick1Module::QtQuick1) {
- qmlRegisterUncreatableType<QDeclarative1Application>("QtQuick",1,1,"Application", QDeclarative1Application::tr("Application is an abstract class"));
-
- qmlRegisterType<QDeclarative1AnchorAnimation>("QtQuick",1,0,"AnchorAnimation");
- qmlRegisterType<QDeclarative1AnchorChanges>("QtQuick",1,0,"AnchorChanges");
- qmlRegisterType<QDeclarative1Behavior>("QtQuick",1,0,"Behavior");
- qmlRegisterType<QDeclarative1Bind>("QtQuick",1,0,"Binding");
- qmlRegisterType<QDeclarative1ColorAnimation>("QtQuick",1,0,"ColorAnimation");
- qmlRegisterType<QDeclarative1Connections>("QtQuick",1,0,"Connections");
- qmlRegisterType<QDeclarative1SmoothedAnimation>("QtQuick",1,0,"SmoothedAnimation");
- qmlRegisterType<QDeclarative1FontLoader>("QtQuick",1,0,"FontLoader");
- // qmlRegisterType<QDeclarative1ListElement>("QtQuick",1,0,"ListElement");
- qmlRegisterType<QDeclarative1NumberAnimation>("QtQuick",1,0,"NumberAnimation");
- qmlRegisterType<QDeclarative1Package>("QtQuick",1,0,"Package");
- qmlRegisterType<QDeclarative1ParallelAnimation>("QtQuick",1,0,"ParallelAnimation");
- qmlRegisterType<QDeclarative1ParentAnimation>("QtQuick",1,0,"ParentAnimation");
- qmlRegisterType<QDeclarative1ParentChange>("QtQuick",1,0,"ParentChange");
- qmlRegisterType<QDeclarative1PauseAnimation>("QtQuick",1,0,"PauseAnimation");
- qmlRegisterType<QDeclarative1PropertyAction>("QtQuick",1,0,"PropertyAction");
- qmlRegisterType<QDeclarative1PropertyAnimation>("QtQuick",1,0,"PropertyAnimation");
- qmlRegisterType<QDeclarative1RotationAnimation>("QtQuick",1,0,"RotationAnimation");
- qmlRegisterType<QDeclarative1ScriptAction>("QtQuick",1,0,"ScriptAction");
- qmlRegisterType<QDeclarative1SequentialAnimation>("QtQuick",1,0,"SequentialAnimation");
- qmlRegisterType<QDeclarative1SpringAnimation>("QtQuick",1,0,"SpringAnimation");
- qmlRegisterType<QDeclarative1StateChangeScript>("QtQuick",1,0,"StateChangeScript");
- qmlRegisterType<QDeclarative1StateGroup>("QtQuick",1,0,"StateGroup");
- qmlRegisterType<QDeclarative1State>("QtQuick",1,0,"State");
- qmlRegisterType<QDeclarative1SystemPalette>("QtQuick",1,0,"SystemPalette");
- qmlRegisterType<QDeclarative1Timer>("QtQuick",1,0,"Timer");
- qmlRegisterType<QDeclarative1Transition>("QtQuick",1,0,"Transition");
- qmlRegisterType<QDeclarative1Vector3dAnimation>("QtQuick",1,0,"Vector3dAnimation");
-#ifdef QT_NO_XMLPATTERNS
- qmlRegisterTypeNotAvailable("QtQuick",1,0,"XmlListModel",
- qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns"));
- qmlRegisterTypeNotAvailable("QtQuick",1,0,"XmlRole",
- qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns"));
-#else
- qmlRegisterType<QDeclarative1XmlListModel>("QtQuick",1,0,"XmlListModel");
- qmlRegisterType<QDeclarative1XmlListModelRole>("QtQuick",1,0,"XmlRole");
-#endif
-
-
- qmlRegisterUncreatableType<QDeclarative1AbstractAnimation>("QtQuick",1,0,"Animation",QDeclarative1AbstractAnimation::tr("Animation is an abstract class"));
-
- // qmlRegisterCustomType<QDeclarative1ListModel>("QtQuick",1,0,"ListModel", new QDeclarative1ListModelParser);
- qmlRegisterCustomType<QDeclarative1PropertyChanges>("QtQuick",1,0,"PropertyChanges", new QDeclarative1PropertyChangesParser);
- qmlRegisterCustomType<QDeclarative1Connections>("QtQuick",1,0,"Connections", new QDeclarative1ConnectionsParser);
- } else if (module == QDeclarativeQtQuick1Module::Qt47) {
- qmlRegisterType<QDeclarative1AnchorAnimation>("Qt",4,7,"AnchorAnimation");
- qmlRegisterType<QDeclarative1AnchorChanges>("Qt",4,7,"AnchorChanges");
- qmlRegisterType<QDeclarative1Behavior>("Qt",4,7,"Behavior");
- qmlRegisterType<QDeclarative1Bind>("Qt",4,7,"Binding");
- qmlRegisterType<QDeclarative1ColorAnimation>("Qt",4,7,"ColorAnimation");
- qmlRegisterType<QDeclarative1Connections>("Qt",4,7,"Connections");
- qmlRegisterType<QDeclarative1SmoothedAnimation>("Qt",4,7,"SmoothedAnimation");
- qmlRegisterType<QDeclarative1FontLoader>("Qt",4,7,"FontLoader");
- // qmlRegisterType<QDeclarative1ListElement>("Qt",4,7,"ListElement");
- qmlRegisterType<QDeclarative1NumberAnimation>("Qt",4,7,"NumberAnimation");
- qmlRegisterType<QDeclarative1Package>("Qt",4,7,"Package");
- qmlRegisterType<QDeclarative1ParallelAnimation>("Qt",4,7,"ParallelAnimation");
- qmlRegisterType<QDeclarative1ParentAnimation>("Qt",4,7,"ParentAnimation");
- qmlRegisterType<QDeclarative1ParentChange>("Qt",4,7,"ParentChange");
- qmlRegisterType<QDeclarative1PauseAnimation>("Qt",4,7,"PauseAnimation");
- qmlRegisterType<QDeclarative1PropertyAction>("Qt",4,7,"PropertyAction");
- qmlRegisterType<QDeclarative1PropertyAnimation>("Qt",4,7,"PropertyAnimation");
- qmlRegisterType<QDeclarative1RotationAnimation>("Qt",4,7,"RotationAnimation");
- qmlRegisterType<QDeclarative1ScriptAction>("Qt",4,7,"ScriptAction");
- qmlRegisterType<QDeclarative1SequentialAnimation>("Qt",4,7,"SequentialAnimation");
- qmlRegisterType<QDeclarative1SpringAnimation>("Qt",4,7,"SpringAnimation");
- qmlRegisterType<QDeclarative1StateChangeScript>("Qt",4,7,"StateChangeScript");
- qmlRegisterType<QDeclarative1StateGroup>("Qt",4,7,"StateGroup");
- qmlRegisterType<QDeclarative1State>("Qt",4,7,"State");
- qmlRegisterType<QDeclarative1SystemPalette>("Qt",4,7,"SystemPalette");
- qmlRegisterType<QDeclarative1Timer>("Qt",4,7,"Timer");
- qmlRegisterType<QDeclarative1Transition>("Qt",4,7,"Transition");
- qmlRegisterType<QDeclarative1Vector3dAnimation>("Qt",4,7,"Vector3dAnimation");
-#ifdef QT_NO_XMLPATTERNS
- qmlRegisterTypeNotAvailable("Qt",4,7,"XmlListModel",
- qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns"));
- qmlRegisterTypeNotAvailable("Qt",4,7,"XmlRole",
- qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns"));
-#else
- qmlRegisterType<QDeclarative1XmlListModel>("Qt",4,7,"XmlListModel");
- qmlRegisterType<QDeclarative1XmlListModelRole>("Qt",4,7,"XmlRole");
-#endif
-
- qmlRegisterUncreatableType<QDeclarative1AbstractAnimation>("Qt",4,7,"Animation",QDeclarative1AbstractAnimation::tr("Animation is an abstract class"));
-
- // qmlRegisterCustomType<QDeclarative1ListModel>("Qt", 4,7, "ListModel", new QDeclarative1ListModelParser);
- qmlRegisterCustomType<QDeclarative1PropertyChanges>("Qt", 4, 7, "PropertyChanges", new QDeclarative1PropertyChangesParser);
- qmlRegisterCustomType<QDeclarative1Connections>("Qt", 4, 7, "Connections", new QDeclarative1ConnectionsParser);
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/qtquick1/util/qdeclarativeutilmodule_p.h b/src/qtquick1/util/qdeclarativeutilmodule_p.h
deleted file mode 100644
index ae98c6bcea..0000000000
--- a/src/qtquick1/util/qdeclarativeutilmodule_p.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEUTILMODULE_H
-#define QDECLARATIVEUTILMODULE_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include "../qtquick1_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarative1UtilModule
-{
-public:
- static void defineModule(QDeclarativeQtQuick1Module::Module module);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEUTILMODULE_H
diff --git a/src/qtquick1/util/qdeclarativeview.cpp b/src/qtquick1/util/qdeclarativeview.cpp
deleted file mode 100644
index 0c8637d642..0000000000
--- a/src/qtquick1/util/qdeclarativeview.cpp
+++ /dev/null
@@ -1,752 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/qdeclarativeview.h"
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/private/qdeclarativeglobal_p.h>
-#include <QtDeclarative/private/qdeclarativeguard_p.h>
-
-#include <QtDeclarative/private/qdeclarativedebugtrace_p.h>
-#include <QtDeclarative/private/qdeclarativeinspectorservice_p.h>
-
-#include <qdebug.h>
-#include <qtimer.h>
-#include <qevent.h>
-#include <qdir.h>
-#include <qcoreapplication.h>
-#include <qfontdatabase.h>
-#include <qicon.h>
-#include <qurl.h>
-#include <qlayout.h>
-#include <qwidget.h>
-#include <qgraphicswidget.h>
-#include <qbasictimer.h>
-#include <QtCore/qabstractanimation.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-#include <QtWidgets/private/qgraphicsview_p.h>
-#include <private/qabstractanimation_p.h>
-#include <QtQuick1/private/qdeclarativeitemchangelistener_p.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE)
-
-class QDeclarative1Scene : public QGraphicsScene
-{
-public:
- QDeclarative1Scene(QObject *parent = 0);
-
-protected:
- virtual void keyPressEvent(QKeyEvent *);
- virtual void keyReleaseEvent(QKeyEvent *);
-
- virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
- virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
- virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
-};
-
-QDeclarative1Scene::QDeclarative1Scene(QObject *parent) : QGraphicsScene(parent)
-{
-}
-
-void QDeclarative1Scene::keyPressEvent(QKeyEvent *e)
-{
- QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Key);
-
- QGraphicsScene::keyPressEvent(e);
-}
-
-void QDeclarative1Scene::keyReleaseEvent(QKeyEvent *e)
-{
- QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Key);
-
- QGraphicsScene::keyReleaseEvent(e);
-}
-
-void QDeclarative1Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
-{
- QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse);
-
- QGraphicsScene::mouseMoveEvent(e);
-}
-
-void QDeclarative1Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
-{
- QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse);
-
- QGraphicsScene::mousePressEvent(e);
-}
-
-void QDeclarative1Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
-{
- QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse);
-
- QGraphicsScene::mouseReleaseEvent(e);
-}
-
-class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarativeItemChangeListener
-{
- Q_DECLARE_PUBLIC(QDeclarativeView)
-public:
- QDeclarativeViewPrivate()
- : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0),
- resizeMode(QDeclarativeView::SizeViewToRootObject), initialSize(0,0) {}
- ~QDeclarativeViewPrivate() { delete root; delete engine; }
- void execute();
- void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
- void initResize();
- void updateSize();
- inline QSize rootObjectSize() const;
-
- QDeclarativeGuard<QGraphicsObject> root;
- QDeclarativeGuard<QDeclarativeItem> declarativeItemRoot;
- QDeclarativeGuard<QGraphicsWidget> graphicsWidgetRoot;
-
- QUrl source;
-
- QDeclarativeEngine* engine;
- QDeclarativeComponent *component;
- QBasicTimer resizetimer;
-
- QDeclarativeView::ResizeMode resizeMode;
- QSize initialSize;
- QElapsedTimer frameTimer;
-
- void init();
-};
-
-void QDeclarativeViewPrivate::execute()
-{
- Q_Q(QDeclarativeView);
- if (root) {
- delete root;
- root = 0;
- }
- if (component) {
- delete component;
- component = 0;
- }
- if (!source.isEmpty()) {
- component = new QDeclarativeComponent(engine, source, q);
- if (!component->isLoading()) {
- q->continueExecute();
- } else {
- QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), q, SLOT(continueExecute()));
- }
- }
-}
-
-void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- Q_Q(QDeclarativeView);
- if (resizeItem == root && resizeMode == QDeclarativeView::SizeViewToRootObject) {
- // wait for both width and height to be changed
- resizetimer.start(0,q);
- }
- QDeclarativeItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry);
-}
-
-/*!
- \class QDeclarativeView
- \since QtQuick 1.0
- \brief The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface.
-
- QDeclarativeItem objects can be placed on a standard QGraphicsScene and
- displayed with QGraphicsView. QDeclarativeView is a QGraphicsView subclass
- provided as a convenience for displaying QML files, and connecting between
- QML and C++ Qt objects.
-
- QDeclarativeView provides:
-
- \list
- \o Management of QDeclarativeComponent loading and object creation
- \o Initialization of QGraphicsView for optimal performance with QML using these settings:
- \list
- \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState)
- \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate)
- \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex)
- \endlist
- \o Initialization of QGraphicsView for QML key handling using these settings:
- \list
- \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus)
- \o QGraphicsView::setFocusPolicy(Qt::StrongFocus)
- \o QGraphicsScene::setStickyFocus(true)
- \endlist
- \endlist
-
- Typical usage:
-
- \code
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile("myqmlfile.qml"));
- view->show();
- \endcode
-
- Since QDeclarativeView is a QWidget-based class, it can be used to
- display QML interfaces within QWidget-based GUI applications that do not
- use the Graphics View framework.
-
- To receive errors related to loading and executing QML with QDeclarativeView,
- you can connect to the statusChanged() signal and monitor for QDeclarativeView::Error.
- The errors are available via QDeclarativeView::errors().
-
- If you're using your own QGraphicsScene-based scene with QDeclarativeView, remember to
- enable scene's sticky focus mode and to set itemIndexMethod to QGraphicsScene::NoIndex.
-
- \sa {Integrating QML Code with Existing Qt UI Code}, {Using QML Bindings in C++ Applications}
-*/
-
-
-/*! \fn void QDeclarativeView::sceneResized(QSize size)
- This signal is emitted when the view is resized to \a size.
-*/
-
-/*! \fn void QDeclarativeView::statusChanged(QDeclarativeView::Status status)
- This signal is emitted when the component's current \a status changes.
-*/
-
-/*! \fn void QDeclarativeView::initialSizeChanged(QSize size)
- \internal
-*/
-
-/*!
- \fn QDeclarativeView::QDeclarativeView(QWidget *parent)
-
- Constructs a QDeclarativeView with the given \a parent.
-*/
-QDeclarativeView::QDeclarativeView(QWidget *parent)
- : QGraphicsView(*(new QDeclarativeViewPrivate), parent)
-{
- Q_D(QDeclarativeView);
- setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
- d->init();
-}
-
-/*!
- \fn QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent)
-
- Constructs a QDeclarativeView with the given QML \a source and \a parent.
-*/
-QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent)
- : QGraphicsView(*(new QDeclarativeViewPrivate), parent)
-{
- Q_D(QDeclarativeView);
- setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
- d->init();
- setSource(source);
-}
-
-void QDeclarativeViewPrivate::init()
-{
- Q_Q(QDeclarativeView);
- engine = new QDeclarativeEngine();
- q->setScene(new QDeclarative1Scene(q));
-
- q->setOptimizationFlags(QGraphicsView::DontSavePainterState);
- q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- q->setFrameStyle(0);
-
- // These seem to give the best performance
- q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- q->scene()->setItemIndexMethod(QGraphicsScene::NoIndex);
- q->viewport()->setFocusPolicy(Qt::NoFocus);
- q->setFocusPolicy(Qt::StrongFocus);
-
- q->scene()->setStickyFocus(true); //### needed for correct focus handling
-
-#ifdef QDECLARATIVEVIEW_NOBACKGROUND
- q->setAttribute(Qt::WA_OpaquePaintEvent);
- q->setAttribute(Qt::WA_NoSystemBackground);
- q->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
- q->viewport()->setAttribute(Qt::WA_NoSystemBackground);
-#endif
-
- if (QDeclarativeDebugService::isDebuggingEnabled())
- QDeclarativeInspectorService::instance()->addView(q);
-}
-
-/*!
- Destroys the view.
- */
-QDeclarativeView::~QDeclarativeView()
-{
- if (QDeclarativeDebugService::isDebuggingEnabled())
- QDeclarativeInspectorService::instance()->removeView(this);
-}
-
-/*! \property QDeclarativeView::source
- \brief The URL of the source of the QML component.
-
- Changing this property causes the QML component to be reloaded.
-
- Ensure that the URL provided is full and correct, in particular, use
- \l QUrl::fromLocalFile() when loading a file from the local filesystem.
- */
-
-/*!
- Sets the source to the \a url, loads the QML component and instantiates it.
-
- Ensure that the URL provided is full and correct, in particular, use
- \l QUrl::fromLocalFile() when loading a file from the local filesystem.
-
- Calling this methods multiple times with the same url will result
- in the QML being reloaded.
- */
-void QDeclarativeView::setSource(const QUrl& url)
-{
- Q_D(QDeclarativeView);
- d->source = url;
- d->execute();
-}
-
-/*!
- Returns the source URL, if set.
-
- \sa setSource()
- */
-QUrl QDeclarativeView::source() const
-{
- Q_D(const QDeclarativeView);
- return d->source;
-}
-
-/*!
- Returns a pointer to the QDeclarativeEngine used for instantiating
- QML Components.
- */
-QDeclarativeEngine* QDeclarativeView::engine() const
-{
- Q_D(const QDeclarativeView);
- return d->engine;
-}
-
-/*!
- This function returns the root of the context hierarchy. Each QML
- component is instantiated in a QDeclarativeContext. QDeclarativeContext's are
- essential for passing data to QML components. In QML, contexts are
- arranged hierarchically and this hierarchy is managed by the
- QDeclarativeEngine.
- */
-QDeclarativeContext* QDeclarativeView::rootContext() const
-{
- Q_D(const QDeclarativeView);
- return d->engine->rootContext();
-}
-
-/*!
- \enum QDeclarativeView::Status
- Specifies the loading status of the QDeclarativeView.
-
- \value Null This QDeclarativeView has no source set.
- \value Ready This QDeclarativeView has loaded and created the QML component.
- \value Loading This QDeclarativeView is loading network data.
- \value Error One or more errors has occurred. Call errors() to retrieve a list
- of errors.
-*/
-
-/*! \enum QDeclarativeView::ResizeMode
-
- This enum specifies how to resize the view.
-
- \value SizeViewToRootObject The view resizes with the root item in the QML.
- \value SizeRootObjectToView The view will automatically resize the root item to the size of the view.
-*/
-
-/*!
- \property QDeclarativeView::status
- The component's current \l{QDeclarativeView::Status} {status}.
-*/
-
-QDeclarativeView::Status QDeclarativeView::status() const
-{
- Q_D(const QDeclarativeView);
- if (!d->component)
- return QDeclarativeView::Null;
-
- return QDeclarativeView::Status(d->component->status());
-}
-
-/*!
- Return the list of errors that occurred during the last compile or create
- operation. When the status is not Error, an empty list is returned.
-*/
-QList<QDeclarativeError> QDeclarativeView::errors() const
-{
- Q_D(const QDeclarativeView);
- if (d->component)
- return d->component->errors();
- return QList<QDeclarativeError>();
-}
-
-/*!
- \property QDeclarativeView::resizeMode
- \brief whether the view should resize the canvas contents
-
- If this property is set to SizeViewToRootObject (the default), the view
- resizes with the root item in the QML.
-
- If this property is set to SizeRootObjectToView, the view will
- automatically resize the root item.
-
- Regardless of this property, the sizeHint of the view
- is the initial size of the root item. Note though that
- since QML may load dynamically, that size may change.
-*/
-
-void QDeclarativeView::setResizeMode(ResizeMode mode)
-{
- Q_D(QDeclarativeView);
- if (d->resizeMode == mode)
- return;
-
- if (d->declarativeItemRoot) {
- if (d->resizeMode == SizeViewToRootObject) {
- QDeclarativeItemPrivate *p =
- static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(d->declarativeItemRoot));
- p->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry);
- }
- } else if (d->graphicsWidgetRoot) {
- if (d->resizeMode == QDeclarativeView::SizeViewToRootObject) {
- d->graphicsWidgetRoot->removeEventFilter(this);
- }
- }
-
- d->resizeMode = mode;
- if (d->root) {
- d->initResize();
- }
-}
-
-void QDeclarativeViewPrivate::initResize()
-{
- Q_Q(QDeclarativeView);
- if (declarativeItemRoot) {
- if (resizeMode == QDeclarativeView::SizeViewToRootObject) {
- QDeclarativeItemPrivate *p =
- static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(declarativeItemRoot));
- p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
- }
- } else if (graphicsWidgetRoot) {
- if (resizeMode == QDeclarativeView::SizeViewToRootObject) {
- graphicsWidgetRoot->installEventFilter(q);
- }
- }
- updateSize();
-}
-
-void QDeclarativeViewPrivate::updateSize()
-{
- Q_Q(QDeclarativeView);
- if (!root)
- return;
- if (declarativeItemRoot) {
- if (resizeMode == QDeclarativeView::SizeViewToRootObject) {
- QSize newSize = QSize(declarativeItemRoot->width(), declarativeItemRoot->height());
- if (newSize.isValid() && newSize != q->size()) {
- q->resize(newSize);
- }
- } else if (resizeMode == QDeclarativeView::SizeRootObjectToView) {
- if (!qFuzzyCompare(q->width(), declarativeItemRoot->width()))
- declarativeItemRoot->setWidth(q->width());
- if (!qFuzzyCompare(q->height(), declarativeItemRoot->height()))
- declarativeItemRoot->setHeight(q->height());
- }
- } else if (graphicsWidgetRoot) {
- if (resizeMode == QDeclarativeView::SizeViewToRootObject) {
- QSize newSize = QSize(graphicsWidgetRoot->size().width(), graphicsWidgetRoot->size().height());
- if (newSize.isValid() && newSize != q->size()) {
- q->resize(newSize);
- }
- } else if (resizeMode == QDeclarativeView::SizeRootObjectToView) {
- QSizeF newSize = QSize(q->size().width(), q->size().height());
- if (newSize.isValid() && newSize != graphicsWidgetRoot->size()) {
- graphicsWidgetRoot->resize(newSize);
- }
- }
- }
- q->updateGeometry();
-}
-
-QSize QDeclarativeViewPrivate::rootObjectSize() const
-{
- QSize rootObjectSize(0,0);
- int widthCandidate = -1;
- int heightCandidate = -1;
- if (root) {
- QSizeF size = root->boundingRect().size();
- widthCandidate = size.width();
- heightCandidate = size.height();
- }
- if (widthCandidate > 0) {
- rootObjectSize.setWidth(widthCandidate);
- }
- if (heightCandidate > 0) {
- rootObjectSize.setHeight(heightCandidate);
- }
- return rootObjectSize;
-}
-
-QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const
-{
- Q_D(const QDeclarativeView);
- return d->resizeMode;
-}
-
-/*!
- \internal
- */
-void QDeclarativeView::continueExecute()
-{
- Q_D(QDeclarativeView);
- disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
-
- if (d->component->isError()) {
- QList<QDeclarativeError> errorList = d->component->errors();
- foreach (const QDeclarativeError &error, errorList) {
- qWarning() << error;
- }
- emit statusChanged(status());
- return;
- }
-
- QObject *obj = d->component->create();
-
- if(d->component->isError()) {
- QList<QDeclarativeError> errorList = d->component->errors();
- foreach (const QDeclarativeError &error, errorList) {
- qWarning() << error;
- }
- emit statusChanged(status());
- return;
- }
-
- setRootObject(obj);
- emit statusChanged(status());
-}
-
-/*!
- \internal
-*/
-void QDeclarativeView::setRootObject(QObject *obj)
-{
- Q_D(QDeclarativeView);
- if (d->root == obj || !scene())
- return;
- if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem *>(obj)) {
- scene()->addItem(declarativeItem);
- d->root = declarativeItem;
- d->declarativeItemRoot = declarativeItem;
- } else if (QGraphicsObject *graphicsObject = qobject_cast<QGraphicsObject *>(obj)) {
- scene()->addItem(graphicsObject);
- d->root = graphicsObject;
- if (graphicsObject->isWidget()) {
- d->graphicsWidgetRoot = static_cast<QGraphicsWidget*>(graphicsObject);
- } else {
- qWarning() << "QDeclarativeView::resizeMode is not honored for components of type QGraphicsObject";
- }
- } else if (obj) {
- qWarning() << "QDeclarativeView only supports loading of root objects that derive from QGraphicsObject";
- if (QWidget* widget = qobject_cast<QWidget *>(obj)) {
- window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
- window()->setAttribute(Qt::WA_NoSystemBackground, false);
- if (layout() && layout()->count()) {
- // Hide the QGraphicsView in GV mode.
- QLayoutItem *item = layout()->itemAt(0);
- if (item->widget())
- item->widget()->hide();
- }
- widget->setParent(this);
- if (isVisible()) {
- widget->setVisible(true);
- }
- resize(widget->size());
- }else{
- delete obj;
- }
- }
-
- if (d->root) {
- d->initialSize = d->rootObjectSize();
- if ((d->resizeMode == QDeclarativeView::SizeViewToRootObject || !testAttribute(Qt::WA_Resized))
- && d->initialSize != size()) {
- if (!(parentWidget() && parentWidget()->layout())) {
- resize(d->initialSize);
- }
- }
- emit initialSizeChanged(d->initialSize);
- d->initResize();
- }
-}
-
-/*!
- \internal
- If the \l {QTimerEvent} {timer event} \a e is this
- view's resize timer, sceneResized() is emitted.
- */
-void QDeclarativeView::timerEvent(QTimerEvent* e)
-{
- Q_D(QDeclarativeView);
- if (!e || e->timerId() == d->resizetimer.timerId()) {
- d->updateSize();
- d->resizetimer.stop();
- }
-}
-
-/*! \internal */
-bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e)
-{
- Q_D(QDeclarativeView);
- if (watched == d->root && d->resizeMode == SizeViewToRootObject) {
- if (d->graphicsWidgetRoot) {
- if (e->type() == QEvent::GraphicsSceneResize) {
- d->updateSize();
- }
- }
- }
- return QGraphicsView::eventFilter(watched, e);
-}
-
-/*!
- \internal
- Preferred size follows the root object geometry.
-*/
-QSize QDeclarativeView::sizeHint() const
-{
- Q_D(const QDeclarativeView);
- QSize rootObjectSize = d->rootObjectSize();
- if (rootObjectSize.isEmpty()) {
- return size();
- } else {
- return rootObjectSize;
- }
-}
-
-/*!
- Returns the initial size of the root object
-*/
-QSize QDeclarativeView::initialSize() const
-{
- Q_D(const QDeclarativeView);
- return d->initialSize;
-}
-
-/*!
- Returns the view's root \l {QGraphicsObject} {item}.
- */
-QGraphicsObject *QDeclarativeView::rootObject() const
-{
- Q_D(const QDeclarativeView);
- return d->root;
-}
-
-/*!
- \internal
- This function handles the \l {QResizeEvent} {resize event}
- \a e.
- */
-void QDeclarativeView::resizeEvent(QResizeEvent *e)
-{
- Q_D(QDeclarativeView);
- if (d->resizeMode == SizeRootObjectToView) {
- d->updateSize();
- }
- if (d->declarativeItemRoot) {
- setSceneRect(QRectF(0, 0, d->declarativeItemRoot->width(), d->declarativeItemRoot->height()));
- } else if (d->root) {
- setSceneRect(d->root->boundingRect());
- } else {
- setSceneRect(rect());
- }
- emit sceneResized(e->size());
- QGraphicsView::resizeEvent(e);
-}
-
-/*!
- \internal
-*/
-void QDeclarativeView::paintEvent(QPaintEvent *event)
-{
- Q_D(QDeclarativeView);
-
- QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::FramePaint);
- QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Painting);
-
- int time = 0;
- if (frameRateDebug())
- time = d->frameTimer.restart();
-
- QGraphicsView::paintEvent(event);
-
- QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Painting);
-
- if (frameRateDebug())
- qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time;
-
-#if QT_SHOW_DECLARATIVEVIEW_FPS
- static QTime timer;
- static int frames;
-
- if (frames == 0) {
- timer.start();
- } else if (timer.elapsed() > 5000) {
- qreal avgtime = timer.elapsed() / (qreal) frames;
- qDebug("Average time per frame: %f ms (%i fps)", avgtime, int(1000 / avgtime));
- timer.start();
- frames = 0;
- }
- ++frames;
- scene()->update();
-#endif
-
-}
-
-QDeclarativeItem * QDeclarativeView::accessibleRootItem() const
-{
- Q_D(const QDeclarativeView);
- return d->declarativeItemRoot;
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtquick1/util/qdeclarativeview.h b/src/qtquick1/util/qdeclarativeview.h
deleted file mode 100644
index 9ffae9c950..0000000000
--- a/src/qtquick1/util/qdeclarativeview.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEVIEW_H
-#define QDECLARATIVEVIEW_H
-
-#include <QtCore/qdatetime.h>
-#include <QtCore/qurl.h>
-#include <QtWidgets/qgraphicssceneevent.h>
-#include <QtWidgets/qgraphicsview.h>
-#include <QtWidgets/qwidget.h>
-#include <QtDeclarative/qdeclarativedebug.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsObject;
-class QDeclarativeEngine;
-class QDeclarativeContext;
-class QDeclarativeError;
-class QDeclarativeItem;
-
-
-class QDeclarativeViewPrivate;
-class Q_QTQUICK1_EXPORT QDeclarativeView : public QGraphicsView
-{
- Q_OBJECT
- Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true)
- Q_ENUMS(ResizeMode Status)
-public:
- explicit QDeclarativeView(QWidget *parent = 0);
- QDeclarativeView(const QUrl &source, QWidget *parent = 0);
- virtual ~QDeclarativeView();
-
- QUrl source() const;
-
- QDeclarativeEngine* engine() const;
- QDeclarativeContext* rootContext() const;
-
- QGraphicsObject *rootObject() const;
-
- enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
- ResizeMode resizeMode() const;
- void setResizeMode(ResizeMode);
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
-
- QList<QDeclarativeError> errors() const;
-
- QSize sizeHint() const;
- QSize initialSize() const;
-
-public Q_SLOTS:
- void setSource(const QUrl&);
-
-Q_SIGNALS:
- void sceneResized(QSize size); // ???
- void statusChanged(QDeclarativeView::Status);
- void initialSizeChanged(QSize size);
-
-private Q_SLOTS:
- void continueExecute();
-
-protected:
- virtual void resizeEvent(QResizeEvent *);
- virtual void paintEvent(QPaintEvent *event);
- virtual void timerEvent(QTimerEvent*);
- virtual void setRootObject(QObject *obj);
- virtual bool eventFilter(QObject *watched, QEvent *e);
-
-private:
- Q_DISABLE_COPY(QDeclarativeView)
- Q_DECLARE_PRIVATE(QDeclarativeView)
-// Accessibility support:
- friend class QAccessibleDeclarativeView;
- QDeclarativeItem *accessibleRootItem() const;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEVIEW_H
diff --git a/src/qtquick1/util/qdeclarativexmllistmodel.cpp b/src/qtquick1/util/qdeclarativexmllistmodel.cpp
deleted file mode 100644
index 28b134456d..0000000000
--- a/src/qtquick1/util/qdeclarativexmllistmodel.cpp
+++ /dev/null
@@ -1,1060 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtQuick1/private/qdeclarativexmllistmodel_p.h"
-
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-
-#include <QDebug>
-#include <QStringList>
-#include <QMap>
-#include <QApplication>
-#include <QThread>
-#include <QXmlQuery>
-#include <QXmlResultItems>
-#include <QXmlNodeModelIndex>
-#include <QBuffer>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QTimer>
-#include <QMutex>
-
-#include <private/qobject_p.h>
-
-Q_DECLARE_METATYPE(QDeclarative1XmlQueryResult)
-
-QT_BEGIN_NAMESPACE
-
-
-
-
-typedef QPair<int, int> QDeclarative1XmlListRange;
-
-#define XMLLISTMODEL_CLEAR_ID 0
-
-/*!
- \qmlclass XmlRole QDeclarative1XmlListModelRole
- \inqmlmodule QtQuick 1
- \ingroup qml-working-with-data
- \since QtQuick 1.0
- \brief The XmlRole element allows you to specify a role for an XmlListModel.
-
- \sa {QtDeclarative}
-*/
-
-/*!
- \qmlproperty string QtQuick1::XmlRole::name
-
- The name for the role. This name is used to access the model data for this role.
-
- For example, the following model has a role named "title", which can be accessed
- from the view's delegate:
-
- \qml
- XmlListModel {
- id: xmlModel
- // ...
- XmlRole {
- name: "title"
- query: "title/string()"
- }
- }
- \endqml
-
- \qml
- ListView {
- model: xmlModel
- delegate: Text { text: title }
- }
- \endqml
-*/
-
-/*!
- \qmlproperty string QtQuick1::XmlRole::query
- The relative XPath expression query for this role. The query must be relative; it cannot start
- with a '/'.
-
- For example, if there is an XML document like this:
-
- \quotefile doc/src/snippets/qtquick1/xmlrole.xml
-
- Here are some valid XPath expressions for XmlRole queries on this document:
-
- \snippet doc/src/snippets/qtquick1/xmlrole.qml 0
- \dots 4
- \snippet doc/src/snippets/qtquick1/xmlrole.qml 1
-
- See the \l{http://www.w3.org/TR/xpath20/}{W3C XPath 2.0 specification} for more information.
-*/
-
-/*!
- \qmlproperty bool QtQuick1::XmlRole::isKey
- Defines whether this is a key role.
-
- Key roles are used to to determine whether a set of values should
- be updated or added to the XML list model when XmlListModel::reload()
- is called.
-
- \sa XmlListModel
-*/
-
-struct XmlQueryJob
-{
- int queryId;
- QByteArray data;
- QString query;
- QString namespaces;
- QStringList roleQueries;
- QList<void*> roleQueryErrorId; // the ptr to send back if there is an error
- QStringList keyRoleQueries;
- QStringList keyRoleResultsCache;
- QString prefix;
-};
-
-class QDeclarative1XmlQuery : public QObject
-{
- Q_OBJECT
-public:
- QDeclarative1XmlQuery(QObject *parent=0)
- : QObject(parent), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1) {
- qRegisterMetaType<QDeclarative1XmlQueryResult>("QDeclarative1XmlQueryResult");
- moveToThread(&m_thread);
- m_thread.start(QThread::IdlePriority);
- }
-
- ~QDeclarative1XmlQuery() {
- if(m_thread.isRunning()) {
- m_thread.quit();
- m_thread.wait();
- }
- }
-
- void abort(int id) {
- QMutexLocker ml(&m_mutex);
- if (id != -1) {
- m_jobs.remove(id);
- }
- }
-
- int doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarative1XmlListModelRole *>* roleObjects, QStringList keyRoleResultsCache) {
- {
- QMutexLocker m1(&m_mutex);
- m_queryIds.ref();
- if (m_queryIds.load() <= 0)
- m_queryIds.store(1);
- }
-
- XmlQueryJob job;
- job.queryId = m_queryIds.load();
- job.data = data;
- job.query = QLatin1String("doc($src)") + query;
- job.namespaces = namespaces;
- job.keyRoleResultsCache = keyRoleResultsCache;
-
- for (int i=0; i<roleObjects->count(); i++) {
- if (!roleObjects->at(i)->isValid()) {
- job.roleQueries << QString();
- continue;
- }
- job.roleQueries << roleObjects->at(i)->query();
- job.roleQueryErrorId << static_cast<void*>(roleObjects->at(i));
- if (roleObjects->at(i)->isKey())
- job.keyRoleQueries << job.roleQueries.last();
- }
-
- {
- QMutexLocker ml(&m_mutex);
- m_jobs.insert(m_queryIds.load(), job);
- }
-
- QMetaObject::invokeMethod(this, "processQuery", Qt::QueuedConnection, Q_ARG(int, job.queryId));
- return job.queryId;
- }
-
-private slots:
- void processQuery(int queryId) {
- XmlQueryJob job;
-
- {
- QMutexLocker ml(&m_mutex);
- if (!m_jobs.contains(queryId))
- return;
- job = m_jobs.value(queryId);
- }
-
- QDeclarative1XmlQueryResult result;
- result.queryId = job.queryId;
- doQueryJob(&job, &result);
- doSubQueryJob(&job, &result);
-
- {
- QMutexLocker ml(&m_mutex);
- if (m_jobs.contains(queryId)) {
- emit queryCompleted(result);
- m_jobs.remove(queryId);
- }
- }
- }
-
-Q_SIGNALS:
- void queryCompleted(const QDeclarative1XmlQueryResult &);
- void error(void*, const QString&);
-
-protected:
-
-
-private:
- void doQueryJob(XmlQueryJob *job, QDeclarative1XmlQueryResult *currentResult);
- void doSubQueryJob(XmlQueryJob *job, QDeclarative1XmlQueryResult *currentResult);
- void getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const;
- void addIndexToRangeList(QList<QDeclarative1XmlListRange> *ranges, int index) const;
-
-private:
- QMutex m_mutex;
- QThread m_thread;
- QMap<int, XmlQueryJob> m_jobs;
- QAtomicInt m_queryIds;
-};
-
-Q_GLOBAL_STATIC(QDeclarative1XmlQuery, globalXmlQuery)
-
-void QDeclarative1XmlQuery::doQueryJob(XmlQueryJob *currentJob, QDeclarative1XmlQueryResult *currentResult)
-{
- Q_ASSERT(currentJob->queryId != -1);
-
- QString r;
- QXmlQuery query;
- QBuffer buffer(&currentJob->data);
- buffer.open(QIODevice::ReadOnly);
- query.bindVariable(QLatin1String("src"), &buffer);
- query.setQuery(currentJob->namespaces + currentJob->query);
- query.evaluateTo(&r);
-
- //always need a single root element
- QByteArray xml = "<dummy:items xmlns:dummy=\"http://qtsotware.com/dummy\">\n" + r.toUtf8() + "</dummy:items>";
- QBuffer b(&xml);
- b.open(QIODevice::ReadOnly);
-
- QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + currentJob->namespaces;
- QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
- currentJob->query.mid(currentJob->query.lastIndexOf(QLatin1Char('/')));
-
- //figure out how many items we are dealing with
- int count = -1;
- {
- QXmlResultItems result;
- QXmlQuery countquery;
- countquery.bindVariable(QLatin1String("inputDocument"), &b);
- countquery.setQuery(namespaces + QLatin1String("count(") + prefix + QLatin1Char(')'));
- countquery.evaluateTo(&result);
- QXmlItem item(result.next());
- if (item.isAtomicValue())
- count = item.toAtomicValue().toInt();
- }
-
- currentJob->data = xml;
- currentJob->prefix = namespaces + prefix + QLatin1Char('/');
- currentResult->size = (count > 0 ? count : 0);
-}
-
-void QDeclarative1XmlQuery::getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const
-{
- const QStringList &keysQueries = currentJob.keyRoleQueries;
- QString keysQuery;
- if (keysQueries.count() == 1)
- keysQuery = currentJob.prefix + keysQueries[0];
- else if (keysQueries.count() > 1)
- keysQuery = currentJob.prefix + QLatin1String("concat(") + keysQueries.join(QLatin1String(",")) + QLatin1String(")");
-
- if (!keysQuery.isEmpty()) {
- query->setQuery(keysQuery);
- QXmlResultItems resultItems;
- query->evaluateTo(&resultItems);
- QXmlItem item(resultItems.next());
- while (!item.isNull()) {
- values->append(item.toAtomicValue().toString());
- item = resultItems.next();
- }
- }
-}
-
-void QDeclarative1XmlQuery::addIndexToRangeList(QList<QDeclarative1XmlListRange> *ranges, int index) const {
- if (ranges->isEmpty())
- ranges->append(qMakePair(index, 1));
- else if (ranges->last().first + ranges->last().second == index)
- ranges->last().second += 1;
- else
- ranges->append(qMakePair(index, 1));
-}
-
-void QDeclarative1XmlQuery::doSubQueryJob(XmlQueryJob *currentJob, QDeclarative1XmlQueryResult *currentResult)
-{
- Q_ASSERT(currentJob->queryId != -1);
-
- QBuffer b(&currentJob->data);
- b.open(QIODevice::ReadOnly);
-
- QXmlQuery subquery;
- subquery.bindVariable(QLatin1String("inputDocument"), &b);
-
- QStringList keyRoleResults;
- getValuesOfKeyRoles(*currentJob, &keyRoleResults, &subquery);
-
- // See if any values of key roles have been inserted or removed.
-
- if (currentJob->keyRoleResultsCache.isEmpty()) {
- currentResult->inserted << qMakePair(0, currentResult->size);
- } else {
- if (keyRoleResults != currentJob->keyRoleResultsCache) {
- QStringList temp;
- for (int i=0; i<currentJob->keyRoleResultsCache.count(); i++) {
- if (!keyRoleResults.contains(currentJob->keyRoleResultsCache[i]))
- addIndexToRangeList(&currentResult->removed, i);
- else
- temp << currentJob->keyRoleResultsCache[i];
- }
-
- for (int i=0; i<keyRoleResults.count(); i++) {
- if (temp.count() == i || keyRoleResults[i] != temp[i]) {
- temp.insert(i, keyRoleResults[i]);
- addIndexToRangeList(&currentResult->inserted, i);
- }
- }
- }
- }
- currentResult->keyRoleResultsCache = keyRoleResults;
-
- // Get the new values for each role.
- //### we might be able to condense even further (query for everything in one go)
- const QStringList &queries = currentJob->roleQueries;
- for (int i = 0; i < queries.size(); ++i) {
- QList<QVariant> resultList;
- if (!queries[i].isEmpty()) {
- subquery.setQuery(currentJob->prefix + QLatin1String("(let $v := string(") + queries[i] + QLatin1String(") return if ($v) then ") + queries[i] + QLatin1String(" else \"\")"));
- if (subquery.isValid()) {
- QXmlResultItems resultItems;
- subquery.evaluateTo(&resultItems);
- QXmlItem item(resultItems.next());
- while (!item.isNull()) {
- resultList << item.toAtomicValue(); //### we used to trim strings
- item = resultItems.next();
- }
- } else {
- emit error(currentJob->roleQueryErrorId.at(i), queries[i]);
- }
- }
- //### should warn here if things have gone wrong.
- while (resultList.count() < currentResult->size)
- resultList << QVariant();
- currentResult->data << resultList;
- b.seek(0);
- }
-
- //this method is much slower, but works better for incremental loading
- /*for (int j = 0; j < m_size; ++j) {
- QList<QVariant> resultList;
- for (int i = 0; i < m_roleObjects->size(); ++i) {
- QDeclarative1XmlListModelRole *role = m_roleObjects->at(i);
- subquery.setQuery(m_prefix.arg(j+1) + role->query());
- if (role->isStringList()) {
- QStringList data;
- subquery.evaluateTo(&data);
- resultList << QVariant(data);
- //qDebug() << data;
- } else {
- QString s;
- subquery.evaluateTo(&s);
- if (role->isCData()) {
- //un-escape
- s.replace(QLatin1String("&lt;"), QLatin1String("<"));
- s.replace(QLatin1String("&gt;"), QLatin1String(">"));
- s.replace(QLatin1String("&amp;"), QLatin1String("&"));
- }
- resultList << s.trimmed();
- //qDebug() << s;
- }
- b.seek(0);
- }
- m_modelData << resultList;
- }*/
-}
-
-class QDeclarative1XmlListModelPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarative1XmlListModel)
-public:
- QDeclarative1XmlListModelPrivate()
- : isComponentComplete(true), size(-1), highestRole(Qt::UserRole)
- , reply(0), status(QDeclarative1XmlListModel::Null), progress(0.0)
- , queryId(-1), roleObjects(), redirectCount(0) {}
-
-
- void notifyQueryStarted(bool remoteSource) {
- Q_Q(QDeclarative1XmlListModel);
- progress = remoteSource ? 0.0 : 1.0;
- status = QDeclarative1XmlListModel::Loading;
- errorString.clear();
- emit q->progressChanged(progress);
- emit q->statusChanged(status);
- }
-
- bool isComponentComplete;
- QUrl src;
- QString xml;
- QString query;
- QString namespaces;
- int size;
- QList<int> roles;
- QStringList roleNames;
- int highestRole;
- QNetworkReply *reply;
- QDeclarative1XmlListModel::Status status;
- QString errorString;
- qreal progress;
- int queryId;
- QStringList keyRoleResultsCache;
- QList<QDeclarative1XmlListModelRole *> roleObjects;
- static void append_role(QDeclarativeListProperty<QDeclarative1XmlListModelRole> *list, QDeclarative1XmlListModelRole *role);
- static void clear_role(QDeclarativeListProperty<QDeclarative1XmlListModelRole> *list);
- QList<QList<QVariant> > data;
- int redirectCount;
-};
-
-
-void QDeclarative1XmlListModelPrivate::append_role(QDeclarativeListProperty<QDeclarative1XmlListModelRole> *list, QDeclarative1XmlListModelRole *role)
-{
- QDeclarative1XmlListModel *_this = qobject_cast<QDeclarative1XmlListModel *>(list->object);
- if (_this && role) {
- int i = _this->d_func()->roleObjects.count();
- _this->d_func()->roleObjects.append(role);
- if (_this->d_func()->roleNames.contains(role->name())) {
- qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name());
- return;
- }
- _this->d_func()->roles.insert(i, _this->d_func()->highestRole);
- _this->d_func()->roleNames.insert(i, role->name());
- ++_this->d_func()->highestRole;
- }
-}
-
-//### clear needs to invalidate any cached data (in data table) as well
-// (and the model should emit the appropriate signals)
-void QDeclarative1XmlListModelPrivate::clear_role(QDeclarativeListProperty<QDeclarative1XmlListModelRole> *list)
-{
- QDeclarative1XmlListModel *_this = static_cast<QDeclarative1XmlListModel *>(list->object);
- _this->d_func()->roles.clear();
- _this->d_func()->roleNames.clear();
- _this->d_func()->roleObjects.clear();
-}
-
-/*!
- \qmlclass XmlListModel QDeclarative1XmlListModel
- \inqmlmodule QtQuick 1
- \ingroup qml-working-with-data
- \since QtQuick 1.0
- \brief The XmlListModel element is used to specify a read-only model using XPath expressions.
-
- XmlListModel is used to create a read-only model from XML data. It can be used as a data source
- for view elements (such as ListView, PathView, GridView) and other elements that interact with model
- data (such as \l Repeater).
-
- For example, if there is a XML document at http://www.mysite.com/feed.xml like this:
-
- \code
- <?xml version="1.0" encoding="utf-8"?>
- <rss version="2.0">
- ...
- <channel>
- <item>
- <title>A blog post</title>
- <pubDate>Sat, 07 Sep 2010 10:00:01 GMT</pubDate>
- </item>
- <item>
- <title>Another blog post</title>
- <pubDate>Sat, 07 Sep 2010 15:35:01 GMT</pubDate>
- </item>
- </channel>
- </rss>
- \endcode
-
- A XmlListModel could create a model from this data, like this:
-
- \qml
- import QtQuick 1.0
-
- XmlListModel {
- id: xmlModel
- source: "http://www.mysite.com/feed.xml"
- query: "/rss/channel/item"
-
- XmlRole { name: "title"; query: "title/string()" }
- XmlRole { name: "pubDate"; query: "pubDate/string()" }
- }
- \endqml
-
- The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate
- a model item for each \c <item> in the XML document.
-
- The XmlRole objects define the
- model item attributes. Here, each model item will have \c title and \c pubDate
- attributes that match the \c title and \c pubDate values of its corresponding \c <item>.
- (See \l XmlRole::query for more examples of valid XPath expressions for XmlRole.)
-
- The model could be used in a ListView, like this:
-
- \qml
- ListView {
- width: 180; height: 300
- model: xmlModel
- delegate: Text { text: title + ": " + pubDate }
- }
- \endqml
-
- \image qml-xmllistmodel-example.png
-
- The XmlListModel data is loaded asynchronously, and \l status
- is set to \c XmlListModel.Ready when loading is complete.
- Note this means when XmlListModel is used for a view, the view is not
- populated until the model is loaded.
-
-
- \section2 Using key XML roles
-
- You can define certain roles as "keys" so that when reload() is called,
- the model will only add and refresh data that contains new values for
- these keys.
-
- For example, if above role for "pubDate" was defined like this instead:
-
- \qml
- XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true }
- \endqml
-
- Then when reload() is called, the model will only add and reload
- items with a "pubDate" value that is not already
- present in the model.
-
- This is useful when displaying the contents of XML documents that
- are incrementally updated (such as RSS feeds) to avoid repainting the
- entire contents of a model in a view.
-
- If multiple key roles are specified, the model only adds and reload items
- with a combined value of all key roles that is not already present in
- the model.
-
- \sa {RSS News}
-*/
-
-QDeclarative1XmlListModel::QDeclarative1XmlListModel(QObject *parent)
- : QListModelInterface(*(new QDeclarative1XmlListModelPrivate), parent)
-{
- connect(globalXmlQuery(), SIGNAL(queryCompleted(QDeclarative1XmlQueryResult)),
- this, SLOT(queryCompleted(QDeclarative1XmlQueryResult)));
- connect(globalXmlQuery(), SIGNAL(error(void*,QString)),
- this, SLOT(queryError(void*,QString)));
-}
-
-QDeclarative1XmlListModel::~QDeclarative1XmlListModel()
-{
-}
-
-/*!
- \qmlproperty list<XmlRole> QtQuick1::XmlListModel::roles
-
- The roles to make available for this model.
-*/
-QDeclarativeListProperty<QDeclarative1XmlListModelRole> QDeclarative1XmlListModel::roleObjects()
-{
- Q_D(QDeclarative1XmlListModel);
- QDeclarativeListProperty<QDeclarative1XmlListModelRole> list(this, d->roleObjects);
- list.append = &QDeclarative1XmlListModelPrivate::append_role;
- list.clear = &QDeclarative1XmlListModelPrivate::clear_role;
- return list;
-}
-
-QHash<int,QVariant> QDeclarative1XmlListModel::data(int index, const QList<int> &roles) const
-{
- Q_D(const QDeclarative1XmlListModel);
- QHash<int, QVariant> rv;
- for (int i = 0; i < roles.size(); ++i) {
- int role = roles.at(i);
- int roleIndex = d->roles.indexOf(role);
- rv.insert(role, roleIndex == -1 ? QVariant() : d->data.value(roleIndex).value(index));
- }
- return rv;
-}
-
-QVariant QDeclarative1XmlListModel::data(int index, int role) const
-{
- Q_D(const QDeclarative1XmlListModel);
- int roleIndex = d->roles.indexOf(role);
- return (roleIndex == -1) ? QVariant() : d->data.value(roleIndex).value(index);
-}
-
-/*!
- \qmlproperty int QtQuick1::XmlListModel::count
- The number of data entries in the model.
-*/
-int QDeclarative1XmlListModel::count() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->size;
-}
-
-QList<int> QDeclarative1XmlListModel::roles() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->roles;
-}
-
-QString QDeclarative1XmlListModel::toString(int role) const
-{
- Q_D(const QDeclarative1XmlListModel);
- int index = d->roles.indexOf(role);
- if (index == -1)
- return QString();
- return d->roleNames.at(index);
-}
-
-/*!
- \qmlproperty url QtQuick1::XmlListModel::source
- The location of the XML data source.
-
- If both \c source and \l xml are set, \l xml is used.
-*/
-QUrl QDeclarative1XmlListModel::source() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->src;
-}
-
-void QDeclarative1XmlListModel::setSource(const QUrl &src)
-{
- Q_D(QDeclarative1XmlListModel);
- if (d->src != src) {
- d->src = src;
- if (d->xml.isEmpty()) // src is only used if d->xml is not set
- reload();
- emit sourceChanged();
- }
-}
-
-/*!
- \qmlproperty string QtQuick1::XmlListModel::xml
- This property holds the XML data for this model, if set.
-
- The text is assumed to be UTF-8 encoded.
-
- If both \l source and \c xml are set, \c xml is used.
-*/
-QString QDeclarative1XmlListModel::xml() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->xml;
-}
-
-void QDeclarative1XmlListModel::setXml(const QString &xml)
-{
- Q_D(QDeclarative1XmlListModel);
- if (d->xml != xml) {
- d->xml = xml;
- reload();
- emit xmlChanged();
- }
-}
-
-/*!
- \qmlproperty string QtQuick1::XmlListModel::query
- An absolute XPath query representing the base query for creating model items
- from this model's XmlRole objects. The query should start with '/' or '//'.
-*/
-QString QDeclarative1XmlListModel::query() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->query;
-}
-
-void QDeclarative1XmlListModel::setQuery(const QString &query)
-{
- Q_D(QDeclarative1XmlListModel);
- if (!query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << QCoreApplication::translate("QDeclarative1XmlRoleList", "An XmlListModel query must start with '/' or \"//\"");
- return;
- }
-
- if (d->query != query) {
- d->query = query;
- reload();
- emit queryChanged();
- }
-}
-
-/*!
- \qmlproperty string QtQuick1::XmlListModel::namespaceDeclarations
- The namespace declarations to be used in the XPath queries.
-
- The namespaces should be declared as in XQuery. For example, if a requested document
- at http://mysite.com/feed.xml uses the namespace "http://www.w3.org/2005/Atom",
- this can be declared as the default namespace:
-
- \qml
- XmlListModel {
- source: "http://mysite.com/feed.xml"
- query: "/feed/entry"
- namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
-
- XmlRole { name: "title"; query: "title/string()" }
- }
- \endqml
-*/
-QString QDeclarative1XmlListModel::namespaceDeclarations() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->namespaces;
-}
-
-void QDeclarative1XmlListModel::setNamespaceDeclarations(const QString &declarations)
-{
- Q_D(QDeclarative1XmlListModel);
- if (d->namespaces != declarations) {
- d->namespaces = declarations;
- reload();
- emit namespaceDeclarationsChanged();
- }
-}
-
-/*!
- \qmlmethod object QtQuick1::XmlListModel::get(int index)
-
- Returns the item at \a index in the model.
-
- For example, for a model like this:
-
- \qml
- XmlListModel {
- id: model
- source: "http://mysite.com/feed.xml"
- query: "/feed/entry"
- XmlRole { name: "title"; query: "title/string()" }
- }
- \endqml
-
- This will access the \c title value for the first item in the model:
-
- \js
- var title = model.get(0).title;
- \endjs
-*/
-QDeclarativeV8Handle QDeclarative1XmlListModel::get(int index) const
-{
- // Must be called with a context and handle scope
- Q_D(const QDeclarative1XmlListModel);
-
- if (index < 0 || index >= count())
- return QDeclarativeV8Handle::fromHandle(v8::Undefined());
-
- QDeclarativeEngine *engine = qmlContext(this)->engine();
- QV8Engine *v8engine = QDeclarativeEnginePrivate::getV8Engine(engine);
- v8::Local<v8::Object> rv = v8::Object::New();
- for (int ii = 0; ii < d->roleObjects.count(); ++ii)
- rv->Set(v8engine->toString(d->roleObjects[ii]->name()),
- v8engine->fromVariant(d->data.value(ii).value(index)));
-
- return QDeclarativeV8Handle::fromHandle(rv);
-}
-
-/*!
- \qmlproperty enumeration QtQuick1::XmlListModel::status
- Specifies the model loading status, which can be one of the following:
-
- \list
- \o XmlListModel.Null - No XML data has been set for this model.
- \o XmlListModel.Ready - The XML data has been loaded into the model.
- \o XmlListModel.Loading - The model is in the process of reading and loading XML data.
- \o XmlListModel.Error - An error occurred while the model was loading. See errorString() for details
- about the error.
- \endlist
-
- \sa progress
-
-*/
-QDeclarative1XmlListModel::Status QDeclarative1XmlListModel::status() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->status;
-}
-
-/*!
- \qmlproperty real QtQuick1::XmlListModel::progress
-
- This indicates the current progress of the downloading of the XML data
- source. This value ranges from 0.0 (no data downloaded) to
- 1.0 (all data downloaded). If the XML data is not from a remote source,
- the progress becomes 1.0 as soon as the data is read.
-
- Note that when the progress is 1.0, the XML data has been downloaded, but
- it is yet to be loaded into the model at this point. Use the status
- property to find out when the XML data has been read and loaded into
- the model.
-
- \sa status, source
-*/
-qreal QDeclarative1XmlListModel::progress() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->progress;
-}
-
-/*!
- \qmlmethod void QtQuick1::XmlListModel::errorString()
-
- Returns a string description of the last error that occurred
- if \l status is XmlListModel::Error.
-*/
-QString QDeclarative1XmlListModel::errorString() const
-{
- Q_D(const QDeclarative1XmlListModel);
- return d->errorString;
-}
-
-void QDeclarative1XmlListModel::classBegin()
-{
- Q_D(QDeclarative1XmlListModel);
- d->isComponentComplete = false;
-}
-
-void QDeclarative1XmlListModel::componentComplete()
-{
- Q_D(QDeclarative1XmlListModel);
- d->isComponentComplete = true;
- reload();
-}
-
-/*!
- \qmlmethod QtQuick1::XmlListModel::reload()
-
- Reloads the model.
-
- If no key roles have been specified, all existing model
- data is removed, and the model is rebuilt from scratch.
-
- Otherwise, items are only added if the model does not already
- contain items with matching key role values.
-
- \sa {Using key XML roles}, XmlRole::isKey
-*/
-void QDeclarative1XmlListModel::reload()
-{
- Q_D(QDeclarative1XmlListModel);
-
- if (!d->isComponentComplete)
- return;
-
- globalXmlQuery()->abort(d->queryId);
- d->queryId = -1;
-
- if (d->size < 0)
- d->size = 0;
-
- if (d->reply) {
- d->reply->abort();
- if (d->reply) {
- // abort will generally have already done this (and more)
- d->reply->deleteLater();
- d->reply = 0;
- }
- }
-
- if (!d->xml.isEmpty()) {
- d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache);
- d->notifyQueryStarted(false);
-
- } else if (d->src.isEmpty()) {
- d->queryId = XMLLISTMODEL_CLEAR_ID;
- d->notifyQueryStarted(false);
- QTimer::singleShot(0, this, SLOT(dataCleared()));
-
- } else {
- d->notifyQueryStarted(true);
- QNetworkRequest req(d->src);
- req.setRawHeader("Accept", "application/xml,*/*");
- d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
- QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
- QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
- }
-}
-
-#define XMLLISTMODEL_MAX_REDIRECT 16
-
-void QDeclarative1XmlListModel::requestFinished()
-{
- Q_D(QDeclarative1XmlListModel);
-
- d->redirectCount++;
- if (d->redirectCount < XMLLISTMODEL_MAX_REDIRECT) {
- QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirect.isValid()) {
- QUrl url = d->reply->url().resolved(redirect.toUrl());
- d->reply->deleteLater();
- d->reply = 0;
- setSource(url);
- return;
- }
- }
- d->redirectCount = 0;
-
- if (d->reply->error() != QNetworkReply::NoError) {
- d->errorString = d->reply->errorString();
- disconnect(d->reply, 0, this, 0);
- d->reply->deleteLater();
- d->reply = 0;
-
- int count = this->count();
- d->data.clear();
- d->size = 0;
- if (count > 0) {
- emit itemsRemoved(0, count);
- emit countChanged();
- }
-
- d->status = Error;
- d->queryId = -1;
- emit statusChanged(d->status);
- } else {
- QByteArray data = d->reply->readAll();
- if (data.isEmpty()) {
- d->queryId = XMLLISTMODEL_CLEAR_ID;
- QTimer::singleShot(0, this, SLOT(dataCleared()));
- } else {
- d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache);
- }
- disconnect(d->reply, 0, this, 0);
- d->reply->deleteLater();
- d->reply = 0;
-
- d->progress = 1.0;
- emit progressChanged(d->progress);
- }
-}
-
-void QDeclarative1XmlListModel::requestProgress(qint64 received, qint64 total)
-{
- Q_D(QDeclarative1XmlListModel);
- if (d->status == Loading && total > 0) {
- d->progress = qreal(received)/total;
- emit progressChanged(d->progress);
- }
-}
-
-void QDeclarative1XmlListModel::dataCleared()
-{
- Q_D(QDeclarative1XmlListModel);
- QDeclarative1XmlQueryResult r;
- r.queryId = XMLLISTMODEL_CLEAR_ID;
- r.size = 0;
- r.removed << qMakePair(0, count());
- r.keyRoleResultsCache = d->keyRoleResultsCache;
- queryCompleted(r);
-}
-
-void QDeclarative1XmlListModel::queryError(void* object, const QString& error)
-{
- // Be extra careful, object may no longer exist, it's just an ID.
- Q_D(QDeclarative1XmlListModel);
- for (int i=0; i<d->roleObjects.count(); i++) {
- if (d->roleObjects.at(i) == static_cast<QDeclarative1XmlListModelRole*>(object)) {
- qmlInfo(d->roleObjects.at(i)) << QObject::tr("invalid query: \"%1\"").arg(error);
- return;
- }
- }
- qmlInfo(this) << QObject::tr("invalid query: \"%1\"").arg(error);
-}
-
-void QDeclarative1XmlListModel::queryCompleted(const QDeclarative1XmlQueryResult &result)
-{
- Q_D(QDeclarative1XmlListModel);
- if (result.queryId != d->queryId)
- return;
-
- int origCount = d->size;
- bool sizeChanged = result.size != d->size;
-
- d->size = result.size;
- d->data = result.data;
- d->keyRoleResultsCache = result.keyRoleResultsCache;
- d->status = Ready;
- d->errorString.clear();
- d->queryId = -1;
-
- bool hasKeys = false;
- for (int i=0; i<d->roleObjects.count(); i++) {
- if (d->roleObjects[i]->isKey()) {
- hasKeys = true;
- break;
- }
- }
- if (!hasKeys) {
- if (!(origCount == 0 && d->size == 0)) {
- emit itemsRemoved(0, origCount);
- emit itemsInserted(0, d->size);
- emit countChanged();
- }
-
- } else {
- for (int i=0; i<result.removed.count(); i++)
- emit itemsRemoved(result.removed[i].first, result.removed[i].second);
- for (int i=0; i<result.inserted.count(); i++)
- emit itemsInserted(result.inserted[i].first, result.inserted[i].second);
-
- if (sizeChanged)
- emit countChanged();
- }
-
- emit statusChanged(d->status);
-}
-
-
-
-QT_END_NAMESPACE
-
-#include <qdeclarativexmllistmodel.moc>
diff --git a/src/qtquick1/util/qdeclarativexmllistmodel_p.h b/src/qtquick1/util/qdeclarativexmllistmodel_p.h
deleted file mode 100644
index 811207a26e..0000000000
--- a/src/qtquick1/util/qdeclarativexmllistmodel_p.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEXMLLISTMODEL_H
-#define QDECLARATIVEXMLLISTMODEL_H
-
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeinfo.h>
-
-#include <QtCore/qurl.h>
-#include <QtCore/qstringlist.h>
-
-#include <QtDeclarative/private/qlistmodelinterface_p.h>
-#include <private/qv8engine_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-
-class QDeclarativeContext;
-class QDeclarative1XmlListModelRole;
-class QDeclarative1XmlListModelPrivate;
-
-struct QDeclarative1XmlQueryResult {
- int queryId;
- int size;
- QList<QList<QVariant> > data;
- QList<QPair<int, int> > inserted;
- QList<QPair<int, int> > removed;
- QStringList keyRoleResultsCache;
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1XmlListModel : public QListModelInterface, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
- Q_ENUMS(Status)
-
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QString xml READ xml WRITE setXml NOTIFY xmlChanged)
- Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
- Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations NOTIFY namespaceDeclarationsChanged)
- Q_PROPERTY(QDeclarativeListProperty<QDeclarative1XmlListModelRole> roles READ roleObjects)
- Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_CLASSINFO("DefaultProperty", "roles")
-
-public:
- QDeclarative1XmlListModel(QObject *parent = 0);
- ~QDeclarative1XmlListModel();
-
- virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
- virtual QVariant data(int index, int role) const;
- virtual int count() const;
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
-
- QDeclarativeListProperty<QDeclarative1XmlListModelRole> roleObjects();
-
- QUrl source() const;
- void setSource(const QUrl&);
-
- QString xml() const;
- void setXml(const QString&);
-
- QString query() const;
- void setQuery(const QString&);
-
- QString namespaceDeclarations() const;
- void setNamespaceDeclarations(const QString&);
-
- Q_INVOKABLE QDeclarativeV8Handle get(int index) const;
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
- qreal progress() const;
-
- Q_INVOKABLE QString errorString() const;
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void statusChanged(QDeclarative1XmlListModel::Status);
- void progressChanged(qreal progress);
- void countChanged();
- void sourceChanged();
- void xmlChanged();
- void queryChanged();
- void namespaceDeclarationsChanged();
-
-public Q_SLOTS:
- // ### need to use/expose Expiry to guess when to call this?
- // ### property to auto-call this on reasonable Expiry?
- // ### LastModified/Age also useful to guess.
- // ### Probably also applies to other network-requesting types.
- void reload();
-
-private Q_SLOTS:
- void requestFinished();
- void requestProgress(qint64,qint64);
- void dataCleared();
- void queryCompleted(const QDeclarative1XmlQueryResult &);
- void queryError(void* object, const QString& error);
-
-private:
- Q_DECLARE_PRIVATE(QDeclarative1XmlListModel)
- Q_DISABLE_COPY(QDeclarative1XmlListModel)
-};
-
-class Q_AUTOTEST_EXPORT QDeclarative1XmlListModelRole : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
- Q_PROPERTY(bool isKey READ isKey WRITE setIsKey NOTIFY isKeyChanged)
-public:
- QDeclarative1XmlListModelRole() : m_isKey(false) {}
- ~QDeclarative1XmlListModelRole() {}
-
- QString name() const { return m_name; }
- void setName(const QString &name) {
- if (name == m_name)
- return;
- m_name = name;
- emit nameChanged();
- }
-
- QString query() const { return m_query; }
- void setQuery(const QString &query)
- {
- if (query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << tr("An XmlRole query must not start with '/'");
- return;
- }
- if (m_query == query)
- return;
- m_query = query;
- emit queryChanged();
- }
-
- bool isKey() const { return m_isKey; }
- void setIsKey(bool b) {
- if (m_isKey == b)
- return;
- m_isKey = b;
- emit isKeyChanged();
- }
-
- bool isValid() {
- return !m_name.isEmpty() && !m_query.isEmpty();
- }
-
-Q_SIGNALS:
- void nameChanged();
- void queryChanged();
- void isKeyChanged();
-
-private:
- QString m_name;
- QString m_query;
- bool m_isKey;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarative1XmlListModel)
-QML_DECLARE_TYPE(QDeclarative1XmlListModelRole)
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEXMLLISTMODEL_H
diff --git a/src/qtquick1/util/util.pri b/src/qtquick1/util/util.pri
deleted file mode 100644
index c5e68b78e3..0000000000
--- a/src/qtquick1/util/util.pri
+++ /dev/null
@@ -1,69 +0,0 @@
-INCLUDEPATH += $$PWD
-
-SOURCES += \
- $$PWD/qdeclarativeapplication.cpp \
- $$PWD/qdeclarativeview.cpp \
- $$PWD/qdeclarativeconnections.cpp \
- $$PWD/qdeclarativepackage.cpp \
- $$PWD/qdeclarativeanimation.cpp \
- $$PWD/qdeclarativesystempalette.cpp \
- $$PWD/qdeclarativespringanimation.cpp \
- $$PWD/qdeclarativesmoothedanimation.cpp \
- $$PWD/qdeclarativestate.cpp\
- $$PWD/qdeclarativetransitionmanager.cpp \
- $$PWD/qdeclarativestateoperations.cpp \
- $$PWD/qdeclarativepropertychanges.cpp \
- $$PWD/qdeclarativestategroup.cpp \
- $$PWD/qdeclarativetransition.cpp \
-# $$PWD/qdeclarativelistmodel.cpp\
-# $$PWD/qdeclarativelistmodelworkeragent.cpp \
- $$PWD/qdeclarativelistaccessor.cpp \
- $$PWD/qdeclarativeopenmetaobject.cpp \
- $$PWD/qdeclarativetimeline.cpp \
- $$PWD/qdeclarativetimer.cpp \
- $$PWD/qdeclarativebind.cpp \
- $$PWD/qdeclarativepixmapcache.cpp \
- $$PWD/qdeclarativebehavior.cpp \
- $$PWD/qdeclarativefontloader.cpp \
- $$PWD/qdeclarativestyledtext.cpp \
- $$PWD/qdeclarativeutilmodule.cpp\
-
-HEADERS += \
- $$PWD/qdeclarativeapplication_p.h \
- $$PWD/qdeclarativeutilmodule_p.h\
- $$PWD/qdeclarativeview.h \
- $$PWD/qdeclarativeconnections_p.h \
- $$PWD/qdeclarativepackage_p.h \
- $$PWD/qdeclarativeanimation_p.h \
- $$PWD/qdeclarativeanimation_p_p.h \
- $$PWD/qdeclarativesystempalette_p.h \
- $$PWD/qdeclarativespringanimation_p.h \
- $$PWD/qdeclarativesmoothedanimation_p.h \
- $$PWD/qdeclarativesmoothedanimation_p_p.h \
- $$PWD/qdeclarativestate_p.h\
- $$PWD/qdeclarativestateoperations_p.h \
- $$PWD/qdeclarativepropertychanges_p.h \
- $$PWD/qdeclarativestate_p_p.h\
- $$PWD/qdeclarativetransitionmanager_p_p.h \
- $$PWD/qdeclarativestategroup_p.h \
- $$PWD/qdeclarativetransition_p.h \
-# $$PWD/qdeclarativelistmodel_p.h\
-# $$PWD/qdeclarativelistmodel_p_p.h\
-# $$PWD/qdeclarativelistmodelworkeragent_p.h \
- $$PWD/qdeclarativelistaccessor_p.h \
- $$PWD/qdeclarativeopenmetaobject_p.h \
- $$PWD/qdeclarativetimeline_p_p.h \
- $$PWD/qdeclarativetimer_p.h \
- $$PWD/qdeclarativebind_p.h \
- $$PWD/qdeclarativepixmapcache_p.h \
- $$PWD/qdeclarativebehavior_p.h \
- $$PWD/qdeclarativefontloader_p.h \
- $$PWD/qdeclarativestyledtext_p.h \
-
-contains(QT_CONFIG, xmlpatterns) {
- QT+=xmlpatterns
- SOURCES += $$PWD/qdeclarativexmllistmodel.cpp
- HEADERS += $$PWD/qdeclarativexmllistmodel_p.h
-} else {
- DEFINES += QT_NO_XMLPATTERNS
-}