diff options
Diffstat (limited to 'src/qml/qmldirparser')
-rw-r--r-- | src/qml/qmldirparser/qqmldirparser.cpp | 33 | ||||
-rw-r--r-- | src/qml/qmldirparser/qqmldirparser_p.h | 9 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/qml/qmldirparser/qqmldirparser.cpp b/src/qml/qmldirparser/qqmldirparser.cpp index 6e925ba515..36b47a3302 100644 --- a/src/qml/qmldirparser/qqmldirparser.cpp +++ b/src/qml/qmldirparser/qqmldirparser.cpp @@ -73,6 +73,20 @@ static bool parseVersion(const QString &str, int *major, int *minor) return false; } +void QQmlDirParser::clear() +{ + _errors.clear(); + _typeNamespace.clear(); + _components.clear(); + _dependencies.clear(); + _imports.clear(); + _scripts.clear(); + _plugins.clear(); + _designerSupported = false; + _typeInfos.clear(); + _className.clear(); +} + inline static void scanSpace(const QChar *&ch) { while (ch->isSpace() && !ch->isNull() && *ch != QLatin1Char('\n')) ++ch; @@ -93,13 +107,6 @@ inline static void scanWord(const QChar *&ch) { */ bool QQmlDirParser::parse(const QString &source) { - _errors.clear(); - _plugins.clear(); - _components.clear(); - _scripts.clear(); - _designerSupported = false; - _className.clear(); - quint16 lineNumber = 0; bool firstLine = true; @@ -198,7 +205,7 @@ bool QQmlDirParser::parse(const QString &source) } Component entry(sections[1], sections[2], -1, -1); entry.internal = true; - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } else if (sections[0] == QLatin1String("singleton")) { if (sectionCount < 3 || sectionCount > 4) { reportError(lineNumber, 0, @@ -209,7 +216,7 @@ bool QQmlDirParser::parse(const QString &source) // singleton TestSingletonType TestSingletonType.qml Component entry(sections[1], sections[2], -1, -1); entry.singleton = true; - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } else { // handle qmldir module listing case where singleton is defined in the following pattern: // singleton TestSingletonType 2.0 TestSingletonType20.qml @@ -218,7 +225,7 @@ bool QQmlDirParser::parse(const QString &source) const QString &fileName = sections[3]; Component entry(sections[1], fileName, major, minor); entry.singleton = true; - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } else { reportError(lineNumber, 0, QStringLiteral("invalid version %1, expected <major>.<minor>").arg(sections[2])); } @@ -264,7 +271,7 @@ bool QQmlDirParser::parse(const QString &source) } else if (sectionCount == 2) { // No version specified (should only be used for relative qmldir files) const Component entry(sections[0], sections[1], -1, -1); - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } else if (sectionCount == 3) { int major, minor; if (parseVersion(sections[1], &major, &minor)) { @@ -276,7 +283,7 @@ bool QQmlDirParser::parse(const QString &source) _scripts.append(entry); } else { const Component entry(sections[0], fileName, major, minor); - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } } else { reportError(lineNumber, 0, QStringLiteral("invalid version %1, expected <major>.<minor>").arg(sections[1])); @@ -343,7 +350,7 @@ QList<QQmlDirParser::Plugin> QQmlDirParser::plugins() const return _plugins; } -QHash<QString, QQmlDirParser::Component> QQmlDirParser::components() const +QMultiHash<QString, QQmlDirParser::Component> QQmlDirParser::components() const { return _components; } diff --git a/src/qml/qmldirparser/qqmldirparser_p.h b/src/qml/qmldirparser/qqmldirparser_p.h index c9d77532c8..3696a1aa12 100644 --- a/src/qml/qmldirparser/qqmldirparser_p.h +++ b/src/qml/qmldirparser/qqmldirparser_p.h @@ -64,6 +64,7 @@ class QQmlEngine; class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlDirParser { public: + void clear(); bool parse(const QString &source); bool hasError() const; @@ -75,7 +76,7 @@ public: static void checkNonRelative(const char *item, const QString &typeName, const QString &fileName) { - if (fileName.startsWith(QLatin1Char('/')) || fileName.contains(QLatin1Char(':'))) { + if (fileName.startsWith(QLatin1Char('/'))) { qWarning() << item << typeName << "is specified with non-relative URL" << fileName << "in a qmldir file." << "URLs in qmldir files should be relative to the qmldir file's directory."; @@ -131,7 +132,7 @@ public: int minorVersion = 0; }; - QHash<QString,Component> components() const; + QMultiHash<QString,Component> components() const; QHash<QString,Component> dependencies() const; QStringList imports() const; QList<Script> scripts() const; @@ -158,7 +159,7 @@ private: private: QList<QQmlJS::DiagnosticMessage> _errors; QString _typeNamespace; - QHash<QString,Component> _components; // multi hash + QMultiHash<QString,Component> _components; QHash<QString,Component> _dependencies; QStringList _imports; QList<Script> _scripts; @@ -168,7 +169,7 @@ private: QString _className; }; -using QQmlDirComponents = QHash<QString,QQmlDirParser::Component>; +using QQmlDirComponents = QMultiHash<QString,QQmlDirParser::Component>; using QQmlDirScripts = QList<QQmlDirParser::Script>; using QQmlDirPlugins = QList<QQmlDirParser::Plugin>; |