QEditor Class Reference

A text editing widget. More...

Inheritance diagram for QEditor:

Inheritance graph
[legend]

List of all members.
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, Persistent = 0x040,
  Multiline = 0x080, FoldedCursor = 0x100, Internal = 0x00000fff, LineWrap = 0x00001000,
  CtrlNavigation = 0x00010000, CursorJumpPastWrap = 0x00020000, ReplaceTabs = 0x00100000, RemoveTrailing = 0x00200000,
  PreserveTrailingIndent = 0x00400000, AutoCloseChars = 0x01000000, AutoIndent = 0x02000000, Accessible = 0xfffff000
}
 Flag holding information about the state of an editor. More...
static int m_defaultFlags = QEditor::AutoIndent
static QTextCodec * m_defaultCodec = 0
static QList< QEditor * > m_editors
static InputBindingm_defaultBinding = 0
static QHash< QString,
InputBinding * > 
m_bindings
 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
InputBindinginputBinding () const
bool isCursorVisible () const
QDocumentCursor cursor () const
int cursorMirrorCount () const
QDocumentCursor cursorMirror (int i) const
QLanguageDefinitionlanguageDefinition () const
QCodeCompletionEngine * completionEngine () 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
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 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 QStringList inputBindings ()
static QString defaultInputBinding ()
static void addInputBinding (InputBinding *b)
 Add an input binding to make it available for all editors.
static void removeInputBinding (InputBinding *b)
 Remove an input binding from the pool of publicly available ones.
static void setDefaultInputBinding (InputBinding *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 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 setInputBinding (InputBinding *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 addPlaceHolder (const PlaceHolder &p, bool autoUpdate=true)
 Add a placeholder.
int placeHolderCount () 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 ()

Classes

class  InputBinding
 A class designed to allow extending user input in a transparent way. More...
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

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
InputBindingm_binding
QLanguageDefinitionm_definition
QPointer< QCodeCompletionEngine > m_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


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:
actions Whether builtin actions and menus should be created

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

ctor

Parameters:
s file to load
Note:
Creates builtin menus/actions

References setText().

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

ctor

Parameters:
s file to load
actions Whether 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:
a action to add
menu if not empty (and if QCE is built with qmdilib support) the action will be added to that menu
toolbar similar to menu but acts on toolbars
See also:
removeAction()

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

Add a placeholder.

Parameters:
p placeholder data
autoUpdate whether 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 QEditor::PlaceHolder::cursor, QEditor::PlaceHolder::length, QEditor::PlaceHolder::mirrors, QDocumentCursor::movePosition(), and QDocumentCursor::setAutoUpdated().

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  )  [protected, virtual]

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  )  [protected, virtual]

Context menu event.

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

References QEditor::InputBinding::contextMenuEvent(), and 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().

QDocumentCursor QEditor::cursor (  )  const

Returns:
the current cursor

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

Referenced by QEditSession::addEditor(), 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 QDocumentCursor c  )  const [virtual]

Returns:
The line rect of the given cursor

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

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().

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::defaultInputBinding (  )  [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.

References QEditor::InputBinding::name().

QDocument * QEditor::document (  )  const

QString QEditor::fileName (  )  const

Returns:
The full filename of the file being edited

Referenced by QEditSession::addEditor(), save(), setCodec(), and setFileName().

bool QEditor::flag ( EditFlag  f  )  const

Returns:
wether the flag f is set

Referenced by 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:
l left margin
t top margin
r right margin
b bottom margin

QEditor::InputBinding * QEditor::inputBinding (  )  const

Returns:
the current InputBinding

QStringList QEditor::inputBindings (  )  [static]

Returns:
A list of available input bindings

void QEditor::insertFromMimeData ( const QMimeData *  d  )  [protected, virtual]

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 ( 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().

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().

void QEditor::load ( const QString &  file  )  [slot]

load a text file

Parameters:
file file to load
If the file cannot be loaded, previous content is cleared.

References QDocument::addChunk(), QDocument::height(), QDocument::originalLineEnding(), setCursor(), setFileName(), setText(), QDocument::startChunkLoading(), QDocument::stopChunkLoading(), and QDocument::width().

Referenced by save(), and setCodec().

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().

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().

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

remove an action form the editor

Parameters:
a action to add
menu if not empty (and if QCE is built with qmdilib support) the action will be added to that menu
toolbar similar to menu but acts on toolbars
See also:
addAction()

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(), QReliableFileWatch::removeWatch(), QDocument::setClean(), setFileName(), QDocument::text(), and watcher().

void QEditor::save (  )  [virtual, slot]

void QEditor::selectionChange ( bool  force = false  ) 

Does not do anything anymore...

Deprecated:

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

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(), and selectionChange().

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::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 ( 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::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  )  [virtual, slot]

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:
line document line to move the cursor to (start at zero)
index column index of the new cursor (start at zero)

References setCursor().

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:
name name of the codec to use
update Update policy

References setDefaultCodec().

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:
name name of the codec to use
update Update policy

References setDefaultCodec().

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

Set the default text codec.

Parameters:
c codec to use
update Update policy
The update policy determines whether existing editors are affected by the change of the default codec.

References codec(), and setCodec().

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:
mib codec identifier
update Update policy

Referenced by QEditConfig::apply(), and 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(), m_actions, m_state, QDocument::setWidthConstraint(), and wrapWidth().

Referenced by QEditConfig::apply().

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::setDefaultInputBinding ( QEditor::InputBinding b  )  [static]

Set the default input binding.

Note:
This does not change the current input binding of existing editors

void QEditor::setFileName ( const QString &  f  )  [virtual, slot]

Changes the file name.

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

References QReliableFileWatch::addWatch(), fileName(), name(), QReliableFileWatch::removeWatch(), setTitle(), and watcher().

Referenced by load(), and save().

void QEditor::setLineWrapping ( bool  on  )  [slot]

Set line wrapping.

Parameters:
on line 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:
l left margin
t top margin
r right margin
b bottom 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 addCursorMirror(), clearCursorMirrors(), QEditor::PlaceHolder::cursor, QEditor::PlaceHolder::mirrors, 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 ( int  line  )  const

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

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

QString QEditor::text (  )  const

Returns:
The whole text being edited

References QDocument::text().

Referenced by isProcessingKeyEvent().

QReliableFileWatch * QEditor::watcher (  )  [static, protected]

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  )  [virtual, slot]

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:
n relative 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:

Generated on Sun Feb 15 22:50:20 2009 for QCodeEdit by  doxygen 1.5.7.1