itom 2.0.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 ShortcutAction *m_insertCodecAct; 00147 00148 QMenu *m_tabContextMenu; 00149 QMenu *m_fileMenu; 00150 QMenu *m_lastFilesMenu; 00151 QMenu *m_viewMenu; 00152 QMenu *m_editMenu; 00153 QMenu *m_scriptMenu; 00154 QMenu *m_winMenu; 00155 QMenu *m_bookmark; 00156 00157 QSignalMapper *m_lastFilesMapper; 00158 00159 QToolBar* m_fileToolBar; 00160 QToolBar* m_editToolBar; 00161 QToolBar* m_scriptToolBar; 00162 QToolBar* m_bookmarkToolBar; 00163 00164 // ClassNavigator 00165 QWidget *m_classMenuBar; 00166 QComboBox *m_classBox; 00167 QComboBox *m_methodBox; 00168 bool m_ClassNavigatorEnabled; 00169 void fillClassBox(const ClassNavigatorItem *parent, QString prefix); 00170 void fillMethodBox(const ClassNavigatorItem *parent); 00171 void showClassNavigator(bool show); 00172 QMap<int, ClassNavigatorItem*> m_rootElements; 00173 00174 signals: 00175 void removeAndDeleteScriptDockWidget(ScriptDockWidget* widget); 00177 void openScriptRequest(const QString &filename, ScriptDockWidget* scriptDockWidget); 00179 void dockScriptTab(ScriptDockWidget* widget, int index, bool closeDockIfEmpty = false); 00180 void undockScriptTab(ScriptDockWidget* widget, int index, bool undockToNewScriptWindow = false, bool closeDockIfEmpty = false); 00182 void pythonRunFileRequest(QString filename); 00183 void pythonDebugFileRequest(QString filename); 00184 void pythonInterruptExecution(); 00185 void pythonDebugCommand(tPythonDbgCmd cmd); 00186 void pythonRunSelection(QString selectionText); 00188 //void lastFileClicked(const QString &path); 00189 00190 private slots: 00191 void tabContextMenuEvent (QContextMenuEvent * event); 00192 00193 void findTextExpr(QString expr, bool regExpr, bool caseSensitive, bool wholeWord, bool wrap, bool forward, bool isQuickSeach); 00194 void replaceTextExpr(QString expr, QString replace); 00195 void replaceAllExpr(QString expr, QString replace, bool regExpr, bool caseSensitive, bool wholeWord, int findIn); 00196 void insertIconBrowserText(QString iconLink); 00197 00198 void currentTabChanged(int index); 00199 void tabCloseRequested(int index); 00200 void tabCloseRequested(ScriptEditorWidget* sew, bool ignoreModifications); 00201 void scriptModificationChanged(bool changed); 00202 00203 void updateEditorActions(); 00204 void updatePythonActions(); 00205 void updateTabContextActions(); 00206 00207 void mnuOpenIconBrowser(); 00208 00209 void mnuTabMoveLeft(); 00210 void mnuTabMoveRight(); 00211 void mnuTabMoveFirst(); 00212 void mnuTabMoveLast(); 00213 void mnuTabClose(); 00214 void mnuTabCloseOthers(); 00215 void mnuTabCloseAll(); 00216 void mnuTabDock(); 00217 void mnuTabUndock(); 00218 void mnuNewScript(); 00219 void mnuOpenScript(); 00220 void mnuSaveScript(); 00221 void mnuSaveScriptAs(); 00222 void mnuSaveAllScripts(); 00223 void mnuPrint(); 00224 void mnuCut(); 00225 void mnuCopy(); 00226 void mnuPaste(); 00227 void mnuUndo(); 00228 void mnuRedo(); 00229 void mnuComment(); 00230 void mnuUncomment(); 00231 void mnuIndent(); 00232 void mnuUnindent(); 00233 void mnuScriptRun(); 00234 void mnuScriptRunSelection(); 00235 void mnuScriptDebug(); 00236 void mnuScriptStop(); 00237 void mnuScriptContinue(); 00238 void mnuScriptStep(); 00239 void mnuScriptStepOver(); 00240 void mnuScriptStepOut(); 00241 void mnuFindTextExpr(); 00242 void mnuReplaceTextExpr(); 00243 void mnuGoto(); 00244 void mnuToggleBookmark(); 00245 void mnuClearAllBookmarks(); 00246 void mnuGotoNextBookmark(); 00247 void mnuGotoPreviousBookmark(); 00248 void mnuInsertCodec(); 00249 00250 void menuLastFilesAboutToShow(); 00251 void lastFileOpen(const QString &path); 00252 00253 // Class Navigator 00254 void classChosen(const QString &text); 00255 void methodChosen(const QString &text); 00256 00257 void loadSettings(); 00258 void findWordWidgetFinished(); 00259 00260 public slots: 00261 void editorMarginChanged(); 00262 void updateClassesBox(ScriptEditorWidget *editor); 00263 }; 00264 00265 } //end namespace ito 00266 00267 #endif