itom
Loading...
Searching...
No Matches
ito::ScriptEditorOrganizer Class Reference

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

Inheritance diagram for ito::ScriptEditorOrganizer:

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
 
RetVal 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, bool errorMessageClick=false, bool showSelectedCallstackLine=false)
 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)
 maximum number of entries in the go back navigation history.
 
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, int *saveScriptState=NULL)
 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 information about widgets before itom is closed.
 
RetVal restoreScriptState ()
 This function is called to get all the saved information about widgets after itom starts.
 
const QStringList & getRecentlyUsedFiles () const
 
const ScriptEditorActionsgetScriptEditorActions () const
 
QStringList openedScripts () const
 
QVector< QPair< QString, bool > > getAllOpenedScriptsWithModificationState () const
 
BookmarkModelgetBookmarkModel () const
 
ScriptDockWidgetactivateOpenedScriptByFilename (const QString &filename, int currentDebugLine=-1, int UID=-1)
 
ScriptDockWidgetgetActiveDockWidget () const
 returns the outlines of all opened scripts
 
QList< OutlineSelectorWidget::EditorOutlinegetAllOutlines (const ScriptDockWidget *currentScriptDockWidget, int &currentIndex) const
 
ScriptEditorWidgetgetEditorFromCanonicalFilepath (const QString &filepath) const
 

Protected Member Functions

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

Private Slots

void widgetFocusChanged (QWidget *old, QWidget *now)
 slot is connected to signal "focusChanged" of QApplication and indicates every change in the active widget.
 
void onAddGoBackNavigationItem (const GoBackNavigationItem &item)
 
void onGotoBookmark (const BookmarkItem &item)
 
void mnuNavigateForward ()
 
void mnuNavigateBackward ()
 
void mnuNavigateBackwardItem (int index)
 

Private Member Functions

ScriptDockWidgetgetFirstDockedElement () const
 returns first ScriptDockWidget of the widget-list which is docked. This is also the last activated docked widget.
 
ScriptDockWidgetgetFirstUndockedElement () const
 

Private Attributes

BookmarkModelm_pBookmarkModel
 
QList< ScriptDockWidget * > m_scriptDockElements
 
QSet< QString > m_usedObjectNames
 
bool m_dockAvailable
 currently used objectNames for script windows
 
bool m_dockedNewWidget
 true if docking mode is available, else: false
 
QMutex m_scriptStackMutex
 
QStringList m_recentlyUsedFiles
 
ScriptEditorActions m_commonScriptEditorActions
 
QMenu * m_pGoBackNavigationMenu
 
QList< GoBackNavigationItemm_goBackNavigationHistory
 menu for the backward items
 
int m_goBackNavigationIndex
 

Static Private Attributes

static const int MaxGoBackNavigationEntries = 20
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ScriptEditorOrganizer()

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

◆ ~ScriptEditorOrganizer()

ito::ScriptEditorOrganizer::~ScriptEditorOrganizer ( )

destructor

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

Member Function Documentation

◆ closeAllScripts()

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 m_scriptDockElements will change its size during closing

◆ createEmptyScriptDock()

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

◆ dockScriptTab

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

◆ fileOpenedOrSaved

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

◆ getActiveDockWidget()

ScriptDockWidget * ito::ScriptEditorOrganizer::getActiveDockWidget ( ) const

returns the outlines of all opened scripts

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

Returns
Active ScriptDockWidget or NULL, if no ScriptDockWidget is available

◆ getFirstDockedElement()

ScriptDockWidget * ito::ScriptEditorOrganizer::getFirstDockedElement ( ) const
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.

◆ getFirstUndockedElement()

ScriptDockWidget * ito::ScriptEditorOrganizer::getFirstUndockedElement ( ) const
private

◆ newScript

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

◆ openNewScriptWindow

ito::RetVal 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

◆ openScript

RetVal ito::ScriptEditorOrganizer::openScript ( const QString & filename,
ItomSharedSemaphore * semaphore = NULL,
int visibleLineNr = -1,
bool errorMessageClick = false,
bool showSelectedCallstackLine = false )
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)
errorMessageClickif true, the entire line will be marked with the "error line" background indicator
showSelectedCallstackLineif true, the callstackIcon (green arrow) will be added to the breakpoint panel of the script editor
Returns
retOk if success, else retError

◆ openScriptRequested

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 opens 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

◆ pythonDebugFileRequested

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

◆ pythonDebugPositionChanged

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)

◆ pythonRunFileRequested

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

◆ removeScriptDockWidget

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 m_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

◆ saveAllScripts()

RetVal ito::ScriptEditorOrganizer::saveAllScripts ( bool askFirst = true,
bool ignoreNewScripts = false,
int * saveScriptState = NULL )

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
saveScriptStateis the possibility to remember this action for the next time: NULL -> don't show a checkbox to remember this, else: pointer to value: 0: show message box and let user decide, 1: automatically save all changed files, 2: do not save unchanged files
Returns
retOk if everything done, else retError (e.g. user cancellation)

◆ undockScriptTab

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

◆ widgetFocusChanged

void ito::ScriptEditorOrganizer::widgetFocusChanged ( QWidget * old,
QWidget * now )
privateslot

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 m_scriptDockElements-list, since the first element should always be the active one. Write action to m_scriptDockElements is protected by scriptStackMutex.

Parameters
nowwidget which just got the focus

Member Data Documentation

◆ m_goBackNavigationIndex

int ito::ScriptEditorOrganizer::m_goBackNavigationIndex
private

history of go back navigation items. Newer items are at the end of the list. The list is limited to a number of maximum items.

◆ m_recentlyUsedFiles

QStringList ito::ScriptEditorOrganizer::m_recentlyUsedFiles
private

mutex locking any changes to m_scriptDockElements. This mutex can also be changed in const methods

◆ m_usedObjectNames

QSet<QString> ito::ScriptEditorOrganizer::m_usedObjectNames
private

list with references to all ScriptDockWidgets (docked or windows-style)

◆ MaxGoBackNavigationEntries

const int ito::ScriptEditorOrganizer::MaxGoBackNavigationEntries = 20
staticprivate

current position of script editors in goBackNavigationHistory. If equal to m_goBackNavigationHistory.size(), the current position is at the end.


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