libs/kotext

KoTextEditingPlugin Class Reference

This is a base class for a text editing plugin as used by the text tool. More...

#include <KoTextEditingPlugin.h>

Inheritance diagram for KoTextEditingPlugin:

List of all members.

Signals

void startMacro (const QString &name)
void stopMacro ()

Public Member Functions

 KoTextEditingPlugin ()
virtual ~KoTextEditingPlugin ()
QHash< QString, KAction * > actions () const
virtual void checkSection (QTextDocument *document, int startPosition, int endPosition)
virtual void finishedParagraph (QTextDocument *document, int cursorPosition)=0
virtual void finishedWord (QTextDocument *document, int cursorPosition)=0

Protected Member Functions

void addAction (const QString &name, KAction *action)
QString paragraph (QTextDocument *document, int cursorPosition) const
void selectWord (QTextCursor &cursor, int cursorPosition) const

Detailed Description

This is a base class for a text editing plugin as used by the text tool.

When the user types text into the text shape text editing plugins will be notified of changes in the text document. The plugin is meant to be for altering or checking text as the user types it, To ensure a good user experience this plugin will only be called when it makes sense from a users perspective. The finishedWord() method will be called when the user makes at least one change to a word and then moves the cursor out of the word, a similar approach happens with the finishedParagraph(), it will only be called after the cursor has been moved out of the paragraph.

Definition at line 43 of file KoTextEditingPlugin.h.


Constructor & Destructor Documentation

KoTextEditingPlugin::KoTextEditingPlugin (  ) 

constructor

Definition at line 34 of file KoTextEditingPlugin.cpp.

KoTextEditingPlugin::~KoTextEditingPlugin (  )  [virtual]

Definition at line 39 of file KoTextEditingPlugin.cpp.


Member Function Documentation

QHash< QString, KAction * > KoTextEditingPlugin::actions (  )  const

Retrieves the entire collection of actions for the plugin.

Definition at line 108 of file KoTextEditingPlugin.cpp.

void KoTextEditingPlugin::addAction ( const QString name,
KAction *  action 
) [protected]

Add an action under the given name to the action collection.

Parameters:
name The name by which the action be retrieved again from the collection.
action The action to add.

Definition at line 75 of file KoTextEditingPlugin.cpp.

void KoTextEditingPlugin::checkSection ( QTextDocument document,
int  startPosition,
int  endPosition 
) [virtual]

This method will be called when the user selects a portion of text and selects this plugin to handle it.

You are free to alter the text via the textDocument. Be aware that operations should be done via a QTextCursor and should retain any formatting already present on the text.

Parameters:
document the text document that was altered.
startPosition the position at the start of the selection
endPosition the position at the end of the selection

Definition at line 80 of file KoTextEditingPlugin.cpp.

virtual void KoTextEditingPlugin::finishedParagraph ( QTextDocument document,
int  cursorPosition 
) [pure virtual]

This method will be called when the user makes at least one change to a paragraph and then moves the cursor out of the paragraph.

You are free to alter the paragraph via the textDocument. Be aware that operations should be done via a QTextCursor and should retain any formatting already present on the text. Note that finishedWord() is always called just prior to the call to this method.

Parameters:
document the text document that was altered.
cursorPosition the last altered position in the paragraph.
virtual void KoTextEditingPlugin::finishedWord ( QTextDocument document,
int  cursorPosition 
) [pure virtual]

This method will be called when the user makes at least one change to a word and then moves the cursor out of the word.

You are free to alter the word via the textDocument. Be aware that operations should be done via a QTextCursor and should retain any formatting already present on the text.

Parameters:
document the text document that was altered.
cursorPosition the last altered position in the word.
QString KoTextEditingPlugin::paragraph ( QTextDocument document,
int  cursorPosition 
) const [protected]

Helper method that allows you to easily get the text of the paragraph which holds the cursor position.

Please realize that altering of the paragraph text should be done on a QTextCursor and not by altering the returned string. Doing so would loose all text formatting of the paragraph.

Parameters:
document the document.
cursorPosition the position of the cursor somewhere in the word.

Definition at line 69 of file KoTextEditingPlugin.cpp.

void KoTextEditingPlugin::selectWord ( QTextCursor cursor,
int  cursorPosition 
) const [protected]

Helper method that allows you to easily get the word out of the document.

This method will create a selection on the parameter cursor where the altered word is selected. Example usage:

        QTextCursor cursor(document);
        selectWord(cursor, cursorPosition);
        QString word = cursor.selectedText();
Parameters:
cursor the cursor to alter.
cursorPosition the position of the cursor somewhere in the word.

Definition at line 44 of file KoTextEditingPlugin.cpp.

void KoTextEditingPlugin::startMacro ( const QString name  )  [signal]

emitted when a series of commands is started that together need to become 1 undo action.

void KoTextEditingPlugin::stopMacro (  )  [signal]

emitted when a series of commands has ended that together should be 1 undo action.


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