Quark  0.1
AutoSaver.h++
Go to the documentation of this file.
1 #ifndef __libquark_util_AutoSaver_hxx
2 #define __libquark_util_AutoSaver_hxx
3 
4 #include <QBasicTimer>
5 #include <QObject>
6 #include <QTime>
7 
8 #include <quark/Quark.h++>
9 
10 namespace quark {
11 namespace util {
12 
22 class LIBQUARK_API AutoSaver : public QObject
23 {
24  Q_OBJECT;
25 
26  public:
27 
33  AutoSaver(QObject *parent);
34 
36  virtual ~AutoSaver();
37 
44  void setAutosaveInterval(int interval);
45 
47  static const int DEFAULT_AUTOSAVE_INTERVAL;
48 
55  void setMaxDelay(int delay);
56 
58  static const int MAX_DELAY;
59 
60  public slots:
61 
65  void changeOccurred();
66 
70  void saveIfNecessary();
71 
72  protected:
73 
74  virtual void timerEvent(QTimerEvent *event);
75 
76  private:
77 
78  QBasicTimer _timer;
79  QTime _firstChange;
80  int _autosaveInterval;
81  int _maxDelay;
82 
83  Q_DISABLE_COPY(AutoSaver);
84 };
85 
86 } // namespace util
87 } // namespace quark
88 
89 #endif // __libquark_util_AutoSaver_hxx
static const int MAX_DELAY
The maximum delay, in seconds, before a save operation occurs.
Definition: AutoSaver.h++:58
static const int DEFAULT_AUTOSAVE_INTERVAL
The default autosave interval, in seconds.
Definition: AutoSaver.h++:47
A class to be used in implementing a document autosave feature.
Definition: AutoSaver.h++:22
Definition: BarChartView.h++:6
#define LIBQUARK_API
Definition: Quark.h++:18