From 0200260487c888b62d7761d6f358543602b53994 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 11:31:10 +1000 Subject: Cleanup. --- src/declarative/util/qmlanimation.cpp | 16 ++-------------- src/declarative/util/qmlanimation.h | 1 - 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index c4eabfe..620739f 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); 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; -- cgit v0.12 From e44a16c440a56ccd6d9a001f01c45d7327ce8e62 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 12:35:25 +1000 Subject: Change reversible transition semantics. The new semantics match those of playing a QAbstractionAnimation backward. (i.e. it is now an exact visual reverse) --- src/declarative/util/qmlanimation.cpp | 12 ++++-------- src/declarative/util/qmltransition.cpp | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 620739f..0c8f55f 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1347,17 +1347,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) @@ -1797,8 +1789,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]; @@ -1844,6 +1839,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 objs; for (int ii = 0; ii < actions.count(); ++ii) { diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index 5931075..43a4605 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -176,6 +176,7 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions, } d->endState = endState; + d->group->setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); d->group->start(); } -- cgit v0.12 From 5bb4fe79e92a4882977f64c03654e707721c59a9 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 13:24:24 +1000 Subject: Add a Scale transform object. --- doc/src/declarative/elements.qdoc | 1 + src/declarative/fx/qfxtransform.cpp | 133 ++++++++++++++++++++++++++++++++++++ src/declarative/fx/qfxtransform.h | 43 ++++++++++++ 3 files changed, 177 insertions(+) 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/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) -- cgit v0.12 From 10c1e4a09d8e2fa671f5538bde5f9126954272ed Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 15:01:28 +1000 Subject: ListModel code cleanup. --- src/declarative/util/qmllistmodel.cpp | 70 ++++++++++++----------------------- src/declarative/util/qmllistmodel.h | 28 ++++++++++++++ 2 files changed, 52 insertions(+), 46 deletions(-) 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 roles() const; - virtual QString toString(int role) const; - Q_PROPERTY(int count READ count) - virtual int count() const; - virtual QHash data(int index, const QList &roles = (QList())) 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 values; QHash 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 ListModel::roles() const +QList QmlListModel::roles() const { checkRoles(); QList rv; @@ -285,7 +264,7 @@ QList 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 ListModel::data(int index, const QList &roles) const +QHash QmlListModel::data(int index, const QList &roles) const { checkRoles(); QHash rv; @@ -352,13 +331,13 @@ QHash ListModel::data(int index, const QList &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 &, bool *ok); @@ -366,7 +345,7 @@ public: void setCustomData(QObject *, const QByteArray &); }; -bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList &instr, QByteArray &data) +bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList &instr, QByteArray &data) { QList 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 &customProps, bool *ok) +QByteArray QmlListModelParser::compile(const QList &customProps, bool *ok) { *ok = true; QList instr; @@ -470,9 +449,9 @@ QByteArray ListModelParser::compile(const QList &custom return rv; } -void ListModelParser::setCustomData(QObject *obj, const QByteArray &d) +void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) { - ListModel *rv = static_cast(obj); + QmlListModel *rv = static_cast(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 roles() const; + virtual QString toString(int role) const; + virtual int count() const; + virtual QHash data(int index, const QList &roles = (QList())) 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 -- cgit v0.12 From 9fdcef95dfb369ef490d5be8e4621485d11cddda Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 1 Jul 2009 15:47:19 +1000 Subject: Implement edge resistance for flickable dragging horizontally. --- src/declarative/fx/qfxflickable.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- cgit v0.12 From f1b6711ab742c9ab56304861f2bef01a8beecebc Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 15:52:50 +1000 Subject: Have ColorAnimation select all properties of type QColor by default. This allows you to write ColorAnimation {} in a transition and all colors that are changing will be handled by default. --- src/declarative/util/qmlanimation.cpp | 11 ++++++++--- src/declarative/util/qmlanimation_p.h | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 0c8f55f..6ad47f5 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -709,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 @@ -728,6 +732,7 @@ QmlColorAnimation::QmlColorAnimation(QObject *parent) d->init(); d->interpolatorType = QMetaType::QColor; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + d->defaultToInterpolatorType = true; } QmlColorAnimation::~QmlColorAnimation() @@ -1828,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()); @@ -1853,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_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; -- cgit v0.12 From eeccaca2875b675d9fabfe5cf03941fa1fd93511 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 1 Jul 2009 17:47:55 +0200 Subject: Removed superfluous methods. --- src/declarative/qml/qmldom.cpp | 10 ---------- src/declarative/qml/qmldom.h | 2 -- src/declarative/qml/qmlscriptparser.cpp | 11 ----------- src/declarative/qml/qmlscriptparser_p.h | 4 ---- 4 files changed, 27 deletions(-) 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 QmlDomDocument::automaticSemicolonOffsets() const -{ - if (d) - return d->automaticSemicolonOffsets; - else - return QList(); -} - 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 automaticSemicolonOffsets() const; - private: QSharedDataPointer d; }; diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index f1f1710..b957499 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; @@ -645,14 +643,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 collectCommas(AST::UiArrayMemberList *members) { QList commas; @@ -856,7 +846,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 errors() const; - QList 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 _automaticSemicolonOffsets; }; QT_END_NAMESPACE -- cgit v0.12 From 4e9336d1f60089bffda7fca93a63d18ffce0a6fa Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 2 Jul 2009 10:02:39 +1000 Subject: Augment docs for JS dynamic creation functions Note that I'm still not entirely certain the docs are in the right place for people to find them - but if they do they should now have a better understanding of which function to use. --- src/declarative/qml/qmlengine.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 294e333..fc2c7e3 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -866,7 +866,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) { @@ -892,6 +894,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) { -- cgit v0.12