-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaste_presenter.cpp
More file actions
45 lines (35 loc) · 1.69 KB
/
Copy pathpaste_presenter.cpp
File metadata and controls
45 lines (35 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: Apache-2.0
#include "paste_presenter.hpp"
#include "gui/error_text.hpp"
namespace pastebin::gui {
PastePresenter::PastePresenter(::morph::bridge::Bridge& bridge, ::morph::exec::IExecutor* executor, QObject* parent)
: Presenter{parent}, _handler{bridge, executor} {
trackBound(_handler.whenBound());
}
void PastePresenter::reportError(const std::exception_ptr& err) { emit failed(::morph::ladder::gui::errorText(err)); }
void PastePresenter::create(CreatePaste action) {
track<CreatePasteResult>(
_handler.execute(std::move(action)), [this](CreatePasteResult result) { emit created(std::move(result)); },
[this](const std::exception_ptr& err) { reportError(err); });
}
void PastePresenter::get(GetPaste action) {
track<PasteView>(
_handler.execute(std::move(action)), [this](PasteView view) { emit loaded(std::move(view)); },
[this](const std::exception_ptr& err) { reportError(err); });
}
void PastePresenter::edit(EditPaste action) {
track<PasteView>(
_handler.execute(std::move(action)), [this](PasteView view) { emit edited(std::move(view)); },
[this](const std::exception_ptr& err) { reportError(err); });
}
void PastePresenter::remove(DeletePaste action) {
track<Ack>(
_handler.execute(std::move(action)), [this](Ack) { emit removed(); },
[this](const std::exception_ptr& err) { reportError(err); });
}
void PastePresenter::list(ListPastes action) {
track<ListPastesResult>(
_handler.execute(std::move(action)), [this](ListPastesResult result) { emit listed(std::move(result)); },
[this](const std::exception_ptr& err) { reportError(err); });
}
} // namespace pastebin::gui