gui::BaseCore Class Reference

Core scripting functions. More...

#include <basecore.h>

Inheritance diagram for gui::BaseCore:
gui::Base gui::BaseConsole gui::BaseGUI

List of all members.

Public Member Functions

 BaseCore ()
virtual ~BaseCore ()
void setConWriter (ConsoleWriter *_con)
void conPrintError (const QString &line)
void conPrintLine (const QString &line)
void runScript (const QString &script)
void call (const QString &name, const QString &arguments="")
void importDocument (boost::shared_ptr< pdfobjects::CPdf > pdf)
void destroyDocument ()
QSPdfgetQSPdf () const
void stopScript ()
void addGC (QSCObject *o)
void removeGC (QSCObject *o)
void errorNullPointer (const QString &className, const QString &methodName)
void errorBadParameter (const QString &className, const QString &methodName, int paramNum, const QObject *param, const QString &expected)
void errorException (const QString &className, const QString &methodName, const QString &exceptionInfo)
void addTreeItemToList (QSTreeItem *theWrap)
void removeTreeItemFromList (QSTreeItem *theWrap)
QSInterpreter * interpreter ()

Protected Member Functions

virtual void preRun (const QString &script, bool callback=false)
virtual void postRun ()
virtual void removeScriptingObjects ()
virtual void addScriptingObjects ()
void deleteVariable (const QString &varName)
void errorMessage ()
void clearError ()

Protected Attributes

QSProject * qp
QSInterpreter * qs
QSImporterimport
TreeBindingMap treeWrap
QSPdfqpdf
bool treeReloadFlag

Private Slots

void scriptError (const QString &message, const QString &scriptName, int lineNumber)

Private Member Functions

void cleanup ()

Private Attributes

Q_PtrDict< QSCObjectbaseObjects
ConsoleWritercon
QString errMessage
QString errScript
int errLineNumber

Detailed Description

Core scripting functions.

Core of Class that host scripts and is responsible for garbage collection of scripting objects and core scriptiong functionality


Constructor & Destructor Documentation

gui::BaseCore::BaseCore (  ) 

Create new BaseCore class

gui::BaseCore::~BaseCore (  )  [virtual]

destructor


Member Function Documentation

void gui::BaseCore::addGC ( QSCObject o  ) 

Add QSCObject to list of object to delete when file in editor window is closed

Parameters:
o Object to add to cleanup-list

Referenced by gui::QSCObject::QSCObject().

void gui::BaseCore::addScriptingObjects (  )  [protected, virtual]

Create objects that should be available to scripting from current CPdf and related objects

See also:
removeScriptingObjects

Reimplemented in gui::BaseGUI.

void gui::BaseCore::addTreeItemToList ( QSTreeItem theWrap  ) 

Add tree item wrapper to list of managed wrappers
Called from treeitem wrapper contructor

Parameters:
theWrap Tree item wrapper

Referenced by gui::QSTreeItem::QSTreeItem().

void gui::BaseCore::call ( const QString &  name,
const QString &  arguments = "" 
)

Call a callback function (without return value) in a script

Parameters:
name Function name
arguments Function arguments, separated by comma. Strings must be properly quoted

some error occured

Referenced by gui::PdfEditWindow::pageDeleteSelection(), gui::PdfEditWindow::setSelection(), and gui::ConsoleWindow::~ConsoleWindow().

void gui::BaseCore::cleanup (  )  [private]

Delete all objects in cleanup list

void gui::BaseCore::clearError (  )  [protected]

Clear internal error state Usually called after printing the error, so to avoid seeing the same error again

void gui::BaseCore::conPrintError ( const QString &  line  ) 

Print one error line to console, followed by newline

Parameters:
line Error line to print

Referenced by gui::Base::runFile(), gui::BaseConsole::runInitScript(), and gui::Base::runScriptsFromPath().

void gui::BaseCore::conPrintLine ( const QString &  line  ) 

Print one line to console, followed by newline

Parameters:
line Line to print
void gui::BaseCore::deleteVariable ( const QString &  varName  )  [protected]

"Remove" defined variable from scripting context

Parameters:
varName name of variable;
void gui::BaseCore::destroyDocument (  ) 

destroy document - destroy it also in scripting

void gui::BaseCore::errorBadParameter ( const QString &  className,
const QString &  methodName,
int  paramNum,
const QObject *  param,
const QString &  expected 
)

Script error invoked when script function was executed with bad parameter

Parameters:
className Name of class, in which this error occured
methodName Name of method, in which this error occured
paramNum number of bad parameter
param Pointer to the QObject that was given as parameter
expected What was expected to see as parameter

Referenced by gui::QSCObject::qobject_cast().

void gui::BaseCore::errorException ( const QString &  className,
const QString &  methodName,
const QString &  exceptionInfo 
)
void gui::BaseCore::errorMessage (  )  [protected]

If there was some error since last call of this function or since last clearing the error message, display it. Clear the error message before returning.

Referenced by gui::Base::runFile(), and gui::Base::runScriptsFromPath().

void gui::BaseCore::errorNullPointer ( const QString &  className,
const QString &  methodName 
)

Script error invoked when script tried to access a NULL pointer

Parameters:
className Name of class, in which this error occured
methodName Name of method, in which this error occured

Referenced by gui::QSCObject::nullPtr().

QSPdf * gui::BaseCore::getQSPdf (  )  const

Return QSA wrapper of current PDF document, or NULL if the wrapper is invalid or not present

Returns:
Current document (scripting wrapper)
void gui::BaseCore::importDocument ( boost::shared_ptr< pdfobjects::CPdf pdf  ) 

Import currently edited document into scripting QSPDF wrapper will be created around the pdf document

Parameters:
pdf PDF to import under name "document" into scripting
QSInterpreter * gui::BaseCore::interpreter (  ) 

Return interpreter instance used to launch scripts in this context

Returns:
current QSInterpreter
void gui::BaseCore::postRun (  )  [protected, virtual]

Function to be run after the script is executed BaseCore::postRun should be called in overrriden function if overiding with own function

Reimplemented in gui::BaseGUI.

void gui::BaseCore::preRun ( const QString &  script,
bool  callback = false 
) [protected, virtual]

Function to be run before the script is executed BaseCore::preRun should be called in overrriden function if overiding with own function

Parameters:
script Script code;
callback is it callback from script?

Reimplemented in gui::BaseGUI.

void gui::BaseCore::removeGC ( QSCObject o  ) 

Remove QSCObject from list of object to delete when file in editor window is closed

Parameters:
o Object to remove from cleanup-list

Referenced by gui::QSCObject::~QSCObject().

void gui::BaseCore::removeScriptingObjects (  )  [protected, virtual]

Removes objects added with addScriptingObjects

See also:
addScriptingObjects

Reimplemented in gui::BaseGUI.

void gui::BaseCore::removeTreeItemFromList ( QSTreeItem theWrap  ) 

Remove tree item wrapper from list of managed wrappers
Called from treeitem wrapper contructor

Parameters:
theWrap Tree item wrapper

Referenced by gui::QSTreeItem::~QSTreeItem().

void gui::BaseCore::runScript ( const QString &  script  ) 

Runs given script code

Parameters:
script QT Script code to run

Referenced by gui::ConsoleWindow::eval().

void gui::BaseCore::scriptError ( const QString &  message,
const QString &  scriptName,
int  lineNumber 
) [private, slot]

Slot called on error in any script

Parameters:
message Error message
scriptName Name of script in which the error occured
lineNumber 
void gui::BaseCore::setConWriter ( ConsoleWriter _con  ) 

Set new console writer for this class. NULL mean no console writer, effectively turning off console output

Parameters:
_con Console writer
void gui::BaseCore::stopScript (  ) 

if any script is running, stop it


Member Data Documentation

Q_PtrDict<QSCObject> gui::BaseCore::baseObjects [private]

All Scripting objects created under this base. Will be used for purpose of garbage collection

Console writer handler

Script line number for last-seen error message

QString gui::BaseCore::errMessage [private]

Last-seen error message from script

QString gui::BaseCore::errScript [private]

Script filename for last-seen error message

QSObject Importer

QSProject* gui::BaseCore::qp [protected]

QSA Scripting Project

QSPdf* gui::BaseCore::qpdf [protected]

QObject wrapper around CPdf (document) that is exposed to scripting. Lifetime of this class is the same as lifetime of document

QSInterpreter* gui::BaseCore::qs [protected]

QSA Interpreter - taken from project

Referenced by gui::Base::print().

Flag specifying if the tree have changed while running script to the degree it need to be reloaded

Referenced by gui::BaseGUI::removeScriptingObjects(), and gui::Base::~Base().

map containing trees to disable if necessary

Referenced by gui::Base::~Base().


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