25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
791 B

  1. #ifndef BASEDOCUMENT_H
  2. #define BASEDOCUMENT_H
  3. #include <QWidget>
  4. #include <QString>
  5. class BaseDocument : public QWidget
  6. {
  7. Q_OBJECT
  8. public:
  9. enum DocumentType { HMI, PLC };
  10. BaseDocument(DocumentType type, QWidget *parent = nullptr);
  11. virtual ~BaseDocument() = default;
  12. DocumentType type() const;
  13. virtual QString title() const = 0;
  14. virtual QString filePath() const;
  15. virtual void setFilePath(const QString &path);
  16. virtual bool isModified() const;
  17. virtual void setModified(bool modified);
  18. // 保存/加载接口
  19. virtual bool saveToFile(const QString &filePath) = 0;
  20. virtual bool loadFromFile(const QString &filePath) = 0;
  21. protected:
  22. DocumentType m_type;
  23. QString m_filePath;
  24. bool m_modified = false;
  25. };
  26. #endif // BASEDOCUMENT_H