43 #include "private/qdeclarativecomponent_p.h" 45 #include "private/qdeclarativecompiler_p.h" 46 #include "private/qdeclarativecontext_p.h" 47 #include "private/qdeclarativeengine_p.h" 48 #include "private/qdeclarativevme_p.h" 51 #include "private/qdeclarativebinding_p.h" 52 #include "private/qdeclarativebinding_p_p.h" 53 #include "private/qdeclarativeglobal_p.h" 54 #include "private/qdeclarativescriptparser_p.h" 55 #include "private/qdeclarativedebugtrace_p.h" 56 #include "private/qdeclarativeenginedebugservice_p.h" 57 #include <QtScript/qscriptvalueiterator.h> 60 #include <QStringList> 61 #include <QtCore/qdebug.h> 62 #include <QApplication> 265 emit q->statusChanged(q->status());
274 emit q->progressChanged(p);
321 if (
d->state.completePending) {
322 qWarning(
"QDeclarativeComponent: Component destroyed while completion pending");
327 d->typeData->unregisterCallback(
d);
328 d->typeData->release();
362 else if (!
d->state.errors.isEmpty())
364 else if (
d->engine &&
d->cc)
520 d->fromTypeData(typeData);
522 d->typeData = typeData;
523 d->typeData->registerCallback(
d);
538 if(
d->creationContext)
539 return d->creationContext->asQDeclarativeContext();
558 d->url =
d->engine->baseUrl().resolved(url);
572 d->fromTypeData(data);
576 d->typeData->registerCallback(
d);
592 return d->state.errors;
727 qmlInfo(
this) <<
tr(
"createObject: value is not an object");
730 return d->createObject(parent, valuemap);
738 ctxt = engine->rootContext();
741 QObject* ret = q->beginCreate(ctxt);
751 bool needParent =
false;
753 for (
int ii = 0; ii < functions.
count(); ++ii) {
764 qWarning(
"QDeclarativeComponent: Created graphical object was not placed in the graphics scene.");
783 subProp = propName.
mid(lastIndex, index - lastIndex);
785 lastIndex = index + 1;
813 context =
d->engine->rootContext();
860 qWarning(
"QDeclarativeComponent: Cannot create a component in a null context");
865 qWarning(
"QDeclarativeComponent: Cannot create a component in an invalid context");
869 if (context->
engine != engine) {
870 qWarning(
"QDeclarativeComponent: Must create component in context from the same QDeclarativeEngine");
874 if (state.completePending) {
875 qWarning(
"QDeclarativeComponent: Cannot create new component instance before completing the previous");
880 qWarning(
"QDeclarativeComponent: Component is not ready");
897 Q_ASSERT((state != 0) ^ (errors != 0));
906 ctxt->
url = component->
url;
910 if (componentCreationContext && start != -1)
919 QObject *rv = vme.
run(ctxt, component, start, count, bindings);
922 if(errors) *errors = vme.
errors();
991 for (
int jj = 0; jj < bv.
count; ++jj) {
1006 for (
int jj = ps.
count - 1; jj >= 0; --jj) {
1008 if (status && status->
d) {
1020 void *args[] = { 0 };
1033 void *args[] = { 0 };
1050 }
QT_CATCH(
const std::exception&) {
1084 d->completeCreate();
1089 if (state.completePending) {
1091 complete(ep, &state);
1098 :
QObject(parent), prev(0), next(0)
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_INVOKABLE QScriptValue createObject(QObject *parent)
A version of create which returns a scriptObject, for use in script.
QDeclarativeContextData * context
QDeclarativeComponentAttached * next
bool isError() const
Returns true if the status is Error.
Status
Emitted after component "startup" has completed.
static QDeclarativeData * get(const QObject *object, bool create=false)
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue's property with the given name, using the given mode to resolv...
QUrl url() const
Returns the url for the file that caused this error.
#define QT_END_NAMESPACE
This macro expands to.
~QDeclarativeComponentAttached()
QDeclarativeParserStatus ** d
void setDescription(const QString &)
Sets the error description.
QUrl finalUrl() const
Returns the final url of the data.
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
QDeclarativeEngine * engine
void setImplicitDestructible()
#define it(className, varName)
QList< QPair< QDeclarativeGuard< QObject >, int > > finalizedParserStatus
The QByteArray class provides an array of bytes.
QDeclarativeComponentAttached(QObject *parent=0)
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
QDeclarativeComponentAttached * componentAttached
QDeclarativeCompiledData * compiledData() const
void runDeferred(QObject *)
virtual void typeDataReady(QDeclarativeTypeData *)
QString name() const
Returns the name of the last property that was jumped over using next() or previous().
bool isReady() const
Returns true if status() == QDeclarativeComponent::Ready.
void setData(const QByteArray &, const QUrl &baseUrl)
Sets the QDeclarativeComponent to use the given QML data.
QList< QDeclarativeError > errors
QDeclarativeComponentAttached ** prev
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
bool isCompleteOrError() const
Returns true if the status is Complete or Error.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QList< QDeclarativeError > errors() const
void add(QDeclarativeComponentAttached **a)
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
int count() const
Same as size().
QObject * beginCreate(QDeclarativeContextData *, const QBitField &)
QScriptValue createObject(QObject *publicParent, const QScriptValue valuemap)
The QUrl class provides a convenient interface for working with URLs.
QDeclarativeTypeLoader typeLoader
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
virtual QObject * create(QDeclarativeContext *context=0)
Create an object instance from this component.
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
void loadUrl(const QUrl &url)
Load the QDeclarativeComponent from the provided url.
QList< QPair< QDeclarativeGuard< QObject >, int > > finalizedParserStatus
QDeclarativeTypeNameCache * imports
QDeclarativeComponent(QObject *parent=0)
void setParent(QObject *)
Makes the object a child of parent.
qreal progress() const
Returns the data download progress from 0 to 1.
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
QList< QDeclarativeEnginePrivate::SimpleList< QDeclarativeParserStatus > > parserStatus
void append(const T &t)
Inserts value at the end of the list.
void setParent(QDeclarativeContextData *)
QDeclarativeContextPrivate * asQDeclarativeContextPrivate()
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QDeclarativeComponent class encapsulates a QML component definition.
QList< QDeclarativeError > errors() const
Return the list of errors that occurred during the last compile or create operation.
The QDeclarativeParserStatus class provides updates on the QML parser state.
QDeclarativeCompiledData * cc
const T & at(int i) const
Returns the item at index position i in the list.
QString description() const
Returns the error description.
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void unregisterCallback(TypeDataCallback *)
virtual QObject * beginCreate(QDeclarativeContext *)
This method provides more advanced control over component instance creation.
The QDeclarativeError class encapsulates a QML error.
void fromTypeData(QDeclarativeTypeData *data)
QObject * run(QDeclarativeContextData *, QDeclarativeCompiledData *, int start=-1, int count=-1, const QBitField &=QBitField())
void clear()
Removes all items from the list.
static qreal component(const QPointF &point, unsigned int i)
static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state)
static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, ConstructionState *state)
QList< SimpleList< QDeclarativeAbstractBinding > > bindValues
int line() const
Returns the error line number.
bool isLoading() const
Returns true if status() == QDeclarativeComponent::Loading.
QDeclarativeObjectScriptClass * objectClass
QList< QPointer< QObject > > instances
static void endRange(RangeType)
static void startRange(RangeType)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
QString scheme() const
Returns the scheme of the URL.
static QDeclarativeComponentAttached * qmlAttachedProperties(QObject *)
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue's property with the given name to the given value.
static QObject * begin(QDeclarativeContextData *parentContext, QDeclarativeContextData *componentCreationContext, QDeclarativeCompiledData *component, int start, int count, ConstructionState *state, QList< QDeclarativeError > *errors, const QBitField &bindings=QBitField())
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
Q_DECLARATIVE_EXPORT QDeclarativeEngine * qmlEngine(const QObject *)
QList< QDeclarativeError > errors() const
Return the errors on this blob.
The QDeclarativeEngine class provides an environment for instantiating QML components.
static void clear(SimpleList< QDeclarativeAbstractBinding > &)
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QDeclarativeEngineDebugService * instance()
QDeclarativeDelayedError * erroredBindings
QObject * parent() const
Returns a pointer to the parent object.
QDeclarativeComponentAttached * componentAttached
QScriptValue value() const
Returns the value of the last property that was jumped over using next() or previous().
QDeclarativeComponentAttached * componentAttached
static void rangeData(RangeType, const QString &)
QDeclarativeTypeData * typeData
The QDeclarativeContext class defines a context within a QML engine.
void objectCreated(QDeclarativeEngine *, QObject *)
QDeclarativeTypeData * get(const QUrl &url)
Returns a QDeclarativeTypeData for the specified url.
QList< QDeclarativeEnginePrivate::SimpleList< QDeclarativeAbstractBinding > > bindValues
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
virtual ~QDeclarativeComponent()
Destruct the QDeclarativeComponent.
QDeclarativeTypeNameCache * importCache
bool isArray() const
Returns true if this QScriptValue is an object of the Array class; otherwise returns false...
QDeclarativeInfo qmlInfo(const QObject *me)
Q_INVOKABLE QString errorString() const
virtual void typeDataProgress(QDeclarativeTypeData *, qreal)
bool isError() const
Returns true if status() == QDeclarativeComponent::Error.
void warning(const QDeclarativeError &)
QList< QScriptValue > importedScripts
The QScriptValue class acts as a container for the Qt Script data types.
static QString fileName(const QString &fileUrl)
bool isNull() const
Returns true if status() == QDeclarativeComponent::Null.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void statusChanged(QDeclarativeComponent::Status)
Emitted whenever the component's status changes.
void next()
Advances the iterator by one position.
virtual void completeCreate()
This method provides more advanced control over component instance creation.
QList< SimpleList< QDeclarativeParserStatus > > parserStatus
bool isObject() const
Returns true if this QScriptValue is of the Object type; otherwise returns false. ...
bool hasNext() const
Returns true if there is at least one item ahead of the iterator (i.e.
QDeclarativeContext * creationContext() const
Returns the QDeclarativeContext the component was created in.
void progressChanged(qreal)
Emitted whenever the component's loading progress changes.
QDeclarativeAbstractBinding ** m_mePtr
static QDeclarativeContextData * get(QDeclarativeContext *context)