summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmldom.cpp100
-rw-r--r--src/declarative/qml/qmldom.h4
-rw-r--r--src/declarative/qml/qmldom_p.h22
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp15
4 files changed, 57 insertions, 84 deletions
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index 39d6730..f4a137c 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -57,13 +57,6 @@ QmlDomDocumentPrivate::QmlDomDocumentPrivate()
{
}
-QmlDomDocumentPrivate::QmlDomDocumentPrivate(const QmlDomDocumentPrivate &other)
-: QSharedData(other), root(0)
-{
- root = other.root;
- if (root) root->addref();
-}
-
QmlDomDocumentPrivate::~QmlDomDocumentPrivate()
{
if (root) root->release();
@@ -141,7 +134,7 @@ QList<QmlDomImport> QmlDomDocument::imports() const
/*!
Loads a QmlDomDocument from \a data. \a data should be valid QML
data. On success, true is returned. If the \a data is malformed, false
- is returned and QmlDomDocument::loadError() contains an error description.
+ is returned and QmlDomDocument::errors() contains an error description.
\sa QmlDomDocument::loadError()
*/
@@ -160,7 +153,8 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
td->release();
component->release();
return false;
- } else if(td->status == QmlCompositeTypeData::Waiting) {
+ } else if(td->status == QmlCompositeTypeData::Waiting ||
+ td->status == QmlCompositeTypeData::WaitingResources) {
QmlError error;
error.setDescription(QLatin1String("QmlDomDocument supports local types only"));
d->errors << error;
@@ -234,13 +228,6 @@ QmlDomPropertyPrivate::QmlDomPropertyPrivate()
{
}
-QmlDomPropertyPrivate::QmlDomPropertyPrivate(const QmlDomPropertyPrivate &other)
-: QSharedData(other), property(0)
-{
- property = other.property;
- if (property) property->addref();
-}
-
QmlDomPropertyPrivate::~QmlDomPropertyPrivate()
{
if (property) property->release();
@@ -251,13 +238,6 @@ QmlDomDynamicPropertyPrivate::QmlDomDynamicPropertyPrivate():
{
}
-QmlDomDynamicPropertyPrivate::QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &other)
-: QSharedData(other), valid(other.valid)
-{
- property = other.property;
- if (valid && property.defaultValue) property.defaultValue->addref();
-}
-
QmlDomDynamicPropertyPrivate::~QmlDomDynamicPropertyPrivate()
{
if (valid && property.defaultValue) property.defaultValue->release();
@@ -307,6 +287,15 @@ QmlDomProperty &QmlDomProperty::operator=(const QmlDomProperty &other)
}
/*!
+ Returns true if this is a valid QmlDomProperty, false otherwise.
+*/
+bool QmlDomProperty::isValid() const
+{
+ return d->property != 0;
+}
+
+
+/*!
Return the name of this property.
\qml
@@ -482,7 +471,7 @@ int QmlDomDynamicProperty::propertyType() const
return QMetaType::type("QColor");
case QmlParser::Object::DynamicProperty::Date:
- return QMetaType::type("QDateTime");
+ return QMetaType::type("QDate");
case QmlParser::Object::DynamicProperty::Int:
return QMetaType::type("int");
@@ -507,6 +496,14 @@ int QmlDomDynamicProperty::propertyType() const
return -1;
}
+QByteArray QmlDomDynamicProperty::propertyTypeName() const
+{
+ if (isValid())
+ return d->property.customType;
+
+ return QByteArray();
+}
+
/*!
Return true if this property is used as a default property in the QML
document.
@@ -539,6 +536,7 @@ QmlDomProperty QmlDomDynamicProperty::defaultValue() const
if (isValid() && d->property.defaultValue) {
rp.d->property = d->property.defaultValue;
+ rp.d->propertyName = propertyName();
rp.d->property->addref();
}
@@ -570,18 +568,10 @@ int QmlDomDynamicProperty::length() const
}
QmlDomObjectPrivate::QmlDomObjectPrivate()
-: object(0), isVirtualComponent(false)
+: object(0)
{
}
-QmlDomObjectPrivate::QmlDomObjectPrivate(const QmlDomObjectPrivate &other)
-: QSharedData(other), object(0), isVirtualComponent(false)
-{
- object = other.object;
- if (object) object->addref();
- isVirtualComponent = other.isVirtualComponent;
-}
-
QmlDomObjectPrivate::~QmlDomObjectPrivate()
{
if (object) object->release();
@@ -665,16 +655,6 @@ QmlDomObject::QmlDomObject()
}
/*!
- Construct a new QmlDomObject with the specified \a objectType.
-*/
-QmlDomObject::QmlDomObject(const QByteArray &objectType)
-: d(new QmlDomObjectPrivate)
-{
- Q_UNUSED(objectType);
- qWarning("QmlDomObject::QmlDomObject(const QByteArray &): Not implemented");
-}
-
-/*!
Create a copy of \a other QmlDomObject.
*/
QmlDomObject::QmlDomObject(const QmlDomObject &other)
@@ -785,7 +765,7 @@ QList<QmlDomProperty> QmlDomObject::properties() const
{
QList<QmlDomProperty> rv;
- if (!d->object)
+ if (!d->object || isComponent())
return rv;
QmlDomObjectPrivate::Properties properties = d->properties();
@@ -853,6 +833,9 @@ QmlDomDynamicProperty QmlDomObject::dynamicProperty(const QByteArray &name) cons
{
QmlDomDynamicProperty p;
+ if (!isValid())
+ return p;
+
for (int i = 0; i < d->object->dynamicProperties.size(); ++i) {
if (d->object->dynamicProperties.at(i).name == name) {
p.d = new QmlDomDynamicPropertyPrivate;
@@ -900,8 +883,7 @@ QByteArray QmlDomObject::customTypeData() const
*/
bool QmlDomObject::isComponent() const
{
- return d->isVirtualComponent ||
- (d->object && d->object->typeName == "Qt/Component");
+ return (d->object && d->object->typeName == "Qt/Component");
}
/*!
@@ -958,13 +940,6 @@ QmlDomBasicValuePrivate::QmlDomBasicValuePrivate()
{
}
-QmlDomBasicValuePrivate::QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &other)
-: QSharedData(other), value(0)
-{
- value = other.value;
- if (value) value->addref();
-}
-
QmlDomBasicValuePrivate::~QmlDomBasicValuePrivate()
{
if (value) value->release();
@@ -1250,15 +1225,6 @@ QmlDomValuePrivate::QmlDomValuePrivate()
{
}
-QmlDomValuePrivate::QmlDomValuePrivate(const QmlDomValuePrivate &other)
-: QSharedData(other), property(0), value(0)
-{
- property = other.property;
- value = other.value;
- if (property) property->addref();
- if (value) value->addref();
-}
-
QmlDomValuePrivate::~QmlDomValuePrivate()
{
if (property) property->release();
@@ -1754,10 +1720,7 @@ Item {
QmlDomObject QmlDomComponent::componentRoot() const
{
QmlDomObject rv;
- if (d->isVirtualComponent) {
- rv.d->object = d->object;
- rv.d->object->addref();
- } else if (d->object) {
+ if (d->object) {
QmlParser::Object *obj = 0;
if (d->object->defaultProperty &&
d->object->defaultProperty->values.count() == 1 &&
@@ -1778,11 +1741,6 @@ QmlDomImportPrivate::QmlDomImportPrivate()
{
}
-QmlDomImportPrivate::QmlDomImportPrivate(const QmlDomImportPrivate &other)
-: QSharedData(other)
-{
-}
-
QmlDomImportPrivate::~QmlDomImportPrivate()
{
}
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index 8c43c4a..250307f 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -92,6 +92,8 @@ public:
~QmlDomProperty();
QmlDomProperty &operator=(const QmlDomProperty &);
+ bool isValid() const;
+
QByteArray propertyName() const;
QList<QByteArray> propertyNameParts() const;
@@ -121,6 +123,7 @@ public:
QByteArray propertyName() const;
int propertyType() const;
+ QByteArray propertyTypeName() const;
bool isDefaultProperty() const;
@@ -139,7 +142,6 @@ class Q_DECLARATIVE_EXPORT QmlDomObject
{
public:
QmlDomObject();
- QmlDomObject(const QByteArray &);
QmlDomObject(const QmlDomObject &);
~QmlDomObject();
QmlDomObject &operator=(const QmlDomObject &);
diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h
index 4b4de80..cb0d884 100644
--- a/src/declarative/qml/qmldom_p.h
+++ b/src/declarative/qml/qmldom_p.h
@@ -62,7 +62,8 @@ class QmlDomDocumentPrivate : public QSharedData
{
public:
QmlDomDocumentPrivate();
- QmlDomDocumentPrivate(const QmlDomDocumentPrivate &);
+ QmlDomDocumentPrivate(const QmlDomDocumentPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
~QmlDomDocumentPrivate();
QList<QmlError> errors;
@@ -75,7 +76,8 @@ class QmlDomObjectPrivate : public QSharedData
{
public:
QmlDomObjectPrivate();
- QmlDomObjectPrivate(const QmlDomObjectPrivate &);
+ QmlDomObjectPrivate(const QmlDomObjectPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
~QmlDomObjectPrivate();
typedef QList<QPair<QmlParser::Property *, QByteArray> > Properties;
@@ -83,14 +85,14 @@ public:
Properties properties(QmlParser::Property *) const;
QmlParser::Object *object;
- bool isVirtualComponent;
};
class QmlDomPropertyPrivate : public QSharedData
{
public:
QmlDomPropertyPrivate();
- QmlDomPropertyPrivate(const QmlDomPropertyPrivate &);
+ QmlDomPropertyPrivate(const QmlDomPropertyPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
~QmlDomPropertyPrivate();
QByteArray propertyName;
@@ -101,7 +103,8 @@ class QmlDomDynamicPropertyPrivate : public QSharedData
{
public:
QmlDomDynamicPropertyPrivate();
- QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &);
+ QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
~QmlDomDynamicPropertyPrivate();
bool valid;
@@ -112,7 +115,8 @@ class QmlDomValuePrivate : public QSharedData
{
public:
QmlDomValuePrivate();
- QmlDomValuePrivate(const QmlDomValuePrivate &);
+ QmlDomValuePrivate(const QmlDomValuePrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
~QmlDomValuePrivate();
QmlParser::Property *property;
@@ -123,7 +127,8 @@ class QmlDomBasicValuePrivate : public QSharedData
{
public:
QmlDomBasicValuePrivate();
- QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &);
+ QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
~QmlDomBasicValuePrivate();
QmlParser::Value *value;
@@ -133,7 +138,8 @@ class QmlDomImportPrivate : public QSharedData
{
public:
QmlDomImportPrivate();
- QmlDomImportPrivate(const QmlDomImportPrivate &);
+ QmlDomImportPrivate(const QmlDomImportPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
~QmlDomImportPrivate();
enum Type { Library, File };
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 526894e..b622c24 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -342,10 +342,17 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
Value *v = new Value;
v->object = obj;
v->location = obj->location;
- if (state.property)
+ if (state.property) {
state.property->addValue(v);
- else
- state.object->getDefaultProperty()->addValue(v);
+ } else {
+ Property *defaultProp = state.object->getDefaultProperty();
+ if (defaultProp->location.start.line == -1) {
+ defaultProp->location = v->location;
+ defaultProp->location.end = defaultProp->location.start;
+ defaultProp->location.range.length = 0;
+ }
+ defaultProp->addValue(v);
+ }
}
}
@@ -583,8 +590,8 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
QmlScriptParser::TypeReference *typeRef =
_parser->findOrCreateType(memberType);
typeRef->refObjects.append(_stateStack.top().object);
- property.customType = memberType.toUtf8();
}
+ property.customType = memberType.toUtf8();
property.name = name.toUtf8();
property.location = location(node->firstSourceLocation(),
node->lastSourceLocation());