edbee - Qt Editor Library
mergablechangegroup.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "edbee/models/change.h"
9 
10 namespace edbee {
11 
12 class AbstractRangedChange;
13 class LineDataListChange;
14 class TextChange;
15 class TextRangeSet;
16 
24 {
25 public:
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 
36 private:
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 
44 //TODO: void giveAbstractRangedTextChange( TextDocument* doc, QList<AbstractRangedTextChange* changeList>& changes, AbstractRangedTextChange* change );
45 
46 public:
47  void giveSingleTextChange( TextDocument* doc, TextChange* change );
49 
50  virtual void giveChange( TextDocument* doc, Change* change );
51  virtual Change* at( int idx );
52  virtual Change* take( int idx );
53  virtual int size();
54  virtual void clear(bool performDelete=true);
55 
61  virtual bool giveAndMerge( TextDocument* document, Change* textChange );
62 
63  virtual QString toString();
65 
66  void moveChangesFromGroup( TextDocument* doc, ChangeGroup* group);
67 
68 protected:
69 
70  bool mergeAsGroup( TextDocument* document, Change* textChange );
71  bool mergeAsSelection( TextDocument* document, Change* textChange );
72 
73  void compressTextChanges( TextDocument* document );
74  void compressChanges( TextDocument* document );
75 
76 private:
77 
78  QList<AbstractRangedChange*> textChangeList_;
79  QList<LineDataListChange*> lineDataTextChangeList_;
80  QList<Change*> miscChangeList_;
81 
82 
83  TextRangeSet* previousSelection_;
84  TextRangeSet* newSelection_;
85 
86 };
87 
88 } // 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
virtual QString toString()
Converts this textchange to a textual representation.
Definition: mergablechangegroup.cpp:383
MergableChangeGroup(TextEditorController *controller)
The default complex textchange constructor.
Definition: mergablechangegroup.cpp:23
virtual Change * take(int idx)
Takes the given item.
Definition: mergablechangegroup.cpp:331
An undoable-command-group.
Definition: change.h:84
virtual void clear(bool performDelete=true)
clears all items
Definition: mergablechangegroup.cpp:357
bool mergeAsSelection(TextDocument *document, Change *textChange)
Definition: mergablechangegroup.cpp:476
virtual int size()
returns the number of elements
Definition: mergablechangegroup.cpp:350
This is the basic text change that&#39;s the base of the textchanges.
Definition: textchange.h:18
A special mergable group textchange. Used by the editor to merge editing operation together...
Definition: mergablechangegroup.h:23
void giveSingleTextChange(TextDocument *doc, TextChange *change)
Gives a single textchange.
Definition: mergablechangegroup.cpp:214
virtual bool isDiscardable()
default not discardable
Definition: mergablechangegroup.cpp:44
bool mergeAsGroup(TextDocument *document, Change *textChange)
merges the given textchange as a group.
Definition: mergablechangegroup.cpp:455
virtual void groupClosed()
the group is closed, we must &#39;store&#39; the selection
Definition: mergablechangegroup.cpp:51
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
void compressChanges(TextDocument *document)
This is going to be the magic method that&#39;s going to merge all changes.
Definition: mergablechangegroup.cpp:512
virtual void execute(TextDocument *document)
Executes this textchange.
Definition: mergablechangegroup.cpp:62
virtual TextEditorController * controller()
returns the controller
Definition: change.cpp:128
virtual void giveChange(TextDocument *doc, Change *change)
Gives the change.
Definition: mergablechangegroup.cpp:269
A basic change.
Definition: change.h:18
void giveLineDataListTextChange(TextDocument *doc, LineDataListChange *change)
gives a line data list text change
Definition: mergablechangegroup.cpp:221
The texteditor works via the controller. The controller is the central point/mediater which maps/cont...
Definition: texteditorcontroller.h:37
The basic textrange class. A simple class of textrange with a simple vector implementation.
Definition: textrange.h:198
virtual Change * at(int idx)
returns the textchange at the given index
Definition: mergablechangegroup.cpp:312
QString toSingleTextChangeTestString()
Converts the textchangeList as as string The format is the following: <offset>:<length>:<str>,...
Definition: mergablechangegroup.cpp:395
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:374
This is an abstract class for ranged changes This are changes (text changes and line changes) that sp...
Definition: abstractrangedchange.h:15
virtual ~MergableChangeGroup()
The default destructor.
Definition: mergablechangegroup.cpp:35
virtual void revert(TextDocument *document)
this method is called to revert the operation reverts the given operation
Definition: mergablechangegroup.cpp:74
void moveChangesFromGroup(TextDocument *doc, ChangeGroup *group)
Moves all textchanges from the given group to this group.
Definition: mergablechangegroup.cpp:409
void compressTextChanges(TextDocument *document)
Compresses the textchanges.
Definition: mergablechangegroup.cpp:492
A full line data text change. This means the growing or shrinking of the line data buffer It stores t...
Definition: linedatalistchange.h:19