FilePath: Remove ::toDir() and deprecation hints

Change-Id: Ib561c019e3fd44cd85504ad4286eb3759ce19516
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-07-28 15:59:52 +02:00
parent 783f0e1205
commit 451d02c88d
14 changed files with 101 additions and 106 deletions

View File

@@ -153,7 +153,7 @@ Qt::CaseSensitivity FilePath::caseSensitivity() const
// FIXME: This could or possibly should the target device's file name case sensitivity
// into account by diverting to IDevice. However, as this is expensive and we are
// in time-critical path here, we go with "good enough" for now:
// The first approximation is "Anything unusual is not case sensitive"
// The first approximation is "most things are case-sensitive".
return Qt::CaseSensitive;
}
@@ -387,6 +387,16 @@ FilePath FilePath::fromUrl(const QUrl &url)
return fn;
}
FilePath FilePath::currentWorkingPath()
{
return FilePath::fromString(QDir::currentPath());
}
FilePath FilePath::rootPath()
{
return FilePath::fromString(QDir::rootPath());
}
static QString hostEncoded(QString host)
{
host.replace('%', "%25");
@@ -839,6 +849,7 @@ FilePath FilePath::parentDir() const
if (basePath.isEmpty())
return FilePath();
// TODO: Replace usage of QDir !!
const QDir base(basePath);
if (base.isRoot())
return FilePath();
@@ -854,22 +865,16 @@ FilePath FilePath::parentDir() const
FilePath FilePath::absolutePath() const
{
if (isAbsolutePath())
return parentDir();
QTC_ASSERT(!needsDevice(), return *this);
FilePath result = *this;
result.m_data = QFileInfo(m_data).absolutePath();
return result;
const FilePath parentPath = isAbsolutePath() ? parentDir() : FilePath::currentWorkingPath().resolvePath(*this).parentDir();
return parentPath.isEmpty() ? *this : parentPath;
}
FilePath FilePath::absoluteFilePath() const
{
if (isAbsolutePath())
return *this;
QTC_ASSERT(!needsDevice(), return *this);
FilePath result = *this;
result.m_data = QFileInfo(m_data).absoluteFilePath();
return result;
return FilePath::currentWorkingPath().resolvePath(*this);
}
QString FilePath::specialPath(SpecialPathComponent component)
@@ -1102,11 +1107,6 @@ QVariant FilePath::toVariant() const
return toString();
}
QDir FilePath::toDir() const
{
return QDir(m_data);
}
bool FilePath::operator==(const FilePath &other) const
{
return QString::compare(m_data, other.m_data, caseSensitivity()) == 0