/** * @file alarm_configuration_dialog.h * @brief 定义报警定义配置对话框 * @version 1.0.0 * @author suyu * @date 2026-08-22 */ #pragma once #include #include #include namespace Ui { class AlarmConfigurationDialog; } class AlarmEditorService; struct AlarmDefinition; /** 报警定义编辑对话框;保存、更新和删除都委托 AlarmEditorService */ class AlarmConfigurationDialog final : public QDialog { public: /** 创建报警配置对话框并绑定报警编辑服务 */ explicit AlarmConfigurationDialog( AlarmEditorService &service, QWidget *parent = nullptr); /** 释放 Designer 界面对象 */ ~AlarmConfigurationDialog() override; private: /** 刷新左侧列表并尽量恢复原选中项 */ void reloadDefinitions(const std::string &selected_id = {}); /** 将当前选中报警加载到编辑区 */ void loadSelectedDefinition(); /** 根据报警类型更新条件输入项 */ void updateConditionOptions(); /** 新增一条报警定义 */ void addDefinition(); /** 更新当前选中的报警定义 */ void updateDefinition(); /** 删除当前选中的报警定义 */ void removeDefinition(); /** 从输入框读取报警定义 */ AlarmDefinition definitionFromInputs() const; /** 返回当前选中的报警标识 */ std::string selectedId() const; /** Qt Designer 生成的界面对象 */ std::unique_ptr ui_; /** 报警定义服务,不由对话框拥有 */ AlarmEditorService &service_; };