CuteLogger
Fast and simple logging solution for Qt based applications
autosavefile.h
1 /*
2  * Copyright (c) 2011-2015 Meltytech, LLC
3  * Author: Dan Dennedy <dan@dennedy.org>
4  * Loosely based on ideas from KAutoSaveFile by Jacob R Rideout <kde@jacobrideout.net>
5  * and Kdenlive by Jean-Baptiste Mardelle.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef AUTOSAVEFILE_H
22 #define AUTOSAVEFILE_H
23 
24 #include <QtCore/QFile>
25 #include <QtCore/QString>
26 
27 class AutoSaveFile : public QFile
28 {
29  Q_OBJECT
30 public:
31  explicit AutoSaveFile(const QString &filename, QObject *parent = 0);
32  ~AutoSaveFile();
33 
34  QString managedFileName() const { return m_managedFile; }
35  void changeManagedFile(const QString &filename);
36 
37  virtual bool open(OpenMode openmode);
38  static AutoSaveFile* getFile(const QString &filename);
39  static QString path();
40 
41 private:
42  Q_DISABLE_COPY(AutoSaveFile)
43  QString m_managedFile;
44  bool m_managedFileNameChanged;
45 };
46 
47 #endif // AUTOSAVEFILE_H