summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecomponent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qdeclarativecomponent.cpp')
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp81
1 files changed, 78 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index c697367..d8bbb70 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -154,7 +154,7 @@ int statusId = qRegisterMetaType<QDeclarativeComponent::Status>("QDeclarativeCom
\value Null This QDeclarativeComponent has no data. Call loadUrl() or setData() to add QML content.
\value Ready This QDeclarativeComponent is ready and create() may be called.
\value Loading This QDeclarativeComponent is loading network data.
- \value Error An error has occured. Calling errorDescription() to retrieve a description.
+ \value Error An error has occured. Call errors() to retrieve a list of \{QDeclarativeError}{errors}.
*/
void QDeclarativeComponentPrivate::typeDataReady()
@@ -239,6 +239,18 @@ QDeclarativeComponent::~QDeclarativeComponent()
}
/*!
+ \qmlproperty enumeration Component::status
+ This property holds the status of component loading. It can be one of:
+ \list
+ \o Null - no data is available for the component
+ \o Ready - the component has been loaded, and can be used to create instances.
+ \o Loading - the component is currently being loaded
+ \o Error - an error occurred while loading the component.
+ Calling errorsString() will provide a human-readable description of any errors.
+ \endlist
+ */
+
+/*!
\property QDeclarativeComponent::status
The component's current \l{QDeclarativeComponent::Status} {status}.
*/
@@ -257,6 +269,14 @@ QDeclarativeComponent::Status QDeclarativeComponent::status() const
}
/*!
+ \qmlproperty bool Component::isNull
+
+ Is true if the component is in the Null state, false otherwise.
+
+ Equivalent to status == Component.Null.
+*/
+
+/*!
\property QDeclarativeComponent::isNull
Is true if the component is in the Null state, false otherwise.
@@ -269,6 +289,14 @@ bool QDeclarativeComponent::isNull() const
}
/*!
+ \qmlproperty bool Component::isReady
+
+ Is true if the component is in the Ready state, false otherwise.
+
+ Equivalent to status == Component.Ready.
+*/
+
+/*!
\property QDeclarativeComponent::isReady
Is true if the component is in the Ready state, false otherwise.
@@ -281,6 +309,16 @@ bool QDeclarativeComponent::isReady() const
}
/*!
+ \qmlproperty bool Component::isError
+
+ Is true if the component is in the Error state, false otherwise.
+
+ Equivalent to status == Component.Error.
+
+ Calling errorsString() will provide a human-readable description of any errors.
+*/
+
+/*!
\property QDeclarativeComponent::isError
Is true if the component is in the Error state, false otherwise.
@@ -293,6 +331,14 @@ bool QDeclarativeComponent::isError() const
}
/*!
+ \qmlproperty bool Component::isLoading
+
+ Is true if the component is in the Loading state, false otherwise.
+
+ Equivalent to status == Component::Loading.
+*/
+
+/*!
\property QDeclarativeComponent::isLoading
Is true if the component is in the Loading state, false otherwise.
@@ -305,6 +351,12 @@ bool QDeclarativeComponent::isLoading() const
}
/*!
+ \qmlproperty real Component::progress
+ The progress of loading the component, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+*/
+
+/*!
\property QDeclarativeComponent::progress
The progress of loading the component, from 0.0 (nothing loaded)
to 1.0 (finished).
@@ -490,6 +542,17 @@ QList<QDeclarativeError> QDeclarativeComponent::errors() const
}
/*!
+ \qmlmethod string Component::errorsString()
+
+ Returns a human-readable description of any errors.
+
+ The string includes the file, location, and description of each error.
+ If multiple errors are present they are separated by a newline character.
+
+ If no errors are present, an empty string is returned.
+*/
+
+/*!
\internal
errorsString is only meant as a way to get the errors in script
*/
@@ -508,6 +571,11 @@ QString QDeclarativeComponent::errorsString() const
}
/*!
+ \qmlproperty url Component::url
+ The component URL. This is the URL that was used to construct the component.
+*/
+
+/*!
\property QDeclarativeComponent::url
The component URL. This is the URL passed to either the constructor,
or the loadUrl() or setData() methods.
@@ -527,6 +595,13 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
}
/*!
+ \qmlmethod object Component::createObject()
+ Returns an object instance from this component, or null if object creation fails.
+
+ The object will be created in the same context as the component was created in.
+*/
+
+/*!
\internal
A version of create which returns a scriptObject, for use in script
*/
@@ -535,10 +610,10 @@ QScriptValue QDeclarativeComponent::createObject()
Q_D(QDeclarativeComponent);
QDeclarativeContext* ctxt = creationContext();
if(!ctxt)
- return QScriptValue();
+ return QScriptValue(QScriptValue::NullValue);
QObject* ret = create(ctxt);
if (!ret)
- return QScriptValue();
+ return QScriptValue(QScriptValue::NullValue);
QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine);
QDeclarativeData::get(ret, true)->setImplicitDestructible();
return priv->objectClass->newQObject(ret, QMetaType::QObjectStar);