edbee - Qt Editor Library
|
The texteditor works via the controller. The controller is the central point/mediater which maps/controls all messages between the different editor componenents. More...
#include <texteditorcontroller.h>
Public Types | |
enum | AutoScrollToCaret { AutoScrollAlways, AutoScrollWhenFocus, AutoScrollNever } |
Public Slots | |
void | onTextChanged (edbee::TextBufferChange change) |
This slot is placed if a piece of text is replaced. More... | |
void | onSelectionChanged (edbee::TextRangeSet *oldRangeSet) |
the old selection has been changed More... | |
void | onLineDataChanged (int line, int length, int newLength) |
The line-data is changed, we need to repaint the selected lines. More... | |
void | updateAfterConfigChange () |
This method is used to update the component when the configuration has been changed. This is a temporary solution, perhaps we should make TextConfig signal changes A lot of changes don't require an updates, but some do. More... | |
virtual void | updateStatusText (const QString &extraText="") |
This method updates the status text. This is the text as displayed in the lower status bar. More... | |
virtual void | update () |
updates the main widget More... | |
virtual void | scrollPositionVisible (int xPos, int yPos) |
Asserts the view shows the given position. More... | |
virtual void | scrollOffsetVisible (int offset) |
Assets the view shows the given offset. More... | |
virtual void | scrollCaretVisible () |
This method makes sure caret 1 is vible. More... | |
virtual void | storeSelection (int coalesceId=0) |
This method adds a textchange on the stack that simply stores the current text-selection. More... | |
virtual void | replace (int offset, int length, const QString &text, int coalesceId) |
replaces the given text (single ranges) More... | |
virtual void | replaceSelection (const QString &text, int coalesceId=0) |
This method replaces the selection with the given text. More... | |
virtual void | replaceSelection (const QStringList &texts, int coalesceId=0) |
This method replaces the given selection with the given texts. More... | |
virtual void | replaceRangeSet (TextRangeSet &rangeSet, const QString &text, int coalesceId=0) |
Replaces the given rangeset with the given text. More... | |
virtual void | replaceRangeSet (TextRangeSet &rangeSet, const QStringList &texts, int coalesceId=0) |
Replaces the given ranges with the given texts. Different text per range is possible. More... | |
virtual void | moveCaretTo (int line, int col, bool keepAnchors) |
This method creates a command that moves the caret to the given line/column position A negative number means that we're counting from the end This method assumes line 0 is the first line! More... | |
virtual void | moveCaretToOffset (int offset, bool keepAnchors) |
Moves the caret to the given offset. More... | |
virtual void | addCaretAt (int line, int col) |
Adds a new caret to the selection. More... | |
virtual void | addCaretAtOffset (int offset) |
Adds a carert at the given offset. More... | |
virtual void | changeAndGiveTextSelection (TextRangeSet *rangeSet, int coalesceId=0) |
This method changes the text selection. More... | |
virtual void | undo (bool soft=false) |
This method performs an undo operation. By supplying soft only controller based operations are undone. When suppplying false a Document operation is being undone. More... | |
virtual void | redo (bool soft=false) |
This method performs an redo operation. By supplying soft only controller based operations are redone. When suppplying false a Document operation is being redone. More... | |
virtual void | beginUndoGroup (ChangeGroup *group) |
Starts an undo group. More... | |
virtual void | endUndoGroup (int coalesceId, bool flatten) |
Ends the undo-group. More... | |
virtual void | executeCommand (TextEditorCommand *textCommand) |
This method executes the command. More... | |
virtual bool | executeCommand (const QString &name=QString()) |
Executes a command with the given name. More... | |
Signals | |
void | updateStatusTextSignal (const QString &text) |
This signal is fired if the statusbar needs updating. More... | |
void | textDocumentChanged (edbee::TextDocument *oldDocument, edbee::TextDocument *newDocument) |
This signal is fired if the textdocument changes. More... | |
void | commandToBeExecuted (edbee::TextEditorCommand *command) |
this method is executed when a command is going to be executed More... | |
void | commandExecuted (edbee::TextEditorCommand *command) |
Public Member Functions | |
TextEditorController (TextEditorWidget *widget=0, QObject *parent=0) | |
The constructor. More... | |
virtual | ~TextEditorController () |
Destroys the controller and associated objects. More... | |
void | notifyStateChange () |
This method is called to reset the caret timer and update the ui. More... | |
void | giveTextDocument (TextDocument *doc) |
sets the document and tranfers the ownership of the textdocument to this class More... | |
void | setTextDocument (TextDocument *doc) |
Set the text document. More... | |
void | setAutoScrollToCaret (AutoScrollToCaret autoScroll) |
Changes the autoScrollToCaret setting. More... | |
virtual AutoScrollToCaret | autoScrollToCaret () const |
Returns the autoScrollToCaret setting. More... | |
bool | hasFocus () |
This method return true if the text-editor has focus. More... | |
QAction * | createUnconnectedAction (const QString &command, const QString &text, const QIcon &icon=QIcon(), QObject *owner=0) |
This method creates an editor action that is. More... | |
QAction * | createAction (const QString &command, const QString &text, const QIcon &icon=QIcon(), QObject *owner=0) |
Creates a QAction object that performs the given editor action The shortcut of the given editor-command is retrieved from the keymap. More... | |
TextDocument * | textDocument () const |
Returns a reference to the textdocument. More... | |
TextSelection * | textSelection () const |
Returns the textselection. More... | |
TextRenderer * | textRenderer () const |
Returns the current text renderer. More... | |
void | setKeyMap (TextEditorKeyMap *keyMap) |
sets the keymap. It will replace (and if owned, delete) the previous keymap More... | |
void | giveKeyMap (TextEditorKeyMap *keyMap) |
gives a keymap to the editor. The ownership is transfered to this controller More... | |
TextEditorKeyMap * | keyMap () const |
Returns the current keymap. More... | |
void | setCommandMap (TextEditorCommandMap *commandMap) |
set a commandmap the ownership is NOT transfered to this object. The old owned command-map is deleted commandMap the new commandMap of this object More... | |
void | giveCommandMap (TextEditorCommandMap *commandMap) |
gives a commandmap to the editor The old associated command map is deleted More... | |
TextEditorCommandMap * | commandMap () const |
Returns the current commandmap. More... | |
TextEditorWidget * | widget () const |
Returns the active widget. More... | |
TextCaretCache * | textCaretCache () const |
Returns the textCaretCache. More... | |
void | giveTextSearcher (TextSearcher *searcher) |
Gives the text-searcher to this document. More... | |
TextSearcher * | textSearcher () |
Returnst the associated text searcher object. More... | |
DynamicVariables * | dynamicVariables () const |
this method returns the dynamic variables object for this controller The current implementation simply returns the application-wide environment variables More... | |
The texteditor works via the controller. The controller is the central point/mediater which maps/controls all messages between the different editor componenents.
|
explicit |
The constructor.
widget | the widget this controller is associated with parent the QObject parent of the controlle |
|
virtual |
Destroys the controller and associated objects.
|
virtualslot |
Adds a new caret to the selection.
line | the line number |
col | the column |
|
virtualslot |
Adds a carert at the given offset.
offset | the character offset to add the caret |
|
virtual |
Returns the autoScrollToCaret setting.
|
virtualslot |
Starts an undo group.
group | the undogroup to use |
|
virtualslot |
This method changes the text selection.
|
signal |
TextEditorCommandMap * edbee::TextEditorController::commandMap | ( | ) | const |
Returns the current commandmap.
|
signal |
this method is executed when a command is going to be executed
QAction * edbee::TextEditorController::createAction | ( | const QString & | command, |
const QString & | text, | ||
const QIcon & | icon = QIcon() , |
||
QObject * | owner = 0 |
||
) |
Creates a QAction object that performs the given editor action The shortcut of the given editor-command is retrieved from the keymap.
command | the command that needs to be executed. |
text | description of the command |
icon | the optional icon of the command |
owner | the QObject owner of this action |
connect the signal to executeCommand
QAction * edbee::TextEditorController::createUnconnectedAction | ( | const QString & | command, |
const QString & | text, | ||
const QIcon & | icon = QIcon() , |
||
QObject * | owner = 0 |
||
) |
This method creates an editor action that is.
command | the command that needs to be executed. |
text | description of the command |
icon | the optional icon of the command |
owner | the QObject owner of this action |
DynamicVariables * edbee::TextEditorController::dynamicVariables | ( | ) | const |
this method returns the dynamic variables object for this controller The current implementation simply returns the application-wide environment variables
|
virtualslot |
Ends the undo-group.
coalesceId | is used to decide if merging of groups is required. a value of 0 means NO merging and id > 0 means if the previous command had the same id, the command is merged |
flatten | when an undogroup is ended and flatten is set to true ALL sub-undo-groups are merged to this group |
|
virtualslot |
This method executes the command.
|
virtualslot |
Executes a command with the given name.
When the name hasn't been supplied. This functiona assumes the command is triggered by a QAction and it will retrieve the command-name from the QAction data method
name | of the command to execute |
void edbee::TextEditorController::giveCommandMap | ( | TextEditorCommandMap * | commandMap | ) |
gives a commandmap to the editor The old associated command map is deleted
commandMap | the new commandMap |
void edbee::TextEditorController::giveKeyMap | ( | TextEditorKeyMap * | keyMap | ) |
gives a keymap to the editor. The ownership is transfered to this controller
keyMap | the new keymap to give to the controller |
void edbee::TextEditorController::giveTextDocument | ( | TextDocument * | doc | ) |
sets the document and tranfers the ownership of the textdocument to this class
doc | the new document for this controlelr |
void edbee::TextEditorController::giveTextSearcher | ( | TextSearcher * | searcher | ) |
Gives the text-searcher to this document.
searcher | the new textsearcher for this document (The old one is deleted) |
bool edbee::TextEditorController::hasFocus | ( | ) |
This method return true if the text-editor has focus.
TextEditorKeyMap * edbee::TextEditorController::keyMap | ( | ) | const |
Returns the current keymap.
|
virtualslot |
This method creates a command that moves the caret to the given line/column position A negative number means that we're counting from the end This method assumes line 0 is the first line!
For example: moveCaretTo( 2, 1 ) => Moves the caret to the 3rd line and 2nd column moveCaretTo( -1, -2 ) => Moves the caret to the character before the last character
|
virtualslot |
Moves the caret to the given offset.
offset | the offset to move the caret to |
keepAnchors | should the anchors stay at the current position (extending the selection range) |
void edbee::TextEditorController::notifyStateChange | ( | ) |
This method is called to reset the caret timer and update the ui.
|
slot |
The line-data is changed, we need to repaint the selected lines.
line | the line number that had a data change |
length | the number of lines changed |
newLength | the new number of lines |
|
slot |
the old selection has been changed
oldRangeSet | the old range set of the change |
|
slot |
|
virtualslot |
This method performs an redo operation. By supplying soft only controller based operations are redone. When suppplying false a Document operation is being redone.
soft | perform a soft undo? |
|
virtualslot |
replaces the given text (single ranges)
offset | the character offset in the document |
length | the number of characters to replace |
text | the text to replace |
coalesceId | the identifier for grouping undo operations |
|
virtualslot |
Replaces the given rangeset with the given text.
reangeSet | hte ranges to replace |
text | the text to replace the selection with |
coalesceId | the identifier for grouping undo operations |
|
virtualslot |
Replaces the given ranges with the given texts. Different text per range is possible.
rangeSet | the rangeset to fille |
text | the texts to fill the given ranges with. |
coalesceId | the identifier for grouping undo operations |
|
virtualslot |
This method replaces the selection with the given text.
text | the text to replace the selection with |
coalesceId | the identifier for grouping undo operations |
|
virtualslot |
This method replaces the given selection with the given texts.
texts | the list of texts that need to be replaced |
coalesceID | the identifier for grouping undo operation |
|
virtualslot |
This method makes sure caret 1 is vible.
|
virtualslot |
Assets the view shows the given offset.
|
virtualslot |
Asserts the view shows the given position.
void edbee::TextEditorController::setAutoScrollToCaret | ( | TextEditorController::AutoScrollToCaret | autoScroll | ) |
Changes the autoScrollToCaret setting.
autoScroll | the new autoscroll to caret setting. This can be one of the following values:
|
void edbee::TextEditorController::setCommandMap | ( | TextEditorCommandMap * | commandMap | ) |
set a commandmap the ownership is NOT transfered to this object. The old owned command-map is deleted commandMap the new commandMap of this object
void edbee::TextEditorController::setKeyMap | ( | TextEditorKeyMap * | keyMap | ) |
sets the keymap. It will replace (and if owned, delete) the previous keymap
keyMap | the new keyMap to use |
void edbee::TextEditorController::setTextDocument | ( | TextDocument * | doc | ) |
Set the text document.
doc | the document for this controller |
|
virtualslot |
This method adds a textchange on the stack that simply stores the current text-selection.
coalsceId | the coalescing identifier for merging/coalescing undo operations |
TextCaretCache * edbee::TextEditorController::textCaretCache | ( | ) | const |
Returns the textCaretCache.
TextDocument * edbee::TextEditorController::textDocument | ( | ) | const |
Returns a reference to the textdocument.
|
signal |
This signal is fired if the textdocument changes.
TextRenderer * edbee::TextEditorController::textRenderer | ( | ) | const |
Returns the current text renderer.
TextSearcher * edbee::TextEditorController::textSearcher | ( | ) |
Returnst the associated text searcher object.
TextSelection * edbee::TextEditorController::textSelection | ( | ) | const |
Returns the textselection.
|
virtualslot |
This method performs an undo operation. By supplying soft only controller based operations are undone. When suppplying false a Document operation is being undone.
|
virtualslot |
updates the main widget
|
slot |
This method is used to update the component when the configuration has been changed. This is a temporary solution, perhaps we should make TextConfig signal changes A lot of changes don't require an updates, but some do.
|
virtualslot |
This method updates the status text. This is the text as displayed in the lower status bar.
extraText | the extra text to show in the status bar |
|
signal |
This signal is fired if the statusbar needs updating.
TextEditorWidget * edbee::TextEditorController::widget | ( | ) | const |
Returns the active widget.