annotate gui/src/FileEditorMdiSubWindow.h @ 13584:e76a22bfe406

editor: added bookmark feature
author ttl <ttl@justmail.de>
date Tue, 02 Aug 2011 22:57:31 +0200
parents a89aa9e05e19
children da69cec2459f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13504
13e3d60aff2d Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13503
diff changeset
1 /* OctaveGUI - A graphical user interface for Octave
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
2 * Copyright (C) 2011 Jacob Dawid
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
3 * jacob.dawid@googlemail.com
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
4 *
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
8 * (at your option) any later version.
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
9 *
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
14 *
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
17 */
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
18
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
19 #ifndef FILEEDITORMDISUBWINDOW_H
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
20 #define FILEEDITORMDISUBWINDOW_H
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
21
13562
a89aa9e05e19 editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents: 13558
diff changeset
22 #include "OctaveTerminal.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
23 #include <QMdiSubWindow>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
24 #include <QToolBar>
13584
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
25 #include <QAction>
13562
a89aa9e05e19 editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents: 13558
diff changeset
26 #include <QMenuBar>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
27 #include <QStatusBar>
13524
8c143d6d0330 gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents: 13506
diff changeset
28 #include <QCloseEvent>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
29 #include <Qsci/qsciscintilla.h>
13503
5ab40ef3d241 Merged diff from Torsten.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
30 // Not available in the Debian repos yet!
5ab40ef3d241 Merged diff from Torsten.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
31 // #include <Qsci/qscilexeroctave.h>
13558
248b897d9f36 editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents: 13557
diff changeset
32 #include "lexer/lexeroctavegui.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
33
13529
8e87f3ba3beb gui-editor: enabled 'Save File As'
ttl <ttl@justmail.de>
parents: 13524
diff changeset
34 const char UNNAMED_FILE[] = "<unnamed>";
8e87f3ba3beb gui-editor: enabled 'Save File As'
ttl <ttl@justmail.de>
parents: 13524
diff changeset
35 const char SAVE_FILE_FILTER[] = "Octave Files *.m(*.m);;All Files *.*(*.*)";
13584
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
36 enum MARKER
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
37 {
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
38 MARKER_BOOKMARK,
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
39 MARKER_BREAKPOINT
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
40 };
13529
8e87f3ba3beb gui-editor: enabled 'Save File As'
ttl <ttl@justmail.de>
parents: 13524
diff changeset
41
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
42 class FileEditorMdiSubWindow:public QMdiSubWindow
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
43 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
44 Q_OBJECT public:
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
45 FileEditorMdiSubWindow (QWidget * parent = 0);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
46 ~FileEditorMdiSubWindow ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
47 void loadFile (QString fileName);
13562
a89aa9e05e19 editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents: 13558
diff changeset
48 void initEditor (OctaveTerminal *terminal, LexerOctaveGui *lexer);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
49
13558
248b897d9f36 editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents: 13557
diff changeset
50 public slots:
13524
8c143d6d0330 gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents: 13506
diff changeset
51
8c143d6d0330 gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents: 13506
diff changeset
52 void newFile ();
13530
8c7390b78911 gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents: 13529
diff changeset
53 void openFile ();
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
54 void saveFile ();
13529
8e87f3ba3beb gui-editor: enabled 'Save File As'
ttl <ttl@justmail.de>
parents: 13524
diff changeset
55 void saveFile (QString fileName);
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
56 void saveFileAs ();
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
57
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
58 void showToolTipNew ();
13530
8c7390b78911 gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents: 13529
diff changeset
59 void showToolTipOpen ();
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
60 void showToolTipSave ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
61 void showToolTipSaveAs ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
62 void showToolTipUndo ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
63 void showToolTipRedo ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
64 void registerModified (bool modified);
13524
8c143d6d0330 gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents: 13506
diff changeset
65
8c143d6d0330 gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents: 13506
diff changeset
66 protected:
8c143d6d0330 gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents: 13506
diff changeset
67 void closeEvent(QCloseEvent *event);
8c143d6d0330 gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents: 13506
diff changeset
68
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
69 private:
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
70 int checkFileModified (QString msg);
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
71 void construct ();
13562
a89aa9e05e19 editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents: 13558
diff changeset
72 QMenuBar *m_menuBar;
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
73 QToolBar *m_toolBar;
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
74 QsciScintilla *m_editor;
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
75 QStatusBar *m_statusBar;
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
76 QString m_fileName;
13562
a89aa9e05e19 editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents: 13558
diff changeset
77 OctaveTerminal* m_octave;
13584
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
78 QAction* m_copyAction;
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
79 QAction* m_cutAction;
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
80 int m_markerBookmark;
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
81 bool m_modified;
13557
ad18a8e7fb02 editor: change window title if text is modified
ttl <ttl@justmail.de>
parents: 13530
diff changeset
82
ad18a8e7fb02 editor: change window title if text is modified
ttl <ttl@justmail.de>
parents: 13530
diff changeset
83 private slots:
ad18a8e7fb02 editor: change window title if text is modified
ttl <ttl@justmail.de>
parents: 13530
diff changeset
84 void handleModificationChanged(bool modified);
13584
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
85 void handleMarginClicked(int line, int margin, Qt::KeyboardModifiers state);
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
86 void handleCopyAvailable(bool enableCopy);
13562
a89aa9e05e19 editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents: 13558
diff changeset
87 void runFile();
13584
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
88 void toggleBookmark ();
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
89 void nextBookmark();
e76a22bfe406 editor: added bookmark feature
ttl <ttl@justmail.de>
parents: 13562
diff changeset
90 void prevBookmark();
13557
ad18a8e7fb02 editor: change window title if text is modified
ttl <ttl@justmail.de>
parents: 13530
diff changeset
91
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
92 };
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
93
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
94 #endif // FILEEDITORMDISUBWINDOW_H