diff options
author | saturneric <[email protected]> | 2025-01-27 22:12:00 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2025-01-27 22:12:00 +0000 |
commit | a66d868f500c0bd94fe9783172ac3d17b1dbb6f5 (patch) | |
tree | 3c2c07e0ec717fac5beec08d9678bd311a84e134 /src/ui/struct | |
parent | refactor: reduce code duplication of gnupg file operations (diff) | |
download | GpgFrontend-a66d868f500c0bd94fe9783172ac3d17b1dbb6f5.tar.gz GpgFrontend-a66d868f500c0bd94fe9783172ac3d17b1dbb6f5.zip |
refactor: reduce code duplication of gnupg operations
Diffstat (limited to 'src/ui/struct')
-rw-r--r-- | src/ui/struct/GpgOperaResult.h | 2 | ||||
-rw-r--r-- | src/ui/struct/GpgOperaResultContext.cpp | 25 | ||||
-rw-r--r-- | src/ui/struct/GpgOperaResultContext.h | 4 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/ui/struct/GpgOperaResult.h b/src/ui/struct/GpgOperaResult.h index 7ee6ad37..18eef96a 100644 --- a/src/ui/struct/GpgOperaResult.h +++ b/src/ui/struct/GpgOperaResult.h @@ -28,12 +28,14 @@ #pragma once +#include "core/model/GFBuffer.h" namespace GpgFrontend::UI { struct GpgOperaResult { int status; QString report; QString tag; + GFBuffer o_buffer; GpgOperaResult(int status, QString report, QString tag); }; 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 diff --git a/src/ui/struct/GpgOperaResultContext.h b/src/ui/struct/GpgOperaResultContext.h index 526c1ef7..47333b73 100644 --- a/src/ui/struct/GpgOperaResultContext.h +++ b/src/ui/struct/GpgOperaResultContext.h @@ -36,6 +36,7 @@ namespace GpgFrontend::UI { struct GpgOperaCategory { QStringList paths; QStringList o_paths; + QContainer<GFBuffer> buffers; }; struct GpgOperaContext; @@ -54,6 +55,8 @@ struct GpgOperaContextBasement { auto GetContextOutPath(int category) -> QStringList&; + auto GetContextBuffer(int category) -> QContainer<GFBuffer>&; + auto GetAllPath() -> QStringList; auto GetAllOutPath() -> QStringList; @@ -64,6 +67,7 @@ struct GpgOperaContext { QStringList paths; QStringList o_paths; + QContainer<GFBuffer> buffers; explicit GpgOperaContext(QSharedPointer<GpgOperaContextBasement> base); }; |