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