diff options
author | hjk <hjk@qt.io> | 2022-11-23 09:21:31 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2022-11-23 08:41:55 +0000 |
commit | 7e9cab6e788aabc39aa1f5cc5ec8d1ca2a6a81f3 (patch) | |
tree | 3b07ef9a3d1fc3fa5522cf525bc3817a0564d2e9 /src/libs | |
parent | c7c6ddb8b07251270b42f648ccd5e08c6e8b2127 (diff) |
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>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/utils/filepath.cpp | 8 | ||||
-rw-r--r-- | src/libs/utils/filepath.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index dcbcd09fb9..55e0d8fb27 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -161,6 +161,14 @@ FilePath FilePath::fromParts(const QStringView scheme, const QStringView host, c 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() { return FilePath::fromString(QDir::currentPath()); diff --git a/src/libs/utils/filepath.h b/src/libs/utils/filepath.h index aa809b9a71..429be2619c 100644 --- a/src/libs/utils/filepath.h +++ b/src/libs/utils/filepath.h @@ -64,6 +64,7 @@ public: [[nodiscard]] static FilePath fromVariant(const QVariant &variant); [[nodiscard]] static FilePath fromUrl(const QUrl &url); [[nodiscard]] static FilePath fromParts(const QStringView scheme, const QStringView host, const QStringView path); + [[nodiscard]] static FilePath fromPathPart(const QStringView path); [[nodiscard]] static FilePath currentWorkingPath(); |