itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef SCRIPTEDITORORGANIZER_H 00024 #define SCRIPTEDITORORGANIZER_H 00025 00026 #include "../widgets/scriptDockWidget.h" 00027 #include "../common/sharedStructuresQt.h" 00028 00029 00030 namespace ito 00031 { 00032 QDataStream &operator<<(QDataStream &out, const ito::ScriptEditorStorage &obj); 00033 00034 QDataStream &operator>>(QDataStream &in, ito::ScriptEditorStorage &obj); 00035 00036 class ScriptEditorOrganizer : public QObject 00037 { 00038 Q_OBJECT 00039 public: 00040 ScriptEditorOrganizer( bool dockAvailable); 00041 ~ScriptEditorOrganizer(); 00042 00043 RetVal saveAllScripts(bool askFirst = true, bool ignoreNewScripts = false, int *saveScriptState = NULL); 00044 RetVal closeAllScripts(bool saveFirst); 00045 00046 void saveScriptState(); 00047 RetVal restoreScriptState(); 00048 00049 const QStringList &getRecentlyUsedFiles() const { return m_recentlyUsedFiles; } 00050 00051 QStringList openedScripts() const; 00052 00053 protected: 00054 ScriptDockWidget* createEmptyScriptDock(bool docked, Qt::DockWidgetArea area = Qt::TopDockWidgetArea, const QString &objectName = QString()); 00055 00056 private: 00057 ScriptDockWidget* getFirstDockedElement(); 00058 ScriptDockWidget* getFirstUndockedElement(); 00059 ScriptDockWidget* getActiveDockWidget(); 00060 00061 QList<ScriptDockWidget*> scriptDockElements; 00062 QSet<QString> m_usedObjectNames; 00063 bool m_dockAvailable; 00064 00065 QMutex m_scriptStackMutex; 00066 00067 QStringList m_recentlyUsedFiles; 00068 00069 signals: 00070 void addScriptDockWidgetToMainWindow(AbstractDockWidget *dockWidget, Qt::DockWidgetArea area); 00071 void removeScriptDockWidgetFromMainWindow(AbstractDockWidget *dockWidget); 00072 00073 void pythonRunFile(QString filename); 00074 void pythonDebugFile(QString filename); 00075 00076 public slots: 00077 void removeScriptDockWidget(ScriptDockWidget* widget); 00078 00079 void dockScriptTab(ScriptDockWidget* widget, int index, bool closeDockIfEmpty = false); 00080 void undockScriptTab(ScriptDockWidget* widget, int index, bool undockToNewScriptWindow = false, bool closeDockIfEmpty = false); 00081 00082 void openNewScriptWindow(bool docked, ItomSharedSemaphore* semaphore = NULL); 00083 RetVal newScript(ItomSharedSemaphore* semaphore = NULL); 00084 RetVal openScript(const QString &filename, ItomSharedSemaphore* semaphore = NULL, int visibleLineNr = -1, bool errorMessageClick = false); 00085 00086 ScriptDockWidget* openScriptRequested(const QString &filename, ScriptDockWidget* widget); 00087 00088 void pythonRunFileRequested(QString filename); 00089 void pythonDebugFileRequested(QString filename); 00090 00091 void pythonDebugPositionChanged(QString filename, int lineNo); 00092 00093 void fileOpenedOrSaved(const QString &filename); 00094 00095 private slots: 00096 void widgetFocusChanged(QWidget* old, QWidget* now); 00097 }; 00098 00099 } //end namespace ito 00100 00101 #endif