itom 1.0.14
|
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, 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 00151 signals: 00152 void removeAndDeleteScriptDockWidget(ScriptDockWidget* widget); 00154 void openScriptRequest(QString filename, ScriptDockWidget* scriptDockWidget); 00156 void dockScriptTab(ScriptDockWidget* widget, int index, bool closeDockIfEmpty = false); 00157 void undockScriptTab(ScriptDockWidget* widget, int index, bool undockToNewScriptWindow = false, bool closeDockIfEmpty = false); 00159 void pythonRunFileRequest(QString filename); 00160 void pythonDebugFileRequest(QString filename); 00161 void pythonInterruptExecution(); 00162 void pythonDebugCommand(tPythonDbgCmd cmd); 00163 void pythonRunSelection(QString selectionText); 00165 private slots: 00166 void tabContextMenuEvent (QContextMenuEvent * event); 00167 00168 void findTextExpr(QString expr, bool regExpr, bool caseSensitive, bool wholeWord, bool wrap, bool forward, bool isQuickSeach); 00169 void replaceTextExpr(QString expr, QString replace); 00170 void replaceAllExpr(QString expr, QString replace, bool regExpr, bool caseSensitive, bool wholeWord); 00171 void insertIconBrowserText(QString iconLink); 00172 00173 void currentTabChanged(int index); 00174 void tabCloseRequested(int index); 00175 void tabCloseRequested(ScriptEditorWidget* sew, bool ignoreModifications); 00176 void scriptModificationChanged(bool changed); 00177 00178 void updateEditorActions(); 00179 void updatePythonActions(); 00180 void updateTabContextActions(); 00181 00182 void mnuOpenIconBrowser(); 00183 00184 void mnuTabMoveLeft(); 00185 void mnuTabMoveRight(); 00186 void mnuTabMoveFirst(); 00187 void mnuTabMoveLast(); 00188 void mnuTabClose(); 00189 void mnuTabCloseOthers(); 00190 void mnuTabCloseAll(); 00191 void mnuTabDock(); 00192 void mnuTabUndock(); 00193 void mnuNewScript(); 00194 void mnuOpenScript(); 00195 void mnuSaveScript(); 00196 void mnuSaveScriptAs(); 00197 void mnuSaveAllScripts(); 00198 void mnuPrint(); 00199 void mnuCut(); 00200 void mnuCopy(); 00201 void mnuPaste(); 00202 void mnuUndo(); 00203 void mnuRedo(); 00204 void mnuComment(); 00205 void mnuUncomment(); 00206 void mnuIndent(); 00207 void mnuUnindent(); 00208 void mnuScriptRun(); 00209 void mnuScriptRunSelection(); 00210 void mnuScriptDebug(); 00211 void mnuScriptStop(); 00212 void mnuScriptContinue(); 00213 void mnuScriptStep(); 00214 void mnuScriptStepOver(); 00215 void mnuScriptStepOut(); 00216 void mnuFindTextExpr(); 00217 void mnuReplaceTextExpr(); 00218 void mnuGoto(); 00219 void mnuToggleBookmark(); 00220 void mnuClearAllBookmarks(); 00221 void mnuGotoNextBookmark(); 00222 void mnuGotoPreviousBookmark(); 00223 00224 public slots: 00225 void editorMarginChanged(); 00226 }; 00227 00228 } //end namespace ito 00229 00230 #endif