diff options
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/QmlChanges.txt | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 11 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypedata_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager.cpp | 21 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 6 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 34 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser_p.h | 18 | ||||
-rw-r--r-- | src/declarative/util/qmltransition.cpp | 12 | ||||
-rw-r--r-- | src/declarative/util/qmltransition.h | 4 |
10 files changed, 78 insertions, 42 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 7c4fcc3..8588175 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -2,7 +2,9 @@ QML API Review ============== The QML API is being reviewed from 17 to 28 August 2009. This -file documents the changes. +file documents the changes. Note that the changes are incremental, +so a rename A->B for example may be follow by another subseqent +rename B->C, if later reviews override earlier reviews. API Changes =========== @@ -34,6 +36,8 @@ Text elements: hAlign -> horizontalAlignment Text elements: vAlign -> verticalAlignment State: operations -> changes Transition: operations -> animations +Transition: fromState -> from +Transition: toState -> to Follow: followValue -> value Additions: @@ -58,8 +62,6 @@ Pending Changes Renamed elements: Renamed properties: -Transition: fromState -> from -Trnasition: toState -> to Removed Properties: PropertyAction::property diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 83b4eb5..d78e096 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -88,7 +88,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) 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: + The following example scales the X axis of the Rectangle, relative to its interior point 25, 25: \qml Rectangle { width: 100; height: 100 @@ -121,7 +121,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) \qmlclass Rotation \brief A Rotation object provides a way to rotate an Item around a point using an axis in 3D space. - The following example rotates a Rect around its interior point 25, 25: + The following example rotates a Rectangle around its interior point 25, 25: \qml Rectangle { width: 100; height: 100 diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 1fb4b46..1771cb4 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -569,6 +569,7 @@ bool QmlCompiler::compile(QmlEngine *engine, for (int ii = 0; ii < unit->types.count(); ++ii) { QmlCompositeTypeData::TypeReference &tref = unit->types[ii]; QmlCompiledData::TypeReference ref; + QmlScriptParser::TypeReference *parserRef = unit->data.referencedTypes().at(ii); if (tref.type) ref.type = tref.type; else if (tref.unit) { @@ -578,7 +579,13 @@ bool QmlCompiler::compile(QmlEngine *engine, QmlError error; error.setUrl(output->url); error.setDescription(QLatin1String("Unable to create type ") + - unit->data.types().at(ii)); + parserRef->name); + if (!parserRef->refObjects.isEmpty()) { + QmlParser::Object *parserObject = parserRef->refObjects.first(); + error.setLine(parserObject->location.start.line); + error.setColumn(parserObject->location.start.column); + } + exceptions << error; exceptions << ref.component->errors(); reset(out); @@ -587,7 +594,7 @@ bool QmlCompiler::compile(QmlEngine *engine, ref.ref = tref.unit; ref.ref->addref(); } - ref.className = unit->data.types().at(ii).toLatin1(); + ref.className = parserRef->name.toLatin1(); out->types << ref; } diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h index 3469fea..54933c4 100644 --- a/src/declarative/qml/qmlcompositetypedata_p.h +++ b/src/declarative/qml/qmlcompositetypedata_p.h @@ -91,7 +91,7 @@ struct QmlCompositeTypeData : public QmlRefCount // occurs QmlCompiledData *toCompiledComponent(QmlEngine *); - struct TypeReference + struct TypeReference { TypeReference(); diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 97391e6..0fb6c86 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -311,21 +311,23 @@ void QmlCompositeTypeManager::checkComplete(QmlCompositeTypeData *unit) void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) { - QStringList typeNames = unit->data.types(); + QList<QmlScriptParser::TypeReference*> types = unit->data.referencedTypes(); int waiting = 0; - for (int ii = 0; ii < typeNames.count(); ++ii) { - QByteArray type = typeNames.at(ii).toLatin1(); + for (int ii = 0; ii < types.count(); ++ii) { + QmlScriptParser::TypeReference *parserRef = types.at(ii); + QByteArray typeName = parserRef->name.toLatin1(); QmlCompositeTypeData::TypeReference ref; - if (type == QByteArray("Property") || - type == QByteArray("Signal")) { + + if (typeName == QByteArray("Property") || + typeName == QByteArray("Signal")) { unit->types << ref; continue; } QUrl url; - if (!QmlEnginePrivate::get(engine)->resolveType(unit->imports, type, &ref.type, &url)) { + if (!QmlEnginePrivate::get(engine)->resolveType(unit->imports, typeName, &ref.type, &url)) { // XXX could produce error message here. } @@ -353,7 +355,12 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) { QmlError error; error.setUrl(unit->imports.baseUrl()); - error.setDescription(tr("Type %1 unavailable").arg(QLatin1String(type))); + error.setDescription(tr("Type %1 unavailable").arg(QLatin1String(typeName))); + if (!parserRef->refObjects.isEmpty()) { + QmlParser::Object *obj = parserRef->refObjects.first(); + error.setLine(obj->location.start.line); + error.setColumn(obj->location.start.column); + } unit->errors << error; } if (urlUnit->errorType != QmlCompositeTypeData::AccessError) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 7f2a3e1..351bd8a 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -71,6 +71,7 @@ #include <QtCore/qthread.h> #include <QtCore/qcoreapplication.h> #include <QtCore/qdir.h> +#include <QtGui/qvector3d.h> #include <qmlcomponent.h> #include "private/qmlcomponentjs_p.h" #include "private/qmlmetaproperty_p.h" @@ -727,10 +728,7 @@ QScriptValue QmlEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engin qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); qsreal z = ctxt->argument(2).toNumber(); - QString s = QString::number(x) + QLatin1Char(',') + - QString::number(y) + QLatin1Char(',') + - QString::number(z); - return QScriptValue(s); + return engine->newVariant(qVariantFromValue(QVector3D(x, y, z))); } QmlScriptClass::QmlScriptClass(QmlEngine *bindengine) diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 2f82f0d..187f640 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -288,10 +288,13 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, QString resolvableObjectType = objectType; if (lastTypeDot >= 0) resolvableObjectType.replace(QLatin1Char('.'),QLatin1Char('/')); - const int typeId = _parser->findOrCreateTypeId(resolvableObjectType); + + QmlScriptParser::TypeReference *typeRef = _parser->findOrCreateType(resolvableObjectType); Object *obj = new Object; - obj->type = typeId; + obj->type = typeRef->id; + + typeRef->refObjects.append(obj); // XXX this doesn't do anything (_scope never builds up) _scope.append(resolvableObjectType); @@ -802,9 +805,9 @@ bool QmlScriptParser::parse(const QByteArray &qmldata, const QUrl &url) return _errors.isEmpty(); } -QStringList QmlScriptParser::types() const +QList<QmlScriptParser::TypeReference*> QmlScriptParser::referencedTypes() const { - return _typeNames; + return _refTypes; } Object *QmlScriptParser::tree() const @@ -828,7 +831,8 @@ void QmlScriptParser::clear() root->release(); root = 0; } - _typeNames.clear(); + qDeleteAll(_refTypes); + _refTypes.clear(); _errors.clear(); if (data) { @@ -837,16 +841,22 @@ void QmlScriptParser::clear() } } -int QmlScriptParser::findOrCreateTypeId(const QString &name) +QmlScriptParser::TypeReference *QmlScriptParser::findOrCreateType(const QString &name) { - int index = _typeNames.indexOf(name); - - if (index == -1) { - index = _typeNames.size(); - _typeNames.append(name); + TypeReference *type = 0; + int i = 0; + for (; i < _refTypes.size(); ++i) { + if (_refTypes.at(i)->name == name) { + type = _refTypes.at(i); + break; + } + } + if (!type) { + type = new TypeReference(i, name); + _refTypes.append(type); } - return index; + return type; } void QmlScriptParser::setTree(Object *tree) diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h index 355ff75..d489610 100644 --- a/src/declarative/qml/qmlscriptparser_p.h +++ b/src/declarative/qml/qmlscriptparser_p.h @@ -84,12 +84,24 @@ public: QmlParser::LocationSpan location; }; + class TypeReference + { + public: + TypeReference(int typeId, const QString &typeName) : id(typeId), name(typeName) {} + + int id; + // type as it has been referenced in Qml + QString name; + // objects in parse tree referencing the type + QList<QmlParser::Object*> refObjects; + }; + QmlScriptParser(); ~QmlScriptParser(); bool parse(const QByteArray &data, const QUrl &url = QUrl()); - QStringList types() const; + QList<TypeReference*> referencedTypes() const; QmlParser::Object *tree() const; QList<Import> imports() const; @@ -99,7 +111,7 @@ public: QList<QmlError> errors() const; // ### private: - int findOrCreateTypeId(const QString &name); + TypeReference *findOrCreateType(const QString &name); void setTree(QmlParser::Object *tree); void setScriptFile(const QString &filename) {_scriptFile = filename; } @@ -110,7 +122,7 @@ public: QmlParser::Object *root; QList<Import> _imports; - QStringList _typeNames; + QList<TypeReference*> _refTypes; QString _scriptFile; QmlScriptParserJsASTData *data; }; diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index e70661d..66275d9 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -183,17 +183,17 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions, } /*! - \qmlproperty string Transition::fromState - \qmlproperty string Transition::toState + \qmlproperty string Transition::from + \qmlproperty string Transition::to These properties are selectors indicating which state changes should trigger the transition. - fromState is used in conjunction with toState to determine when a transition should - be applied. By default fromState and toState are both "*" (any state). In the following example, + from is used in conjunction with to to determine when a transition should + be applied. By default from and to are both "*" (any state). In the following example, the transition is applied when changing from state1 to state2. \code Transition { - fromState: "state1" - toState: "state2" + from: "state1" + to: "state2" ... } \endcode diff --git a/src/declarative/util/qmltransition.h b/src/declarative/util/qmltransition.h index 39b35ba..b09341d 100644 --- a/src/declarative/util/qmltransition.h +++ b/src/declarative/util/qmltransition.h @@ -61,8 +61,8 @@ class Q_DECLARATIVE_EXPORT QmlTransition : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QmlTransition) - Q_PROPERTY(QString fromState READ fromState WRITE setFromState) - Q_PROPERTY(QString toState READ toState WRITE setToState) + Q_PROPERTY(QString from READ fromState WRITE setFromState) + Q_PROPERTY(QString to READ toState WRITE setToState) Q_PROPERTY(bool reversible READ reversible WRITE setReversible) Q_PROPERTY(QmlList<QmlAbstractAnimation *>* animations READ animations) Q_CLASSINFO("DefaultProperty", "animations") |