Utils: Introduce a FilePath::fromPathPart()

... as shortcut for the fromParts({}, {}, x) case.
Less noise on the user side, and saves a few cycles.

Change-Id: Ie5b2a76c7261a049a3e600f29c4edaff37ab3828
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2022-11-23 09:21:31 +01:00
parent c7c6ddb8b0
commit 7e9cab6e78
2 changed files with 9 additions and 0 deletions

View File

@@ -161,6 +161,14 @@ FilePath FilePath::fromParts(const QStringView scheme, const QStringView host, c
return result; return result;
} }
FilePath FilePath::fromPathPart(const QStringView path)
{
FilePath result;
result.m_data = path.toString();
result.m_pathLen = path.size();
return result;
}
FilePath FilePath::currentWorkingPath() FilePath FilePath::currentWorkingPath()
{ {
return FilePath::fromString(QDir::currentPath()); return FilePath::fromString(QDir::currentPath());

View File

@@ -64,6 +64,7 @@ public:
[[nodiscard]] static FilePath fromVariant(const QVariant &variant); [[nodiscard]] static FilePath fromVariant(const QVariant &variant);
[[nodiscard]] static FilePath fromUrl(const QUrl &url); [[nodiscard]] static FilePath fromUrl(const QUrl &url);
[[nodiscard]] static FilePath fromParts(const QStringView scheme, const QStringView host, const QStringView path); [[nodiscard]] static FilePath fromParts(const QStringView scheme, const QStringView host, const QStringView path);
[[nodiscard]] static FilePath fromPathPart(const QStringView path);
[[nodiscard]] static FilePath currentWorkingPath(); [[nodiscard]] static FilePath currentWorkingPath();