aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/struct/GpgOperaResultContext.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2025-01-27 22:12:00 +0000
committersaturneric <[email protected]>2025-01-27 22:12:00 +0000
commita66d868f500c0bd94fe9783172ac3d17b1dbb6f5 (patch)
tree3c2c07e0ec717fac5beec08d9678bd311a84e134 /src/ui/struct/GpgOperaResultContext.cpp
parentrefactor: reduce code duplication of gnupg file operations (diff)
downloadGpgFrontend-a66d868f500c0bd94fe9783172ac3d17b1dbb6f5.tar.gz
GpgFrontend-a66d868f500c0bd94fe9783172ac3d17b1dbb6f5.zip
refactor: reduce code duplication of gnupg operations
Diffstat (limited to 'src/ui/struct/GpgOperaResultContext.cpp')
-rw-r--r--src/ui/struct/GpgOperaResultContext.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/ui/struct/GpgOperaResultContext.cpp b/src/ui/struct/GpgOperaResultContext.cpp
index 5640a204..b01f8788 100644
--- a/src/ui/struct/GpgOperaResultContext.cpp
+++ b/src/ui/struct/GpgOperaResultContext.cpp
@@ -45,6 +45,12 @@ auto GpgOperaContextBasement::GetContextOutPath(int category) -> QStringList& {
return categories[category].o_paths;
}
+auto GpgOperaContextBasement::GetContextBuffer(int category)
+ -> QContainer<GFBuffer>& {
+ if (!categories.contains(category)) categories[category] = {};
+ return categories[category].buffers;
+}
+
auto GpgOperaContextBasement::GetAllPath() -> QStringList {
QStringList res;
@@ -66,12 +72,21 @@ auto GpgOperaContextBasement::GetAllOutPath() -> QStringList {
auto GetGpgOperaContextFromBasement(
const QSharedPointer<GpgOperaContextBasement>& base,
int category) -> QSharedPointer<GpgOperaContext> {
- if (base->GetContextPath(category).empty()) return nullptr;
+ if (!base->GetContextPath(category).isEmpty()) {
+ auto context = QSharedPointer<GpgOperaContext>::create(base);
- auto context = QSharedPointer<GpgOperaContext>::create(base);
+ context->paths = base->GetContextPath(category);
+ context->o_paths = base->GetContextOutPath(category);
+ return context;
+ }
+
+ if (!base->GetContextBuffer(category).isEmpty()) {
+ auto context = QSharedPointer<GpgOperaContext>::create(base);
+
+ context->buffers = base->GetContextBuffer(category);
+ return context;
+ }
- context->paths = base->GetContextPath(category);
- context->o_paths = base->GetContextOutPath(category);
- return context;
+ return nullptr;
}
} // namespace GpgFrontend::UI \ No newline at end of file