11#include <spdlog/spdlog.h>
15namespace Models::Manager {
26class OperationModelManager {
57 template<
typename... TModels>
74 [[nodiscard]]
const std::vector<std::shared_ptr<Models::Operations::OperationProvider>>&
getModels()
const {
return m_operation_models; }
83 [[nodiscard]]
const std::vector<std::shared_ptr<UI::Models::Operations::BaseAdjustmentModel>>&
getBaseAdjustmentModels()
const {
return m_base_adjustment_models; }
90 std::vector<std::shared_ptr<Models::Operations::OperationProvider>> m_operation_models;
98 std::vector<std::shared_ptr<UI::Models::Operations::BaseAdjustmentModel>> m_base_adjustment_models;
107 [[nodiscard]]
bool createAndAddModel() {
108 static_assert(std::is_base_of_v<UI::Models::Operations::OperationProvider, T>,
"T must derive from OperationProvider");
110 auto model = std::make_shared<T>();
112 spdlog::error(
"OperationModelManager::createAndAddModel: Failed to create model of type {}",
typeid(T).name());
115 spdlog::debug(
"OperationModelManager::createAndAddModel: Created model of type {}",
typeid(T).name());
117 QString qmlName = model->name().toLower() +
"Control";
118 spdlog::debug(
"OperationModelManager::createAndAddModel: Generated QML name '{}'", qmlName.toStdString());
120 m_operation_models.push_back(model);
123 if constexpr (std::is_base_of_v<UI::Models::Operations::BaseAdjustmentModel, T>) {
124 auto adjustment_model_ptr = std::dynamic_pointer_cast<UI::Models::Operations::BaseAdjustmentModel>(model);
125 if (adjustment_model_ptr) {
126 m_base_adjustment_models.push_back(adjustment_model_ptr);
129 spdlog::warn(
"OperationModelManager::createAndAddModel: Failed dynamic_pointer_cast for type {}",
typeid(T).name());
Generic Qt base class for single-value adjustment operations (e.g., Brightness, Contrast,...
Manages the creation, storage, and QML registration of operation model instances.
const std::vector< std::shared_ptr< Models::Operations::OperationProvider > > & getModels() const
Gets a const reference to the vector of created operation model instances. Provides access to the int...
bool registerModelsToQml(QQmlContext *context)
Registers the created operation models to the QML context. Makes the models available under their gen...
bool createModels()
Creates instances of specified operation model types. This is a variadic template method allowing for...
bool createBasicAdjustmentModels()
Creates instances of basic adjustment operation models. This method typically creates models like Bri...
OperationModelManager()
Constructs an OperationModelManager. Initializes the manager without requiring external dependencies ...
~OperationModelManager()=default
Destructor. Cleans up the owned operation model instances.
const std::vector< std::shared_ptr< UI::Models::Operations::BaseAdjustmentModel > > & getBaseAdjustmentModels() const
Gets a const reference to the vector of created BaseAdjustmentModel instances. Provides access to the...
OperationModelManager(const OperationModelManager &)=delete
OperationModelManager & operator=(const OperationModelManager &)=delete
Generic Qt base class for operation models with QObject infrastructure.