BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
AutosaveController.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Project/AutosaveController.h
6 //! @brief Defines class AutosaveController
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_AUTOSAVECONTROLLER_H
16 #define BORNAGAIN_GUI_VIEW_PROJECT_AUTOSAVECONTROLLER_H
17 
18 #include <QObject>
19 
20 class ProjectDocument;
21 class UpdateTimer;
22 
23 //! Triggers autosave request after some accumulated ammount of document changes.
24 
25 class AutosaveController : public QObject {
26  Q_OBJECT
27 public:
28  explicit AutosaveController(QObject* parent = nullptr);
29 
30  void setDocument(ProjectDocument* document);
31 
32  //! Sets autosave time (in msec)
33  void setAutosaveTime(int timerInterval);
34 
35  //! The complete path to the autosave dir (e.g. '/projects/Untitled2/autosave').
36  QString autosaveDir() const;
37  QString autosaveName() const;
38 
39  //! remove auto save directory for given project and all its content
40  void removeAutosaveDir() const;
41 
42 signals:
44 
45 private slots:
46  void onTimerTimeout();
47  void onDocumentDestroyed(QObject* object);
48  void onDocumentModified();
49 
50 private:
51  void autosave();
52 
53  //! Tries to make sure that the directory for auto saving exists. Tries to create it if not
54  //! existing so far. No creation, if project directory itself doesn't exist at all.
55  //! Returns true, if the directory finally exists.
56  bool assureAutoSaveDirExists() const;
57 
60 };
61 
62 #endif // BORNAGAIN_GUI_VIEW_PROJECT_AUTOSAVECONTROLLER_H
Triggers autosave request after some accumulated ammount of document changes.
void setAutosaveTime(int timerInterval)
Sets autosave time (in msec)
void setDocument(ProjectDocument *document)
void onDocumentDestroyed(QObject *object)
AutosaveController(QObject *parent=nullptr)
ProjectDocument * m_document
QString autosaveName() const
bool assureAutoSaveDirExists() const
Tries to make sure that the directory for auto saving exists. Tries to create it if not existing so f...
void removeAutosaveDir() const
remove auto save directory for given project and all its content
QString autosaveDir() const
The complete path to the autosave dir (e.g. '/projects/Untitled2/autosave').
Project document class handles all data related to the opened project (sample, job,...
The UpdateTimer class accumulates update requests during certain period of time, and at the end of th...
Definition: UpdateTimer.h:27