GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
file-editor.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2013 Jacob Dawid
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifndef FILEEDITORMDISUBWINDOW_H
24 #define FILEEDITORMDISUBWINDOW_H
25 
26 #include <QToolBar>
27 #include <QAction>
28 #include <QMenuBar>
29 #include <QStatusBar>
30 #include <QCloseEvent>
31 #include <QTabWidget>
32 
33 #include <map>
34 
35 #include "file-editor-interface.h"
36 #include "file-editor-tab.h"
37 
39 {
40  Q_OBJECT
41 
42 public:
43 
44  typedef std::map<QString, QWidget *>::iterator editor_tab_map_iterator;
45  typedef std::map<QString, QWidget *>::const_iterator editor_tab_map_const_iterator;
46 
47  file_editor (QWidget *p);
48  ~file_editor (void);
49 
50  void loadFile (const QString& fileName);
51 
52  QMenu *get_mru_menu (void) { return _mru_file_menu; }
53  QMenu *debug_menu (void);
54  QToolBar *toolbar (void);
55 
56  void set_focus (void);
57  void handle_enter_debug_mode (void);
58  void handle_exit_debug_mode (void);
59 
60  void check_actions (void);
61 signals:
62 
63  void fetab_settings_changed (const QSettings *settings);
64  void fetab_close_request (const QWidget* ID, bool app_closing = false);
65  void fetab_change_request (const QWidget* ID);
66  void fetab_file_name_query (const QWidget* ID);
67  // Save is a ping-pong type of communication
68  void fetab_save_file (const QWidget* ID, const QString& fileName,
69  bool remove_on_success);
70  // No fetab_open, functionality in editor
71  // No fetab_new, functionality in editor
72  void fetab_undo (const QWidget* ID);
73  void fetab_redo (const QWidget* ID);
74  void fetab_copy (const QWidget* ID);
75  void fetab_cut (const QWidget* ID);
76  void fetab_paste (const QWidget* ID);
77  void fetab_context_help (const QWidget* ID, bool);
78  void fetab_context_edit (const QWidget* ID);
79  void fetab_save_file (const QWidget* ID);
80  void fetab_save_file_as (const QWidget* ID);
81  void fetab_print_file (const QWidget* ID);
82  void fetab_run_file (const QWidget* ID);
83  void fetab_context_run (const QWidget* ID);
84  void fetab_toggle_bookmark (const QWidget* ID);
85  void fetab_next_bookmark (const QWidget* ID);
86  void fetab_previous_bookmark (const QWidget* ID);
87  void fetab_remove_bookmark (const QWidget* ID);
88  void fetab_toggle_breakpoint (const QWidget* ID);
89  void fetab_next_breakpoint (const QWidget* ID);
90  void fetab_previous_breakpoint (const QWidget* ID);
91  void fetab_remove_all_breakpoints (const QWidget* ID);
92  void fetab_comment_selected_text (const QWidget* ID);
93  void fetab_uncomment_selected_text (const QWidget* ID);
94  void fetab_find (const QWidget* ID);
95  void fetab_goto_line (const QWidget* ID, int line = -1);
96  void fetab_insert_debugger_pointer (const QWidget* ID, int line = -1);
97  void fetab_delete_debugger_pointer (const QWidget* ID, int line = -1);
98  void fetab_do_breakpoint_marker (bool insert, const QWidget* ID,
99  int line = -1);
100  void fetab_set_focus (const QWidget* ID);
101  void request_settings_dialog (const QString&);
102  void execute_command_in_terminal_signal (const QString&);
103  void file_loaded_signal ();
104 
105 public slots:
106  void focus (void);
107 
108  void request_new_file (const QString& commands);
109  void request_new_script (const QString& commands);
110  void request_new_function (bool triggered = true);
111  void request_open_file (void);
112  void request_close_file (bool);
113  void request_close_all_files (bool);
114  void request_close_other_files (bool);
115  void request_mru_open_file (QAction *action);
116  void request_print_file (void);
117 
118  void request_undo (void);
119  void request_redo (void);
120  void request_copy (void);
121  void request_cut (void);
122  void request_paste (void);
123  void request_context_help (bool);
124  void request_context_doc (bool);
125  void request_context_edit (bool);
126  void request_save_file (void);
127  void request_save_file_as (void);
128  void request_run_file (void);
129  void request_context_run (bool);
130  void request_toggle_bookmark (void);
131  void request_next_bookmark (void);
132  void request_previous_bookmark (void);
133  void request_remove_bookmark (void);
134 
135  void request_toggle_breakpoint (void);
136  void request_next_breakpoint (void);
137  void request_previous_breakpoint (void);
138  void request_remove_breakpoint (void);
139 
140  void request_comment_selected_text (void);
142  void request_find (void);
143 
144  void request_goto_line (void);
145 
146  void handle_file_name_changed (const QString& fileName,
147  const QString& toolTip);
148  void handle_tab_close_request (int index);
149  void handle_tab_remove_request (void);
150  void handle_add_filename_to_list (const QString& fileName, QWidget *ID);
151  void active_tab_changed (int index);
152  void handle_editor_state_changed (bool enableCopy, const QString& fileName);
153  void handle_mru_add_file (const QString& file_name);
154  void check_conflict_save (const QString& fileName, bool remove_on_success);
155 
156  void handle_insert_debugger_pointer_request (const QString& file, int line);
157  void handle_delete_debugger_pointer_request (const QString& file, int line);
158  void handle_update_breakpoint_marker_request (bool insert,
159  const QString& file, int line);
160 
161  void handle_edit_file_request (const QString& file);
162 
163  // Tells the editor to react on changed settings.
164  void notice_settings (const QSettings *settings);
165 
166  // Tells the ditor to dis- or enable some shortcuts
167  void set_shortcuts (bool set_shortcuts);
168 
169 
170 protected slots:
171  void copyClipboard ();
172  void pasteClipboard ();
173 
174 private slots:
175 
176  void request_open_file (const QString& fileName, int line = -1,
177  bool debug_pointer = false,
178  bool breakpoint_marker = false, bool insert = true);
179  void request_preferences (bool);
180  void request_styles_preferences (bool);
182 
183 private:
184 
185  void construct (void);
186  void add_file_editor_tab (file_editor_tab *f, const QString& fn);
187  void save_file_as (QWidget *fetabID = 0);
188  void mru_menu_update (void);
189  bool call_custom_editor (const QString& file_name = QString (), int line = -1);
190 
191  QWidget *find_tab_widget (const QString& openFileName) const;
192 
193  std::map<QString, QWidget *> editor_tab_map;
194 
195  QString ced;
196 
197  QMenuBar *_menu_bar;
198  QToolBar *_tool_bar;
199  QMenu *_debug_menu;
200 
203 
204  QAction *_copy_action;
205  QAction *_cut_action;
206  QAction *_paste_action;
209 
210  QAction *_find_action;
212 
217 
218  QAction *_print_action;
219  QAction *_run_action;
221 
223  QAction *_save_action;
224  QAction *_save_as_action;
225  QAction *_close_action;
228 
229  QAction *_redo_action;
230  QAction *_undo_action;
231 
234 
235  QTabWidget *_tab_widget;
236 
238 
239  enum { MaxMRUFiles = 10 };
242  QStringList _mru_files;
243 
244 };
245 
246 #endif // FILEEDITORMDISUBWINDOW_H