QtSpell  0.8.1
Spell checking for Qt text widgets
UndoRedoStack.hpp
1 /* QtSpell - Spell checking for Qt text widgets.
2  * Copyright (c) 2014 Sandro Mani
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef QTSPELL_UNDOREDOSTACK_HPP
20 #define QTSPELL_UNDOREDOSTACK_HPP
21 
22 #include <QObject>
23 #include <QStack>
24 
25 
26 namespace QtSpell {
27 
28 class TextEditProxy;
29 
30 class UndoRedoStack : public QObject
31 {
32  Q_OBJECT
33 public:
34  UndoRedoStack(TextEditProxy* textEdit);
35  void handleContentsChange(int pos, int removed, int added);
36  void clear();
37 
38 public slots:
39  void undo();
40  void redo();
41 
42 signals:
43  void undoAvailable(bool);
44  void redoAvailable(bool);
45 
46 private:
47  struct Action;
48  struct UndoableInsert;
49  struct UndoableDelete;
50 
51  bool m_actionInProgress;
52  TextEditProxy* m_textEdit;
53  QStack<Action*> m_undoStack;
54  QStack<Action*> m_redoStack;
55 
56  bool insertMergeable(const UndoableInsert* prev, const UndoableInsert* cur) const;
57  bool deleteMergeable(const UndoableDelete* prev, const UndoableDelete* cur) const;
58 };
59 
60 } // QtSpell
61 
62 #endif // QTSPELL_UNDOREDOSTACK_HPP
QtSpell namespace.
Definition: Checker.cpp:56