|Home | Tutorial | Classes | Functions | Qt Scripter | Language | Library | Qt API | QSA Articles Qt Script for Applications

QSEditor Class Reference

The QSEditor class provides an enhanced editor for editing of Qt Script source code. More...

#include <qseditor.h>

List of all member functions.

Public Members

Signals


Detailed Description

The QSEditor class provides an enhanced editor for editing of Qt Script source code.

For some applications the Qt Scripter is too complex. In this case it might be more appropriate to embed a simple editor into the application's UI. QSEditor provides such a widget component, which offers in addition to normal editor functionality also Qt Script syntax highlighting, completion, function argument hints and auto-indentation.

The text in the QSEditor can be set using setText() and retrieved using text().

A QSEditor can be associated with a QSSctipt object using setScript() and the associated QSScript can be retrieved by using script().

When text is edited in the QSEditor it is not directly reflected in the underlying script. To write the changes in the editor to the script, use commit(). To revert the changes in the editor to the text in the script, use revert().

The QSEditor will automatically become the active editor when it gets focus. The active editor can be retrieved from QSProject.

Look at the examples/simplescript, examples/scriptbutton and examples/console examples to see an example usage of the QSEditor class.


Member Function Documentation

QSEditor::QSEditor ( QWidget * parent, const char * name = 0 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Constructs an editor not linked to any project.

The parent and name arguments are passed to the QWidget constructor.

QSEditor::~QSEditor ()

Destructs the editor.

void QSEditor::commit ()

Updates the script with the text in the editor.

When the text in the editor is changed, one must commit the changes before the changes are reflected in the script.

void QSEditor::copy ()

Copies the selected text to the clipboard

void QSEditor::cut ()

Cuts the selected text to the clipboard

bool QSEditor::find ( const QString & expr, bool cs, bool wo, bool forward, bool startAtCursor )

Finds the expression expr in the editor and selects the result. If cs is TRUE the search is done case sensitive. If wo is TRUE, only whole words are searched. If forward is TRUE, the search is done formward, otherwise backwards. If startAtCursor is TRUE, the search starts at the current cursor position, otherwise it starts at the beginning of the document.

Returns TRUE, of expr was found, FALSE otherwise.

void QSEditor::gotoLine ( int line )

Moves the cursor to the line line in the editor

void QSEditor::indent ()

Indents the current line or selection

bool QSEditor::isActive () const

Returns whether this editor is active or not.

See the class description for the concept of active editors.

bool QSEditor::isModified () const

Returns TRUE if the text in the editor is different from the text in the underlying script. This is the case whenever the user types input and up til the user does either commit or revert.

bool QSEditor::isRedoAvailable () const

Returns whether redo is available

bool QSEditor::isUndoAvailable () const

Returns whether undo is available

void QSEditor::paste ()

Pastes text from the clipboard into the editor

QSProject * QSEditor::project () const

Returns the project this editor is associated; otherwise 0;

void QSEditor::readSettings ()

Re-reads settings for syntax highlighting, indentation, etc. The settings are read from the QSettings path /Trolltech/QSAScriptEditor/

Following settings are read for syntax highlighting:

For each of those following settings are read:

So, the font family for strings is e.g. saved in /Trolltech/QuickScriptEditor/String/family.

Following settings for indentation are read:

Code complection can be switched on or off via /completion, wordwrapping via /wordWrap and paren matching via /parenMatching

void QSEditor::redo ()

Redoes the last editor operation

void QSEditor::removeErrorMark ()

Removes all the error marks for this editor.

bool QSEditor::replace ( const QString & find, const QString & replace, bool cs, bool wo, bool forward, bool startAtCursor, bool replaceAll )

Replaces the expression find in the editor with replace. If cs is TRUE the search is done case sensitive. If wo is TRUE, only whole words are searched. If forward is TRUE, the search is done formward, otherwise backwards. If startAtCursor is TRUE, the search starts at the current cursor position, otherwise it starts at the beginning of the document. If replaceAll is TRUE, all found occurances of find are replaced by replace. Otherwise only the first occurance is replaced.

void QSEditor::revert ()

Reverts the contents in the editor back to the contents of the underlying script.

When the text in the editor is changed and one wishes to revert it to the state of the underlying script, revert is used.

QSScript * QSEditor::script () const

Returns the script that this editor is editing if any; otherwise 0.

void QSEditor::selectAll ()

Selects all the text in the editor

void QSEditor::setErrorMark ( int line )

Highlights the line line. This can be used e.g. to show and error or warning

bool QSEditor::setScript ( QSScript * script )

Sets the current script of this editor to be script.

void QSEditor::setText ( const QString & text )

Sets the editor contents to text.

QString QSEditor::text () const

Returns the text of the editor

void QSEditor::textChanged () [signal]

This signal is emitted if the text of the editor has been changed

QTextEdit * QSEditor::textEdit () const

Returns the pointer to the real editor widget, which is a QTextEdit. This might be 0 if an error occured while initializing the editor.

void QSEditor::undo ()

Undoes the last editor operation

This file is part of Qt Script for Applications, copyright © 2001-2003 Trolltech. All Rights Reserved.


Copyright © 2001-2003 TrolltechTrademarks
QSA version 1.0.0-beta2