qmldump: Dump attached types and read them in Creator.

This commit is contained in:
Christian Kamm
2011-02-10 14:46:03 +01:00
parent 047ed35579
commit 13f9135827
5 changed files with 88 additions and 4 deletions

View File

@@ -249,6 +249,7 @@ Module {
"Qt/Component 4.7", "Qt/Component 4.7",
"QtQuick/Component 1.0" "QtQuick/Component 1.0"
] ]
attachedType: "QDeclarativeComponentAttached"
Enum { Enum {
name: "Status" name: "Status"
values: { values: {
@@ -271,6 +272,12 @@ Module {
} }
Method { name: "errorString"; type: "string" } Method { name: "errorString"; type: "string" }
} }
Component {
name: "QDeclarativeComponentAttached"
prototype: "QObject"
Signal { name: "completed" }
Signal { name: "destruction" }
}
Component { Component {
name: "QDeclarativeConnections" name: "QDeclarativeConnections"
prototype: "QObject" prototype: "QObject"
@@ -677,6 +684,7 @@ Module {
"QtQuick/GridView 1.0", "QtQuick/GridView 1.0",
"QtQuick/GridView 1.1" "QtQuick/GridView 1.1"
] ]
attachedType: "QDeclarativeGridViewAttached"
Enum { Enum {
name: "HighlightRangeMode" name: "HighlightRangeMode"
values: { values: {
@@ -766,6 +774,18 @@ Module {
Method { name: "positionViewAtBeginning" } Method { name: "positionViewAtBeginning" }
Method { name: "positionViewAtEnd" } Method { name: "positionViewAtEnd" }
} }
Component {
name: "QDeclarativeGridViewAttached"
prototype: "QObject"
Property { name: "view"; type: "QDeclarativeGridView"; isReadonly: true; isPointer: true }
Property { name: "isCurrentItem"; type: "bool"; isReadonly: true }
Property { name: "delayRemove"; type: "bool" }
Signal { name: "currentItemChanged" }
Signal { name: "delayRemoveChanged" }
Signal { name: "add" }
Signal { name: "remove" }
Signal { name: "viewChanged" }
}
Component { Component {
name: "QDeclarativeImage" name: "QDeclarativeImage"
defaultProperty: "data" defaultProperty: "data"
@@ -967,6 +987,7 @@ Module {
"Qt/KeyNavigation 4.7", "Qt/KeyNavigation 4.7",
"QtQuick/KeyNavigation 1.0" "QtQuick/KeyNavigation 1.0"
] ]
attachedType: "QDeclarativeKeyNavigationAttached"
Enum { Enum {
name: "Priority" name: "Priority"
values: { values: {
@@ -996,6 +1017,7 @@ Module {
"Qt/Keys 4.7", "Qt/Keys 4.7",
"QtQuick/Keys 1.0" "QtQuick/Keys 1.0"
] ]
attachedType: "QDeclarativeKeysAttached"
Enum { Enum {
name: "Priority" name: "Priority"
values: { values: {
@@ -1248,6 +1270,7 @@ Module {
"QtQuick/ListView 1.0", "QtQuick/ListView 1.0",
"QtQuick/ListView 1.1" "QtQuick/ListView 1.1"
] ]
attachedType: "QDeclarativeListViewAttached"
Enum { Enum {
name: "HighlightRangeMode" name: "HighlightRangeMode"
values: { values: {
@@ -1343,6 +1366,24 @@ Module {
Method { name: "positionViewAtBeginning" } Method { name: "positionViewAtBeginning" }
Method { name: "positionViewAtEnd" } Method { name: "positionViewAtEnd" }
} }
Component {
name: "QDeclarativeListViewAttached"
prototype: "QObject"
Property { name: "view"; type: "QDeclarativeListView"; isReadonly: true; isPointer: true }
Property { name: "isCurrentItem"; type: "bool"; isReadonly: true }
Property { name: "previousSection"; type: "string"; isReadonly: true }
Property { name: "nextSection"; type: "string"; isReadonly: true }
Property { name: "section"; type: "string"; isReadonly: true }
Property { name: "delayRemove"; type: "bool" }
Signal { name: "currentItemChanged" }
Signal { name: "sectionChanged" }
Signal { name: "prevSectionChanged" }
Signal { name: "nextSectionChanged" }
Signal { name: "delayRemoveChanged" }
Signal { name: "add" }
Signal { name: "remove" }
Signal { name: "viewChanged" }
}
Component { Component {
name: "QDeclarativeLoader" name: "QDeclarativeLoader"
defaultProperty: "data" defaultProperty: "data"
@@ -1443,8 +1484,14 @@ Module {
"Qt/Package 4.7", "Qt/Package 4.7",
"QtQuick/Package 1.0" "QtQuick/Package 1.0"
] ]
attachedType: "QDeclarativePackageAttached"
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
} }
Component {
name: "QDeclarativePackageAttached"
prototype: "QObject"
Property { name: "name"; type: "string" }
}
Component { Component {
name: "QDeclarativePaintedItem" name: "QDeclarativePaintedItem"
defaultProperty: "data" defaultProperty: "data"
@@ -1585,6 +1632,7 @@ Module {
"Qt/PathView 4.7", "Qt/PathView 4.7",
"QtQuick/PathView 1.0" "QtQuick/PathView 1.0"
] ]
attachedType: "QDeclarativePathViewAttached"
Enum { Enum {
name: "HighlightRangeMode" name: "HighlightRangeMode"
values: { values: {
@@ -1637,6 +1685,15 @@ Module {
Method { name: "incrementCurrentIndex" } Method { name: "incrementCurrentIndex" }
Method { name: "decrementCurrentIndex" } Method { name: "decrementCurrentIndex" }
} }
Component {
name: "QDeclarativePathViewAttached"
prototype: "QObject"
Property { name: "view"; type: "QDeclarativePathView"; isReadonly: true; isPointer: true }
Property { name: "isCurrentItem"; type: "bool"; isReadonly: true }
Property { name: "onPath"; type: "bool"; isReadonly: true }
Signal { name: "currentItemChanged" }
Signal { name: "pathChanged" }
}
Component { Component {
name: "QDeclarativePauseAnimation" name: "QDeclarativePauseAnimation"
prototype: "QDeclarativeAbstractAnimation" prototype: "QDeclarativeAbstractAnimation"
@@ -2623,9 +2680,16 @@ Module {
"Qt/VisualItemModel 4.7", "Qt/VisualItemModel 4.7",
"QtQuick/VisualItemModel 1.0" "QtQuick/VisualItemModel 1.0"
] ]
attachedType: "QDeclarativeVisualItemModelAttached"
Property { name: "children"; type: "QDeclarativeItem"; isList: true; isReadonly: true } Property { name: "children"; type: "QDeclarativeItem"; isList: true; isReadonly: true }
Signal { name: "childrenChanged" } Signal { name: "childrenChanged" }
} }
Component {
name: "QDeclarativeVisualItemModelAttached"
prototype: "QObject"
Property { name: "index"; type: "int"; isReadonly: true }
Signal { name: "indexChanged" }
}
Component { Component {
name: "QDeclarativeVisualModel" name: "QDeclarativeVisualModel"
prototype: "QObject" prototype: "QObject"

View File

@@ -67,6 +67,8 @@ void collectReachableMetaObjects(QObject *object, QSet<const QMetaObject *> *met
void collectReachableMetaObjects(const QDeclarativeType *ty, QSet<const QMetaObject *> *metas) void collectReachableMetaObjects(const QDeclarativeType *ty, QSet<const QMetaObject *> *metas)
{ {
collectReachableMetaObjects(ty->metaObject(), metas); collectReachableMetaObjects(ty->metaObject(), metas);
if (ty->attachedPropertiesType())
collectReachableMetaObjects(ty->attachedPropertiesType(), metas);
} }
/* We want to add the MetaObject for 'Qt' to the list, this is a /* We want to add the MetaObject for 'Qt' to the list, this is a
@@ -219,6 +221,11 @@ public:
qSort(exports); qSort(exports);
qml->writeArrayBinding(QLatin1String("exports"), exports); qml->writeArrayBinding(QLatin1String("exports"), exports);
if (const QMetaObject *attachedType = (*qmlTypes.begin())->attachedPropertiesType()) {
qml->writeScriptBinding(QLatin1String("attachedType"), enquote(
convertToId(attachedType->className())));
}
} }
for (int index = meta->enumeratorOffset(); index < meta->enumeratorCount(); ++index) for (int index = meta->enumeratorOffset(); index < meta->enumeratorCount(); ++index)

View File

@@ -187,6 +187,13 @@ FakeMetaMethod FakeMetaObject::method(int index) const
QString FakeMetaObject::defaultPropertyName() const QString FakeMetaObject::defaultPropertyName() const
{ return m_defaultPropertyName; } { return m_defaultPropertyName; }
void FakeMetaObject::setDefaultPropertyName(const QString &defaultPropertyName)
void FakeMetaObject::setDefaultPropertyName(const QString defaultPropertyName)
{ m_defaultPropertyName = defaultPropertyName; } { m_defaultPropertyName = defaultPropertyName; }
QString FakeMetaObject::attachedTypeName() const
{ return m_attachedTypeName; }
void FakeMetaObject::setAttachedTypeName(const QString &name)
{ m_attachedTypeName = name; }
bool FakeMetaObject::Export::isValid() const
{ return !type.isEmpty(); }

View File

@@ -148,6 +148,7 @@ private:
QHash<QString, int> m_propNameToIdx; QHash<QString, int> m_propNameToIdx;
QList<FakeMetaMethod> m_methods; QList<FakeMetaMethod> m_methods;
QString m_defaultPropertyName; QString m_defaultPropertyName;
QString m_attachedTypeName;
public: public:
FakeMetaObject(); FakeMetaObject();
@@ -181,7 +182,10 @@ public:
FakeMetaMethod method(int index) const; FakeMetaMethod method(int index) const;
QString defaultPropertyName() const; QString defaultPropertyName() const;
void setDefaultPropertyName(const QString defaultPropertyName); void setDefaultPropertyName(const QString &defaultPropertyName);
QString attachedTypeName() const;
void setAttachedTypeName(const QString &name);
}; };
} // namespace LanguageUtils } // namespace LanguageUtils

View File

@@ -158,8 +158,10 @@ void TypeDescriptionReader::readComponent(UiObjectDefinition *ast)
fmo->setDefaultPropertyName(readStringBinding(script)); fmo->setDefaultPropertyName(readStringBinding(script));
} else if (name == "exports") { } else if (name == "exports") {
readExports(script, fmo); readExports(script, fmo);
} else if (name == "attachedType") {
fmo->setAttachedTypeName(readStringBinding(script));
} else { } else {
addError(script->firstSourceLocation(), "Expected only name, prototype, defaultProperty and exports script bindings"); addError(script->firstSourceLocation(), "Expected only name, prototype, defaultProperty, attachedType and exports script bindings");
return; return;
} }
} else { } else {