aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/advanceddockingsystem
diff options
context:
space:
mode:
authorhjk <[email protected]>2025-04-08 17:17:23 +0200
committerhjk <[email protected]>2025-04-11 09:38:34 +0000
commit9e9bbf215cb72467ec71be144b24b177e31afe0a (patch)
tree3a921f3cb8cace118182ff43ae29079b3067ead4 /src/libs/advanceddockingsystem
parent133cdb8e80894b0438e441a61ada13da5694ceaa (diff)
Utils: Replace Result class by type alias to std::expected<T, QString>
... to be able to conveniently return also non-void cases without being exposed to the syntax of expected. The price for the more general approach is some uglification of the void case: The previous 'Result' is now equivalent to 'Result<>', which needs to be spelled out in function signatures, and some changes to the special cases. Change-Id: Ic5026e237ef2077a0765cdb8287122cae99d699f Reviewed-by: Marcus Tillmanns <[email protected]> Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/libs/advanceddockingsystem')
-rw-r--r--src/libs/advanceddockingsystem/dockmanager.cpp16
-rw-r--r--src/libs/advanceddockingsystem/dockmanager.h2
2 files changed, 9 insertions, 9 deletions
diff --git a/src/libs/advanceddockingsystem/dockmanager.cpp b/src/libs/advanceddockingsystem/dockmanager.cpp
index e15c495f6ea..c38f1e286b4 100644
--- a/src/libs/advanceddockingsystem/dockmanager.cpp
+++ b/src/libs/advanceddockingsystem/dockmanager.cpp
@@ -1311,7 +1311,7 @@ expected_str<QString> DockManager::cloneWorkspace(const QString &originalFileNam
const FilePath clonePath = workspaceNameToFilePath(cloneName);
- const Result copyResult = originalPath.copyFile(clonePath);
+ const Result<> copyResult = originalPath.copyFile(clonePath);
if (!copyResult)
return make_unexpected(Tr::tr("Could not clone \"%1\" due to: %2")
.arg(originalPath.toUserOutput(), copyResult.error()));
@@ -1337,21 +1337,21 @@ expected_str<QString> DockManager::renameWorkspace(const QString &originalFileNa
return originalFileName;
}
-Result DockManager::resetWorkspacePreset(const QString &fileName)
+Result<> DockManager::resetWorkspacePreset(const QString &fileName)
{
qCInfo(adsLog) << "Reset workspace" << fileName;
Workspace *w = workspace(fileName);
if (!w)
- return Result::Error(Tr::tr("Workspace \"%1\" does not exist.").arg(fileName));
+ return ResultError(Tr::tr("Workspace \"%1\" does not exist.").arg(fileName));
if (!w->isPreset())
- return Result::Error(Tr::tr("Workspace \"%1\" is not a preset.").arg(fileName));
+ return ResultError(Tr::tr("Workspace \"%1\" is not a preset.").arg(fileName));
const FilePath filePath = w->filePath();
if (!filePath.removeFile())
- return Result::Error(Tr::tr("Cannot remove \"%1\".").arg(filePath.toUserOutput()));
+ return ResultError(Tr::tr("Cannot remove \"%1\".").arg(filePath.toUserOutput()));
return presetDirectory().pathAppended(fileName).copyFile(filePath);
}
@@ -1400,7 +1400,7 @@ expected_str<QString> DockManager::importWorkspace(const QString &filePath)
const FilePath targetFilePath = userDirectory().pathAppended(fileName);
- const Result copyResult = sourceFilePath.copyFile(targetFilePath);
+ const Result<> copyResult = sourceFilePath.copyFile(targetFilePath);
if (!copyResult)
return make_unexpected(
Tr::tr("Could not copy \"%1\" to \"%2\" due to: %3")
@@ -1441,7 +1441,7 @@ expected_str<QString> DockManager::exportWorkspace(const QString &targetFilePath
Tr::tr("The workspace \"%1\" does not exist ").arg(workspaceFile.toUserOutput()));
// Finally copy the workspace to the target
- const Result copyResult = workspaceFile.copyFile(targetFile);
+ const Result<> copyResult = workspaceFile.copyFile(targetFile);
if (!copyResult)
return make_unexpected(
Tr::tr("Could not copy \"%1\" to \"%2\" due to: %3")
@@ -1675,7 +1675,7 @@ void DockManager::syncWorkspacePresets()
continue;
}
- const Result copyResult = filePath.copyFile(
+ const Result<> copyResult = filePath.copyFile(
userDirectory().pathAppended(filePath.fileName()));
if (!copyResult)
qWarning() << QString("Could not copy '%1' to '%2' due to %3")
diff --git a/src/libs/advanceddockingsystem/dockmanager.h b/src/libs/advanceddockingsystem/dockmanager.h
index cb573327fe3..ffc38307c17 100644
--- a/src/libs/advanceddockingsystem/dockmanager.h
+++ b/src/libs/advanceddockingsystem/dockmanager.h
@@ -739,7 +739,7 @@ public:
Utils::expected_str<QString> renameWorkspace(const QString &originalFileName,
const QString &newName);
- Utils::Result resetWorkspacePreset(const QString &fileName);
+ Utils::Result<> resetWorkspacePreset(const QString &fileName);
/**
* \brief Save the currently active workspace.