BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SaveService.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Project/SaveService.h
6 //! @brief Defines class SaveService
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_SAVESERVICE_H
16 #define BORNAGAIN_GUI_VIEW_PROJECT_SAVESERVICE_H
17 
18 #include <QObject>
19 #include <QQueue>
20 
21 class ProjectDocument;
22 class AutosaveController;
23 
24 //! Provides save/autosave of ProjectDocument in a thread.
25 
26 class SaveService : public QObject {
27  Q_OBJECT
28 
29 public:
30  explicit SaveService(QObject* parent = nullptr);
31 
32  void setDocument(ProjectDocument* document);
33 
34  void save(const QString& project_file_name);
35 
36  void setAutosaveEnabled(bool value);
37  bool isAutosaveEnabled() const;
38 
39  //! Sets autosave time (in msec)
40  void setAutosaveTime(int timerInterval);
41 
42  bool isSaving() const;
43 
44  void stopService();
45 
46 signals:
47  void projectSaved();
48 
49 public slots:
50  void onAutosaveRequest();
51 
52 private slots:
53  void onProjectSaved();
54 
55 private:
56  void process_queue();
57 
58  QQueue<QString> m_save_queue;
62 };
63 
64 #endif // BORNAGAIN_GUI_VIEW_PROJECT_SAVESERVICE_H
Triggers autosave request after some accumulated ammount of document changes.
Project document class handles all data related to the opened project (sample, job,...
Provides save/autosave of ProjectDocument in a thread.
Definition: SaveService.h:26
void projectSaved()
bool isSaving() const
Definition: SaveService.cpp:97
void setAutosaveTime(int timerInterval)
Sets autosave time (in msec)
Definition: SaveService.cpp:89
SaveService(QObject *parent=nullptr)
Definition: SaveService.cpp:44
void setAutosaveEnabled(bool value)
Definition: SaveService.cpp:70
void stopService()
ProjectDocument * m_document
Definition: SaveService.h:61
void save(const QString &project_file_name)
Definition: SaveService.cpp:62
void process_queue()
bool isAutosaveEnabled() const
Definition: SaveService.cpp:84
QQueue< QString > m_save_queue
Definition: SaveService.h:58
void setDocument(ProjectDocument *document)
Definition: SaveService.cpp:52
AutosaveController * m_autosave
Definition: SaveService.h:60
bool m_is_saving
Definition: SaveService.h:59
void onProjectSaved()
void onAutosaveRequest()