選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

38 行
1.3 KiB

  1. #pragma once
  2. #include <QObject>
  3. #include <QJsonObject>
  4. #include <QString>
  5. #include "editorwidget.h"
  6. #include "modules/HMI/hmieditorwidget.h"
  7. #include "modules/PLC/plceditorwidget.h"
  8. class FileManager : public QObject {
  9. Q_OBJECT
  10. public:
  11. explicit FileManager(QObject* parent = nullptr);
  12. // 通用接口:保存文件
  13. bool saveFile(EditorWidget* editor, const QString& filePath);
  14. // 通用接口:加载文件
  15. bool loadFile(EditorWidget* editor, const QString& filePath);
  16. private:
  17. // HMI 特定保存/加载方法
  18. bool saveHmiFile(HmiEditorWidget* widget, const QString& filePath);
  19. bool loadHmiFile(HmiEditorWidget* widget, const QString& filePath);
  20. // PLC 特定保存/加载方法
  21. bool savePlcFile(PlcEditorWidget* widget, const QString& filePath);
  22. bool loadPlcFile(PlcEditorWidget* widget, const QString& filePath);
  23. // 将 HMI 页面序列化为 JSON 对象
  24. QJsonObject serializeHmiPages(const QList<QGraphicsScene*>& pages);
  25. // 从 JSON 对象反序列化 HMI 页面
  26. bool deserializeHmiPages(HmiEditorWidget* widget, const QJsonObject& jsonObj);
  27. // 将 PLC 场景序列化为 JSON 对象
  28. QJsonObject serializePlcScene(QGraphicsScene* scene);
  29. // 从 JSON 对象反序列化 PLC 场景
  30. bool deserializePlcScene(PlcEditorWidget* widget, const QJsonObject& jsonObj);
  31. };