Carousel
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Pages
Public Slots | Signals | Public Member Functions | Properties | List of all members
IScriptUnit Class Referenceabstract

This abstract class represents a JavaScript unit that could be loaded from file and executed. More...

#include <IScriptUnit.h>

Inherits QObject, and IOutputHandler.

Inherited by ScriptUnit.

Public Slots

virtual void clear ()=0
 
virtual bool load ()=0
 
virtual bool load (const QString &filePath)=0
 
virtual bool run ()=0
 
virtual bool save ()=0
 
virtual bool saveAs (const QString &filePath)=0
 

Signals

void error (const QString &error)
 
void fileNameChanged ()
 
void printed (const QString &message)
 

Public Member Functions

 IScriptUnit ()
 
virtual QString absoluteFilePath () const =0
 
virtual QString fileName () const =0
 
virtual bool isLoaded () const =0
 
virtual QTextDocumentscript ()=0
 
virtual const QTextDocumentscript () const =0
 
virtual QString scriptText () const =0
 
virtual void setScriptText (const QString &plainText)=0
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
bool blockSignals (bool block)
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThreadthread () const
 
- Public Member Functions inherited from IOutputHandler
 IOutputHandler ()
 
virtual void print (const QString &message)=0
 

Properties

QString absoluteFilePath
 
QString fileName
 
bool isLoaded
 
QTextDocument script
 
QString scriptText
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObjectsender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 

Detailed Description

This abstract class represents a JavaScript unit that could be loaded from file and executed.

The IScriptCollection interface is a storage for that units so you usually should to get IScriptCollection reference to create or to get some script unit.

This class itself does not provide any GUI capabilities, indeed it is rendered using ScriptUnitView widget. Since script is stored as text inside the QTextDocument, it is possible to setup this document to widgets like QTextEdit. It allows to use all benefits like code highliting and undo/redo.

See Also
IScriptCollection, ScriptUnitView

Constructor & Destructor Documentation

IScriptUnit::IScriptUnit ( )
inline

Initializes a new instance of the IScriptUnit class.

Member Function Documentation

virtual bool IScriptUnit::isLoaded ( ) const
pure virtual

Returns true if script was loaded from the file.

Implemented in ScriptUnit.

virtual QString IScriptUnit::absoluteFilePath ( ) const
pure virtual

Gets the absolute path to the file from wich script was loaded (if it was loaded).

Implemented in ScriptUnit.

virtual QString IScriptUnit::fileName ( ) const
pure virtual

Gets the file name from wich script was loaded (if it was loaded).

See Also
QFileInfo::fileName, absoluteFilePath

Implemented in ScriptUnit.

virtual QString IScriptUnit::scriptText ( ) const
pure virtual

Gets script as a plain text.

Implemented in ScriptUnit.

virtual void IScriptUnit::setScriptText ( const QString plainText)
pure virtual

Sets a new plainText as a script.

Implemented in ScriptUnit.

virtual QTextDocument* IScriptUnit::script ( )
pure virtual

Gets script as a document.

Implemented in ScriptUnit.

virtual const QTextDocument* IScriptUnit::script ( ) const
pure virtual

Gets script as a document.

Implemented in ScriptUnit.

virtual bool IScriptUnit::load ( )
pure virtualslot

Tries to load script from the fileName(). Returns true, if loading was successful.

virtual bool IScriptUnit::load ( const QString filePath)
pure virtualslot

Tries to load script from a filePath. Sets filePath as a current file name and returns true, if loading was successful.

Since after successful loading file name is changed, the fileNameChanged() signal is emitted.

virtual void IScriptUnit::clear ( )
pure virtualslot

Clears script body.

virtual bool IScriptUnit::save ( )
pure virtualslot

Tries to save script to the fileName(). Returns true, if saving was successful.

virtual bool IScriptUnit::saveAs ( const QString filePath)
pure virtualslot

Tries to save script to a filePath. Sets filePath as a current file name and returns true, if saving was successful.

Since after successful saving file name is changed, the fileNameChanged() signal is emitted.

virtual bool IScriptUnit::run ( )
pure virtualslot

Tries to save script to the fileName(). All print() functions called from the script will be emitted as printed() signal. Returns true, if script was evaluated without errors. Otherwise, returns false and emits the error() signal.

void IScriptUnit::fileNameChanged ( )
signal

This signal is emitted when script's file name is changed. It could happen on loading a new file or saving as a new file.

See Also
load(), saveAs()
void IScriptUnit::printed ( const QString message)
signal

This signal is emmited when the print() function is called from the script. Connect to this signal if you want to echo message, for example, into text edit.

See Also
run
void IScriptUnit::error ( const QString error)
signal

This signal is emmited when the error is appears during evaluate the script. Connect to this signal if you want to echo error, for example, into text edit.

See Also
run