edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mergablechangegroup.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
9
10namespace edbee {
11
14class TextChange;
15class TextRangeSet;
16
24{
25public:
27 virtual ~MergableChangeGroup();
28
29 // this change cannot be optimized away
30 virtual bool isDiscardable();
31 virtual void groupClosed();
32
33 virtual void execute(TextDocument* document);
34 virtual void revert(TextDocument* document);
35
36private:
37 void addOffsetDeltaToChanges( QList<AbstractRangedChange*>& changes, int fromIndex, int delta );
38 int findInsertIndexForOffset( QList<AbstractRangedChange*>& changes, int offset );
39 int mergeChange( QList<AbstractRangedChange*>& changes, TextDocument* doc, AbstractRangedChange* newChange, int& delta );
40 void inverseMergeRemainingOverlappingChanges( QList<AbstractRangedChange*>& changes, TextDocument* doc, int mergedAtIndex, int orgStartOffset, int orgEndOffset , int delta);
41
42 void giveChangeToList( QList<AbstractRangedChange*>& changes, TextDocument* doc, AbstractRangedChange* change );
43 void giveAndMergeChangeToList( QList<AbstractRangedChange*>& changes, TextDocument* doc, AbstractRangedChange* change );
44
45//TODO: void giveAbstractRangedTextChange( TextDocument* doc, QList<AbstractRangedTextChange* changeList>& changes, AbstractRangedTextChange* change );
46
47public:
48 void giveSingleTextChange( TextDocument* doc, TextChange* change);
50
51 virtual void giveChange( TextDocument* doc, Change* change );
52 virtual Change* at( int idx );
53 virtual Change* take( int idx );
54 virtual int size();
55 virtual void clear(bool performDelete=true);
56
62 virtual bool giveAndMerge( TextDocument* document, Change* textChange );
63
64 virtual QString toString();
66
68
69protected:
70
71 bool mergeAsGroup( TextDocument* document, Change* textChange );
72 bool mergeAsSelection( TextDocument* document, Change* textChange );
73
74 void compressTextChanges( TextDocument* document );
75 void compressChanges( TextDocument* document );
76
77private:
78
79 QList<AbstractRangedChange*> textChangeList_;
80 QList<LineDataListChange*> lineDataTextChangeList_;
81 QList<Change*> miscChangeList_;
82
83
84 TextRangeSet* previousSelection_;
85 TextRangeSet* newSelection_;
86
87};
88
89} // edbee
This is an abstract class for ranged changes This are changes (text changes and line changes) that sp...
Definition abstractrangedchange.h:16
ChangeGroup(TextEditorController *controller)
default contructor
Definition change.cpp:137
A basic change.
Definition change.h:18
virtual TextEditorController * controller()
returns the controller
Definition change.cpp:126
A full line data text change. This means the growing or shrinking of the line data buffer It stores t...
Definition linedatalistchange.h:20
virtual int size()
returns the number of elements
Definition mergablechangegroup.cpp:348
virtual void execute(TextDocument *document)
Executes this textchange.
Definition mergablechangegroup.cpp:60
virtual void clear(bool performDelete=true)
clears all items
Definition mergablechangegroup.cpp:355
virtual QString toString()
Converts this textchange to a textual representation.
Definition mergablechangegroup.cpp:381
virtual void groupClosed()
the group is closed, we must 'store' the selection
Definition mergablechangegroup.cpp:49
virtual Change * take(int idx)
Takes the given item.
Definition mergablechangegroup.cpp:329
virtual void revert(TextDocument *document)
this method is called to revert the operation reverts the given operation
Definition mergablechangegroup.cpp:72
virtual bool giveAndMerge(TextDocument *document, Change *textChange)
This method tries to merge the given change with the other change The textChange supplied with this m...
Definition mergablechangegroup.cpp:372
bool mergeAsSelection(TextDocument *document, Change *textChange)
Definition mergablechangegroup.cpp:476
MergableChangeGroup(TextEditorController *controller)
The default complex textchange constructor.
Definition mergablechangegroup.cpp:21
void compressTextChanges(TextDocument *document)
Compresses the textchanges.
Definition mergablechangegroup.cpp:492
virtual Change * at(int idx)
returns the textchange at the given index
Definition mergablechangegroup.cpp:310
void moveChangesFromGroup(TextDocument *doc, ChangeGroup *group)
Moves all textchanges from the given group to this group.
Definition mergablechangegroup.cpp:409
void giveLineDataListTextChange(TextDocument *doc, LineDataListChange *change)
gives a line data list text change
Definition mergablechangegroup.cpp:219
QString toSingleTextChangeTestString()
Converts the textchangeList as as string The format is the following: <offset>:<length>:<str>,...
Definition mergablechangegroup.cpp:393
void compressChanges(TextDocument *document)
This is going to be the magic method that's going to merge all changes.
Definition mergablechangegroup.cpp:512
void giveSingleTextChange(TextDocument *doc, TextChange *change)
Gives a single textchange.
Definition mergablechangegroup.cpp:212
bool mergeAsGroup(TextDocument *document, Change *textChange)
merges the given textchange as a group.
Definition mergablechangegroup.cpp:455
virtual void giveChange(TextDocument *doc, Change *change)
Gives the change.
Definition mergablechangegroup.cpp:267
virtual bool isDiscardable()
default not discardable
Definition mergablechangegroup.cpp:42
This is the basic text change that's the base of the textchanges.
Definition textchange.h:19
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
The basic textrange class. A simple class of textrange with a simple vector implementation.
Definition textrange.h:202
#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