Utils: Further split StringAspect and FilePathAspect

... by introducing "proper" FilePathAspect::value() (and therefore
hiding the inherited StringAspect::value(() and a temporary stringValue()
for the transition period for the remaining users of the QString value.

Change-Id: I40cf4238a09a9009cda0decba1acac82bd730233
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-07-10 12:31:25 +02:00
parent ebda2068dd
commit 96506f1f6a
9 changed files with 27 additions and 10 deletions

View File

@@ -1327,6 +1327,21 @@ FilePathAspect::FilePathAspect(AspectContainer *container)
setDisplayStyle(PathChooserDisplay);
}
FilePath FilePathAspect::operator()() const
{
return filePath();
}
FilePath FilePathAspect::value() const
{
return filePath();
}
QString FilePathAspect::stringValue() const
{
return StringAspect::value();
}
/*!
Sets the value of this file path aspect to \a value.

View File

@@ -518,7 +518,9 @@ class QTCREATOR_UTILS_EXPORT FilePathAspect : public StringAspect
public:
FilePathAspect(AspectContainer *container = nullptr);
FilePath operator()() const { return filePath(); }
FilePath operator()() const;
FilePath value() const;
QString stringValue() const;
void setValue(const FilePath &filePath);
void setDefaultValue(const FilePath &filePath);

View File

@@ -766,7 +766,7 @@ unsigned int FossilClient::binaryVersion() const
static unsigned int cachedBinaryVersion = 0;
static QString cachedBinaryPath;
const QString currentBinaryPath = settings().binaryPath.value();
const QString currentBinaryPath = settings().binaryPath.stringValue();
if (currentBinaryPath.isEmpty())
return 0;

View File

@@ -58,7 +58,7 @@ QString FossilJsExtension::defaultSslIdentityFile() const
if (!isConfigured())
return QString();
return settings().sslIdentityFile.value();
return settings().sslIdentityFile.stringValue();
}
QString FossilJsExtension::defaultLocalRepoPath() const
@@ -66,7 +66,7 @@ QString FossilJsExtension::defaultLocalRepoPath() const
if (!isConfigured())
return QString();
return settings().defaultRepoPath.value();
return settings().defaultRepoPath.stringValue();
}
bool FossilJsExtension::defaultDisableAutosync() const

View File

@@ -170,7 +170,7 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
*ok = false;
if (errorMessage)
*errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"")
.arg(binaryPath.value(), path().toUserOutput());
.arg(binaryPath().toUserOutput(), path().toUserOutput());
}
return resolvedBinPath;
}

View File

@@ -41,10 +41,10 @@ class NimPluginPrivate
public:
NimPluginPrivate()
{
Suggest::NimSuggestCache::instance().setExecutablePath(settings.nimSuggestPath.value());
Suggest::NimSuggestCache::instance().setExecutablePath(settings.nimSuggestPath.stringValue());
QObject::connect(&settings.nimSuggestPath, &StringAspect::changed,
&Suggest::NimSuggestCache::instance(), [this] {
Suggest::NimSuggestCache::instance().setExecutablePath(settings.nimSuggestPath.value());
Suggest::NimSuggestCache::instance().setExecutablePath(settings.nimSuggestPath.stringValue());
});
}

View File

@@ -61,7 +61,7 @@ BuildDirectoryAspect::BuildDirectoryAspect(AspectContainer *container, const Bui
});
setOpenTerminalHandler([this, bc] {
Core::FileUtils::openTerminal(FilePath::fromString(value()), bc->environment());
Core::FileUtils::openTerminal(value(), bc->environment());
});
}

View File

@@ -228,7 +228,7 @@ BuildConfiguration::~BuildConfiguration()
FilePath BuildConfiguration::buildDirectory() const
{
FilePath path = FilePath::fromUserInput(
environment().expandVariables(d->m_buildDirectoryAspect.value().trimmed()));
environment().expandVariables(d->m_buildDirectoryAspect.stringValue().trimmed()));
// FIXME: If the macro expander is expected to be able to do some
// structual changes, the fromUserInput() above might already have
// mis-parsed. Should this here be encapsulated in the FilePathAspect?

View File

@@ -38,7 +38,7 @@ VcsBaseSettings::~VcsBaseSettings() = default;
FilePaths VcsBaseSettings::searchPathList() const
{
return Utils::transform(path.value().split(HostOsInfo::pathListSeparator(), Qt::SkipEmptyParts),
return Utils::transform(path.stringValue().split(HostOsInfo::pathListSeparator(), Qt::SkipEmptyParts),
&FilePath::fromUserInput);
}