|
3 | 3 | #include <QObject> |
4 | 4 | #include <QPushButton> |
5 | 5 | #include <QSettings> |
6 | | -#include <functional> |
7 | 6 | #include "../../GUI/Include/TableView.hpp" |
8 | 7 | #include "../../Utils/Include/Namespace_Macro.hpp" |
9 | 8 | #include "../../Lib_Memory/Include/Memory.hpp" |
| 9 | +#include "../../Utils/Include/Meta_Macro.hpp" |
| 10 | +#include "../../Listener/Include/ListenerClearCache.hpp" |
| 11 | +#include "../../Utils/Include/Meta_Macro.hpp" |
10 | 12 |
|
11 | 13 | using std::function; |
12 | 14 | using ZClipboard::Lib_Memory::MakePtr; |
13 | 15 | using ZClipboard::Lib_Memory::PtrUnique; |
14 | 16 | using ZClipboard::GUI::TableView; |
| 17 | +using ZClipboard::Listener::ClearCacheListener; |
| 18 | +using std::enable_if_t; |
| 19 | +using std::is_invocable_v; |
15 | 20 |
|
16 | 21 | CORE_NAMESPACE |
17 | 22 |
|
18 | | - struct ParamImpl { |
| 23 | + struct CoreClearBuilderData { |
19 | 24 | QPushButton *button; |
| 25 | + QSettings *settings; |
| 26 | + TableView *tableView; |
20 | 27 | }; |
21 | 28 |
|
22 | | - class ClearCoreBuilder { |
23 | | - private: |
24 | | - PtrUnique<ParamImpl> Impl; |
| 29 | + class CoreClearBuilder { |
| 30 | + private: |
| 31 | + using Self = CoreClearBuilder; |
| 32 | + using ImplData = CoreClearBuilderData; |
| 33 | + using Listener = ClearCacheListener; |
| 34 | + using Button = QPushButton; |
| 35 | + using Settings = QSettings; |
| 36 | + |
| 37 | + private: |
| 38 | + PtrUnique<ImplData> Impl; |
| 39 | + PtrUnique<Listener> func_Builder; |
| 40 | + |
25 | 41 |
|
26 | | - public: |
27 | | - ClearCoreBuilder *StartBuild(QPushButton* button); |
28 | | - void ThenAddListener(function<void()> func); |
| 42 | + private: |
| 43 | + inline Button *GetClearButton() noexcept; |
| 44 | + inline Settings *GetSettings() noexcept; |
| 45 | + inline TableView *GetTableView() noexcept; |
| 46 | + |
| 47 | + public: |
| 48 | + Self *StartBuild(); |
| 49 | + |
| 50 | + CLASS_BUILD(T, V) |
| 51 | + Self *WithAndThen(T ImplData::*member, V&& value) { |
| 52 | + Impl.get()->*member = FORWARD(V, value); |
| 53 | + |
| 54 | + return this; |
| 55 | + } |
| 56 | + |
| 57 | + Self *WhenDone(); |
| 58 | + void Finally_Setup_Listener(); |
| 59 | + |
29 | 60 | }; |
30 | 61 |
|
31 | 62 | END_NAMESPACE |
|
0 commit comments