summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-01 05:05:24 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-01 05:05:24 (GMT)
commite8b2404e04ff38511a96ae2dfb2aa097c6ec8166 (patch)
tree91f59051e690551cb89df3d0304bb714c711b2f0 /src/declarative
parent8095b3074a47ff317cafdce5e8a8f955bf8c97fa (diff)
parent20def6f5fe3e02bda1c5f5873ed1923d36511312 (diff)
downloadQt-e8b2404e04ff38511a96ae2dfb2aa097c6ec8166.zip
Qt-e8b2404e04ff38511a96ae2dfb2aa097c6ec8166.tar.gz
Qt-e8b2404e04ff38511a96ae2dfb2aa097c6ec8166.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Conflicts: tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/QmlChanges.txt10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeeffects.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeevents.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp138
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h37
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp25
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativewebview.cpp3
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeglobal_p.h2
-rw-r--r--src/declarative/qml/qdeclarativelist.cpp113
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp222
-rw-r--r--src/declarative/qml/qdeclarativeproperty.h55
-rw-r--r--src/declarative/qml/qdeclarativeproperty_p.h10
-rw-r--r--src/declarative/qml/qdeclarativescript.cpp1
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp8
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp278
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h34
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h28
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp1
-rw-r--r--src/declarative/util/qdeclarativeconnection.cpp287
-rw-r--r--src/declarative/util/qdeclarativeconnections.cpp245
-rw-r--r--src/declarative/util/qdeclarativeconnections_p.h (renamed from src/declarative/util/qdeclarativeconnection_p.h)43
-rw-r--r--src/declarative/util/qdeclarativeeasefollow.cpp1
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp1
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp2
-rw-r--r--src/declarative/util/qdeclarativelistmodel_p.h2
-rw-r--r--src/declarative/util/qdeclarativepackage.cpp2
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp1
-rw-r--r--src/declarative/util/qdeclarativestate_p.h2
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp3
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp159
-rw-r--r--src/declarative/util/qdeclarativestateoperations_p.h34
-rw-r--r--src/declarative/util/qdeclarativesystempalette.cpp1
-rw-r--r--src/declarative/util/qdeclarativetimer.cpp1
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp6
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel_p.h2
-rw-r--r--src/declarative/util/util.pri4
49 files changed, 1284 insertions, 563 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index cf1080b..34e4834 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -1,7 +1,17 @@
=============================================================================
The changes below are pre Qt 4.7.0 alpha
+Flickable: renamed viewportWidth -> contentWidth
+Flickable: renamed viewportHeight -> contentHeight
+Flickable: renamed viewportX -> contentX
+Flickable: renamed viewportY -> contentY
+Removed Flickable.reportedVelocitySmoothing
Renamed MouseRegion -> MouseArea
+Connection: syntax and rename:
+ Connection { sender: a; signal: foo(); script: xxx }
+ Connection { sender: a; signal: bar(); script: yyy }
+ becomes:
+ Connections { target: a; onFoo: xxx; onBar: yyy }
QmlView
-------
diff --git a/src/declarative/graphicsitems/qdeclarativeeffects.cpp b/src/declarative/graphicsitems/qdeclarativeeffects.cpp
index efab24e..ea1f9cc 100644
--- a/src/declarative/graphicsitems/qdeclarativeeffects.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeeffects.cpp
@@ -45,6 +45,7 @@
/*!
\qmlclass Blur QGraphicsBlurEffect
+ \since 4.7
\brief The Blur object provides a blur effect.
A blur effect blurs the source item. This effect is useful for reducing details;
@@ -80,6 +81,7 @@
/*!
\qmlclass Colorize QGraphicsColorizeEffect
+ \since 4.7
\brief The Colorize object provides a colorize effect.
A colorize effect renders the source item with a tint of its color.
@@ -106,6 +108,7 @@
/*!
\qmlclass DropShadow QGraphicsDropShadowEffect
+ \since 4.7
\brief The DropShadow object provides a drop shadow effect.
A drop shadow effect renders the source item with a drop shadow. The color of
@@ -147,6 +150,7 @@
/*!
\qmlclass Opacity QGraphicsOpacityEffect
+ \since 4.7
\brief The Opacity object provides an opacity effect.
An opacity effect renders the source with an opacity. This effect is useful
diff --git a/src/declarative/graphicsitems/qdeclarativeevents.cpp b/src/declarative/graphicsitems/qdeclarativeevents.cpp
index d2cbb54..8be2f40 100644
--- a/src/declarative/graphicsitems/qdeclarativeevents.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeevents.cpp
@@ -114,6 +114,7 @@ Item {
/*!
\qmlclass MouseEvent QDeclarativeMouseEvent
+ \since 4.7
\brief The MouseEvent object provides information about a mouse event.
The position of the mouse can be found via the x and y properties.
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 9f19f53..c54ddd0 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -128,7 +128,7 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
, vWidth(-1), vHeight(-1), overShoot(true), flicked(false), moving(false), stealMouse(false)
, pressed(false), atXEnd(false), atXBeginning(true), atYEnd(false), atYBeginning(true)
, interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100)
- , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(200)
+ , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(600)
, horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0)
, flickDirection(QDeclarativeFlickable::AutoFlickDirection)
{
@@ -142,12 +142,29 @@ void QDeclarativeFlickablePrivate::init()
QObject::connect(&timeline, SIGNAL(completed()), q, SLOT(movementEnding()));
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFiltersChildEvents(true);
- QObject::connect(viewport, SIGNAL(xChanged()), q, SIGNAL(positionXChanged()));
- QObject::connect(viewport, SIGNAL(yChanged()), q, SIGNAL(positionYChanged()));
+ QObject::connect(viewport, SIGNAL(xChanged()), q, SIGNAL(contentXChanged()));
+ QObject::connect(viewport, SIGNAL(yChanged()), q, SIGNAL(contentYChanged()));
QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange()));
QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(widthChange()));
}
+/*
+ Returns the amount to overshoot by given a velocity.
+ Will be roughly in range 0 - size/4
+*/
+qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size)
+{
+ Q_Q(QDeclarativeFlickable);
+ if (maxVelocity <= 0)
+ return 0.0;
+
+ velocity = qAbs(velocity);
+ if (velocity > maxVelocity)
+ velocity = maxVelocity;
+ qreal dist = size / 4 * velocity / maxVelocity;
+ return dist;
+}
+
void QDeclarativeFlickablePrivate::flickX(qreal velocity)
{
Q_Q(QDeclarativeFlickable);
@@ -156,12 +173,12 @@ void QDeclarativeFlickablePrivate::flickX(qreal velocity)
if (velocity > 0) {
const qreal minX = q->minXExtent();
if (_moveX.value() < minX)
- maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0));
+ maxDistance = qAbs(minX -_moveX.value() + (overShoot?overShootDistance(velocity,q->width()):0));
flickTargetX = minX;
} else {
const qreal maxX = q->maxXExtent();
if (_moveX.value() > maxX)
- maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0);
+ maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?overShootDistance(velocity,q->width()):0);
flickTargetX = maxX;
}
if (maxDistance > 0) {
@@ -194,12 +211,12 @@ void QDeclarativeFlickablePrivate::flickY(qreal velocity)
if (velocity > 0) {
const qreal minY = q->minYExtent();
if (_moveY.value() < minY)
- maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0));
+ maxDistance = qAbs(minY -_moveY.value() + (overShoot?overShootDistance(velocity,q->height()):0));
flickTargetY = minY;
} else {
const qreal maxY = q->maxYExtent();
if (_moveY.value() > maxY)
- maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0);
+ maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?overShootDistance(velocity,q->height()):0);
flickTargetY = maxY;
}
if (maxDistance > 0) {
@@ -233,18 +250,24 @@ void QDeclarativeFlickablePrivate::fixupX()
if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->minXExtent())) {
timeline.reset(_moveX);
if (_moveX.value() != q->minXExtent()) {
- if (fixupDuration)
- timeline.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveY.setValue(q->minYExtent());
+ if (fixupDuration) {
+ qreal dist = q->minXExtent() - _moveX;
+ timeline.move(_moveX, q->minXExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ } else {
+ _moveX.setValue(q->minXExtent());
+ }
}
//emit flickingChanged();
} else if (_moveX.value() < q->maxXExtent()) {
timeline.reset(_moveX);
- if (fixupDuration)
- timeline.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
- _moveY.setValue(q->maxYExtent());
+ if (fixupDuration) {
+ qreal dist = q->maxXExtent() - _moveX;
+ timeline.move(_moveX, q->maxXExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ } else {
+ _moveX.setValue(q->maxXExtent());
+ }
//emit flickingChanged();
} else {
flicked = false;
@@ -272,18 +295,24 @@ void QDeclarativeFlickablePrivate::fixupY()
if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
timeline.reset(_moveY);
if (_moveY.value() != q->minYExtent()) {
- if (fixupDuration)
- timeline.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
+ if (fixupDuration) {
+ qreal dist = q->minYExtent() - _moveY;
+ timeline.move(_moveY, q->minYExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ } else {
_moveY.setValue(q->minYExtent());
+ }
}
//emit flickingChanged();
} else if (_moveY.value() < q->maxYExtent()) {
timeline.reset(_moveY);
- if (fixupDuration)
- timeline.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
- else
+ if (fixupDuration) {
+ qreal dist = q->maxYExtent() - _moveY;
+ timeline.move(_moveY, q->maxYExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ } else {
_moveY.setValue(q->maxYExtent());
+ }
//emit flickingChanged();
} else {
flicked = false;
@@ -336,6 +365,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd()
/*!
\qmlclass Flickable QDeclarativeFlickable
+ \since 4.7
\brief The Flickable item provides a surface that can be "flicked".
\inherits Item
@@ -343,7 +373,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd()
\code
Flickable {
- width: 200; height: 200; viewportWidth: image.width; viewportHeight: image.height
+ width: 200; height: 200; contentWidth: image.width; contentHeight: image.height
Image { id: image; source: "bigimage.png" }
}
\endcode
@@ -429,20 +459,20 @@ QDeclarativeFlickable::~QDeclarativeFlickable()
}
/*!
- \qmlproperty int Flickable::viewportX
- \qmlproperty int Flickable::viewportY
+ \qmlproperty int Flickable::contentX
+ \qmlproperty int Flickable::contentY
These properties hold the surface coordinate currently at the top-left
corner of the Flickable. For example, if you flick an image up 100 pixels,
- \c yPosition will be 100.
+ \c contentY will be 100.
*/
-qreal QDeclarativeFlickable::viewportX() const
+qreal QDeclarativeFlickable::contentX() const
{
Q_D(const QDeclarativeFlickable);
return -d->_moveX.value();
}
-void QDeclarativeFlickable::setViewportX(qreal pos)
+void QDeclarativeFlickable::setContentX(qreal pos)
{
Q_D(QDeclarativeFlickable);
pos = qRound(pos);
@@ -454,13 +484,13 @@ void QDeclarativeFlickable::setViewportX(qreal pos)
}
}
-qreal QDeclarativeFlickable::viewportY() const
+qreal QDeclarativeFlickable::contentY() const
{
Q_D(const QDeclarativeFlickable);
return -d->_moveY.value();
}
-void QDeclarativeFlickable::setViewportY(qreal pos)
+void QDeclarativeFlickable::setContentY(qreal pos)
{
Q_D(QDeclarativeFlickable);
pos = qRound(pos);
@@ -506,12 +536,10 @@ void QDeclarativeFlickable::setInteractive(bool interactive)
/*!
\qmlproperty real Flickable::horizontalVelocity
\qmlproperty real Flickable::verticalVelocity
- \qmlproperty real Flickable::reportedVelocitySmoothing
The instantaneous velocity of movement along the x and y axes, in pixels/sec.
The reported velocity is smoothed to avoid erratic output.
- reportedVelocitySmoothing determines how much smoothing is applied.
*/
qreal QDeclarativeFlickable::horizontalVelocity() const
{
@@ -584,8 +612,8 @@ QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea()
\list
\o AutoFlickDirection (default) - allows flicking vertically if the
- \e viewportHeight is not equal to the \e height of the Flickable.
- Allows flicking horizontally if the \e viewportWidth is not equal
+ \e contentHeight is not equal to the \e height of the Flickable.
+ Allows flicking horizontally if the \e contentWidth is not equal
to the \e width of the Flickable.
\o HorizontalFlick - allows flicking horizontally.
\o VerticalFlick - allows flicking vertically.
@@ -968,10 +996,10 @@ QDeclarativeListProperty<QDeclarativeItem> QDeclarativeFlickable::flickableChild
/*!
\qmlproperty bool Flickable::overShoot
- This property holds the number of pixels the surface may overshoot the
+ This property holds whether the surface may overshoot the
Flickable's boundaries when flicked.
- If overShoot is non-zero the contents can be flicked beyond the boundary
+ If overShoot is true the contents can be flicked beyond the boundary
of the Flickable before being moved back to the boundary. This provides
the feeling that the edges of the view are soft, rather than a hard
physical boundary.
@@ -992,26 +1020,26 @@ void QDeclarativeFlickable::setOverShoot(bool o)
}
/*!
- \qmlproperty int Flickable::viewportWidth
- \qmlproperty int Flickable::viewportHeight
+ \qmlproperty int Flickable::contentWidth
+ \qmlproperty int Flickable::contentHeight
- The dimensions of the viewport (the surface controlled by Flickable). Typically this
+ The dimensions of the content (the surface controlled by Flickable). Typically this
should be set to the combined size of the items placed in the Flickable.
\code
Flickable {
- width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height
+ width: 320; height: 480; contentWidth: image.width; contentHeight: image.height
Image { id: image; source: "bigimage.png" }
}
\endcode
*/
-qreal QDeclarativeFlickable::viewportWidth() const
+qreal QDeclarativeFlickable::contentWidth() const
{
Q_D(const QDeclarativeFlickable);
return d->vWidth;
}
-void QDeclarativeFlickable::setViewportWidth(qreal w)
+void QDeclarativeFlickable::setContentWidth(qreal w)
{
Q_D(QDeclarativeFlickable);
if (d->vWidth == w)
@@ -1024,7 +1052,7 @@ void QDeclarativeFlickable::setViewportWidth(qreal w)
// Make sure that we're entirely in view.
if (!d->pressed)
d->fixupX();
- emit viewportWidthChanged();
+ emit contentWidthChanged();
d->updateBeginningEnd();
}
@@ -1033,7 +1061,7 @@ void QDeclarativeFlickable::widthChange()
Q_D(QDeclarativeFlickable);
if (d->vWidth < 0) {
d->viewport->setWidth(width());
- emit viewportWidthChanged();
+ emit contentWidthChanged();
}
d->updateBeginningEnd();
}
@@ -1043,18 +1071,18 @@ void QDeclarativeFlickable::heightChange()
Q_D(QDeclarativeFlickable);
if (d->vHeight < 0) {
d->viewport->setHeight(height());
- emit viewportHeightChanged();
+ emit contentHeightChanged();
}
d->updateBeginningEnd();
}
-qreal QDeclarativeFlickable::viewportHeight() const
+qreal QDeclarativeFlickable::contentHeight() const
{
Q_D(const QDeclarativeFlickable);
return d->vHeight;
}
-void QDeclarativeFlickable::setViewportHeight(qreal h)
+void QDeclarativeFlickable::setContentHeight(qreal h)
{
Q_D(QDeclarativeFlickable);
if (d->vHeight == h)
@@ -1067,7 +1095,7 @@ void QDeclarativeFlickable::setViewportHeight(qreal h)
// Make sure that we're entirely in view.
if (!d->pressed)
d->fixupY();
- emit viewportHeightChanged();
+ emit contentHeightChanged();
d->updateBeginningEnd();
}
@@ -1259,22 +1287,6 @@ void QDeclarativeFlickable::setPressDelay(int delay)
emit pressDelayChanged();
}
-qreal QDeclarativeFlickable::reportedVelocitySmoothing() const
-{
- Q_D(const QDeclarativeFlickable);
- return d->reportedVelocitySmoothing;
-}
-
-void QDeclarativeFlickable::setReportedVelocitySmoothing(qreal reportedVelocitySmoothing)
-{
- Q_D(QDeclarativeFlickable);
- Q_ASSERT(reportedVelocitySmoothing >= 0);
- if (reportedVelocitySmoothing == d->reportedVelocitySmoothing)
- return;
- d->reportedVelocitySmoothing = reportedVelocitySmoothing;
- emit reportedVelocitySmoothingChanged(reportedVelocitySmoothing);
-}
-
/*!
\qmlproperty bool Flickable::moving
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
index 19fb2a9..4617688 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -56,14 +56,13 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
{
Q_OBJECT
- Q_PROPERTY(qreal viewportWidth READ viewportWidth WRITE setViewportWidth NOTIFY viewportWidthChanged)
- Q_PROPERTY(qreal viewportHeight READ viewportHeight WRITE setViewportHeight NOTIFY viewportHeightChanged)
- Q_PROPERTY(qreal viewportX READ viewportX WRITE setViewportX NOTIFY positionXChanged)
- Q_PROPERTY(qreal viewportY READ viewportY WRITE setViewportY NOTIFY positionYChanged)
+ Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
+ Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
+ Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
+ Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
- Q_PROPERTY(qreal reportedVelocitySmoothing READ reportedVelocitySmoothing WRITE setReportedVelocitySmoothing NOTIFY reportedVelocitySmoothingChanged)
Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged)
Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
@@ -98,17 +97,17 @@ public:
bool overShoot() const;
void setOverShoot(bool);
- qreal viewportWidth() const;
- void setViewportWidth(qreal);
+ qreal contentWidth() const;
+ void setContentWidth(qreal);
- qreal viewportHeight() const;
- void setViewportHeight(qreal);
+ qreal contentHeight() const;
+ void setContentHeight(qreal);
- qreal viewportX() const;
- void setViewportX(qreal pos);
+ qreal contentX() const;
+ void setContentX(qreal pos);
- qreal viewportY() const;
- void setViewportY(qreal pos);
+ qreal contentY() const;
+ void setContentY(qreal pos);
bool isMoving() const;
bool isFlicking() const;
@@ -116,9 +115,6 @@ public:
int pressDelay() const;
void setPressDelay(int delay);
- qreal reportedVelocitySmoothing() const;
- void setReportedVelocitySmoothing(qreal);
-
qreal maximumFlickVelocity() const;
void setMaximumFlickVelocity(qreal);
@@ -143,17 +139,16 @@ public:
void setFlickDirection(FlickDirection);
Q_SIGNALS:
- void viewportWidthChanged();
- void viewportHeightChanged();
- void positionXChanged();
- void positionYChanged();
+ void contentWidthChanged();
+ void contentHeightChanged();
+ void contentXChanged();
+ void contentYChanged();
void movingChanged();
void flickingChanged();
void movementStarted();
void movementEnded();
void flickStarted();
void flickEnded();
- void reportedVelocitySmoothingChanged(int);
void horizontalVelocityChanged();
void verticalVelocityChanged();
void isAtBoundaryChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index dc3a8a2..1ff4f92 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -85,6 +85,8 @@ public:
void setRoundedViewportX(qreal x);
void setRoundedViewportY(qreal y);
+ qreal overShootDistance(qreal velocity, qreal size);
+
public:
QDeclarativeItem *viewport;
QDeclarativeTimeLineValueProxy<QDeclarativeFlickablePrivate> _moveX;
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index ab5022b..b43b30b 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -133,14 +133,14 @@ public:
qreal position() const {
Q_Q(const QDeclarativeGridView);
- return flow == QDeclarativeGridView::LeftToRight ? q->viewportY() : q->viewportX();
+ return flow == QDeclarativeGridView::LeftToRight ? q->contentY() : q->contentX();
}
void setPosition(qreal pos) {
Q_Q(QDeclarativeGridView);
if (flow == QDeclarativeGridView::LeftToRight)
- q->setViewportY(pos);
+ q->setContentY(pos);
else
- q->setViewportX(pos);
+ q->setContentX(pos);
}
int size() const {
Q_Q(const QDeclarativeGridView);
@@ -315,9 +315,9 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex)
if (QDeclarativeItem *item = model->item(modelIndex, false)) {
listItem = new FxGridItem(item, q);
listItem->index = modelIndex;
+ listItem->item->setZValue(1);
// complete
model->completeItem();
- listItem->item->setZValue(1);
listItem->item->setParent(q->viewport());
unrequestedItems.remove(listItem->item);
}
@@ -458,9 +458,9 @@ void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer)
}
if (changed) {
if (flow == QDeclarativeGridView::LeftToRight)
- q->setViewportHeight(endPosition() - startPosition());
+ q->setContentHeight(endPosition() - startPosition());
else
- q->setViewportWidth(endPosition() - startPosition());
+ q->setContentWidth(endPosition() - startPosition());
} else if (!doBuffer && buffer && bufferMode != NoBuffer) {
refill(from, to, true);
}
@@ -473,9 +473,9 @@ void QDeclarativeGridViewPrivate::updateGrid()
columns = (int)qMax((flow == QDeclarativeGridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.));
if (isValid()) {
if (flow == QDeclarativeGridView::LeftToRight)
- q->setViewportHeight(endPosition() - startPosition());
+ q->setContentHeight(endPosition() - startPosition());
else
- q->setViewportWidth(endPosition() - startPosition());
+ q->setContentWidth(endPosition() - startPosition());
}
}
@@ -516,10 +516,10 @@ void QDeclarativeGridViewPrivate::layout(bool removed)
updateHighlight();
moveReason = Other;
if (flow == QDeclarativeGridView::LeftToRight) {
- q->setViewportHeight(endPosition() - startPosition());
+ q->setContentHeight(endPosition() - startPosition());
fixupY();
} else {
- q->setViewportWidth(endPosition() - startPosition());
+ q->setContentWidth(endPosition() - startPosition());
fixupX();
}
updateUnrequestedPositions();
@@ -675,6 +675,7 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex)
/*!
\qmlclass GridView QDeclarativeGridView
+ \since 4.7
\inherits Flickable
\brief The GridView item provides a grid view of items provided by a model.
@@ -1028,10 +1029,10 @@ void QDeclarativeGridView::setFlow(Flow flow)
if (d->flow != flow) {
d->flow = flow;
if (d->flow == LeftToRight) {
- setViewportWidth(-1);
+ setContentWidth(-1);
setFlickDirection(QDeclarativeFlickable::VerticalFlick);
} else {
- setViewportHeight(-1);
+ setContentHeight(-1);
setFlickDirection(QDeclarativeFlickable::HorizontalFlick);
}
d->clear();
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 338b086..99ab053 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE
QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent)
: QDeclarativeImageBase(*(new QDeclarativeImagePrivate), parent)
{
- connect(this, SIGNAL(sourceChanged(QUrl)), this, SLOT(updatePaintedGeometry()));
+ connect(this, SIGNAL(pixmapChanged()), this, SLOT(updatePaintedGeometry()));
}
QDeclarativeImage::QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent)
@@ -139,12 +139,6 @@ QDeclarativeImage::~QDeclarativeImage()
{
}
-void QDeclarativeImage::setSource(const QUrl &url)
-{
- QDeclarativeImageBase::setSource(url);
- updatePaintedGeometry();
-}
-
/*!
\qmlproperty QPixmap Image::pixmap
@@ -268,10 +262,10 @@ void QDeclarativeImage::updatePaintedGeometry()
Q_D(QDeclarativeImage);
if (d->fillMode == PreserveAspectFit) {
- qreal widthScale = width() / qreal(d->pix.width());
- qreal heightScale = height() / qreal(d->pix.height());
if (!d->pix.width() || !d->pix.height())
return;
+ qreal widthScale = width() / qreal(d->pix.width());
+ qreal heightScale = height() / qreal(d->pix.height());
if (widthScale <= heightScale) {
d->paintedWidth = width();
d->paintedHeight = widthScale * qreal(d->pix.height());
diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h
index 5b365e7..fb77ac9 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h
@@ -76,7 +76,6 @@ public:
qreal paintedWidth() const;
qreal paintedHeight() const;
- void setSource(const QUrl &url);
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
Q_SIGNALS:
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 81c5688..4b4917e 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -60,8 +60,8 @@
#include "qdeclarativeitemchangelistener_p.h"
#include <private/qpodvector_p.h>
-#include "../util/qdeclarativestate_p.h"
-#include "../util/qdeclarativenullablevalue_p_p.h"
+#include <private/qdeclarativestate_p.h>
+#include <private/qdeclarativenullablevalue_p_p.h>
#include <qdeclarative.h>
#include <qdeclarativecontext.h>
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index e6b6f2a..03303a0 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -203,14 +203,14 @@ public:
qreal position() const {
Q_Q(const QDeclarativeListView);
- return orient == QDeclarativeListView::Vertical ? q->viewportY() : q->viewportX();
+ return orient == QDeclarativeListView::Vertical ? q->contentY() : q->contentX();
}
void setPosition(qreal pos) {
Q_Q(QDeclarativeListView);
if (orient == QDeclarativeListView::Vertical)
- q->setViewportY(pos);
+ q->setContentY(pos);
else
- q->setViewportX(pos);
+ q->setContentX(pos);
}
qreal size() const {
Q_Q(const QDeclarativeListView);
@@ -382,9 +382,9 @@ public:
void updateViewport() {
Q_Q(QDeclarativeListView);
if (orient == QDeclarativeListView::Vertical) {
- q->setViewportHeight(endPosition() - startPosition() + 1);
+ q->setContentHeight(endPosition() - startPosition() + 1);
} else {
- q->setViewportWidth(endPosition() - startPosition() + 1);
+ q->setContentWidth(endPosition() - startPosition() + 1);
}
}
@@ -530,9 +530,9 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
listItem->attached->m_prevSection = sectionAt(modelIndex-1);
}
}
+ listItem->item->setZValue(1);
// complete
model->completeItem();
- listItem->item->setZValue(1);
listItem->item->setParent(q->viewport());
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -1073,7 +1073,7 @@ void QDeclarativeListViewPrivate::fixupY()
qreal pos = currentItem->position() - highlightRangeStart;
timeline.reset(_moveY);
if (fixupDuration)
- timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
else
_moveY.setValue(-pos);
vTime = timeline.time();
@@ -1085,7 +1085,7 @@ void QDeclarativeListViewPrivate::fixupY()
if (dist > 0) {
timeline.reset(_moveY);
if (fixupDuration)
- timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
else
_moveY.setValue(-pos);
vTime = timeline.time();
@@ -1155,7 +1155,7 @@ void QDeclarativeListViewPrivate::flickX(qreal velocity)
if (FxListItem *item = firstVisibleItem())
maxDistance = qAbs(item->position() + _moveX.value());
} else if (_moveX.value() < minX) {
- maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0));
+ maxDistance = qAbs(minX -_moveX.value() + (overShoot?overShootDistance(velocity, q->width()):0));
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
flickTargetX = minX;
@@ -1164,7 +1164,7 @@ void QDeclarativeListViewPrivate::flickX(qreal velocity)
if (FxListItem *item = nextVisibleItem())
maxDistance = qAbs(item->position() + _moveX.value());
} else if (_moveX.value() > maxX) {
- maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0);
+ maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?overShootDistance(velocity, q->width()):0);
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
flickTargetX = maxX;
@@ -1196,7 +1196,7 @@ void QDeclarativeListViewPrivate::flickX(qreal velocity)
overshootDist = 0.0;
} else {
flickTargetX = velocity > 0 ? minX : maxX;
- overshootDist = overShoot ? 30 : 0;
+ overshootDist = overShoot ? overShootDistance(v, q->width()) : 0;
}
timeline.reset(_moveX);
timeline.accel(_moveX, v, accel, maxDistance + overshootDist);
@@ -1253,7 +1253,7 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity)
if (FxListItem *item = firstVisibleItem())
maxDistance = qAbs(item->position() + _moveY.value());
} else if (_moveY.value() < minY) {
- maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0));
+ maxDistance = qAbs(minY -_moveY.value() + (overShoot?overShootDistance(velocity, q->height()):0));
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
flickTargetY = minY;
@@ -1262,7 +1262,7 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity)
if (FxListItem *item = nextVisibleItem())
maxDistance = qAbs(item->position() + _moveY.value());
} else if (_moveY.value() > maxY) {
- maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0);
+ maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?overShootDistance(velocity, q->height()):0);
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
flickTargetY = maxY;
@@ -1294,7 +1294,7 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity)
overshootDist = 0.0;
} else {
flickTargetY = velocity > 0 ? minY : maxY;
- overshootDist = overShoot ? 30 : 0;
+ overshootDist = overShoot ? overShootDistance(v, q->height()) : 0;
}
timeline.reset(_moveY);
timeline.accel(_moveY, v, accel, maxDistance + overshootDist);
@@ -1819,10 +1819,10 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie
if (d->orient != orientation) {
d->orient = orientation;
if (d->orient == QDeclarativeListView::Vertical) {
- setViewportWidth(-1);
+ setContentWidth(-1);
setFlickDirection(VerticalFlick);
} else {
- setViewportHeight(-1);
+ setContentHeight(-1);
setFlickDirection(HorizontalFlick);
}
d->clear();
@@ -1980,6 +1980,12 @@ void QDeclarativeListView::setHighlightResizeSpeed(qreal speed)
visible item at the time the mouse button is released. This mode is particularly
useful for moving one page at a time.
\endlist
+
+ snapMode does not affect the currentIndex. To update the
+ currentIndex as the list is moved set \e highlightRangeMode
+ to \e StrictlyEnforceRange.
+
+ \sa highlightRangeMode
*/
QDeclarativeListView::SnapMode QDeclarativeListView::snapMode() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index c131f4c..f1b0213 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -111,7 +111,7 @@ QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex)
{
Q_Q(QDeclarativePathView);
requestedIndex = modelIndex;
- QDeclarativeItem *item = model->item(modelIndex);
+ QDeclarativeItem *item = model->item(modelIndex, false);
if (item) {
if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item))
static_cast<QDeclarativePathViewAttached *>(obj)->setOnPath(true);
@@ -655,6 +655,7 @@ void QDeclarativePathViewPrivate::regenerate()
}
items.append(item);
item->setZValue(i);
+ model->completeItem();
if (currentIndex == index)
item->setFocus(true);
}
@@ -715,6 +716,7 @@ void QDeclarativePathView::refill()
int index = (d->firstIndex + d->items.count())%d->model->count();
QDeclarativeItem *item = d->getItem(index);
item->setZValue(wrapIndex);
+ d->model->completeItem();
if (d->currentIndex == index)
item->setFocus(true);
d->items << item;
@@ -731,6 +733,7 @@ void QDeclarativePathView::refill()
d->firstIndex = d->model->count() - 1;
QDeclarativeItem *item = d->getItem(d->firstIndex);
item->setZValue(d->firstIndex);
+ d->model->completeItem();
if (d->currentIndex == d->firstIndex)
item->setFocus(true);
d->items.prepend(item);
@@ -757,6 +760,7 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count)
for (int i = 0; i < count; ++i) {
QDeclarativeItem *item = d->getItem(modelIndex + i);
item->setZValue(modelIndex + i);
+ d->model->completeItem();
d->items.insert(modelIndex + i, item);
}
refill();
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
index ff6fc4b..f38847c 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
@@ -44,7 +44,7 @@
#include "qdeclarativeitem.h"
-#include "../util/qdeclarativestate_p.h"
+#include <private/qdeclarativestate_p.h>
#include <private/qpodvector_p.h>
#include <QtCore/QObject>
diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h
index 92b3f91..fbf9040 100644
--- a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h
@@ -44,7 +44,7 @@
#include "qdeclarativeborderimage_p.h"
-#include "../util/qdeclarativepixmapcache_p.h"
+#include <private/qdeclarativepixmapcache_p.h>
#include <qdeclarative.h>
#include <QtCore/QString>
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 9919904..3382628 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -704,6 +704,8 @@ bool QDeclarativeTextInput::event(QEvent* ev)
break;
default:
handled = d->control->processEvent(ev);
+ if (ev->type() == QEvent::InputMethod)
+ updateSize();
}
if(!handled)
return QDeclarativePaintedItem::event(ev);
diff --git a/src/declarative/graphicsitems/qdeclarativewebview.cpp b/src/declarative/graphicsitems/qdeclarativewebview.cpp
index 61b5b56..a2b16ba 100644
--- a/src/declarative/graphicsitems/qdeclarativewebview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativewebview.cpp
@@ -177,6 +177,8 @@ void QDeclarativeWebView::init()
{
Q_D(QDeclarativeWebView);
+ QWebSettings::enablePersistentStorage();
+
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::LeftButton);
setFlag(QGraphicsItem::ItemHasNoContents, false);
@@ -955,6 +957,7 @@ void QDeclarativeWebView::setPage(QWebPage *page)
connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect)));
connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SLOT(pageUrlChanged()));
connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
+ connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged()));
connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged()));
connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(noteContentsSizeChanged(QSize)));
connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout()));
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index cecca65..88ca5cd 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -130,7 +130,7 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
if (data->property.propertyType() == qMetaTypeId<QDeclarativeBinding *>()) {
- int idx = data->property.coreIndex();
+ int idx = data->property.index();
Q_ASSERT(idx != -1);
@@ -223,7 +223,7 @@ void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteF
int QDeclarativeBinding::propertyIndex()
{
Q_D(QDeclarativeBinding);
- return d->bindingData()->property.coreIndex();
+ return d->bindingData()->property.index();
}
bool QDeclarativeBinding::enabled() const
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index ce396fd..6a5a102 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -104,7 +104,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QObject *scope, const QMetaMeth
// is that they both do the work to figure it out. Boo hoo.
if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
- QDeclarativeGraphics_setParent_noEvent(this, parent);
+ QDeclarative_setParent_noEvent(this, parent);
QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
}
@@ -120,7 +120,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, cons
// is that they both do the work to figure it out. Boo hoo.
if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
- QDeclarativeGraphics_setParent_noEvent(this, parent);
+ QDeclarative_setParent_noEvent(this, parent);
QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
m_expression = new QDeclarativeExpression(ctxt, val, scope);
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index fe63ad2..6a2d2d1 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -618,7 +618,7 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContext *context, const QB
QObject *rv = begin(ctxt, ep, cc, start, count, &state, bindings);
if (rv) {
- QDeclarativeGraphics_setParent_noEvent(ctxt, rv);
+ QDeclarative_setParent_noEvent(ctxt, rv);
} else {
delete ctxt;
}
diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h
index 89da399..a95449b 100644
--- a/src/declarative/qml/qdeclarativeenginedebug_p.h
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include "../debugger/qdeclarativedebugservice_p.h"
+#include <private/qdeclarativedebugservice_p.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
diff --git a/src/declarative/qml/qdeclarativeglobal_p.h b/src/declarative/qml/qdeclarativeglobal_p.h
index bbdc91c..1041992 100644
--- a/src/declarative/qml/qdeclarativeglobal_p.h
+++ b/src/declarative/qml/qdeclarativeglobal_p.h
@@ -79,7 +79,7 @@ struct QDeclarativeGraphics_DerivedObject : public QObject
neither \a parent nor the object's previous parent (if it had one) will
receive ChildRemoved or ChildAdded events.
*/
-inline void QDeclarativeGraphics_setParent_noEvent(QObject *object, QObject *parent)
+inline void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
{
static_cast<QDeclarativeGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
}
diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp
index af720d7..9691f32 100644
--- a/src/declarative/qml/qdeclarativelist.cpp
+++ b/src/declarative/qml/qdeclarativelist.cpp
@@ -85,18 +85,57 @@ void QDeclarativeListReferencePrivate::release()
delete this;
}
+/*!
+\class QDeclarativeListReference
+\brief The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties.
+
+QDeclarativeListReference allows programs to read from, and assign values to a QML list property in a
+simple and type safe way. A QDeclarativeListReference can be created by passing an object and property
+name or through a QDeclarativeProperty instance. These two are equivalant:
+
+\code
+QDeclarativeListReference ref1(object, "children");
+
+QDeclarativeProperty ref2(object, "children");
+QDeclarativeListReference ref2 = qvariant_cast<QDeclarativeListReference>(ref2.read());
+\endcode
+
+Not all QML list properties support all operations. A set of methods, canAppend(), canAt(), canClear() and
+canCount() allow programs to query whether an operation is supported on a given property.
+
+QML list properties are typesafe. Only QObject's that derive from the correct base class can be assigned to
+the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported.
+Attempting to add objects of the incorrect type to a list property will fail.
+
+Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure
+that it does not request an out of range element using the count() method before calling at().
+*/
+
+/*!
+Constructs an invalid instance.
+*/
QDeclarativeListReference::QDeclarativeListReference()
: d(0)
{
}
-QDeclarativeListReference::QDeclarativeListReference(QObject *o, const char *property, QDeclarativeEngine *engine)
+/*!
+Constructs a QDeclarativeListReference for \a object's \a property. If \a property is not a list
+property, an invalid QDeclarativeListReference is created. If \a object is destroyed after
+the reference is constructed, it will automatically become invalid. That is, it is safe to hold
+QDeclarativeListReference instances even after \a object is deleted.
+
+Passing \a engine is required to access some QML created list properties. If in doubt, and an engine
+is available, pass it.
+*/
+QDeclarativeListReference::QDeclarativeListReference(QObject *object, const char *property, QDeclarativeEngine *engine)
: d(0)
{
- if (!o || !property) return;
+ if (!object || !property) return;
QDeclarativePropertyCache::Data local;
- QDeclarativePropertyCache::Data *data = QDeclarativePropertyCache::property(engine, o, QLatin1String(property), local);
+ QDeclarativePropertyCache::Data *data =
+ QDeclarativePropertyCache::property(engine, object, QLatin1String(property), local);
if (!data || !(data->flags & QDeclarativePropertyCache::Data::IsQList)) return;
@@ -106,20 +145,22 @@ QDeclarativeListReference::QDeclarativeListReference(QObject *o, const char *pro
if (listType == -1) return;
d = new QDeclarativeListReferencePrivate;
- d->object = o;
+ d->object = object;
d->elementType = p?p->rawMetaObjectForType(listType):QDeclarativeMetaType::qmlType(listType)->baseMetaObject();
d->propertyType = data->propType;
void *args[] = { &d->property, 0 };
- QMetaObject::metacall(o, QMetaObject::ReadProperty, data->coreIndex, args);
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex, args);
}
+/*! \internal */
QDeclarativeListReference::QDeclarativeListReference(const QDeclarativeListReference &o)
: d(o.d)
{
if (d) d->addref();
}
+/*! \internal */
QDeclarativeListReference &QDeclarativeListReference::operator=(const QDeclarativeListReference &o)
{
if (o.d) o.d->addref();
@@ -128,60 +169,108 @@ QDeclarativeListReference &QDeclarativeListReference::operator=(const QDeclarati
return *this;
}
+/*! \internal */
QDeclarativeListReference::~QDeclarativeListReference()
{
if (d) d->release();
}
+/*!
+Returns true if the instance refers to a valid list property, otherwise false.
+*/
bool QDeclarativeListReference::isValid() const
{
return d && d->object;
}
+/*!
+Returns the list property's object. Returns 0 if the reference is invalid.
+*/
QObject *QDeclarativeListReference::object() const
{
if (isValid()) return d->object;
else return 0;
}
+/*!
+Returns the QMetaObject for the elements stored in the list property. Returns 0 if the reference
+is invalid.
+
+The QMetaObject can be used ahead of time to determine whether a given instance can be added
+to a list.
+*/
const QMetaObject *QDeclarativeListReference::listElementType() const
{
if (isValid()) return d->elementType;
else return 0;
}
+/*!
+Returns true if the list property can be appended to, otherwise false. Returns false if the
+reference is invalid.
+
+\sa append()
+*/
bool QDeclarativeListReference::canAppend() const
{
return (isValid() && d->property.append);
}
+/*!
+Returns true if the list property can queried by index, otherwise false. Returns false if the
+reference is invalid.
+
+\sa at()
+*/
bool QDeclarativeListReference::canAt() const
{
return (isValid() && d->property.at);
}
+/*!
+Returns true if the list property can be cleared, otherwise false. Returns false if the
+reference is invalid.
+
+\sa clear()
+*/
bool QDeclarativeListReference::canClear() const
{
return (isValid() && d->property.clear);
}
+/*!
+Returns true if the list property can be queried for its element count, otherwise false.
+Returns false if the reference is invalid.
+
+\sa count()
+*/
bool QDeclarativeListReference::canCount() const
{
return (isValid() && d->property.count);
}
-bool QDeclarativeListReference::append(QObject *o) const
+/*!
+Appends \a object to the list. Returns true if the operation succeeded, otherwise false.
+
+\sa canAppend()
+*/
+bool QDeclarativeListReference::append(QObject *object) const
{
if (!canAppend()) return false;
- if (o && !QDeclarativePropertyPrivate::canConvert(o->metaObject(), d->elementType))
+ if (object && !QDeclarativePropertyPrivate::canConvert(object->metaObject(), d->elementType))
return false;
- d->property.append(&d->property, o);
+ d->property.append(&d->property, object);
return true;
}
+/*!
+Returns the list element at \a index, or 0 if the operation failed.
+
+\sa canAt()
+*/
QObject *QDeclarativeListReference::at(int index) const
{
if (!canAt()) return 0;
@@ -189,6 +278,11 @@ QObject *QDeclarativeListReference::at(int index) const
return d->property.at(&d->property, index);
}
+/*!
+Clears the list. Returns true if the operation succeeded, otherwise false.
+
+\sa canClear()
+*/
bool QDeclarativeListReference::clear() const
{
if (!canClear()) return false;
@@ -198,6 +292,9 @@ bool QDeclarativeListReference::clear() const
return true;
}
+/*!
+Returns the number of objects in the list, or 0 if the operation failed.
+*/
int QDeclarativeListReference::count() const
{
if (!canCount()) return 0;
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index 7ead1b5..e1ec2cd 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -63,10 +63,30 @@
QT_BEGIN_NAMESPACE
/*!
- \class QDeclarativeProperty
- \brief The QDeclarativeProperty class abstracts accessing QML properties.
- \internal
- */
+\class QDeclarativeProperty
+\brief The QDeclarativeProperty class abstracts accessing properties on objects created from QML.
+
+As QML uses Qt's meta-type system all of the existing QMetaObject classes can be used to introspect
+and interact with objects created by QML. However, some of the new features provided by QML - such
+as type safety and attached properties - are most easily used through the QDeclarativeProperty class
+that simplifies some of their natural complexity.
+
+Unlike QMetaProperty which represents a property on a class type, QDeclarativeProperty encapsulates
+a property on a specific object instance. To read a property's value, programmers create a
+QDeclarativeProperty instance and call the read() method. Likewise to write a property value the
+write() method is used.
+
+\code
+
+QObject *object = declarativeComponent.create();
+
+QDeclarativeProperty property(object, "font.pixelSize");
+qWarning() << "Current pixel size:" << property.read().toInt();
+property.write(24);
+qWarning() << "Pixel size should now be 24:" << property.read().toInt();
+
+\endcode
+*/
/*!
Create an invalid QDeclarativeProperty.
@@ -95,7 +115,6 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj)
}
/*!
- \internal
Creates a QDeclarativeProperty for the default property of \a obj. If there is no
default property, an invalid QDeclarativeProperty will be created.
*/
@@ -104,6 +123,20 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeContext *ct
{
d->q = this;
d->context = ctxt;
+ d->engine = ctxt?ctxt->engine():0;
+ d->initDefault(obj);
+}
+
+/*!
+ Creates a QDeclarativeProperty for the default property of \a obj. If there is no
+ default property, an invalid QDeclarativeProperty will be created.
+ */
+QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeEngine *engine)
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+ d->context = 0;
+ d->engine = engine;
d->initDefault(obj);
}
@@ -117,10 +150,8 @@ void QDeclarativePropertyPrivate::initDefault(QObject *obj)
QMetaProperty p = QDeclarativeMetaType::defaultProperty(obj);
core.load(p);
- if (core.isValid()) {
- isDefaultProperty = true;
+ if (core.isValid())
object = obj;
- }
}
/*!
@@ -135,7 +166,6 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name)
}
/*!
- \internal
Creates a QDeclarativeProperty for the property \a name of \a obj.
*/
QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeContext *ctxt)
@@ -143,8 +173,22 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QD
{
d->q = this;
d->context = ctxt;
+ d->engine = ctxt?ctxt->engine():0;
+ d->initProperty(obj, name);
+ if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
+}
+
+/*!
+ Creates a QDeclarativeProperty for the property \a name of \a obj.
+ */
+QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeEngine *engine)
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+ d->context = 0;
+ d->engine = engine;
d->initProperty(obj, name);
- if (!isValid()) { d->object = 0; d->context = 0; }
+ if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
}
Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes);
@@ -153,7 +197,6 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name
{
if (!obj) return;
- QDeclarativeEngine *engine = context?context->engine():0;
QDeclarativeTypeNameCache *typeNameCache = context?QDeclarativeContextPrivate::get(context)->imports:0;
QStringList path = name.split(QLatin1Char('.'));
@@ -247,7 +290,7 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name
// Property
QDeclarativePropertyCache::Data local;
QDeclarativePropertyCache::Data *property =
- QDeclarativePropertyCache::property(context?context->engine():0, currentObject, terminal, local);
+ QDeclarativePropertyCache::property(engine, currentObject, terminal, local);
if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction)) {
object = currentObject;
core = *property;
@@ -268,10 +311,10 @@ QDeclarativeProperty::QDeclarativeProperty(const QDeclarativeProperty &other)
This enum specifies a category of QML property.
- \value InvalidCategory The property is invalid.
- \value List The property is a QList pointer
+ \value InvalidCategory The property is invalid, or is a signal property.
+ \value List The property is a QDeclarativeListProperty list property
\value Object The property is a QObject derived type pointer
- \value Normal The property is none of the above.
+ \value Normal The property is a normal value property.
*/
/*!
@@ -282,7 +325,6 @@ QDeclarativeProperty::QDeclarativeProperty(const QDeclarativeProperty &other)
\value Invalid The property is invalid.
\value Property The property is a regular Qt property.
\value SignalProperty The property is a signal property.
- \value Default The property is the default property.
*/
/*!
@@ -298,7 +340,7 @@ QDeclarativePropertyPrivate::propertyTypeCategory() const
{
uint type = q->type();
- if (type & QDeclarativeProperty::ValueTypeProperty) {
+ if (isValueType()) {
return QDeclarativeProperty::Normal;
} else if (type & QDeclarativeProperty::Property) {
int type = propertyType();
@@ -323,7 +365,7 @@ QDeclarativePropertyPrivate::propertyTypeCategory() const
*/
const char *QDeclarativeProperty::propertyTypeName() const
{
- if (type() & ValueTypeProperty) {
+ if (d->isValueType()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context);
QDeclarativeValueType *valueType = 0;
@@ -365,10 +407,15 @@ int QDeclarativeProperty::propertyType() const
return d->propertyType();
}
+bool QDeclarativePropertyPrivate::isValueType() const
+{
+ return valueType.valueTypeCoreIdx != -1;
+}
+
int QDeclarativePropertyPrivate::propertyType() const
{
uint type = q->type();
- if (type & QDeclarativeProperty::ValueTypeProperty) {
+ if (isValueType()) {
return valueType.valueTypePropType;
} else if (type & QDeclarativeProperty::Property) {
if (core.propType == (int)QVariant::LastType)
@@ -387,10 +434,8 @@ QDeclarativeProperty::Type QDeclarativeProperty::type() const
{
if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction)
return SignalProperty;
- else if (d->valueType.valueTypeCoreIdx != -1)
- return (Type)(Property | ValueTypeProperty);
else if (d->core.isValid())
- return (Type)(Property | ((d->isDefaultProperty)?Default:0));
+ return Property;
else
return Invalid;
}
@@ -404,11 +449,11 @@ bool QDeclarativeProperty::isProperty() const
}
/*!
- Returns true if this QDeclarativeProperty represents a default property.
+ Returns true if this QDeclarativeProperty represents a QML signal property.
*/
-bool QDeclarativeProperty::isDefault() const
+bool QDeclarativeProperty::isSignalProperty() const
{
- return type() & Default;
+ return type() & SignalProperty;
}
/*!
@@ -425,9 +470,9 @@ QObject *QDeclarativeProperty::object() const
QDeclarativeProperty &QDeclarativeProperty::operator=(const QDeclarativeProperty &other)
{
d->context = other.d->context;
+ d->engine = other.d->engine;
d->object = other.d->object;
- d->isDefaultProperty = other.d->isDefaultProperty;
d->isNameCached = other.d->isNameCached;
d->core = other.d->core;
d->nameCache = other.d->nameCache;
@@ -495,10 +540,10 @@ QString QDeclarativeProperty::name() const
if (!d->isNameCached) {
// ###
if (!d->object) {
- } else if (type() & ValueTypeProperty) {
+ } else if (d->isValueType()) {
QString rv = d->core.name(d->object) + QLatin1Char('.');
- QDeclarativeEnginePrivate *ep = d->context?QDeclarativeEnginePrivate::get(d->context->engine()):0;
+ QDeclarativeEnginePrivate *ep = d->engine?QDeclarativeEnginePrivate::get(d->engine):0;
QDeclarativeValueType *valueType = 0;
if (ep) valueType = ep->valueTypes[d->core.propType];
else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType);
@@ -646,7 +691,7 @@ QDeclarativePropertyPrivate::signalExpression(const QDeclarativeProperty &that)
QObject *child = children.at(ii);
QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal && signal->index() == that.coreIndex())
+ if (signal && signal->index() == that.index())
return signal->expression();
}
@@ -675,7 +720,7 @@ QDeclarativePropertyPrivate::setSignalExpression(const QDeclarativeProperty &tha
QObject *child = children.at(ii);
QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal && signal->index() == that.coreIndex())
+ if (signal && signal->index() == that.index())
return signal->setExpression(expr);
}
@@ -707,10 +752,48 @@ QVariant QDeclarativeProperty::read() const
return QVariant();
}
+/*!
+Return the \a name property value of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name);
+ p.read();
+\endcode
+*/
+QVariant QDeclarativeProperty::read(QObject *object, const QString &name)
+{
+ QDeclarativeProperty p(object, name);
+ return p.read();
+}
+
+/*!
+Return the \a name property value of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name, context);
+ p.read();
+\endcode
+*/
+QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeContext *ctxt)
+{
+ QDeclarativeProperty p(object, name, ctxt);
+ return p.read();
+}
+
+/*!
+Return the \a name property value of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name, engine);
+ p.read();
+\endcode
+*/
+QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeEngine *engine)
+{
+ QDeclarativeProperty p(object, name, engine);
+ return p.read();
+}
+
QVariant QDeclarativePropertyPrivate::readValueProperty()
{
- uint type = q->type();
- if(type & QDeclarativeProperty::ValueTypeProperty) {
+ if(isValueType()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
QDeclarativeValueType *valueType = 0;
@@ -731,7 +814,7 @@ QVariant QDeclarativePropertyPrivate::readValueProperty()
QDeclarativeListProperty<QObject> prop;
void *args[] = { &prop, 0 };
QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
- return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, context?context->engine():0));
+ return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine));
} else {
@@ -740,9 +823,7 @@ QVariant QDeclarativePropertyPrivate::readValueProperty()
}
}
-//###
//writeEnumProperty MIRRORS the relelvant bit of QMetaProperty::write AND MUST BE KEPT IN SYNC!
-//###
bool QDeclarativePropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
{
if (!object || !prop.isWritable())
@@ -789,8 +870,7 @@ bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, Writ
}
bool rv = false;
- uint type = q->type();
- if (type & QDeclarativeProperty::ValueTypeProperty) {
+ if (isValueType()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
QDeclarativeValueType *writeBack = 0;
@@ -931,13 +1011,13 @@ bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePrope
for (int ii = 0; ii < list.count(); ++ii) {
QObject *o = list.at(ii);
- if (!canConvert(o->metaObject(), listType))
+ if (o && !canConvert(o->metaObject(), listType))
o = 0;
prop.append(&prop, (void *)o);
}
} else {
QObject *o = enginePriv?enginePriv->toQObject(value):QDeclarativeMetaType::toQObject(value);
- if (!canConvert(o->metaObject(), listType))
+ if (o && !canConvert(o->metaObject(), listType))
o = 0;
prop.append(&prop, (void *)o);
}
@@ -994,6 +1074,47 @@ bool QDeclarativeProperty::write(const QVariant &value) const
}
/*!
+Writes \a value to the \a name property of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name);
+ p.write(value);
+\endcode
+*/
+bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value)
+{
+ QDeclarativeProperty p(object, name);
+ return p.write(value);
+}
+
+/*!
+Writes \a value to the \a name property of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name, ctxt);
+ p.write(value);
+\endcode
+*/
+bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value,
+ QDeclarativeContext *ctxt)
+{
+ QDeclarativeProperty p(object, name, ctxt);
+ return p.write(value);
+}
+
+/*!
+Writes \a value to the \a name property of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name, engine);
+ p.write(value);
+\endcode
+*/
+bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value,
+ QDeclarativeEngine *engine)
+{
+ QDeclarativeProperty p(object, name, engine);
+ return p.write(value);
+}
+
+/*!
Resets the property value.
*/
bool QDeclarativeProperty::reset() const
@@ -1020,7 +1141,7 @@ bool QDeclarativePropertyPrivate::write(const QDeclarativeProperty &that,
/*!
Returns true if the property has a change notifier signal, otherwise false.
*/
-bool QDeclarativeProperty::hasChangedNotifier() const
+bool QDeclarativeProperty::hasNotifySignal() const
{
if (type() & Property && d->object) {
return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal();
@@ -1035,7 +1156,7 @@ bool QDeclarativeProperty::hasChangedNotifier() const
Some properties, such as attached properties or those whose value never
changes, do not require a change notifier.
*/
-bool QDeclarativeProperty::needsChangedNotifier() const
+bool QDeclarativeProperty::needsNotifySignal() const
{
return type() & Property && !property().isConstant();
}
@@ -1048,7 +1169,7 @@ bool QDeclarativeProperty::needsChangedNotifier() const
change notifier signal, or if the \a dest object does
not have the specified \a method.
*/
-bool QDeclarativeProperty::connectNotifier(QObject *dest, int method) const
+bool QDeclarativeProperty::connectNotifySignal(QObject *dest, int method) const
{
if (!(type() & Property) || !d->object)
return false;
@@ -1069,7 +1190,7 @@ bool QDeclarativeProperty::connectNotifier(QObject *dest, int method) const
change notifier signal, or if the \a dest object does
not have the specified \a slot.
*/
-bool QDeclarativeProperty::connectNotifier(QObject *dest, const char *slot) const
+bool QDeclarativeProperty::connectNotifySignal(QObject *dest, const char *slot) const
{
if (!(type() & Property) || !d->object)
return false;
@@ -1086,7 +1207,7 @@ bool QDeclarativeProperty::connectNotifier(QObject *dest, const char *slot) cons
/*!
Return the Qt metaobject index of the property.
*/
-int QDeclarativeProperty::coreIndex() const
+int QDeclarativeProperty::index() const
{
return d->core.coreIndex;
}
@@ -1097,7 +1218,7 @@ int QDeclarativePropertyPrivate::valueTypeCoreIndex(const QDeclarativeProperty &
}
struct SerializedData {
- QDeclarativeProperty::Type type;
+ bool isValueType;
QDeclarativePropertyCache::Data core;
};
@@ -1112,7 +1233,7 @@ QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObj
QMetaProperty subProp = subObject->property(subIndex);
ValueTypeSerializedData sd;
- sd.type = QDeclarativeProperty::ValueTypeProperty;
+ sd.isValueType = true;
sd.core.load(metaObject->property(index));
sd.valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(subProp);
sd.valueType.valueTypeCoreIdx = subIndex;
@@ -1126,7 +1247,7 @@ QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObj
QByteArray QDeclarativePropertyPrivate::saveProperty(const QMetaObject *metaObject, int index)
{
SerializedData sd;
- sd.type = QDeclarativeProperty::Property;
+ sd.isValueType = false;
sd.core.load(metaObject->property(index));
QByteArray rv((const char *)&sd, sizeof(sd));
@@ -1143,14 +1264,15 @@ QDeclarativePropertyPrivate::restore(const QByteArray &data, QObject *object, QD
prop.d->object = object;
prop.d->context = ctxt;
+ prop.d->engine = ctxt?ctxt->engine():0;
const SerializedData *sd = (const SerializedData *)data.constData();
- if (sd->type == QDeclarativeProperty::Property) {
- prop.d->core = sd->core;
- } else if(sd->type == QDeclarativeProperty::ValueTypeProperty) {
+ if (sd->isValueType) {
const ValueTypeSerializedData *vt = (const ValueTypeSerializedData *)sd;
prop.d->core = vt->core;
prop.d->valueType = vt->valueType;
+ } else {
+ prop.d->core = sd->core;
}
return prop;
diff --git a/src/declarative/qml/qdeclarativeproperty.h b/src/declarative/qml/qdeclarativeproperty.h
index be1065e..73bccf3 100644
--- a/src/declarative/qml/qdeclarativeproperty.h
+++ b/src/declarative/qml/qdeclarativeproperty.h
@@ -51,11 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QObject;
-class QDeclarativeAbstractBinding;
-class QDeclarativeExpression;
-class QStringList;
class QVariant;
-struct QMetaObject;
class QDeclarativeContext;
class QDeclarativeEngine;
@@ -70,11 +66,10 @@ public:
Normal
};
- enum Type { Invalid = 0x00,
- Property = 0x01,
- SignalProperty = 0x02,
- Default = 0x08,
- ValueTypeProperty = 0x10
+ enum Type {
+ Invalid,
+ Property,
+ SignalProperty
};
QDeclarativeProperty();
@@ -82,45 +77,55 @@ public:
QDeclarativeProperty(QObject *);
QDeclarativeProperty(QObject *, QDeclarativeContext *);
+ QDeclarativeProperty(QObject *, QDeclarativeEngine *);
QDeclarativeProperty(QObject *, const QString &);
QDeclarativeProperty(QObject *, const QString &, QDeclarativeContext *);
+ QDeclarativeProperty(QObject *, const QString &, QDeclarativeEngine *);
QDeclarativeProperty(const QDeclarativeProperty &);
QDeclarativeProperty &operator=(const QDeclarativeProperty &);
+ bool operator==(const QDeclarativeProperty &) const;
+
+ Type type() const;
+ bool isValid() const;
+ bool isProperty() const;
+ bool isSignalProperty() const;
+
+ int propertyType() const;
+ PropertyTypeCategory propertyTypeCategory() const;
+ const char *propertyTypeName() const;
+
QString name() const;
QVariant read() const;
+ static QVariant read(QObject *, const QString &);
+ static QVariant read(QObject *, const QString &, QDeclarativeContext *);
+ static QVariant read(QObject *, const QString &, QDeclarativeEngine *);
+
bool write(const QVariant &) const;
+ static bool write(QObject *, const QString &, const QVariant &);
+ static bool write(QObject *, const QString &, const QVariant &, QDeclarativeContext *);
+ static bool write(QObject *, const QString &, const QVariant &, QDeclarativeEngine *);
+
bool reset() const;
- bool hasChangedNotifier() const;
- bool needsChangedNotifier() const;
- bool connectNotifier(QObject *dest, const char *slot) const;
- bool connectNotifier(QObject *dest, int method) const;
+ bool hasNotifySignal() const;
+ bool needsNotifySignal() const;
+ bool connectNotifySignal(QObject *dest, const char *slot) const;
+ bool connectNotifySignal(QObject *dest, int method) const;
- Type type() const;
- bool isProperty() const;
- bool isDefault() const;
bool isWritable() const;
bool isDesignable() const;
bool isResettable() const;
- bool isValid() const;
QObject *object() const;
- int propertyType() const;
- PropertyTypeCategory propertyTypeCategory() const;
- const char *propertyTypeName() const;
-
- bool operator==(const QDeclarativeProperty &) const;
-
- int coreIndex() const;
+ int index() const;
QMetaProperty property() const;
QMetaMethod method() const;
private:
- friend class QDeclarativeEnginePrivate;
friend class QDeclarativePropertyPrivate;
QDeclarativePropertyPrivate *d;
};
diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h
index d0ad09c..1fda7f4 100644
--- a/src/declarative/qml/qdeclarativeproperty_p.h
+++ b/src/declarative/qml/qdeclarativeproperty_p.h
@@ -64,6 +64,7 @@ QT_BEGIN_NAMESPACE
class QDeclarativeContext;
class QDeclarativeEnginePrivate;
+class QDeclarativeExpression;
class Q_AUTOTEST_EXPORT QDeclarativePropertyPrivate
{
public:
@@ -71,20 +72,20 @@ public:
Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
QDeclarativePropertyPrivate()
- : q(0), context(0), object(0), isDefaultProperty(false), isNameCached(false) {}
+ : q(0), context(0), engine(0), object(0), isNameCached(false) {}
QDeclarativePropertyPrivate(const QDeclarativePropertyPrivate &other)
- : q(0), context(other.context), object(other.object),
- isDefaultProperty(other.isDefaultProperty), isNameCached(other.isNameCached),
+ : q(0), context(other.context), engine(other.engine), object(other.object),
+ isNameCached(other.isNameCached),
core(other.core), nameCache(other.nameCache),
valueType(other.valueType) {}
QDeclarativeProperty *q;
QDeclarativeContext *context;
+ QDeclarativeEngine *engine;
QDeclarativeGuard<QObject> object;
- bool isDefaultProperty:1;
bool isNameCached:1;
QDeclarativePropertyCache::Data core;
QString nameCache;
@@ -97,6 +98,7 @@ public:
QMetaMethod findSignal(QObject *, const QString &);
+ bool isValueType() const;
int propertyType() const;
QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const;
diff --git a/src/declarative/qml/qdeclarativescript.cpp b/src/declarative/qml/qdeclarativescript.cpp
index acfb9e1..ac4b2c1 100644
--- a/src/declarative/qml/qdeclarativescript.cpp
+++ b/src/declarative/qml/qdeclarativescript.cpp
@@ -43,6 +43,7 @@
/*!
\qmlclass Script QDeclarativeScript
+ \since 4.7
\brief The Script element provides a way to add JavaScript code snippets in QML.
\ingroup group_utility
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index baa98bd..fc3722d 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -217,7 +217,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
// TODO: parent might be a layout
}
} else {
- QDeclarativeGraphics_setParent_noEvent(o, parent);
+ QDeclarative_setParent_noEvent(o, parent);
// o->setParent(parent);
}
}
@@ -525,7 +525,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature()))
VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature())));
- QMetaObject::connect(target, prop.coreIndex(), assign, method.methodIndex());
+ QMetaObject::connect(target, prop.index(), assign, method.methodIndex());
} else {
VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr)));
@@ -593,7 +593,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
QDeclarativeProperty mp =
QDeclarativePropertyPrivate::restore(datas.at(instr.assignBinding.property), target, ctxt);
- int coreIndex = mp.coreIndex();
+ int coreIndex = mp.index();
if (stack.count() == 1 && bindingSkipList.testBit(coreIndex))
break;
@@ -648,7 +648,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
obj->setParent(target);
vi->setTarget(prop);
QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
- mo->registerInterceptor(prop.coreIndex(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi);
+ mo->registerInterceptor(prop.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi);
}
break;
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 264b88c..10230d3 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -63,6 +63,7 @@
#include <QtCore/qrect.h>
#include <QtCore/qpoint.h>
#include <QtCore/qsize.h>
+#include <QtCore/qmath.h>
#include <private/qvariantanimation_p.h>
@@ -70,7 +71,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Animation QDeclarativeAbstractAnimation
- \since 4.7
+ \since 4.7
\brief The Animation element is the base of all QML animations.
The Animation element cannot be used directly in a QML file. It exists
@@ -360,9 +361,6 @@ void QDeclarativeAbstractAnimation::setGroup(QDeclarativeAnimationGroup *g)
if (d->group && !static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.contains(this))
static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.append(this);
- if (d->group)
- ((QAnimationGroup*)d->group->qtAnimation())->addAnimation(qtAnimation());
-
//if (g) //if removed from a group, then the group should no longer be the parent
setParent(g);
}
@@ -517,7 +515,7 @@ void QDeclarativeAbstractAnimation::timelineComplete()
/*!
\qmlclass PauseAnimation QDeclarativePauseAnimation
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The PauseAnimation element provides a pause for an animation.
@@ -554,7 +552,7 @@ void QDeclarativePauseAnimationPrivate::init()
{
Q_Q(QDeclarativePauseAnimation);
pa = new QPauseAnimation;
- QDeclarativeGraphics_setParent_noEvent(pa, q);
+ QDeclarative_setParent_noEvent(pa, q);
}
/*!
@@ -591,7 +589,7 @@ QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation()
/*!
\qmlclass ColorAnimation QDeclarativeColorAnimation
- \since 4.7
+ \since 4.7
\inherits PropertyAnimation
\brief The ColorAnimation element allows you to animate color changes.
@@ -655,7 +653,7 @@ void QDeclarativeColorAnimation::setTo(const QColor &t)
/*!
\qmlclass ScriptAction QDeclarativeScriptAction
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The ScriptAction element allows scripts to be run during an animation.
@@ -679,7 +677,7 @@ void QDeclarativeScriptActionPrivate::init()
{
Q_Q(QDeclarativeScriptAction);
rsa = new QActionAnimation(&proxy);
- QDeclarativeGraphics_setParent_noEvent(rsa, q);
+ QDeclarative_setParent_noEvent(rsa, q);
}
/*!
@@ -761,7 +759,7 @@ QAbstractAnimation *QDeclarativeScriptAction::qtAnimation()
/*!
\qmlclass PropertyAction QDeclarativePropertyAction
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The PropertyAction element allows immediate property changes during animation.
@@ -797,7 +795,7 @@ void QDeclarativePropertyActionPrivate::init()
{
Q_Q(QDeclarativePropertyAction);
spa = new QActionAnimation;
- QDeclarativeGraphics_setParent_noEvent(spa, q);
+ QDeclarative_setParent_noEvent(spa, q);
}
/*!
@@ -1010,7 +1008,7 @@ void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions,
/*!
\qmlclass ParentAction QDeclarativeParentAction
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The ParentAction element allows parent changes during animation.
@@ -1058,7 +1056,7 @@ void QDeclarativeParentActionPrivate::init()
{
Q_Q(QDeclarativeParentAction);
cpa = new QActionAnimation;
- QDeclarativeGraphics_setParent_noEvent(cpa, q);
+ QDeclarative_setParent_noEvent(cpa, q);
}
/*!
@@ -1214,7 +1212,7 @@ void QDeclarativeParentAction::transition(QDeclarativeStateActions &actions,
/*!
\qmlclass NumberAnimation QDeclarativeNumberAnimation
- \since 4.7
+ \since 4.7
\inherits PropertyAnimation
\brief The NumberAnimation element allows you to animate changes in properties of type qreal.
@@ -1278,7 +1276,7 @@ void QDeclarativeNumberAnimation::setTo(qreal t)
/*!
\qmlclass Vector3dAnimation QDeclarativeVector3dAnimation
- \since 4.7
+ \since 4.7
\inherits PropertyAnimation
\brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d.
*/
@@ -1337,6 +1335,7 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t)
/*!
\qmlclass RotationAnimation QDeclarativeRotationAnimation
+ \since 4.7
\inherits PropertyAnimation
\brief The RotationAnimation element allows you to animate rotations.
@@ -1511,12 +1510,18 @@ QDeclarativeAnimationGroup::QDeclarativeAnimationGroup(QObject *parent)
{
}
+QDeclarativeAnimationGroup::QDeclarativeAnimationGroup(QDeclarativeAnimationGroupPrivate &dd, QObject *parent)
+ : QDeclarativeAbstractAnimation(dd, parent)
+{
+}
+
void QDeclarativeAnimationGroupPrivate::append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a)
{
QDeclarativeAnimationGroup *q = qobject_cast<QDeclarativeAnimationGroup *>(list->object);
if (q) {
q->d_func()->animations.append(a);
a->setGroup(q);
+ q->d_func()->ag->addAnimation(a->qtAnimation());
}
}
@@ -1545,7 +1550,7 @@ QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeAnimationGro
/*!
\qmlclass SequentialAnimation QDeclarativeSequentialAnimation
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The SequentialAnimation element allows you to run animations sequentially.
@@ -1606,7 +1611,7 @@ void QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actio
/*!
\qmlclass ParallelAnimation QDeclarativeParallelAnimation
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The ParallelAnimation element allows you to run animations in parallel.
@@ -1715,7 +1720,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
/*!
\qmlclass PropertyAnimation QDeclarativePropertyAnimation
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The PropertyAnimation element allows you to animate property changes.
@@ -1793,7 +1798,7 @@ void QDeclarativePropertyAnimationPrivate::init()
{
Q_Q(QDeclarativePropertyAnimation);
va = new QDeclarativeTimeLineValueAnimator;
- QDeclarativeGraphics_setParent_noEvent(va, q);
+ QDeclarative_setParent_noEvent(va, q);
}
/*!
@@ -2366,6 +2371,241 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions
}
}
+QDeclarativeParentAnimation::QDeclarativeParentAnimation(QObject *parent)
+ : QDeclarativeAnimationGroup(*(new QDeclarativeParentAnimationPrivate), parent)
+{
+ Q_D(QDeclarativeParentAnimation);
+ d->topLevelGroup = new QSequentialAnimationGroup;
+ QDeclarative_setParent_noEvent(d->topLevelGroup, this);
+
+ d->startAction = new QActionAnimation;
+ d->topLevelGroup->addAnimation(d->startAction);
+
+ d->ag = new QParallelAnimationGroup;
+ d->topLevelGroup->addAnimation(d->ag);
+
+ d->endAction = new QActionAnimation;
+ d->topLevelGroup->addAnimation(d->endAction);
+}
+
+QDeclarativeParentAnimation::~QDeclarativeParentAnimation()
+{
+}
+
+QDeclarativeItem *QDeclarativeParentAnimation::target() const
+{
+ Q_D(const QDeclarativeParentAnimation);
+ return d->target;
+}
+
+void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target)
+{
+ Q_D(QDeclarativeParentAnimation);
+ d->target = target;
+}
+
+QDeclarativeItem *QDeclarativeParentAnimation::newParent() const
+{
+ Q_D(const QDeclarativeParentAnimation);
+ return d->newParent;
+}
+
+void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent)
+{
+ Q_D(QDeclarativeParentAnimation);
+ d->newParent = newParent;
+}
+
+QDeclarativeItem *QDeclarativeParentAnimation::via() const
+{
+ Q_D(const QDeclarativeParentAnimation);
+ return d->via;
+}
+
+void QDeclarativeParentAnimation::setVia(QDeclarativeItem *via)
+{
+ Q_D(QDeclarativeParentAnimation);
+ d->via = via;
+}
+
+//### mirrors same-named function in QDeclarativeItem
+QPointF QDeclarativeParentAnimationPrivate::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 QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_D(QDeclarativeParentAnimation);
+
+ struct QDeclarativeParentActionData : public QAbstractAnimationAction
+ {
+ QDeclarativeParentActionData(): pc(0) {}
+ ~QDeclarativeParentActionData() { delete pc; }
+
+ QDeclarativeStateActions actions;
+ bool reverse;
+ QDeclarativeParentChange *pc;
+ virtual void doAction()
+ {
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ const QDeclarativeAction &action = actions.at(ii);
+ if (reverse)
+ action.event->reverse();
+ else
+ action.event->execute();
+ }
+ }
+ };
+
+ QDeclarativeParentActionData *data = new QDeclarativeParentActionData;
+ QDeclarativeParentActionData *viaData = new QDeclarativeParentActionData;
+ for (int i = 0; i < actions.size(); ++i) {
+ QDeclarativeAction &action = actions[i];
+ if (action.event && action.event->typeName() == QLatin1String("ParentChange")
+ && (!d->target || static_cast<QDeclarativeParentChange*>(action.event)->object() == d->target)) {
+
+ QDeclarativeParentChange *pc = static_cast<QDeclarativeParentChange*>(action.event);
+ QDeclarativeAction myAction = action;
+ data->reverse = action.reverseEvent;
+ action.actionDone = true;
+ data->actions << myAction;
+
+ if (d->via) {
+ viaData->reverse = false;
+ QDeclarativeAction myAction;
+ QDeclarativeParentChange *vpc = new QDeclarativeParentChange;
+ vpc->setObject(pc->object());
+ vpc->setParent(d->via);
+ myAction.event = vpc;
+ viaData->pc = vpc;
+ viaData->actions << myAction;
+ QDeclarativeAction dummyAction;
+ QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction;
+ QDeclarativeAction &yAction = pc->yIsSet() ? actions[++i] : dummyAction;
+ QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[++i] : dummyAction;
+ QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[++i] : dummyAction;
+ bool forward = (direction == QDeclarativeAbstractAnimation::Forward);
+ QDeclarativeItem *target = pc->object();
+ QDeclarativeItem *targetParent = forward ? pc->parent() : pc->originalParent();
+
+ //### this mirrors the logic in QDeclarativeParentChange.
+ bool ok;
+ const QTransform &transform = targetParent->itemTransform(d->via, &ok);
+ if (transform.type() >= QTransform::TxShear || !ok) {
+ qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under complex transform");
+ ok = false;
+ }
+
+ qreal scale = 1;
+ qreal rotation = 0;
+ if (ok && transform.type() != QTransform::TxRotate) {
+ if (transform.m11() == transform.m22())
+ scale = transform.m11();
+ else {
+ qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
+ ok = false;
+ }
+ } else if (ok && transform.type() == QTransform::TxRotate) {
+ if (transform.m11() == transform.m22())
+ scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
+ else {
+ qmlInfo(this) << QDeclarativeParentAnimation::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) << QDeclarativeParentAnimation::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())
+ w = actions[++i].toValue.toReal();
+ if (pc->heightIsSet())
+ 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 == QDeclarativeAbstractAnimation::Forward) {
+ d->startAction->setAnimAction(d->via ? viaData : data, QActionAnimation::DeleteWhenStopped);
+ d->endAction->setAnimAction(d->via ? data : 0, QActionAnimation::DeleteWhenStopped);
+ } else {
+ d->endAction->setAnimAction(d->via ? viaData : data, QActionAnimation::DeleteWhenStopped);
+ d->startAction->setAnimAction(d->via ? data : 0, QActionAnimation::DeleteWhenStopped);
+ }
+ } 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 *QDeclarativeParentAnimation::qtAnimation()
+{
+ Q_D(QDeclarativeParentAnimation);
+ return d->topLevelGroup;
+}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h
index 53afbb5..0f23f5c 100644
--- a/src/declarative/util/qdeclarativeanimation_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p.h
@@ -413,6 +413,9 @@ public:
QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations();
friend class QDeclarativeAbstractAnimation;
+
+protected:
+ QDeclarativeAnimationGroup(QDeclarativeAnimationGroupPrivate &dd, QObject *parent);
};
class QDeclarativeSequentialAnimation : public QDeclarativeAnimationGroup
@@ -447,6 +450,36 @@ protected:
virtual QAbstractAnimation *qtAnimation();
};
+class QDeclarativeParentAnimationPrivate;
+class QDeclarativeParentAnimation : public QDeclarativeAnimationGroup
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeParentAnimation)
+
+ Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget)
+ //Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent)
+ Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia)
+
+public:
+ QDeclarativeParentAnimation(QObject *parent=0);
+ virtual ~QDeclarativeParentAnimation();
+
+ QDeclarativeItem *target() const;
+ void setTarget(QDeclarativeItem *);
+
+ QDeclarativeItem *newParent() const;
+ void setNewParent(QDeclarativeItem *);
+
+ QDeclarativeItem *via() const;
+ void setVia(QDeclarativeItem *);
+
+protected:
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation();
+};
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QDeclarativeAbstractAnimation)
@@ -461,6 +494,7 @@ QML_DECLARE_TYPE(QDeclarativeSequentialAnimation)
QML_DECLARE_TYPE(QDeclarativeParallelAnimation)
QML_DECLARE_TYPE(QDeclarativeVector3dAnimation)
QML_DECLARE_TYPE(QDeclarativeRotationAnimation)
+QML_DECLARE_TYPE(QDeclarativeParentAnimation)
QT_END_HEADER
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
index fc4e6e6..e582066 100644
--- a/src/declarative/util/qdeclarativeanimation_p_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -59,6 +59,7 @@
#include "qdeclarativetimeline_p_p.h"
#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
#include <qdeclarativecontext.h>
#include <QtCore/QPauseAnimation>
@@ -104,6 +105,12 @@ public:
: QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped), running(false) {}
~QActionAnimation() { if (policy == DeleteWhenStopped) { delete animAction; animAction = 0; } }
virtual int duration() const { return 0; }
+ void clearAnimAction()
+ {
+ if (policy == DeleteWhenStopped)
+ delete animAction;
+ animAction = 0;
+ }
void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p)
{
if (state() == Running)
@@ -311,8 +318,6 @@ public:
static void append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *role);
static void clear_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list);
- static void removeAt_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, int i);
- static void insert_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, int i, QDeclarativeAbstractAnimation *role);
QList<QDeclarativeAbstractAnimation *> animations;
QAnimationGroup *ag;
};
@@ -362,6 +367,25 @@ public:
QDeclarativeRotationAnimation::RotationDirection direction;
};
+class QDeclarativeParentAnimationPrivate : public QDeclarativeAnimationGroupPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeParentAnimation)
+public:
+ QDeclarativeParentAnimationPrivate()
+ : QDeclarativeAnimationGroupPrivate(), target(0), newParent(0),
+ via(0), topLevelGroup(0), startAction(0), endAction(0) {}
+
+ QDeclarativeItem *target;
+ QDeclarativeItem *newParent;
+ QDeclarativeItem *via;
+
+ QSequentialAnimationGroup *topLevelGroup;
+ QActionAnimation *startAction;
+ QActionAnimation *endAction;
+
+ QPointF computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const;
+};
+
QT_END_NAMESPACE
#endif // QDECLARATIVEANIMATION_P_H
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index e0189dc..5352341 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -70,6 +70,7 @@ public:
/*!
\qmlclass Behavior QDeclarativeBehavior
+ \since 4.7
\brief The Behavior element allows you to specify a default animation for a property change.
Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML.
diff --git a/src/declarative/util/qdeclarativeconnection.cpp b/src/declarative/util/qdeclarativeconnection.cpp
deleted file mode 100644
index e9ae74b..0000000
--- a/src/declarative/util/qdeclarativeconnection.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativeconnection_p.h"
-
-#include <qdeclarativeexpression.h>
-#include <qdeclarativeboundsignal_p.h>
-#include <qdeclarativecontext.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstringlist.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeConnectionPrivate : public QObjectPrivate
-{
-public:
- QDeclarativeConnectionPrivate() : boundsignal(0), signalSender(0), scriptset(false), componentcomplete(false) {}
-
- QDeclarativeBoundSignal *boundsignal;
- QObject *signalSender;
- QDeclarativeScriptString script;
- bool scriptset;
- QString signal;
- bool componentcomplete;
-};
-
-/*!
- \qmlclass Connection QDeclarativeConnection
- \since 4.7
- \brief A Connection object describes generalized connections to signals.
-
- 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(x+123,y+456) }
- }
- \endqml
-
- However, in some cases, it is not possible to connect to a signal in this
- way. For example, JavaScript-in-HTML style signal properties do not allow:
-
- \list
- \i connecting to signals with the same name but different parameters
- \i conformance checking that parameters are correctly named
- \i multiple connections to the same signal
- \i connections outside the scope of the signal sender
- \i signals in classes with coincidentally-named on<Signal> properties
- \endlist
-
- When any of these are needed, the Connection object can be used instead.
-
- For example, the above code can be changed to use a Connection object,
- like this:
-
- \qml
- MouseArea {
- Connection {
- signal: "clicked(x,y)"
- script: { foo(x+123,y+456) }
- }
- }
- \endqml
-
- More generally, the Connection object can be a child of some other object than
- the sender of the signal:
-
- \qml
- MouseArea {
- id: mr
- }
- ...
- Connection {
- sender: mr
- signal: "clicked(x,y)"
- script: { foo(x+123,y+456) }
- }
- \endqml
-*/
-
-/*!
- \internal
- \class QDeclarativeConnection
- \brief The QDeclarativeConnection class describes generalized connections to signals.
-
-*/
-QDeclarativeConnection::QDeclarativeConnection(QObject *parent) :
- QObject(*(new QDeclarativeConnectionPrivate), parent)
-{
-}
-
-QDeclarativeConnection::~QDeclarativeConnection()
-{
- Q_D(QDeclarativeConnection);
- delete d->boundsignal;
-}
-
-/*!
- \qmlproperty Object Connection::sender
- This property holds the object that sends the signal.
-
- By default, the sender is assumed to be the parent of the Connection.
-*/
-QObject *QDeclarativeConnection::signalSender() const
-{
- Q_D(const QDeclarativeConnection);
- return d->signalSender ? d->signalSender : parent();
-}
-
-void QDeclarativeConnection::setSignalSender(QObject *obj)
-{
- Q_D(QDeclarativeConnection);
- if (d->signalSender == obj)
- return;
- disconnectIfValid();
- d->signalSender = obj;
- connectIfValid();
-}
-
-void QDeclarativeConnection::connectIfValid()
-{
- Q_D(QDeclarativeConnection);
- if (!d->componentcomplete)
- return;
- // boundsignal must not exist
- if ((d->signalSender || parent()) && !d->signal.isEmpty() && d->scriptset) {
- // create
- // XXX scope?
- int sigIdx = -1;
- int lparen = d->signal.indexOf(QLatin1Char('('));
- QList<QByteArray> sigparams;
- if (lparen >= 0 && d->signal.length() > lparen+2) {
- QStringList l = d->signal.mid(lparen+1,d->signal.length()-lparen-2).split(QLatin1Char(','));
- foreach (const QString &s, l) {
- sigparams.append(s.trimmed().toUtf8());
- }
- }
- QString signalname = d->signal.left(lparen);
- QObject *sender = d->signalSender ? d->signalSender : parent();
- const QMetaObject *mo = sender->metaObject();
- int methods = mo->methodCount();
- for (int ii = 0; ii < methods; ++ii) {
- QMetaMethod method = mo->method(ii);
- QString methodName = QString::fromUtf8(method.signature());
- int idx = methodName.indexOf(QLatin1Char('('));
- methodName = methodName.left(idx);
- if (methodName == signalname && (lparen<0 || method.parameterNames() == sigparams)) {
- sigIdx = ii;
- break;
- }
- }
- if (sigIdx < 0) {
- // Cannot usefully warn, since could be in middle of
- // changing sender and signal.
- // XXX need state change transactions to do better
- return;
- }
-
- d->boundsignal = new QDeclarativeBoundSignal(qmlContext(this), d->script.script(), sender, mo->method(sigIdx), this);
- }
-}
-
-void QDeclarativeConnection::disconnectIfValid()
-{
- Q_D(QDeclarativeConnection);
- if (!d->componentcomplete)
- return;
- if ((d->signalSender || parent()) && !d->signal.isEmpty() && d->scriptset) {
- // boundsignal must exist
- // destroy
- delete d->boundsignal;
- d->boundsignal = 0;
- }
-}
-
-void QDeclarativeConnection::componentComplete()
-{
- Q_D(QDeclarativeConnection);
- d->componentcomplete=true;
- connectIfValid();
-}
-
-
-/*!
- \qmlproperty script Connection::script
- This property holds the JavaScript executed whenever the signal is sent.
-*/
-QDeclarativeScriptString QDeclarativeConnection::script() const
-{
- Q_D(const QDeclarativeConnection);
- return d->script;
-}
-
-void QDeclarativeConnection::setScript(const QDeclarativeScriptString& script)
-{
- Q_D(QDeclarativeConnection);
- if ((d->signalSender || parent()) && !d->signal.isEmpty()) {
- if (!d->scriptset) {
- // mustn't exist - create
- d->scriptset = true;
- d->script = script;
- connectIfValid();
- } else {
- // must exist - update
- d->script = script;
- d->boundsignal->expression()->setExpression(script.script());
- }
- } else {
- d->scriptset = true;
- d->script = script;
- }
-}
-
-/*!
- \qmlproperty string Connection::signal
- This property holds the signal from the sender to which the script is attached.
-
- The signal's formal parameter names must be given in parentheses:
-
- \qml
-Connection {
- signal: "clicked(x,y)"
- script: { ... }
-}
- \endqml
-*/
-QString QDeclarativeConnection::signal() const
-{
- Q_D(const QDeclarativeConnection);
- return d->signal;
-}
-
-void QDeclarativeConnection::setSignal(const QString& sig)
-{
- Q_D(QDeclarativeConnection);
- if (d->signal == sig)
- return;
- disconnectIfValid();
- d->signal = sig;
- connectIfValid();
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp
new file mode 100644
index 0000000..0b9e3ab
--- /dev/null
+++ b/src/declarative/util/qdeclarativeconnections.cpp
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeconnections_p.h"
+
+#include <qdeclarativeexpression.h>
+#include <qdeclarativeproperty_p.h>
+#include <qdeclarativeboundsignal_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeinfo.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeConnectionsPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeConnectionsPrivate() : target(0), componentcomplete(false) {}
+
+ QList<QDeclarativeBoundSignal*> boundsignals;
+ QObject *target;
+
+ bool componentcomplete;
+
+ QByteArray data;
+};
+
+/*!
+ \qmlclass Connections QDeclarativeConnections
+ \since 4.7
+ \brief A Connections object describes generalized connections to signals.
+
+ 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(...) }
+ }
+ \endqml
+
+ However, in some cases, it is not possible to connect to a signal in this
+ way, such as:
+
+ \list
+ \i multiple connections to the same signal
+ \i connections outside the scope of the signal sender
+ \i connections to targets not defined in QML
+ \endlist
+
+ When any of these are needed, the Connections object can be used instead.
+
+ For example, the above code can be changed to use a Connections object,
+ like this:
+
+ \qml
+ MouseArea {
+ Connections {
+ onClicked: foo(...)
+ }
+ }
+ \endqml
+
+ More generally, the Connections object can be a child of some other object than
+ the sender of the signal:
+
+ \qml
+ MouseArea {
+ id: area
+ }
+ ...
+ Connections {
+ target: area
+ onClicked: foo(...)
+ }
+ \endqml
+*/
+
+/*!
+ \internal
+ \class QDeclarativeConnections
+ \brief The QDeclarativeConnections class describes generalized connections to signals.
+
+*/
+QDeclarativeConnections::QDeclarativeConnections(QObject *parent) :
+ QObject(*(new QDeclarativeConnectionsPrivate), parent)
+{
+}
+
+QDeclarativeConnections::~QDeclarativeConnections()
+{
+}
+
+/*!
+ \qmlproperty Object Connections::target
+ This property holds the object that sends the signal.
+
+ By default, the target is assumed to be the parent of the Connections.
+*/
+QObject *QDeclarativeConnections::target() const
+{
+ Q_D(const QDeclarativeConnections);
+ return d->target ? d->target : parent();
+}
+
+void QDeclarativeConnections::setTarget(QObject *obj)
+{
+ Q_D(QDeclarativeConnections);
+ if (d->target == obj)
+ return;
+ foreach (QDeclarativeBoundSignal *s, d->boundsignals)
+ delete s;
+ d->boundsignals.clear();
+ d->target = obj;
+ connectSignals();
+ emit targetChanged();
+}
+
+
+QByteArray
+QDeclarativeConnectionsParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
+{
+ QByteArray rv;
+ QDataStream ds(&rv, QIODevice::WriteOnly);
+
+ for(int ii = 0; ii < props.count(); ++ii)
+ {
+ QString propName = QString::fromUtf8(props.at(ii).name());
+ if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) {
+ error(props.at(ii), QDeclarativeConnections::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), QDeclarativeConnections::tr("Connections: nested objects not allowed"));
+ return QByteArray();
+ } else if (value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
+ error(props.at(ii), QDeclarativeConnections::tr("Connections: syntax error"));
+ return QByteArray();
+ } else {
+ QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(value);
+ if (v.isScript()) {
+ ds << propName;
+ ds << v.asScript();
+ } else {
+ error(props.at(ii), QDeclarativeConnections::tr("Connections: script expected"));
+ return QByteArray();
+ }
+ }
+ }
+ }
+
+ return rv;
+}
+
+void QDeclarativeConnectionsParser::setCustomData(QObject *object,
+ const QByteArray &data)
+{
+ QDeclarativeConnectionsPrivate *p =
+ static_cast<QDeclarativeConnectionsPrivate *>(QObjectPrivate::get(object));
+ p->data = data;
+}
+
+
+void QDeclarativeConnections::connectSignals()
+{
+ Q_D(QDeclarativeConnections);
+ if (!d->componentcomplete)
+ return;
+
+ QDataStream ds(d->data);
+ while (!ds.atEnd()) {
+ QString propName;
+ ds >> propName;
+ QString script;
+ ds >> script;
+ QDeclarativeProperty prop(target(), propName);
+ if (!prop.isValid()) {
+ qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName);
+ } else if (prop.type() & QDeclarativeProperty::SignalProperty) {
+ QDeclarativeBoundSignal *signal =
+ new QDeclarativeBoundSignal(target(), prop.method(), this);
+ signal->setExpression(new QDeclarativeExpression(qmlContext(this), script, 0));
+ d->boundsignals += signal;
+ } else {
+ qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName);
+ }
+ }
+}
+
+void QDeclarativeConnections::componentComplete()
+{
+ Q_D(QDeclarativeConnections);
+ d->componentcomplete=true;
+ connectSignals();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeconnection_p.h b/src/declarative/util/qdeclarativeconnections_p.h
index ae2efe9..3eacf12 100644
--- a/src/declarative/util/qdeclarativeconnection_p.h
+++ b/src/declarative/util/qdeclarativeconnections_p.h
@@ -39,11 +39,12 @@
**
****************************************************************************/
-#ifndef QDECLARATIVECONNECTION_H
-#define QDECLARATIVECONNECTION_H
+#ifndef QDECLARATIVECONNECTIONS_H
+#define QDECLARATIVECONNECTIONS_H
#include <qdeclarative.h>
#include <qdeclarativescriptstring.h>
+#include <private/qdeclarativecustomparser_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
@@ -56,37 +57,41 @@ QT_MODULE(Declarative)
class QDeclarativeBoundSignal;
class QDeclarativeContext;
-class QDeclarativeConnectionPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeConnection : public QObject, public QDeclarativeParserStatus
+class QDeclarativeConnectionsPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeConnections : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeConnection)
+ Q_DECLARE_PRIVATE(QDeclarativeConnections)
Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(QObject *sender READ signalSender WRITE setSignalSender)
- Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString signal READ signal WRITE setSignal)
+ Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
public:
- QDeclarativeConnection(QObject *parent=0);
- ~QDeclarativeConnection();
+ QDeclarativeConnections(QObject *parent=0);
+ ~QDeclarativeConnections();
- QObject *signalSender() const;
- void setSignalSender(QObject *);
- QDeclarativeScriptString script() const;
- void setScript(const QDeclarativeScriptString&);
- QString signal() const;
- void setSignal(const QString&);
+ QObject *target() const;
+ void setTarget(QObject *);
+
+Q_SIGNALS:
+ void targetChanged();
private:
- void disconnectIfValid();
- void connectIfValid();
+ void connectSignals();
void componentComplete();
};
+class QDeclarativeConnectionsParser : public QDeclarativeCustomParser
+{
+public:
+ virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
+ virtual void setCustomData(QObject *, const QByteArray &);
+};
+
+
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QDeclarativeConnection)
+QML_DECLARE_TYPE(QDeclarativeConnections)
QT_END_HEADER
diff --git a/src/declarative/util/qdeclarativeeasefollow.cpp b/src/declarative/util/qdeclarativeeasefollow.cpp
index 232dc90..3fa9866 100644
--- a/src/declarative/util/qdeclarativeeasefollow.cpp
+++ b/src/declarative/util/qdeclarativeeasefollow.cpp
@@ -251,6 +251,7 @@ void QDeclarativeEaseFollowPrivate::tick(int t)
/*!
\qmlclass EaseFollow QDeclarativeEaseFollow
+ \since 4.7
\brief The EaseFollow element allows a property to smoothly track a value.
The EaseFollow smoothly animates a property's value to a set target value
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index ac30384..4d12ae1 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -75,6 +75,7 @@ public:
/*!
\qmlclass FontLoader QDeclarativeFontLoader
+ \since 4.7
\ingroup group_utility
\brief This item allows using fonts by name or url.
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index e78e0e1..e3f26d7 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -70,6 +70,7 @@ static void dump(ModelNode *node, int ind);
/*!
\qmlclass ListModel QDeclarativeListModel
+ \since 4.7
\brief The ListModel element defines a free-form list data source.
The ListModel is a simple hierarchy of elements containing data roles. The contents can
@@ -936,6 +937,7 @@ bool QDeclarativeListModelParser::definesEmptyList(const QString &s)
/*!
\qmlclass ListElement
+ \since 4.7
\brief The ListElement element defines a data item in a ListModel.
\sa ListModel
diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h
index 251a31f..8eb6583 100644
--- a/src/declarative/util/qdeclarativelistmodel_p.h
+++ b/src/declarative/util/qdeclarativelistmodel_p.h
@@ -50,7 +50,7 @@
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QVariant>
-#include "../3rdparty/qlistmodelinterface_p.h"
+#include <private/qlistmodelinterface_p.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp
index 34ae466..d144777 100644
--- a/src/declarative/util/qdeclarativepackage.cpp
+++ b/src/declarative/util/qdeclarativepackage.cpp
@@ -42,7 +42,7 @@
#include "qdeclarativepackage_p.h"
#include <private/qobject_p.h>
-#include "private/qdeclarativeguard_p.h"
+#include <private/qdeclarativeguard_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
index 012e6a0..6205ab9 100644
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -213,6 +213,7 @@ void QDeclarativeSpringFollowPrivate::stop()
/*!
\qmlclass SpringFollow QDeclarativeSpringFollow
+ \since 4.7
\brief The SpringFollow element allows a property to track a value.
In example below, \e rect2 will follow \e rect1 moving with a velocity of up to 200:
diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h
index abdbec5..0c6e7a3 100644
--- a/src/declarative/util/qdeclarativestate_p.h
+++ b/src/declarative/util/qdeclarativestate_p.h
@@ -53,7 +53,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeActionEvent;
+class QDeclarativeAbstractBinding;
class QDeclarativeBinding;
+class QDeclarativeExpression;
class Q_DECLARATIVE_EXPORT QDeclarativeAction
{
public:
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index 1a7c256..083e87d 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -84,6 +84,7 @@ public:
/*!
\qmlclass StateGroup QDeclarativeStateGroup
+ \since 4.7
\brief The StateGroup element provides state support for non-Item elements.
Item (and all dervied elements) provides built in support for states and transitions
@@ -406,7 +407,7 @@ void QDeclarativeStateGroupPrivate::setCurrentStateInternal(const QString &state
}
if (oldState == 0 || newState == 0) {
- if (!nullState) { nullState = new QDeclarativeState; QDeclarativeGraphics_setParent_noEvent(nullState, q); }
+ if (!nullState) { nullState = new QDeclarativeState; QDeclarative_setParent_noEvent(nullState, q); }
if (!oldState) oldState = nullState;
if (!newState) newState = nullState;
}
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 9df8658..cea9ad7 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -48,6 +48,7 @@
#include <qdeclarativeanchors_p_p.h>
#include <qdeclarativeitem_p.h>
#include <qdeclarativeguard_p.h>
+#include <qdeclarativenullablevalue_p_p.h>
#include <QtCore/qdebug.h>
#include <QtGui/qgraphicsitem.h>
@@ -62,7 +63,7 @@ class QDeclarativeParentChangePrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QDeclarativeParentChange)
public:
QDeclarativeParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0),
- rewindParent(0), rewindStackBefore(0) {}
+ rewindParent(0), rewindStackBefore(0) {}
QDeclarativeItem *target;
QDeclarativeItem *parent;
@@ -71,6 +72,13 @@ public:
QDeclarativeItem *rewindParent;
QDeclarativeItem *rewindStackBefore;
+ 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);
};
@@ -173,6 +181,120 @@ QDeclarativeParentChange::~QDeclarativeParentChange()
{
}
+qreal QDeclarativeParentChange::x() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->x.isNull ? qreal(0.) : d->x.value;
+}
+
+void QDeclarativeParentChange::setX(qreal x)
+{
+ Q_D(QDeclarativeParentChange);
+ d->x = x;
+}
+
+bool QDeclarativeParentChange::xIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->x.isValid();
+}
+
+qreal QDeclarativeParentChange::y() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->y.isNull ? qreal(0.) : d->y.value;
+}
+
+void QDeclarativeParentChange::setY(qreal y)
+{
+ Q_D(QDeclarativeParentChange);
+ d->y = y;
+}
+
+bool QDeclarativeParentChange::yIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->y.isValid();
+}
+
+qreal QDeclarativeParentChange::width() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->width.isNull ? qreal(0.) : d->width.value;
+}
+
+void QDeclarativeParentChange::setWidth(qreal width)
+{
+ Q_D(QDeclarativeParentChange);
+ d->width = width;
+}
+
+bool QDeclarativeParentChange::widthIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->width.isValid();
+}
+
+qreal QDeclarativeParentChange::height() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->height.isNull ? qreal(0.) : d->height.value;
+}
+
+void QDeclarativeParentChange::setHeight(qreal height)
+{
+ Q_D(QDeclarativeParentChange);
+ d->height = height;
+}
+
+bool QDeclarativeParentChange::heightIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->height.isValid();
+}
+
+qreal QDeclarativeParentChange::scale() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->scale.isNull ? qreal(1.) : d->scale.value;
+}
+
+void QDeclarativeParentChange::setScale(qreal scale)
+{
+ Q_D(QDeclarativeParentChange);
+ d->scale = scale;
+}
+
+bool QDeclarativeParentChange::scaleIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->scale.isValid();
+}
+
+qreal QDeclarativeParentChange::rotation() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->rotation.isNull ? qreal(0.) : d->rotation.value;
+}
+
+void QDeclarativeParentChange::setRotation(qreal rotation)
+{
+ Q_D(QDeclarativeParentChange);
+ d->rotation = rotation;
+}
+
+bool QDeclarativeParentChange::rotationIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->rotation.isValid();
+}
+
+QDeclarativeItem *QDeclarativeParentChange::originalParent() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->origParent;
+}
+
/*!
\qmlproperty Item ParentChange::target
This property holds the item to be reparented
@@ -213,10 +335,43 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
if (!d->target || !d->parent)
return ActionList();
+ ActionList actions;
+
QDeclarativeAction a;
a.event = this;
+ actions << a;
- return ActionList() << a;
+ if (d->x.isValid()) {
+ QDeclarativeAction xa(d->target, QLatin1String("x"), x());
+ actions << xa;
+ }
+
+ if (d->y.isValid()) {
+ QDeclarativeAction ya(d->target, QLatin1String("y"), y());
+ actions << ya;
+ }
+
+ if (d->scale.isValid()) {
+ QDeclarativeAction sa(d->target, QLatin1String("scale"), scale());
+ actions << sa;
+ }
+
+ if (d->rotation.isValid()) {
+ QDeclarativeAction ra(d->target, QLatin1String("rotation"), rotation());
+ actions << ra;
+ }
+
+ if (d->width.isValid()) {
+ QDeclarativeAction wa(d->target, QLatin1String("width"), width());
+ actions << wa;
+ }
+
+ if (d->height.isValid()) {
+ QDeclarativeAction ha(d->target, QLatin1String("height"), height());
+ actions << ha;
+ }
+
+ return actions;
}
class AccessibleFxItem : public QDeclarativeItem
diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h
index 9204a58..dd4248023 100644
--- a/src/declarative/util/qdeclarativestateoperations_p.h
+++ b/src/declarative/util/qdeclarativestateoperations_p.h
@@ -45,7 +45,7 @@
#include "qdeclarativestate_p.h"
#include <qdeclarativeitem.h>
-#include "private/qdeclarativeanchors_p.h"
+#include <private/qdeclarativeanchors_p.h>
#include <qdeclarativescriptstring.h>
QT_BEGIN_HEADER
@@ -62,6 +62,12 @@ class Q_DECLARATIVE_EXPORT QDeclarativeParentChange : public QDeclarativeStateOp
Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent)
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal width READ width WRITE setWidth)
+ Q_PROPERTY(qreal height READ height WRITE setHeight)
+ Q_PROPERTY(qreal scale READ scale WRITE setScale)
+ Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
public:
QDeclarativeParentChange(QObject *parent=0);
~QDeclarativeParentChange();
@@ -72,6 +78,32 @@ public:
QDeclarativeItem *parent() const;
void setParent(QDeclarativeItem *);
+ QDeclarativeItem *originalParent() const;
+
+ qreal x() const;
+ void setX(qreal x);
+ bool xIsSet() const;
+
+ qreal y() const;
+ void setY(qreal y);
+ bool yIsSet() const;
+
+ qreal width() const;
+ void setWidth(qreal width);
+ bool widthIsSet() const;
+
+ qreal height() const;
+ void setHeight(qreal height);
+ bool heightIsSet() const;
+
+ qreal scale() const;
+ void setScale(qreal scale);
+ bool scaleIsSet() const;
+
+ qreal rotation() const;
+ void setRotation(qreal rotation);
+ bool rotationIsSet() const;
+
virtual ActionList actions();
virtual void saveOriginals();
diff --git a/src/declarative/util/qdeclarativesystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp
index 1e00f22..d819c27 100644
--- a/src/declarative/util/qdeclarativesystempalette.cpp
+++ b/src/declarative/util/qdeclarativesystempalette.cpp
@@ -58,6 +58,7 @@ public:
/*!
\qmlclass SystemPalette QDeclarativeSystemPalette
+ \since 4.7
\ingroup group_utility
\brief The SystemPalette item gives access to the Qt palettes.
\sa QPalette
diff --git a/src/declarative/util/qdeclarativetimer.cpp b/src/declarative/util/qdeclarativetimer.cpp
index 89c461b..d7e02b1 100644
--- a/src/declarative/util/qdeclarativetimer.cpp
+++ b/src/declarative/util/qdeclarativetimer.cpp
@@ -70,6 +70,7 @@ public:
/*!
\qmlclass Timer QDeclarativeTimer
+ \since 4.7
\brief The Timer item triggers a handler at a specified interval.
A timer can be used to trigger an action either once, or repeatedly
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index ecaa607c..2b8c7de 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -45,7 +45,7 @@
#include "qdeclarativeanimation_p_p.h"
#include "qdeclarativebehavior_p.h"
#include "qdeclarativebind_p.h"
-#include "qdeclarativeconnection_p.h"
+#include "qdeclarativeconnections_p.h"
#include "qdeclarativedatetimeformatter_p.h"
#include "qdeclarativeeasefollow_p.h"
#include "qdeclarativefontloader_p.h"
@@ -80,7 +80,7 @@ void QDeclarativeUtilModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,Behavior,QDeclarativeBehavior);
QML_REGISTER_TYPE(Qt,4,6,Binding,QDeclarativeBind);
QML_REGISTER_TYPE(Qt,4,6,ColorAnimation,QDeclarativeColorAnimation);
- QML_REGISTER_TYPE(Qt,4,6,Connection,QDeclarativeConnection);
+ QML_REGISTER_TYPE(Qt,4,6,Connections,QDeclarativeConnections);
QML_REGISTER_TYPE(Qt,4,6,DateTimeFormatter,QDeclarativeDateTimeFormatter);
QML_REGISTER_TYPE(Qt,4,6,EaseFollow,QDeclarativeEaseFollow);;
QML_REGISTER_TYPE(Qt,4,6,FontLoader,QDeclarativeFontLoader);
@@ -90,6 +90,7 @@ void QDeclarativeUtilModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,Package,QDeclarativePackage);
QML_REGISTER_TYPE(Qt,4,6,ParallelAnimation,QDeclarativeParallelAnimation);
QML_REGISTER_TYPE(Qt,4,6,ParentAction,QDeclarativeParentAction);
+ QML_REGISTER_TYPE(Qt,4,6,ParentAnimation,QDeclarativeParentAnimation);
QML_REGISTER_TYPE(Qt,4,6,ParentChange,QDeclarativeParentChange);
QML_REGISTER_TYPE(Qt,4,6,PauseAnimation,QDeclarativePauseAnimation);
QML_REGISTER_TYPE(Qt,4,6,PropertyAction,QDeclarativePropertyAction);
@@ -117,4 +118,5 @@ void QDeclarativeUtilModule::defineModule()
QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, ListModel, QDeclarativeListModel, QDeclarativeListModelParser);
QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QDeclarativePropertyChanges, QDeclarativePropertyChangesParser);
+ QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, Connections, QDeclarativeConnections, QDeclarativeConnectionsParser);
}
diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h
index 132a53c..f0ad4b8 100644
--- a/src/declarative/util/qdeclarativexmllistmodel_p.h
+++ b/src/declarative/util/qdeclarativexmllistmodel_p.h
@@ -47,7 +47,7 @@
#include <QtCore/qurl.h>
-#include "../3rdparty/qlistmodelinterface_p.h"
+#include <private/qlistmodelinterface_p.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 610eb3f..198e9e5 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -5,7 +5,7 @@ SOURCES += \
$$PWD/qdeclarativeview.cpp \
$$PWD/qfxperf.cpp \
$$PWD/qperformancelog.cpp \
- $$PWD/qdeclarativeconnection.cpp \
+ $$PWD/qdeclarativeconnections.cpp \
$$PWD/qdeclarativepackage.cpp \
$$PWD/qdeclarativeanimation.cpp \
$$PWD/qdeclarativesystempalette.cpp \
@@ -37,7 +37,7 @@ HEADERS += \
$$PWD/qdeclarativeview.h \
$$PWD/qfxperf_p_p.h \
$$PWD/qperformancelog_p_p.h \
- $$PWD/qdeclarativeconnection_p.h \
+ $$PWD/qdeclarativeconnections_p.h \
$$PWD/qdeclarativepackage_p.h \
$$PWD/qdeclarativeanimation_p.h \
$$PWD/qdeclarativeanimation_p_p.h \