Use static version of QFileInfo::exists()

Docs say it's faster than creating QFileInfo object and calling
exists().

Change-Id: I0c10216bf72ab11ebf97b66a113d85ac0768d918
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Jarek Kobus
2020-11-16 23:30:07 +01:00
parent eaba657d90
commit b6a51f046f
4 changed files with 7 additions and 7 deletions

View File

@@ -1413,7 +1413,7 @@ QString getTemplateDialog(const Utils::FilePath &projectPath)
dialog->exec(); dialog->exec();
if (!result.isEmpty() && !QFileInfo(result).exists()) { if (!result.isEmpty() && !QFileInfo::exists(result)) {
result = templateFiles.at(names.indexOf(result)); result = templateFiles.at(names.indexOf(result));
result = templatesPath.pathAppended(result).toString(); result = templatesPath.pathAppended(result).toString();
} }
@@ -1489,7 +1489,7 @@ void mergeWithTemplate(const SelectionContext &selectionContext)
const QString templateFile = getTemplateDialog(projectPath); const QString templateFile = getTemplateDialog(projectPath);
if (QFileInfo(templateFile).exists()) if (QFileInfo::exists(templateFile))
styleMerge(selectionContext, templateFile); styleMerge(selectionContext, templateFile);
} }

View File

@@ -129,7 +129,7 @@ ItemLibraryAssetImportDialog::ItemLibraryAssetImportDialog(const QStringList &im
if (importPath.startsWith(targetDir)) { if (importPath.startsWith(targetDir)) {
const bool isDefaultFolder = importPath.endsWith(defaultAssetFolder); const bool isDefaultFolder = importPath.endsWith(defaultAssetFolder);
const QString assetFolder = importPath + quick3DFolder; const QString assetFolder = importPath + quick3DFolder;
const bool exists = QFileInfo(assetFolder).exists(); const bool exists = QFileInfo::exists(assetFolder);
if (exists) { if (exists) {
if (isDefaultFolder) { if (isDefaultFolder) {
// Priority one location, stop looking // Priority one location, stop looking

View File

@@ -334,7 +334,7 @@ void ItemLibraryAssetImporter::parseQuick3DAsset(const QString &file, const QVar
// Generate qmldir file if importer doesn't already make one // Generate qmldir file if importer doesn't already make one
QString qmldirFileName = outDir.absoluteFilePath(QStringLiteral("qmldir")); QString qmldirFileName = outDir.absoluteFilePath(QStringLiteral("qmldir"));
if (!QFileInfo(qmldirFileName).exists()) { if (!QFileInfo::exists(qmldirFileName)) {
QSaveFile qmldirFile(qmldirFileName); QSaveFile qmldirFile(qmldirFileName);
QString version = QStringLiteral("1.0"); QString version = QStringLiteral("1.0");
@@ -451,7 +451,7 @@ void ItemLibraryAssetImporter::copyImportedFiles()
// by filesystem watchers. // by filesystem watchers.
QHash<QString, QString>::const_iterator it = assetFiles.begin(); QHash<QString, QString>::const_iterator it = assetFiles.begin();
while (it != assetFiles.end()) { while (it != assetFiles.end()) {
if (QFileInfo(it.key()).exists()) { if (QFileInfo::exists(it.key())) {
QDir targetDir = QFileInfo(it.value()).dir(); QDir targetDir = QFileInfo(it.value()).dir();
if (!targetDir.exists()) if (!targetDir.exists())
targetDir.mkpath("."); targetDir.mkpath(".");

View File

@@ -404,7 +404,7 @@ void SubComponentManager::parseQuick3DAssetDir(const QString &assetPath)
QString iconName = qmlIt.fileInfo().absolutePath() + '/' QString iconName = qmlIt.fileInfo().absolutePath() + '/'
+ Constants::QUICK_3D_ASSET_ICON_DIR + '/' + name + Constants::QUICK_3D_ASSET_ICON_DIR + '/' + name
+ Constants::QUICK_3D_ASSET_LIBRARY_ICON_SUFFIX; + Constants::QUICK_3D_ASSET_LIBRARY_ICON_SUFFIX;
if (!QFileInfo(iconName).exists()) if (!QFileInfo::exists(iconName))
iconName = iconPath; iconName = iconPath;
itemLibraryEntry.setLibraryEntryIconPath(iconName); itemLibraryEntry.setLibraryEntryIconPath(iconName);
itemLibraryEntry.setTypeIcon(QIcon(iconName)); itemLibraryEntry.setTypeIcon(QIcon(iconName));
@@ -444,7 +444,7 @@ QStringList SubComponentManager::quick3DAssetPaths() const
QStringList retPaths; QStringList retPaths;
for (const auto &impPath : impPaths) { for (const auto &impPath : impPaths) {
const QString assetPath = impPath + QLatin1String(Constants::QUICK_3D_ASSETS_FOLDER); const QString assetPath = impPath + QLatin1String(Constants::QUICK_3D_ASSETS_FOLDER);
if (QFileInfo(assetPath).exists()) if (QFileInfo::exists(assetPath))
retPaths << assetPath; retPaths << assetPath;
} }
return retPaths; return retPaths;