KTextEditor::Document::EditingTransaction Class

class KTextEditor::Document::EditingTransaction

Editing transaction support. More...

Public Functions

EditingTransaction(KTextEditor::Document *document)
EditingTransaction(const KTextEditor::Document::EditingTransaction &)
~EditingTransaction()
void finish()
void start()
KTextEditor::Document::EditingTransaction &operator=(const KTextEditor::Document::EditingTransaction &)

Detailed Description

Edit commands during this sequence will be bunched together so that they represent a single undo command in the editor, and so that repaint events do not occur in between.

Your application should not return control to the event loop while it has an unterminated (i.e. this object is not destructed) editing sequence (result undefined) - so do all of your work in one go!

Using this class typically looks as follows:

void foo() {
    KTextEditor::Document::EditingTransaction transaction(document);
    // now call editing functions
    document->removeText(...)
    document->insertText(...)
}

Although usually not required, the EditingTransaction additionally allows to manually call finish() and start() in between.

See also editingStarted() and editingFinished().

Member Function Documentation

[explicit] EditingTransaction::EditingTransaction(KTextEditor::Document *document)

Constructs the object and starts an editing transaction by calling start().

document document for the transaction

See also start().

EditingTransaction::EditingTransaction(const KTextEditor::Document::EditingTransaction &)

No copy constructor, don't allow this to be copied.

[noexcept] EditingTransaction::~EditingTransaction()

Destructs the object and, if needed, finishes a running editing transaction by calling finish().

See also finish().

void EditingTransaction::finish()

By calling finish(), the editing transaction can be finished already before destruction of this instance.

See also start().

void EditingTransaction::start()

By calling start(), the editing transaction can be started again. This function only is of use in combination with finish().

See also finish().

KTextEditor::Document::EditingTransaction &EditingTransaction::operator=(const KTextEditor::Document::EditingTransaction &)

No assignment operator, no copying around editing transations.