summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-14 05:18:52 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-14 05:18:52 (GMT)
commit8e9a0667ee8856558694d9d661585d36f7f41da8 (patch)
tree7f71e351fbc4cd7d45186076c9450065428c1f38 /src/declarative
parentc84227fbd5e068859f8de15e4c522b076885b9dc (diff)
parent8a8ddeb9e29abb0734bb7cd703de8302c3e1a506 (diff)
downloadQt-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')
-rw-r--r--src/declarative/extra/qmlfontloader.cpp14
-rw-r--r--src/declarative/fx/qfxborderimage.cpp14
-rw-r--r--src/declarative/fx/qfxpixmapcache.cpp18
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp18
-rw-r--r--src/declarative/qml/qmlengine.cpp13
-rw-r--r--src/declarative/qml/qmlerror.cpp1
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp1
7 files changed, 65 insertions, 14 deletions
diff --git a/src/declarative/extra/qmlfontloader.cpp b/src/declarative/extra/qmlfontloader.cpp
index 66c8567..4a447de 100644
--- a/src/declarative/extra/qmlfontloader.cpp
+++ b/src/declarative/extra/qmlfontloader.cpp
@@ -92,6 +92,15 @@ QmlFontLoader::~QmlFontLoader()
{
}
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+
/*!
\qmlproperty url FontLoader::source
The url of the font to load.
@@ -112,8 +121,9 @@ void QmlFontLoader::setSource(const QUrl &url)
d->status = Loading;
emit statusChanged();
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- if (d->url.scheme() == QLatin1String("file")) {
- QFile file(d->url.toLocalFile());
+ QString lf = toLocalFileOrQrc(d->url);
+ if (!lf.isEmpty()) {
+ QFile file(lf);
file.open(QIODevice::ReadOnly);
QByteArray ba = file.readAll();
d->addFontToDatabase(ba);
diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp
index 8f98a11..f1574e5 100644
--- a/src/declarative/fx/qfxborderimage.cpp
+++ b/src/declarative/fx/qfxborderimage.cpp
@@ -138,6 +138,15 @@ QFxBorderImage::~QFxBorderImage()
The URL may be absolute, or relative to the URL of the component.
*/
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+
void QFxBorderImage::setSource(const QUrl &url)
{
Q_D(QFxBorderImage);
@@ -180,8 +189,9 @@ void QFxBorderImage::setSource(const QUrl &url)
d->status = Loading;
if (d->url.path().endsWith(QLatin1String(".sci"))) {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- if (d->url.scheme() == QLatin1String("file")) {
- QFile file(d->url.toLocalFile());
+ QString lf = toLocalFileOrQrc(d->url);
+ if (!lf.isEmpty()) {
+ QFile file(lf);
file.open(QIODevice::ReadOnly);
setGridScaledImage(QFxGridScaledImage(&file));
} else
diff --git a/src/declarative/fx/qfxpixmapcache.cpp b/src/declarative/fx/qfxpixmapcache.cpp
index 80b5011..13e1b16 100644
--- a/src/declarative/fx/qfxpixmapcache.cpp
+++ b/src/declarative/fx/qfxpixmapcache.cpp
@@ -124,6 +124,14 @@ static bool readImage(QIODevice *dev, QPixmap *pixmap)
This class is NOT reentrant.
*/
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
/*!
Finds the cached pixmap corresponding to \a url.
A previous call to get() must have requested the URL,
@@ -142,8 +150,9 @@ bool QFxPixmapCache::find(const QUrl& url, QPixmap *pixmap)
bool ok = true;
if (!QPixmapCache::find(key,pixmap)) {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- if (url.scheme()==QLatin1String("file")) {
- QFile f(url.toLocalFile());
+ QString lf = toLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
+ QFile f(lf);
if (f.open(QIODevice::ReadOnly)) {
if (!readImage(&f, pixmap)) {
qWarning() << "Format error loading" << url;
@@ -207,10 +216,11 @@ bool QFxPixmapCache::find(const QUrl& url, QPixmap *pixmap)
QNetworkReply *QFxPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap)
{
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- if (url.scheme()==QLatin1String("file")) {
+ QString lf = toLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
QString key = url.toString();
if (!QPixmapCache::find(key,pixmap)) {
- QFile f(url.toLocalFile());
+ QFile f(lf);
if (f.open(QIODevice::ReadOnly)) {
if (!readImage(&f, pixmap)) {
qWarning() << "Format error loading" << url;
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);