QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
kautosavefile.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2026 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef QET_KAUTOSAVEFILE_H
19#define QET_KAUTOSAVEFILE_H
20
21#include <QFile>
22#include <QList>
23#include <QUrl>
24
25#include <memory>
26
27class QLockFile;
28
37class KAutoSaveFile : public QFile
38{
39 public:
40 explicit KAutoSaveFile(const QUrl &filename, QObject *parent = nullptr);
41 explicit KAutoSaveFile(QObject *parent = nullptr);
42 ~KAutoSaveFile() override;
43
44 QUrl managedFile() const;
45 void setManagedFile(const QUrl &filename);
46 virtual void releaseLock();
47 bool open(OpenMode openmode) override;
48
49 static QList<KAutoSaveFile *> staleFiles(
50 const QUrl &url,
51 const QString &applicationName = QString());
52 static QList<KAutoSaveFile *> allStaleFiles(
53 const QString &applicationName = QString());
54
55 private:
57 std::unique_ptr<QLockFile> m_lock;
59};
60
61#endif // QET_KAUTOSAVEFILE_H
bool open(OpenMode openmode) override
Definition kautosavefile.cpp:232
virtual void releaseLock()
Definition kautosavefile.cpp:217
~KAutoSaveFile() override
Definition kautosavefile.cpp:198
std::unique_ptr< QLockFile > m_lock
Definition kautosavefile.h:57
bool m_managed_file_name_changed
Definition kautosavefile.h:58
QUrl managedFile() const
Definition kautosavefile.cpp:203
QUrl m_managed_file
Definition kautosavefile.h:56
static QList< KAutoSaveFile * > allStaleFiles(const QString &applicationName=QString())
Definition kautosavefile.cpp:300
KAutoSaveFile(const QUrl &filename, QObject *parent=nullptr)
Definition kautosavefile.cpp:187
void setManagedFile(const QUrl &filename)
Definition kautosavefile.cpp:208
static QList< KAutoSaveFile * > staleFiles(const QUrl &url, const QString &applicationName=QString())
Definition kautosavefile.cpp:271