itom 1.1.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 SCRIPTDOCKWIDGET_H 00024 #define SCRIPTDOCKWIDGET_H 00025 00026 #include "abstractDockWidget.h" 00027 #include "QTabWidgetItom.h" 00028 #include "scriptEditorWidget.h" 00029 00030 #include <qaction.h> 00031 #include <qstring.h> 00032 #include <qtoolbar.h> 00033 00034 #include <qevent.h> 00035 00036 #include "../ui/widgetFindWord.h" 00037 00038 namespace ito { 00039 00040 class DialogReplace; //forward declaration 00041 00042 class ScriptDockWidget : public AbstractDockWidget 00043 { 00044 Q_OBJECT 00045 public: 00046 ScriptDockWidget(const QString &title, const QString &objName, bool docked, bool isDockAvailable, QWidget *parent = 0, Qt::WindowFlags flags = 0); 00047 ~ScriptDockWidget(); 00048 00049 QStringList getModifiedFileNames(bool ignoreNewScripts = false, int excludeIndex = -1) const; 00050 00051 RetVal newScript(); 00052 RetVal openScript(); 00053 RetVal openScript(QString filename, bool silent = false); 00054 RetVal saveAllScripts(bool askFirst = true, bool ignoreNewScripts = false, int excludeIndex = -1); 00055 RetVal closeAllScripts(bool saveFirst = true, bool askFirst = true, bool ignoreNewScripts = false, int excludeIndex = -1); 00056 00057 inline bool isTabIndexValid(int tabIndex) const { return (tabIndex >= 0 && tabIndex < m_tab->count()); }; 00058 inline int getTabCount() const { return m_tab->count(); }; 00059 bool containsNewScripts() const; 00060 00061 RetVal appendEditor(ScriptEditorWidget* editorWidget); 00062 ScriptEditorWidget* removeEditor(int index); 00063 bool activateTabByFilename(QString filename, int line = -1); 00064 bool activeTabEnsureLineVisible(int lineNr); 00065 00066 protected: 00067 ScriptEditorWidget* getEditorByIndex(int index) const; 00068 ScriptEditorWidget* getCurrentEditor() const; 00069 00070 int getIndexByEditor(ScriptEditorWidget* sew) const; 00071 00072 00073 void createActions(); 00074 //void deleteActions(); 00075 void createMenus(); 00076 void createToolBars(); 00077 void createStatusBar(); 00078 00079 //void windowStateChanged( bool windowNotToolbox ); 00080 00081 void closeEvent(QCloseEvent *event); 00082 00083 RetVal closeTab(int index, bool saveFirst = true); 00084 RetVal saveTab(int index, bool forceSaveAs = false, bool askFirst = true); 00085 00086 private: 00087 QWidget *m_pCenterWidget; 00088 QVBoxLayout *m_pVBox; 00089 QTabWidgetItom* m_tab; 00090 WidgetFindWord *m_pWidgetFindWord; 00091 DialogReplace *m_pDialogReplace; 00092 00093 int m_actTabIndex; 00095 // ACTIONS 00096 ShortcutAction *m_tabMoveLeftAction; 00097 ShortcutAction *m_tabMoveRightAction; 00098 ShortcutAction *m_tabMoveFirstAction; 00099 ShortcutAction *m_tabMoveLastAction; 00100 ShortcutAction *m_tabCloseAction; 00101 ShortcutAction *m_tabCloseOthersAction; 00102 ShortcutAction *m_tabCloseAllAction; 00103 ShortcutAction *m_tabDockAction; 00104 ShortcutAction *m_tabUndockAction; 00105 ShortcutAction *m_newScriptAction; 00106 ShortcutAction *m_openScriptAction; 00107 ShortcutAction *m_saveScriptAction; 00108 ShortcutAction *m_saveScriptAsAction; 00109 ShortcutAction *m_saveAllScriptsAction; 00110 ShortcutAction *m_printAction; 00111 ShortcutAction *m_cutAction; 00112 ShortcutAction *m_copyAction; 00113 ShortcutAction *m_pasteAction; 00114 ShortcutAction *m_undoAction; 00115 ShortcutAction *m_redoAction; 00116 ShortcutAction *m_commentAction; 00117 ShortcutAction *m_uncommentAction; 00118 ShortcutAction *m_indentAction; 00119 ShortcutAction *m_unindentAction; 00120 ShortcutAction *m_scriptRunAction; 00121 ShortcutAction *m_scriptRunSelectionAction; 00122 ShortcutAction *m_scriptDebugAction; 00123 ShortcutAction *m_scriptStopAction; 00124 ShortcutAction *m_scriptContinueAction; 00125 ShortcutAction *m_scriptStepAction; 00126 ShortcutAction *m_scriptStepOverAction; 00127 ShortcutAction *m_scriptStepOutAction; 00128 ShortcutAction *m_findTextExprAction; 00129 ShortcutAction *m_replaceTextExprAction; 00130 ShortcutAction *m_gotoAction; 00131 ShortcutAction *m_openIconBrowser; 00132 ShortcutAction *m_bookmarkToggle; 00133 ShortcutAction *m_bookmarkNext; 00134 ShortcutAction *m_bookmarkPrevious; 00135 ShortcutAction *m_bookmarkClearAll; 00136 00137 QMenu *m_tabContextMenu; 00138 QMenu *m_fileMenu; 00139 QMenu *m_viewMenu; 00140 QMenu *m_editMenu; 00141 QMenu *m_scriptMenu; 00142 QMenu *m_winMenu; 00143 QMenu *m_bookmark; 00144 00145 QToolBar* m_fileToolBar; 00146 QToolBar* m_editToolBar; 00147 QToolBar* m_scriptToolBar; 00148 QToolBar* m_bookmarkToolBar; 00149 00150 signals: 00151 void removeAndDeleteScriptDockWidget(ScriptDockWidget* widget); 00153 void openScriptRequest(QString filename, ScriptDockWidget* scriptDockWidget); 00155 void dockScriptTab(ScriptDockWidget* widget, int index, bool closeDockIfEmpty = false); 00156 void undockScriptTab(ScriptDockWidget* widget, int index, bool undockToNewScriptWindow = false, bool closeDockIfEmpty = false); 00158 void pythonRunFileRequest(QString filename); 00159 void pythonDebugFileRequest(QString filename); 00160 void pythonInterruptExecution(); 00161 void pythonDebugCommand(tPythonDbgCmd cmd); 00162 void pythonRunSelection(QString selectionText); 00164 private slots: 00165 void tabContextMenuEvent (QContextMenuEvent * event); 00166 00167 void findTextExpr(QString expr, bool regExpr, bool caseSensitive, bool wholeWord, bool wrap, bool forward, bool isQuickSeach); 00168 void replaceTextExpr(QString expr, QString replace); 00169 void replaceAllExpr(QString expr, QString replace, bool regExpr, bool caseSensitive, bool wholeWord); 00170 void insertIconBrowserText(QString iconLink); 00171 00172 void currentTabChanged(int index); 00173 void tabCloseRequested(int index); 00174 void tabCloseRequested(ScriptEditorWidget* sew, bool ignoreModifications); 00175 void scriptModificationChanged(bool changed); 00176 00177 void updateEditorActions(); 00178 void updatePythonActions(); 00179 void updateTabContextActions(); 00180 00181 void mnuOpenIconBrowser(); 00182 00183 void mnuTabMoveLeft(); 00184 void mnuTabMoveRight(); 00185 void mnuTabMoveFirst(); 00186 void mnuTabMoveLast(); 00187 void mnuTabClose(); 00188 void mnuTabCloseOthers(); 00189 void mnuTabCloseAll(); 00190 void mnuTabDock(); 00191 void mnuTabUndock(); 00192 void mnuNewScript(); 00193 void mnuOpenScript(); 00194 void mnuSaveScript(); 00195 void mnuSaveScriptAs(); 00196 void mnuSaveAllScripts(); 00197 void mnuPrint(); 00198 void mnuCut(); 00199 void mnuCopy(); 00200 void mnuPaste(); 00201 void mnuUndo(); 00202 void mnuRedo(); 00203 void mnuComment(); 00204 void mnuUncomment(); 00205 void mnuIndent(); 00206 void mnuUnindent(); 00207 void mnuScriptRun(); 00208 void mnuScriptRunSelection(); 00209 void mnuScriptDebug(); 00210 void mnuScriptStop(); 00211 void mnuScriptContinue(); 00212 void mnuScriptStep(); 00213 void mnuScriptStepOver(); 00214 void mnuScriptStepOut(); 00215 void mnuFindTextExpr(); 00216 void mnuReplaceTextExpr(); 00217 void mnuGoto(); 00218 void mnuToggleBookmark(); 00219 void mnuClearAllBookmarks(); 00220 void mnuGotoNextBookmark(); 00221 void mnuGotoPreviousBookmark(); 00222 00223 public slots: 00224 void editorMarginChanged(); 00225 }; 00226 00227 } //end namespace ito 00228 00229 #endif