BrainStim Main Application  1.1.0.1
The BrainStim Main Application class references.
Public Slots | Public Member Functions | List of all members
MainWindow Class Reference

The BrainStim Main Application. More...

Inherits DocumentWindow.

Public Slots

bool addOutputWindow (const QString &sTabName)
 Add a new tab to the Output Log Window. More...
 
bool addScriptIncludePath (const QString &sPath)
 Adds an include path/directory for the script engine to search in for an included file. More...
 
void clearOutputWindow (const QString &sTabName=MAINWINDOW_DEFAULT_OUTPUTWINDOW_TABNAME)
 Clears the Output Log Window. More...
 
void closeActiveDocument ()
 Closes the current active document. More...
 
void enableActiveDocument (bool bEnable=true)
 configures the Active(edit) state for the current document. More...
 
void executeActiveDocument ()
 Executes the current active document. More...
 
QString getActiveDocumentFileLocation ()
 Returns the path to the current active document. More...
 
QString getActiveDocumentFileName ()
 Returns the filename of the current active document. More...
 
QString getApplicationRootDirPath ()
 Returns the path to the BrainStim Root directory. More...
 
QString getEnvironmentVariabele (QString strName)
 Returns the requested Environment Variable. More...
 
QString getJavaScriptConfigurationFileContents ()
 returns the content from the embedded JavaScript file inside the BrainStim application. More...
 
QString getQMLPluginPath ()
 Returns the path to the BrainStim QML plugin directory. More...
 
QStringList getScriptIncludePaths ()
 Returns an array containing all the appended include paths/directories for the script engine to search in for an included file. More...
 
bool initialize (GlobalApplicationInformation::MainProgramModeFlags mainFlags=0)
 Initializes the main BrainStim application and the dynamic plugin loading. More...
 
QVariant invokeJavaScriptConfigurationFile (const QString &sCode)
 Executes and returns a result from a provided Javascript function that is embedded inside the BrainStim application. More...
 
void openFiles (const QString &fileToLoad=QString(), const QStringList &filesToLoad=QStringList(), const bool &bViewAsText=false)
 Opens one or more files. More...
 
void processEvents ()
 forces the main application event loop to process its events. More...
 
void reloadSubWindow ()
 Re-opens the current active document. More...
 
bool removeOutputWindow (const QString &sTabName=MAINWINDOW_DEFAULT_OUTPUTWINDOW_TABNAME)
 Removes a named tab from the Output Log Window. More...
 
void reOpenCurrentFile (const QString &strCanonicalFilePath, const bool &bNativeFileViewer=false)
 Re-opens the document. More...
 
bool saveOutputWindow (const QString &sFilePath="", const bool &bOverwrite=false, const QString &sTabName=MAINWINDOW_DEFAULT_OUTPUTWINDOW_TABNAME)
 Saves the content of a Output Log window to a file. More...
 
void showJavaScriptConfigurationFile ()
 executes the content from the embedded JavaScript file inside the BrainStim application in a QWebView object. More...
 
void write2OutputWindow (const QString &text2Write="", const QString &sTabName=MAINWINDOW_DEFAULT_OUTPUTWINDOW_TABNAME)
 Appends a text String to the Output Log Window. More...
 

Public Member Functions

void activateMainWindow ()
 Forces the BrainStim User Interface to become activated. More...
 
void cleanupScript ()
 Forces the script engine to perform a garbage collection. More...
 
bool copyDirectoryRecursively (const QString &srcFilePath, const QString &tgtFilePath)
 Use this function to copy a complete directory path recursively. More...
 
bool deleteContextState (const QString &sContextName)
 Deletes the provided context name of the internal script engine context state list. More...
 
bool emulateKeyPress (QWindow *pWindow=NULL, const int keyCode=0, const QString &sKeys="", const Qt::KeyboardModifiers modifier=Qt::NoModifier, const int nDelay=-1)
 Emulates one or more key press event(s). More...
 
QScriptValue executeScriptContent (const QString &sContent)
 Executes the provided script content in the Internal Script Engine and returns the result of that operation. More...
 
QScriptValue executeScriptFile (const QString &sFilePath)
 Executes the provided script file content in the Internal Script Engine and returns the result of that operation. More...
 
void find (bool useParams=false, QString strFindString="", DocFindFlags findFlags=_DocFindFlags())
 Searches for a provided String inside the currently active document. More...
 
void findNext ()
 Searches for the last provided String inside the currently active document. More...
 
void findPrev ()
 Searches for the last provided String inside the currently active document. More...
 
int getCurrentContextStateScriptID ()
 Returns the current internal script engine context state script identifier. More...
 
QString getCurrentDateTimeStamp (const QString &sFormat=MainAppInfo::stdDateTimeFormat())
 Use this function to retrieve the current date/time. More...
 
bool getStoredSettingValue (const QString &sSettingPath, QString *sResult)
 Use this function to retrieve a stored setting value. More...
 
bool loadDynamicPlugins ()
 loads the available enabled plugins. More...
 
void quit ()
 Closes the BrainStim application. More...
 
Q_INVOKABLE QAction * registerMainMenuAction (const QStringList &lmenuItemSpecifier, QIcon *iMenuIcon=NULL, const bool &bSkipSubWindowRegistration=false)
 
void replace (bool bReplaceAll=false, bool useParams=false, QString strFindString="", QString strReplaceString="", DocFindFlags findFlags=_DocFindFlags())
 Searches and replaces a provided String inside the currently active document. More...
 
bool resetContextState (const quint64 &nScriptId=0)
 Resets the current internal script engine context state to the context state marked with a script identifier. More...
 
bool restartScriptEngine ()
 Forces a complete restart of the internal script engine. More...
 
bool saveContextState (const QString &sContextName)
 Saves the current internal script engine context state marked with a provided context name for later usage. More...
 
bool setContextState (const QString &sContextName)
 Sets/switches the current internal script engine to the context state marked with the provided context name. More...
 
bool unloadDynamicPlugins ()
 unloads the previously loaded plugins. More...
 

Detailed Description

The BrainStim Main Application.

The BrainStim Main Application can be directly accessed within the script by using the default 'BrainStim' object.

Member Function Documentation

void MainWindow::activateMainWindow ( )

Forces the BrainStim User Interface to become activated.

This function forces the the BrainStim User Interface to become activated. An active window is a visible top-level window that has the keyboard input focus. It is the same operation as clicking the mouse on the title bar of a top-level window.

bool MainWindow::addOutputWindow ( const QString &  sTabName)
slot

Add a new tab to the Output Log Window.

This function adds a new tab to the Output Log Window.

Parameters
sTabNamea String value holding the name of the new tab.
Returns
a boolean value determining whether the function did insert a new tab successfully.
bool MainWindow::addScriptIncludePath ( const QString &  sPath)
slot

Adds an include path/directory for the script engine to search in for an included file.

This function adds an include path/directory for the script engine to search in for an included file. Whenever the script "Include()" command cannot be resolved automatically (using the active docments directory) all the included paths appended with this method are then used for resolving the command.

Parameters
sPatha String containing the path of the path/directory that should be appended to the include script paths.
Returns
a boolean value determining whether the function could remove the tab successfully.
void MainWindow::cleanupScript ( )

Forces the script engine to perform a garbage collection.

This function forces the script engine to perform a garbage collection and is therefore a safe and good practice to execute as last command before ending the script.

void MainWindow::clearOutputWindow ( const QString &  sTabName = MAINWINDOW_DEFAULT_OUTPUTWINDOW_TABNAME)
slot

Clears the Output Log Window.

This function clears the Output Log Window.

Parameters
sTabNamea String value holding the name of the tab that should be cleared, if left empty then the first "Default" tab is automatically cleared.
void MainWindow::closeActiveDocument ( )
slot

Closes the current active document.

This function closes the document that is currently opened and active.

bool MainWindow::copyDirectoryRecursively ( const QString &  srcFilePath,
const QString &  tgtFilePath 
)

Use this function to copy a complete directory path recursively.

This function copies a complete directory path recursively to another directory path.

Parameters
srcFilePatha string value containing the path to the directory to copy from.
tgtFilePatha string value containing the path to the directory to copy to.
Returns
a boolean value determining whether the directory path copy succeeded.
bool MainWindow::deleteContextState ( const QString &  sContextName)

Deletes the provided context name of the internal script engine context state list.

This function deletes the provided context name of the internal script engine context state list.

Returns
a boolean value determining whether the function could execute successfully.
bool MainWindow::emulateKeyPress ( QWindow *  pWindow = NULL,
const int  keyCode = 0,
const QString &  sKeys = "",
const Qt::KeyboardModifiers  modifier = Qt::NoModifier,
const int  nDelay = -1 
)

Emulates one or more key press event(s).

This function emulates one or more key press event(s). These events are executed in a specified QWindow, there's also a option to set a delay.

Parameters
pWindowa pointer to a QWindow, this is the QWindow where the key press event should be executed in (default = NULL), if this parameter is NULL then the current active BrainStim document window is used.
keyCodea value (default = 0), this is the key code for the key to emulate, see http://qt-project.org/doc/qt-5.1/qtcore/qt.html#Key-enum.
sKeysa string (default = ""), this is a string of keys to emulate.
modifiera integer value holding a keyboard modifier value (default = Qt::NoModifier), see http://qt-project.org/doc/qt-5.1/qtcore/qt.html#KeyboardModifier-enum.
nDelaya integer value (default = -1) holding the delay in mSeconds between the key presses.
Returns
a boolean value determining whether the function could execute successfully.
void MainWindow::enableActiveDocument ( bool  bEnable = true)
slot

configures the Active(edit) state for the current document.

This function can configures the Active(edit) state for the current document, this can be convenient for (un-)locking the document for editing

Parameters
bEnablea Boolean value (default = true) determining whether the document should be Activated (Editable).
void MainWindow::executeActiveDocument ( )
slot

Executes the current active document.

This function executes the current active document (file that is opened and active).

QScriptValue MainWindow::executeScriptContent ( const QString &  sContent)

Executes the provided script content in the Internal Script Engine and returns the result of that operation.

This function executes the provided script content in the Internal Script Engine and returns the result of that operation. This function acts the same as like executing a script file (*.qs) from the BrainStim application, but now the content of the script is directly provided by a string of text. Before the internal script engine executes the custom script it firsts creates a so called script context state from within the script is then executed. This context state holds the stack and can be saved/recovered for later usage, see also MainWindow::saveContextState(), MainWindow::setContextState(), MainWindow.resetContextState() and MainWindow.deleteContextState().

Parameters
sContenta string value holding the script content to execute.
Returns
a QScriptValue value holding the return value of the script execution.
QScriptValue MainWindow::executeScriptFile ( const QString &  sFilePath)

Executes the provided script file content in the Internal Script Engine and returns the result of that operation.

This function executes the provided script file content in the Internal Script Engine and returns the result of that operation. See MainWindow::executeScriptFile(), MainWindow::saveContextState(), MainWindow::setContextState(), MainWindow.resetContextState() and MainWindow.deleteContextState().

Parameters
sFilePatha string value holding the script absolute path to the script file that should be executed.
Returns
a QScriptValue value holding the return value of the script execution.
void MainWindow::find ( bool  useParams = false,
QString  strFindString = "",
DocFindFlags  findFlags = _DocFindFlags() 
)

Searches for a provided String inside the currently active document.

This function searches for a provided String of text inside the currently active document. Furthermore this action can be specified with special flags.

Parameters
useParamsa boolean value that determines whether the optional provided parameters should be used. If useParams is false then a Search window appears allowing the user to make further changes. If some text from the document was selected than this String is automatically used for the find String, otherwise the word around the cursor position is used. If useParams is true then no Search window appears and the optional provided parameters are used for the search action, the first found occurrence (starting from the cursor position) of the find result is then automatically selected.
strFindStringa String holding the text value to use.
findFlagsa DocFindFlags structure holding the text value to use, you can create this structure in the script like:
var varName=DocFindFlags;
varName.backwards = true;
see _DocFindFlags.
void MainWindow::findNext ( )

Searches for the last provided String inside the currently active document.

This function searches (forwards) for the last provided String of text inside the currently active document starting from the current cursor position.

void MainWindow::findPrev ( )

Searches for the last provided String inside the currently active document.

This function searches (backwards) for the last provided String of text inside the currently active document starting from the current cursor position.

QString MainWindow::getActiveDocumentFileLocation ( )
slot

Returns the path to the current active document.

This function returns the path to the document that is currently opened and active.

Returns
a String value holding a path to the requested document.
QString MainWindow::getActiveDocumentFileName ( )
slot

Returns the filename of the current active document.

This function returns the filename of the document that is currently opened and active.

Returns
a String value holding the filename of the requested document.
QString MainWindow::getApplicationRootDirPath ( )
slot

Returns the path to the BrainStim Root directory.

This function returns the path to the BrainStim Root directory, where the binary is running in.

Returns
a String value holding the path to the Root directory.
int MainWindow::getCurrentContextStateScriptID ( )

Returns the current internal script engine context state script identifier.

This function returns the current internal script engine context state script identifier.

Returns
a integer value holding the requested context state script identifier.
QString MainWindow::getCurrentDateTimeStamp ( const QString &  sFormat = MainAppInfo::stdDateTimeFormat())

Use this function to retrieve the current date/time.

This function returns the current date/time string that can be custom formatted.

Parameters
sFormata string value containing the custom Date/Time format, if left empty the value "yyyyMMddHHmmsszzz" is used.
Returns
a string value containing the current date/time string.
QString MainWindow::getEnvironmentVariabele ( QString  strName)
slot

Returns the requested Environment Variable.

This function can return a Environment Variable value by providing the name of the variable.

Parameters
strNamea String value holding the name of the requested Environment Variable.
Returns
a String value holding the value of the requested Environment Variable.
QString MainWindow::getJavaScriptConfigurationFileContents ( )
slot

returns the content from the embedded JavaScript file inside the BrainStim application.

This function returns the content from the embedded JavaScript file inside the BrainStim application that is used for storing all kind of application and plugin (version) information. See also MainWindow.invokeJavaScriptConfigurationFile().

Returns
a string containing a copy of the code contents of the embedded JavaScript file.
QString MainWindow::getQMLPluginPath ( )
slot

Returns the path to the BrainStim QML plugin directory.

This function returns the path to the BrainStim QML plugin directory.

Returns
a String value holding the path to the BrainStim QML plugin directory.
QStringList MainWindow::getScriptIncludePaths ( )
slot

Returns an array containing all the appended include paths/directories for the script engine to search in for an included file.

This function returns an array containing all the appended include paths/directories for the script engine to search in for an included file. See also MainWindow::addScriptIncludePath()

Returns
a string array containing the requested paths/directories.
bool MainWindow::getStoredSettingValue ( const QString &  sSettingPath,
QString *  sResult 
)

Use this function to retrieve a stored setting value.

This function returns a stored setting using the provided path to the settings variable.

Parameters
sSettingPatha string value containing the path to the settings variable.
sResulta string value containing the requested settings variable value.
Returns
a boolean value determining whether the settings variable could be found.
bool MainWindow::initialize ( GlobalApplicationInformation::MainProgramModeFlags  mainFlags = 0)
slot

Initializes the main BrainStim application and the dynamic plugin loading.

This function Initializes the main BrainStim application and the dynamic plugin loading, this is automatically done during startup.

Parameters
mainFlagsa GlobalApplicationInformation::MainProgramModeFlags value holding the flags used for the initialization.
Returns
a boolean value determining whether the function could remove the tab successfully.
QVariant MainWindow::invokeJavaScriptConfigurationFile ( const QString &  sCode)
slot

Executes and returns a result from a provided Javascript function that is embedded inside the BrainStim application.

This function executes and returns a result from a provided Javascript function that is embedded inside the BrainStim application. The embedded available Javascript function calls provide a way to request all kind of application and plugin (version) information. The menu command 'Help' –> 'BrainStim History' can also be used to retrieve this kind of information, see also MainWindow.getJavaScriptConfigurationFileContents().

Parameters
sCodea String containing the Javascript function call that should be executed.
Returns
a QVariant value that holds the result of the executed Javascript function call.
bool MainWindow::loadDynamicPlugins ( )

loads the available enabled plugins.

This function loads the available enabled plugins.

Returns
a boolean value determining whether the whole process completed succeeded.

= QFileInfo(sPluginAbsFilePath).canonicalFilePath()) && (QFileInfo(lFiles[i]).canonicalPath() != QDir(MainAppInfo::appDirPath()).canonicalPath()))

void MainWindow::openFiles ( const QString &  fileToLoad = QString(),
const QStringList &  filesToLoad = QStringList(),
const bool &  bViewAsText = false 
)
slot

Opens one or more files.

This function can open one or more files.

Parameters
fileToLoada String containing a single path to the file that should be loaded.
filesToLoada String Array containing multiple Strings containing the paths to the files that should be loaded.
bViewAsTexta boolean value determining whether the file(s) to open should be viewed/formatted as text.
void MainWindow::processEvents ( )
inlineslot

forces the main application event loop to process its events.

This function forces the main application event loop to process its events, see http://qt-project.org/doc/qt-5.1/qtcore/qcoreapplication.html#processEvents.

void MainWindow::quit ( )
inline

Closes the BrainStim application.

This function closes the BrainStim application.

QAction * MainWindow::registerMainMenuAction ( const QStringList &  lmenuItemSpecifier,
QIcon *  iMenuIcon = NULL,
const bool &  bSkipSubWindowRegistration = false 
)

Cannot use already present menu actions...

void MainWindow::reloadSubWindow ( )
slot

Re-opens the current active document.

This function first closes and then re-opens the current active document, see MainWindow::reOpenCurrentFile().

bool MainWindow::removeOutputWindow ( const QString &  sTabName = MAINWINDOW_DEFAULT_OUTPUTWINDOW_TABNAME)
slot

Removes a named tab from the Output Log Window.

This function removes a named tab from the Output Log Window.

Parameters
sTabNamea String value holding the name of the tab that should be removed.
Returns
a boolean value determining whether the function could remove the tab successfully.
void MainWindow::reOpenCurrentFile ( const QString &  strCanonicalFilePath,
const bool &  bNativeFileViewer = false 
)
slot

Re-opens the document.

This function first closes and re-opens the document.

Parameters
strCanonicalFilePatha String value containing the canonical file path of the document, if empty then the current active document file path is used.
bNativeFileViewera Boolean value determining whether the file should be opened again by the default set file-handler (defined by a plug-in) or by BrainStim directly.
void MainWindow::replace ( bool  bReplaceAll = false,
bool  useParams = false,
QString  strFindString = "",
QString  strReplaceString = "",
DocFindFlags  findFlags = _DocFindFlags() 
)

Searches and replaces a provided String inside the currently active document.

This function searches and replaces a provided String of text inside the currently active document. Furthermore this action can be specified with special flags.

Parameters
bReplaceAlla boolean value that determines whether all occurrences of the found String should be replaced.
useParamsa boolean value that determines whether the optional provided parameters should be used. If useParams is false then a Replace window appears allowing the user to make further changes. If some text from the document was selected than this String is automatically used for the find String, otherwise the word around the cursor position is used. If useParams is true then no Search window appears and the optional provided parameters are used for the search action, the first found occurrence (starting from the cursor position) of the find result is then automatically selected.
strFindStringa String holding the String value to search for.
strReplaceStringa String holding the text value to replace the found String strFindString with.
findFlagsa DocFindFlags structure holding the text value to use, you can create this structure in the script like:
var varName=DocFindFlags;
varName.backwards = true;
see _DocFindFlags.
bool MainWindow::resetContextState ( const quint64 &  nScriptId = 0)

Resets the current internal script engine context state to the context state marked with a script identifier.

This function resets the current internal script engine context state to the context state marked with a script identifier, see also MainWindow.getCurrentContextStateScriptID(). If the script identifier is left empty or 0 then the current script state is reset.

Parameters
nScriptIda integer value holding the script identifier (default = 0).
Returns
a boolean value determining whether the function could execute successfully.
bool MainWindow::restartScriptEngine ( )

Forces a complete restart of the internal script engine.

This function forces a complete restart of the internal script engine. The engine restarts which means that all running scripts and context states are deleted.

Returns
a boolean value determining whether the function could execute successfully.
bool MainWindow::saveContextState ( const QString &  sContextName)

Saves the current internal script engine context state marked with a provided context name for later usage.

This function saves the current internal script engine context state marked with a provided name for later usage.

Parameters
sContextNamea string value holding the script context name.
Returns
a boolean value determining whether the function could execute successfully.
bool MainWindow::saveOutputWindow ( const QString &  sFilePath = "",
const bool &  bOverwrite = false,
const QString &  sTabName = MAINWINDOW_DEFAULT_OUTPUTWINDOW_TABNAME 
)
slot

Saves the content of a Output Log window to a file.

This function saves the content of a named Output Log Window to a text file.

Parameters
sFilePatha String value holding the path to the destination file.
bOverwritea Boolean value determining whether the destination file may be overwritten in case the file already exists.
sTabNamea String value holding the name of the tab that should be saved.
Returns
a boolean value determining whether the function could remove the tab successfully.
bool MainWindow::setContextState ( const QString &  sContextName)

Sets/switches the current internal script engine to the context state marked with the provided context name.

This function sets/switches the current internal script engine to the context state marked with the provided context name.

Parameters
sContextNamea string value holding the script context name.
Returns
a boolean value determining whether the function could execute successfully.
void MainWindow::showJavaScriptConfigurationFile ( )
slot

executes the content from the embedded JavaScript file inside the BrainStim application in a QWebView object.

This function executes the content from the embedded JavaScript file (of the BrainStim application that is used for storing all kind of application and plugin (version) information) in a QWebView object. See also MainWindow.invokeJavaScriptConfigurationFile().

bool MainWindow::unloadDynamicPlugins ( )

unloads the previously loaded plugins.

This function unloads the previously loaded plugins.

Returns
a boolean value determining whether the whole process completed succeeded.
void MainWindow::write2OutputWindow ( const QString &  text2Write = "",
const QString &  sTabName = MAINWINDOW_DEFAULT_OUTPUTWINDOW_TABNAME 
)
slot

Appends a text String to the Output Log Window.

This function appends a provided String to the Output Log Window.

Parameters
text2Writea String value holding the text that should be appended.
sTabNamea String value holding the name of the tab where the text should be appended, if left empty then the text is automatically send to the first "Default" tab.