itom 1.2.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität 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 namespace ito 00030 { 00031 QDataStream &operator<<(QDataStream &out, const ito::ScriptEditorStorage &obj); 00032 00033 QDataStream &operator>>(QDataStream &in, ito::ScriptEditorStorage &obj); 00034 00035 class ScriptEditorOrganizer : public QObject 00036 { 00037 Q_OBJECT 00038 public: 00039 ScriptEditorOrganizer( bool dockAvailable); 00040 ~ScriptEditorOrganizer(); 00041 00042 RetVal saveAllScripts(bool askFirst = true, bool ignoreNewScripts = false); 00043 RetVal closeAllScripts(bool saveFirst); 00044 00045 void saveScriptState(); 00046 RetVal restoreScriptState(); 00047 00048 protected: 00049 ScriptDockWidget* createEmptyScriptDock(bool docked, Qt::DockWidgetArea area = Qt::TopDockWidgetArea, const QString &objectName = QString()); 00050 00051 00052 00053 private: 00054 ScriptDockWidget* getFirstDockedElement(); 00055 ScriptDockWidget* getFirstUndockedElement(); 00056 ScriptDockWidget* getActiveDockWidget(); 00057 00058 QList<ScriptDockWidget*> scriptDockElements; 00059 QSet<QString> m_usedObjectNames; 00060 bool m_dockAvailable; 00061 00062 QMutex m_scriptStackMutex; 00063 00064 signals: 00065 void addScriptDockWidgetToMainWindow(AbstractDockWidget *dockWidget, Qt::DockWidgetArea area); 00066 void removeScriptDockWidgetFromMainWindow(AbstractDockWidget *dockWidget); 00067 00068 void pythonRunFile(QString filename); 00069 void pythonDebugFile(QString filename); 00070 00071 public slots: 00072 void removeScriptDockWidget(ScriptDockWidget* widget); 00073 00074 void dockScriptTab(ScriptDockWidget* widget, int index, bool closeDockIfEmpty = false); 00075 void undockScriptTab(ScriptDockWidget* widget, int index, bool undockToNewScriptWindow = false, bool closeDockIfEmpty = false); 00076 00077 void openNewScriptWindow(bool docked, ItomSharedSemaphore* semaphore = NULL); 00078 RetVal newScript(ItomSharedSemaphore* semaphore = NULL); 00079 RetVal openScript(QString filename, ItomSharedSemaphore* semaphore = NULL, int visibleLineNr = -1); 00080 00081 ScriptDockWidget* openScriptRequested(QString filename, ScriptDockWidget* widget); 00082 00083 void pythonRunFileRequested(QString filename); 00084 void pythonDebugFileRequested(QString filename); 00085 00086 void pythonDebugPositionChanged(QString filename, int lineNo); 00087 00088 private slots: 00089 void widgetFocusChanged(QWidget* old, QWidget* now); 00090 00091 }; 00092 00093 } //end namespace ito 00094 00095 #endif