summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-11-09 03:09:12 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-11-09 03:09:12 (GMT)
commit5e5ee991ad4261516cf099c9b237f8c72c9d49cc (patch)
treef0f0f96e9b51baf85e22eb5698b1ea66a0223f2b /src
parent034c9f1b81cfa2d854f87b08e945296d3c1fac85 (diff)
parent7620586aa79c027e5dfd246d53232826333ce715 (diff)
downloadQt-5e5ee991ad4261516cf099c9b237f8c72c9d49cc.zip
Qt-5e5ee991ad4261516cf099c9b237f8c72c9d49cc.tar.gz
Qt-5e5ee991ad4261516cf099c9b237f8c72c9d49cc.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp39
-rw-r--r--src/declarative/QmlChanges.txt4
-rw-r--r--src/declarative/extra/extra.pri2
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors.cpp47
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp100
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp54
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp85
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp68
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview_p.h5
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader.cpp89
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader_p.h1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader_p_p.h5
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles.cpp (renamed from src/declarative/extra/qmlgraphicsparticles.cpp)308
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles_p.h (renamed from src/declarative/extra/qmlgraphicsparticles_p.h)52
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp21
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p.h1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp2
-rw-r--r--src/declarative/qml/qmlboundsignal.cpp2
-rw-r--r--src/declarative/qml/qmlcompiler.cpp13
-rw-r--r--src/declarative/qml/qmlcontext_p.h2
-rw-r--r--src/declarative/qml/qmldom.cpp7
-rw-r--r--src/declarative/qml/qmlengine.cpp22
-rw-r--r--src/declarative/qml/qmlinfo.cpp12
-rw-r--r--src/declarative/qml/qmlintegercache.cpp29
-rw-r--r--src/declarative/qml/qmlintegercache_p.h2
-rw-r--r--src/declarative/qml/qmlmetatype.cpp45
-rw-r--r--src/declarative/qml/qmlmetatype.h3
-rw-r--r--src/declarative/qml/qmlparser.cpp94
-rw-r--r--src/declarative/qml/qmlparser_p.h6
-rw-r--r--src/declarative/qml/qmlprivate.h3
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h20
-rw-r--r--src/declarative/qml/qmlvaluetypescriptclass.cpp101
-rw-r--r--src/declarative/qml/qmlvaluetypescriptclass_p.h18
-rw-r--r--src/declarative/util/qmlanimation.cpp313
-rw-r--r--src/declarative/util/qmlanimation_p.h8
-rw-r--r--src/declarative/util/qmlpropertychanges.cpp4
-rw-r--r--src/declarative/util/qmlsystempalette.cpp26
-rw-r--r--src/declarative/util/qmlsystempalette_p.h13
-rw-r--r--src/declarative/util/qmltimer.cpp5
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp4
43 files changed, 924 insertions, 723 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 948a084..5110ce8 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -262,11 +262,11 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopL
void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
{
+ unregisterRunningAnimation(animation);
+
if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
return;
- unregisterRunningAnimation(animation);
-
int idx = animations.indexOf(animation);
if (idx != -1) {
animations.removeAt(idx);
@@ -347,34 +347,32 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
state = newState;
QWeakPointer<QAbstractAnimation> guard(q);
- q->updateState(oldState, newState);
- if (!guard)
- return;
+ //(un)registration of the animation must always happen before calls to
+ //virtual function (updateState) to ensure a correct state of the timer
+ bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
+ if (oldState == QAbstractAnimation::Running) {
+ if (newState == QAbstractAnimation::Paused && hasRegisteredTimer)
+ QUnifiedTimer::instance()->ensureTimerUpdate();
+ //the animation, is not running any more
+ QUnifiedTimer::instance()->unregisterAnimation(q);
+ } else {
+ QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
+ }
- //this is to be safe if updateState changes the state
- if (state == oldState)
+ q->updateState(oldState, newState);
+ if (!guard || newState != state) //this is to be safe if updateState changes the state
return;
// Notify state change
emit q->stateChanged(oldState, newState);
- if (!guard)
+ if (!guard || newState != state) //this is to be safe if updateState changes the state
return;
switch (state) {
case QAbstractAnimation::Paused:
- if (hasRegisteredTimer)
- // currentTime needs to be updated if pauseTimer is active
- QUnifiedTimer::instance()->ensureTimerUpdate();
- if (!guard)
- return;
- //here we're sure that we were in running state before and that the
- //animation is currently registered
- QUnifiedTimer::instance()->unregisterAnimation(q);
break;
case QAbstractAnimation::Running:
{
- bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
- QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
// this ensures that the value is updated now that the animation is running
if (oldState == QAbstractAnimation::Stopped) {
@@ -389,15 +387,10 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
case QAbstractAnimation::Stopped:
// Leave running state.
int dura = q->duration();
- if (!guard)
- return;
if (deleteWhenStopped)
q->deleteLater();
- if (oldState == QAbstractAnimation::Running)
- QUnifiedTimer::instance()->unregisterAnimation(q);
-
if (dura == -1 || loopCount < 0
|| (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
|| (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) {
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 465ee9e..97cefd5 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -70,6 +70,8 @@ ListView: wrap -> keyNavigationWraps
ListView: autoHighlight -> highlightFollowsCurrentItem
GridView: wrap -> keyNavigationWraps
GridView: autoHighlight -> highlightFollowsCurrentItem
+Animation: targets -> matchTargets
+Animation: properties -> matchProperties
Additions:
MouseRegion: add "acceptedButtons" property
@@ -82,6 +84,7 @@ Loader: add sourceComponent property
Loader: add resizeMode property
ListView: preferredHighlightBegin, preferredHighlightEnd
ListView: strictlyEnforceHighlightRange
+Particles: Added emissionRate, emissionVariance and burst()
Deletions:
Column/VerticalPositioner: lost "margins" property
@@ -92,6 +95,7 @@ Flickable: removed "dragMode" property
ComponentInstance: removed. Replaced by Loader.sourceComponent
ListView: removed currentItemMode. Replaced by highligh range.
ListView: removed snapPos.
+Particles: removed streamIn. Replaced by emissionRate
Other Changes:
ids must be lowercase: Text { id: foo }, not Text { id: Foo }
diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri
index a84dfca..78272a9 100644
--- a/src/declarative/extra/extra.pri
+++ b/src/declarative/extra/extra.pri
@@ -3,7 +3,6 @@ SOURCES += \
extra/qmlnumberformatter.cpp \
extra/qmldatetimeformatter.cpp \
extra/qmlgraphicsanimatedimageitem.cpp \
- extra/qmlgraphicsparticles.cpp \
extra/qmlbehavior.cpp \
extra/qmlfontloader.cpp
@@ -13,7 +12,6 @@ HEADERS += \
extra/qmldatetimeformatter_p.h \
extra/qmlgraphicsanimatedimageitem_p.h \
extra/qmlgraphicsanimatedimageitem_p_p.h \
- extra/qmlgraphicsparticles_p.h \
extra/qmlbehavior_p.h \
extra/qmlfontloader_p.h
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index cf71451..3c4e39a 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -42,6 +42,7 @@ HEADERS += \
graphicsitems/qmlgraphicsvisualitemmodel_p.h \
graphicsitems/qmlgraphicslistview_p.h \
graphicsitems/qmlgraphicsgraphicsobjectcontainer_p.h \
+ graphicsitems/qmlgraphicsparticles_p.h \
graphicsitems/qmlgraphicslayoutitem_p.h \
graphicsitems/qmlgraphicseffects.cpp
@@ -72,6 +73,7 @@ SOURCES += \
graphicsitems/qmlgraphicsvisualitemmodel.cpp \
graphicsitems/qmlgraphicslistview.cpp \
graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp \
+ graphicsitems/qmlgraphicsparticles.cpp \
graphicsitems/qmlgraphicslayoutitem.cpp \
contains(QT_CONFIG, webkit) {
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
index 404daad..f6dc5fd 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
@@ -152,13 +152,23 @@ void QmlGraphicsAnchorsPrivate::fillChanged()
if (!fill || !isItemComplete())
return;
- if (fill == item->parentItem()) { //child-parent
- setItemPos(QPointF(leftMargin, topMargin));
- } else if (fill->parentItem() == item->parentItem()) { //siblings
- setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
+ if (updatingFill < 2) {
+ ++updatingFill;
+
+ if (fill == item->parentItem()) { //child-parent
+ setItemPos(QPointF(leftMargin, topMargin));
+ } else if (fill->parentItem() == item->parentItem()) { //siblings
+ setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
+ }
+ setItemWidth(fill->width()-leftMargin-rightMargin);
+ setItemHeight(fill->height()-topMargin-bottomMargin);
+
+ --updatingFill;
+ } else {
+ // ### Make this certain :)
+ qmlInfo(QmlGraphicsAnchors::tr("Possible anchor loop detected on fill."), item);
}
- setItemWidth(fill->width()-leftMargin-rightMargin);
- setItemHeight(fill->height()-topMargin-bottomMargin);
+
}
void QmlGraphicsAnchorsPrivate::centerInChanged()
@@ -166,16 +176,25 @@ void QmlGraphicsAnchorsPrivate::centerInChanged()
if (!centerIn || fill || !isItemComplete())
return;
- if (centerIn == item->parentItem()) {
- QPointF p((item->parentItem()->width() - item->width()) / 2.,
- (item->parentItem()->height() - item->height()) / 2.);
- setItemPos(p);
+ if (updatingCenterIn < 2) {
+ ++updatingCenterIn;
- } else if (centerIn->parentItem() == item->parentItem()) {
+ if (centerIn == item->parentItem()) {
+ QPointF p((item->parentItem()->width() - item->width()) / 2.,
+ (item->parentItem()->height() - item->height()) / 2.);
+ setItemPos(p);
- QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2.,
- centerIn->y() + (centerIn->height() - item->height()) / 2.);
- setItemPos(p);
+ } else if (centerIn->parentItem() == item->parentItem()) {
+
+ QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2.,
+ centerIn->y() + (centerIn->height() - item->height()) / 2.);
+ setItemPos(p);
+ }
+
+ --updatingCenterIn;
+ } else {
+ // ### Make this certain :)
+ qmlInfo(QmlGraphicsAnchors::tr("Possible anchor loop detected on centerIn."), item);
}
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
index 5f8b2c1..d21d9c5 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
@@ -89,7 +89,7 @@ class QmlGraphicsAnchorsPrivate : public QObjectPrivate
public:
QmlGraphicsAnchorsPrivate()
: updatingMe(false), updatingHorizontalAnchor(0),
- updatingVerticalAnchor(0), item(0), usedAnchors(0), fill(0),
+ updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(0), usedAnchors(0), fill(0),
centerIn(0), leftMargin(0), rightMargin(0), topMargin(0),
bottomMargin(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0),
componentComplete(true)
@@ -109,6 +109,8 @@ public:
bool updatingMe;
int updatingHorizontalAnchor;
int updatingVerticalAnchor;
+ int updatingFill;
+ int updatingCenterIn;
void setItemHeight(qreal);
void setItemWidth(qreal);
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index c7332f9..ea9c173 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -185,17 +185,17 @@ void QmlGraphicsFlickablePrivate::flickX(qreal velocity)
{
Q_Q(QmlGraphicsFlickable);
qreal maxDistance = -1;
- if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
- velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
// -ve velocity means list is moving up
if (velocity > 0) {
- if (_moveX.value() < q->minXExtent())
- maxDistance = qAbs(q->minXExtent() -_moveX.value() + (overShoot?30:0));
- flickTargetX = q->minXExtent();
+ const qreal minX = q->minXExtent();
+ if (_moveX.value() < minX)
+ maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0));
+ flickTargetX = minX;
} else {
- if (_moveX.value() > q->maxXExtent())
- maxDistance = qAbs(q->maxXExtent() - _moveX.value()) + (overShoot?30:0);
- flickTargetX = q->maxXExtent();
+ const qreal maxX = q->maxXExtent();
+ if (_moveX.value() > maxX)
+ maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0);
+ flickTargetX = maxX;
}
if (maxDistance > 0) {
qreal v = velocity;
@@ -225,13 +225,15 @@ void QmlGraphicsFlickablePrivate::flickY(qreal velocity)
qreal maxDistance = -1;
// -ve velocity means list is moving up
if (velocity > 0) {
- if (_moveY.value() < q->minYExtent())
- maxDistance = qAbs(q->minYExtent() -_moveY.value() + (overShoot?30:0));
- flickTargetY = q->minYExtent();
+ const qreal minY = q->minYExtent();
+ if (_moveY.value() < minY)
+ maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0));
+ flickTargetY = minY;
} else {
- if (_moveY.value() > q->maxYExtent())
- maxDistance = qAbs(q->maxYExtent() - _moveY.value()) + (overShoot?30:0);
- flickTargetY = q->maxYExtent();
+ const qreal maxY = q->maxYExtent();
+ if (_moveY.value() > maxY)
+ maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0);
+ flickTargetY = maxY;
}
if (maxDistance > 0) {
qreal v = velocity;
@@ -261,8 +263,6 @@ void QmlGraphicsFlickablePrivate::fixupX()
if (!q->xflick() || _moveX.timeLine())
return;
- vTime = timeline.time();
-
if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->minXExtent())) {
timeline.reset(_moveX);
if (_moveX.value() != q->minXExtent())
@@ -275,6 +275,8 @@ void QmlGraphicsFlickablePrivate::fixupX()
} else {
flicked = false;
}
+
+ vTime = timeline.time();
}
void QmlGraphicsFlickablePrivate::fixupY()
@@ -283,8 +285,6 @@ void QmlGraphicsFlickablePrivate::fixupY()
if (!q->yflick() || _moveY.timeLine())
return;
- vTime = timeline.time();
-
if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
timeline.reset(_moveY);
if (_moveY.value() != q->minYExtent())
@@ -297,6 +297,8 @@ void QmlGraphicsFlickablePrivate::fixupY()
} else {
flicked = false;
}
+
+ vTime = timeline.time();
}
void QmlGraphicsFlickablePrivate::updateBeginningEnd()
@@ -447,6 +449,7 @@ void QmlGraphicsFlickable::setViewportX(qreal pos)
Q_D(QmlGraphicsFlickable);
pos = qRound(pos);
d->timeline.reset(d->_moveX);
+ d->vTime = d->timeline.time();
if (-pos != d->_moveX.value()) {
d->_moveX.setValue(-pos);
viewportMoved();
@@ -464,6 +467,7 @@ void QmlGraphicsFlickable::setViewportY(qreal pos)
Q_D(QmlGraphicsFlickable);
pos = qRound(pos);
d->timeline.reset(d->_moveY);
+ d->vTime = d->timeline.time();
if (-pos != d->_moveY.value()) {
d->_moveY.setValue(-pos);
viewportMoved();
@@ -491,6 +495,7 @@ void QmlGraphicsFlickable::setInteractive(bool interactive)
d->interactive = interactive;
if (!interactive && d->flicked) {
d->timeline.clear();
+ d->vTime = d->timeline.time();
d->flicked = false;
emit flickingChanged();
emit flickEnded();
@@ -837,56 +842,57 @@ void QmlGraphicsFlickable::viewportMoved()
Q_D(QmlGraphicsFlickable);
int elapsed = QmlGraphicsItemPrivate::elapsed(d->velocityTime);
+ if (!elapsed)
+ return;
- if (elapsed) {
- qreal prevY = d->lastFlickablePosition.x();
- qreal prevX = d->lastFlickablePosition.y();
- d->velocityTimeline.clear();
- if (d->pressed) {
- qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed;
- qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed;
- d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing);
- } else {
- if (d->timeline.time() != d->vTime) {
- qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime);
- qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime);
- d->horizontalVelocity.setValue(horizontalVelocity);
- d->verticalVelocity.setValue(verticalVelocity);
- }
- d->vTime = d->timeline.time();
+ qreal prevY = d->lastFlickablePosition.x();
+ qreal prevX = d->lastFlickablePosition.y();
+ d->velocityTimeline.clear();
+ if (d->pressed) {
+ qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed;
+ qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed;
+ d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing);
+ } else {
+ if (d->timeline.time() > d->vTime) {
+ qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime);
+ qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime);
+ d->horizontalVelocity.setValue(horizontalVelocity);
+ d->verticalVelocity.setValue(verticalVelocity);
}
}
- d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value());
QmlGraphicsItemPrivate::restart(d->velocityTime);
- d->updateBeginningEnd();
+ d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value());
- if (d->flicked) {
+ if (d->flicked && d->timeline.time() > d->vTime) {
// Near an end and it seems that the extent has changed?
// Recalculate the flick so that we don't end up in an odd position.
if (d->velocityY > 0) {
const qreal minY = minYExtent();
- if (minY - d->_moveY.value() < height()/3 && minY != d->flickTargetY)
+ if (minY - d->_moveY.value() < height()/2 && minY != d->flickTargetY)
d->flickY(-d->verticalVelocity.value());
- } else {
+ } else if (d->velocityY < 0) {
const qreal maxY = maxYExtent();
- if (d->_moveY.value() - maxY < height()/3 && maxY != d->flickTargetY)
+ if (d->_moveY.value() - maxY < height()/2 && maxY != d->flickTargetY)
d->flickY(-d->verticalVelocity.value());
}
if (d->velocityX > 0) {
const qreal minX = minXExtent();
- if (minX - d->_moveX.value() < height()/3 && minX != d->flickTargetX)
+ if (minX - d->_moveX.value() < height()/2 && minX != d->flickTargetX)
d->flickX(-d->horizontalVelocity.value());
- } else {
+ } else if (d->velocityX < 0) {
const qreal maxX = maxXExtent();
- if (d->_moveX.value() - maxX < height()/3 && maxX != d->flickTargetX)
+ if (d->_moveX.value() - maxX < height()/2 && maxX != d->flickTargetX)
d->flickX(-d->horizontalVelocity.value());
}
}
+
+ d->vTime = d->timeline.time();
+ d->updateBeginningEnd();
}
void QmlGraphicsFlickable::cancelFlick()
@@ -1171,7 +1177,7 @@ void QmlGraphicsFlickable::setMaximumFlickVelocity(qreal v)
}
/*!
- \qmlproperty real Flickable::maximumFlickVelocity
+ \qmlproperty real Flickable::flickDeceleration
This property holds the rate at which a flick will decelerate.
The default is 500.
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 9f9b336..f39f5c7 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -578,29 +578,35 @@ void QmlGraphicsGridViewPrivate::createHighlight()
highlightYAnimator = 0;
}
- if (!highlightComponent)
- return;
-
if (currentItem) {
- QmlContext *highlightContext = new QmlContext(qmlContext(q));
- QObject *nobj = highlightComponent->create(highlightContext);
- if (nobj) {
- highlightContext->setParent(nobj);
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (item) {
- item->setParent(q->viewport());
- highlight = new FxGridItem(item, q);
- highlightXAnimator = new QmlEaseFollow(q);
- highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x")));
- highlightXAnimator->setDuration(150);
- highlightXAnimator->setEnabled(autoHighlight);
- highlightYAnimator = new QmlEaseFollow(q);
- highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y")));
- highlightYAnimator->setDuration(150);
- highlightYAnimator->setEnabled(autoHighlight);
+ QmlGraphicsItem *item = 0;
+ if (highlightComponent) {
+ QmlContext *highlightContext = new QmlContext(qmlContext(q));
+ QObject *nobj = highlightComponent->create(highlightContext);
+ if (nobj) {
+ highlightContext->setParent(nobj);
+ item = qobject_cast<QmlGraphicsItem *>(nobj);
+ if (!item)
+ delete nobj;
} else {
delete highlightContext;
}
+ } else {
+ item = new QmlGraphicsItem;
+ item->setParent(q->viewport());
+ }
+ if (item) {
+ item->setZValue(0);
+ item->setParent(q->viewport());
+ highlight = new FxGridItem(item, q);
+ highlightXAnimator = new QmlEaseFollow(q);
+ highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x")));
+ highlightXAnimator->setDuration(150);
+ highlightXAnimator->setEnabled(autoHighlight);
+ highlightYAnimator = new QmlEaseFollow(q);
+ highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y")));
+ highlightYAnimator->setDuration(150);
+ highlightYAnimator->setEnabled(autoHighlight);
}
}
}
@@ -1148,7 +1154,7 @@ void QmlGraphicsGridView::keyPressEvent(QKeyEvent *event)
}
/*!
- \qmlmethod GridView::moveCurrentIndexUp
+ \qmlmethod GridView::moveCurrentIndexUp()
Move the currentIndex up one item in the view.
The current index will wrap if keyNavigationWraps is true and it
@@ -1171,7 +1177,7 @@ void QmlGraphicsGridView::moveCurrentIndexUp()
}
/*!
- \qmlmethod GridView::moveCurrentIndexDown
+ \qmlmethod GridView::moveCurrentIndexDown()
Move the currentIndex down one item in the view.
The current index will wrap if keyNavigationWraps is true and it
@@ -1194,7 +1200,7 @@ void QmlGraphicsGridView::moveCurrentIndexDown()
}
/*!
- \qmlmethod GridView::moveCurrentIndexLeft
+ \qmlmethod GridView::moveCurrentIndexLeft()
Move the currentIndex left one item in the view.
The current index will wrap if keyNavigationWraps is true and it
@@ -1217,7 +1223,7 @@ void QmlGraphicsGridView::moveCurrentIndexLeft()
}
/*!
- \qmlmethod GridView::moveCurrentIndexRight
+ \qmlmethod GridView::moveCurrentIndexRight()
Move the currentIndex right one item in the view.
The current index will wrap if keyNavigationWraps is true and it
@@ -1500,6 +1506,8 @@ void QmlGraphicsGridView::itemsMoved(int from, int to, int count)
if (item->index > from && item->index != -1) {
// move everything after the moved items.
item->index -= count;
+ if (item->index < d->visibleIndex)
+ d->visibleIndex = item->index;
}
++it;
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index 77e6db8..572aa98 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -389,6 +389,76 @@ void QmlGraphicsItemKeyFilter::componentComplete()
if (m_next) m_next->componentComplete();
}
+
+/*!
+ \qmlclass KeyNavigation
+ \brief The KeyNavigation attached property supports key navigation by arrow keys.
+
+ It is common in key-based UIs to use arrow keys to navigate
+ between focussed items. The KeyNavigation property provides a
+ convenient way of specifying which item will gain focus
+ when an arrow key is pressed. The following example provides
+ key navigation for a 2x2 grid of items.
+
+ \code
+ Grid {
+ columns: 2
+ width: 100; height: 100
+ Rectangle {
+ id: item1
+ focus: true
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.right: item2
+ KeyNavigation.down: item3
+ }
+ Rectangle {
+ id: item2
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.left: item1
+ KeyNavigation.down: item4
+ }
+ Rectangle {
+ id: item3
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.right: item4
+ KeyNavigation.up: item1
+ }
+ Rectangle {
+ id: item4
+ width: 50; height: 50
+ color: focus ? "red" : "lightgray"
+ KeyNavigation.left: item3
+ KeyNavigation.up: item2
+ }
+ }
+ \endcode
+
+ KeyNavigation receives key events after the item it is attached to.
+ If the item accepts an arrow key event, the KeyNavigation
+ attached property will not receive an event for that key.
+
+ If an item has been set for a direction and the KeyNavigation
+ attached property receives the corresponding
+ key press and release events, the events will be accepted by
+ KeyNaviagtion and will not propagate any further.
+
+ \sa {Keys}{Keys attached property}
+*/
+
+/*!
+ \qmlproperty Item KeyNavigation::left
+ \qmlproperty Item KeyNavigation::right
+ \qmlproperty Item KeyNavigation::up
+ \qmlproperty Item KeyNavigation::down
+
+ These properties hold the item to assign focus to
+ when Key_Left, Key_Right, Key_Up or Key_Down are
+ pressed.
+*/
+
class QmlGraphicsKeyNavigationAttachedPrivate : public QObjectPrivate
{
public:
@@ -606,7 +676,7 @@ void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event)
See \l {Qt::Key}{Qt.Key} for the list of keyboard codes.
- \sa KeyEvent
+ \sa KeyEvent, {KeyNavigation}{KeyNavigation attached property}
*/
/*!
@@ -1119,7 +1189,7 @@ void QmlGraphicsKeysAttached::keyPressed(QKeyEvent *event)
// If we specifically handle a key then default to accepted
ke.setAccepted(true);
int idx = QmlGraphicsKeysAttached::staticMetaObject.indexOfSignal(keySignal);
- metaObject()->method(idx).invoke(this, Q_ARG(QmlGraphicsKeysAttached, &ke));
+ metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QmlGraphicsKeyEvent*, &ke));
}
}
if (!ke.isAccepted())
@@ -1838,6 +1908,17 @@ void QmlGraphicsItem::setClip(bool c)
*/
/*!
+ \qmlproperty bool Item::visible
+
+ Whether the item is visible. By default this is true.
+
+ \note visible is not linked to actual visibility; if you item
+ goes off screen, or the opacity changes to 0, etc this will
+ not affect the visible property.
+*/
+
+
+/*!
This function is called to handle this item's changes in
geometry from \a oldGeometry to \a newGeometry. If the two
geometries are the same, it doesn't do anything.
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index fd8b8b0..53287a6 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -434,7 +434,6 @@ void QmlGraphicsListViewPrivate::clear()
visibleIndex = 0;
releaseItem(currentItem);
currentItem = 0;
- currentIndex = -1;
createHighlight();
trackedItem = 0;
}
@@ -662,19 +661,16 @@ void QmlGraphicsListViewPrivate::createHighlight()
if (nobj) {
highlightContext->setParent(nobj);
item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (!item) {
+ if (!item)
delete nobj;
- } else {
- item->setParent(q->viewport());
- }
} else {
delete highlightContext;
}
} else {
item = new QmlGraphicsItem;
- item->setParent(q->viewport());
}
if (item) {
+ item->setParent(q->viewport());
item->setZValue(0);
highlight = new FxListItem(item, q);
if (orient == QmlGraphicsListView::Vertical)
@@ -749,7 +745,7 @@ void QmlGraphicsListViewPrivate::updateCurrentSection()
void QmlGraphicsListViewPrivate::updateCurrent(int modelIndex)
{
Q_Q(QmlGraphicsListView);
- if (!isValid() || modelIndex < 0 || modelIndex >= model->count()) {
+ if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) {
if (currentItem) {
currentItem->attached->setIsCurrentItem(false);
releaseItem(currentItem);
@@ -815,8 +811,9 @@ void QmlGraphicsListViewPrivate::fixupY()
if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) {
if (currentItem && highlight && currentItem->position() != highlight->position()) {
moveReason = Mouse;
- timeline.clear();
+ timeline.reset(_moveY);
timeline.move(_moveY, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), 200);
+ vTime = timeline.time();
}
}
}
@@ -830,8 +827,9 @@ void QmlGraphicsListViewPrivate::fixupX()
if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) {
if (currentItem && highlight && currentItem->position() != highlight->position()) {
moveReason = Mouse;
- timeline.clear();
+ timeline.reset(_moveX);
timeline.move(_moveX, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), 200);
+ vTime = timeline.time();
}
}
}
@@ -1115,16 +1113,20 @@ void QmlGraphicsListView::setModel(const QVariant &model)
dataModel->setModel(model);
}
if (d->model) {
- if (d->currentIndex >= d->model->count() || d->currentIndex < 0)
- setCurrentIndex(0);
- else
- d->updateCurrent(d->currentIndex);
+ if (isComponentComplete()) {
+ refill();
+ if (d->currentIndex >= d->model->count() || d->currentIndex < 0) {
+ setCurrentIndex(0);
+ } else {
+ d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ }
+ }
connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
connect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*)));
connect(d->model, SIGNAL(destroyingItem(QmlGraphicsItem*)), this, SLOT(destroyingItem(QmlGraphicsItem*)));
- refill();
emit countChanged();
}
}
@@ -1157,8 +1159,11 @@ void QmlGraphicsListView::setDelegate(QmlComponent *delegate)
}
if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) {
dataModel->setDelegate(delegate);
- d->updateCurrent(d->currentIndex);
- refill();
+ if (isComponentComplete()) {
+ refill();
+ d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ }
}
}
@@ -1179,7 +1184,7 @@ int QmlGraphicsListView::currentIndex() const
void QmlGraphicsListView::setCurrentIndex(int index)
{
Q_D(QmlGraphicsListView);
- if (d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
+ if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) {
d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
cancelFlick();
d->updateCurrent(index);
@@ -1255,7 +1260,7 @@ void QmlGraphicsListView::setHighlight(QmlComponent *highlight)
is scrolled. This is because the view moves to maintain the
highlight within the preferred highlight range (or visible viewport).
- \sa highlight
+ \sa highlight, highlightMoveSpeed
*/
bool QmlGraphicsListView::highlightFollowsCurrentItem() const
{
@@ -1462,6 +1467,10 @@ void QmlGraphicsListView::setSectionExpression(const QString &expression)
}
}
+/*!
+ \qmlproperty string ListView::currentSection
+ This property holds the section that is currently at the beginning of the view.
+*/
QString QmlGraphicsListView::currentSection() const
{
Q_D(const QmlGraphicsListView);
@@ -1470,8 +1479,13 @@ QString QmlGraphicsListView::currentSection() const
/*!
\qmlproperty real ListView::highlightMoveSpeed
+ \qmlproperty real ListView::highlightResizeSpeed
+ These properties hold the move and resize animation speed of the highlight delegate.
- This property holds the moving animation speed of the highlight delegate.
+ highlightFollowsCurrentItem must be true for these properties
+ to have effect.
+
+ \sa highlightFollowsCurrentItem
*/
qreal QmlGraphicsListView::highlightMoveSpeed() const
{
@@ -1485,15 +1499,12 @@ void QmlGraphicsListView::setHighlightMoveSpeed(qreal speed)
if (d->highlightMoveSpeed != speed)
{
d->highlightMoveSpeed = speed;
+ if (d->highlightPosAnimator)
+ d->highlightPosAnimator->setVelocity(d->highlightMoveSpeed);
emit highlightMoveSpeedChanged();
}
}
-/*!
- \qmlproperty real ListView::highlightResizeSpeed
-
- This property holds the resizing animation speed of the highlight delegate.
-*/
qreal QmlGraphicsListView::highlightResizeSpeed() const
{
Q_D(const QmlGraphicsListView);\
@@ -1506,6 +1517,8 @@ void QmlGraphicsListView::setHighlightResizeSpeed(qreal speed)
if (d->highlightResizeSpeed != speed)
{
d->highlightResizeSpeed = speed;
+ if (d->highlightSizeAnimator)
+ d->highlightSizeAnimator->setVelocity(d->highlightResizeSpeed);
emit highlightResizeSpeedChanged();
}
}
@@ -1663,9 +1676,11 @@ void QmlGraphicsListView::componentComplete()
{
Q_D(QmlGraphicsListView);
QmlGraphicsFlickable::componentComplete();
+ refill();
if (d->currentIndex < 0)
d->updateCurrent(0);
- refill();
+ else
+ d->updateCurrent(d->currentIndex);
d->fixupPosition();
}
@@ -1745,6 +1760,7 @@ void QmlGraphicsListView::itemsInserted(int modelIndex, int count)
d->updateUnrequestedIndexes();
if (!d->visibleItems.count() || d->model->count() <= 1) {
d->layout();
+ d->updateSections();
d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
emit countChanged();
return;
@@ -1824,6 +1840,7 @@ void QmlGraphicsListView::itemsInserted(int modelIndex, int count)
added.at(j)->attached->emitAdd();
d->updateUnrequestedPositions();
d->updateViewport();
+ d->updateSections();
emit countChanged();
}
@@ -2006,6 +2023,7 @@ void QmlGraphicsListView::itemsMoved(int from, int to, int count)
d->visibleItems.first()->setPosition(firstItemPos);
d->layout();
+ d->updateSections();
}
void QmlGraphicsListView::createdItem(int index, QmlGraphicsItem *item)
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h
index 446d71a..3f46434 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h
@@ -64,8 +64,11 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsListView : public QmlGraphicsFlickable
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(QmlGraphicsItem *currentItem READ currentItem NOTIFY currentIndexChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
+
Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight)
Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
+ Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
+ Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin)
Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd)
@@ -78,8 +81,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsListView : public QmlGraphicsFlickable
Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged)
Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
- Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
- Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
Q_ENUMS(HighlightRangeMode)
Q_ENUMS(Orientation)
Q_CLASSINFO("DefaultProperty", "data")
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
index 3b10908..c466c44 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
@@ -45,7 +45,8 @@
QT_BEGIN_NAMESPACE
QmlGraphicsLoaderPrivate::QmlGraphicsLoaderPrivate()
-: item(0), component(0), ownComponent(false), resizeMode(QmlGraphicsLoader::SizeLoaderToItem)
+ : item(0), component(0), ownComponent(false)
+ , resizeMode(QmlGraphicsLoader::SizeLoaderToItem)
{
}
@@ -53,6 +54,36 @@ QmlGraphicsLoaderPrivate::~QmlGraphicsLoaderPrivate()
{
}
+void QmlGraphicsLoaderPrivate::clear()
+{
+ if (ownComponent) {
+ delete component;
+ component = 0;
+ ownComponent = false;
+ }
+ source = QUrl();
+
+ delete item;
+ item = 0;
+}
+
+void QmlGraphicsLoaderPrivate::initResize()
+{
+ Q_Q(QmlGraphicsLoader);
+
+ QmlGraphicsItem *resizeItem = 0;
+ if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem)
+ resizeItem = item;
+ else if (resizeMode == QmlGraphicsLoader::SizeItemToLoader)
+ resizeItem = q;
+ if (resizeItem) {
+ QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ }
+ _q_updateSize();
+}
+
+
QML_DEFINE_TYPE(Qt,4,6,Loader,QmlGraphicsLoader)
/*!
@@ -74,6 +105,17 @@ QML_DEFINE_TYPE(Qt,4,6,Loader,QmlGraphicsLoader)
MouseRegion { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" }
}
\endcode
+
+ If the Loader source is changed, any previous items instantiated
+ will be destroyed. Setting \c source to an empty string
+ will destroy the currently instantiated items, freeing resources
+ and leaving the Loader empty. For example:
+
+ \code
+ pageLoader.source = ""
+ \endcode
+
+ unloads "Page1.qml" and frees resources consumed by it.
*/
/*!
@@ -102,7 +144,7 @@ QmlGraphicsLoader::~QmlGraphicsLoader()
This property holds the URL of the QML component to
instantiate.
- \sa status, progress
+ \sa sourceComponent, status, progress
*/
QUrl QmlGraphicsLoader::source() const
{
@@ -116,12 +158,7 @@ void QmlGraphicsLoader::setSource(const QUrl &url)
if (d->source == url)
return;
- if (d->ownComponent) {
- delete d->component;
- d->component = 0;
- }
- delete d->item;
- d->item = 0;
+ d->clear();
d->source = url;
if (d->source.isEmpty()) {
@@ -164,7 +201,7 @@ void QmlGraphicsLoader::setSource(const QUrl &url)
}
\endqml
- \sa source
+ \sa source, progress
*/
QmlComponent *QmlGraphicsLoader::sourceComponent() const
@@ -179,13 +216,7 @@ void QmlGraphicsLoader::setSourceComponent(QmlComponent *comp)
if (comp == d->component)
return;
- d->source = QUrl();
- if (d->ownComponent) {
- delete d->component;
- d->component = 0;
- }
- delete d->item;
- d->item = 0;
+ d->clear();
d->component = comp;
d->ownComponent = false;
@@ -233,16 +264,7 @@ void QmlGraphicsLoaderPrivate::_q_sourceLoaded()
if (item) {
item->setParentItem(q);
// item->setFocus(true);
- QmlGraphicsItem *resizeItem = 0;
- if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem)
- resizeItem = item;
- else if (resizeMode == QmlGraphicsLoader::SizeItemToLoader)
- resizeItem = q;
- if (resizeItem) {
- QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
- QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
- }
- _q_updateSize();
+ initResize();
}
} else {
delete obj;
@@ -340,20 +362,7 @@ void QmlGraphicsLoader::setResizeMode(ResizeMode mode)
}
d->resizeMode = mode;
-
- if (d->item) {
- QmlGraphicsItem *resizeItem = 0;
- if (d->resizeMode == SizeLoaderToItem)
- resizeItem = d->item;
- else if (d->resizeMode == SizeItemToLoader)
- resizeItem = this;
- if (resizeItem) {
- connect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
- connect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize()));
- }
-
- d->_q_updateSize();
- }
+ d->initResize();
}
void QmlGraphicsLoaderPrivate::_q_updateSize()
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p.h
index 8cd1819..ad516b4 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsloader_p.h
@@ -63,7 +63,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsLoader : public QmlGraphicsItem
Q_PROPERTY(QmlGraphicsItem *item READ item NOTIFY itemChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- //### sourceItem
public:
QmlGraphicsLoader(QmlGraphicsItem *parent=0);
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h
index 23fedb7..cd7316d 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h
@@ -67,10 +67,13 @@ public:
QmlGraphicsLoaderPrivate();
~QmlGraphicsLoaderPrivate();
+ void clear();
+ void initResize();
+
QUrl source;
QmlGraphicsItem *item;
QmlComponent *component;
- bool ownComponent;
+ bool ownComponent : 1;
QmlGraphicsLoader::ResizeMode resizeMode;
void _q_sourceLoaded();
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
index 196cdf2..22c2c0a 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
@@ -146,19 +146,19 @@ void QmlGraphicsDrag::setYmax(qreal m)
*/
/*!
- \qmlsignal MouseRegion::onEntered
+ \qmlsignal MouseRegion::onEntered()
This handler is called when the mouse enters the mouse region.
*/
/*!
- \qmlsignal MouseRegion::onExited
+ \qmlsignal MouseRegion::onExited()
This handler is called when the mouse exists the mouse region.
*/
/*!
- \qmlsignal MouseRegion::onPositionChanged(mouse)
+ \qmlsignal MouseRegion::onPositionChanged(MouseEvent mouse)
This handler is called when the mouse position changes.
diff --git a/src/declarative/extra/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
index e96a1d5..4ac02b4 100644
--- a/src/declarative/extra/qmlgraphicsparticles.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
@@ -302,7 +302,7 @@ void QmlGraphicsParticleMotionWander::advance(QmlGraphicsParticle &p, int interv
qreal xdiff = p.x_velocity - d->x_targetV;
if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) {
d->x_var = -d->x_var;
- d->x_peak = _xvariance + _xvariance * qreal(rand()) / RAND_MAX;
+ d->x_peak = _xvariance + _xvariance * qreal(qrand()) / RAND_MAX;
}
p.x_velocity += d->x_var * interval;
}
@@ -312,7 +312,7 @@ void QmlGraphicsParticleMotionWander::advance(QmlGraphicsParticle &p, int interv
qreal ydiff = p.y_velocity - d->y_targetV;
if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) {
d->y_var = -d->y_var;
- d->y_peak = _yvariance + _yvariance * qreal(rand()) / RAND_MAX;
+ d->y_peak = _yvariance + _yvariance * qreal(qrand()) / RAND_MAX;
}
p.y_velocity += d->y_var * interval;
}
@@ -329,8 +329,8 @@ void QmlGraphicsParticleMotionWander::created(QmlGraphicsParticle &p)
d->y_targetV = p.y_velocity;
d->x_peak = _xvariance;
d->y_peak = _yvariance;
- d->x_var = _pace * qreal(rand()) / RAND_MAX / 1000.0;
- d->y_var = _pace * qreal(rand()) / RAND_MAX / 1000.0;
+ d->x_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0;
+ d->y_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0;
}
}
@@ -368,9 +368,10 @@ class QmlGraphicsParticlesPrivate : public QmlGraphicsItemPrivate
Q_DECLARE_PUBLIC(QmlGraphicsParticles)
public:
QmlGraphicsParticlesPrivate()
- : count(1), lifeSpan(1000), lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
- , angle(0), angleDev(0), velocity(0), velocityDev(0)
- , addParticleTime(0), addParticleCount(0), lastAdvTime(0), stream(false), streamDelay(0)
+ : count(1), emissionRate(-1), emissionVariance(0.5), lifeSpan(1000)
+ , lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
+ , angle(0), angleDev(0), velocity(0), velocityDev(0), emissionCarry(0.)
+ , addParticleTime(0), addParticleCount(0), lastAdvTime(0)
, emitting(true), motion(0), pendingPixmapCache(false), clock(this)
{
}
@@ -392,6 +393,8 @@ public:
QUrl url;
QPixmap image;
int count;
+ int emissionRate;
+ qreal emissionVariance;
int lifeSpan;
int lifeSpanDev;
int fadeInDur;
@@ -400,17 +403,17 @@ public:
qreal angleDev;
qreal velocity;
qreal velocityDev;
+ qreal emissionCarry;
int addParticleTime;
int addParticleCount;
int lastAdvTime;
- bool stream;
- int streamDelay;
bool emitting;
QmlGraphicsParticleMotion *motion;
QmlGraphicsParticlesPainter *paintItem;
bool pendingPixmapCache;
+ QList<QPair<int, int> > bursts;//countLeft, emissionRate pairs
QList<QmlGraphicsParticle> particles;
QTickAnimationProxy<QmlGraphicsParticlesPrivate, &QmlGraphicsParticlesPrivate::tick> clock;
@@ -439,40 +442,62 @@ void QmlGraphicsParticlesPrivate::tick(int time)
}
}
- while(removed-- && particles.count() < count && emitting)
- createParticle(time);
+ if(emissionRate == -1)//Otherwise leave emission to the emission rate
+ while(removed-- && ((count == -1) || particles.count() < count) && emitting)
+ createParticle(time);
if (!addParticleTime)
addParticleTime = time;
- if (particles.count() < count && emitting) {
- qreal perc = (lifeSpanDev <= 0)?(1.):(qreal(time - addParticleTime) / qreal(lifeSpanDev));
- int percCount = addParticleCount + (int)perc * (count - addParticleCount);
- int streamWidth = -1;
- if (stream){
- if (streamDelay > time){
- streamWidth = 0;
- }else{
- int missed = time - streamDelay;
- qreal streamWidthReal = qreal(count)/qreal(lifeSpan);
- if (streamWidthReal < 1){
- streamDelay = time + (int)(1.0/streamWidthReal);
- streamWidth = 1;
- streamWidth += missed/streamDelay;
- }else{
- streamWidth = qRound(streamWidthReal * (time-lastAdvTime));
- }
+ //Possibly emit new particles
+ if (((count == -1) || particles.count() < count) && emitting
+ && !(count==-1 && emissionRate==-1)) {
+ int emissionCount = -1;
+ if (emissionRate != -1){
+ qreal variance = 1.;
+ if (emissionVariance > 0.){
+ variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.);
+ }
+ qreal emission = emissionRate * (qreal(interval)/1000.);
+ emission = emission * variance + emissionCarry;
+ double tmpDbl;
+ emissionCarry = modf(emission, &tmpDbl);
+ emissionCount = (int)tmpDbl;
+ emissionCount = qMax(0,emissionCount);
+ }
+ while(((count == -1) || particles.count() < count) &&
+ (emissionRate==-1 || emissionCount--))
+ createParticle(time);
+ }
+
+ //Deal with emissions from requested bursts
+ for(int i=0; i<bursts.size(); i++){
+ int emission = 0;
+ if(bursts[i].second == -1){
+ emission = bursts[i].first;
+ }else{
+ qreal variance = 1.;
+ if (emissionVariance > 0.){
+ variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.);
}
+ qreal workingEmission = bursts[i].second * (qreal(interval)/1000.);
+ workingEmission *= variance;
+ emission = (int)workingEmission;
+ emission = qMax(emission, 0);
}
- while(particles.count() < count &&
- (!stream || (particles.count() < percCount && streamWidth--)))
+ emission = qMin(emission, bursts[i].first);
+ bursts[i].first -= emission;
+ while(emission--)
createParticle(time);
}
+ for(int i=bursts.size()-1; i>=0; i--)
+ if(bursts[i].first <= 0)
+ bursts.removeAt(i);
lastAdvTime = time;
paintItem->updateSize();
paintItem->update();
- if (!(oldCount || particles.count()) && (!count || !emitting)) {
+ if (!(oldCount || particles.count()) && (!count || !emitting) && bursts.isEmpty()) {
lastAdvTime = 0;
clock.stop();
}
@@ -485,11 +510,11 @@ void QmlGraphicsParticlesPrivate::createParticle(int time)
#endif
Q_Q(QmlGraphicsParticles);
QmlGraphicsParticle p(time);
- p.x = q->x() + q->width() * qreal(rand()) / RAND_MAX - image.width()/2.0;
- p.y = q->y() + q->height() * qreal(rand()) / RAND_MAX - image.height()/2.0;
+ p.x = q->x() + q->width() * qreal(qrand()) / RAND_MAX - image.width()/2.0;
+ p.y = q->y() + q->height() * qreal(qrand()) / RAND_MAX - image.height()/2.0;
p.lifeSpan = lifeSpan;
if (lifeSpanDev)
- p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(rand()) / RAND_MAX);
+ p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(qrand()) / RAND_MAX);
p.fadeOutAge = p.lifeSpan - fadeOutDur;
if (fadeInDur == 0.) {
p.state= QmlGraphicsParticle::Solid;
@@ -497,12 +522,12 @@ void QmlGraphicsParticlesPrivate::createParticle(int time)
}
qreal a = angle;
if (angleDev)
- a += angleDev/2 - angleDev * qreal(rand()) / RAND_MAX;
+ a += angleDev/2 - angleDev * qreal(qrand()) / RAND_MAX;
if (a > M_PI)
a = a - 2 * M_PI;
qreal v = velocity;
if (velocityDev)
- v += velocityDev/2 - velocityDev * qreal(rand()) / RAND_MAX;
+ v += velocityDev/2 - velocityDev * qreal(qrand()) / RAND_MAX;
p.x_velocity = v * fastCos(a);
p.y_velocity = v * fastSin(a);
particles.append(p);
@@ -541,6 +566,8 @@ QML_DEFINE_TYPE(Qt,4,6,Particles,QmlGraphicsParticles)
\brief The Particles object generates and moves particles.
\inherits Item
+ This element provides preliminary support for particles in QML, and may be heavily changed or removed in later versions.
+
The particles created by this object cannot be dealt with directly, they can only be controlled through the parameters of the Particles object. The particles are all the same pixmap, specified by the user.
The particles are painted relative to the parent of the Particles object. Moving the
@@ -675,16 +702,27 @@ void QmlGraphicsParticles::setSource(const QUrl &name)
d->paintItem->update();
}
}
+ emit sourceChanged();
}
/*!
\qmlproperty int Particles::count
- This property holds the target number of particles
+ This property holds the maximum number of particles
+
+ The particles element emits particles until it has count active
+ particles. When this number is reached, new particles are not emitted until
+ some of the current particles reach theend of their lifespan.
+
+ If count is -1 then there is no maximum number of active particles, and
+ particles will be constantly emitted at the rate specified by emissionRate.
+
+ If both count and emissionRate are set to -1, nothing will be emitted.
+
*/
/*!
\property QmlGraphicsParticles::count
- \brief the target number of particles
+ \brief the maximum number of particles
*/
int QmlGraphicsParticles::count() const
{
@@ -702,11 +740,93 @@ void QmlGraphicsParticles::setCount(int cnt)
d->count = cnt;
d->addParticleTime = 0;
d->addParticleCount = d->particles.count();
- if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count) {
+ if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count && d->emitting) {
d->clock.start();
}
d->paintItem->updateSize();
d->paintItem->update();
+ emit countChanged();
+}
+
+
+/*!
+ \qmlproperty int Particles::emissionRate
+ This property holds the target number of particles to emit every second.
+
+ The particles element will emit up to emissionRate particles every
+ second. Fewer particles may be emitted per second if the maximum number of
+ particles has been reached.
+
+ If emissionRate is set to -1 there is no limit to the number of
+ particles emitted per second, and particles will be instantly emitted to
+ reach the maximum number of particles specified by count.
+
+ The default value for emissionRate is -1.
+
+ If both count and emissionRate are set to -1, nothing will be emitted.
+*/
+
+/*!
+ \property QmlGraphicsParticles::emissionRate
+ \brief the emission rate of particles
+*/
+int QmlGraphicsParticles::emissionRate() const
+{
+ Q_D(const QmlGraphicsParticles);
+ return d->emissionRate;
+}
+void QmlGraphicsParticles::setEmissionRate(int er)
+{
+ Q_D(QmlGraphicsParticles);
+ if(er == d->emissionRate)
+ return;
+ d->emissionRate = er;
+ emit emissionRateChanged();
+}
+
+/*!
+ \qmlproperty qreal Particles::emissionVariance
+ This property holds how inconsistent the rate of particle emissions are.
+ It is a number between 0 (no variance) and 1 (some variance).
+
+ The expected number of particles emitted per second is emissionRate. If
+ emissionVariance is 0 then particles will be emitted consistently throughout
+ each second to reach that number. If emissionVariance is greater than 0 the
+ rate of particle emission will vary randomly throughout the second, with the
+ consequence that the actual number of particles emitted in one second will
+ vary randomly as well.
+
+ emissionVariance is the maximum deviation from emitting
+ emissionRate particles per second. An emissionVariance of 0 means you should
+ get exactly emissionRate particles emitted per second,
+ and an emissionVariance of 1 means you will get between zero and two times
+ emissionRate particles per second, but you should get emissionRate particles
+ per second on average.
+
+ Note that even with an emissionVariance of 0 there may be some variance due
+ to performance and hardware constraints.
+
+ The default value of emissionVariance is 0.5
+*/
+
+/*!
+ \property QmlGraphicsParticles::emissionVariance
+ \brief how much the particle emission amounts vary per tick
+*/
+
+qreal QmlGraphicsParticles::emissionVariance() const
+{
+ Q_D(const QmlGraphicsParticles);
+ return d->emissionVariance;
+}
+
+void QmlGraphicsParticles::setEmissionVariance(qreal ev)
+{
+ Q_D(QmlGraphicsParticles);
+ if(d->emissionVariance == ev)
+ return;
+ d->emissionVariance = ev;
+ emit emissionVarianceChanged();
}
/*!
@@ -747,7 +867,10 @@ int QmlGraphicsParticles::lifeSpan() const
void QmlGraphicsParticles::setLifeSpan(int ls)
{
Q_D(QmlGraphicsParticles);
+ if(d->lifeSpan == ls)
+ return;
d->lifeSpan = ls;
+ emit lifeSpanChanged();
}
/*!
@@ -777,7 +900,10 @@ int QmlGraphicsParticles::lifeSpanDeviation() const
void QmlGraphicsParticles::setLifeSpanDeviation(int dev)
{
Q_D(QmlGraphicsParticles);
+ if(d->lifeSpanDev == dev)
+ return;
d->lifeSpanDev = dev;
+ emit lifeSpanDeviationChanged();
}
/*!
@@ -803,8 +929,10 @@ int QmlGraphicsParticles::fadeInDuration() const
void QmlGraphicsParticles::setFadeInDuration(int dur)
{
Q_D(QmlGraphicsParticles);
- if (dur >= 0.0)
- d->fadeInDur = dur;
+ if (dur < 0.0 || dur == d->fadeInDur)
+ return;
+ d->fadeInDur = dur;
+ emit fadeInDurationChanged();
}
/*!
@@ -822,8 +950,10 @@ int QmlGraphicsParticles::fadeOutDuration() const
void QmlGraphicsParticles::setFadeOutDuration(int dur)
{
Q_D(QmlGraphicsParticles);
- if (dur >= 0.0)
- d->fadeOutDur = dur;
+ if (dur < 0.0 || d->fadeOutDur == dur)
+ return;
+ d->fadeOutDur = dur;
+ emit fadeOutDurationChanged();
}
/*!
@@ -860,7 +990,11 @@ qreal QmlGraphicsParticles::angle() const
void QmlGraphicsParticles::setAngle(qreal angle)
{
Q_D(QmlGraphicsParticles);
- d->angle = angle * M_PI / 180.0;
+ qreal radAngle = angle * M_PI / 180.0;
+ if(radAngle == d->angle)
+ return;
+ d->angle = radAngle;
+ emit angleChanged();
}
/*!
@@ -890,7 +1024,11 @@ qreal QmlGraphicsParticles::angleDeviation() const
void QmlGraphicsParticles::setAngleDeviation(qreal dev)
{
Q_D(QmlGraphicsParticles);
- d->angleDev = dev * M_PI / 180.0;;
+ qreal radDev = dev * M_PI / 180.0;
+ if(radDev == d->angleDev)
+ return;
+ d->angleDev = radDev;
+ emit angleDeviationChanged();
}
/*!
@@ -927,7 +1065,11 @@ qreal QmlGraphicsParticles::velocity() const
void QmlGraphicsParticles::setVelocity(qreal velocity)
{
Q_D(QmlGraphicsParticles);
- d->velocity = velocity / 1000.0;
+ qreal realVel = velocity / 1000.0;
+ if(realVel == d->velocity)
+ return;
+ d->velocity = realVel;
+ emit velocityChanged();
}
/*!
@@ -957,38 +1099,11 @@ qreal QmlGraphicsParticles::velocityDeviation() const
void QmlGraphicsParticles::setVelocityDeviation(qreal velocity)
{
Q_D(QmlGraphicsParticles);
- d->velocityDev = velocity / 1000.0;
-}
-
-/*!
- \qmlproperty bool Particles::streamIn
- This property determines whether the particles stream in at a constant rate
-
- When stream is set to true the particles will stream in at a constant rate.
- Otherwise the particles will appear as a clump. Note that this only affects the
- start of the particle effect, variables such as lifespan deviation can cause the
- particles to unclump over time.
-*/
-/*!
- \property QmlGraphicsParticles::streamIn
- \brief determines whether the particles stream in at a constant rate
-
- When stream is set to true the particles will stream in at a constant rate.
- Otherwise the particles will appear as a clump. Note that this only affects the
- start of the particle effect, variables such as lifespan deviation can cause the
-
-*/
-//The name may need a rethink
-bool QmlGraphicsParticles::streamIn() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->stream;
-}
-
-void QmlGraphicsParticles::setStreamIn(bool b)
-{
- Q_D(QmlGraphicsParticles);
- d->stream = b;
+ qreal realDev = velocity / 1000.0;
+ if(realDev == d->velocityDev)
+ return;
+ d->velocityDev = realDev;
+ emit velocityDeviationChanged();
}
/*!
@@ -1020,9 +1135,12 @@ bool QmlGraphicsParticles::emitting() const
void QmlGraphicsParticles::setEmitting(bool r)
{
Q_D(QmlGraphicsParticles);
+ if(d->emitting == r)
+ return;
d->emitting = r;
if (d->count && r)
d->clock.start();
+ emit emittingChanged();
}
/*!
\qmlproperty ParticleMotion Particles::motion
@@ -1057,6 +1175,31 @@ void QmlGraphicsParticles::setMotion(QmlGraphicsParticleMotion *motion)
d->motion = motion;
}
+/*!
+ \qmlmethod Particles::burst
+
+ Initiates a burst of particles.
+
+ This method takes two arguments. The first argument is the number
+ of particles to emit and the second argument is the emissionRate for the
+ burst. If the second argument is omitted, it is treated as -1. The burst
+ of particles has a separate emissionRate and count to the normal emission of
+ particles. The burst uses the same values as normal emission for all other
+ properties, including emissionVariance and emitting.
+
+ The normal emission of particles will continue during the burst, however
+ the particles created by the burst count towards the maximum number used by
+ normal emission. To avoid this behavior, use two Particles elements.
+
+*/
+void QmlGraphicsParticles::burst(int count, int emissionRate)
+{
+ Q_D(QmlGraphicsParticles);
+ d->bursts << qMakePair(count, emissionRate);
+ if (d->clock.state() != QAbstractAnimation::Running && d->emitting)
+ d->clock.start();
+}
+
void QmlGraphicsParticlesPainter::updateSize()
{
if (!isComponentComplete())
@@ -1100,14 +1243,15 @@ void QmlGraphicsParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsI
const int myX = x() + parentItem()->x();
const int myY = y() + parentItem()->y();
- static QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData;
- if (pixmapData.count() < d->particles.count())
- pixmapData.resize(d->particles.count());
+ QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData;
+ pixmapData.resize(d->particles.count());
const QRectF sourceRect = d->image.rect();
+ qreal halfPWidth = sourceRect.width()/2.;
+ qreal halfPHeight = sourceRect.height()/2.;
for (int i = 0; i < d->particles.count(); ++i) {
const QmlGraphicsParticle &particle = d->particles.at(i);
- pixmapData[i].point = QPointF(particle.x - myX, particle.y - myY);
+ pixmapData[i].point = QPointF(particle.x - myX + halfPWidth, particle.y - myY + halfPHeight);
pixmapData[i].opacity = particle.opacity;
//these never change
diff --git a/src/declarative/extra/qmlgraphicsparticles_p.h b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
index 9eca762..851edd7 100644
--- a/src/declarative/extra/qmlgraphicsparticles_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
@@ -145,18 +145,19 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsParticles : public QmlGraphicsItem
{
Q_OBJECT
- Q_PROPERTY(QUrl source READ source WRITE setSource)
- Q_PROPERTY(int count READ count WRITE setCount)
- Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan)
- Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation)
- Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration)
- Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle)
- Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation)
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
- Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation)
- Q_PROPERTY(bool streamIn READ streamIn WRITE setStreamIn)
- Q_PROPERTY(bool emitting READ emitting WRITE setEmitting)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
+ Q_PROPERTY(int emissionRate READ emissionRate WRITE setEmissionRate NOTIFY emissionRateChanged)
+ Q_PROPERTY(qreal emissionVariance READ emissionVariance WRITE setEmissionVariance NOTIFY emissionVarianceChanged)
+ Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan NOTIFY lifeSpanChanged)
+ Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation NOTIFY lifeSpanDeviationChanged)
+ Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration NOTIFY fadeInDurationChanged)
+ Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration NOTIFY fadeOutDurationChanged)
+ Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
+ Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation NOTIFY angleDeviationChanged)
+ Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
+ Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation NOTIFY velocityDeviationChanged)
+ Q_PROPERTY(bool emitting READ emitting WRITE setEmitting NOTIFY emittingChanged)
Q_PROPERTY(QmlGraphicsParticleMotion *motion READ motion WRITE setMotion)
Q_CLASSINFO("DefaultProperty", "motion")
@@ -170,6 +171,12 @@ public:
int count() const;
void setCount(int cnt);
+ int emissionRate() const;
+ void setEmissionRate(int);
+
+ qreal emissionVariance() const;
+ void setEmissionVariance(qreal);
+
int lifeSpan() const;
void setLifeSpan(int);
@@ -194,9 +201,6 @@ public:
qreal velocityDeviation() const;
void setVelocityDeviation(qreal);
- bool streamIn() const;
- void setStreamIn(bool);
-
bool emitting() const;
void setEmitting(bool);
@@ -205,10 +209,28 @@ public:
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+public Q_SLOTS:
+ void burst(int count, int emissionRate=-1);
+
protected:
virtual void componentComplete();
QmlGraphicsParticles(QmlGraphicsParticlesPrivate &dd, QmlGraphicsItem *parent);
+Q_SIGNALS:
+ void sourceChanged();
+ void countChanged();
+ void emissionRateChanged();
+ void emissionVarianceChanged();
+ void lifeSpanChanged();
+ void lifeSpanDeviationChanged();
+ void fadeInDurationChanged();
+ void fadeOutDurationChanged();
+ void angleChanged();
+ void angleDeviationChanged();
+ void velocityChanged();
+ void velocityDeviationChanged();
+ void emittingChanged();
+
private Q_SLOTS:
void imageLoaded();
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
index d6f1fb9..3b975ba 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
@@ -209,7 +209,12 @@ void QmlGraphicsBasePositioner::prePositioning()
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
QSet<QmlGraphicsItem *> allItems;
+ //Need to order children by creation order modified by stacking order
+ //###can we avoid using the QGraphicsItemPrivate?
QList<QGraphicsItem *> children = childItems();
+ qSort(children.begin(), children.end(), d->insertionOrder);
+ positionedItems = QList<QmlGraphicsItem*>();
+
for (int ii = 0; ii < children.count(); ++ii) {
QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(ii));
if (!child)
@@ -234,6 +239,7 @@ void QmlGraphicsBasePositioner::prePositioning()
d->_newItems+=child;
}
allItems += child;
+ positionedItems << child;
}
QSet<QmlGraphicsItem *> deletedItems = d->_items - allItems;
foreach(QmlGraphicsItem *child, d->_items){
@@ -497,9 +503,9 @@ void QmlGraphicsColumn::doPositioning()
}
}
- QList<QGraphicsItem *> children = childItems();
+ QList<QmlGraphicsItem *> children = positionedItems;
for (int ii = 0; ii < children.count(); ++ii) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(ii));
+ QmlGraphicsItem *child = children.at(ii);
if (!child || isInvisible(child))
continue;
@@ -653,9 +659,9 @@ void QmlGraphicsRow::doPositioning()
applyRemove(changes, item);
}
}
- QList<QGraphicsItem *> children = childItems();
+ QList<QmlGraphicsItem *> children = positionedItems;
for (int ii = 0; ii < children.count(); ++ii) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(ii));
+ QmlGraphicsItem *child = children.at(ii);
if (!child || isInvisible(child))
continue;
@@ -859,7 +865,7 @@ void QmlGraphicsGrid::doPositioning()
QList<int> maxColWidth;
QList<int> maxRowHeight;
int childIndex =0;
- QList<QGraphicsItem *> children = childItems();
+ QList<QmlGraphicsItem *> children = positionedItems;
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
if (j==0)
@@ -869,7 +875,7 @@ void QmlGraphicsGrid::doPositioning()
if (childIndex == children.count())
continue;
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(childIndex++));
+ QmlGraphicsItem *child = children.at(childIndex++);
if (!child || isInvisible(child))
continue;
if (child->width() > maxColWidth[j])
@@ -889,8 +895,7 @@ void QmlGraphicsGrid::doPositioning()
applyRemove(changes, item);
}
}
- foreach(QGraphicsItem* schild, children){
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(schild);
+ foreach(QmlGraphicsItem* child, children){
if (!child || isInvisible(child))
continue;
bool needMove = (child->x()!=xoffset)||(child->y()!=yoffset);
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
index 0011ec5..56adc8b 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
@@ -104,6 +104,7 @@ private Q_SLOTS:
protected:
QmlGraphicsBasePositioner(QmlGraphicsBasePositionerPrivate &dd, AutoUpdateType at, QmlGraphicsItem *parent);
void setMovingItem(QmlGraphicsItem *);
+ QList<QmlGraphicsItem *> positionedItems;
private:
void applyTransition(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target,
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
index 4ac208c..5ce0ee8 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -362,7 +362,7 @@ void QmlGraphicsWebView::pageUrlChanged()
expandToWebPage();
if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank")))
- || d->url != page()->mainFrame()->url())
+ || d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty())
{
d->url = page()->mainFrame()->url();
if (d->url == QUrl(QLatin1String("about:blank")))
diff --git a/src/declarative/qml/qmlboundsignal.cpp b/src/declarative/qml/qmlboundsignal.cpp
index def11c3..deb15dc 100644
--- a/src/declarative/qml/qmlboundsignal.cpp
+++ b/src/declarative/qml/qmlboundsignal.cpp
@@ -177,7 +177,7 @@ int QmlBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
if (m_params) m_params->setValues(a);
if (m_expression) {
QmlExpressionPrivate::get(m_expression)->value(m_params);
- if (m_expression->hasError())
+ if (m_expression && m_expression->hasError())
qWarning().nospace() << qPrintable(m_expression->error().toString());
}
if (m_params) m_params->clearValues();
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 240f16c..8e92eb4 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1714,7 +1714,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
prop->value, obj, ctxt.incr()));
obj->addValueTypeProperty(prop);
} else {
- COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property access"));
+ COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid grouped property access"));
}
} else {
@@ -1722,7 +1722,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
prop->value->metatype =
QmlEnginePrivate::get(engine)->metaObjectForType(prop->type);
if (!prop->value->metatype)
- COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Cannot nest non-QObject property \"%1\"").arg(QString::fromUtf8(prop->name)));
+ COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid grouped property access"));
obj->addGroupedProperty(prop);
@@ -1749,8 +1749,11 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type,
prop->index = idx;
prop->type = p.userType();
- if (prop->value || prop->values.count() != 1)
- COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property use"));
+ if (prop->value)
+ COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Property assignment expected"));
+
+ if (prop->values.count() != 1)
+ COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Single property assignment expected"));
Value *value = prop->values.at(0);
@@ -1758,7 +1761,7 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type,
bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1;
bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1;
if (!isPropertyValue && !isPropertyInterceptor) {
- COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property use"));
+ COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Unexpected object assignment"));
} else {
COMPILE_CHECK(buildObject(value->object, ctxt));
diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h
index 7f9be0f..22d981f 100644
--- a/src/declarative/qml/qmlcontext_p.h
+++ b/src/declarative/qml/qmlcontext_p.h
@@ -74,7 +74,7 @@ class QmlExpressionPrivate;
class QmlAbstractExpression;
class QmlBinding_Id;
-class QmlContextPrivate : public QObjectPrivate
+class Q_DECLARATIVE_EXPORT QmlContextPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlContext)
public:
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index b6e794b..39d6730 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -52,8 +52,6 @@
QT_BEGIN_NAMESPACE
-DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP)
-
QmlDomDocumentPrivate::QmlDomDocumentPrivate()
: root(0)
{
@@ -191,11 +189,6 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
}
if (td->data.tree()) {
- if (compilerDump()) {
- qWarning() << "-AST------------------------------------------------------------------------------";
- td->data.tree()->dump();
- qWarning() << "----------------------------------------------------------------------------------";
- }
d->root = td->data.tree();
d->root->addref();
}
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 3df04b2..177818f 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -626,6 +626,11 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
url = QUrl(ctxt->argument(2).toString());
QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1));
QmlContext *qmlCtxt = qmlContext(parentArg);
+ if(!parentArg || !qmlCtxt){
+ //TODO: Could use a qmlInfo() like function for script functions
+ qWarning() << "createQmlObject called with invalid parent object";
+ return engine->nullValue();
+ }
if (url.isEmpty()) {
url = qmlCtxt->resolvedUrl(QUrl(QLatin1String("<Unknown File>")));
} else {
@@ -903,7 +908,7 @@ QVariant QmlEnginePrivate::scriptValueToVariant(const QScriptValue &val)
else if (dc == contextClass)
return QVariant();
- QScriptClass *sc = val.scriptClass();
+ QScriptDeclarativeClass *sc = QScriptDeclarativeClass::scriptClass(val);
if (!sc) {
return val.toVariant();
} else if (sc == valueTypeClass) {
@@ -924,20 +929,7 @@ QVariant QmlScriptClass::toVariant(QmlEngine *engine, const QScriptValue &val)
QmlEnginePrivate *ep =
static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine));
- QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(val);
- if (dc == ep->objectClass)
- return QVariant::fromValue(ep->objectClass->toQObject(val));
- else if (dc == ep->contextClass)
- return QVariant();
-
- QScriptClass *sc = val.scriptClass();
- if (!sc) {
- return val.toVariant();
- } else if (sc == ep->valueTypeClass) {
- return ep->valueTypeClass->toVariant(val);
- }
-
- return QVariant();
+ return ep->scriptValueToVariant(val);
}
// XXX this beyonds in QUrl::toLocalFile()
diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp
index c0d9eca..f62f5fd 100644
--- a/src/declarative/qml/qmlinfo.cpp
+++ b/src/declarative/qml/qmlinfo.cpp
@@ -80,18 +80,18 @@ void qmlInfo(const QString& msg, QObject* object)
pos += QLatin1Char(' ');
pos += QLatin1String(object->metaObject()->className());
}
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(object);
+ QmlDeclarativeData *ddata = object?QmlDeclarativeData::get(object):0;
pos += QLatin1String(" (");
if (ddata) {
if (ddata->outerContext) {
pos += ddata->outerContext->baseUrl().toString();
+ pos += QLatin1String(":");
+ pos += QString::number(ddata->lineNumber);
+ pos += QLatin1String(":");
+ pos += QString::number(ddata->columnNumber);
} else {
- pos += qApp->translate("QmlInfo","unknown");
+ pos += qApp->translate("QmlInfo","unknown location");
}
- pos += QLatin1String(":");
- pos += QString::number(ddata->lineNumber);
- pos += QLatin1String(":");
- pos += QString::number(ddata->columnNumber);
} else {
pos += qApp->translate("QmlInfo","unknown location");
}
diff --git a/src/declarative/qml/qmlintegercache.cpp b/src/declarative/qml/qmlintegercache.cpp
index b20b6eb..d1927b3 100644
--- a/src/declarative/qml/qmlintegercache.cpp
+++ b/src/declarative/qml/qmlintegercache.cpp
@@ -82,33 +82,4 @@ int QmlIntegerCache::value(const QString &id)
return d?d->value:-1;
}
-QmlIntegerCache *QmlIntegerCache::createForEnums(QmlType *type, QmlEngine *engine)
-{
- Q_ASSERT(type);
- Q_ASSERT(engine);
-
- QmlIntegerCache *cache = new QmlIntegerCache(engine);
-
- const QMetaObject *mo = type->metaObject();
-
- for (int ii = mo->enumeratorCount() - 1; ii >= 0; --ii) {
- QMetaEnum enumerator = mo->enumerator(ii);
-
- for (int jj = 0; jj < enumerator.keyCount(); ++jj) {
- QString name = QString::fromUtf8(enumerator.key(jj));
- int value = enumerator.value(jj);
-
- if (!name.at(0).isUpper())
- continue;
-
- if (cache->stringCache.contains(name))
- continue;
-
- cache->add(name, value);
- }
- }
-
- return cache;
-}
-
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlintegercache_p.h b/src/declarative/qml/qmlintegercache_p.h
index 7816004..2b10dcc 100644
--- a/src/declarative/qml/qmlintegercache_p.h
+++ b/src/declarative/qml/qmlintegercache_p.h
@@ -73,8 +73,6 @@ public:
int value(const QString &);
inline int value(const QScriptDeclarativeClass::Identifier &id) const;
- static QmlIntegerCache *createForEnums(QmlType *, QmlEngine *);
-
protected:
virtual void clear();
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index 6ecaa9f..5fb2f50 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -134,7 +134,6 @@ public:
QmlCustomParser *m_customParser;
mutable volatile bool m_isSetup:1;
mutable QList<QmlProxyMetaObject::ProxyData> m_metaObjects;
- mutable QByteArray m_hash;
};
QmlTypePrivate::QmlTypePrivate()
@@ -259,27 +258,6 @@ void QmlTypePrivate::init() const
m_metaObjects.at(ii).metaObject->methodOffset();
}
- // Calculate hash
- QByteArray hashData;
-
- const QMetaObject *myMetaObject = m_metaObjects.isEmpty()?m_baseMetaObject:m_metaObjects.first().metaObject;
-
- for (int ii = 0; ii < myMetaObject->propertyCount(); ++ii) {
- QMetaProperty prop = myMetaObject->property(ii);
- hashData.append(prop.type());
- hashData.append("|");
- hashData.append(prop.name());
- hashData.append("|");
- }
-
- for (int ii = 0; ii < myMetaObject->methodCount(); ++ii) {
- QMetaMethod method = myMetaObject->method(ii);
- hashData.append(method.signature());
- hashData.append("|");
- }
-
- m_hash = QCryptographicHash::hash(hashData, QCryptographicHash::Md5);
-
m_isSetup = true;
lock.unlock();
}
@@ -297,13 +275,6 @@ QByteArray QmlType::qmlTypeName() const
return d->m_name;
}
-QByteArray QmlType::hash() const
-{
- d->init();
-
- return d->m_hash;
-}
-
QObject *QmlType::create() const
{
d->init();
@@ -804,17 +775,6 @@ const char *QmlMetaType::interfaceIId(int userType)
return 0;
}
-bool QmlMetaType::isObject(const QMetaObject *mo)
-{
- // ### Huh?
- while(mo) {
- if (mo == &QObject::staticMetaObject)
- return true;
- mo = mo->superClass();
- }
- return false;
-}
-
bool QmlMetaType::isQmlList(int userType)
{
QReadLocker lock(metaTypeDataLock());
@@ -851,6 +811,9 @@ int QmlMetaType::listCount(const QVariant &v)
QVariant QmlMetaType::listAt(const QVariant &v, int idx)
{
+ if (idx < 0)
+ return QVariant();
+
int userType = v.userType();
QReadLocker lock(metaTypeDataLock());
@@ -861,7 +824,7 @@ QVariant QmlMetaType::listAt(const QVariant &v, int idx)
if (type && type->qListTypeId() == userType)
return type->listAt(v, idx);
else
- return 0;
+ return QVariant();
}
/*!
diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h
index e90c367..1f493f8 100644
--- a/src/declarative/qml/qmlmetatype.h
+++ b/src/declarative/qml/qmlmetatype.h
@@ -97,7 +97,6 @@ public:
static bool isInterface(int);
static const char *interfaceIId(int);
static bool isObject(int);
- static bool isObject(const QMetaObject *);
static bool isList(int);
static bool isList(const QVariant &);
static bool isQmlList(int);
@@ -121,8 +120,6 @@ public:
int minorVersion() const;
bool availableInVersion(int vmajor, int vminor) const;
- QByteArray hash() const;
-
QObject *create() const;
QmlCustomParser *customParser() const;
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp
index 7fd57f3..ee69b14 100644
--- a/src/declarative/qml/qmlparser.cpp
+++ b/src/declarative/qml/qmlparser.cpp
@@ -200,28 +200,6 @@ QmlParser::Object::DynamicSlot::DynamicSlot(const DynamicSlot &o)
{
}
-void QmlParser::Object::dump(int indent) const
-{
- QByteArray ba(indent * 4, ' ');
- if (type != -1) {
- qWarning() << ba.constData() << "Object:" << typeName;
- } else {
- qWarning() << ba.constData() << "Object: fetched";
- }
-
- for (QHash<QByteArray, Property *>::ConstIterator iter = properties.begin();
- iter != properties.end();
- ++iter) {
- qWarning() << ba.constData() << " Property" << iter.key();
- (*iter)->dump(indent + 1);
- }
-
- if (defaultProperty) {
- qWarning() << ba.constData() << " Default property";
- defaultProperty->dump(indent + 1);
- }
-}
-
QmlParser::Property::Property()
: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false)
{
@@ -256,15 +234,6 @@ bool QmlParser::Property::isEmpty() const
return !value && values.isEmpty();
}
-void QmlParser::Property::dump(int indent) const
-{
- QByteArray ba(indent * 4, ' ');
- for (int ii = 0; ii < values.count(); ++ii)
- values.at(ii)->dump(indent);
- if (value)
- value->dump(indent);
-}
-
QmlParser::Value::Value()
: type(Unknown), object(0)
{
@@ -275,69 +244,6 @@ QmlParser::Value::~Value()
if (object) object->release();
}
-void QmlParser::Value::dump(int indent) const
-{
- QByteArray type;
- switch(this->type) {
- default:
- case Value::Unknown:
- type = "Unknown";
- break;
- case Value::Literal:
- type = "Literal";
- break;
- case Value::PropertyBinding:
- type = "PropertyBinding";
- break;
- case Value::ValueSource:
- type = "ValueSource";
- break;
- case Value::ValueInterceptor:
- type = "ValueInterceptor";
- break;
- case Value::CreatedObject:
- type = "CreatedObject";
- break;
- case Value::SignalObject:
- type = "SignalObject";
- break;
- case Value::SignalExpression:
- type = "SignalExpression";
- break;
- case Value::Id:
- type = "Id";
- break;
- }
-
- QByteArray primType;
- switch(this->value.type()) {
- default:
- case Variant::Invalid:
- primType = "Invalid";
- break;
- case Variant::Boolean:
- primType = "Boolean";
- break;
- case Variant::Number:
- primType = "Number";
- break;
- case Variant::String:
- primType = "String";
- break;
- case Variant::Script:
- primType = "Script";
- break;
- }
-
- QByteArray ba(indent * 4, ' ');
- if (object) {
- qWarning() << ba.constData() << "Value (" << type << "):";
- object->dump(indent + 1);
- } else {
- qWarning() << ba.constData() << "Value (" << type << "):" << primType.constData() << primitive();
- }
-}
-
QmlParser::Variant::Variant()
: t(Invalid) {}
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
index 5bffff2..4f080e5 100644
--- a/src/declarative/qml/qmlparser_p.h
+++ b/src/declarative/qml/qmlparser_p.h
@@ -216,8 +216,6 @@ namespace QmlParser
QList<DynamicSignal> dynamicSignals;
// The list of dynamic slots
QList<DynamicSlot> dynamicSlots;
-
- void dump(int = 0) const;
};
class Variant
@@ -299,8 +297,6 @@ namespace QmlParser
Object *object;
LocationSpan location;
-
- void dump(int = 0) const;
};
class Property : public QmlRefCount
@@ -342,8 +338,6 @@ namespace QmlParser
LocationSpan location;
LocationRange listValueRange;
QList<int> listCommaPositions;
-
- void dump(int = 0) const;
};
}
diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h
index e5b1060..0eec43c 100644
--- a/src/declarative/qml/qmlprivate.h
+++ b/src/declarative/qml/qmlprivate.h
@@ -283,7 +283,8 @@ int QmlPrivate::list_op(QmlPrivate::ListOp op, int val,
}
break;
case QmlPrivate::Value:
- *((QVariant *)*out) = QVariant::fromValue(list->at(val));
+ if (list->count() <= val) *((QVariant *)*out) = QVariant();
+ else *((QVariant *)*out) = QVariant::fromValue(list->at(val));
break;
}
return 0;
diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h
index 0af3813..e7566f9 100644
--- a/src/declarative/qml/qmlvaluetype_p.h
+++ b/src/declarative/qml/qmlvaluetype_p.h
@@ -62,7 +62,7 @@
QT_BEGIN_NAMESPACE
-class QmlValueType : public QObject
+class Q_AUTOTEST_EXPORT QmlValueType : public QObject
{
Q_OBJECT
public:
@@ -73,7 +73,7 @@ public:
virtual void setValue(QVariant) = 0;
};
-class QmlValueTypeFactory
+class Q_AUTOTEST_EXPORT QmlValueTypeFactory
{
public:
QmlValueTypeFactory();
@@ -84,7 +84,7 @@ public:
QmlValueType *operator[](int idx) const { return valueTypes[idx]; }
};
-class QmlPointFValueType : public QmlValueType
+class Q_AUTOTEST_EXPORT QmlPointFValueType : public QmlValueType
{
Q_PROPERTY(qreal x READ x WRITE setX)
Q_PROPERTY(qreal y READ y WRITE setY)
@@ -106,7 +106,7 @@ private:
QPointF point;
};
-class QmlPointValueType : public QmlValueType
+class Q_AUTOTEST_EXPORT QmlPointValueType : public QmlValueType
{
Q_PROPERTY(int x READ x WRITE setX)
Q_PROPERTY(int y READ y WRITE setY)
@@ -128,7 +128,7 @@ private:
QPoint point;
};
-class QmlSizeFValueType : public QmlValueType
+class Q_AUTOTEST_EXPORT QmlSizeFValueType : public QmlValueType
{
Q_PROPERTY(qreal width READ width WRITE setWidth)
Q_PROPERTY(qreal height READ height WRITE setHeight)
@@ -150,7 +150,7 @@ private:
QSizeF size;
};
-class QmlSizeValueType : public QmlValueType
+class Q_AUTOTEST_EXPORT QmlSizeValueType : public QmlValueType
{
Q_PROPERTY(int width READ width WRITE setWidth)
Q_PROPERTY(int height READ height WRITE setHeight)
@@ -172,7 +172,7 @@ private:
QSize size;
};
-class QmlRectFValueType : public QmlValueType
+class Q_AUTOTEST_EXPORT QmlRectFValueType : public QmlValueType
{
Q_PROPERTY(qreal x READ x WRITE setX)
Q_PROPERTY(qreal y READ y WRITE setY)
@@ -201,7 +201,7 @@ private:
QRectF rect;
};
-class QmlRectValueType : public QmlValueType
+class Q_AUTOTEST_EXPORT QmlRectValueType : public QmlValueType
{
Q_PROPERTY(int x READ x WRITE setX)
Q_PROPERTY(int y READ y WRITE setY)
@@ -230,7 +230,7 @@ private:
QRect rect;
};
-class QmlVector3DValueType : public QmlValueType
+class Q_AUTOTEST_EXPORT QmlVector3DValueType : public QmlValueType
{
Q_PROPERTY(qreal x READ x WRITE setX)
Q_PROPERTY(qreal y READ y WRITE setY)
@@ -255,7 +255,7 @@ private:
QVector3D vector;
};
-class QmlFontValueType : public QmlValueType
+class Q_AUTOTEST_EXPORT QmlFontValueType : public QmlValueType
{
Q_OBJECT
Q_ENUMS(FontWeight)
diff --git a/src/declarative/qml/qmlvaluetypescriptclass.cpp b/src/declarative/qml/qmlvaluetypescriptclass.cpp
index 0c30992..e939e80 100644
--- a/src/declarative/qml/qmlvaluetypescriptclass.cpp
+++ b/src/declarative/qml/qmlvaluetypescriptclass.cpp
@@ -44,15 +44,14 @@
QT_BEGIN_NAMESPACE
-struct QmlValueTypeReference {
+struct QmlValueTypeReference : public QScriptDeclarativeClass::Object {
QmlValueType *type;
QGuard<QObject> object;
int property;
};
-Q_DECLARE_METATYPE(QmlValueTypeReference);
QmlValueTypeScriptClass::QmlValueTypeScriptClass(QmlEngine *bindEngine)
-: QScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine)
+: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine)
{
}
@@ -62,89 +61,83 @@ QmlValueTypeScriptClass::~QmlValueTypeScriptClass()
QScriptValue QmlValueTypeScriptClass::newObject(QObject *object, int coreIndex, QmlValueType *type)
{
- QmlValueTypeReference ref = { type, object, coreIndex };
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
- return scriptEngine->newObject(this, scriptEngine->newVariant(qVariantFromValue(ref)));
+ QmlValueTypeReference *ref = new QmlValueTypeReference;
+ ref->type = type;
+ ref->object = object;
+ ref->property = coreIndex;
+ return QScriptDeclarativeClass::newObject(QmlEnginePrivate::getScriptEngine(engine), this, ref);
}
-QmlValueTypeScriptClass::QueryFlags
-QmlValueTypeScriptClass::queryProperty(const QScriptValue &object,
- const QScriptString &name,
- QueryFlags flags, uint *id)
+QScriptClass::QueryFlags
+QmlValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name,
+ QScriptClass::QueryFlags)
{
- Q_UNUSED(flags);
- QmlValueTypeReference ref =
- qvariant_cast<QmlValueTypeReference>(object.data().toVariant());
+ QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj);
- if (!ref.object)
+ m_lastIndex = -1;
+
+ if (!ref->object)
return 0;
- QByteArray propName = name.toString().toUtf8();
+ QByteArray propName = toString(name).toUtf8();
- int idx = ref.type->metaObject()->indexOfProperty(propName.constData());
- if (idx == -1)
+ m_lastIndex = ref->type->metaObject()->indexOfProperty(propName.constData());
+ if (m_lastIndex == -1)
return 0;
- *id = idx;
- QMetaProperty prop = ref.object->metaObject()->property(idx);
+ QMetaProperty prop = ref->object->metaObject()->property(m_lastIndex);
- QmlValueTypeScriptClass::QueryFlags rv =
- QmlValueTypeScriptClass::HandlesReadAccess;
+ QScriptClass::QueryFlags rv =
+ QScriptClass::HandlesReadAccess;
if (prop.isWritable())
- rv |= QmlValueTypeScriptClass::HandlesWriteAccess;
+ rv |= QScriptClass::HandlesWriteAccess;
return rv;
}
-QScriptValue QmlValueTypeScriptClass::property(const QScriptValue &object,
- const QScriptString &name,
- uint id)
+QScriptValue QmlValueTypeScriptClass::property(Object *obj, const Identifier &)
{
- Q_UNUSED(name);
- QmlValueTypeReference ref =
- qvariant_cast<QmlValueTypeReference>(object.data().toVariant());
-
- if (!ref.object)
- return QScriptValue();
+ QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj);
- ref.type->read(ref.object, ref.property);
-
- QMetaProperty p = ref.type->metaObject()->property(id);
- QVariant rv = p.read(ref.type);
+ QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
+ ref->type->read(ref->object, ref->property);
+ QVariant rv = p.read(ref->type);
return static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine))->scriptValueFromVariant(rv);
}
-void QmlValueTypeScriptClass::setProperty(QScriptValue &object,
- const QScriptString &name,
- uint id,
+void QmlValueTypeScriptClass::setProperty(Object *obj, const Identifier &,
const QScriptValue &value)
{
- Q_UNUSED(name);
- QmlValueTypeReference ref =
- qvariant_cast<QmlValueTypeReference>(object.data().toVariant());
-
- if (!ref.object)
- return;
+ QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj);
QVariant v = QmlScriptClass::toVariant(engine, value);
- ref.type->read(ref.object, ref.property);
- QMetaProperty p = ref.type->metaObject()->property(id);
- p.write(ref.type, v);
- ref.type->write(ref.object, ref.property, 0);
+ ref->type->read(ref->object, ref->property);
+ QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
+ p.write(ref->type, v);
+ ref->type->write(ref->object, ref->property, 0);
}
-QVariant QmlValueTypeScriptClass::toVariant(const QScriptValue &val)
+QVariant QmlValueTypeScriptClass::toVariant(Object *obj, bool *ok)
{
- QmlValueTypeReference ref =
- qvariant_cast<QmlValueTypeReference>(val.data().toVariant());
+ QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj);
- if (!ref.object)
+ if (ok) *ok = true;
+
+ if (ref->object) {
+ ref->type->read(ref->object, ref->property);
+ return ref->type->value();
+ } else {
return QVariant();
+ }
+}
+
+QVariant QmlValueTypeScriptClass::toVariant(const QScriptValue &value)
+{
+ Q_ASSERT(scriptClass(value) == this);
- QMetaProperty p = ref.object->metaObject()->property(ref.property);
- return p.read(ref.object);
+ return toVariant(object(value), 0);
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlvaluetypescriptclass_p.h b/src/declarative/qml/qmlvaluetypescriptclass_p.h
index bd31ec1..19020b2 100644
--- a/src/declarative/qml/qmlvaluetypescriptclass_p.h
+++ b/src/declarative/qml/qmlvaluetypescriptclass_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
class QmlEngine;
class QmlValueType;
-class QmlValueTypeScriptClass : public QScriptClass
+class QmlValueTypeScriptClass : public QScriptDeclarativeClass
{
public:
QmlValueTypeScriptClass(QmlEngine *);
@@ -67,20 +67,16 @@ public:
QScriptValue newObject(QObject *object, int coreIndex, QmlValueType *);
- virtual QueryFlags queryProperty(const QScriptValue &object,
- const QScriptString &name,
- QueryFlags flags, uint *id);
- virtual QScriptValue property(const QScriptValue &object,
- const QScriptString &name,
- uint id);
- virtual void setProperty(QScriptValue &object,
- const QScriptString &name,
- uint id,
- const QScriptValue &value);
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
+ QScriptClass::QueryFlags flags);
+ virtual QScriptValue property(Object *, const Identifier &);
+ virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
+ virtual QVariant toVariant(Object *, bool *ok = 0);
QVariant toVariant(const QScriptValue &);
private:
QmlEngine *engine;
+ int m_lastIndex;
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index bd4c6f7..94cdadf 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -422,21 +422,6 @@ void QmlAbstractAnimation::setGroup(QmlAnimationGroup *g)
setParent(g);
}
-/*!
- \qmlproperty Object PropertyAction::target
- This property holds an explicit target object to animate.
-
- The exact effect of the \c target property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
-*/
-
-/*!
- \qmlproperty Object PropertyAnimation::target
- This property holds an explicit target object to animate.
-
- The exact effect of the \c target property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
-*/
QObject *QmlAbstractAnimation::target() const
{
Q_D(const QmlAbstractAnimation);
@@ -459,21 +444,6 @@ void QmlAbstractAnimation::setTarget(QObject *o)
emit targetChanged(d->target, d->propertyName);
}
-/*!
- \qmlproperty string PropertyAction::property
- This property holds an explicit property to animated.
-
- The exact effect of the \c property property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
-*/
-
-/*!
- \qmlproperty string PropertyAnimation::property
- This property holds an explicit property to animated.
-
- The exact effect of the \c property property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
-*/
QString QmlAbstractAnimation::property() const
{
Q_D(const QmlAbstractAnimation);
@@ -880,7 +850,7 @@ QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction)
Set \c thewebview.url to the value set for the destination state:
\code
- PropertyAction { target: thewebview; property: "url" }
+ PropertyAction { matchTargets: thewebview; matchProperties: "url" }
\endcode
The PropertyAction is immediate -
@@ -909,8 +879,33 @@ void QmlPropertyActionPrivate::init()
}
/*!
- \qmlproperty string PropertyAction::properties
- This property holds the properties to be immediately set, comma-separated.
+ \qmlproperty Object PropertyAction::target
+ This property holds an explicit target object to animate.
+
+ The exact effect of the \c target property depends on how the animation
+ is being used. Refer to the \l animation documentation for details.
+*/
+
+/*!
+ \qmlproperty string PropertyAction::property
+ This property holds an explicit property to animated.
+
+ The exact effect of the \c property property depends on how the animation
+ is being used. Refer to the \l animation documentation for details.
+*/
+
+/*!
+ \qmlproperty string PropertyAction::matchProperties
+ This property holds a comma-separated list of property names this action
+ will match against. These names are used in conjunction with matchTargets
+ to create a list of properties that the action will set, assuming those
+ properties have changed.
+
+ This property is typically used for an action appearing as part of a Transition.
+
+ By default, no property names will be matched.
+
+ \sa matchTargets PropertyAnimation::matchProperties
*/
QString QmlPropertyAction::properties() const
{
@@ -928,9 +923,16 @@ void QmlPropertyAction::setProperties(const QString &p)
}
/*!
- \qmlproperty list<Item> PropertyAction::targets
- This property holds the items selected to be affected by this animation (all if not set).
- \sa exclude
+ \qmlproperty list<Object> PropertyAction::matchTargets
+ This property holds a list of objects this action will match against.
+ These objects are used in conjunction with matchProperties to create a list of properties
+ that the action will set, assuming those properties have changed.
+
+ This property is typically used for an action appearing as part of a Transition.
+
+ By default, all changing targets will be matched.
+
+ \sa exclude matchProperties PropertyAnimation::matchTargets
*/
QList<QObject *> *QmlPropertyAction::targets()
{
@@ -939,9 +941,9 @@ QList<QObject *> *QmlPropertyAction::targets()
}
/*!
- \qmlproperty list<Item> PropertyAction::exclude
- This property holds the items not to be affected by this animation.
- \sa targets
+ \qmlproperty list<Object> PropertyAction::exclude
+ This property holds the objects not to be affected by this animation.
+ \sa matchTargets
*/
QList<QObject *> *QmlPropertyAction::exclude()
{
@@ -1014,19 +1016,26 @@ void QmlPropertyAction::transition(QmlStateActions &actions,
QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
for (int ii = 0; ii < props.count(); ++ii)
props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty() && !props.contains(d->propertyName))
- props.append(d->propertyName);
-
- bool targetNeedsReset = false;
- if (d->userProperty.isValid() && props.isEmpty() && !target()) {
- props.append(d->userProperty.value.name());
- d->target = d->userProperty.value.object();
- targetNeedsReset = true;
- }
+
+ bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty();
+ bool hasTarget = !d->propertyName.isEmpty() || d->target;
+
+ if (hasSelectors && hasTarget) {
+ qmlInfo(tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive."), this);
+ return;
+ }
QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction;
- QSet<QObject *> objs;
+ if (hasTarget && d->value.isValid()) {
+ Action myAction;
+ myAction.property = d->createProperty(target(), d->propertyName);
+ if (myAction.property.isValid()) {
+ myAction.toValue = d->value;
+ data->actions << myAction;
+ }
+ }
+
for (int ii = 0; ii < actions.count(); ++ii) {
Action &action = actions[ii];
@@ -1038,9 +1047,7 @@ void QmlPropertyAction::transition(QmlStateActions &actions,
if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) &&
(!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName))) &&
- (!target() || target() == obj || (!same && target() == sObj))) {
- objs.insert(obj);
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) {
Action myAction = action;
if (d->value.isValid())
@@ -1049,18 +1056,20 @@ void QmlPropertyAction::transition(QmlStateActions &actions,
modified << action.property;
data->actions << myAction;
action.fromValue = myAction.toValue;
- }
- }
+ } else if (d->userProperty.isValid() &&
+ !hasSelectors && !hasTarget) {
+ if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) &&
+ (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) {
+ //### same as above. merge
+ Action myAction = action;
- if (d->value.isValid() && target() && !objs.contains(target())) {
- QObject *obj = target();
- for (int jj = 0; jj < props.count(); ++jj) {
- Action myAction;
- myAction.property = d->createProperty(obj, props.at(jj));
- if (!myAction.property.isValid())
- continue;
- myAction.toValue = d->value;
- data->actions << myAction;
+ if (d->value.isValid())
+ myAction.toValue = d->value;
+
+ modified << action.property;
+ data->actions << myAction;
+ action.fromValue = myAction.toValue;
+ }
}
}
@@ -1069,8 +1078,6 @@ void QmlPropertyAction::transition(QmlStateActions &actions,
} else {
delete data;
}
- if (targetNeedsReset)
- d->target = 0;
}
QML_DEFINE_TYPE(Qt,4,6,PropertyAction,QmlPropertyAction)
@@ -1222,7 +1229,7 @@ QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction)
Animate a set of properties over 200ms, from their values in the start state to
their values in the end state of the transition:
\code
- NumberAnimation { properties: "x,y,scale"; duration: 200 }
+ NumberAnimation { matchProperties: "x,y,scale"; duration: 200 }
\endcode
*/
@@ -1500,6 +1507,8 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
\code
VariantAnimation { property: "size"; to: "20x20"; duration: 200 }
\endcode
+
+ \a qmlanimation.html
*/
QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent)
@@ -1785,11 +1794,53 @@ void QmlPropertyAnimation::setEasing(const QString &e)
}
/*!
- \qmlproperty string PropertyAnimation::properties
- This property holds the properties this animation should be applied to.
+ \qmlproperty Object PropertyAnimation::target
+ This property holds an explicit target object to animate.
+
+ target is used in conjunction with property to determine
+ what property should be animated.
+
+ \sa property matchTargets
+*/
+
+/*!
+ \qmlproperty string PropertyAnimation::property
+ This property holds an explicit property name to animate.
+
+ property is used in conjunction with target to determine
+ what property should be animated.
+
+ \sa target matchProperties
+*/
+
+/*!
+ \qmlproperty string PropertyAnimation::matchProperties
+ This property holds a comma-separated list of property names this animation
+ will match against. These names are used in conjunction with matchTargets
+ to create a list of properties that the animation will animate, assuming those
+ properties have changed.
+
+ In the following example, the change in 'x' will be animated by the transition, while
+ the change in 'y' will not.
+ \qml
+ State {
+ PropertyChanges {
+ target: myItem
+ x: 15; y: 15
+ }
+ }
+ Transition {
+ PropertyAnimation {
+ matchProperties: "x"
+ }
+ }
+ \endqml
+
+ This property is typically used for an animation appearing as part of a Transition.
+
+ By default, no property names will be matched.
- This is a comma-separated list of properties that should use
- this animation when they change.
+ \sa matchTargets PropertyAction::matchTargets
*/
QString QmlPropertyAnimation::properties() const
{
@@ -1808,9 +1859,37 @@ void QmlPropertyAnimation::setProperties(const QString &prop)
}
/*!
- \qmlproperty list<Item> PropertyAnimation::targets
- This property holds the items selected to be affected by this animation (all if not set).
- \sa exclude
+ \qmlproperty list<Object> PropertyAnimation::matchTargets
+ This property holds a list of objects this animation will match against.
+ These objects are used in conjunction with matchProperties to create a list of properties
+ that the animation will animate, assuming those properties have changed.
+
+ In the following example, the changes to \c myItem will be animated by the transition, while
+ the changes to \c myOtherItem will not.
+ \qml
+ State {
+ PropertyChanges {
+ target: myItem
+ x: 15; y: 15
+ }
+ PropertyChanges {
+ target: myOtherItem
+ x: 30; y: 30
+ }
+ }
+ Transition {
+ PropertyAnimation {
+ matchTargets: myItem
+ matchProperties: "x,y"
+ }
+ }
+ \endqml
+
+ This property is typically used for an animation appearing as part of a Transition.
+
+ By default, all changing targets will be matched.
+
+ \sa exclude matchProperties
*/
QList<QObject *> *QmlPropertyAnimation::targets()
{
@@ -1819,9 +1898,9 @@ QList<QObject *> *QmlPropertyAnimation::targets()
}
/*!
- \qmlproperty list<Item> PropertyAnimation::exclude
+ \qmlproperty list<Object> PropertyAnimation::exclude
This property holds the items not to be affected by this animation.
- \sa targets
+ \sa matchTargets
*/
QList<QObject *> *QmlPropertyAnimation::exclude()
{
@@ -1933,24 +2012,37 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
for (int ii = 0; ii < props.count(); ++ii)
props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty() && !props.contains(d->propertyName))
- props.append(d->propertyName);
- bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+ bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty();
+ bool hasTarget = !d->propertyName.isEmpty() || d->target;
- bool targetNeedsReset = false;
- if (d->userProperty.isValid() && props.isEmpty() && !target()) {
- props.append(d->userProperty.value.name());
- d->target = d->userProperty.value.object();
- targetNeedsReset = true;
+ if (hasSelectors && hasTarget) {
+ qmlInfo(tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive."), this);
+ return;
}
+ bool useType = (props.isEmpty() && d->propertyName.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+
PropertyUpdater *data = new PropertyUpdater;
data->interpolatorType = d->interpolatorType;
data->interpolator = d->interpolator;
data->reverse = direction == Backward ? true : false;
- QSet<QObject *> objs;
+ //an explicit animation has been specified
+ if (hasTarget && d->toIsDefined) {
+ Action myAction;
+ myAction.property = d->createProperty(target(), d->propertyName);
+ if (myAction.property.isValid()) {
+ if (d->fromIsDefined) {
+ d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ myAction.fromValue = d->from;
+ }
+ d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ myAction.toValue = d->to;
+ data->actions << myAction;
+ }
+ }
+
for (int ii = 0; ii < actions.count(); ++ii) {
Action &action = actions[ii];
@@ -1963,16 +2055,13 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) &&
(!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
(props.contains(propertyName) || (!same && props.contains(sPropertyName))
- || (useType && action.property.propertyType() == d->interpolatorType)) &&
- (!target() || target() == obj || (!same && target() == sObj))) {
- objs.insert(obj);
+ || (useType && action.property.propertyType() == d->interpolatorType))) {
Action myAction = action;
- if (d->fromIsDefined) {
+ if (d->fromIsDefined)
myAction.fromValue = d->from;
- } else {
+ else
myAction.fromValue = QVariant();
- }
if (d->toIsDefined)
myAction.toValue = d->to;
@@ -1983,25 +2072,29 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
data->actions << myAction;
action.fromValue = myAction.toValue;
- }
- }
-
- if (d->toIsDefined && target() && !objs.contains(target())) {
- QObject *obj = target();
- for (int jj = 0; jj < props.count(); ++jj) {
- Action myAction;
- myAction.property = d->createProperty(obj, props.at(jj));
- if (!myAction.property.isValid())
- continue;
-
- if (d->fromIsDefined) {
- d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- myAction.fromValue = d->from;
- }
- d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- myAction.toValue = d->to;
- data->actions << myAction;
- }
+ } else if (d->userProperty.isValid() &&
+ !hasSelectors && !hasTarget) {
+ if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) &&
+ (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) {
+ //### same as above. merge
+ Action myAction = action;
+
+ if (d->fromIsDefined)
+ myAction.fromValue = d->from;
+ else
+ myAction.fromValue = QVariant();
+ if (d->toIsDefined)
+ myAction.toValue = d->to;
+
+ d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+
+ modified << action.property;
+
+ data->actions << myAction;
+ action.fromValue = myAction.toValue;
+ }
+ }
}
if (data->actions.count()) {
@@ -2009,8 +2102,6 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
} else {
delete data;
}
- if (targetNeedsReset)
- d->target = 0;
}
QML_DEFINE_TYPE(Qt,4,6,PropertyAnimation,QmlPropertyAnimation)
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 214bab9..3a9839e 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -191,8 +191,8 @@ class QmlPropertyAction : public QmlAbstractAnimation
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* targets READ targets)
+ Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QList<QObject *>* matchTargets READ targets)
Q_PROPERTY(QList<QObject *>* exclude READ exclude)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
@@ -260,8 +260,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation
Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged)
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* targets READ targets)
+ Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QList<QObject *>* matchTargets READ targets)
Q_PROPERTY(QList<QObject *>* exclude READ exclude)
public:
diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp
index dbf2bc4..3aa3678 100644
--- a/src/declarative/util/qmlpropertychanges.cpp
+++ b/src/declarative/util/qmlpropertychanges.cpp
@@ -232,7 +232,7 @@ void QmlPropertyChangesPrivate::decode()
ds >> data;
QmlMetaProperty prop = property(name); //### better way to check for signal property?
- if (prop.type() == QmlMetaProperty::SignalProperty) {
+ if (prop.type() & QmlMetaProperty::SignalProperty) {
QmlExpression *expression = new QmlExpression(qmlContext(q), data.toString(), object);
expression->setTrackChange(false);
QmlReplaceSignalHandler *handler = new QmlReplaceSignalHandler;
@@ -307,7 +307,7 @@ QmlPropertyChangesPrivate::property(const QByteArray &property)
if (!prop.isValid()) {
qmlInfo(QmlPropertyChanges::tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(property)), q);
return QmlMetaProperty();
- } else if (!prop.isWritable()) {
+ } else if (!(prop.type() & QmlMetaProperty::SignalProperty) && !prop.isWritable()) {
qmlInfo(QmlPropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property)), q);
return QmlMetaProperty();
}
diff --git a/src/declarative/util/qmlsystempalette.cpp b/src/declarative/util/qmlsystempalette.cpp
index bb3ec70..4ddc82d 100644
--- a/src/declarative/util/qmlsystempalette.cpp
+++ b/src/declarative/util/qmlsystempalette.cpp
@@ -256,39 +256,23 @@ QColor QmlSystemPalette::highlightedText() const
}
/*!
- \qmlproperty color SystemPalette::lighter
-*/
-QColor QmlSystemPalette::lighter(const QColor& color) const
-{
- return color.lighter();
-}
-
-/*!
- \qmlproperty color SystemPalette::darker
-*/
-QColor QmlSystemPalette::darker(const QColor& color) const
-{
- return color.darker();
-}
-
-/*!
- \qmlproperty QPalette::ColorGroup SystemPalette::colorGroup
+ \qmlproperty QmlSystemPalette::ColorGroup SystemPalette::colorGroup
The color group of the palette. It can be Active, Inactive or Disabled.
Active is the default.
\sa QPalette::ColorGroup
*/
-QPalette::ColorGroup QmlSystemPalette::colorGroup() const
+QmlSystemPalette::ColorGroup QmlSystemPalette::colorGroup() const
{
Q_D(const QmlSystemPalette);
- return d->group;
+ return (QmlSystemPalette::ColorGroup)d->group;
}
-void QmlSystemPalette::setColorGroup(QPalette::ColorGroup colorGroup)
+void QmlSystemPalette::setColorGroup(QmlSystemPalette::ColorGroup colorGroup)
{
Q_D(QmlSystemPalette);
- d->group = colorGroup;
+ d->group = (QPalette::ColorGroup)colorGroup;
emit paletteChanged();
}
diff --git a/src/declarative/util/qmlsystempalette_p.h b/src/declarative/util/qmlsystempalette_p.h
index e87534e..6abbfe0 100644
--- a/src/declarative/util/qmlsystempalette_p.h
+++ b/src/declarative/util/qmlsystempalette_p.h
@@ -56,9 +56,10 @@ class QmlSystemPalettePrivate;
class Q_DECLARATIVE_EXPORT QmlSystemPalette : public QObject
{
Q_OBJECT
+ Q_ENUMS(ColorGroup)
Q_DECLARE_PRIVATE(QmlSystemPalette)
- Q_PROPERTY(QPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
+ Q_PROPERTY(QmlSystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
@@ -78,6 +79,8 @@ public:
QmlSystemPalette(QObject *parent=0);
~QmlSystemPalette();
+ enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled };
+
QColor window() const;
QColor windowText() const;
@@ -97,12 +100,8 @@ public:
QColor highlight() const;
QColor highlightedText() const;
- QPalette::ColorGroup colorGroup() const;
- void setColorGroup(QPalette::ColorGroup);
-
- // FIXME: Move to utility class?
- Q_INVOKABLE QColor lighter(const QColor&) const;
- Q_INVOKABLE QColor darker(const QColor&) const;
+ QmlSystemPalette::ColorGroup colorGroup() const;
+ void setColorGroup(QmlSystemPalette::ColorGroup);
Q_SIGNALS:
void paletteChanged();
diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp
index 0aa0747..8ee9059 100644
--- a/src/declarative/util/qmltimer.cpp
+++ b/src/declarative/util/qmltimer.cpp
@@ -176,6 +176,11 @@ void QmlTimer::setRepeating(bool repeating)
/*!
\qmlproperty bool Timer::triggeredOnStart
+ When the Timer is started the first trigger is normally after the specified
+ interval has elapsed. It is sometimes desireable to trigger immediately
+ when the timer is started, for example to establish an initial
+ state.
+
If \a triggeredOnStart is true, the timer will be triggered immediately
when started, and subsequently at the specified interval. Note that for
a Timer with \e repeat set to false, this will result in the timer being
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 9fd9ce9..fe7f5d7 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -2926,10 +2926,10 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
}
// Draw arrow
p->save();
- p->setPen(option->palette.dark());
+ p->setPen(option->palette.dark().color());
p->drawLine(menuarea.left(), menuarea.top() + 3,
menuarea.left(), menuarea.bottom() - 3);
- p->setPen(option->palette.light());
+ p->setPen(option->palette.light().color());
p->drawLine(menuarea.left() - 1, menuarea.top() + 3,
menuarea.left() - 1, menuarea.bottom() - 3);