diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-14 05:18:52 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-14 05:18:52 (GMT) |
commit | 8e9a0667ee8856558694d9d661585d36f7f41da8 (patch) | |
tree | 7f71e351fbc4cd7d45186076c9450065428c1f38 /src/declarative/qml | |
parent | c84227fbd5e068859f8de15e4c522b076885b9dc (diff) | |
parent | 8a8ddeb9e29abb0734bb7cd703de8302c3e1a506 (diff) | |
download | Qt-8e9a0667ee8856558694d9d661585d36f7f41da8.zip Qt-8e9a0667ee8856558694d9d661585d36f7f41da8.tar.gz Qt-8e9a0667ee8856558694d9d661585d36f7f41da8.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager.cpp | 18 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 13 | ||||
-rw-r--r-- | src/declarative/qml/qmlerror.cpp | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 1 |
4 files changed, 27 insertions, 6 deletions
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 13bd02c..3c76344 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -262,13 +262,22 @@ void QmlCompositeTypeManager::resourceReplyFinished() reply->deleteLater(); } +static QString toLocalFileOrQrc(const QUrl& url) +{ + QString r = url.toLocalFile(); + if (r.isEmpty() && url.scheme() == QLatin1String("qrc")) + r = QLatin1Char(':') + url.path(); + return r; +} + void QmlCompositeTypeManager::loadResource(QmlCompositeTypeResource *resource) { QUrl url(resource->url); - if (url.scheme() == QLatin1String("file")) { + QString lf = toLocalFileOrQrc(url); + if (!lf.isEmpty()) { - QFile file(url.toLocalFile()); + QFile file(lf); if (file.open(QFile::ReadOnly)) { resource->data = file.readAll(); resource->status = QmlCompositeTypeResource::Complete; @@ -290,9 +299,10 @@ void QmlCompositeTypeManager::loadSource(QmlCompositeTypeData *unit) { QUrl url(unit->imports.baseUrl()); - if (url.scheme() == QLatin1String("file")) { + QString lf = toLocalFileOrQrc(url); + if (!lf.isEmpty()) { - QFile file(url.toLocalFile()); + QFile file(lf); if (file.open(QFile::ReadOnly)) { QByteArray data = file.readAll(); setData(unit, data, url); diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 4dbc336..f0ecf1d 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -959,6 +959,15 @@ QVariant QmlScriptClass::toVariant(QmlEngine *engine, const QScriptValue &val) return QVariant(); } +// XXX this beyonds in QUrl::toLocalFile() +static QString toLocalFileOrQrc(const QUrl& url) +{ + QString r = url.toLocalFile(); + if (r.isEmpty() && url.scheme() == QLatin1String("qrc")) + r = QLatin1Char(':') + url.path(); + return r; +} + ///////////////////////////////////////////////////////////// struct QmlEnginePrivate::ImportedNamespace { QStringList urls; @@ -989,7 +998,7 @@ struct QmlEnginePrivate::ImportedNamespace { QUrl url = QUrl(urls.at(i) + QLatin1String("/") + QString::fromUtf8(type) + QLatin1String(".qml")); if (vmaj || vmin) { // Check version file - XXX cache these in QmlEngine! - QFile qmldir(QUrl(urls.at(i)+QLatin1String("/qmldir")).toLocalFile()); + QFile qmldir(toLocalFileOrQrc(QUrl(urls.at(i)+QLatin1String("/qmldir")))); if (qmldir.open(QIODevice::ReadOnly)) { do { QByteArray lineba = qmldir.readLine(); @@ -1020,7 +1029,7 @@ struct QmlEnginePrivate::ImportedNamespace { } } else { // XXX search non-files too! (eg. zip files, see QT-524) - QFileInfo f(url.toLocalFile()); + QFileInfo f(toLocalFileOrQrc(url)); if (f.exists()) { if (url_return) *url_return = url; diff --git a/src/declarative/qml/qmlerror.cpp b/src/declarative/qml/qmlerror.cpp index 5ee9144..514fe44 100644 --- a/src/declarative/qml/qmlerror.cpp +++ b/src/declarative/qml/qmlerror.cpp @@ -201,6 +201,7 @@ QDebug operator<<(QDebug debug, const QmlError &error) if (f.open(QIODevice::ReadOnly)) { QByteArray data = f.readAll(); QTextStream stream(data, QIODevice::ReadOnly); + stream.setCodec("UTF-8"); const QString code = stream.readAll(); const QStringList lines = code.split(QLatin1Char('\n')); diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 9cc12b3..6e5f315 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -870,6 +870,7 @@ bool QmlScriptParser::parse(const QByteArray &qmldata, const QUrl &url) const QString fileName = url.toString(); QTextStream stream(qmldata, QIODevice::ReadOnly); + stream.setCodec("UTF-8"); const QString code = stream.readAll(); data = new QmlScriptParserJsASTData(fileName); |