diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2009-07-16 06:45:36 (GMT) |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2009-07-16 07:23:23 (GMT) |
commit | c02bfff71cc56582e0898864d8c13047fa86756d (patch) | |
tree | b99d7c0e84cdee470e6e38832f9a6d233cdb9e95 /src/declarative/util | |
parent | 14275363e5ae678ca92a6da4778035ca2ad1594c (diff) | |
download | Qt-c02bfff71cc56582e0898864d8c13047fa86756d.zip Qt-c02bfff71cc56582e0898864d8c13047fa86756d.tar.gz Qt-c02bfff71cc56582e0898864d8c13047fa86756d.tar.bz2 |
Add an errors() signal to QFxView
This is in addition to the logging to the console. Discussed with Aaron.
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qfxview.cpp | 64 | ||||
-rw-r--r-- | src/declarative/util/qfxview.h | 2 |
2 files changed, 18 insertions, 48 deletions
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index 41f7db2..821dc25 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -246,44 +246,6 @@ void QFxView::execute() } } -/*! - \internal -*/ -void QFxView::printErrorLine(const QmlError &error) -{ - QUrl url = error.url(); - if (error.line() > 0 && error.column() > 0 && - url.scheme() == QLatin1String("file")) { - QString file = url.toLocalFile(); - QFile f(file); - if (f.open(QIODevice::ReadOnly)) { - QByteArray data = f.readAll(); - QTextStream stream(data, QIODevice::ReadOnly); - const QString code = stream.readAll(); - const QStringList lines = code.split(QLatin1Char('\n')); - - if (lines.count() >= error.line()) { - const QString &line = lines.at(error.line() - 1); - qWarning() << qPrintable(line); - - int column = qMax(0, error.column() - 1); - column = qMin(column, line.length()); - - QByteArray ind; - ind.reserve(column); - for (int i = 0; i < column; ++i) { - const QChar ch = line.at(i); - if (ch.isSpace()) - ind.append(ch.unicode()); - else - ind.append(' '); - } - ind.append('^'); - qWarning() << ind.constData(); - } - } - } -} /*! \internal @@ -292,14 +254,15 @@ void QFxView::continueExecute() { disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); - if (!d->component){ + if (!d->component) { qWarning() << "Error in loading" << d->source; return; } if(d->component->isError()) { - QList<QmlError> errors = d->component->errors(); - foreach (const QmlError &error, errors) { + QList<QmlError> errorList = d->component->errors(); + emit errors(errorList); + foreach (const QmlError &error, errorList) { qWarning() << error; } @@ -309,8 +272,9 @@ void QFxView::continueExecute() QObject *obj = d->component->create(); if(d->component->isError()) { - QList<QmlError> errors = d->component->errors(); - foreach (const QmlError &error, errors) { + QList<QmlError> errorList = d->component->errors(); + emit errors(errorList); + foreach (const QmlError &error, errorList) { qWarning() << error; } @@ -362,6 +326,10 @@ void QFxView::continueExecute() This signal is emitted when the view is resized to \a size. */ +/*! \fn void QFxView::error(const QList<QmlError> &errors) + This signal is emitted when the qml loaded contains errors. + */ + /*! \internal */ @@ -453,8 +421,9 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent) QmlComponent component(&d->engine, qml.toUtf8(), QUrl()); if(d->component->isError()) { - QList<QmlError> errors = d->component->errors(); - foreach (const QmlError &error, errors) { + QList<QmlError> errorList = d->component->errors(); + emit errors(errorList); + foreach (const QmlError &error, errorList) { qWarning() << error; } @@ -463,8 +432,9 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent) QObject *obj = component.create(); if(d->component->isError()) { - QList<QmlError> errors = d->component->errors(); - foreach (const QmlError &error, errors) { + QList<QmlError> errorList = d->component->errors(); + emit errors(errorList); + foreach (const QmlError &error, errorList) { qWarning() << error; } diff --git a/src/declarative/util/qfxview.h b/src/declarative/util/qfxview.h index 05bf005..67de89b 100644 --- a/src/declarative/util/qfxview.h +++ b/src/declarative/util/qfxview.h @@ -88,9 +88,9 @@ public: void dumpRoot(); - static void printErrorLine(const QmlError &); Q_SIGNALS: void sceneResized(QSize size); + void errors(const QList<QmlError> &error); private Q_SLOTS: void continueExecute(); |