summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/elements.qdoc1
-rw-r--r--src/declarative/fx/qfxflickable.cpp8
-rw-r--r--src/declarative/fx/qfxtransform.cpp133
-rw-r--r--src/declarative/fx/qfxtransform.h43
-rw-r--r--src/declarative/qml/qmldom.cpp10
-rw-r--r--src/declarative/qml/qmldom.h2
-rw-r--r--src/declarative/qml/qmlengine.cpp12
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp11
-rw-r--r--src/declarative/qml/qmlscriptparser_p.h4
-rw-r--r--src/declarative/util/qmlanimation.cpp39
-rw-r--r--src/declarative/util/qmlanimation.h1
-rw-r--r--src/declarative/util/qmlanimation_p.h4
-rw-r--r--src/declarative/util/qmllistmodel.cpp70
-rw-r--r--src/declarative/util/qmllistmodel.h28
-rw-r--r--src/declarative/util/qmltransition.cpp1
15 files changed, 265 insertions, 102 deletions
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 63566f6..eda9079 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -139,6 +139,7 @@ The following table lists the Qml elements provided by the Qt Declarative module
\o
\list
+\o \l Scale
\o \l Rotation
\o \l Squish
\o \l Rotation3D
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 3580edb..a82385a 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -597,7 +597,13 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
int dx = int(event->pos().x() - pressPos.x());
if (qAbs(dx) > FlickThreshold || pressTime.elapsed() > 200) {
qreal newX = dx + pressX;
- if (q->overShoot() || (newX <= q->minXExtent() && newX >= q->maxXExtent())) {
+ const qreal minX = q->minXExtent();
+ const qreal maxX = q->maxXExtent();
+ if (newX > minX)
+ newX = minX + (newX - minX) / 2;
+ if (newX < maxX && maxX - minX < 0)
+ newX = maxX + (newX - maxX) / 2;
+ if (q->overShoot() || (newX <= minX && newX >= maxX)) {
if (dragMode == QFxFlickable::Hard)
_moveX.setValue(newX);
else
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index 2c4f842..0f0ce80 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -84,6 +84,139 @@ void QFxTransform::update()
}
/*!
+ \qmlclass Scale
+ \brief A Scale object provides a way to scale an Item.
+
+ The scale object gives more control over scaling than using Item's scale property. Specifically,
+ it allows a different scale for the x and y axes, and allows the scale to be relative to an
+ arbitrary point.
+
+ The following example scales the X axis of the Rect, relative to its interior point 25, 25:
+ \qml
+ Rect {
+ width: 100; height: 100
+ color: "blue"
+ transform: Scale { originX: 25; originY: 25; xScale: 3}
+ }
+ \endqml
+*/
+
+QFxScale::QFxScale(QObject *parent)
+: QFxTransform(parent), _originX(0), _originY(0), _xScale(1), _yScale(1), _dirty(true)
+{
+}
+
+QFxScale::~QFxScale()
+{
+}
+
+/*!
+ \qmlproperty real Scale::originX
+ \qmlproperty real Scale::originY
+
+ The origin point for the scale. The scale will be relative to this point.
+*/
+qreal QFxScale::originX() const
+{
+ return _originX;
+}
+
+void QFxScale::setOriginX(qreal ox)
+{
+ _originX = ox;
+ update();
+}
+
+qreal QFxScale::originY() const
+{
+ return _originY;
+}
+
+void QFxScale::setOriginY(qreal oy)
+{
+ _originY = oy;
+ update();
+}
+
+/*!
+ \qmlproperty real Scale::xScale
+
+ The scaling factor for the X axis.
+*/
+qreal QFxScale::xScale() const
+{
+ return _xScale;
+}
+
+void QFxScale::setXScale(qreal scale)
+{
+ if (_xScale == scale)
+ return;
+ _xScale = scale;
+ update();
+ emit scaleChanged();
+}
+
+/*!
+ \qmlproperty real Scale::yScale
+
+ The scaling factor for the Y axis.
+*/
+qreal QFxScale::yScale() const
+{
+ return _yScale;
+}
+
+void QFxScale::setYScale(qreal scale)
+{
+ if (_yScale == scale)
+ return;
+ _yScale = scale;
+ update();
+ emit scaleChanged();
+}
+
+bool QFxScale::isIdentity() const
+{
+ return (_xScale == 1. && _yScale == 1.);
+}
+
+#if defined(QFX_RENDER_QPAINTER)
+QTransform QFxScale::transform() const
+{
+ if (_dirty) {
+ _transform = QTransform();
+ _dirty = false;
+ _transform.translate(_originX, _originY);
+ _transform.scale(_xScale, _yScale);
+ _transform.translate(-_originX, -_originY);
+ }
+ return _transform;
+}
+#elif defined(QFX_RENDER_OPENGL)
+QMatrix4x4 QFxScale::transform() const
+{
+ if (_dirty) {
+ _transform = QMatrix4x4();
+ _dirty = false;
+ _transform.translate(_originX, _originY);
+ _transform.scale(_xScale, _yScale);
+ _transform.translate(-_originX, -_originY);
+ }
+ return _transform;
+}
+#endif
+
+void QFxScale::update()
+{
+ _dirty = true;
+ QFxTransform::update();
+}
+
+QML_DEFINE_TYPE(QFxScale, Scale)
+
+
+/*!
\qmlclass Axis
\brief A Axis object defines an axis that can be used for rotation or translation.
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
index 8693e7b..e0bd276 100644
--- a/src/declarative/fx/qfxtransform.h
+++ b/src/declarative/fx/qfxtransform.h
@@ -68,6 +68,48 @@ public:
virtual QSimpleCanvas::Matrix transform() const;
};
+class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal originX READ originX WRITE setOriginX)
+ Q_PROPERTY(qreal originY READ originY WRITE setOriginY)
+ Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY scaleChanged())
+ Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY scaleChanged())
+public:
+ QFxScale(QObject *parent=0);
+ ~QFxScale();
+
+ qreal originX() const;
+ void setOriginX(qreal);
+
+ qreal originY() const;
+ void setOriginY(qreal);
+
+ qreal xScale() const;
+ void setXScale(qreal);
+
+ qreal yScale() const;
+ void setYScale(qreal);
+
+ virtual bool isIdentity() const;
+ virtual QSimpleCanvas::Matrix transform() const;
+
+Q_SIGNALS:
+ void scaleChanged();
+
+private Q_SLOTS:
+ void update();
+private:
+ qreal _originX;
+ qreal _originY;
+ qreal _xScale;
+ qreal _yScale;
+
+ mutable bool _dirty;
+ mutable QSimpleCanvas::Matrix _transform;
+};
+
class Q_DECLARATIVE_EXPORT QFxAxis : public QObject
{
Q_OBJECT
@@ -308,6 +350,7 @@ private:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QFxTransform)
+QML_DECLARE_TYPE(QFxScale)
QML_DECLARE_TYPE(QFxAxis)
QML_DECLARE_TYPE(QFxRotation)
QML_DECLARE_TYPE(QFxRotation3D)
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index 9015e5c..648eb36 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -194,8 +194,6 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
d->imports += QUrl(td->data.imports().at(i).uri);
}
- d->automaticSemicolonOffsets = td->data.automaticSemicolonOffsets();
-
if (td->data.tree()) {
if (compilerDump()) {
qWarning() << "-AST------------------------------------------------------------------------------";
@@ -253,14 +251,6 @@ QmlDomObject QmlDomDocument::rootObject() const
return rv;
}
-QList<int> QmlDomDocument::automaticSemicolonOffsets() const
-{
- if (d)
- return d->automaticSemicolonOffsets;
- else
- return QList<int>();
-}
-
QmlDomPropertyPrivate::QmlDomPropertyPrivate()
: property(0)
{
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index 170ef56..ef9fe25 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -79,8 +79,6 @@ public:
QmlDomObject rootObject() const;
- QList<int> automaticSemicolonOffsets() const;
-
private:
QSharedDataPointer<QmlDomDocumentPrivate> d;
};
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 14dbf84..2d98063 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -842,7 +842,9 @@ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine)
}
\endcode
- \sa QmlComponent::createObject()
+ If you want to just create an arbitrary string of QML, instead of an
+ existing qml component or qml file, consider the evalQML() function.
+ \sa QmlComponent::createObject(), QmlEngine::createQMLObject()
*/
QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *engine)
{
@@ -868,6 +870,14 @@ QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *eng
Returns the created object, or null if there is an error. In the case of an
error, details of the error are output using qWarning().
+
+ Note that this function returns immediately, and therefore may not work if
+ the QML loads new components. If you are trying to load a new component,
+ for example from a QML file, consider the createComponent() function
+ instead. 'New components' refers to external QML files that have not yet
+ been loaded, and so it is safe to use evalQml to load built-in components.
+
+ \sa QmlEngine::createComponent()
*/
QScriptValue QmlEngine::createQMLObject(QScriptContext *ctxt, QScriptEngine *engine)
{
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 880b64b..7475943 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -178,8 +178,6 @@ protected:
virtual bool visit(AST::UiArrayBinding *node);
virtual bool visit(AST::UiSourceElement *node);
- virtual bool visit(AST::ExpressionStatement *node);
-
void accept(AST::Node *node);
QString asString(AST::UiQualifiedId *node) const;
@@ -669,14 +667,6 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
return true;
}
-bool ProcessAST::visit(AST::ExpressionStatement *node)
-{
- if (!node->semicolonToken.isValid())
- _parser->addAutomaticSemicolonOffset(node->semicolonToken.offset);
-
- return true;
-}
-
static QList<int> collectCommas(AST::UiArrayMemberList *members)
{
QList<int> commas;
@@ -880,7 +870,6 @@ void QmlScriptParser::clear()
_nameSpacePaths.clear();
_typeNames.clear();
_errors.clear();
- _automaticSemicolonOffsets.clear();
if (data) {
delete data;
diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h
index 15f165c..a4cbd82 100644
--- a/src/declarative/qml/qmlscriptparser_p.h
+++ b/src/declarative/qml/qmlscriptparser_p.h
@@ -93,9 +93,6 @@ public:
QList<QmlError> errors() const;
- QList<int> automaticSemicolonOffsets() const { return _automaticSemicolonOffsets; }
- void addAutomaticSemicolonOffset(int offset) { _automaticSemicolonOffsets.append(offset); }
-
// ### private:
int findOrCreateTypeId(const QString &name);
void setTree(QmlParser::Object *tree);
@@ -114,7 +111,6 @@ public:
QStringList _typeNames;
QString _scriptFile;
QmlScriptParserJsASTData *data;
- QList<int> _automaticSemicolonOffsets;
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index c4eabfe..6ad47f5 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -97,13 +97,11 @@ QEasingCurve stringToCurve(const QString &curve)
if (normalizedCurve.startsWith(QLatin1String("ease")))
normalizedCurve = normalizedCurve.mid(4);
- //XXX optimize?
- int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type");
- QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index);
+ static int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type");
+ static QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index);
int value = me.keyToValue(normalizedCurve.toLatin1().constData());
if (value < 0) {
- //XXX print line number
qWarning("QEasingCurve: Unknown easing curve '%s'",
curve.toLatin1().constData());
value = 0;
@@ -130,7 +128,6 @@ QEasingCurve stringToCurve(const QString &curve)
return easingCurve;
}
- //XXX optimize
if (propName == QLatin1String("amplitude")) {
easingCurve.setAmplitude(propValue);
} else if (propName == QLatin1String("period")) {
@@ -698,15 +695,6 @@ void QmlPauseAnimation::setDuration(int duration)
emit durationChanged(duration);
}
-void QmlPauseAnimation::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlPauseAnimation);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-}
-
QAbstractAnimation *QmlPauseAnimation::qtAnimation()
{
Q_D(QmlPauseAnimation);
@@ -721,6 +709,10 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation()
\code
ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 }
\endcode
+
+ When used in a transition, ColorAnimation will by default animate
+ all properties of type color that are changing. If a property or properties
+ are explicity set for the animation, then those will be used instead.
*/
/*!
\internal
@@ -740,6 +732,7 @@ QmlColorAnimation::QmlColorAnimation(QObject *parent)
d->init();
d->interpolatorType = QMetaType::QColor;
d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ d->defaultToInterpolatorType = true;
}
QmlColorAnimation::~QmlColorAnimation()
@@ -1359,17 +1352,9 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions,
d->animations.at(i)->setTarget(d->userProperty);
}
- //XXX removing and readding isn't ideal; we do it to get around the problem mentioned below.
- for (int i = d->ag->animationCount()-1; i >= 0; --i)
- d->ag->takeAnimationAt(i);
-
for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
d->animations.at(ii)->transition(actions, modified, direction);
- d->ag->addAnimation(d->animations.at(ii)->qtAnimation());
}
-
- //XXX changing direction means all the animations play in reverse, while we only want the ordering reversed.
- //d->ag->setDirection(direction == Backward ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
}
QML_DEFINE_TYPE(QmlSequentialAnimation,SequentialAnimation)
@@ -1809,8 +1794,11 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
int interpolatorType; //for Number/ColorAnimation
int prevInterpolatorType; //for generic
QVariantAnimation::Interpolator interpolator;
+ bool reverse;
void setValue(qreal v)
{
+ if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
+ v = 1 - v;
QmlTimeLineValue::setValue(v);
for (int ii = 0; ii < actions.count(); ++ii) {
Action &action = actions[ii];
@@ -1845,8 +1833,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
if (!d->propertyName.isEmpty() && !props.contains(d->propertyName))
props.append(d->propertyName);
- /* ### we used to select properties of name 'color' by default for color animations
- props << QLatin1String("color");*/
+ bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
if (d->userProperty.isValid() && props.isEmpty() && !target()) {
props.append(d->userProperty.value.name());
@@ -1856,6 +1843,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
PropertyUpdater *data = new PropertyUpdater;
data->interpolatorType = d->interpolatorType;
data->interpolator = d->interpolator;
+ data->reverse = direction == Backward ? true : false;
QSet<QObject *> objs;
for (int ii = 0; ii < actions.count(); ++ii) {
@@ -1869,7 +1857,8 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) &&
(!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName))) &&
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName))
+ || (useType && action.property.propertyType() == d->interpolatorType)) &&
(!target() || target() == obj || (!same && target() == sObj))) {
objs.insert(obj);
Action myAction = action;
diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h
index 12212df..91c1898 100644
--- a/src/declarative/util/qmlanimation.h
+++ b/src/declarative/util/qmlanimation.h
@@ -154,7 +154,6 @@ Q_SIGNALS:
protected:
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
};
class QmlRunScriptActionPrivate;
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 051516d..fce5eca 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -319,7 +319,8 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
public:
QmlPropertyAnimationPrivate()
: QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- interpolatorType(0), interpolator(0), va(0), value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
+ defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
+ value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
void init();
@@ -335,6 +336,7 @@ public:
bool fromSourced;
bool fromIsDefined;
bool toIsDefined;
+ bool defaultToInterpolatorType;
int interpolatorType;
QVariantAnimation::Interpolator interpolator;
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index c202a9f..f5f76b0 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -169,31 +169,6 @@ struct ListModelData
*/
-struct ModelNode;
-class ListModel : public QListModelInterface
-{
- Q_OBJECT
-public:
- ListModel(QObject *parent=0);
-
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
- Q_PROPERTY(int count READ count)
- virtual int count() const;
- virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
-
-private:
- QVariant valueForNode(ModelNode *) const;
- mutable QStringList roleStrings;
- friend class ListModelParser;
- friend struct ModelNode;
-
- void checkRoles() const;
- void addRole(const QString &) const;
- mutable bool _rolesOk;
- ModelNode *_root;
-};
-
class ModelObject : public QObject
{
Q_OBJECT
@@ -220,9 +195,9 @@ struct ModelNode
QList<QVariant> values;
QHash<QString, ModelNode *> properties;
- ListModel *model() {
+ QmlListModel *model() {
if (!modelCache) {
- modelCache = new ListModel;
+ modelCache = new QmlListModel;
modelCache->_root = this;
}
return modelCache;
@@ -240,7 +215,7 @@ struct ModelNode
return objectCache;
}
- ListModel *modelCache;
+ QmlListModel *modelCache;
ModelObject *objectCache;
};
@@ -249,12 +224,16 @@ ModelObject::ModelObject(ModelNode *node)
{
}
-ListModel::ListModel(QObject *parent)
+QmlListModel::QmlListModel(QObject *parent)
: QListModelInterface(parent), _rolesOk(false), _root(0)
{
}
-void ListModel::checkRoles() const
+QmlListModel::~QmlListModel()
+{
+}
+
+void QmlListModel::checkRoles() const
{
if (_rolesOk)
return;
@@ -270,13 +249,13 @@ void ListModel::checkRoles() const
_rolesOk = true;
}
-void ListModel::addRole(const QString &role) const
+void QmlListModel::addRole(const QString &role) const
{
if (!roleStrings.contains(role))
roleStrings << role;
}
-QList<int> ListModel::roles() const
+QList<int> QmlListModel::roles() const
{
checkRoles();
QList<int> rv;
@@ -285,7 +264,7 @@ QList<int> ListModel::roles() const
return rv;
}
-QString ListModel::toString(int role) const
+QString QmlListModel::toString(int role) const
{
checkRoles();
if (role < roleStrings.count())
@@ -294,7 +273,7 @@ QString ListModel::toString(int role) const
return QString();
}
-QVariant ListModel::valueForNode(ModelNode *node) const
+QVariant QmlListModel::valueForNode(ModelNode *node) const
{
QObject *rv = 0;
@@ -327,7 +306,7 @@ QVariant ListModel::valueForNode(ModelNode *node) const
return QVariant();
}
-QHash<int,QVariant> ListModel::data(int index, const QList<int> &roles) const
+QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const
{
checkRoles();
QHash<int, QVariant> rv;
@@ -352,13 +331,13 @@ QHash<int,QVariant> ListModel::data(int index, const QList<int> &roles) const
return rv;
}
-int ListModel::count() const
+int QmlListModel::count() const
{
if (!_root) return 0;
return _root->values.count();
}
-class ListModelParser : public QmlCustomParser
+class QmlListModelParser : public QmlCustomParser
{
public:
QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok);
@@ -366,7 +345,7 @@ public:
void setCustomData(QObject *, const QByteArray &);
};
-bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
+bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
{
QList<QVariant> values = prop.assignedValues();
for(int ii = 0; ii < values.count(); ++ii) {
@@ -433,7 +412,7 @@ bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList
return true;
}
-QByteArray ListModelParser::compile(const QList<QmlCustomParserProperty> &customProps, bool *ok)
+QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &customProps, bool *ok)
{
*ok = true;
QList<ListInstruction> instr;
@@ -470,9 +449,9 @@ QByteArray ListModelParser::compile(const QList<QmlCustomParserProperty> &custom
return rv;
}
-void ListModelParser::setCustomData(QObject *obj, const QByteArray &d)
+void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d)
{
- ListModel *rv = static_cast<ListModel *>(obj);
+ QmlListModel *rv = static_cast<QmlListModel *>(obj);
ModelNode *root = new ModelNode;
rv->_root = root;
@@ -518,14 +497,14 @@ void ListModelParser::setCustomData(QObject *obj, const QByteArray &d)
}
}
-QML_DEFINE_CUSTOM_TYPE(ListModel, ListModel, ListModelParser)
+QML_DEFINE_CUSTOM_TYPE(QmlListModel, ListModel, QmlListModelParser)
// ### FIXME
-class ListElement : public QObject
+class QmlListElement : public QObject
{
Q_OBJECT
};
-QML_DEFINE_TYPE(ListElement,ListElement)
+QML_DEFINE_TYPE(QmlListElement,ListElement)
static void dump(ModelNode *node, int ind)
{
@@ -566,7 +545,6 @@ ModelNode::~ModelNode()
QT_END_NAMESPACE
Q_DECLARE_METATYPE(ModelNode *)
-QML_DECLARE_TYPE(ListModel)
-QML_DECLARE_TYPE(ListElement)
+QML_DECLARE_TYPE(QmlListElement)
#include "qmllistmodel.moc"
diff --git a/src/declarative/util/qmllistmodel.h b/src/declarative/util/qmllistmodel.h
index 56ed8fb..39edbe4 100644
--- a/src/declarative/util/qmllistmodel.h
+++ b/src/declarative/util/qmllistmodel.h
@@ -57,9 +57,37 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+struct ModelNode;
+class QmlListModel : public QListModelInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count)
+
+public:
+ QmlListModel(QObject *parent=0);
+ ~QmlListModel();
+
+ virtual QList<int> roles() const;
+ virtual QString toString(int role) const;
+ virtual int count() const;
+ virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
+
+private:
+ QVariant valueForNode(ModelNode *) const;
+ mutable QStringList roleStrings;
+ friend class QmlListModelParser;
+ friend struct ModelNode;
+
+ void checkRoles() const;
+ void addRole(const QString &) const;
+ mutable bool _rolesOk;
+ ModelNode *_root;
+};
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlListModel)
+
QT_END_HEADER
#endif // QMLLISTMODEL_H
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index ccd0293..d793c7d 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -177,6 +177,7 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions,
}
d->endState = endState;
+ d->group->setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
d->group->start();
}