BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
projectdocument.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/mainwindow/projectdocument.h
6 //! @brief Defines class ProjectDocument
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_COREGUI_MAINWINDOW_PROJECTDOCUMENT_H
16 #define BORNAGAIN_GUI_COREGUI_MAINWINDOW_PROJECTDOCUMENT_H
17 
19 #include <QObject>
20 
21 class QIODevice;
22 class ApplicationModels;
23 class MessageService;
25 
26 namespace ProjectDocumentXML {
27 const QString BornAgainTag("BornAgain");
28 const QString BornAgainVersionAttribute("Version");
29 const QString InfoTag("DocumentInfo");
30 const QString InfoNameAttribute("ProjectName");
31 } // namespace ProjectDocumentXML
32 
33 //! Project document class handles all data related to the opened project
34 //! (sample, jobModel, project specific windows settings)
35 //!
36 //! e.g. if project file is /home/users/development/Untitled/Untitled.pro
37 //! projectName() - 'Untitled'
38 //! projectDir() - '/home/users/development/Untitled
39 //! projectFileName() - '/home/users/development/Untitled/Untitled.pro'
40 class ProjectDocument : public QObject {
41  Q_OBJECT
42 
43 public:
44  ProjectDocument(const QString& projectFileName = "");
45 
46  QString projectName() const;
47  void setProjectName(const QString& text);
48 
49  QString projectDir() const;
50  void setProjectDir(const QString& text);
51 
52  QString projectFileName() const;
53  void setProjectFileName(const QString& text);
54 
55  static QString projectFileExtension();
56 
57  void setApplicationModels(ApplicationModels* applicationModels);
58 
59  void save(const QString& project_file_name, bool autoSave = false);
60 
61  void save_project_file(const QString& project_file_name, bool autoSave = false);
62  void save_project_data(const QString& project_file_name);
63 
64  void load(const QString& project_file_name);
65 
66  bool hasValidNameAndPath();
67 
68  bool isModified();
69  void setModified(bool flag);
70 
71  void setLogger(MessageService* messageService);
72 
73  ProjectFlags::DocumentStatus documentStatus() const;
74 
75  bool isReady() const;
76 
77  bool hasWarnings() const;
78 
79  bool hasErrors() const;
80 
81  bool hasData() const;
82 
83  QString documentVersion() const;
84 
85 signals:
86  void modified();
87 
88 public slots:
89  void onModelChanged();
90 
91 private:
92  void readFrom(QIODevice* device);
93  void writeTo(QIODevice* device);
94 
95  void disconnectModels();
96  void connectModels();
97 
98  QString m_project_dir;
99  QString m_project_name;
102  ProjectFlags::DocumentStatus m_documentStatus;
106 };
107 
108 #endif // BORNAGAIN_GUI_COREGUI_MAINWINDOW_PROJECTDOCUMENT_H
Defines class ProjectFlags.
The service to collect messages from different senders.
Provide read/write of heavy data files in a separate thread.
Project document class handles all data related to the opened project (sample, jobModel,...
OutputDataIOService * m_dataService
QString m_project_name
void setApplicationModels(ApplicationModels *applicationModels)
static QString projectFileExtension()
QString projectFileName() const
MessageService * m_messageService
void setProjectDir(const QString &text)
QString documentVersion() const
bool isReady() const
QString projectName() const
void load(const QString &project_file_name)
void readFrom(QIODevice *device)
void setProjectName(const QString &text)
void writeTo(QIODevice *device)
void setLogger(MessageService *messageService)
ApplicationModels * m_applicationModels
bool hasData() const
ProjectFlags::DocumentStatus m_documentStatus
void save_project_data(const QString &project_file_name)
QString projectDir() const
void setProjectFileName(const QString &text)
bool hasWarnings() const
ProjectDocument(const QString &projectFileName="")
bool hasErrors() const
void save(const QString &project_file_name, bool autoSave=false)
void save_project_file(const QString &project_file_name, bool autoSave=false)
QString m_currentVersion
ProjectFlags::DocumentStatus documentStatus() const
void setModified(bool flag)
const QString InfoTag("DocumentInfo")
const QString InfoNameAttribute("ProjectName")
const QString BornAgainVersionAttribute("Version")
const QString BornAgainTag("BornAgain")