BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
OutputDataIOHistory.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/mainwindow/OutputDataIOHistory.h
6 //! @brief Defines OutputDataIOHistory classes
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_OUTPUTDATAIOHISTORY_H
16 #define BORNAGAIN_GUI_COREGUI_MAINWINDOW_OUTPUTDATAIOHISTORY_H
17 
18 #include <QDateTime>
19 #include <QMap>
20 #include <QVector>
21 
22 class SaveLoadInterface;
23 
24 //! Holds information about last save for items with non-XML data.
25 
27 public:
28  OutputDataSaveInfo() : m_data(nullptr) {}
29 
31 
32  const SaveLoadInterface* item() const { return m_data; }
33 
34  QString fileName() const { return m_file_name; }
35 
36  bool wasModifiedSinceLastSave() const;
37 
38 private:
39  bool wasSavedBefore(const QDateTime& dtime) const;
40 
41  QDateTime m_last_saved;
42  QString m_file_name;
44 };
45 
46 //! Save history information for collection of items with non-XML data.
47 
49 public:
51 
52  void markAsSaved(const SaveLoadInterface* item);
53 
55 
56  bool contains(const SaveLoadInterface* item);
57 
58  QStringList savedFileNames() const;
59 
60 private:
62 
63  QVector<OutputDataSaveInfo> m_history;
64 };
65 
66 //! Save history information for set of directories.
67 
69 public:
70  bool hasHistory(const QString& dirname) const;
71 
72  bool wasModifiedSinceLastSave(const QString& dirname, const SaveLoadInterface* item);
73 
74  void setHistory(const QString& dirname, const OutputDataDirHistory& history);
75 
76  QStringList savedFileNames(const QString& dirname) const;
77 
78 private:
79  //!< Correspondance of directory name to save history.
80  QMap<QString, OutputDataDirHistory> m_dir_history;
81 };
82 
83 #endif // BORNAGAIN_GUI_COREGUI_MAINWINDOW_OUTPUTDATAIOHISTORY_H
Save history information for collection of items with non-XML data.
bool wasModifiedSinceLastSave(const SaveLoadInterface *item)
QVector< OutputDataSaveInfo > m_history
void markAsSaved(const SaveLoadInterface *item)
QStringList savedFileNames() const
Returns list of file names used to save all items in a history.
OutputDataSaveInfo itemInfo(const SaveLoadInterface *item) const
bool contains(const SaveLoadInterface *item)
Save history information for set of directories.
bool wasModifiedSinceLastSave(const QString &dirname, const SaveLoadInterface *item)
bool hasHistory(const QString &dirname) const
QStringList savedFileNames(const QString &dirname) const
QMap< QString, OutputDataDirHistory > m_dir_history
< Correspondance of directory name to save history.
void setHistory(const QString &dirname, const OutputDataDirHistory &history)
Sets history for given directory. Previous history will be rewritten.
Holds information about last save for items with non-XML data.
bool wasModifiedSinceLastSave() const
bool wasSavedBefore(const QDateTime &dtime) const
Returns true if IntensityDataItem was saved before given time.
static OutputDataSaveInfo createSaved(const SaveLoadInterface *item)
Static method to create info for just saved item.
const SaveLoadInterface * item() const
const SaveLoadInterface * m_data
QString fileName() const
Purely virtual interface to handle non-XML data save and load.