edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
edbee::AbstractRangedChange Class Referenceabstract

This is an abstract class for ranged changes This are changes (text changes and line changes) that span a range in an array. These ranges share a common alogrithm for performing merges, detecting overlaps etc. More...

#include <abstractrangedchange.h>

+ Inheritance diagram for edbee::AbstractRangedChange:
+ Collaboration diagram for edbee::AbstractRangedChange:

Public Member Functions

virtual ~AbstractRangedChange ()
 default destructor is empty
 
virtual int offset () const =0
 this method should return the offset of the change
 
virtual void setOffset (int value)=0
 this method should set the offset
 
void addOffset (int amount)
 Adds the given amount to the offset.
 
virtual void setDocLength (int value)=0
 this method should set the old length
 
virtual int docLength () const =0
 this method should return the length in the document
 
virtual int storedLength () const =0
 this method should return the length of this item in memory
 
bool isOverlappedBy (AbstractRangedChange *secondChange)
 This method checks if this textchange is overlapped by the second textchange overlapping is an exclusive overlap, which means the changes are really on top of eachother to test if the changes are touching use isTouchedBy.
 
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.
 
- Public Member Functions inherited from edbee::Change
virtual ~Change ()
 a virtual empty destructor
 
virtual void execute (TextDocument *document)=0
 This method should execute the command.
 
virtual void revert (TextDocument *)
 this method reverts the given operation
 
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 merged. When the method returns true the ownership of the given textchange is transfered to this class.
 
virtual bool canUndo ()
 This method should return true if the change can be reverted.
 
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.
 
virtual TextEditorControllercontrollerContext ()
 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!!
 
bool isDocumentChange ()
 this method can be used to check if the given change is a document change
 
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.
 
virtual QString toString ()=0
 

Protected Member Functions

virtual void mergeStoredData (AbstractRangedChange *change)=0
 implement this method to merge to old data. Sample implementation
 
int getMergedDocLength (AbstractRangedChange *change)
 Calculates the merged length.
 
int getMergedStoredLength (AbstractRangedChange *change)
 Calculates the merge data size, that's required for merging the given change.
 
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.
 
bool merge (AbstractRangedChange *change)
 This method merges the change.
 

Detailed Description

This is an abstract class for ranged changes This are changes (text changes and line changes) that span a range in an array. These ranges share a common alogrithm for performing merges, detecting overlaps etc.

Constructor & Destructor Documentation

◆ ~AbstractRangedChange()

edbee::AbstractRangedChange::~AbstractRangedChange ( )
virtual

default destructor is empty

Member Function Documentation

◆ addOffset()

void edbee::AbstractRangedChange::addOffset ( int amount)

Adds the given amount to the offset.

Parameters
amountthe offset to add

◆ docLength()

virtual int edbee::AbstractRangedChange::docLength ( ) const
pure virtual

this method should return the length in the document

Implemented in edbee::LineDataListChange, and edbee::TextChange.

◆ getMergedDocLength()

int edbee::AbstractRangedChange::getMergedDocLength ( AbstractRangedChange * change)
protected

Calculates the merged length.

Parameters
changethe change that't being merged

◆ getMergedStoredLength()

int edbee::AbstractRangedChange::getMergedStoredLength ( AbstractRangedChange * change)
protected

Calculates the merge data size, that's required for merging the given change.

Parameters
changethe change to merge with this change
Returns
the size of this change

◆ isOverlappedBy()

bool edbee::AbstractRangedChange::isOverlappedBy ( AbstractRangedChange * secondChange)

This method checks if this textchange is overlapped by the second textchange overlapping is an exclusive overlap, which means the changes are really on top of eachother to test if the changes are touching use isTouchedBy.

Parameters
secondChangethe other change to compare it to
Returns
tue if the changes overlap

◆ isTouchedBy()

bool edbee::AbstractRangedChange::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.

Parameters
secondChangethe other change to match
Returns
true if the changes overlap

◆ merge()

bool edbee::AbstractRangedChange::merge ( AbstractRangedChange * change)
protected

This method merges the change.

Parameters
documentthe document to merges
changethe change change to merge

◆ mergeStoredData()

virtual void edbee::AbstractRangedChange::mergeStoredData ( AbstractRangedChange * change)
protectedpure virtual

implement this method to merge to old data. Sample implementation

SingleTextChange* singleTextChange = dynamic_cast<SingleTextChange*>(change); QString newText; newText.resize( calculateMergeDataSize( change) ); mergeData( newText.data(), text_.data(), singleTextChange->text_.data(), change, sizeof(QChar) );

Implemented in edbee::LineDataListChange, and edbee::TextChange.

◆ mergeStoredDataViaMemcopy()

void edbee::AbstractRangedChange::mergeStoredDataViaMemcopy ( void * targetData,
void * data,
void * changeData,
AbstractRangedChange * change,
int itemSize )
protected

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.

Parameters
targetDatathe target of the data, (be sure enough space is reserved!!
datapointer to the data of this change (this can be a 0 pointer!, which results in 0-filling the target)
changeDatapointer to the of the other change data (this can be a 0 pointer!, which results in 0-filling the target)
changethe other change of the data to merge
itemSizethe size of single item

◆ offset()

virtual int edbee::AbstractRangedChange::offset ( ) const
pure virtual

this method should return the offset of the change

Implemented in edbee::LineDataListChange, and edbee::TextChange.

◆ setDocLength()

virtual void edbee::AbstractRangedChange::setDocLength ( int value)
pure virtual

this method should set the old length

Implemented in edbee::LineDataListChange, and edbee::TextChange.

◆ setOffset()

virtual void edbee::AbstractRangedChange::setOffset ( int value)
pure virtual

this method should set the offset

Implemented in edbee::LineDataListChange, and edbee::TextChange.

◆ storedLength()

virtual int edbee::AbstractRangedChange::storedLength ( ) const
pure virtual

this method should return the length of this item in memory

Implemented in edbee::LineDataListChange, and edbee::TextChange.


The documentation for this class was generated from the following files: