CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
operation_model_manager.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5#include <unordered_map>
6#include <QQmlContext>
7#include <type_traits> // For std::void_t (C++17) or std::conjunction_v (C++17/20)
8
9#include "models/operations/i_operation_model.h" // For IOperationModel
10#include "controller/image_controller_base.h" // For ImageControllerBase
11
12namespace CaptureMoment::UI {
13
14namespace Controller {
15class ImageControllerBase;
16}
17
18namespace Models::Manager {
19
27public:
30
31 // Disable copy and assignment
34
41 template<typename... TModels>
42 [[nodiscard]] bool createModels();
43
48 [[nodiscard]] bool connectModels();
49
55 [[nodiscard]] bool registerModelsToQml(QQmlContext* context);
56
57private:
58 Controller::ImageControllerBase* m_controller; // Reference to the controller
59 std::vector<std::shared_ptr<Models::Operations::IOperationModel>> m_operation_models; // Container for all models
60
61 // Internal method to create a specific model and add it to the container
62 template<typename T>
63 [[nodiscard]] bool addModel(const QString& qmlName); // qmlName = "brightnessControl", "contrastControl", etc.
64
65 // Helper to check if T has a 'name()' method returning QString
66 template<typename T>
67 using has_name_method = std::is_same_v<decltype(std::declval<T>().name()), QString>;
68
69 // Internal helper to create a single model and add it to the container
70 template<typename T>
71 [[nodiscard]] bool createAndAddModel(const QString& qmlName);
72};
73
74} // namespace Models::Manager
75
76} // namespace CaptureMoment::UI
Manages the creation, storage, and QML registration of operation model instances.
OperationModelManager(Controller::ImageControllerBase *controller)
bool registerModelsToQml(QQmlContext *context)
Registers all operation models to the QML context.
bool createModels()
Creates all operation models. Uses a variadic template to create multiple models in one call.
bool connectModels()
Connects all operation models to the controller.
OperationModelManager(const OperationModelManager &)=delete
OperationModelManager & operator=(const OperationModelManager &)=delete
Qt bridge between Core (PhotoEngine) and Qt UI.
CaptureMoment — footer