#pragma once #include "domain/hmi_model.h" #include "domain/runtime_state.h" #include #include #include class HmiEditorService; class HmiEditorWidget; class HmiNavigationService; class LogicEditorService; class LogicEditorWidget; class ProjectService; class RuntimeModeService; class RuntimeMonitorWidget; class QWidget; class QAction; namespace Ui { class MainWindow; } // 组织工程树、当前页面/逻辑选择和工程对象的界面刷新 class ProjectWorkspaceController final { public: using ResultReporter = std::function; using StatusReporter = std::function; ProjectWorkspaceController( QWidget &parent, Ui::MainWindow &ui, ProjectService &project_service, HmiEditorService &hmi_editor_service, LogicEditorService &logic_editor_service, RuntimeModeService &runtime_mode_service, HmiNavigationService &hmi_navigation_service, HmiEditorWidget &hmi_editor_widget, LogicEditorWidget &logic_editor_widget, RuntimeMonitorWidget &runtime_monitor_widget, std::string ¤t_hmi_page_id, std::string ¤t_logic_id, std::function show_control_properties, std::function show_logic_properties, ResultReporter result_reporter, StatusReporter status_reporter); void configure(); void refresh(); void updateActions(); void addPage(); void addLogic(); void renameSelectedItem(); void deleteSelectedItem(); void moveSelectedItem(int offset); void setSelectedPageAsInitial(); void toggleSelectedLogicEnabled(); const std::string ¤tHmiPageId() const; const std::string ¤tLogicId() const; private: enum class ItemKind { Root = 0, HmiPage = 1, ControlLogic = 2 }; void handleSelectionChanged(); void reportFailure( const QString &action, const std::string &message) const; QWidget &parent_; Ui::MainWindow &ui_; ProjectService &project_service_; HmiEditorService &hmi_editor_service_; LogicEditorService &logic_editor_service_; RuntimeModeService &runtime_mode_service_; HmiNavigationService &hmi_navigation_service_; HmiEditorWidget &hmi_editor_widget_; LogicEditorWidget &logic_editor_widget_; RuntimeMonitorWidget &runtime_monitor_widget_; std::string ¤t_hmi_page_id_; std::string ¤t_logic_id_; std::function show_control_properties_; std::function show_logic_properties_; ResultReporter result_reporter_; StatusReporter status_reporter_; QAction *add_page_action_ = nullptr; QAction *add_logic_action_ = nullptr; QAction *rename_item_action_ = nullptr; QAction *delete_item_action_ = nullptr; QAction *move_item_up_action_ = nullptr; QAction *move_item_down_action_ = nullptr; QAction *set_initial_page_action_ = nullptr; QAction *toggle_logic_enabled_action_ = nullptr; };