itom
Loading...
Searching...
No Matches
scriptEditorOrganizer.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2024, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23#ifndef SCRIPTEDITORORGANIZER_H
24#define SCRIPTEDITORORGANIZER_H
25
26#include "../common/sharedStructuresQt.h"
27#include "../models/bookmarkModel.h"
28#include "../widgets/outlineSelectorWidget.h"
29#include "../widgets/scriptDockWidget.h"
30#include "../widgets/scriptEditorWidget.h"
31
32#include <qlist.h>
33#include <qsignalmapper.h>
34#include <qpair.h>
35
36namespace ito {
37
38QDataStream& operator<<(QDataStream& out, const ito::ScriptEditorStorage& obj);
39
40QDataStream& operator>>(QDataStream& in, ito::ScriptEditorStorage& obj);
41
42class ScriptEditorOrganizer : public QObject
43{
44 Q_OBJECT
45
46public:
47 ScriptEditorOrganizer(bool dockAvailable);
49
51 bool askFirst = true, bool ignoreNewScripts = false, int* saveScriptState = NULL);
52 RetVal closeAllScripts(bool saveFirst);
53
54 void saveScriptState();
56
57 const QStringList& getRecentlyUsedFiles() const
58 {
60 }
61
62 inline const ScriptEditorActions& getScriptEditorActions() const
63 {
64 return m_commonScriptEditorActions;
65 }
66
67 QStringList openedScripts() const;
68
69 QVector<QPair<QString, bool>> getAllOpenedScriptsWithModificationState() const;
70
71 inline BookmarkModel* getBookmarkModel() const
72 {
73 return m_pBookmarkModel;
74 }
75
76 ScriptDockWidget* activateOpenedScriptByFilename(
77 const QString& filename, int currentDebugLine = -1, int UID = -1);
79
81 QList<OutlineSelectorWidget::EditorOutline> getAllOutlines(
82 const ScriptDockWidget* currentScriptDockWidget, int& currentIndex) const;
83
84 ScriptEditorWidget* getEditorFromCanonicalFilepath(const QString &filepath) const;
85
86protected:
88 bool docked,
89 Qt::DockWidgetArea area = Qt::TopDockWidgetArea,
90 const QString& objectName = QString());
91
92 RetVal applyGoBackNavigationItem(const GoBackNavigationItem& item);
93 void updateGoBackNavigationActions();
94
95private:
98
99 BookmarkModel* m_pBookmarkModel;
100
101 QList<ScriptDockWidget*> m_scriptDockElements;
103 QSet<QString> m_usedObjectNames;
106 mutable QMutex m_scriptStackMutex;
108
110
111 ScriptEditorActions m_commonScriptEditorActions;
112 QMenu* m_pGoBackNavigationMenu;
113 QList<GoBackNavigationItem>
120 static const int
122
123signals:
125 AbstractDockWidget* dockWidget,
126 Qt::DockWidgetArea
127 area);
130 dockWidget);
131
133 QString filename);
135 QString filename);
136
137public slots:
139
140 void dockScriptTab(ScriptDockWidget* widget, int index, bool closeDockIfEmpty = false);
141 void undockScriptTab(
142 ScriptDockWidget* widget,
143 int index,
144 bool undockToNewScriptWindow = false,
145 bool closeDockIfEmpty = false);
146
147 RetVal openNewScriptWindow(bool docked, ItomSharedSemaphore* semaphore = NULL);
148 RetVal newScript(ItomSharedSemaphore* semaphore = NULL);
150 const QString& filename,
151 ItomSharedSemaphore* semaphore = NULL,
152 int visibleLineNr = -1,
153 bool errorMessageClick = false,
154 bool showSelectedCallstackLine = false);
155
156 ScriptDockWidget* openScriptRequested(const QString& filename, ScriptDockWidget* widget);
157
158 void pythonRunFileRequested(QString filename);
159 void pythonDebugFileRequested(QString filename);
160
161 void pythonDebugPositionChanged(QString filename, int lineNo);
162
163 void fileOpenedOrSaved(const QString& filename);
164
165private slots:
166 void widgetFocusChanged(QWidget* old, QWidget* now);
167
168 void onAddGoBackNavigationItem(const GoBackNavigationItem& item);
169 void onGotoBookmark(const BookmarkItem& item);
170
171 // Action slots
172 void mnuNavigateForward();
173 void mnuNavigateBackward();
174 void mnuNavigateBackwardItem(int index);
175};
176
177} // end namespace ito
178
179#endif
semaphore which can be used for asynchronous thread communication. By using this class it is possible...
Definition sharedStructuresQt.h:58
abstract dock widget class which inherits QDockWidget. The content of QDockWidget consists of an inst...
Definition abstractDockWidget.h:55
model for management of all bookmarks. This model will be displayed by a viewer-widget in the main wi...
Definition bookmarkModel.h:65
Class for managing status values (like errors or warning)
Definition retVal.h:54
widget containing one or multiple script editors (tabbed). This widget can either be a docking widget...
Definition scriptDockWidget.h:59
organizes script editors, independent on their appearance (docked or window-style)
Definition scriptEditorOrganizer.h:43
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
Definition scriptEditorOrganizer.cpp:849
void removeScriptDockWidgetFromMainWindow(AbstractDockWidget *dockWidget)
signal emitted if dockWidget should be added to docking area in main window
void fileOpenedOrSaved(const QString &filename)
This slot is called if a file is saved or stored in any widget.
Definition scriptEditorOrganizer.cpp:359
void pythonDebugPositionChanged(QString filename, int lineNo)
slot invoked if line in python debugging process has been changed
Definition scriptEditorOrganizer.cpp:1049
void dockScriptTab(ScriptDockWidget *widget, int index, bool closeDockIfEmpty=false)
slot invoked if tab, defined by its index, if the given widget should be docked
Definition scriptEditorOrganizer.cpp:705
void addScriptDockWidgetToMainWindow(AbstractDockWidget *dockWidget, Qt::DockWidgetArea area)
maximum number of entries in the go back navigation history.
int m_goBackNavigationIndex
Definition scriptEditorOrganizer.h:117
~ScriptEditorOrganizer()
destructor
Definition scriptEditorOrganizer.cpp:120
RetVal saveAllScripts(bool askFirst=true, bool ignoreNewScripts=false, int *saveScriptState=NULL)
saves all opened scripts, if changes exist
Definition scriptEditorOrganizer.cpp:484
RetVal newScript(ItomSharedSemaphore *semaphore=NULL)
slot, invoked if new script should be opened
Definition scriptEditorOrganizer.cpp:796
bool m_dockedNewWidget
true if docking mode is available, else: false
Definition scriptEditorOrganizer.h:105
static const int MaxGoBackNavigationEntries
Definition scriptEditorOrganizer.h:121
void saveScriptState()
This function is called to save all the information about widgets before itom is closed.
Definition scriptEditorOrganizer.cpp:148
QStringList m_recentlyUsedFiles
Definition scriptEditorOrganizer.h:109
ScriptEditorOrganizer(bool dockAvailable)
constructor
Definition scriptEditorOrganizer.cpp:78
RetVal restoreScriptState()
This function is called to get all the saved information about widgets after itom starts.
Definition scriptEditorOrganizer.cpp:209
void pythonRunFileRequested(QString filename)
slot invoked if someone wants to run a python file with filename.
Definition scriptEditorOrganizer.cpp:977
void removeScriptDockWidget(ScriptDockWidget *widget)
signal emitted if macro (filename) should be debugged in python
Definition scriptEditorOrganizer.cpp:459
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
Definition scriptEditorOrganizer.cpp:736
RetVal openNewScriptWindow(bool docked, ItomSharedSemaphore *semaphore=NULL)
slot invoked if empty new script window should be created and displayed
Definition scriptEditorOrganizer.cpp:765
RetVal closeAllScripts(bool saveFirst)
tries to close all opened script.
Definition scriptEditorOrganizer.cpp:565
void pythonRunFile(QString filename)
signal emitted if dockWidget should be removed from main window
ScriptDockWidget * openScriptRequested(const QString &filename, ScriptDockWidget *widget)
slot invoked if a file open command has been executed in any script window.
Definition scriptEditorOrganizer.cpp:936
void widgetFocusChanged(QWidget *old, QWidget *now)
slot is connected to signal "focusChanged" of QApplication and indicates every change in the active w...
Definition scriptEditorOrganizer.cpp:658
bool m_dockAvailable
currently used objectNames for script windows
Definition scriptEditorOrganizer.h:104
ScriptDockWidget * createEmptyScriptDock(bool docked, Qt::DockWidgetArea area=Qt::TopDockWidgetArea, const QString &objectName=QString())
creates new ScriptDockWidget without any script editor tab.
Definition scriptEditorOrganizer.cpp:383
void pythonDebugFileRequested(QString filename)
slot invoked if someone wants to debug a python file with filename.
Definition scriptEditorOrganizer.cpp:1012
void pythonDebugFile(QString filename)
signal emitted if macro (filename) should be executed in python
ScriptDockWidget * getActiveDockWidget() const
returns the outlines of all opened scripts
Definition scriptEditorOrganizer.cpp:616
ScriptDockWidget * getFirstUndockedElement() const
Definition scriptEditorOrganizer.cpp:635
QList< GoBackNavigationItem > m_goBackNavigationHistory
menu for the backward items
Definition scriptEditorOrganizer.h:114
QSet< QString > m_usedObjectNames
Definition scriptEditorOrganizer.h:103
ScriptDockWidget * getFirstDockedElement() const
returns first ScriptDockWidget of the widget-list which is docked. This is also the last activated do...
Definition scriptEditorOrganizer.cpp:596
Definition scriptEditorWidget.h:99
Definition apiFunctionsGraph.cpp:40
item of BookmarkModel
Definition bookmarkModel.h:43
Definition scriptEditorWidget.h:78
this struct can hold common actions for all script editor and script dock widgets
Definition scriptDockWidget.h:52
Definition scriptEditorWidget.h:70