aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMarcus Tillmanns <marcus.tillmanns@qt.io>2022-07-28 15:59:52 +0200
committerMarcus Tillmanns <marcus.tillmanns@qt.io>2022-08-04 08:46:06 +0000
commit451d02c88d3aca4a1c1d6487b2ecaaac848e5c90 (patch)
tree41f1a7e1bc131502763ea471e4e0b6d1f10aadd7 /src/plugins
parent783f0e120530777bca881f5e3bcc37d269011f32 (diff)
FilePath: Remove ::toDir() and deprecation hints
Change-Id: Ib561c019e3fd44cd85504ad4286eb3759ce19516 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/coreplugin/dialogs/externaltoolconfig.cpp15
-rw-r--r--src/plugins/coreplugin/generalsettings.cpp11
-rw-r--r--src/plugins/coreplugin/generatedfile.cpp8
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp3
-rw-r--r--src/plugins/projectexplorer/projectnodes.cpp2
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp40
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h1
-rw-r--r--src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp10
-rw-r--r--src/plugins/qmljseditor/qmljshoverhandler.cpp8
-rw-r--r--src/plugins/qmlprojectmanager/qmlproject.cpp5
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectplugin.cpp6
-rw-r--r--src/plugins/texteditor/fontsettingspage.cpp50
12 files changed, 76 insertions, 83 deletions
diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
index cee2c6d7c9d..39483fb8323 100644
--- a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
+++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
@@ -632,12 +632,15 @@ void ExternalToolConfig::showInfoForItem(const QModelIndex &index)
static FilePath getUserFilePath(const QString &proposalFileName)
{
- const QDir resourceDir(ICore::userResourcePath().toDir());
- if (!resourceDir.exists(QLatin1String("externaltools")))
- resourceDir.mkpath(QLatin1String("externaltools"));
- const QFileInfo fi(proposalFileName);
- const QString &suffix = QLatin1Char('.') + fi.completeSuffix();
- const FilePath newFilePath = ICore::userResourcePath("externaltools") / fi.baseName();
+ const FilePath resourceDir(ICore::userResourcePath());
+ const FilePath externalToolsDir = resourceDir / "externalTools";
+ if (!externalToolsDir.isDir())
+ externalToolsDir.createDir();
+
+ const FilePath proposal = FilePath::fromString(proposalFileName);
+ const QString suffix = QLatin1Char('.') + proposal.suffix();
+ const FilePath newFilePath = externalToolsDir / proposal.baseName();
+
int count = 0;
FilePath tryPath = newFilePath + suffix;
while (tryPath.exists()) {
diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp
index f0b8690097f..7285ebf6e47 100644
--- a/src/plugins/coreplugin/generalsettings.cpp
+++ b/src/plugins/coreplugin/generalsettings.cpp
@@ -180,13 +180,14 @@ void GeneralSettingsWidget::fillLanguageBox() const
m_languageBox->setCurrentIndex(m_languageBox->count() - 1);
const FilePath creatorTrPath = ICore::resourcePath("translations");
- const QStringList languageFiles = creatorTrPath.toDir().entryList(
+ const FilePaths languageFiles = creatorTrPath.dirEntries(
QStringList(QLatin1String("qtcreator*.qm")));
- for (const QString &languageFile : languageFiles) {
- int start = languageFile.indexOf('_') + 1;
- int end = languageFile.lastIndexOf('.');
- const QString locale = languageFile.mid(start, end-start);
+ for (const FilePath &languageFile : languageFiles) {
+ const QString path = languageFile.path();
+ int start = path.indexOf('_') + 1;
+ int end = path.lastIndexOf('.');
+ const QString locale = path.mid(start, end-start);
// no need to show a language that creator will not load anyway
if (hasQmFilesForLocale(locale, creatorTrPath.toString())) {
QLocale tmpLocale(locale);
diff --git a/src/plugins/coreplugin/generatedfile.cpp b/src/plugins/coreplugin/generatedfile.cpp
index 3c67d5525f3..152cf4c1d14 100644
--- a/src/plugins/coreplugin/generatedfile.cpp
+++ b/src/plugins/coreplugin/generatedfile.cpp
@@ -182,12 +182,12 @@ void GeneratedFile::setEditorId(Id id)
bool GeneratedFile::write(QString *errorMessage) const
{
// Ensure the directory
- const QDir dir = m_d->path.parentDir().toDir();
- if (!dir.exists()) {
- if (!dir.mkpath(dir.absolutePath())) {
+ const FilePath parentDir = m_d->path.parentDir();
+ if (!parentDir.isDir()) {
+ if (!parentDir.createDir()) {
*errorMessage = QCoreApplication::translate("BaseFileWizard",
"Unable to create the directory %1.")
- .arg(QDir::toNativeSeparators(dir.absolutePath()));
+ .arg(parentDir.toUserOutput());
return false;
}
}
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp
index 3963b4b71f6..5ecfd89d683 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp
@@ -257,8 +257,7 @@ void ProjectExplorer::ProjectExplorerPlugin::testJsonWizardsComboBox()
static QString iconInsideResource(const QString &relativePathToIcon)
{
- const QDir resourcePath(Core::ICore::resourcePath().toDir());
- return resourcePath.filePath(relativePathToIcon);
+ return Core::ICore::resourcePath().resolvePath(relativePathToIcon).toString();
}
void ProjectExplorer::ProjectExplorerPlugin::testJsonWizardsIconList()
diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp
index d10c6521b70..6df432d19d6 100644
--- a/src/plugins/projectexplorer/projectnodes.cpp
+++ b/src/plugins/projectexplorer/projectnodes.cpp
@@ -70,7 +70,7 @@ static FolderNode *recursiveFindOrCreateFolderNode(FolderNode *folder,
Utils::FilePath directoryWithoutPrefix;
bool isRelative = false;
- if (path.isEmpty() || path.toDir().isRoot()) {
+ if (path.isEmpty() || path == FilePath::rootPath()) {
directoryWithoutPrefix = directory;
isRelative = false;
} else {
diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp
index 17d3cdd957f..7c4c9270459 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp
+++ b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp
@@ -32,9 +32,11 @@
#include <richtexteditor/richtexteditor.h>
#include <projectexplorer/target.h>
#include <qmlprojectmanager/qmlproject.h>
+#include <utils/qtcassert.h>
#include <QCryptographicHash>
+using namespace Utils;
namespace QmlDesigner {
AnnotationCommentTab::AnnotationCommentTab(QWidget *parent)
@@ -53,7 +55,8 @@ AnnotationCommentTab::AnnotationCommentTab(QWidget *parent)
const QmlDesigner::DesignDocument *designDocument = QmlDesigner::QmlDesignerPlugin::instance()
->documentManager().currentDesignDocument();
- Utils::FilePath projectPath;
+
+ FilePath projectPath;
Q_ASSERT(designDocument);
@@ -142,7 +145,8 @@ QString AnnotationCommentTab::backupFile(const QString &filePath)
{
const QmlDesigner::DesignDocument *designDocument = QmlDesigner::QmlDesignerPlugin::instance()
->documentManager().currentDesignDocument();
- Utils::FilePath projectFolderPath;
+
+ FilePath projectFolderPath;
Q_ASSERT(designDocument);
@@ -155,43 +159,35 @@ QString AnnotationCommentTab::backupFile(const QString &filePath)
else
return {};
- const QDir projDir(projectFolderPath.toDir());
-
- if (!projDir.exists())
+ if (!projectFolderPath.isDir())
return {};
const QString imageSubDir(".AnnotationImages");
- const QDir imgDir(projDir.absolutePath() + QDir::separator() + imageSubDir);
-
- ensureDir(imgDir);
+ const FilePath imgDir(projectFolderPath / imageSubDir);
- Q_ASSERT(imgDir.exists());
if (!imgDir.exists())
- return {};
+ imgDir.createDir();
+
+ QTC_ASSERT(imgDir.isDir(), return {});
- const QFileInfo oldFile(filePath);
- QFileInfo newFile(imgDir, oldFile.fileName());
+ const FilePath oldFile = FilePath::fromString(filePath);
+ FilePath newFile = imgDir.resolvePath(oldFile.fileName());
- QString newName = newFile.baseName() + "_%1." + newFile.completeSuffix();
+ QString newNameTemplate = newFile.baseName() + "_%1." + newFile.completeSuffix();
for (size_t i = 1; true; ++i) {
if (!newFile.exists()) {
- QFile(oldFile.absoluteFilePath()).copy(newFile.absoluteFilePath());
+ oldFile.copyFile(newFile);
break;
- } else if (compareFileChecksum(oldFile.absoluteFilePath(), newFile.absoluteFilePath()) == 0)
+ } else if (compareFileChecksum(oldFile.absoluteFilePath().toString(), newFile.absoluteFilePath().toString()) == 0)
break;
- newFile.setFile(imgDir, newName.arg(i));
+ newFile = imgDir / newNameTemplate.arg(i);
}
- return projDir.relativeFilePath(newFile.absoluteFilePath());
+ return newFile.relativeChildPath(projectFolderPath).toString();
}
-void AnnotationCommentTab::ensureDir(const QDir &dir)
-{
- if (!dir.exists())
- dir.mkdir(".");
-}
int AnnotationCommentTab::compareFileChecksum(const QString &firstFile, const QString &secondFile)
{
diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h
index a1e2509590d..e1719eecb63 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h
+++ b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h
@@ -69,7 +69,6 @@ signals:
private:
QString backupFile(const QString &filePath);
- void ensureDir(const QDir &dir);
int compareFileChecksum(const QString &firstFile, const QString &secondFile);
private:
diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
index c1c39ecd1a8..bf986d626a9 100644
--- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
@@ -494,11 +494,11 @@ public:
minorVersion = importInfo.version().minorVersion();
typeName.prepend(name + QLatin1Char('.'));
} else if (importInfo.isValid() && importInfo.type() == ImportType::Directory) {
- QString path = importInfo.path();
- QDir dir = m_doc->path().toDir();
- // should probably try to make it relatve to some import path, not to the document path
- QString relativeDir = dir.relativeFilePath(path);
- QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
+ const Utils::FilePath path = Utils::FilePath::fromString(importInfo.path());
+ const Utils::FilePath dir = m_doc->path();
+ // should probably try to make it relative to some import path, not to the document path
+ const Utils::FilePath relativePath = path.relativeChildPath(dir);
+ QString name = relativePath.path().replace(QLatin1Char('/'), QLatin1Char('.'));
if (!name.isEmpty() && name != QLatin1String("."))
typeName.prepend(name + QLatin1Char('.'));
} else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) {
diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp
index ab7d8c904be..167058c2144 100644
--- a/src/plugins/qmljseditor/qmljshoverhandler.cpp
+++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp
@@ -124,11 +124,11 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
return moduleName + QString::number(majorVersion) + QLatin1Char('.')
+ QString::number(minorVersion) ;
} else if (importInfo.isValid() && importInfo.type() == ImportType::Directory) {
- const QString path = importInfo.path();
- const QDir dir = qmlDocument->path().toDir();
+ const Utils::FilePath path = Utils::FilePath::fromString(importInfo.path());
+ const Utils::FilePath dir = qmlDocument->path();
// should probably try to make it relatve to some import path, not to the document path
- QString relativeDir = dir.relativeFilePath(path);
- const QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
+ const Utils::FilePath relativePath = path.relativeChildPath(dir);
+ const QString name = relativePath.path().replace(QLatin1Char('/'), QLatin1Char('.'));
return name;
} else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) {
QString path = Utils::QrcParser::normalizedQrcDirectoryPath(importInfo.path());
diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp
index 051ffacff76..3f20a22a6a5 100644
--- a/src/plugins/qmlprojectmanager/qmlproject.cpp
+++ b/src/plugins/qmlprojectmanager/qmlproject.cpp
@@ -289,9 +289,8 @@ bool QmlBuildSystem::setFileSettingInProjectFile(const QString &setting, const U
const QString settingQmlCode = setting + ":";
- QDir projectDir = project()->projectFilePath().toDir();
- projectDir.cdUp();
- const QString relativePath = projectDir.relativeFilePath(mainFilePath.toString());
+ const Utils::FilePath projectDir = project()->projectFilePath().parentDir();
+ const QString relativePath = mainFilePath.relativeChildPath(projectDir).path();
if (fileContent.indexOf(settingQmlCode) < 0) {
QString addedText = QString("\n %1 \"%2\"\n").arg(settingQmlCode).arg(relativePath);
diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp
index 54aaa2afa00..9db80e099ad 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp
@@ -194,9 +194,9 @@ const Utils::FilePath findQmlProjectUpwards(const Utils::FilePath &folder)
if (ret.exists())
return ret;
- QDir dir = folder.toDir();
- if (dir.cdUp())
- return findQmlProjectUpwards(Utils::FilePath::fromString(dir.absolutePath()));
+ if (folder.parentDir().isDir())
+ return findQmlProjectUpwards(folder.parentDir());
+
return {};
}
diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp
index 1201e7a47a3..c02072f2f5a 100644
--- a/src/plugins/texteditor/fontsettingspage.cpp
+++ b/src/plugins/texteditor/fontsettingspage.cpp
@@ -262,18 +262,18 @@ public:
} // namespace Internal
-static Utils::FilePath customStylesPath()
+static FilePath customStylesPath()
{
return Core::ICore::userResourcePath("styles");
}
-static Utils::FilePath createColorSchemeFileName(const QString &pattern)
+static FilePath createColorSchemeFileName(const QString &pattern)
{
- const Utils::FilePath stylesPath = customStylesPath();
+ const FilePath stylesPath = customStylesPath();
// Find an available file name
int i = 1;
- Utils::FilePath filePath;
+ FilePath filePath;
do {
filePath = stylesPath.pathAppended(pattern.arg((i == 1) ? QString() : QString::number(i)));
++i;
@@ -545,7 +545,7 @@ void FontSettingsPageWidget::copyColorScheme(const QString &name)
QString baseFileName = QFileInfo(entry.fileName).completeBaseName();
baseFileName += QLatin1String("_copy%1.xml");
- Utils::FilePath fileName = createColorSchemeFileName(baseFileName);
+ FilePath fileName = createColorSchemeFileName(baseFileName);
if (!fileName.isEmpty()) {
// Ask about saving any existing modifications
@@ -604,7 +604,7 @@ void FontSettingsPageWidget::deleteColorScheme()
void FontSettingsPageWidget::importScheme()
{
- const Utils::FilePath importedFile
+ const FilePath importedFile
= Utils::FileUtils::getOpenFilePath(this,
tr("Import Color Scheme"),
{},
@@ -613,7 +613,7 @@ void FontSettingsPageWidget::importScheme()
if (importedFile.isEmpty())
return;
- Utils::FilePath fileName = createColorSchemeFileName(importedFile.baseName() + "%1."
+ FilePath fileName = createColorSchemeFileName(importedFile.baseName() + "%1."
+ importedFile.suffix());
// Ask about saving any existing modifications
@@ -647,10 +647,10 @@ void FontSettingsPageWidget::exportScheme()
const ColorSchemeEntry &entry = m_schemeListModel.colorSchemeAt(index);
- const Utils::FilePath filePath
+ const FilePath filePath
= Utils::FileUtils::getSaveFilePath(this,
tr("Export Color Scheme"),
- Utils::FilePath::fromString(entry.fileName),
+ FilePath::fromString(entry.fileName),
tr("Color scheme (*.xml);;All files (*)"));
if (!filePath.isEmpty())
@@ -686,34 +686,30 @@ void FontSettingsPageWidget::refreshColorSchemeList()
{
QList<ColorSchemeEntry> colorSchemes;
- QDir styleDir(Core::ICore::resourcePath("styles").toDir());
- styleDir.setNameFilters(QStringList() << QLatin1String("*.xml"));
- styleDir.setFilter(QDir::Files);
+ const FilePath styleDir = Core::ICore::resourcePath("styles");
- int selected = 0;
+ FilePaths schemeList = styleDir.dirEntries(FileFilter({"*.xml"}, QDir::Files));
+ const FilePath defaultScheme = FilePath::fromString(FontSettings::defaultSchemeFileName());
- QStringList schemeList = styleDir.entryList();
- QString defaultScheme = Utils::FilePath::fromString(FontSettings::defaultSchemeFileName()).fileName();
if (schemeList.removeAll(defaultScheme))
schemeList.prepend(defaultScheme);
- for (const QString &file : qAsConst(schemeList)) {
- const QString fileName = styleDir.absoluteFilePath(file);
- if (m_value.colorSchemeFileName() == fileName)
+
+ int selected = 0;
+
+ for (const FilePath &file : qAsConst(schemeList)) {
+ if (FilePath::fromString(m_value.colorSchemeFileName()) == file)
selected = colorSchemes.size();
- colorSchemes.append(ColorSchemeEntry(fileName, true));
+ colorSchemes.append(ColorSchemeEntry(file.toString(), true));
}
if (colorSchemes.isEmpty())
- qWarning() << "Warning: no color schemes found in path:" << styleDir.path();
-
- styleDir.setPath(customStylesPath().path());
+ qWarning() << "Warning: no color schemes found in path:" << styleDir.toUserOutput();
- const QStringList files = styleDir.entryList();
- for (const QString &file : files) {
- const QString fileName = styleDir.absoluteFilePath(file);
- if (m_value.colorSchemeFileName() == fileName)
+ const FilePaths files = customStylesPath().dirEntries(FileFilter({"*.xml"}, QDir::Files));
+ for (const FilePath &file : files) {
+ if (FilePath::fromString(m_value.colorSchemeFileName()) == file)
selected = colorSchemes.size();
- colorSchemes.append(ColorSchemeEntry(fileName, false));
+ colorSchemes.append(ColorSchemeEntry(file.toString(), false));
}
m_refreshingSchemeList = true;