KTextEditor

kateundomanager.h
1 /*
2  SPDX-FileCopyrightText: 2009-2010 Bernhard Beschow <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef KATEUNDOMANAGER_H
8 #define KATEUNDOMANAGER_H
9 
10 #include <QObject>
11 
12 #include <ktexteditor_export.h>
13 
14 #include <QList>
15 
16 namespace KTextEditor
17 {
18 class DocumentPrivate;
19 }
20 class KateUndo;
21 class KateUndoGroup;
22 
23 namespace KTextEditor
24 {
25 class Document;
26 class View;
27 class Cursor;
28 }
29 
37 class KTEXTEDITOR_EXPORT KateUndoManager : public QObject
38 {
39  Q_OBJECT
40 
41 public:
47  explicit KateUndoManager(KTextEditor::DocumentPrivate *doc);
48 
49  ~KateUndoManager();
50 
51  KTextEditor::Document *document();
52 
58  uint undoCount() const;
59 
65  uint redoCount() const;
66 
70  void undoSafePoint();
71 
80  void setAllowComplexMerge(bool allow);
81 
82  bool isActive() const
83  {
84  return m_isActive;
85  }
86 
87  void setModified(bool modified);
88  void updateConfig();
89  void updateLineModifications();
90 
98  void setUndoRedoCursorsOfLastGroup(const KTextEditor::Cursor &undoCursor, const KTextEditor::Cursor &redoCursor);
99 
104  KTextEditor::Cursor lastRedoCursor() const;
105 
106 public Q_SLOTS:
112  void undo();
113 
119  void redo();
120 
121  void clearUndo();
122  void clearRedo();
123 
127  void editStart();
128 
132  void editEnd();
133 
134  void startUndo();
135  void endUndo();
136 
137  void inputMethodStart();
138  void inputMethodEnd();
139 
143  void slotTextInserted(int line, int col, const QString &s);
144 
148  void slotTextRemoved(int line, int col, const QString &s);
149 
153  void slotMarkLineAutoWrapped(int line, bool autowrapped);
154 
158  void slotLineWrapped(int line, int col, int length, bool newLine);
159 
163  void slotLineUnWrapped(int line, int col, int length, bool lineRemoved);
164 
168  void slotLineInserted(int line, const QString &s);
169 
173  void slotLineRemoved(int line, const QString &s);
174 
175 Q_SIGNALS:
176  void undoChanged();
177  void undoStart(KTextEditor::Document *);
178  void undoEnd(KTextEditor::Document *);
179  void redoStart(KTextEditor::Document *);
180  void redoEnd(KTextEditor::Document *);
181  void isActiveChanged(bool enabled);
182 
183 private Q_SLOTS:
189  void addUndoItem(KateUndo *undo);
190 
191  void setActive(bool active);
192 
193  void updateModified();
194 
195  void undoCancel();
196  void viewCreated(KTextEditor::Document *, KTextEditor::View *newView);
197 
198 private:
199  KTextEditor::View *activeView();
200 
201 private:
202  KTextEditor::DocumentPrivate *m_document = nullptr;
203  bool m_undoComplexMerge = false;
204  bool m_isActive = true;
205  KateUndoGroup *m_editCurrentUndo = nullptr;
206  QList<KateUndoGroup *> undoItems;
207  QList<KateUndoGroup *> redoItems;
208  // these two variables are for resetting the document to
209  // non-modified if all changes have been undone...
210  KateUndoGroup *lastUndoGroupWhenSaved = nullptr;
211  KateUndoGroup *lastRedoGroupWhenSaved = nullptr;
212  bool docWasSavedWhenUndoWasEmpty = true;
213  bool docWasSavedWhenRedoWasEmpty = true;
214 };
215 
216 #endif
KateUndoManager implements a document&#39;s history.
The Cursor represents a position in a Document.
Definition: cursor.h:71
bool editStart()
Enclose editor actions with editStart() and editEnd() to group them.
Class to manage a group of undo items.
Definition: kateundo.h:419
A KParts derived class representing a text document.
Definition: document.h:185
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:21
bool editEnd()
End a editor operation.
Base class for Kate undo commands.
Definition: kateundo.h:33
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:146
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 27 2021 22:56:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.