diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-08-19 05:56:56 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-08-19 05:56:56 (GMT) |
commit | eeb66cd4a8939cd54b890eb511d99f4a62d3f423 (patch) | |
tree | 56290531ba5426bdd8cf2d9eca8e9049bca000cf /src/declarative/qml | |
parent | a48e06bc745afae421d9f91c7143dd1a49906c77 (diff) | |
download | Qt-eeb66cd4a8939cd54b890eb511d99f4a62d3f423.zip Qt-eeb66cd4a8939cd54b890eb511d99f4a62d3f423.tar.gz Qt-eeb66cd4a8939cd54b890eb511d99f4a62d3f423.tar.bz2 |
Use range semantics for versions.
Meets spec QT-558
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index a92ec0f..5902c99 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1055,7 +1055,6 @@ struct QmlEnginePrivate::ImportedNamespace { int vmaj = majversions.at(i); int vmin = minversions.at(i); if (vmaj || vmin) { - QString version = QString::number(vmaj) + QLatin1String(".") + QString::number(vmin); // Check version file - XXX cache these in QmlEngine! QFile qmldir(QUrl(urls.at(i)+QLatin1String("/qmldir")).toLocalFile()); if (qmldir.open(QIODevice::ReadOnly)) { @@ -1066,23 +1065,29 @@ struct QmlEnginePrivate::ImportedNamespace { int space1 = line.indexOf(QLatin1Char(' ')); int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1; QStringRef maptype = line.leftRef(space1); - QStringRef mapversion = line.midRef(space1+1,space2<0?line.length()-space1-2:space2-space1-1); - QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-2); - if (maptype==type && mapversion==version) { - if (mapfile.isEmpty()) - return url; - else - return url.resolved(mapfile.toString()); + if (maptype==type) { + // eg. 1.2-5 + QString mapversions = line.mid(space1+1,space2<0?line.length()-space1-2:space2-space1-1); + int dot = mapversions.indexOf(QLatin1Char('.')); + int dash = mapversions.indexOf(QLatin1Char('-')); + int mapvmaj = mapversions.left(dot).toInt(); + if (mapvmaj==vmaj) { + int mapvmin_from = (dash <= 0 ? mapversions.mid(dot+1) : mapversions.mid(dot+1,dash-dot-1)).toInt(); + int mapvmin_to = dash <= 0 ? mapvmin_from : mapversions.mid(dash+1).toInt(); + if (vmin >= mapvmin_from && vmin <= mapvmin_to) { + QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-2); + return url.resolved(mapfile.toString()); + } + } } } while (!qmldir.atEnd()); } - return QUrl(); // no match for requested version + } else { + // XXX search non-files too! (eg. zip files, see QT-524) + QFileInfo f(url.toLocalFile()); + if (f.exists()) + return url; // (unversioned) local import } - - // XXX search non-files too! (eg. zip files, see QT-524) - QFileInfo f(url.toLocalFile()); - if (f.exists()) - return url; // (unversioned) local import } return QUrl(); } |