catch file types by extension too

This commit is contained in:
Marco Martin 2013-09-18 15:41:21 +02:00
parent 6d65ece95a
commit d567b3414b
2 changed files with 20 additions and 9 deletions

View File

@ -42,12 +42,11 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
return path;
}
switch (type) {
case QQmlAbstractUrlInterceptor::QmlFile:
case QQmlAbstractUrlInterceptor::JavaScriptFile:
if (type != QQmlAbstractUrlInterceptor::QmldirFile) {
//asked a file inside a package: let's rewrite the url!
if (path.path().startsWith(m_package.path())) {
qDebug() << "Found URL in package" << path;
//qDebug() << "Found URL in package" << path;
//tries to isolate the relative path asked relative to the contentsPrefixPath: like ui/foo.qml
QString relativePath;
@ -83,10 +82,6 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
}
qWarning() << "WARNING: Access denied for URL" << path;
}
break;
default:
break;
}
return path;

View File

@ -44,7 +44,23 @@ public:
default:
break;
}
return "";
//failed by type, let's try by extension
const QString extension = fileName.mid(fileName.lastIndexOf(".") + 1).toLower();
if (extension == "svg" || extension == "svgz" ||
extension == "png" || extension == "gif" ||
extension == "jpg" || extension == "jpeg") {
return "images";
//FIXME: are those necessary? are they *always* catched by type?
} else if (extension == "js") {
return "scripts";
} else if (extension == "qml") {
return "ui";
//everything else, throw it in "data"
} else {
return "data";
}
}
private: