BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectManager.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Project/ProjectManager.h
6 //! @brief Defines class ProjectManager
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_VIEW_PROJECT_PROJECTMANAGER_H
16 #define BORNAGAIN_GUI_VIEW_PROJECT_PROJECTMANAGER_H
17 
19 #include <QObject>
20 #include <QStringList>
21 
22 class MainWindow;
23 class MessageService;
24 class SaveService;
25 
26 //! Handles activity related to opening/save projects.
27 
28 class ProjectManager : public QObject {
29  Q_OBJECT
30 public:
31  ProjectManager(QObject* parent);
32  ~ProjectManager() override;
33 
34  static ProjectManager* instance();
35 
36  void readSettings();
37  void writeSettings();
38 
39  QStringList recentProjects();
40  QString projectDir() const;
41  QString userImportDir() const;
42  QString recentlyUsedImportFilter1D() const;
43  QString recentlyUsedImportFilter2D() const;
44  void setImportDir(const QString& dirname);
45  void setImportDirFromFilePath(const QString& filePath);
46  void setRecentlyUsedImportFilter1D(const QString& filter);
47  void setRecentlyUsedImportFilter2D(const QString& filter);
48 
49  bool isAutosaveEnabled() const;
50 
51 signals:
53  void documentOpenedOrClosed(bool opened);
56 
57 public slots:
58  void setAutosaveEnabled(bool value);
59  void clearRecentProjects();
60  void newProject();
61  bool closeCurrentProject();
62  bool saveProject(QString projectFileName = "");
63  bool saveProjectAs();
64  void openProject(QString fileName = "");
65 
66 private:
67  void createNewProject();
68  void deleteCurrentProject();
69  ProjectDocument::ReadResult loadProject(const QString& projectFileName,
70  MessageService& messageService);
71  QString acquireProjectFileName();
72  void addToRecentProjects();
73 
74  QString workingDirectory();
75  QString untitledProjectName();
76 
77  void riseProjectLoadFailedDialog(const MessageService& messageService);
78  void riseProjectLoadProblemDialog(const MessageService& messageService);
79  bool restoreProjectDialog(const QString& projectFileName, QString autosaveName);
80 
81  //!< Name of directory where project directory was created.
83 
84  //!< Name of directory from there user prefer to import files
86 
87  //! Recently used import filter for 1D files
89 
90  //! Recently used import filter for 2D files
92 
93  QStringList m_recentProjects;
95 
97 };
98 
99 #endif // BORNAGAIN_GUI_VIEW_PROJECT_PROJECTMANAGER_H
Defines class ProjectDocument.
The service to collect messages from different senders.
Handles activity related to opening/save projects.
bool saveProject(QString projectFileName="")
Processes save project request.
void setRecentlyUsedImportFilter1D(const QString &filter)
void createNewProject()
Calls dialog window to define project path and name.
void deleteCurrentProject()
void recentListModified()
QString untitledProjectName()
Will return 'Untitled' if the directory with such name doesn't exist in project path....
ProjectDocument::ReadResult loadProject(const QString &projectFileName, MessageService &messageService)
Load project data from file name. If autosave info exists, opens dialog for project restore.
void aboutToCloseDocument()
ProjectManager(QObject *parent)
static ProjectManager * instance()
QString m_importFilter2D
Recently used import filter for 2D files.
void riseProjectLoadProblemDialog(const MessageService &messageService)
QStringList m_recentProjects
void clearRecentProjects()
Clears list of recent projects.
void setAutosaveEnabled(bool value)
QString acquireProjectFileName()
Returns project file name from dialog. Returns empty string if dialog was canceled.
void setImportDirFromFilePath(const QString &filePath)
Sets user import directory in system settings.
void documentModified()
QString recentlyUsedImportFilter2D() const
SaveService * m_saveService
void addToRecentProjects()
Add name of the current project to the name of recent projects.
QString m_importDirectory
void setRecentlyUsedImportFilter2D(const QString &filter)
bool closeCurrentProject()
Processes close current project request. Call save/discard/cancel dialog, if necessary....
void readSettings()
Reads settings of ProjectManager from global settings.
QString m_workingDirectory
Name of directory from there user prefer to import files.
void openProject(QString fileName="")
Opens existing project. If fileName is empty, will popup file selection dialog.
void setImportDir(const QString &dirname)
Sets user import directory in system settings.
QString userImportDir() const
Returns directory name which was used by the user to import files.
~ProjectManager() override
bool isAutosaveEnabled() const
static ProjectManager * s_instance
void newProject()
Processes new project request (close old project, rise dialog for project name, create project).
bool saveProjectAs()
Processes 'save project as' request.
QStringList recentProjects()
Returns list of recent projects, validates if projects still exists on disk.
QString m_importFilter1D
Recently used import filter for 1D files.
QString projectDir() const
Returns name of the current project directory.
void documentOpenedOrClosed(bool opened)
QString workingDirectory()
Returns default project path.
QString recentlyUsedImportFilter1D() const
bool restoreProjectDialog(const QString &projectFileName, QString autosaveName)
Name of directory where project directory was created.
void writeSettings()
Saves settings of ProjectManager in global settings.
void riseProjectLoadFailedDialog(const MessageService &messageService)
Provides save/autosave of ProjectDocument in a thread.
Definition: SaveService.h:26
QString autosaveName(const QString &projectFileName)
Returns name of project for autoSave from given project file name. E.g. from '/projects/Untitled2/Unt...