edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
change.h
Go to the documentation of this file.
1// edbee - Copyright (c) 2012-2025 by Rick Blommers and contributors
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "edbee/exports.h"
7
8#include <QList>
9#include <QString>
10
11namespace edbee {
12
13class TextDocument;
15
16
19public:
20
21 virtual ~Change();
22
24 virtual void execute( TextDocument* document ) = 0;
25 virtual void revert( TextDocument* );
26
27 virtual bool giveAndMerge( TextDocument* document, Change* textChange );
28 virtual bool canUndo();
29
30 virtual bool isPersistenceRequired();
32 bool isDocumentChange();
33 virtual bool isGroup();
34
35 virtual QString toString() = 0;
36};
37
38
39//--------------------------------------------------------------
40
41
44{
45public:
46};
47
48
49//--------------------------------------------------------------
50
51
54{
55public:
56 virtual bool isPersistenceRequired();
57 virtual void execute( TextDocument* );
58 virtual void revert( TextDocument*);
59 virtual QString toString();
60};
61
62
63//--------------------------------------------------------------
64
65
68{
69public:
73
74private:
75 TextEditorController* controllerRef_;
76};
77
78
79//--------------------------------------------------------------
80
81
84{
85public:
87 virtual ~ChangeGroup();
88
89 virtual bool isGroup();
90
91 virtual bool isDiscardable();
92 virtual void groupClosed();
93
94 virtual void execute( TextDocument* document);
95 virtual void revert( TextDocument* document);
96
97 virtual bool giveAndMerge( TextDocument* document, Change* textChange );
98 virtual void flatten();
99
100 virtual void giveChange( TextDocument* doc, Change* change );
101 virtual Change* at( int idx );
102 virtual Change* take( int idx );
103 virtual int size();
104 virtual void clear(bool performDelete=true);
105 Change* last();
106 Change* takeLast();
107 int recursiveSize();
108
110
111 virtual QString toString();
112
113private:
114 QList<Change*> changeList_;
115};
116
117
118
119
120} // edbee
virtual void clear(bool performDelete=true)
Definition change.cpp:260
Change * last()
This method returns the last change in the change group.
Definition change.cpp:269
ChangeGroup(TextEditorController *controller)
default contructor
Definition change.cpp:137
virtual void groupClosed()
This method is called if the group is closed and is added to the stack Default implementation is to d...
Definition change.cpp:169
Change * takeLast()
Takes the ownership of the last element and removes it from the stack.
Definition change.cpp:278
virtual bool isGroup()
A group change is a group change, so this method returns true :)
Definition change.cpp:153
virtual int size()
Definition change.cpp:255
virtual Change * at(int idx)
Definition change.cpp:242
int recursiveSize()
The total number of items in the list (excluding the group items)
Definition change.cpp:287
virtual bool isDiscardable()
This method is called it the group is discardable. A discardable group will be optimized away if the ...
Definition change.cpp:162
virtual void execute(TextDocument *document)
executes this command group
Definition change.cpp:176
virtual Change * take(int idx)
Definition change.cpp:248
virtual bool giveAndMerge(TextDocument *document, Change *textChange)
When another group is given, a merge is performed.
Definition change.cpp:196
virtual void giveChange(TextDocument *doc, Change *change)
Definition change.cpp:236
virtual void flatten()
This method flattens the undo-group by expanding all subgroups to local groups.
Definition change.cpp:215
virtual QString toString()
Converts this change group to a string.
Definition change.cpp:322
virtual TextEditorController * controllerContext()
if this commandgroup only contains commands for a single controller context Then this context is retu...
Definition change.cpp:304
virtual void revert(TextDocument *document)
Reverts the command gorup.
Definition change.cpp:186
A basic change.
Definition change.h:18
bool isDocumentChange()
this method can be used to check if the given change is a document change
Definition change.cpp:65
virtual bool isPersistenceRequired()
This flag is used to mark this stack item as non-persistence requirable The default behaviour is that...
Definition change.cpp:49
virtual QString toString()=0
virtual TextEditorController * controllerContext()
A text command can belong to a controller/view When it's a view only command. The undo only applies o...
Definition change.cpp:58
virtual void execute(TextDocument *document)=0
This method should execute the command.
virtual bool giveAndMerge(TextDocument *document, Change *textChange)
Gives the change and merges it if possible. This method should return false if the change couldn't be...
Definition change.cpp:31
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:73
virtual bool canUndo()
This method should return true if the change can be reverted.
Definition change.cpp:40
virtual void revert(TextDocument *)
this method reverts the given operation
Definition change.cpp:20
virtual TextEditorController * controllerContext()
A text command can belong to a controller/view When it's a view only command. The undo only applies o...
Definition change.cpp:119
ControllerChange(TextEditorController *controller)
A controller specific textcommand. Warning you should NOT modify the textdocument!
Definition change.cpp:111
virtual TextEditorController * controller()
returns the controller
Definition change.cpp:126
A textdocument change.
Definition change.h:44
a document text-change that doesn't do anyhting :-)
Definition change.h:54
virtual void revert(TextDocument *)
does nothing
Definition change.cpp:95
virtual bool isPersistenceRequired()
Empty change doesn't do anything.
Definition change.cpp:83
virtual QString toString()
returns the name of the textchange
Definition change.cpp:100
virtual void execute(TextDocument *)
does nothing
Definition change.cpp:90
This is the base and abstract class of a text document A TextDocument is the model part of the editor...
Definition textdocument.h:42
The texteditor works via the controller. The controller is the central point/mediator which maps/cont...
Definition texteditorcontroller.h:39
#define EDBEE_EXPORT
Definition exports.h:15
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20