Utils: Replace StringAspect::setFilePath()

... by FilePathAspect::setValue().

Closer to the intented uniform API.

Task-number: QTCREATORBUG-29167
Change-Id: Ife26046eaeef2e49108e42a31a2d32e453883e3c
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2023-06-29 17:18:26 +02:00
parent 13ccc24a35
commit 8e257dca2c
23 changed files with 33 additions and 39 deletions

View File

@@ -841,18 +841,6 @@ FilePath StringAspect::filePath() const
return FilePath::fromUserInput(value());
}
/*!
Sets the value of this string aspect to \a value.
\note This simply uses \c FilePath::toUserOutput() for the
conversion. It does not use any check that the value is actually
a file path.
*/
void StringAspect::setFilePath(const FilePath &value)
{
setValue(value.toUserOutput());
}
PathChooser *StringAspect::pathChooser() const
{
return d->m_pathChooserDisplay.data();
@@ -1324,6 +1312,13 @@ FilePathAspect::FilePathAspect(AspectContainer *container)
setDisplayStyle(PathChooserDisplay);
}
/*!
Sets the value of this file path aspect to \a value.
\note This does not use any check that the value is actually
a file path.
*/
void FilePathAspect::setValue(const FilePath &filePath)
{
StringAspect::setValue(filePath.toUserOutput());

View File

@@ -502,7 +502,6 @@ public:
void toMap(QVariantMap &map) const override;
FilePath filePath() const;
void setFilePath(const FilePath &value);
PathChooser *pathChooser() const; // Avoid to use.

View File

@@ -124,7 +124,7 @@ void AxivionSettings::fromSettings(QSettings *s)
const QString curlPath = QStandardPaths::findExecutable(
Utils::HostOsInfo::withExecutableSuffix("curl"));
if (!curlPath.isEmpty())
curl.setFilePath(Utils::FilePath::fromString(curlPath));
curl.setValue(Utils::FilePath::fromString(curlPath));
}
}

View File

@@ -92,7 +92,7 @@ QdbRunConfiguration::QdbRunConfiguration(Target *target, Id id)
IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit());
QTC_ASSERT(dev, return);
exeAspect->setExecutable(dev->filePath(depFile.remoteFilePath()));
symbolsAspect->setFilePath(localExecutable);
symbolsAspect->setValue(localExecutable);
});
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);

View File

@@ -2042,7 +2042,7 @@ BuildSystem *CMakeBuildConfiguration::buildSystem() const
void CMakeBuildConfiguration::setSourceDirectory(const FilePath &path)
{
aspect<SourceDirectoryAspect>()->setFilePath(path);
aspect<SourceDirectoryAspect>()->setValue(path);
}
FilePath CMakeBuildConfiguration::sourceDirectory() const

View File

@@ -72,7 +72,7 @@ ConanInstallStep::ConanInstallStep(BuildStepList *bsl, Id id)
auto conanFile = addAspect<FilePathAspect>();
conanFile->setSettingsKey("ConanPackageManager.InstallStep.ConanFile");
conanFile->setFilePath(conanFilePath(project(),
conanFile->setValue(conanFilePath(project(),
project()->projectDirectory() / "conanfile.txt"));
conanFile->setLabelText(Tr::tr("Conan file:"));
conanFile->setToolTip(Tr::tr("Enter location of conanfile.txt or conanfile.py."));

View File

@@ -178,7 +178,7 @@ GitLabOptionsWidget::GitLabOptionsWidget(GitLabParameters *params)
}, Column { m_add, m_edit, m_remove, st },
}.attachTo(this);
m_curl.setFilePath(params->curl);
m_curl.setValue(params->curl);
for (const auto &gitLabServer : params->gitLabServers) {
m_defaultGitLabServer->addItem(gitLabServer.displayString(),

View File

@@ -78,7 +78,7 @@ DeployMcuProcessStep::DeployMcuProcessStep(ProjectExplorer::BuildStepList *bc, U
cmd->setSettingsKey("QmlProject.Mcu.ProcessStep.Command");
cmd->setExpectedKind(Utils::PathChooser::Command);
cmd->setLabelText(QmlProjectManager::Tr::tr("Command:"));
cmd->setFilePath(rootPath.pathAppended("/bin/qmlprojectexporter"));
cmd->setValue(rootPath.pathAppended("/bin/qmlprojectexporter"));
const char *importPathConstant = QtSupport::Constants::KIT_QML_IMPORT_PATH;
Utils::FilePath projectDir = buildSystem()->projectDirectory();

View File

@@ -39,12 +39,12 @@ private:
NimCompilerCleanStep::NimCompilerCleanStep(BuildStepList *parentList, Id id)
: BuildStep(parentList, id)
{
auto workingDirectory = addAspect<StringAspect>();
auto workingDirectory = addAspect<FilePathAspect>();
workingDirectory->setLabelText(Tr::tr("Working directory:"));
workingDirectory->setDisplayStyle(StringAspect::LineEditDisplay);
setSummaryUpdater([this, workingDirectory] {
workingDirectory->setFilePath(buildDirectory());
workingDirectory->setValue(buildDirectory());
return displayName();
});
}

View File

@@ -102,7 +102,7 @@ void BuildDirectoryAspect::fromMap(const QVariantMap &map)
if (!d->sourceDir.isEmpty()) {
d->savedShadowBuildDir = FilePath::fromSettings(map.value(settingsKey() + ".shadowDir"));
if (d->savedShadowBuildDir.isEmpty())
setFilePath(d->sourceDir);
setValue(d->sourceDir);
setChecked(d->sourceDir != filePath());
}
}
@@ -117,11 +117,11 @@ void BuildDirectoryAspect::addToLayout(Layouting::LayoutItem &parent)
if (!d->sourceDir.isEmpty()) {
connect(this, &StringAspect::checkedChanged, this, [this] {
if (isChecked()) {
setFilePath(d->savedShadowBuildDir.isEmpty()
setValue(d->savedShadowBuildDir.isEmpty()
? d->sourceDir : d->savedShadowBuildDir);
} else {
d->savedShadowBuildDir = filePath();
setFilePath(d->sourceDir);
setValue(d->sourceDir);
}
});
}

View File

@@ -246,10 +246,10 @@ void BuildConfiguration::setBuildDirectory(const FilePath &dir)
{
if (dir == d->m_buildDirectoryAspect->filePath())
return;
d->m_buildDirectoryAspect->setFilePath(dir);
d->m_buildDirectoryAspect->setValue(dir);
const FilePath fixedDir = BuildDirectoryAspect::fixupDir(buildDirectory());
if (!fixedDir.isEmpty())
d->m_buildDirectoryAspect->setFilePath(fixedDir);
d->m_buildDirectoryAspect->setValue(fixedDir);
emitBuildDirectoryChanged();
}

View File

@@ -252,7 +252,7 @@ Environment MakeStep::makeEnvironment() const
void MakeStep::setMakeCommand(const FilePath &command)
{
m_makeCommandAspect.setFilePath(command);
m_makeCommandAspect.setValue(command);
}
int MakeStep::defaultJobCount()

View File

@@ -662,7 +662,7 @@ void ExecutableAspect::setPlaceHolderText(const QString &placeHolderText)
*/
void ExecutableAspect::setExecutable(const FilePath &executable)
{
m_executable.setFilePath(executable);
m_executable.setValue(executable);
m_executable.setShowToolTipOnLabel(true);
}

View File

@@ -190,7 +190,7 @@ private:
ExecutionDeviceSelector m_selector = RunDevice;
};
class PROJECTEXPLORER_EXPORT SymbolFileAspect : public Utils::StringAspect
class PROJECTEXPLORER_EXPORT SymbolFileAspect : public Utils::FilePathAspect
{
Q_OBJECT

View File

@@ -42,7 +42,7 @@ PySideBuildStep::PySideBuildStep(BuildStepList *bsl, Id id)
const FilePath pySideProjectPath = FilePath("pyside6-project").searchInPath();
if (pySideProjectPath.isExecutableFile())
m_pysideProject.setFilePath(pySideProjectPath);
m_pysideProject.setValue(pySideProjectPath);
setCommandLineProvider([this] { return CommandLine(m_pysideProject(), {"build"}); });
setWorkingDirectoryProvider([this] {
@@ -55,7 +55,7 @@ PySideBuildStep::PySideBuildStep(BuildStepList *bsl, Id id)
void PySideBuildStep::updatePySideProjectPath(const FilePath &pySideProjectPath)
{
m_pysideProject.setFilePath(pySideProjectPath);
m_pysideProject.setValue(pySideProjectPath);
}
void PySideBuildStep::doRun()

View File

@@ -133,7 +133,7 @@ void PythonWizardPage::initializePage()
const FilePath projectDir = FilePath::fromString(wiz->property("ProjectDirectory").toString());
m_createVenv.setValue(!projectDir.isEmpty());
if (m_venvPath.filePath().isEmpty())
m_venvPath.setFilePath(projectDir.isEmpty() ? FilePath{} : projectDir / "venv");
m_venvPath.setValue(projectDir.isEmpty() ? FilePath{} : projectDir / "venv");
updateInterpreters();
updateStateLabel();

View File

@@ -18,7 +18,7 @@ public:
Utils::BoolAspect flushEnabled;
Utils::IntegerAspect flushInterval;
Utils::StringAspect lastTraceFile;
Utils::FilePathAspect lastTraceFile;
Utils::BoolAspect aggregateTraces;
};

View File

@@ -568,7 +568,7 @@ static void saveLastTraceFile(const FilePath &filePath)
{
QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings();
if (filePath != settings->lastTraceFile.filePath()) {
settings->lastTraceFile.setFilePath(filePath);
settings->lastTraceFile.setValue(filePath);
settings->writeGlobalSettings();
}
}

View File

@@ -59,7 +59,7 @@ QnxRunConfiguration::QnxRunConfiguration(Target *target, Id id)
const DeployableFile depFile = target->deploymentData()
.deployableForLocalFile(localExecutable);
exeAspect->setExecutable(FilePath::fromString(depFile.remoteFilePath()));
symbolsAspect->setFilePath(localExecutable);
symbolsAspect->setValue(localExecutable);
});
setRunnableModifier([libAspect](Runnable &r) {

View File

@@ -101,7 +101,7 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent
installRootAspect->setSettingsKey(InstallRootAspectId);
installRootAspect->setExpectedKind(PathChooser::Directory);
installRootAspect->setLabelText(Tr::tr("Install root:"));
installRootAspect->setFilePath(rootPath);
installRootAspect->setValue(rootPath);
connect(installRootAspect, &StringAspect::changed,
this, &MakeInstallStep::updateArgsFromAspect);

View File

@@ -69,7 +69,7 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
const DeployableFile depFile = deploymentData.deployableForLocalFile(localExecutable);
exeAspect->setExecutable(runDevice->filePath(depFile.remoteFilePath()));
symbolsAspect->setFilePath(localExecutable);
symbolsAspect->setValue(localExecutable);
libAspect->setEnabled(buildDevice == runDevice);
});

View File

@@ -70,7 +70,7 @@ void SuppressionAspectPrivate::slotAddSuppression()
if (!files.isEmpty()) {
for (const FilePath &file : files)
m_model.appendRow(new QStandardItem(file.toString()));
conf->lastSuppressionDirectory.setFilePath(files.at(0).absolutePath());
conf->lastSuppressionDirectory.setValue(files.at(0).absolutePath());
//conf->setLastSuppressionDialogHistory(dialog.history());
if (!isGlobal)
q->apply();

View File

@@ -120,7 +120,7 @@ public:
void writeSettings() const;
void readSettings();
Utils::StringAspect lastSuppressionDirectory{this};
Utils::FilePathAspect lastSuppressionDirectory{this};
Utils::StringAspect lastSuppressionHistory{this};