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
27class AutoSaveFile : public QFile
28{
29 Q_OBJECT
30public:
31 explicit AutoSaveFile(const QString &filename, QObject *parent = 0);
32 ~AutoSaveFile();
33
34 QString managedFileName() const
35 {
36 return m_managedFile;
37 }
38 void changeManagedFile(const QString &filename);
39
40 virtual bool open(OpenMode openmode);
41 static AutoSaveFile *getFile(const QString &filename);
42 static QString path();
43
44private:
45 Q_DISABLE_COPY(AutoSaveFile)
46 QString m_managedFile;
47 bool m_managedFileNameChanged;
48};
49
50#endif // AUTOSAVEFILE_H