KTextEditor

kateswapfile.h
1 /*
2  SPDX-FileCopyrightText: 2010-2018 Dominik Haumann <[email protected]>
3  SPDX-FileCopyrightText: 2010 Diana-Victoria Tiriplica <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KATE_SWAPFILE_H
9 #define KATE_SWAPFILE_H
10 
11 #include <QDataStream>
12 #include <QFile>
13 #include <QObject>
14 #include <QTimer>
15 
16 #include "katebuffer.h"
17 #include "katedocument.h"
18 #include "katetextbuffer.h"
19 #include <ktexteditor_export.h>
20 
21 #include <KTextEditor/Message>
22 
23 namespace KTextEditor
24 {
25 class ViewPrivate;
26 }
27 
28 namespace Kate
29 {
35 class KTEXTEDITOR_EXPORT SwapFile : public QObject
36 {
37  Q_OBJECT
38 
39 public:
40  explicit SwapFile(KTextEditor::DocumentPrivate *document);
41  ~SwapFile();
42  bool shouldRecover() const;
43 
44  void fileClosed();
45  QString fileName();
46 
47  KTextEditor::DocumentPrivate *document();
48 
49 private:
50  void setTrackingEnabled(bool trackingEnabled);
51  void removeSwapFile();
52  bool updateFileName();
53  bool isValidSwapFile(QDataStream &stream, bool checkDigest) const;
54 
55 private:
56  KTextEditor::DocumentPrivate *m_document;
57  bool m_trackingEnabled;
58 
59 protected Q_SLOTS:
60  void fileSaved(const QString &filename);
61  void fileLoaded(const QString &filename);
62  void modifiedChanged();
63 
64  void startEditing();
65  void finishEditing();
66 
67  void wrapLine(const KTextEditor::Cursor &position);
68  void unwrapLine(int line);
69  void insertText(const KTextEditor::Cursor &position, const QString &text);
70  void removeText(const KTextEditor::Range &range);
71 
72 public Q_SLOTS:
73  void discard();
74  void recover();
75  bool recover(QDataStream &, bool checkDigest = true);
76  void configChanged();
77 
78 private:
79  QDataStream m_stream;
80  QFile m_swapfile;
81  bool m_recovered;
82  bool m_needSync;
83  static QTimer *s_timer;
84 
85 protected Q_SLOTS:
86  void writeFileToDisk();
87 
88 private:
89  QTimer *syncTimer();
90 
91 public Q_SLOTS:
92  void showSwapFileMessage();
93  void showDiff();
94 
95 private:
96  QPointer<KTextEditor::Message> m_swapMessage;
97 };
98 
99 }
100 
101 #endif // KATE_SWAPFILE_H
The Cursor represents a position in a Document.
Definition: cursor.h:71
Class for tracking editing actions.
Definition: kateswapfile.h:35
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
An object representing a section of text, from one Cursor to another.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Nov 26 2020 22:56:12 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.