diff options
| author | Zhao Yuhang <2546789017@qq.com> | 2025-04-10 16:20:35 +0800 |
|---|---|---|
| committer | Zhao Yuhang <2546789017@qq.com> | 2025-04-12 05:39:59 +0000 |
| commit | 60297d4d1e17705c128d11a1ef6f200e59ba4708 (patch) | |
| tree | de516f9eb0c35659cd50c1fcd3a52a94ff6f838c /tools | |
| parent | fe62a09338be3ca3371988e1645c8e74e36a4818 (diff) | |
Port away from QPair
QPair is just an alias of std::pair anyway.
Task-number: QTBUG-115841
Change-Id: I26fc90adcc775aac9955ad57304af914dc4ed48f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/qmlimportscanner/main.cpp | 16 | ||||
| -rw-r--r-- | tools/qmlplugindump/main.cpp | 4 | ||||
| -rw-r--r-- | tools/qmltc/qmltctyperesolver.cpp | 2 | ||||
| -rw-r--r-- | tools/qmltc/qmltctyperesolver.h | 2 |
4 files changed, 12 insertions, 12 deletions
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index 83fd3f6720..0d9c3baf80 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -151,9 +151,9 @@ QVariantMap pluginsForModulePath(const QString &modulePath, const QString &version, FileImportsWithoutDepsCache &fileImportsWithoutDepsCache) { - using Cache = QHash<QPair<QString, QString>, QVariantMap>; + using Cache = QHash<std::pair<QString, QString>, QVariantMap>; static Cache pluginsCache; - const QPair<QString, QString> cacheKey = std::make_pair(modulePath, version); + const std::pair<QString, QString> cacheKey = std::make_pair(modulePath, version); const Cache::const_iterator it = pluginsCache.find(cacheKey); if (it != pluginsCache.end()) { return *it; @@ -275,14 +275,14 @@ QVariantMap pluginsForModulePath(const QString &modulePath, // Search for a given qml import in g_qmlImportPaths and return a pair // of absolute / relative paths (for deployment). -QPair<QString, QString> resolveImportPath(const QString &uri, const QString &version) +std::pair<QString, QString> resolveImportPath(const QString &uri, const QString &version) { const QLatin1Char dot('.'); const QLatin1Char slash('/'); const QStringList parts = uri.split(dot, Qt::SkipEmptyParts); QString ver = version; - QPair<QString, QString> candidate; + std::pair<QString, QString> candidate; while (true) { for (const QString &qmlImportPath : std::as_const(g_qmlImportPaths)) { // Search for the most specific version first, and search @@ -299,7 +299,7 @@ QPair<QString, QString> resolveImportPath(const QString &uri, const QString &ver const QString candidatePath = QDir::cleanPath(qmlImportPath + slash + relativePath); const QDir candidateDir(candidatePath); if (candidateDir.exists()) { - const auto newCandidate = qMakePair(candidatePath, relativePath); // import found + const auto newCandidate = std::make_pair(candidatePath, relativePath); // import found if (candidateDir.exists(u"qmldir"_s)) // if it has a qmldir, we are fine return newCandidate; else if (candidate.first.isEmpty()) @@ -315,7 +315,7 @@ QPair<QString, QString> resolveImportPath(const QString &uri, const QString &ver const QString candidatePath = QDir::cleanPath(qmlImportPath + slash + relativePath); const QDir candidateDir(candidatePath); if (candidateDir.exists()) { - const auto newCandidate = qMakePair(candidatePath, relativePath); // import found + const auto newCandidate = std::make_pair(candidatePath, relativePath); // import found if (candidateDir.exists(u"qmldir"_s)) return newCandidate; else if (candidate.first.isEmpty()) @@ -376,7 +376,7 @@ struct ImportVariantHasher { } }; -using ImportDetailsAndDeps = QPair<QVariantMap, QStringList>; +using ImportDetailsAndDeps = std::pair<QVariantMap, QStringList>; // Returns the import information as it will be written out to the json / .cmake file. // The dependencies are not stored in the same QVariantMap because we don't currently need that @@ -397,7 +397,7 @@ getImportDetails(const QVariant &inputImport, QStringList dependencies; if (import.value(typeLiteral()) == moduleLiteral()) { const QString version = import.value(versionLiteral()).toString(); - const QPair<QString, QString> paths = + const std::pair<QString, QString> paths = resolveImportPath(import.value(nameLiteral()).toString(), version); QVariantMap plugininfo; if (!paths.first.isEmpty()) { diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 397c690882..c6c96dcd90 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -760,11 +760,11 @@ private: qml->writeStartObject("Enum"); qml->writeStringBinding("name", QUtf8StringView(e.name())); - QList<QPair<QAnyStringView, int>> namesValues; + QList<std::pair<QAnyStringView, int>> namesValues; const int keyCount = e.keyCount(); namesValues.reserve(keyCount); for (int index = 0; index < keyCount; ++index) - namesValues.append(qMakePair(QUtf8StringView(e.key(index)), e.value(index))); + namesValues.append(std::make_pair(QUtf8StringView(e.key(index)), e.value(index))); qml->writeEnumObjectLiteralBinding("values", namesValues); qml->writeEndObject(); diff --git a/tools/qmltc/qmltctyperesolver.cpp b/tools/qmltc/qmltctyperesolver.cpp index 9c53686736..38f453fa5f 100644 --- a/tools/qmltc/qmltctyperesolver.cpp +++ b/tools/qmltc/qmltctyperesolver.cpp @@ -43,7 +43,7 @@ QmltcTypeResolver::scopeForLocation(const QV4::CompiledData::Location &location) return m_objectsByLocationNonConst.value(location); } -QPair<QString, QQmlJSScope::Ptr> +std::pair<QString, QQmlJSScope::Ptr> QmltcTypeResolver::importedType(const QQmlJSScope::ConstPtr &type) const { const auto files = m_importer->importedFiles(); diff --git a/tools/qmltc/qmltctyperesolver.h b/tools/qmltc/qmltctyperesolver.h index 19a3ee01bc..4c79bbf393 100644 --- a/tools/qmltc/qmltctyperesolver.h +++ b/tools/qmltc/qmltctyperesolver.h @@ -26,7 +26,7 @@ public: QQmlJSScope::Ptr scopeForLocation(const QV4::CompiledData::Location &location) const; // returns an import pair {url, modifiable type} for a given \a type - QPair<QString, QQmlJSScope::Ptr> importedType(const QQmlJSScope::ConstPtr &type) const; + std::pair<QString, QQmlJSScope::Ptr> importedType(const QQmlJSScope::ConstPtr &type) const; private: QQmlJSImporter *m_importer = nullptr; |
