summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-24 01:11:57 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-24 02:37:36 (GMT)
commitb933f40a39a000ee79e80564b529a3b72365cfae (patch)
tree1f10d6fade41c633844dfaba705c9eda46e67c56 /src/declarative
parent80f946828264c8e9e9213e0b8760f772090c979f (diff)
downloadQt-b933f40a39a000ee79e80564b529a3b72365cfae.zip
Qt-b933f40a39a000ee79e80564b529a3b72365cfae.tar.gz
Qt-b933f40a39a000ee79e80564b529a3b72365cfae.tar.bz2
Move copies of toLocalFileOrQrc() to QDeclarativeEnginePrivate
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp14
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp20
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp11
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp21
-rw-r--r--src/declarative/qml/qdeclarativeinclude.cpp14
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp10
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp12
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp12
10 files changed, 34 insertions, 94 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
index c81c2d2..32a6321 100644
--- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
@@ -45,7 +45,7 @@
#ifndef QT_NO_MOVIE
#include <qdeclarativeinfo.h>
-#include <qdeclarativeengine.h>
+#include <private/qdeclarativeengine_p.h>
#include <QMovie>
#include <QNetworkRequest>
@@ -180,14 +180,6 @@ int QDeclarativeAnimatedImage::frameCount() const
return d->_movie->frameCount();
}
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
void QDeclarativeAnimatedImage::setSource(const QUrl &url)
{
Q_D(QDeclarativeAnimatedImage);
@@ -209,7 +201,7 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url)
d->status = Null;
} else {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
//### should be unified with movieRequestFinished
d->_movie = new QMovie(lf);
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
index 229e15b..1f1e453 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -42,8 +42,8 @@
#include "private/qdeclarativeborderimage_p.h"
#include "private/qdeclarativeborderimage_p_p.h"
-#include <qdeclarativeengine.h>
#include <qdeclarativeinfo.h>
+#include <private/qdeclarativeengine_p.h>
#include <QNetworkRequest>
#include <QNetworkReply>
@@ -152,16 +152,6 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage()
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 QDeclarativeBorderImage::setSource(const QUrl &url)
{
Q_D(QDeclarativeBorderImage);
@@ -210,7 +200,7 @@ void QDeclarativeBorderImage::load()
d->status = Loading;
if (d->url.path().endsWith(QLatin1String("sci"))) {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(d->url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
QFile file(lf);
file.open(QIODevice::ReadOnly);
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index e4405f7..26b2a9b 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -334,23 +334,11 @@ void QDeclarativeCompositeTypeManager::resourceReplyFinished()
reply->deleteLater();
}
-// XXX this beyonds in QUrl::toLocalFile()
-// WARNING, there is a copy of this function in qdeclarativeengine.cpp
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
- if (url.authority().isEmpty())
- return QLatin1Char(':') + url.path();
- return QString();
- }
- return url.toLocalFile();
-}
-
void QDeclarativeCompositeTypeManager::loadResource(QDeclarativeCompositeTypeResource *resource)
{
QUrl url(resource->url);
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
QFile file(lf);
@@ -378,7 +366,7 @@ void QDeclarativeCompositeTypeManager::loadSource(QDeclarativeCompositeTypeData
{
QUrl url(unit->imports.baseUrl());
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
QFile file(lf);
@@ -716,7 +704,7 @@ void QDeclarativeCompositeTypeManager::compile(QDeclarativeCompositeTypeData *un
foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
if (imp.type == QDeclarativeScriptParser::Import::File && imp.qualifier.isEmpty()) {
QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir")));
- if (toLocalFileOrQrc(importUrl).isEmpty()) {
+ if (QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty()) {
// Import requires remote qmldir
resourceList.prepend(importUrl);
}
@@ -726,7 +714,7 @@ void QDeclarativeCompositeTypeManager::compile(QDeclarativeCompositeTypeData *un
QUrl importUrl;
if (!unit->imports.baseUrl().scheme().isEmpty())
importUrl = unit->imports.baseUrl().resolved(QUrl(QLatin1String("qmldir")));
- if (!importUrl.scheme().isEmpty() && toLocalFileOrQrc(importUrl).isEmpty())
+ if (!importUrl.scheme().isEmpty() && QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty())
resourceList.prepend(importUrl);
for (int ii = 0; ii < resourceList.count(); ++ii) {
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 4a5be13..df9aa59 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1021,6 +1021,17 @@ QDeclarativeContextData *QDeclarativeEnginePrivate::getContext(QScriptContext *c
return contextClass->contextFromValue(scopeNode);
}
+
+QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
+{
+ if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
+ if (url.authority().isEmpty())
+ return QLatin1Char(':') + url.path();
+ return QString();
+ }
+ return url.toLocalFile();
+}
+
/*!
\qmlmethod object Qt::createComponent(url)
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 411f780..804476c 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -315,6 +315,8 @@ public:
static QDeclarativeEngine *get(QDeclarativeEnginePrivate *p) { return p->q_func(); }
QDeclarativeContextData *getContext(QScriptContext *);
+ static QString urlToLocalFileOrQrc(const QUrl& url);
+
static void defineModule();
};
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 0c87671..c658a31 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -49,22 +49,13 @@
#include <QtDeclarative/qdeclarativeextensioninterface.h>
#include <private/qdeclarativeglobal_p.h>
#include <private/qdeclarativetypenamecache_p.h>
+#include <private/qdeclarativeengine_p.h>
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
- if (url.authority().isEmpty())
- return QLatin1Char(':') + url.path();
- return QString();
- }
- return url.toLocalFile();
-}
-
static bool greaterThan(const QString &s1, const QString &s2)
{
return s1 > s2;
@@ -262,7 +253,7 @@ bool QDeclarativeImportedNamespace::find_helper(int i, const QByteArray& type, i
if (!typeWasDeclaredInQmldir && !isLibrary.at(i)) {
// XXX search non-files too! (eg. zip files, see QT-524)
- QFileInfo f(toLocalFileOrQrc(url));
+ QFileInfo f(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url));
if (f.exists()) {
if (base && *base == url) { // no recursion
if (typeRecursionDetected)
@@ -415,15 +406,15 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
if (importType == QDeclarativeScriptParser::Import::File && qmldircomponents.isEmpty()) {
QUrl importUrl = base.resolved(QUrl(uri + QLatin1String("/qmldir")));
- QString localFileOrQrc = toLocalFileOrQrc(importUrl);
+ QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl);
if (!localFileOrQrc.isEmpty()) {
- QString dir = toLocalFileOrQrc(base.resolved(QUrl(uri)));
+ QString dir = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri)));
if (dir.isEmpty() || !QDir().exists(dir)) {
if (errorString)
*errorString = QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri_arg);
return false; // local import dirs must exist
}
- uri = resolvedUri(toLocalFileOrQrc(base.resolved(QUrl(uri))), database);
+ uri = resolvedUri(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri))), database);
if (uri.endsWith(QLatin1Char('/')))
uri.chop(1);
if (QFile::exists(localFileOrQrc)) {
@@ -433,7 +424,7 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
} else {
if (prefix.isEmpty()) {
// directory must at least exist for valid import
- QString localFileOrQrc = toLocalFileOrQrc(base.resolved(QUrl(uri)));
+ QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri)));
if (localFileOrQrc.isEmpty() || !QDir().exists(localFileOrQrc)) {
if (errorString) {
if (localFileOrQrc.isEmpty())
diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp
index 4cde54b..388f252 100644
--- a/src/declarative/qml/qdeclarativeinclude.cpp
+++ b/src/declarative/qml/qdeclarativeinclude.cpp
@@ -172,16 +172,6 @@ void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback
}
}
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- if (url.scheme() == QLatin1String("qrc")) {
- if (url.authority().isEmpty())
- return QLatin1Char(':') + url.path();
- return QString();
- }
- return url.toLocalFile();
-}
-
QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *engine)
{
if (ctxt->argumentCount() == 0)
@@ -200,7 +190,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e
urlString = url.toString();
}
- QString localFile = toLocalFileOrQrc(url);
+ QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
QScriptValue func = ctxt->argument(1);
if (!func.isFunction())
@@ -269,7 +259,7 @@ QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEn
urlString = url.toString();
}
- QString localFile = toLocalFileOrQrc(url);
+ QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
QScriptValue func = ctxt->argument(1);
if (!func.isFunction())
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index dc5bc6e..1550351 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -275,20 +275,12 @@ void QDeclarativeWorkerScriptEnginePrivate::processMessage(int id, const QVarian
}
}
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
{
if (url.isRelative())
return;
- QString fileName = toLocalFileOrQrc(url);
+ QString fileName = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
QFile f(fileName);
if (f.open(QIODevice::ReadOnly)) {
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index adfcd62..c73f827 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -53,6 +53,7 @@
#include <QFontDatabase>
#include <private/qobject_p.h>
+#include <private/qdeclarativeengine_p.h>
#include <qdeclarativeinfo.h>
QT_BEGIN_NAMESPACE
@@ -98,15 +99,6 @@ QDeclarativeFontLoader::~QDeclarativeFontLoader()
{
}
-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.
@@ -127,7 +119,7 @@ void QDeclarativeFontLoader::setSource(const QUrl &url)
d->status = Loading;
emit statusChanged();
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(d->url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
int id = QFontDatabase::addApplicationFont(lf);
if (id != -1) {
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index d9ce42c..a4ddf46 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -66,14 +66,6 @@ static const int maxImageRequestCount = 8;
QT_BEGIN_NAMESPACE
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
class QDeclarativeImageReaderEvent : public QEvent
{
public:
@@ -269,7 +261,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event)
}
QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image));
} else {
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
// Image is local - load/decode immediately
QImage image;
@@ -613,7 +605,7 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
if (!async) {
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
status = QDeclarativePixmapReply::Ready;
if (!QPixmapCache::find(strKey,pixmap)) {