edbee - Qt Editor Library
|
This is the basic text change that's the base of the textchanges. More...
#include <textchange.h>
Public Member Functions | |
TextChange (int offset, int length, const QString &text) | |
Constructs a single textchange. More... | |
virtual | ~TextChange () |
undo's a single textchange More... | |
virtual void | execute (TextDocument *document) |
executes the given textchange More... | |
virtual void | revert (TextDocument *document) |
Reverts the single textchange. More... | |
virtual bool | giveAndMerge (TextDocument *document, Change *textChange) |
This method gives the given change to this textchange. The changes will be merged if possible. This method currently only works with executed changes!!! More... | |
virtual QString | toString () |
converts the change to a string More... | |
int | offset () const |
Return the offset. More... | |
void | setOffset (int offset) |
set the new offset More... | |
virtual int | docLength () const |
This is the length in the document. More... | |
virtual int | storedLength () const |
The content length is the length that's currently stored in memory. More... | |
void | setDocLength (int len) |
Set the length of the change. More... | |
QString | storedText () const |
The text currently stored in this textchange. More... | |
void | setStoredText (const QString &text) |
Sets the text of this change. More... | |
void | appendStoredText (const QString &text) |
Appends the text to this change. More... | |
const QString | docText (TextDocument *doc) const |
This method returns the text currently in the document. More... | |
QString | testString () |
This method returns a string used for testing. More... | |
Public Member Functions inherited from edbee::AbstractRangedChange | |
virtual | ~AbstractRangedChange () |
default destructor is empty More... | |
void | addOffset (int amount) |
Adds the given amount to the offset. More... | |
bool | isOverlappedBy (AbstractRangedChange *secondChange) |
This method checks if this textchange is overlapped by the second text change overlapping is an exclusive overlap, which means the changes are really on top of eachother to test if the changes are touching use isTouchedBy. More... | |
bool | isTouchedBy (AbstractRangedChange *secondChange) |
Touched ranges are ranges that are next to eachother Touching means the end offset of one range is the start offset of the other range. More... | |
Public Member Functions inherited from edbee::Change | |
virtual | ~Change () |
a virtual empty destructor More... | |
virtual bool | canUndo () |
This method should return true if the change can be reverted. More... | |
virtual bool | isPersistenceRequired () |
This flag is used to mark this stack item as non-persistence requirable The default behaviour is that every textchange requires persistence. It is also possible to have certain changes that do not require persitence but should be placed on the undo stack. More... | |
virtual TextEditorController * | controllerContext () |
A text command can belong to a controller/view When it's a view only command. The undo only applies only to this view warning a DOCUMENT change may NEVER return a controllerContext!! More... | |
bool | isDocumentChange () |
this method can be used to check if the given change is a document change More... | |
virtual bool | isGroup () |
This method returns true if this change is a group change. When an object is group change it should be inherited by TextChangeGroup. More... | |
Protected Member Functions | |
virtual void | mergeStoredData (AbstractRangedChange *change) |
This method merges the old data with the new data change the data to merge with. More... | |
void | replaceText (TextDocument *document) |
replaces the text and stores the 'old' content More... | |
Protected Member Functions inherited from edbee::AbstractRangedChange | |
int | getMergedDocLength (AbstractRangedChange *change) |
Calculates the merged length. More... | |
int | getMergedStoredLength (AbstractRangedChange *change) |
Calculates the merge data size, that's required for merging the given change. More... | |
void | mergeStoredDataViaMemcopy (void *targetData, void *data, void *changeData, AbstractRangedChange *change, int itemSize) |
This method merges the data via a memcopy. I really don't like this way of merging the data. though this is a way which support all kinds of arrays. I cannot use inheritance, because the types like QString don't have a common ancestor. More... | |
bool | merge (AbstractRangedChange *change) |
This method merges the change. More... | |
This is the basic text change that's the base of the textchanges.
This class re-uses the variables offset/length and text. Depending on the undo/redo state these variables contain the new data or the changed data
edbee::TextChange::TextChange | ( | int | offset, |
int | length, | ||
const QString & | text | ||
) |
Constructs a single textchange.
offset,the | offset of the change |
length,the | length of the change |
text,the | new text |
executed,a | boolean (mainly used for testing) to mark this change as exected |
|
virtual |
undo's a single textchange
void edbee::TextChange::appendStoredText | ( | const QString & | text | ) |
Appends the text to this change.
|
virtual |
This is the length in the document.
Implements edbee::AbstractRangedChange.
const QString edbee::TextChange::docText | ( | TextDocument * | doc | ) | const |
This method returns the text currently in the document.
|
virtual |
executes the given textchange
document | the document to execute the change on |
Implements edbee::Change.
|
virtual |
This method gives the given change to this textchange. The changes will be merged if possible. This method currently only works with executed changes!!!
document | the document |
textChange | the textchange to mege |
Reimplemented from edbee::Change.
|
protectedvirtual |
This method merges the old data with the new data change the data to merge with.
Implements edbee::AbstractRangedChange.
|
virtual |
|
protected |
replaces the text and stores the 'old' content
document | the document to change it for |
|
virtual |
Reverts the single textchange.
document | the document to execute the change on |
Reimplemented from edbee::Change.
|
virtual |
Set the length of the change.
len | sets the length of the change |
Implements edbee::AbstractRangedChange.
|
virtual |
void edbee::TextChange::setStoredText | ( | const QString & | text | ) |
Sets the text of this change.
text | the new text |
|
virtual |
The content length is the length that's currently stored in memory.
Implements edbee::AbstractRangedChange.
QString edbee::TextChange::storedText | ( | ) | const |
The text currently stored in this textchange.
QString edbee::TextChange::testString | ( | ) |
This method returns a string used for testing.
|
virtual |
converts the change to a string
Implements edbee::Change.