Utils: Rename FileName to FilePath

More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-05-28 13:49:26 +02:00
parent 4704f49fbb
commit 473a741c9f
688 changed files with 3487 additions and 3484 deletions

View File

@@ -175,7 +175,7 @@ bool FileFilterBaseItem::matchesFile(const QString &filePath) const
return true;
}
const QString &fileName = Utils::FileName::fromString(filePath).fileName();
const QString &fileName = Utils::FilePath::fromString(filePath).fileName();
if (!fileMatches(fileName))
return false;

View File

@@ -63,7 +63,7 @@ void setupFileFilterItem(QmlProjectManager::FileFilterBaseItem *fileFilterItem,
namespace QmlProjectManager {
QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FileName &fileName, QString *errorMessage)
QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fileName, QString *errorMessage)
{
QmlJS::SimpleReader simpleQmlJSReader;

View File

@@ -39,7 +39,7 @@ class QmlProjectFileFormat
Q_DECLARE_TR_FUNCTIONS(QmlProjectManager::QmlProjectFileFormat)
public:
static QmlProjectItem *parseProjectFile(const Utils::FileName &fileName,
static QmlProjectItem *parseProjectFile(const Utils::FilePath &fileName,
QString *errorMessage = nullptr);
};

View File

@@ -56,13 +56,13 @@ using namespace ProjectExplorer;
namespace QmlProjectManager {
QmlProject::QmlProject(const Utils::FileName &fileName) :
QmlProject::QmlProject(const Utils::FilePath &fileName) :
Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName,
[this]() { refreshProjectFile(); })
{
const QString normalized
= Utils::FileUtils::normalizePathName(fileName.toFileInfo().canonicalFilePath());
m_canonicalProjectDir = Utils::FileName::fromString(normalized).parentDir();
m_canonicalProjectDir = Utils::FilePath::fromString(normalized).parentDir();
setId(QmlProjectManager::Constants::QML_PROJECT_ID);
setProjectLanguages(Context(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID));
@@ -97,7 +97,7 @@ void QmlProject::onKitChanged()
refresh(Configuration);
}
Utils::FileName QmlProject::canonicalProjectDir() const
Utils::FilePath QmlProject::canonicalProjectDir() const
{
return m_canonicalProjectDir;
}
@@ -165,7 +165,7 @@ void QmlProject::refresh(RefreshOptions options)
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
modelManager->defaultProjectInfoForProject(this);
foreach (const QString &searchPath, makeAbsolute(canonicalProjectDir(), customImportPaths()))
projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(searchPath),
projectInfo.importPaths.maybeInsert(Utils::FilePath::fromString(searchPath),
QmlJS::Dialect::Qml);
modelManager->updateProjectInfo(projectInfo, this);
@@ -186,24 +186,24 @@ void QmlProject::setMainFile(const QString &mainFilePath)
m_projectItem.data()->setMainFile(mainFilePath);
}
Utils::FileName QmlProject::targetDirectory(const Target *target) const
Utils::FilePath QmlProject::targetDirectory(const Target *target) const
{
if (DeviceTypeKitAspect::deviceTypeId(target->kit())
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
return canonicalProjectDir();
return m_projectItem ? Utils::FileName::fromString(m_projectItem->targetDirectory())
: Utils::FileName();
return m_projectItem ? Utils::FilePath::fromString(m_projectItem->targetDirectory())
: Utils::FilePath();
}
Utils::FileName QmlProject::targetFile(const Utils::FileName &sourceFile,
Utils::FilePath QmlProject::targetFile(const Utils::FilePath &sourceFile,
const Target *target) const
{
const QDir sourceDir(m_projectItem ? m_projectItem->sourceDirectory()
: canonicalProjectDir().toString());
const QDir targetDir(targetDirectory(target).toString());
const QString relative = sourceDir.relativeFilePath(sourceFile.toString());
return Utils::FileName::fromString(QDir::cleanPath(targetDir.absoluteFilePath(relative)));
return Utils::FilePath::fromString(QDir::cleanPath(targetDir.absoluteFilePath(relative)));
}
QList<Utils::EnvironmentItem> QmlProject::environment() const
@@ -252,7 +252,7 @@ bool QmlProject::needsBuildConfigurations() const
return false;
}
QStringList QmlProject::makeAbsolute(const Utils::FileName &path, const QStringList &relativePaths)
QStringList QmlProject::makeAbsolute(const Utils::FilePath &path, const QStringList &relativePaths)
{
if (path.isEmpty())
return relativePaths;
@@ -374,7 +374,7 @@ void QmlProject::generateProjectTree()
auto newRoot = std::make_unique<Internal::QmlProjectNode>(this);
for (const QString &f : m_projectItem.data()->files()) {
const Utils::FileName fileName = Utils::FileName::fromString(f);
const Utils::FilePath fileName = Utils::FilePath::fromString(f);
const FileType fileType = (fileName == projectFilePath())
? FileType::Project : FileNode::fileTypeForFileName(fileName);
newRoot->addNestedNode(std::make_unique<FileNode>(fileName, fileType));
@@ -399,7 +399,7 @@ void QmlProject::updateDeploymentData(ProjectExplorer::Target *target)
for (const QString &file : m_projectItem->files()) {
deploymentData.addFile(
file,
targetFile(Utils::FileName::fromString(file), target).parentDir().toString());
targetFile(Utils::FilePath::fromString(file), target).parentDir().toString());
}
target->setDeploymentData(deploymentData);

View File

@@ -45,7 +45,7 @@ class QMLPROJECTMANAGER_EXPORT QmlProject : public ProjectExplorer::Project
Q_OBJECT
public:
explicit QmlProject(const Utils::FileName &filename);
explicit QmlProject(const Utils::FilePath &filename);
~QmlProject() override;
ProjectExplorer::Tasks projectIssues(const ProjectExplorer::Kit *k) const final;
@@ -62,11 +62,11 @@ public:
void refresh(RefreshOptions options);
Utils::FileName canonicalProjectDir() const;
Utils::FilePath canonicalProjectDir() const;
QString mainFile() const;
void setMainFile(const QString &mainFilePath);
Utils::FileName targetDirectory(const ProjectExplorer::Target *target) const;
Utils::FileName targetFile(const Utils::FileName &sourceFile,
Utils::FilePath targetDirectory(const ProjectExplorer::Target *target) const;
Utils::FilePath targetFile(const Utils::FilePath &sourceFile,
const ProjectExplorer::Target *target) const;
QList<Utils::EnvironmentItem> environment() const;
@@ -79,7 +79,7 @@ public:
bool needsBuildConfigurations() const final;
static QStringList makeAbsolute(const Utils::FileName &path, const QStringList &relativePaths);
static QStringList makeAbsolute(const Utils::FilePath &path, const QStringList &relativePaths);
QVariant additionalData(Core::Id id, const ProjectExplorer::Target *target) const override;
@@ -103,7 +103,7 @@ private:
ProjectExplorer::Target *m_activeTarget = nullptr;
QPointer<QmlProjectItem> m_projectItem;
Utils::FileName m_canonicalProjectDir;
Utils::FilePath m_canonicalProjectDir;
};
} // namespace QmlProjectManager

View File

@@ -173,7 +173,7 @@ void MainQmlFileAspect::updateFileComboBox()
QModelIndex currentIndex;
QStringList sortedFiles = Utils::transform(m_project->files(Project::AllFiles),
&Utils::FileName::toString);
&Utils::FilePath::toString);
// make paths relative to project directory
QStringList relativeFiles;
@@ -298,7 +298,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
return envModifier(Environment());
});
setExecutableGetter([this] { return FileName::fromString(theExecutable()); });
setExecutableGetter([this] { return FilePath::fromString(theExecutable()); });
m_qmlViewerAspect = addAspect<BaseStringAspect>();
m_qmlViewerAspect->setLabelText(tr("QML Viewer:"));
@@ -395,7 +395,7 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
Utils::QtcProcess::addArg(&args, fileSelector, osType);
}
const QString main = project->targetFile(Utils::FileName::fromString(mainScript()),
const QString main = project->targetFile(Utils::FilePath::fromString(mainScript()),
currentTarget).toString();
if (!main.isEmpty())
Utils::QtcProcess::addArg(&args, main, osType);
@@ -432,7 +432,7 @@ bool MainQmlFileAspect::isQmlFilePresent()
// find a qml file with lowercase filename. This is slow, but only done
// in initialization/other border cases.
const auto files = m_project->files(Project::AllFiles);
for (const Utils::FileName &filename : files) {
for (const Utils::FilePath &filename : files) {
const QFileInfo fi = filename.toFileInfo();
if (!filename.isEmpty() && fi.baseName().at(0).isLower()) {