itom 1.3.0
ito::ScriptEditorOrganizer Class Reference

organizes script editors, independent on their appearance (docked or window-style) More...

List of all members.

Public Slots

void removeScriptDockWidget (ScriptDockWidget *widget)
 signal emitted if macro (filename) should be debugged in python
void dockScriptTab (ScriptDockWidget *widget, int index, bool closeDockIfEmpty=false)
 slot invoked if tab, defined by its index, if the given widget should be docked
void undockScriptTab (ScriptDockWidget *widget, int index, bool undockToNewScriptWindow=false, bool closeDockIfEmpty=false)
 slot invoked if tab, defined by its index, in the given widget should be undocked
void openNewScriptWindow (bool docked, ItomSharedSemaphore *semaphore=NULL)
 slot invoked if empty new script window should be created and displayed
RetVal newScript (ItomSharedSemaphore *semaphore=NULL)
 slot, invoked if new script should be opened
RetVal openScript (const QString &filename, ItomSharedSemaphore *semaphore=NULL, int visibleLineNr=-1)
 slot, invoked if python macro file should be opened as new tab in active script editor window
ScriptDockWidgetopenScriptRequested (const QString &filename, ScriptDockWidget *widget)
 slot invoked if a file open command has been executed in any script window.
void pythonRunFileRequested (QString filename)
 slot invoked if someone wants to run a python file with filename.
void pythonDebugFileRequested (QString filename)
 slot invoked if someone wants to debug a python file with filename.
void pythonDebugPositionChanged (QString filename, int lineNo)
 slot invoked if line in python debugging process has been changed
void fileOpenedOrSaved (const QString &filename)
 This slot is called if a file is saved or stored in any widget.

Signals

void addScriptDockWidgetToMainWindow (AbstractDockWidget *dockWidget, Qt::DockWidgetArea area)
void removeScriptDockWidgetFromMainWindow (AbstractDockWidget *dockWidget)
 signal emitted if dockWidget should be added to docking area in main window
void pythonRunFile (QString filename)
 signal emitted if dockWidget should be removed from main window
void pythonDebugFile (QString filename)
 signal emitted if macro (filename) should be executed in python

Public Member Functions

 ScriptEditorOrganizer (bool dockAvailable)
 constructor
 ~ScriptEditorOrganizer ()
 destructor
RetVal saveAllScripts (bool askFirst=true, bool ignoreNewScripts=false)
 saves all opened scripts, if changes exist
RetVal closeAllScripts (bool saveFirst)
 tries to close all opened script.
void saveScriptState ()
 This function is called to save all the informations about widgets before itom is closed.
RetVal restoreScriptState ()
 This function is called to get all the saved informations about widgets after itom starts.
const QStringList & getRecentlyUsedFiles () const

Protected Member Functions

ScriptDockWidgetcreateEmptyScriptDock (bool docked, Qt::DockWidgetArea area=Qt::TopDockWidgetArea, const QString &objectName=QString())
 creates new ScriptDockWidget without any script editor tab.

Private Slots

void widgetFocusChanged (QWidget *old, QWidget *now)
 slot is connected to signal "focusChanged" of QApplication and indicates every change in the active widget.

Private Member Functions

ScriptDockWidgetgetFirstDockedElement ()
 returns first ScriptDockWidget of the widget-list which is docked. This is also the last activated docked widget.
ScriptDockWidgetgetFirstUndockedElement ()
ScriptDockWidgetgetActiveDockWidget ()
 returns the ScriptDockWidget, which actually has the focus or lastly got the focus.

Private Attributes

QList< ScriptDockWidget * > scriptDockElements
QSet< QString > m_usedObjectNames
 list with references to all ScriptDockWidgets (docked or windows-style)
bool m_dockAvailable
 currently used objectNames for script windows
QMutex m_scriptStackMutex
 true if docking mode is available, else: false
QStringList m_recentlyUsedFiles
 mutex locking any changes to scriptDockElements

Detailed Description

organizes script editors, independent on their appearance (docked or window-style)


Constructor & Destructor Documentation

ito::ScriptEditorOrganizer::ScriptEditorOrganizer ( bool  dockAvailable)

constructor

setups connections to python engine and to get a notification about focus changes.

Parameters:
dockAvailabletrue if dock functionality is available
ito::ScriptEditorOrganizer::~ScriptEditorOrganizer ( )

destructor

disconnections remaining connections to python engine and deletes remaining ScriptDockWidgets (should no occure)


Member Function Documentation

RetVal ito::ScriptEditorOrganizer::closeAllScripts ( bool  saveFirst)

tries to close all opened script.

long description

Parameters:
saveFirstindicates whether unsaved or new scripts should be saved first.
Returns:
retOk if all scripts could be closed, else retError

< copy since scriptDockElements will change its size during closing

ScriptDockWidget * ito::ScriptEditorOrganizer::createEmptyScriptDock ( bool  docked,
Qt::DockWidgetArea  area = Qt::TopDockWidgetArea,
const QString &  objectName = QString() 
) [protected]

creates new ScriptDockWidget without any script editor tab.

Since there should only be one docked widget, docked will be set to false if there exists already a docked widget. Setups connections between the new ScriptDockWidget and this organizer or the python engine.

Parameters:
dockedtrue, if widget should be docked in main window, else false (new on-top window)
Returns:
reference to new ScriptDockWidget

< setup signal/slot-connection to python thread

void ito::ScriptEditorOrganizer::dockScriptTab ( ScriptDockWidget widget,
int  index,
bool  closeDockIfEmpty = false 
) [slot]

slot invoked if tab, defined by its index, if the given widget should be docked

The script editor which should be docked is given by its ScriptDockWidget container, named widget, and its tab index. If there exists at least one docked ScriptDockWidget, widget will be docked there, otherwise a new docked ScriptDockWidget is opened first. If the source ScriptDockWidget does not contain any other tabs and if closeDockIfEmpty is set, the source widget will be closed.

Parameters:
widgetScriptDockWidget container, which contains the tab
indextab-index of the tab
closeDockIfEmptysee method description
void ito::ScriptEditorOrganizer::fileOpenedOrSaved ( const QString &  filename) [slot]

This slot is called if a file is saved or stored in any widget.

This function is used to manage the "last used files" list. It stores all used files in the list and keeps it up to date. If the list is longer than 10 elements, the last ones are deleted.

Parameters:
filenamefilename of a saved or loaded file is insert into the list at first position
ScriptDockWidget * ito::ScriptEditorOrganizer::getActiveDockWidget ( ) [private]

returns the ScriptDockWidget, which actually has the focus or lastly got the focus.

Returns:
Active ScriptDockWidget or NULL, if no ScriptDockWidget is available
ScriptDockWidget * ito::ScriptEditorOrganizer::getFirstDockedElement ( ) [private]

returns first ScriptDockWidget of the widget-list which is docked. This is also the last activated docked widget.

Returns:
docked ScriptDockWidget or NULL, if no such widget exists.
ScriptDockWidget * ito::ScriptEditorOrganizer::getFirstUndockedElement ( ) [private]
RetVal ito::ScriptEditorOrganizer::newScript ( ItomSharedSemaphore semaphore = NULL) [slot]

slot, invoked if new script should be opened

Parameters:
waitCondItomSharedSemaphore which will be waked up if process is finished. Use NULL if nothing should happen
Returns:
retOk if success, else retError
void ito::ScriptEditorOrganizer::openNewScriptWindow ( bool  docked,
ItomSharedSemaphore semaphore = NULL 
) [slot]

slot invoked if empty new script window should be created and displayed

long description

Parameters:
dockedindicates whether script window should be docked in MainWindow or not
waitCondItomSharedSemaphore which will be waked up if process is finished. Use NULL if nothing should happen
RetVal ito::ScriptEditorOrganizer::openScript ( const QString &  filename,
ItomSharedSemaphore semaphore = NULL,
int  visibleLineNr = -1 
) [slot]

slot, invoked if python macro file should be opened as new tab in active script editor window

Parameters:
filenameFilename of the python macro
semaphoreItomSharedSemaphore which will be woken up if opening process is finished. Use NULL if nothing should happen
visibleLineNris the line number that should be visible and where the cursor should be positioned (default: -1, no cursor positioning)
Returns:
retOk if success, else retError
ScriptDockWidget * ito::ScriptEditorOrganizer::openScriptRequested ( const QString &  filename,
ScriptDockWidget widget 
) [slot]

slot invoked if a file open command has been executed in any script window.

Checks if filename already has been opened in another script window. If yes only activates this tab, else openes the script in the given widget (if NULL opens a new script window)

Parameters:
filenameFilename of the python macro which should be opened
widgetScriptDockWidget where this macro should appear as new tab. If NULL, new script window will be created
See also:
ScriptDockWidget
void ito::ScriptEditorOrganizer::pythonDebugFileRequested ( QString  filename) [slot]

slot invoked if someone wants to debug a python file with filename.

Before signaling the debug command, checks that every opened script already having a filename is saved.

Parameters:
filenameFilename of the python script where the debugging should start
void ito::ScriptEditorOrganizer::pythonDebugPositionChanged ( QString  filename,
int  lineNo 
) [slot]

slot invoked if line in python debugging process has been changed

Checks, if filename is already opened in one script editor. If yes, activates this script editor. If no, opens this the specified script in a new tab.

Parameters:
filenameFilename of actual executed python macro
lineNoline number in file (here not used)
void ito::ScriptEditorOrganizer::pythonRunFileRequested ( QString  filename) [slot]

slot invoked if someone wants to run a python file with filename.

Before signaling the execution command, checks that every opened script already having a filename is saved.

Parameters:
filenameFilename of the python script where the execution should start
void ito::ScriptEditorOrganizer::removeScriptDockWidget ( ScriptDockWidget widget) [slot]

signal emitted if macro (filename) should be debugged in python

slot invoked by ScriptDockWidget close event method. The given widget should be closed and removed from the scriptDockElements-list

Disconnects many connections between the ScriptDockWidget and the ScriptEditorOrganizer or the PythonEngine. Emits signal to equally remove the widget from the docking area in main window.

Parameters:
widgetScriptDockWidget which should be closed and removed
RetVal ito::ScriptEditorOrganizer::saveAllScripts ( bool  askFirst = true,
bool  ignoreNewScripts = false 
)

saves all opened scripts, if changes exist

Parameters:
askFirsttrue if user can decide whether to save the script or not
ignoreNewScriptstrue if scripts which do not have a filename should be ignored
Returns:
retOk if everything done, else retError (e.g. user cancellation)
void ito::ScriptEditorOrganizer::undockScriptTab ( ScriptDockWidget widget,
int  index,
bool  undockToNewScriptWindow = false,
bool  closeDockIfEmpty = false 
) [slot]

slot invoked if tab, defined by its index, in the given widget should be undocked

The script editor which should be undocked is given by its ScriptDockWidget container, named widget, and its tab index. If the active ScriptDockWidget is already undocked, widget will be docked there, otherwise a new undocked ScriptDockWidget is opened first. If the source ScriptDockWidget does not contain any other tabs and if closeDockIfEmpty is set, the source widget will be closed.

Parameters:
widgetScriptDockWidget container, which contains the tab
indextab-index of the tab
closeDockIfEmptysee method description
void ito::ScriptEditorOrganizer::widgetFocusChanged ( QWidget *  old,
QWidget *  now 
) [private, slot]

slot is connected to signal "focusChanged" of QApplication and indicates every change in the active widget.

This slot is evaluated in order to check, whether a ScriptDockWidget has been activated (has got the focus). If so, this ScriptDockWidget will be moved on top of the scriptDockElements-list, since the first element should always be the active one. Write action to scriptDockElements is protected by scriptStackMutex.

Parameters:
nowwidget which just got the focus

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends