|
- #pragma once
- #include <QObject>
- #include <QJsonObject>
- #include <QString>
- #include "editorwidget.h"
- #include "modules/HMI/hmieditorwidget.h"
- #include "modules/PLC/plceditorwidget.h"
-
- class FileManager : public QObject {
- Q_OBJECT
- public:
- explicit FileManager(QObject* parent = nullptr);
-
- // 通用接口:保存文件
- bool saveFile(EditorWidget* editor, const QString& filePath);
- // 通用接口:加载文件
- bool loadFile(EditorWidget* editor, const QString& filePath);
-
- private:
- // HMI 特定保存/加载方法
- bool saveHmiFile(HmiEditorWidget* widget, const QString& filePath);
- bool loadHmiFile(HmiEditorWidget* widget, const QString& filePath);
-
- // PLC 特定保存/加载方法
- bool savePlcFile(PlcEditorWidget* widget, const QString& filePath);
- bool loadPlcFile(PlcEditorWidget* widget, const QString& filePath);
-
- // 将 HMI 页面序列化为 JSON 对象
- QJsonObject serializeHmiPages(const QList<QGraphicsScene*>& pages);
- // 从 JSON 对象反序列化 HMI 页面
- bool deserializeHmiPages(HmiEditorWidget* widget, const QJsonObject& jsonObj);
-
- // 将 PLC 场景序列化为 JSON 对象
- QJsonObject serializePlcScene(QGraphicsScene* scene);
- // 从 JSON 对象反序列化 PLC 场景
- bool deserializePlcScene(PlcEditorWidget* widget, const QJsonObject& jsonObj);
- };
|