BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
IOHistory.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/IO/IOHistory.h
6 //! @brief Defines DatafieldIOHistory 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_SUPPORT_IO_IOHISTORY_H
16 #define BORNAGAIN_GUI_SUPPORT_IO_IOHISTORY_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:
29  : m_data(nullptr)
30  {
31  }
32 
34 
35  const SaveLoadInterface* item() const { return m_data; }
36 
37  QString fileName() const { return m_file_name; }
38 
39  bool wasModifiedSinceLastSave() const;
40 
41 private:
42  bool wasSavedBefore(const QDateTime& dtime) const;
43 
44  QDateTime m_last_saved;
45  QString m_file_name;
47 };
48 
49 //! Save history information for collection of items with non-XML data.
50 
52 public:
53  DatafieldDirHistory() = default;
54 
55  void markAsSaved(const SaveLoadInterface* item);
56 
58 
59  bool contains(const SaveLoadInterface* item);
60 
61  QStringList savedFileNames() const;
62 
63 private:
64  DatafieldSaveInfo itemInfo(const SaveLoadInterface* item) const;
65 
66  QVector<DatafieldSaveInfo> m_history;
67 };
68 
69 //! Save history information for set of directories.
70 
72 public:
73  bool hasHistory(const QString& dirname) const;
74 
75  bool wasModifiedSinceLastSave(const QString& dirname, const SaveLoadInterface* item);
76 
77  void setHistory(const QString& dirname, const DatafieldDirHistory& history);
78 
79  QStringList savedFileNames(const QString& dirname) const;
80 
81 private:
82  //!< Correspondence of directory name to save history.
83  QMap<QString, DatafieldDirHistory> m_dir_history;
84 };
85 
86 #endif // BORNAGAIN_GUI_SUPPORT_IO_IOHISTORY_H
Save history information for collection of items with non-XML data.
Definition: IOHistory.h:51
QStringList savedFileNames() const
Returns list of file names used to save all items in a history.
Definition: IOHistory.cpp:75
DatafieldSaveInfo itemInfo(const SaveLoadInterface *item) const
Definition: IOHistory.cpp:85
bool wasModifiedSinceLastSave(const SaveLoadInterface *item)
Definition: IOHistory.cpp:58
bool contains(const SaveLoadInterface *item)
Definition: IOHistory.cpp:64
QVector< DatafieldSaveInfo > m_history
Definition: IOHistory.h:66
void markAsSaved(const SaveLoadInterface *item)
Definition: IOHistory.cpp:48
DatafieldDirHistory()=default
Save history information for set of directories.
Definition: IOHistory.h:71
void setHistory(const QString &dirname, const DatafieldDirHistory &history)
Sets history for given directory. Previous history will be rewritten.
Definition: IOHistory.cpp:114
bool wasModifiedSinceLastSave(const QString &dirname, const SaveLoadInterface *item)
Definition: IOHistory.cpp:102
QStringList savedFileNames(const QString &dirname) const
Definition: IOHistory.cpp:121
QMap< QString, DatafieldDirHistory > m_dir_history
< Correspondence of directory name to save history.
Definition: IOHistory.h:83
bool hasHistory(const QString &dirname) const
Definition: IOHistory.cpp:97
Holds information about last save for items with non-XML data.
Definition: IOHistory.h:26
static DatafieldSaveInfo createSaved(const SaveLoadInterface *item)
Static method to create info for just saved item.
Definition: IOHistory.cpp:22
const SaveLoadInterface * m_data
Definition: IOHistory.h:46
QString fileName() const
Definition: IOHistory.h:37
const SaveLoadInterface * item() const
Definition: IOHistory.h:35
QDateTime m_last_saved
Definition: IOHistory.h:44
bool wasSavedBefore(const QDateTime &dtime) const
Returns true if IntensityDataItem was saved before given time.
Definition: IOHistory.cpp:40
QString m_file_name
Definition: IOHistory.h:45
bool wasModifiedSinceLastSave() const
Definition: IOHistory.cpp:33
Abstract base class to handle non-XML data save and load.