edbee - Qt Editor Library
change.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QList>
9 #include <QString>
10 
11 namespace edbee {
12 
13 class TextDocument;
14 class TextEditorController;
15 
16 
18 class Change
19 {
20 public:
21 
22  virtual ~Change();
23 
25  virtual void execute( TextDocument* document ) = 0;
26  virtual void revert( TextDocument* );
27 
28  virtual bool giveAndMerge( TextDocument* document, Change* textChange );
29  virtual bool canUndo();
30 
31  virtual bool isPersistenceRequired();
33  bool isDocumentChange();
34  virtual bool isGroup();
35 
36  virtual QString toString() = 0;
37 };
38 
39 
40 //--------------------------------------------------------------
41 
42 
44 class DocumentChange : public Change
45 {
46 public:
47 };
48 
49 
50 //--------------------------------------------------------------
51 
52 
55 {
56 public:
57  virtual bool isPersistenceRequired();
58  virtual void execute( TextDocument* );
59  virtual void revert( TextDocument*);
60  virtual QString toString();
61 };
62 
63 
64 //--------------------------------------------------------------
65 
66 
68 class ControllerChange : public Change
69 {
70 public:
73  virtual TextEditorController* controller();
74 
75 private:
76  TextEditorController* controllerRef_;
77 };
78 
79 
80 //--------------------------------------------------------------
81 
82 
85 {
86 public:
87  ChangeGroup( TextEditorController* controller );
88  virtual ~ChangeGroup();
89 
90  virtual bool isGroup();
91 
92  virtual bool isDiscardable();
93  virtual void groupClosed();
94 
95  virtual void execute( TextDocument* document);
96  virtual void revert( TextDocument* document);
97 
98  virtual bool giveAndMerge( TextDocument* document, Change* textChange ) = 0;
99  virtual void flatten();
100 
101  virtual void giveChange( TextDocument* doc, Change* change ) = 0;
102  virtual Change* at( int idx ) = 0;
103  virtual Change* take( int idx ) = 0;
104  virtual int size() = 0;
105  virtual void clear(bool performDelete=true) = 0;
106  Change* last();
107  Change* takeLast();
108  int recursiveSize();
109 
111 
112  virtual QString toString();
113 
114 private:
115  QList<Change*> changeList_;
116 };
117 
118 
119 
120 } // edbee
This is the base and abstract class of a text document A TextDocument is the model part of the editor...
Definition: textdocument.h:40
A textdocument change.
Definition: change.h:44
virtual TextEditorController * controllerContext()
A text command can belong to a controller/view When it&#39;s a view only command. The undo only applies o...
Definition: change.cpp:60
An undoable-command-group.
Definition: change.h:84
virtual QString toString()=0
virtual bool canUndo()
This method should return true if the change can be reverted.
Definition: change.cpp:42
virtual bool giveAndMerge(TextDocument *document, Change *textChange)
Gives the change and merges it if possible. This method should return false if the change couldn&#39;t be...
Definition: change.cpp:33
virtual void execute(TextDocument *document)=0
This method should execute the command.
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
a document text-change that doesn&#39;t do anyhting :-)
Definition: change.h:54
virtual void revert(TextDocument *)
this method reverts the given operation
Definition: change.cpp:22
bool isDocumentChange()
this method can be used to check if the given change is a document change
Definition: change.cpp:67
A basic change.
Definition: change.h:18
The texteditor works via the controller. The controller is the central point/mediater which maps/cont...
Definition: texteditorcontroller.h:37
A textcontroller command. This can ALSO be a document command.
Definition: change.h:68
virtual bool isPersistenceRequired()
This flag is used to mark this stack item as non-persistence requirable The default behaviour is that...
Definition: change.cpp:51
virtual ~Change()
a virtual empty destructor
Definition: change.cpp:16
virtual bool isGroup()
This method returns true if this change is a group change. When an object is group change it should b...
Definition: change.cpp:75