summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/QmlChanges.txt2
-rw-r--r--src/declarative/extra/extra.pri2
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp98
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp46
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp17
-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/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/qml/qmlengine.cpp5
-rw-r--r--src/declarative/qml/qmlmetatype.cpp45
-rw-r--r--src/declarative/qml/qmlmetatype.h3
-rw-r--r--src/declarative/qml/qmlprivate.h3
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h20
-rw-r--r--src/declarative/util/qmlsystempalette.cpp26
-rw-r--r--src/declarative/util/qmlsystempalette_p.h13
20 files changed, 455 insertions, 304 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 465ee9e..c85ef77 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -82,6 +82,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 +93,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/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index c7332f9..b030495 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()
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 9f9b336..7427266 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);
}
}
}
@@ -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/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index fd8b8b0..1f5d51d 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -662,19 +662,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)
@@ -815,8 +812,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 +828,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();
}
}
}
@@ -1462,6 +1461,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);
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/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/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 3df04b2..e46205d 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 {
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/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/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();