QCodeEdit  2.2
Classes | Signals | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | Friends
QEditor Class Reference

A text editing widget. More...

Inheritance diagram for QEditor:
Inheritance graph
[legend]

List of all members.

Classes

struct  PlaceHolder
 A small structure holding placeholder data. More...

Signals

void loaded (QEditor *e, const QString &s)
void saved (QEditor *e, const QString &s)
void contentModified (bool y)
void titleChanged (const QString &title)
void textEdited (QKeyEvent *e)
void cursorPositionChanged ()
void copyAvailable (bool y)
void undoAvailable (bool y)
void redoAvailable (bool y)
void markChanged (const QString &f, QDocumentLineHandle *l, int mark, bool on)

Public Member Functions

int horizontalOffset () const
int verticalOffset () const
QPoint mapToContents (const QPoint &point) const
QPoint mapFromContents (const QPoint &point) const

Static Public Member Functions

static
QEditorInputBindingInterface
registeredInputBinding (const QString &n)
static const QList< QEditor * > & editors ()

Protected Types

enum  SaveState { Undefined, Saving, Saved, Conflict }

Protected Attributes

QString m_name
QString m_fileName
QMenu * pMenu
QHash< QString, QAction * > m_actions
QMenu * m_lineEndingsMenu
QActionGroup * m_lineEndingsActions
QMenu * m_bindingsMenu
QAction * aDefaultBinding
QActionGroup * m_bindingsActions
char m_saveState
quint16 m_checksum
QDocumentm_doc
QTextCodec * m_codec
QList
< QEditorInputBindingInterface * > 
m_bindings
QLanguageDefinitionm_definition
QPointer< QCodeCompletionEnginem_completionEngine
QDocumentCursor m_cursor
QDocumentCursor m_doubleClick
QDocumentCursor m_dragAndDrop
QList< QDocumentCursorm_mirrors
int m_curPlaceHolder
int m_cphOffset
QList< PlaceHolderm_placeHolders
int m_state
bool m_selection
QRect m_crect
QRect m_margins
QPoint m_clickPoint
QPoint m_dragPoint
QBasicTimer m_blink
QBasicTimer m_scroll
QBasicTimer m_click
QBasicTimer m_drag

Friends

class QEditConfig
class QEditorFactory
enum  CodecUpdatePolicy {
  NoUpdate = 0, UpdateOld = 1, UpdateDefault = 2, UpdateCustom = 4,
  UpdateAll = 7
}
 Specify the actions to take when changing the default codec.
enum  EditFlag {
  None = 0, Overwrite = 0x001, CursorOn = 0x002, ReadOnly = 0x004,
  MousePressed = 0x008, MaybeDrag = 0x010, Selection = 0x020, EnsureVisible = 0x040,
  FoldedCursor = 0x100, Internal = 0x00000fff, LineWrap = 0x00001000, CtrlNavigation = 0x00010000,
  CursorJumpPastWrap = 0x00020000, ReplaceTabs = 0x00100000, RemoveTrailing = 0x00200000, PreserveTrailingIndent = 0x00400000,
  AdjustIndent = 0x00800000, AutoCloseChars = 0x01000000, AutoIndent = 0x02000000, Accessible = 0xfffff000
}
 Flag holding information about the state of an editor. More...
static int m_defaultFlags = QEditor::AutoIndent | QEditor::AdjustIndent
static QTextCodec * m_defaultCodec = 0
static QList< QEditor * > m_editors
static
QEditorInputBindingInterface
m_defaultBinding = 0
static QHash< QString,
QEditorInputBindingInterface * > 
m_registeredBindings
 QEditor (QWidget *p=0)
 ctor
 QEditor (bool actions, QWidget *p=0)
 ctor
 QEditor (const QString &s, QWidget *p=0)
 ctor
 QEditor (const QString &s, bool actions, QWidget *p=0)
 ctor
virtual ~QEditor ()
 dtor
bool flag (EditFlag) const
bool canUndo () const
bool canRedo () const
QString text () const
QString text (int line) const
QTextCodec * codec () const
QDocumentdocument () const
QList
< QEditorInputBindingInterface * > 
inputBindings () const
bool isCursorVisible () const
QDocumentCursor cursor () const
int cursorMirrorCount () const
QDocumentCursor cursorMirror (int i) const
QLanguageDefinitionlanguageDefinition () const
QCodeCompletionEnginecompletionEngine () const
QAction * action (const QString &s)
virtual QRect cursorRect () const
virtual QRect selectionRect () const
virtual QRect lineRect (int line) const
virtual QRect lineRect (const QDocumentLine &l) const
virtual QRect cursorRect (const QDocumentCursor &c) const
QString name () const
QString fileName () const
bool isContentModified () const
bool isInConflict () const
int wrapWidth () const
virtual bool protectedCursor (const QDocumentCursor &c) const
void setFlag (EditFlag f, bool b)
 Sets the flag f.
void pageUp (QDocumentCursor::MoveMode moveMode)
 Go up by one page.
void pageDown (QDocumentCursor::MoveMode moveMode)
 Go down by one page.
void selectionChange (bool force=false)
 Does not do anything anymore...
void repaintCursor ()
 Request repaint (using QWidget::update()) for the region occupied by the cursor.
void ensureCursorVisible ()
 Ensure that the current cursor is visible.
void ensureVisible (int line)
 ensure that a given line is visible by updating scrollbars if needed
void ensureVisible (const QRect &rect)
 Ensure that a given rect is visible by updating scrollbars if needed.
void preInsert (QDocumentCursor &c, const QString &text)
void insertText (QDocumentCursor &c, const QString &text)
 Insert some text at a given cursor position.
QDocumentLine lineAtPosition (const QPoint &p) const
QDocumentCursor cursorForPosition (const QPoint &p) const
void setClipboardSelection ()
void setCursorPosition (const QPoint &p)
 Set the cursor to that nearest to a given viewport position.
void setCursorPosition (int line, int index)
 Set the cursor.
void getCursorPosition (int &line, int &index)
 Write the current cursor position to to integers.
void clearCursorMirrors ()
 Removes all cursor mirrors.
void addCursorMirror (const QDocumentCursor &c)
 Add a cursor mirror.
static int defaultFlags ()
static void setDefaultFlags (int f)
 Set the default editor flags.
static QTextCodec * defaultCodec ()
static void setDefaultCodec (int mib, int update)
static void setDefaultCodec (QTextCodec *c, int update)
 Set the default text codec.
static void setDefaultCodec (const char *name, int update)
static void setDefaultCodec (const QByteArray &name, int update)
static QString defaultInputBindingId ()
static QStringList registeredInputBindingIds ()
static void registerInputBinding (QEditorInputBindingInterface *b)
 Add an input binding to make it available for all editors.
static void unregisterInputBinding (QEditorInputBindingInterface *b)
 Remove an input binding from the pool of publicly available ones.
static void setDefaultInputBinding (QEditorInputBindingInterface *b)
 Set the default input binding.
static void setDefaultInputBinding (const QString &b)
 Set the default input binding.
void undo ()
 Undo the last editing operation, if any on the stack.
void redo ()
 Redo the last undone editing operation, if any on the stack.
void cut ()
 Cut the selected text, if any.
void copy ()
 Copy the selected text, if any.
void paste ()
 Paste text from the clipboard to the current cursor position.
void selectAll ()
 Select the whole text.
void find ()
 Show the search/replace panel, if any.
void findNext ()
 Ask the search/replace panel, if any, to move to next match.
void replace ()
 Show the search/replace panel, if any.
void gotoLine ()
 Show a panel or dialog to go to a specific line.
void indentSelection ()
 Indent the selection.
void unindentSelection ()
 Unindent the selection.
void commentSelection ()
 Comment the selection (or the current line) using single line comments supported by the language.
void uncommentSelection ()
 Uncomment the selection (or current line), provided it has been commented with single line comments.
void setLineWrapping (bool on)
 Set line wrapping.
virtual void save ()
 Save the underlying document to a file.
void save (const QString &filename)
 Save the content of the editor to a file.
virtual void print ()
 Print the content of the editor.
virtual void retranslate ()
 Run time translation entry point for compat with Edyuk.
virtual void write (const QString &s)
 Write some text at the current cursor position.
void addAction (QAction *a, const QString &menu, const QString &toolbar=QString())
 Add an action to the editor.
void removeAction (QAction *a, const QString &menu, const QString &toolbar=QString())
 remove an action form the editor
void load (const QString &file)
 load a text file
void setText (const QString &s)
 Set the text of the underlying document and update display.
void setCodec (int mib)
void setCodec (QTextCodec *c)
 Set the text codec to use for load/save operations.
void setCodec (const char *name)
void setCodec (const QByteArray &name)
void setDocument (QDocument *d)
void addInputBinding (QEditorInputBindingInterface *b)
 Set the current input binding.
void removeInputBinding (QEditorInputBindingInterface *b)
 Set the current input binding.
void setInputBinding (QEditorInputBindingInterface *b)
 Set the current input binding.
void setCursor (const QDocumentCursor &c)
 Set the document cursor.
void setLanguageDefinition (QLanguageDefinition *d)
 Set a language definition to the editor.
void setCompletionEngine (QCodeCompletionEngine *e)
 Set a code completion engine to the editor.
void zoom (int n)
 Zoom.
void setPanelMargins (int l, int t, int r, int b)
 Change the viewport margins to make room for panels.
void getPanelMargins (int *l, int *t, int *r, int *b) const
 Obtain the value of panel margins.
void setTitle (const QString &title)
 Set the title of the widget.
void highlight ()
 Force a full re-highlighting of the document.
void clearPlaceHolders ()
 Clear all placeholders.
void removePlaceHolder (int i)
 Remove a placeholder.
void addPlaceHolder (const PlaceHolder &p, bool autoUpdate=true)
 Add a placeholder.
int placeHolderCount () const
int currentPlaceHolder () const
void nextPlaceHolder ()
 Move to next placeholder.
void previousPlaceHolder ()
 Move to previous placeholder.
void setPlaceHolder (int i)
 Set the current placeholder to use.
virtual void setFileName (const QString &f)
 Changes the file name.
void checkClipboard ()
void reconnectWatcher ()
void fileChanged (const QString &f)
void setContentClean (bool y)
 Notify that the content is clean (modifications undone or document saved)
void emitCursorPositionChanged ()
 Emitted whenever the position of the cursor changes.
virtual void setContentModified (bool y)
 Notify that the content has been modified.
virtual bool event (QEvent *e)
virtual void paintEvent (QPaintEvent *e)
virtual void timerEvent (QTimerEvent *e)
virtual void keyPressEvent (QKeyEvent *e)
virtual void inputMethodEvent (QInputMethodEvent *e)
virtual void mouseMoveEvent (QMouseEvent *e)
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual void mouseDoubleClickEvent (QMouseEvent *e)
virtual void dragEnterEvent (QDragEnterEvent *e)
virtual void dragLeaveEvent (QDragLeaveEvent *e)
virtual void dragMoveEvent (QDragMoveEvent *e)
virtual void dropEvent (QDropEvent *e)
virtual void changeEvent (QEvent *e)
virtual void showEvent (QShowEvent *)
virtual void wheelEvent (QWheelEvent *e)
virtual void resizeEvent (QResizeEvent *e)
virtual void focusInEvent (QFocusEvent *e)
virtual void focusOutEvent (QFocusEvent *e)
virtual void contextMenuEvent (QContextMenuEvent *e)
 Context menu event.
virtual void closeEvent (QCloseEvent *e)
 Close event.
virtual bool focusNextPrevChild (bool next)
 Prevent tab key press to be considered as widget navigation.
virtual bool moveKeyEvent (QDocumentCursor &c, QKeyEvent *e, bool *leave)
 Handle cursor movements upon key event.
virtual bool isProcessingKeyEvent (QKeyEvent *e, int *offset=0)
 Determine whether a given key event is an editing operation.
virtual bool processCursor (QDocumentCursor &c, QKeyEvent *e, bool &b)
virtual void startDrag ()
 Start a drag and drop operation using the current selection.
virtual QMimeData * createMimeDataFromSelection () const
 creates a valid QMimeData object depending on the selection
virtual void insertFromMimeData (const QMimeData *d)
 Inserts the content of a QMimeData object at the cursor position.
virtual void scrollContentsBy (int dx, int dy)
void init (bool actions=true)
void updateBindingsMenu ()
void documentWidthChanged (int newWidth)
void documentHeightChanged (int newWidth)
void repaintContent (int i, int n)
void updateContent (int i, int n)
void markChanged (QDocumentLineHandle *l, int mark, bool on)
void bindingSelected (QAction *a)
void lineEndingSelected (QAction *a)
void lineEndingChanged (int lineEnding)
static QReliableFileWatchwatcher ()

Detailed Description

A text editing widget.

QEditor is the central widget in QCE. It allows user to view and edit a document.

QEditor has an API similar to that of QTextEdit and it behaves in a very similar way.

Notable differences are :

QEditor can gain features when it is managed by a QCodeEdit class which is responsible for panels management.


Member Enumeration Documentation

Flag holding information about the state of an editor.

Some of these are public and can be modified freely and some others are only meant to be used internally though they can still be read.


Constructor & Destructor Documentation

QEditor::QEditor ( QWidget p = 0)

ctor

Note:
Creates builtin menus/actions
QEditor::QEditor ( bool  actions,
QWidget p = 0 
)

ctor

Parameters:
actionsWhether builtin actions and menus should be created
QEditor::QEditor ( const QString &  s,
QWidget p = 0 
)

ctor

Parameters:
sfile to load
Note:
Creates builtin menus/actions

References setText().

QEditor::QEditor ( const QString &  s,
bool  actions,
QWidget p = 0 
)

ctor

Parameters:
sfile to load
actionsWhether builtin actions and menus should be created
Note:
Creates builtin menus/action

References setText().


Member Function Documentation

QAction * QEditor::action ( const QString &  s)
Returns:
the action associated with a given name, if the QEditor has been created with actions on

Referenced by startDrag().

void QEditor::addAction ( QAction *  a,
const QString &  menu,
const QString &  toolbar = QString() 
)
slot

Add an action to the editor.

Parameters:
aaction to add
menuif not empty (and if QCE is built with qmdilib support) the action will be added to that menu
toolbarsimilar to menu but acts on toolbars
See also:
removeAction()

Referenced by QCodeCompletionEngine::setEditor().

void QEditor::addPlaceHolder ( const PlaceHolder p,
bool  autoUpdate = true 
)
slot

Add a placeholder.

Parameters:
pplaceholder data
autoUpdatewhether to force auto updating of all cursors used by the placeholder

Auto update is on by default and it is recommended not to disable it unless you know what you are doing.

References QDocumentCursor::movePosition(), and QDocumentCursor::setAutoUpdated().

Referenced by QSnippetInsertionCommand::redo().

bool QEditor::canRedo ( ) const
Returns:
whether it is possible to call redo()

References QDocument::canRedo().

bool QEditor::canUndo ( ) const
Returns:
whether it is possible to call undo()

References QDocument::canUndo().

void QEditor::closeEvent ( QCloseEvent *  e)
protectedvirtual

Close event.

When build with qmdilib support (e.g in Edyuk) this check for modifications and a dialog pops up to offer various options (like saving, discarding or canceling)

References isContentModified().

QTextCodec * QEditor::codec ( ) const
Returns:
The text codec to use for load/save operations

Referenced by setDefaultCodec().

QCodeCompletionEngine * QEditor::completionEngine ( ) const
Returns:
the code completion engine set to this editor, if any
void QEditor::contextMenuEvent ( QContextMenuEvent *  e)
protectedvirtual

Context menu event.

All the (managed) actions added to the editor are showed in it by default.

References selectionChange().

void QEditor::copy ( )
slot

Copy the selected text, if any.

Note:
Column selection may be created but the can only be copied properly in a QCE editor

References createMimeDataFromSelection(), and QDocumentCursor::hasSelection().

Referenced by cursor(), and cut().

int QEditor::currentPlaceHolder ( ) const
slot
Returns:
the id of the current placeholder
QDocumentCursor QEditor::cursor ( ) const
Returns:
the current cursor

References copy(), and QDocumentCursor::setAutoUpdated().

Referenced by QGotoLinePanel::editorChange(), and isCursorVisible().

QDocumentCursor QEditor::cursorForPosition ( const QPoint &  p) const
Returns:
The cursor object nearest to the given viewport position

References QDocument::cursorAt().

Referenced by setCursorPosition().

QDocumentCursor QEditor::cursorMirror ( int  i) const
Returns:
the cursor mirror at index i

Index has no extra meaning : you cannot deduce anything about the cursor mirror it corresponds to from it. For instance, the cursor mirror at index 0 is neither the first mirror added nor the one at smallest document position (well : it might be but that would be a coincidence...)

int QEditor::cursorMirrorCount ( ) const
Returns:
the number of cursor mirrors currently used
QRect QEditor::cursorRect ( ) const
virtual
Returns:
the rectangle occupied by the current cursor

This will either return a cursorRect for the current cursor or the selectionRect() if the cursor has a selection.

The cursor position, which would be the top left corner of the actual rectangle occupied by the cursor can be obtained using QDocumentCursor::documentPosition()

The behavior of this method may surprise newcomers but it is actually quite sensible as this rectangle is mainly used to specify the update rect of the widget and the whole line needs to be updated to properly update the line background whenever the cursor move from a line to another.

References QDocumentCursor::hasSelection(), and selectionRect().

Referenced by repaintCursor(), and selectionRect().

QRect QEditor::cursorRect ( const QDocumentCursor c) const
virtual
Returns:
The line rect of the given cursor

References QDocumentCursor::lineNumber(), and lineRect().

QTextCodec * QEditor::defaultCodec ( )
static
Returns:
The default text codec used to load and save document contents
Note:
a null pointer indicates that local 8 bit encoding is used.

Referenced by QEditConfig::cancel().

int QEditor::defaultFlags ( )
static
Returns:
The default flags set to every QEditor upon construction
Note:
the default flags are a configuration-oriented feature which only expose "user" flags

Referenced by QEditConfig::apply(), and QEditConfig::cancel().

QString QEditor::defaultInputBindingId ( )
static
Returns:
the name of the default input binding
Note:
The "Default" name (or its translation, obtained via QEditor::tr()) is used to indicate that no default input binding has been set.
QDocument * QEditor::document ( ) const
QString QEditor::fileName ( ) const
Returns:
The full filename of the file being edited

Referenced by save(), setCodec(), and setFileName().

bool QEditor::flag ( EditFlag  f) const
Returns:
wether the flag f is set

Referenced by indentSelection(), insertText(), isProcessingKeyEvent(), moveKeyEvent(), save(), and setPanelMargins().

void QEditor::getPanelMargins ( int *  l,
int *  t,
int *  r,
int *  b 
) const
slot

Obtain the value of panel margins.

Parameters:
lleft margin
ttop margin
rright margin
bbottom margin
QList< QEditorInputBindingInterface * > QEditor::inputBindings ( ) const
Returns:
the current InputBinding
void QEditor::insertFromMimeData ( const QMimeData *  d)
protectedvirtual
void QEditor::insertText ( QDocumentCursor c,
const QString &  text 
)
bool QEditor::isContentModified ( ) const
Returns:
Whether the document has been modified.

References QDocument::isClean().

Referenced by closeEvent(), and setCodec().

bool QEditor::isCursorVisible ( ) const
Returns:
whether the cursor is currently visible

References cursor(), QDocumentCursor::documentPosition(), and QDocument::fontMetrics().

bool QEditor::isInConflict ( ) const
Returns:
Whether a file conflict has been detected

File conflicts happen when the loaded file is modified on disk by another application if the text has been modified in QCE

Referenced by save().

QLanguageDefinition * QEditor::languageDefinition ( ) const
Returns:
the language definition set to this editor, if any

Referenced by QLanguageFactory::setLanguage().

QDocumentLine QEditor::lineAtPosition ( const QPoint &  p) const
Returns:
the line at a given viewport position

References QDocument::lineAt().

QRect QEditor::lineRect ( int  line) const
virtual
Returns:
the rectangle occupied by the given line, in viewport coordinates

The width of the returned rectangle will always be the viewport width.

References QDocument::lineRect().

Referenced by cursorRect().

QRect QEditor::lineRect ( const QDocumentLine l) const
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note:
This function relies on QDocumentLine::lineNumber() so avoid it whenever possible as it is much slower than providing a line number directly.

References QDocument::lineRect().

void QEditor::load ( const QString &  file)
slot
QString QEditor::name ( ) const
Returns:
The name of the file being edited (without its path)

Referenced by setFileName().

void QEditor::nextPlaceHolder ( )
slot

Move to next placeholder.

See also:
setPlaceHolder

References setPlaceHolder().

Referenced by QSnippetInsertionCommand::redo().

void QEditor::pageDown ( QDocumentCursor::MoveMode  moveMode)
void QEditor::pageUp ( QDocumentCursor::MoveMode  moveMode)

Go up by one page.

Note:
This method clears all cursor mirrors and suspend placeholder edition.

References QDocumentCursor::atStart(), clearCursorMirrors(), emitCursorPositionChanged(), ensureCursorVisible(), QDocument::fontMetrics(), QDocumentCursor::movePosition(), and repaintCursor().

Referenced by moveKeyEvent().

void QEditor::paste ( )
slot

Paste text from the clipboard to the current cursor position.

Note:
May paste column selections from other QCE editors

References insertFromMimeData().

int QEditor::placeHolderCount ( ) const
slot
Returns:
the number of placeholders currently set
void QEditor::previousPlaceHolder ( )
slot

Move to previous placeholder.

See also:
setPlaceHolder

References setPlaceHolder().

QStringList QEditor::registeredInputBindingIds ( )
static
Returns:
A list of available input bindings
void QEditor::removeAction ( QAction *  a,
const QString &  menu,
const QString &  toolbar = QString() 
)
slot

remove an action form the editor

Parameters:
aaction to add
menuif not empty (and if QCE is built with qmdilib support) the action will be added to that menu
toolbarsimilar to menu but acts on toolbars
See also:
addAction()
void QEditor::removePlaceHolder ( int  id)
slot

Remove a placeholder.

Parameters:
iplaceholder index
Note:
if the current placeholder is removed there will be NO automatic switching to a remaining one.

References clearCursorMirrors(), and QDocumentCursor::setAutoUpdated().

void QEditor::save ( )
virtualslot

Save the underlying document to a file.

See also:
fileName()

References fileName(), flag(), isInConflict(), load(), QDocument::setClean(), setFileName(), QDocument::text(), and watcher().

void QEditor::save ( const QString &  fn)
slot

Save the content of the editor to a file.

Note:
This method renames the editor, stop monitoring the old file and monitor the new one

References fileName(), flag(), QDocument::setClean(), setFileName(), QDocument::text(), and watcher().

void QEditor::selectionChange ( bool  force = false)

Does not do anything anymore...

Deprecated:

Referenced by contextMenuEvent(), redo(), selectAll(), setCursor(), undo(), and write().

QRect QEditor::selectionRect ( ) const
virtual
Returns:
the rectangle occupied by the selection in viewport coordinates

If the current cursor does not have a selection, its cursorRect() is returned.

The returned rectangle will always be bigger than the actual selection has it is actually the union of all the rectangles occupied by all lines the selection spans over.

References cursorRect(), QDocumentCursor::hasSelection(), QDocument::lineRect(), QDocumentCursor::selection(), and QDocument::y().

Referenced by cursorRect().

void QEditor::setCodec ( int  mib)
slot

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Referenced by setCodec(), and setDefaultCodec().

void QEditor::setCodec ( const char *  name)
slot

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References setCodec().

void QEditor::setCodec ( const QByteArray &  name)
slot

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References setCodec().

void QEditor::setCompletionEngine ( QCodeCompletionEngine e)
slot

Set a code completion engine to the editor.

Warning:
Most completion engines can only be attached to a single editor due to issues in the widget used to dispaly matches so you got to clone them and, as a consequence QEditor will take ownership of the completion engines and delete them.

Referenced by QLanguageFactory::setLanguage().

void QEditor::setContentClean ( bool  y)
slot

Notify that the content is clean (modifications undone or document saved)

Note:
Don't mess with this. The document knows better.

References setContentModified().

void QEditor::setContentModified ( bool  y)
virtualslot

Notify that the content has been modified.

Note:
Don't mess with this. The document knows better.

Referenced by setContentClean().

void QEditor::setCursorPosition ( int  line,
int  index 
)

Set the cursor.

Parameters:
linedocument line to move the cursor to (start at zero)
indexcolumn index of the new cursor (start at zero)

References setCursor().

void QEditor::setDefaultCodec ( int  mib,
int  update 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
mibcodec identifier
updateUpdate policy

Referenced by QEditConfig::apply(), and setDefaultCodec().

void QEditor::setDefaultCodec ( QTextCodec *  c,
int  update 
)
static

Set the default text codec.

Parameters:
ccodec to use
updateUpdate policy

The update policy determines whether existing editors are affected by the change of the default codec.

References codec(), and setCodec().

void QEditor::setDefaultCodec ( const char *  name,
int  update 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
namename of the codec to use
updateUpdate policy

References setDefaultCodec().

void QEditor::setDefaultCodec ( const QByteArray &  name,
int  update 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
namename of the codec to use
updateUpdate policy

References setDefaultCodec().

void QEditor::setDefaultFlags ( int  flags)
static

Set the default editor flags.

Setting editor flags result in them being applied to ALL existing editors and editors to be created later on.

These can of course be modified on a per-editor basis later on.

References QDocument::clearWidthConstraint(), document(), and QDocument::setWidthConstraint().

Referenced by QEditConfig::apply().

void QEditor::setDefaultInputBinding ( QEditorInputBindingInterface b)
static

Set the default input binding.

Note:
This does not change the current input binding of existing editors
void QEditor::setDefaultInputBinding ( const QString &  b)
static

Set the default input binding.

Note:
If no binding of the given name is available the default (null) binding will be set back as default binding.
This does not change the current input binding of existing editors
void QEditor::setFileName ( const QString &  f)
virtualslot

Changes the file name.

This method does not affect files on disk (no save/load/move occurs)

References fileName(), name(), setTitle(), and watcher().

Referenced by load(), and save().

void QEditor::setLineWrapping ( bool  on)
slot

Set line wrapping.

Parameters:
online wrap on/off
Note:
the function also enables "cursor movement within wrapped lines" which can be disabled manually using setFlag(QEditor::CursorJumpPastWrap, false);

References setFlag().

void QEditor::setPanelMargins ( int  l,
int  t,
int  r,
int  b 
)
slot

Change the viewport margins to make room for panels.

Parameters:
lleft margin
ttop margin
rright margin
bbottom margin

References flag(), and QDocument::setWidthConstraint().

void QEditor::setPlaceHolder ( int  i)
slot

Set the current placeholder to use.

This function change the cursor and the cursor mirrors.

References clearCursorMirrors(), and setCursor().

Referenced by nextPlaceHolder(), and previousPlaceHolder().

void QEditor::setTitle ( const QString &  title)
slot

Set the title of the widget.

Take care of adding a "[*]" prefix so that document changes are visible on title bars.

Referenced by setFileName().

QString QEditor::text ( ) const
Returns:
The whole text being edited

References QDocument::text().

Referenced by isProcessingKeyEvent().

QString QEditor::text ( int  line) const
Returns:
The text at a given line
Parameters:
linetext line to extract, using C++ array conventions (start at zero)

References QDocument::line(), and QDocumentLine::text().

QReliableFileWatch * QEditor::watcher ( )
staticprotected
Returns:
A pointer to the global "reliable" file monitor used by QEditor to avoid file conflicts

The point of using a custom file watcher is to work around a bug (limitation) of QFileSystemWatcher which sometimes emit multiple signals for a single file save. It also enables to use a single object shared by all QEditor instances and reduce memory footprint.

Referenced by save(), setFileName(), and ~QEditor().

void QEditor::write ( const QString &  s)
virtualslot

Write some text at the current cursor position.

This function is provided to make editing operations easier from the outside and to keep them compatible with cursor mirrors.

References QDocument::beginMacro(), emitCursorPositionChanged(), QDocument::endMacro(), ensureCursorVisible(), insertText(), repaintCursor(), selectionChange(), and setFlag().

void QEditor::zoom ( int  n)
slot

Zoom.

Parameters:
nrelative zoom factor

Zooming is achieved by changing the point size of the font as follow :

fontPointSize += n

References QDocument::font(), and QDocument::setFont().


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