Loading...
Searching...
No Matches
ProjectSettingsFactory.hpp
1#pragma once
2#include <score/plugins/InterfaceList.hpp>
3#include <score/plugins/ProjectSettings/ProjectSettingsModel.hpp>
4#include <score/plugins/documentdelegate/plugin/DocumentPluginCreator.hpp>
5#include <score/plugins/documentdelegate/plugin/SerializableDocumentPlugin.hpp>
6
7#include <score_lib_base_export.h>
8namespace score
9{
10class DocumentPlugin;
11template <class Model>
12class SettingsDelegatePresenter;
13template <class Model>
14class SettingsDelegateView;
15
16class ProjectSettingsModel;
17
18using ProjectSettingsPresenter = SettingsDelegatePresenter<ProjectSettingsModel>;
19using ProjectSettingsView = SettingsDelegateView<ProjectSettingsModel>;
20
26class SCORE_LIB_BASE_EXPORT ProjectSettingsFactory : public DocumentPluginFactory
27{
28public:
30
31 virtual ProjectSettingsModel* makeModel(const score::DocumentContext&, QObject* parent)
32 = 0;
33
34 ProjectSettingsPresenter* makePresenter(
36 virtual ProjectSettingsView* makeView() = 0;
37
38protected:
39 virtual ProjectSettingsPresenter* makePresenter_impl(
41 = 0;
42};
43
44template <typename Model_T, typename Presenter_T, typename View_T>
46{
48 load(const VisitorVariant& var, score::DocumentContext& doc, QObject* parent) override
49 {
50 return deserialize_dyn(var, [&](auto&& deserializer) {
51 return new Model_T{doc, deserializer, parent};
52 });
53 }
54
56 makeModel(const score::DocumentContext& ctx, QObject* parent) override
57 {
58 return new Model_T(ctx, parent);
59 }
60
61 score::ProjectSettingsView* makeView() override { return new View_T; }
62
63 score::ProjectSettingsPresenter* makePresenter_impl(
65 QObject* parent) override
66 {
67 return new Presenter_T{safe_cast<Model_T&>(m), safe_cast<View_T&>(v), parent};
68 }
69};
70}
71
72#define SCORE_DECLARE_PROJECTSETTINGS_FACTORY(Factory, Model, Presenter, View, Uuid) \
73 class Factory final \
74 : public score::ProjectSettingsDelegateFactory_T<Model, Presenter, View> \
75 { \
76 SCORE_CONCRETE(Uuid) \
77 };
Reimplement to instantiate document plug-ins.
Definition DocumentPluginCreator.hpp:25
Definition ProjectSettingsFactory.hpp:46
The ProjectSettingsFactory class.
Definition ProjectSettingsFactory.hpp:27
Definition ProjectSettingsModel.hpp:9
Definition SettingsDelegatePresenter.hpp:17
Definition SettingsDelegateView.hpp:18
Base toolkit upon which the software is built.
Definition Application.cpp:90
The VisitorVariant struct.
Definition VisitorInterface.hpp:26
Definition DocumentContext.hpp:18