diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-07-21 22:41:59 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-07-21 22:41:59 (GMT) |
commit | 2a24201fcfac0ca57afefad836d62308262dafdf (patch) | |
tree | 989f5335627c2b908d9b8b325f62f3934e0e1866 /src/declarative | |
parent | 4dc3189aea1c619828abdf87e553587c656ede63 (diff) | |
download | Qt-2a24201fcfac0ca57afefad836d62308262dafdf.zip Qt-2a24201fcfac0ca57afefad836d62308262dafdf.tar.gz Qt-2a24201fcfac0ca57afefad836d62308262dafdf.tar.bz2 |
Move errorsString to QmlBindableComponent because it's for use in script
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qmlbindablecomponent.cpp | 25 | ||||
-rw-r--r-- | src/declarative/qml/qmlbindablecomponent.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent.cpp | 24 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent.h | 1 |
4 files changed, 26 insertions, 25 deletions
diff --git a/src/declarative/qml/qmlbindablecomponent.cpp b/src/declarative/qml/qmlbindablecomponent.cpp index ed9924a..6938592 100644 --- a/src/declarative/qml/qmlbindablecomponent.cpp +++ b/src/declarative/qml/qmlbindablecomponent.cpp @@ -85,6 +85,31 @@ QScriptValue QmlBindableComponent::createObject() return QmlEngine::qmlScriptObject(ret, d->engine); } +/*! + Return the list of errors that occured during the last compile or create + operation, as a single string. An empty string is returned if isError() + is not set. + + This function is similar to errors(), except more useful when called from + QML. C++ code should usually use errors(). + + \sa errors() +*/ +QString QmlBindableComponent::errorsString() const +{ + Q_D(const QmlBindableComponent); + QString ret; + if(!isError()) + return ret; + foreach(const QmlError &e, d->errors) { + ret += e.url().toString() + QLatin1String(":") + + QString::number(e.line()) + QLatin1String(" ") + + e.description() + QLatin1String("\n"); + } + return ret; +} + + void QmlBindableComponent::statusChange(QmlComponent::Status newStatus) { Q_D(QmlBindableComponent); diff --git a/src/declarative/qml/qmlbindablecomponent.h b/src/declarative/qml/qmlbindablecomponent.h index 2b3e0ce..43e3537 100644 --- a/src/declarative/qml/qmlbindablecomponent.h +++ b/src/declarative/qml/qmlbindablecomponent.h @@ -72,6 +72,7 @@ public: Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged); Q_INVOKABLE QScriptValue createObject(); + Q_INVOKABLE QString errorsString() const; void setContext(QmlContext* c); Q_SIGNALS: diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 0fdba64..2092ef5 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -390,30 +390,6 @@ QList<QmlError> QmlComponent::errors() const } /*! - Return the list of errors that occured during the last compile or create - operation, as a single string. An empty string is returned if isError() - is not set. - - This function is similar to errors(), except more useful when called from - QML. C++ code should usually use errors(). - - \sa errors() -*/ -QString QmlComponent::errorsString() const -{ - Q_D(const QmlComponent); - QString ret; - if(!isError()) - return ret; - foreach(const QmlError &e, d->errors) { - ret += e.url().toString() + QLatin1String(":") + - QString::number(e.line()) + QLatin1String(" ") + - e.description() + QLatin1String("\n"); - } - return ret; -} - -/*! Return the component URL. This is the URL passed to either the constructor, or the loadUrl() or setData() methods. */ diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h index 45b26eb..60b7ccd 100644 --- a/src/declarative/qml/qmlcomponent.h +++ b/src/declarative/qml/qmlcomponent.h @@ -83,7 +83,6 @@ public: bool isLoading() const; QList<QmlError> errors() const; - Q_INVOKABLE QString errorsString() const; QUrl url() const; |