itom 1.3.0
D:/git-itom/sources/itom/Qitom/organizer/scriptEditorOrganizer.h
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     const QStringList &getRecentlyUsedFiles() const { return m_recentlyUsedFiles; }
00049 
00050 protected:
00051     ScriptDockWidget* createEmptyScriptDock(bool docked, Qt::DockWidgetArea area = Qt::TopDockWidgetArea, const QString &objectName = QString());
00052 
00053     
00054 
00055 private:
00056     ScriptDockWidget* getFirstDockedElement();
00057     ScriptDockWidget* getFirstUndockedElement();
00058     ScriptDockWidget* getActiveDockWidget();
00059 
00060     QList<ScriptDockWidget*> scriptDockElements;    
00061     QSet<QString> m_usedObjectNames;               
00062     bool m_dockAvailable;                             
00063 
00064     QMutex m_scriptStackMutex;                        
00065 
00066     QStringList m_recentlyUsedFiles;
00067 
00068 signals:
00069     void addScriptDockWidgetToMainWindow(AbstractDockWidget *dockWidget, Qt::DockWidgetArea area); 
00070     void removeScriptDockWidgetFromMainWindow(AbstractDockWidget *dockWidget);                     
00071 
00072     void pythonRunFile(QString filename);           
00073     void pythonDebugFile(QString filename);         
00074 
00075 public slots:
00076     void removeScriptDockWidget(ScriptDockWidget* widget);
00077 
00078     void dockScriptTab(ScriptDockWidget* widget, int index, bool closeDockIfEmpty = false);
00079     void undockScriptTab(ScriptDockWidget* widget, int index, bool undockToNewScriptWindow = false, bool closeDockIfEmpty = false);
00080 
00081     void openNewScriptWindow(bool docked, ItomSharedSemaphore* semaphore = NULL);
00082     RetVal newScript(ItomSharedSemaphore* semaphore = NULL);
00083     RetVal openScript(const QString &filename, ItomSharedSemaphore* semaphore = NULL, int visibleLineNr = -1);
00084 
00085     ScriptDockWidget* openScriptRequested(const QString &filename, ScriptDockWidget* widget);
00086 
00087     void pythonRunFileRequested(QString filename);
00088     void pythonDebugFileRequested(QString filename);
00089 
00090     void pythonDebugPositionChanged(QString filename, int lineNo);
00091 
00092     void fileOpenedOrSaved(const QString &filename);
00093 
00094 private slots:
00095     void widgetFocusChanged(QWidget* old, QWidget* now);
00096 
00097 };
00098 
00099 } //end namespace ito
00100 
00101 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends