QCodeEdit  2.2
Classes | Public Types | Protected Attributes | List of all members
QDocumentCommand Class Reference

The base class for document editing command. More...

Inheritance diagram for QDocumentCommand:
Inheritance graph
[legend]

Classes

struct  TextCommandData
 

Public Types

enum  Command {
  None, Insert, Erase, Replace,
  Custom
}
 

Protected Attributes

bool m_state
 
bool m_first
 
QDocumentm_doc
 
int m_redoOffset
 
int m_undoOffset
 
 QDocumentCommand (Command c, QDocument *d, QDocumentCommand *p=0)
 ctor
 
virtual ~QDocumentCommand ()
 dtor
 
virtual int id () const
 
virtual bool mergeWith (const QUndoCommand *command)
 Attempts to merge with another command. More...
 
virtual void redo ()
 Redo the command.
 
virtual void undo ()
 Undo the command.
 
bool isSilent () const
 
void setSilent (bool y)
 Set whether the command is silent.
 
bool keepAnchor () const
 
void setKeepAnchor (bool y)
 Set whether the command preserve selection of the target cursor. More...
 
void setTargetCursor (QDocumentCursorHandle *h)
 Set the target cursor. More...
 
void setRedoOffset (int off)
 ?
 
void setUndoOffset (int off)
 ?
 
static bool isAutoUpdated (const QDocumentCursorHandle *h)
 
static void enableAutoUpdate (QDocumentCursorHandle *h)
 Enable auto update for a given cursor.
 
static void disableAutoUpdate (QDocumentCursorHandle *h)
 Disable auto update for a given cursor.
 
static void discardHandlesFromDocument (QDocument *d)
 
void markRedone (QDocumentLineHandle *h, bool firstTime)
 Change the modification status of a line.
 
void markUndone (QDocumentLineHandle *h)
 Change the modifiaction status of a line.
 
void updateTarget (int l, int offset)
 Update the target cursor. More...
 
void insertText (int line, int pos, const QString &s)
 Insert some text. More...
 
void removeText (int line, int pos, int length)
 Remove some text. More...
 
void insertLines (int after, const QList< QDocumentLineHandle * > &l)
 Insert some lines in the host document. More...
 
void removeLines (int after, int n)
 Remove some lines from the host document. More...
 
void updateCursorsOnInsertion (int line, int column, int prefixLength, int numLines, int suffixLength)
 
void updateCursorsOnDeletion (int line, int column, int prefixLength, int numLines, int suffixLength)
 

Detailed Description

The base class for document editing command.

Member Function Documentation

◆ id()

int QDocumentCommand::id ( ) const
virtual
Returns
command identifier

◆ insertLines()

void QDocumentCommand::insertLines ( int  after,
const QList< QDocumentLineHandle * > &  l 
)
protected

Insert some lines in the host document.

Parameters
afterwhere to insert lines (line number)
llist of lines to insert

This helper method is provided so that subclasses may actually modify the document contents without using too much private API (QDocumentLineHandle is part of the private API...)

Referenced by QDocumentInsertCommand::redo(), and QDocumentEraseCommand::undo().

◆ insertText()

void QDocumentCommand::insertText ( int  line,
int  pos,
const QString &  s 
)
protected

Insert some text.

Parameters
linetarget line
postarget text position within line
stext to insert

This helper method is provided so that subclasses may actually modify the document contents without using private API.

Referenced by QDocumentInsertCommand::redo(), QDocumentEraseCommand::redo(), QDocumentInsertCommand::undo(), and QDocumentEraseCommand::undo().

◆ isAutoUpdated()

bool QDocumentCommand::isAutoUpdated ( const QDocumentCursorHandle h)
static
Returns
whether a given cursor is auto updated

◆ isSilent()

bool QDocumentCommand::isSilent ( ) const
Returns
whether the command is silent

Silent command do not update the editing cursor of the host document.

◆ keepAnchor()

bool QDocumentCommand::keepAnchor ( ) const
Returns
whether the command preserve selection of the target cursor

When this property is true, cursor adjustement upon command execution will preserve the anchor of target cursor and only alter its position thus keeping a selection.

Note
This is disabled by default

◆ mergeWith()

bool QDocumentCommand::mergeWith ( const QUndoCommand command)
virtual

Attempts to merge with another command.

Command merging is not implemented.

Reimplemented in QDocumentEraseCommand, and QDocumentInsertCommand.

◆ removeLines()

void QDocumentCommand::removeLines ( int  after,
int  n 
)
protected

Remove some lines from the host document.

Parameters
afterwhere to remove lines (line number)
nnumber of lines to remove

This helper method is provided so that subclasses may actually modify the document contents without using the private API.

Referenced by QDocumentEraseCommand::redo(), and QDocumentInsertCommand::undo().

◆ removeText()

void QDocumentCommand::removeText ( int  line,
int  pos,
int  length 
)
protected

Remove some text.

Parameters
linetarget line
postarget text position within line
lengthlength of the text to remove

This helper method is provided so that subclasses may actually modify the document contents without using private API.

Referenced by QDocumentInsertCommand::redo(), QDocumentEraseCommand::redo(), QDocumentInsertCommand::undo(), and QDocumentEraseCommand::undo().

◆ setKeepAnchor()

void QDocumentCommand::setKeepAnchor ( bool  y)

Set whether the command preserve selection of the target cursor.

Note
This is disabled by default

◆ setTargetCursor()

void QDocumentCommand::setTargetCursor ( QDocumentCursorHandle h)

Set the target cursor.

The position of the target cursor is update upon undo() and redo()

Referenced by QSnippetInsertionCommand::addCommand(), and QSnippetInsertionCommand::removeCommand().

◆ updateTarget()

void QDocumentCommand::updateTarget ( int  l,
int  offset 
)
protected

Update the target cursor.

Parameters
ltarget line
offsettarget text position within target line

References QDocumentLine::length(), QDocument::line(), and QDocument::lines().

Referenced by QDocumentInsertCommand::redo(), QDocumentEraseCommand::redo(), QDocumentInsertCommand::undo(), and QDocumentEraseCommand::undo().


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