File: | libgui/src/m-editor/file-editor.cc |
Location: | line 753, column 15 |
Description: | Attempt to free released memory |
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 | #ifdef HAVE_CONFIG_H1 | |||
24 | #include <config.h> | |||
25 | #endif | |||
26 | ||||
27 | #ifdef HAVE_QSCINTILLA1 | |||
28 | ||||
29 | #include "file-editor.h" | |||
30 | #include "resource-manager.h" | |||
31 | #include <QVBoxLayout> | |||
32 | #include <QApplication> | |||
33 | #include <QFile> | |||
34 | #include <QFont> | |||
35 | #include <QFileDialog> | |||
36 | #include <QMessageBox> | |||
37 | #include <QStyle> | |||
38 | #include <QTextStream> | |||
39 | #include <QProcess> | |||
40 | ||||
41 | #include "octave-link.h" | |||
42 | #include "utils.h" | |||
43 | ||||
44 | file_editor::file_editor (QWidget *p) | |||
45 | : file_editor_interface (p) | |||
46 | { | |||
47 | // Set current editing directory before construct because loaded | |||
48 | // files will change ced accordingly. | |||
49 | ced = QDir::currentPath (); | |||
50 | ||||
51 | construct (); | |||
52 | ||||
53 | setVisible (false); | |||
54 | } | |||
55 | ||||
56 | file_editor::~file_editor (void) | |||
57 | { | |||
58 | QSettings *settings = resource_manager::get_settings (); | |||
59 | ||||
60 | // Have all file editor tabs signal what their file names are. | |||
61 | editor_tab_map.clear (); | |||
62 | emit fetab_file_name_query (0); | |||
63 | ||||
64 | // save file names (even if last session will not be restored next time) | |||
65 | QStringList fetFileNames; | |||
66 | for (editor_tab_map_const_iterator p = editor_tab_map.begin (); | |||
67 | p != editor_tab_map.end (); p++) | |||
68 | { | |||
69 | QString file_name = p->first; | |||
70 | if (!file_name.isEmpty () && file_name.at (file_name.size () - 1) != '/') | |||
71 | fetFileNames.append (p->first); // do not append unnamed files | |||
72 | } | |||
73 | ||||
74 | settings->setValue ("editor/savedSessionTabs", fetFileNames); | |||
75 | settings->sync (); | |||
76 | ||||
77 | for (int index = _tab_widget->count ()-1; index >= 0; index--) | |||
78 | { | |||
79 | // true: app closing | |||
80 | emit fetab_close_request (_tab_widget->widget (index), true); | |||
81 | } | |||
82 | ||||
83 | if (_mru_file_menu) | |||
84 | delete _mru_file_menu; | |||
85 | } | |||
86 | ||||
87 | void | |||
88 | file_editor::focus (void) | |||
89 | { | |||
90 | set_focus (); | |||
91 | } | |||
92 | ||||
93 | // set focus to editor and its current tab | |||
94 | void | |||
95 | file_editor::set_focus (void) | |||
96 | { | |||
97 | if (!isVisible ()) | |||
98 | setVisible (true); | |||
99 | setFocus (); | |||
100 | activateWindow (); | |||
101 | raise (); | |||
102 | QWidget *fileEditorTab = _tab_widget->currentWidget (); | |||
103 | if (fileEditorTab) | |||
104 | emit fetab_set_focus (fileEditorTab); | |||
105 | } | |||
106 | ||||
107 | QMenu * | |||
108 | file_editor::debug_menu (void) | |||
109 | { | |||
110 | return _debug_menu; | |||
111 | } | |||
112 | ||||
113 | QToolBar * | |||
114 | file_editor::toolbar (void) | |||
115 | { | |||
116 | return _tool_bar; | |||
117 | } | |||
118 | ||||
119 | void | |||
120 | file_editor::handle_enter_debug_mode (void) | |||
121 | { | |||
122 | _run_action->setEnabled (false); | |||
123 | } | |||
124 | ||||
125 | void | |||
126 | file_editor::handle_exit_debug_mode (void) | |||
127 | { | |||
128 | _run_action->setEnabled (true); | |||
129 | } | |||
130 | ||||
131 | void | |||
132 | file_editor::request_new_file (const QString& commands) | |||
133 | { | |||
134 | // New file isn't a file_editor_tab function since the file | |||
135 | // editor tab has yet to be created and there is no object to | |||
136 | // pass a signal to. Hence, functionality is here. | |||
137 | ||||
138 | file_editor_tab *fileEditorTab = new file_editor_tab (ced); | |||
139 | if (fileEditorTab) | |||
140 | { | |||
141 | add_file_editor_tab (fileEditorTab, ""); // new tab with empty title | |||
142 | fileEditorTab->new_file (commands); // title is updated here | |||
143 | set_focus (); // focus editor and new tab | |||
144 | } | |||
145 | } | |||
146 | ||||
147 | void | |||
148 | file_editor::request_new_script (const QString& commands) | |||
149 | { | |||
150 | request_new_file (commands); | |||
151 | } | |||
152 | ||||
153 | void | |||
154 | file_editor::request_new_function (const QString& commands) | |||
155 | { | |||
156 | QString text = commands; | |||
157 | ||||
158 | if (text.isEmpty ()) | |||
159 | text = "## Copyright (C)\n" | |||
160 | "\n" | |||
161 | "## -*- texinfo -*-\n" | |||
162 | "## @deftypefn {Function File} {[outputs] =} unamed_function (inputs)\n" | |||
163 | "## @end deftypefn\n" | |||
164 | "\n" | |||
165 | "function [outputs] = unnamed_function (inputs)\n" | |||
166 | "\n" | |||
167 | "endfunction\n"; | |||
168 | ||||
169 | request_new_file (text); | |||
170 | } | |||
171 | ||||
172 | void | |||
173 | file_editor::request_open_file (void) | |||
174 | { | |||
175 | // Open file isn't a file_editor_tab function since the file | |||
176 | // editor tab has yet to be created and there is no object to | |||
177 | // pass a signal to. Hence, functionality is here. | |||
178 | ||||
179 | // Create a NonModal message. | |||
180 | QFileDialog *fileDialog = new QFileDialog (this); | |||
181 | fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)")); | |||
182 | ||||
183 | // Giving trouble under KDE (problem is related to Qt signal handling on unix, | |||
184 | // see https://bugs.kde.org/show_bug.cgi?id=260719 , | |||
185 | // it had/has no effect on Windows, though) | |||
186 | fileDialog->setOption(QFileDialog::DontUseNativeDialog, true); | |||
187 | ||||
188 | fileDialog->setAcceptMode (QFileDialog::AcceptOpen); | |||
189 | fileDialog->setViewMode (QFileDialog::Detail); | |||
190 | fileDialog->setDirectory (ced); | |||
191 | ||||
192 | connect (fileDialog, SIGNAL (fileSelected (const QString&))qFlagLocation("2""fileSelected (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "192"), | |||
193 | this, SLOT (request_open_file (const QString&))qFlagLocation("1""request_open_file (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "193")); | |||
194 | ||||
195 | fileDialog->setWindowModality (Qt::NonModal); | |||
196 | fileDialog->setAttribute (Qt::WA_DeleteOnClose); | |||
197 | fileDialog->show (); | |||
198 | } | |||
199 | ||||
200 | // Check whether this file is already open in the editor. | |||
201 | QWidget * | |||
202 | file_editor::find_tab_widget (const QString& file) const | |||
203 | { | |||
204 | QWidget *retval = 0; | |||
205 | ||||
206 | for (editor_tab_map_const_iterator p = editor_tab_map.begin (); | |||
207 | p != editor_tab_map.end (); p++) | |||
208 | { | |||
209 | QString tab_file = p->first; | |||
210 | ||||
211 | if (same_file (file.toStdString (), tab_file.toStdString ())) | |||
212 | { | |||
213 | retval = p->second; | |||
214 | break; | |||
215 | } | |||
216 | } | |||
217 | ||||
218 | return retval; | |||
219 | } | |||
220 | ||||
221 | void | |||
222 | file_editor::request_open_file (const QString& openFileName, int line, | |||
223 | bool debug_pointer, | |||
224 | bool breakpoint_marker, bool insert) | |||
225 | { | |||
226 | // Check if the user wants to use a custom file editor. | |||
227 | QSettings *settings = resource_manager::get_settings (); | |||
228 | if (settings->value ("useCustomFileEditor").toBool ()) | |||
229 | { | |||
230 | QString editor = settings->value ("customFileEditor").toString (); | |||
231 | editor.replace ("%f", openFileName); | |||
232 | editor.replace ("%l", QString::number (line)); | |||
233 | QProcess::startDetached (editor); | |||
234 | if (line < 0) | |||
235 | handle_mru_add_file (QDir::cleanPath (openFileName)); | |||
236 | return; | |||
237 | } | |||
238 | ||||
239 | if (openFileName.isEmpty ()) | |||
240 | { | |||
241 | // ?? Not sure this will happen. This routine isn't even called | |||
242 | // if the user hasn't selected a file. | |||
243 | } | |||
244 | else | |||
245 | { | |||
246 | // Have all file editor tabs signal what their file names are. | |||
247 | editor_tab_map.clear (); | |||
248 | emit fetab_file_name_query (0); | |||
249 | ||||
250 | // Check whether this file is already open in the editor. | |||
251 | QWidget *tab = find_tab_widget (openFileName); | |||
252 | ||||
253 | if (tab) | |||
254 | { | |||
255 | _tab_widget->setCurrentWidget (tab); | |||
256 | ||||
257 | if (line > 0) | |||
258 | { | |||
259 | emit fetab_goto_line (tab, line); | |||
260 | ||||
261 | if (debug_pointer) | |||
262 | emit fetab_insert_debugger_pointer (tab, line); | |||
263 | ||||
264 | if (breakpoint_marker) | |||
265 | emit fetab_do_breakpoint_marker (insert, tab, line); | |||
266 | } | |||
267 | ||||
268 | emit fetab_set_focus (tab); | |||
269 | } | |||
270 | else | |||
271 | { | |||
272 | file_editor_tab *fileEditorTab = new file_editor_tab (); | |||
273 | if (fileEditorTab) | |||
274 | { | |||
275 | QString result = fileEditorTab->load_file (openFileName); | |||
276 | if (result == "") | |||
277 | { | |||
278 | // Supply empty title then have the file_editor_tab update | |||
279 | // with full or short name. | |||
280 | add_file_editor_tab (fileEditorTab, ""); | |||
281 | fileEditorTab->update_window_title (false); | |||
282 | // file already loaded, add file to mru list here | |||
283 | QFileInfo file_info = QFileInfo (openFileName); | |||
284 | handle_mru_add_file (file_info.canonicalFilePath ()); | |||
285 | ||||
286 | if (line > 0) | |||
287 | { | |||
288 | emit fetab_goto_line (fileEditorTab, line); | |||
289 | ||||
290 | if (debug_pointer) | |||
291 | emit fetab_insert_debugger_pointer (fileEditorTab, | |||
292 | line); | |||
293 | if (breakpoint_marker) | |||
294 | emit fetab_do_breakpoint_marker (insert, fileEditorTab, | |||
295 | line); | |||
296 | } | |||
297 | } | |||
298 | else | |||
299 | { | |||
300 | delete fileEditorTab; | |||
301 | ||||
302 | if (QFile::exists (openFileName)) | |||
303 | { | |||
304 | // File not readable: | |||
305 | // create a NonModal message about error. | |||
306 | QMessageBox *msgBox | |||
307 | = new QMessageBox (QMessageBox::Critical, | |||
308 | tr ("Octave Editor"), | |||
309 | tr ("Could not open file\n%1\nfor read: %2."). | |||
310 | arg (openFileName).arg (result), | |||
311 | QMessageBox::Ok, this); | |||
312 | ||||
313 | msgBox->setWindowModality (Qt::NonModal); | |||
314 | msgBox->setAttribute (Qt::WA_DeleteOnClose); | |||
315 | msgBox->show (); | |||
316 | } | |||
317 | else | |||
318 | { | |||
319 | // File does not exist, should it be crated? | |||
320 | QMessageBox *msgBox; | |||
321 | int answer; | |||
322 | if (settings->value ("editor/create_new_file", | |||
323 | false).toBool ()) | |||
324 | { | |||
325 | answer = QMessageBox::Yes; | |||
326 | } | |||
327 | else | |||
328 | { | |||
329 | msgBox = new QMessageBox (QMessageBox::Question, | |||
330 | tr ("Octave Editor"), | |||
331 | tr ("File\n%1\ndoes not exist. " | |||
332 | "Do you want to create it?").arg (openFileName), | |||
333 | QMessageBox::Yes | |||
334 | | QMessageBox::No, this); | |||
335 | ||||
336 | msgBox->setAttribute (Qt::WA_DeleteOnClose); | |||
337 | answer = msgBox->exec (); | |||
338 | } | |||
339 | ||||
340 | if (answer == QMessageBox::Yes) | |||
341 | { | |||
342 | // create the file and call the editor again | |||
343 | QFile file (openFileName); | |||
344 | if (!file.open (QIODevice::WriteOnly)) | |||
345 | { | |||
346 | // error opening the file | |||
347 | msgBox = new QMessageBox (QMessageBox::Critical, | |||
348 | tr ("Octave Editor"), | |||
349 | tr ("Could not open file\n%1\nfor write: %2."). | |||
350 | arg (openFileName).arg (file.errorString ()), | |||
351 | QMessageBox::Ok, this); | |||
352 | ||||
353 | msgBox->setWindowModality (Qt::NonModal); | |||
354 | msgBox->setAttribute (Qt::WA_DeleteOnClose); | |||
355 | msgBox->show (); | |||
356 | } | |||
357 | else | |||
358 | { | |||
359 | file.close (); | |||
360 | request_open_file (openFileName); | |||
361 | } | |||
362 | } | |||
363 | } | |||
364 | } | |||
365 | } | |||
366 | ||||
367 | // really show editor and the current editor tab | |||
368 | set_focus (); | |||
369 | } | |||
370 | } | |||
371 | } | |||
372 | ||||
373 | // open a file from the mru list | |||
374 | void | |||
375 | file_editor::request_mru_open_file (QAction *action) | |||
376 | { | |||
377 | if (action) | |||
378 | { | |||
379 | request_open_file (action->data ().toString ()); | |||
380 | } | |||
381 | } | |||
382 | ||||
383 | ||||
384 | void | |||
385 | file_editor::check_conflict_save (const QString& saveFileName, | |||
386 | bool remove_on_success) | |||
387 | { | |||
388 | // Have all file editor tabs signal what their file names are. | |||
389 | editor_tab_map.clear (); | |||
390 | emit fetab_file_name_query (0); | |||
391 | ||||
392 | // Check whether this file is already open in the editor. | |||
393 | QWidget *tab = find_tab_widget (saveFileName); | |||
394 | ||||
395 | if (tab) | |||
396 | { | |||
397 | // Note: to overwrite the contents of some other file editor tab | |||
398 | // with the same name requires identifying which file editor tab | |||
399 | // that is (not too difficult) then close that tab. Of course, | |||
400 | // that could trigger another dialog box if the file editor tab | |||
401 | // with the same name has modifications in it. This could become | |||
402 | // somewhat confusing to the user. For now, opt to do nothing. | |||
403 | ||||
404 | // Create a NonModal message about error. | |||
405 | QMessageBox *msgBox | |||
406 | = new QMessageBox (QMessageBox::Critical, tr ("Octave Editor"), | |||
407 | tr ("File not saved! A file with the selected name\n%1\n" | |||
408 | "is already open in the editor"). | |||
409 | arg (saveFileName), | |||
410 | QMessageBox::Ok, 0); | |||
411 | ||||
412 | msgBox->setWindowModality (Qt::NonModal); | |||
413 | msgBox->setAttribute (Qt::WA_DeleteOnClose); | |||
414 | msgBox->show (); | |||
415 | ||||
416 | return; | |||
417 | } | |||
418 | ||||
419 | QObject *saveFileObject = sender (); | |||
420 | QWidget *saveFileWidget = 0; | |||
421 | ||||
422 | for (int i = 0; i < _tab_widget->count (); i++) | |||
423 | { | |||
424 | if (_tab_widget->widget (i) == saveFileObject) | |||
425 | { | |||
426 | saveFileWidget = _tab_widget->widget (i); | |||
427 | break; | |||
428 | } | |||
429 | } | |||
430 | if (!saveFileWidget) | |||
431 | { | |||
432 | // Create a NonModal message about error. | |||
433 | QMessageBox *msgBox | |||
434 | = new QMessageBox (QMessageBox::Critical, tr ("Octave Editor"), | |||
435 | tr ("The associated file editor tab has disappeared. It was likely closed by some means."), | |||
436 | QMessageBox::Ok, 0); | |||
437 | ||||
438 | msgBox->setWindowModality (Qt::NonModal); | |||
439 | msgBox->setAttribute (Qt::WA_DeleteOnClose); | |||
440 | msgBox->show (); | |||
441 | ||||
442 | return; | |||
443 | } | |||
444 | ||||
445 | // Can save without conflict, have the file editor tab do so. | |||
446 | emit fetab_save_file (saveFileWidget, saveFileName, remove_on_success); | |||
447 | } | |||
448 | ||||
449 | void | |||
450 | file_editor::handle_insert_debugger_pointer_request (const QString& file, | |||
451 | int line) | |||
452 | { | |||
453 | request_open_file (file, line, true); | |||
454 | } | |||
455 | ||||
456 | void | |||
457 | file_editor::handle_delete_debugger_pointer_request (const QString& file, | |||
458 | int line) | |||
459 | { | |||
460 | if (! file.isEmpty ()) | |||
461 | { | |||
462 | // Have all file editor tabs signal what their file names are. | |||
463 | editor_tab_map.clear (); | |||
464 | emit fetab_file_name_query (0); | |||
465 | ||||
466 | // Check whether this file is already open in the editor. | |||
467 | QWidget *tab = find_tab_widget (file); | |||
468 | ||||
469 | if (tab) | |||
470 | { | |||
471 | _tab_widget->setCurrentWidget (tab); | |||
472 | ||||
473 | if (line > 0) | |||
474 | emit fetab_delete_debugger_pointer (tab, line); | |||
475 | ||||
476 | emit fetab_set_focus (tab); | |||
477 | } | |||
478 | } | |||
479 | } | |||
480 | ||||
481 | void | |||
482 | file_editor::handle_update_breakpoint_marker_request (bool insert, | |||
483 | const QString& file, | |||
484 | int line) | |||
485 | { | |||
486 | request_open_file (file, line, false, true, insert); | |||
487 | } | |||
488 | ||||
489 | void | |||
490 | file_editor::handle_edit_file_request (const QString& file) | |||
491 | { | |||
492 | request_open_file (file); | |||
493 | set_focus (); | |||
494 | } | |||
495 | ||||
496 | void | |||
497 | file_editor::request_undo (void) | |||
498 | { | |||
499 | emit fetab_undo (_tab_widget->currentWidget ()); | |||
500 | } | |||
501 | ||||
502 | void | |||
503 | file_editor::request_redo (void) | |||
504 | { | |||
505 | emit fetab_redo (_tab_widget->currentWidget ()); | |||
506 | } | |||
507 | ||||
508 | void | |||
509 | file_editor::request_copy (void) | |||
510 | { | |||
511 | emit fetab_copy (_tab_widget->currentWidget ()); | |||
512 | } | |||
513 | ||||
514 | void | |||
515 | file_editor::request_cut (void) | |||
516 | { | |||
517 | emit fetab_cut (_tab_widget->currentWidget ()); | |||
518 | } | |||
519 | ||||
520 | void | |||
521 | file_editor::request_paste (void) | |||
522 | { | |||
523 | emit fetab_paste (_tab_widget->currentWidget ()); | |||
524 | } | |||
525 | ||||
526 | void | |||
527 | file_editor::request_context_help (bool) | |||
528 | { | |||
529 | emit fetab_context_help (_tab_widget->currentWidget (), false); | |||
530 | } | |||
531 | void | |||
532 | file_editor::request_context_doc (bool) | |||
533 | { | |||
534 | emit fetab_context_help (_tab_widget->currentWidget (), true); | |||
535 | } | |||
536 | ||||
537 | void | |||
538 | file_editor::request_context_edit (bool) | |||
539 | { | |||
540 | emit fetab_context_edit (_tab_widget->currentWidget ()); | |||
541 | } | |||
542 | ||||
543 | void | |||
544 | file_editor::request_save_file (void) | |||
545 | { | |||
546 | emit fetab_save_file (_tab_widget->currentWidget ()); | |||
547 | } | |||
548 | ||||
549 | void | |||
550 | file_editor::request_save_file_as (void) | |||
551 | { | |||
552 | emit fetab_save_file_as (_tab_widget->currentWidget ()); | |||
553 | } | |||
554 | ||||
555 | void | |||
556 | file_editor::request_print_file (void) | |||
557 | { | |||
558 | emit fetab_print_file (_tab_widget->currentWidget ()); | |||
559 | } | |||
560 | ||||
561 | ||||
562 | void | |||
563 | file_editor::request_run_file (void) | |||
564 | { | |||
565 | emit fetab_run_file (_tab_widget->currentWidget ()); | |||
566 | } | |||
567 | ||||
568 | void | |||
569 | file_editor::request_context_run (bool) | |||
570 | { | |||
571 | emit fetab_context_run (_tab_widget->currentWidget ()); | |||
572 | } | |||
573 | ||||
574 | void | |||
575 | file_editor::request_toggle_bookmark (void) | |||
576 | { | |||
577 | emit fetab_toggle_bookmark (_tab_widget->currentWidget ()); | |||
578 | } | |||
579 | ||||
580 | void | |||
581 | file_editor::request_next_bookmark (void) | |||
582 | { | |||
583 | emit fetab_next_bookmark (_tab_widget->currentWidget ()); | |||
584 | } | |||
585 | ||||
586 | void | |||
587 | file_editor::request_previous_bookmark (void) | |||
588 | { | |||
589 | emit fetab_previous_bookmark (_tab_widget->currentWidget ()); | |||
590 | } | |||
591 | ||||
592 | void | |||
593 | file_editor::request_remove_bookmark (void) | |||
594 | { | |||
595 | emit fetab_remove_bookmark (_tab_widget->currentWidget ()); | |||
596 | } | |||
597 | ||||
598 | void | |||
599 | file_editor::request_toggle_breakpoint (void) | |||
600 | { | |||
601 | emit fetab_toggle_breakpoint (_tab_widget->currentWidget ()); | |||
602 | } | |||
603 | ||||
604 | void | |||
605 | file_editor::request_next_breakpoint (void) | |||
606 | { | |||
607 | emit fetab_next_breakpoint (_tab_widget->currentWidget ()); | |||
608 | } | |||
609 | ||||
610 | void | |||
611 | file_editor::request_previous_breakpoint (void) | |||
612 | { | |||
613 | emit fetab_previous_breakpoint (_tab_widget->currentWidget ()); | |||
614 | } | |||
615 | ||||
616 | void | |||
617 | file_editor::request_remove_breakpoint (void) | |||
618 | { | |||
619 | emit fetab_remove_all_breakpoints (_tab_widget->currentWidget ()); | |||
620 | } | |||
621 | ||||
622 | void | |||
623 | file_editor::request_comment_selected_text (void) | |||
624 | { | |||
625 | emit fetab_comment_selected_text (_tab_widget->currentWidget ()); | |||
626 | } | |||
627 | ||||
628 | void | |||
629 | file_editor::request_uncomment_selected_text (void) | |||
630 | { | |||
631 | emit fetab_uncomment_selected_text (_tab_widget->currentWidget ()); | |||
632 | } | |||
633 | ||||
634 | void | |||
635 | file_editor::request_find (void) | |||
636 | { | |||
637 | emit fetab_find (_tab_widget->currentWidget ()); | |||
638 | } | |||
639 | ||||
640 | void | |||
641 | file_editor::request_goto_line (void) | |||
642 | { | |||
643 | emit fetab_goto_line (_tab_widget->currentWidget ()); | |||
644 | } | |||
645 | ||||
646 | ||||
647 | void | |||
648 | file_editor::handle_mru_add_file (const QString& file_name) | |||
649 | { | |||
650 | _mru_files.removeAll (file_name); | |||
651 | _mru_files.prepend (file_name); | |||
652 | mru_menu_update (); | |||
653 | } | |||
654 | ||||
655 | void | |||
656 | file_editor::mru_menu_update (void) | |||
657 | { | |||
658 | int num_files = qMin (_mru_files.size (), int (MaxMRUFiles)); | |||
659 | ||||
660 | // configure and show active actions of mru-menu | |||
661 | for (int i = 0; i < num_files; ++i) | |||
662 | { | |||
663 | QString text = tr ("&%1 %2"). | |||
664 | arg ((i+1) % int (MaxMRUFiles)).arg (_mru_files.at (i)); | |||
665 | _mru_file_actions[i]->setText (text); | |||
666 | _mru_file_actions[i]->setData (_mru_files.at (i)); | |||
667 | _mru_file_actions[i]->setVisible (true); | |||
668 | } | |||
669 | ||||
670 | // hide unused mru-menu entries | |||
671 | for (int j = num_files; j < MaxMRUFiles; ++j) | |||
672 | _mru_file_actions[j]->setVisible (false); | |||
673 | ||||
674 | // delete entries in string-list beyond MaxMRUFiles | |||
675 | while (_mru_files.size () > MaxMRUFiles) | |||
676 | _mru_files.removeLast (); | |||
677 | ||||
678 | // save actual mru-list in settings | |||
679 | QSettings *settings = resource_manager::get_settings (); | |||
680 | ||||
681 | // FIXME: what should happen if settings is 0? | |||
682 | settings->setValue ("editor/mru_file_list", _mru_files); | |||
683 | settings->sync (); | |||
684 | } | |||
685 | ||||
686 | void | |||
687 | file_editor::handle_file_name_changed (const QString& fname, | |||
688 | const QString& tip) | |||
689 | { | |||
690 | QObject *fileEditorTab = sender (); | |||
691 | if (fileEditorTab) | |||
692 | { | |||
693 | for (int i = 0; i < _tab_widget->count (); i++) | |||
694 | { | |||
695 | if (_tab_widget->widget (i) == fileEditorTab) | |||
696 | { | |||
697 | _tab_widget->setTabText (i, fname); | |||
698 | _tab_widget->setTabToolTip (i, tip); | |||
699 | } | |||
700 | } | |||
701 | } | |||
702 | } | |||
703 | ||||
704 | void | |||
705 | file_editor::request_close_file (bool) | |||
706 | { | |||
707 | emit fetab_close_request (_tab_widget->currentWidget ()); | |||
708 | } | |||
709 | ||||
710 | void | |||
711 | file_editor::request_close_all_files (bool) | |||
712 | { | |||
713 | // loop over all tabs starting from last one otherwise deletion changes index | |||
714 | for (int index = _tab_widget->count ()-1; index >= 0; index--) | |||
715 | emit fetab_close_request (_tab_widget->widget (index)); | |||
716 | } | |||
717 | ||||
718 | void | |||
719 | file_editor::request_close_other_files (bool) | |||
720 | { | |||
721 | QWidget *tabID = _tab_widget->currentWidget (); | |||
722 | // loop over all tabs starting from last one otherwise deletion changes index | |||
723 | for (int index = _tab_widget->count ()-1; index >= 0; index--) | |||
724 | { | |||
725 | if (tabID != _tab_widget->widget (index)) | |||
726 | emit fetab_close_request (_tab_widget->widget (index)); | |||
727 | } | |||
728 | } | |||
729 | ||||
730 | ||||
731 | void | |||
732 | file_editor::handle_tab_close_request (int index) | |||
733 | { | |||
734 | // Signal to the tabs a request to close whomever matches the identifying | |||
735 | // tag (i.e., unique widget pointer). The reason for this indirection is | |||
736 | // that it will enable a file editor widget to toss up a non-static | |||
737 | // dialog box and later signal that it wants to be removed. | |||
738 | QWidget *tabID = _tab_widget->widget (index); | |||
739 | emit fetab_close_request (tabID); | |||
740 | } | |||
741 | ||||
742 | void | |||
743 | file_editor::handle_tab_remove_request (void) | |||
744 | { | |||
745 | QObject *fileEditorTab = sender (); | |||
746 | if (fileEditorTab) | |||
| ||||
747 | { | |||
748 | for (int i = 0; i < _tab_widget->count (); i++) | |||
749 | { | |||
750 | if (_tab_widget->widget (i) == fileEditorTab) | |||
751 | { | |||
752 | _tab_widget->removeTab (i); | |||
753 | delete fileEditorTab; | |||
| ||||
754 | } | |||
755 | } | |||
756 | } | |||
757 | check_actions (); | |||
758 | } | |||
759 | ||||
760 | void | |||
761 | file_editor::handle_add_filename_to_list (const QString& fileName, QWidget *ID) | |||
762 | { | |||
763 | // Should we allow multiple tabs for a single file? | |||
764 | ||||
765 | editor_tab_map[fileName] = ID; | |||
766 | } | |||
767 | ||||
768 | void | |||
769 | file_editor::active_tab_changed (int index) | |||
770 | { | |||
771 | emit fetab_change_request (_tab_widget->widget (index)); | |||
772 | } | |||
773 | ||||
774 | void | |||
775 | file_editor::handle_editor_state_changed (bool copy_available, | |||
776 | const QString& file_name) | |||
777 | { | |||
778 | // In case there is some scenario where traffic could be coming from | |||
779 | // all the file editor tabs, just process info from the current active tab. | |||
780 | if (sender () == _tab_widget->currentWidget ()) | |||
781 | { | |||
782 | _copy_action->setEnabled (copy_available); | |||
783 | _cut_action->setEnabled (copy_available); | |||
784 | _context_run_action->setEnabled (copy_available); | |||
785 | ||||
786 | if (!file_name.isEmpty ()) | |||
787 | { | |||
788 | ced = QDir::cleanPath (file_name); | |||
789 | int lastslash = ced.lastIndexOf ('/'); | |||
790 | ||||
791 | // Test against > 0 because if somehow the directory is "/" the | |||
792 | // slash should be retained. Otherwise, last slash is removed. | |||
793 | if (lastslash > 0 && lastslash != ced.count ()) | |||
794 | ced = ced.left (lastslash); | |||
795 | } | |||
796 | ||||
797 | setFocusProxy (_tab_widget->currentWidget ()); | |||
798 | } | |||
799 | } | |||
800 | ||||
801 | void | |||
802 | file_editor::notice_settings (const QSettings *settings) | |||
803 | { | |||
804 | int icon_size = settings->value ("toolbar_icon_size", 24).toInt (); | |||
805 | _tool_bar->setIconSize (QSize (icon_size, icon_size)); | |||
806 | // Relay signal to file editor tabs. | |||
807 | emit fetab_settings_changed (settings); | |||
808 | } | |||
809 | ||||
810 | void | |||
811 | file_editor::request_preferences (bool) | |||
812 | { | |||
813 | emit request_settings_dialog ("editor"); | |||
814 | } | |||
815 | ||||
816 | void | |||
817 | file_editor::request_styles_preferences (bool) | |||
818 | { | |||
819 | emit request_settings_dialog ("editor_styles"); | |||
820 | } | |||
821 | ||||
822 | void | |||
823 | file_editor::construct (void) | |||
824 | { | |||
825 | QWidget *editor_widget = new QWidget (this); | |||
826 | ||||
827 | // FIXME: what was the intended purpose of this unused variable? | |||
828 | // QStyle *editor_style = QApplication::style (); | |||
829 | ||||
830 | _menu_bar = new QMenuBar (editor_widget); | |||
831 | _tool_bar = new QToolBar (editor_widget); | |||
832 | _tab_widget = new QTabWidget (editor_widget); | |||
833 | _tab_widget->setTabsClosable (true); | |||
834 | ||||
835 | QAction *new_action = new QAction (QIcon (":/actions/icons/filenew.png"), | |||
836 | tr ("&New File"), _tool_bar); | |||
837 | ||||
838 | QAction *open_action = new QAction (QIcon (":/actions/icons/fileopen.png"), | |||
839 | tr ("&Open File"), _tool_bar); | |||
840 | ||||
841 | _save_action = new QAction (QIcon (":/actions/icons/filesave.png"), | |||
842 | tr ("&Save File"), _tool_bar); | |||
843 | ||||
844 | _save_as_action = new QAction (QIcon (":/actions/icons/filesaveas.png"), | |||
845 | tr ("Save File &As"), _tool_bar); | |||
846 | ||||
847 | _print_action = new QAction ( QIcon (":/actions/icons/fileprint.png"), | |||
848 | tr ("Print"), _tool_bar); | |||
849 | ||||
850 | _undo_action = new QAction (QIcon (":/actions/icons/undo.png"), | |||
851 | tr ("&Undo"), _tool_bar); | |||
852 | ||||
853 | _redo_action = new QAction (QIcon (":/actions/icons/redo.png"), | |||
854 | tr ("&Redo"), _tool_bar); | |||
855 | ||||
856 | _copy_action = new QAction (QIcon (":/actions/icons/editcopy.png"), | |||
857 | tr ("&Copy"), _tool_bar); | |||
858 | _copy_action->setEnabled (false); | |||
859 | ||||
860 | _cut_action = new QAction (QIcon (":/actions/icons/editcut.png"), | |||
861 | tr ("Cu&t"), _tool_bar); | |||
862 | _cut_action->setEnabled (false); | |||
863 | ||||
864 | _paste_action | |||
865 | = new QAction (QIcon (":/actions/icons/editpaste.png"), | |||
866 | tr ("Paste"), _tool_bar); | |||
867 | ||||
868 | _next_bookmark_action = new QAction (tr ("&Next Bookmark"), _tool_bar); | |||
869 | ||||
870 | _previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"), | |||
871 | _tool_bar); | |||
872 | ||||
873 | _toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"), _tool_bar); | |||
874 | ||||
875 | _remove_bookmark_action | |||
876 | = new QAction (tr ("&Remove All Bookmarks"), _tool_bar); | |||
877 | ||||
878 | QAction *next_breakpoint_action | |||
879 | = new QAction (QIcon (":/actions/icons/bp_next.png"), | |||
880 | tr ("&Next breakpoint"), _tool_bar); | |||
881 | QAction *previous_breakpoint_action | |||
882 | = new QAction (QIcon (":/actions/icons/bp_prev.png"), | |||
883 | tr ("Pre&vious breakpoint"), _tool_bar); | |||
884 | QAction *toggle_breakpoint_action | |||
885 | = new QAction (QIcon (":/actions/icons/bp_toggle.png"), | |||
886 | tr ("Toggle &breakpoint"), _tool_bar); | |||
887 | QAction *remove_all_breakpoints_action | |||
888 | = new QAction (QIcon (":/actions/icons/bp_rm_all.png"), | |||
889 | tr ("&Remove All breakpoints"), _tool_bar); | |||
890 | ||||
891 | _comment_selection_action | |||
892 | = new QAction (tr ("&Comment"), _tool_bar); | |||
893 | _uncomment_selection_action | |||
894 | = new QAction (tr ("&Uncomment"), _tool_bar); | |||
895 | ||||
896 | _find_action = new QAction (QIcon (":/actions/icons/search.png"), | |||
897 | tr ("&Find and Replace"), _tool_bar); | |||
898 | ||||
899 | _run_action = new QAction (QIcon (":/actions/icons/artsbuilderexecute.png"), | |||
900 | tr ("Save File And Run"), _tool_bar); | |||
901 | ||||
902 | _goto_line_action = new QAction (tr ("Go&to Line"), _tool_bar); | |||
903 | ||||
904 | // the mru-list and an empty array of actions | |||
905 | QSettings *settings = resource_manager::get_settings (); | |||
906 | // FIXME: what should happen if settings is 0? | |||
907 | _mru_files = settings->value ("editor/mru_file_list").toStringList (); | |||
908 | for (int i = 0; i < MaxMRUFiles; ++i) | |||
909 | { | |||
910 | _mru_file_actions[i] = new QAction (this); | |||
911 | _mru_file_actions[i]->setVisible (false); | |||
912 | } | |||
913 | ||||
914 | // some actions are disabled from the beginning | |||
915 | _copy_action->setEnabled (false); | |||
916 | _cut_action->setEnabled (false); | |||
917 | ||||
918 | _run_action->setShortcutContext (Qt::WindowShortcut); | |||
919 | _save_action->setShortcutContext (Qt::WindowShortcut); | |||
920 | _save_as_action->setShortcutContext (Qt::WindowShortcut); | |||
921 | ||||
922 | _print_action->setShortcutContext (Qt::WindowShortcut); | |||
923 | ||||
924 | _next_bookmark_action->setShortcutContext (Qt::WindowShortcut); | |||
925 | _previous_bookmark_action->setShortcutContext (Qt::WindowShortcut); | |||
926 | _toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); | |||
927 | _comment_selection_action->setShortcutContext (Qt::WindowShortcut); | |||
928 | _uncomment_selection_action->setShortcutContext (Qt::WindowShortcut); | |||
929 | _find_action->setShortcutContext (Qt::WindowShortcut); | |||
930 | _goto_line_action->setShortcutContext (Qt::WindowShortcut); | |||
931 | ||||
932 | // toolbar | |||
933 | _tool_bar->addAction (new_action); | |||
934 | _tool_bar->addAction (open_action); | |||
935 | _tool_bar->addAction (_save_action); | |||
936 | _tool_bar->addAction (_save_as_action); | |||
937 | _tool_bar->addSeparator (); | |||
938 | _tool_bar->addAction (_print_action); | |||
939 | _tool_bar->addSeparator (); | |||
940 | _tool_bar->addAction (_undo_action); | |||
941 | _tool_bar->addAction (_redo_action); | |||
942 | _tool_bar->addAction (_copy_action); | |||
943 | _tool_bar->addAction (_cut_action); | |||
944 | _tool_bar->addAction (_paste_action); | |||
945 | _tool_bar->addSeparator (); | |||
946 | _tool_bar->addAction (_find_action); | |||
947 | _tool_bar->addAction (_run_action); | |||
948 | _tool_bar->addSeparator (); | |||
949 | _tool_bar->addAction (toggle_breakpoint_action); | |||
950 | _tool_bar->addAction (next_breakpoint_action); | |||
951 | _tool_bar->addAction (previous_breakpoint_action); | |||
952 | _tool_bar->addAction (remove_all_breakpoints_action); | |||
953 | ||||
954 | // menu bar | |||
955 | QMenu *fileMenu = new QMenu (tr ("&File"), _menu_bar); | |||
956 | ||||
957 | _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), fileMenu); | |||
958 | for (int i = 0; i < MaxMRUFiles; ++i) | |||
959 | _mru_file_menu->addAction (_mru_file_actions[i]); | |||
960 | ||||
961 | fileMenu->addAction (new_action); | |||
962 | fileMenu->addAction (open_action); | |||
963 | fileMenu->addMenu (_mru_file_menu); | |||
964 | fileMenu->addSeparator (); | |||
965 | _context_edit_action = | |||
966 | fileMenu->addAction (QIcon (), tr ("&Edit Function"), | |||
967 | this, SLOT (request_context_edit (bool))qFlagLocation("1""request_context_edit (bool)" "\0" "src/m-editor/file-editor.cc" ":" "967")); | |||
968 | fileMenu->addSeparator (); | |||
969 | fileMenu->addAction (_save_action); | |||
970 | fileMenu->addAction (_save_as_action); | |||
971 | ||||
972 | fileMenu->addSeparator (); | |||
973 | _close_action = | |||
974 | fileMenu->addAction (QIcon::fromTheme("window-close", | |||
975 | QIcon (":/actions/icons/fileclose.png")), | |||
976 | tr ("&Close"), this, SLOT (request_close_file (bool))qFlagLocation("1""request_close_file (bool)" "\0" "src/m-editor/file-editor.cc" ":" "976")); | |||
977 | _close_all_action = | |||
978 | fileMenu->addAction (QIcon::fromTheme("window-close", | |||
979 | QIcon (":/actions/icons/fileclose.png")), | |||
980 | tr ("Close All"), | |||
981 | this, SLOT (request_close_all_files (bool))qFlagLocation("1""request_close_all_files (bool)" "\0" "src/m-editor/file-editor.cc" ":" "981")); | |||
982 | _close_others_action = | |||
983 | fileMenu->addAction (QIcon::fromTheme("window-close", | |||
984 | QIcon (":/actions/icons/fileclose.png")), | |||
985 | tr ("Close Other Files"), | |||
986 | this, SLOT (request_close_other_files (bool))qFlagLocation("1""request_close_other_files (bool)" "\0" "src/m-editor/file-editor.cc" ":" "986")); | |||
987 | ||||
988 | fileMenu->addSeparator (); | |||
989 | fileMenu->addAction (_print_action); | |||
990 | ||||
991 | _menu_bar->addMenu (fileMenu); | |||
992 | ||||
993 | ||||
994 | QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); | |||
995 | editMenu->addAction (_undo_action); | |||
996 | editMenu->addAction (_redo_action); | |||
997 | editMenu->addSeparator (); | |||
998 | editMenu->addAction (_copy_action); | |||
999 | editMenu->addAction (_cut_action); | |||
1000 | editMenu->addAction (_paste_action); | |||
1001 | editMenu->addSeparator (); | |||
1002 | editMenu->addAction (_find_action); | |||
1003 | editMenu->addSeparator (); | |||
1004 | editMenu->addAction (_comment_selection_action); | |||
1005 | editMenu->addAction (_uncomment_selection_action); | |||
1006 | editMenu->addSeparator (); | |||
1007 | editMenu->addAction (_toggle_bookmark_action); | |||
1008 | editMenu->addAction (_next_bookmark_action); | |||
1009 | editMenu->addAction (_previous_bookmark_action); | |||
1010 | editMenu->addAction (_remove_bookmark_action); | |||
1011 | editMenu->addSeparator (); | |||
1012 | editMenu->addAction (_goto_line_action); | |||
1013 | editMenu->addSeparator (); | |||
1014 | _preferences_action = | |||
1015 | editMenu->addAction (QIcon (":/actions/icons/configure.png"), | |||
1016 | tr ("&Preferences"), | |||
1017 | this, SLOT (request_preferences (bool))qFlagLocation("1""request_preferences (bool)" "\0" "src/m-editor/file-editor.cc" ":" "1017")); | |||
1018 | _styles_preferences_action = | |||
1019 | editMenu->addAction (QIcon (":/actions/icons/configure.png"), | |||
1020 | tr ("&Styles Preferences"), | |||
1021 | this, SLOT (request_styles_preferences (bool))qFlagLocation("1""request_styles_preferences (bool)" "\0" "src/m-editor/file-editor.cc" ":" "1021")); | |||
1022 | _menu_bar->addMenu (editMenu); | |||
1023 | ||||
1024 | _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); | |||
1025 | _debug_menu->addAction (toggle_breakpoint_action); | |||
1026 | _debug_menu->addAction (next_breakpoint_action); | |||
1027 | _debug_menu->addAction (previous_breakpoint_action); | |||
1028 | _debug_menu->addAction (remove_all_breakpoints_action); | |||
1029 | _debug_menu->addSeparator (); | |||
1030 | // The other debug actions will be added by the main window. | |||
1031 | _menu_bar->addMenu (_debug_menu); | |||
1032 | ||||
1033 | QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); | |||
1034 | _run_menu->addAction (_run_action); | |||
1035 | _context_run_action = | |||
1036 | _run_menu->addAction (QIcon (), tr ("Run &Selection"), | |||
1037 | this, SLOT (request_context_run (bool))qFlagLocation("1""request_context_run (bool)" "\0" "src/m-editor/file-editor.cc" ":" "1037")); | |||
1038 | _context_run_action->setEnabled (false); | |||
1039 | _menu_bar->addMenu (_run_menu); | |||
1040 | ||||
1041 | QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); | |||
1042 | _context_help_action = | |||
1043 | _help_menu->addAction (QIcon (), tr ("&Help on Keyword"), | |||
1044 | this, SLOT (request_context_help (bool))qFlagLocation("1""request_context_help (bool)" "\0" "src/m-editor/file-editor.cc" ":" "1044")); | |||
1045 | _context_doc_action = | |||
1046 | _help_menu->addAction (QIcon (), tr ("&Documentation on Keyword"), | |||
1047 | this, SLOT (request_context_doc (bool))qFlagLocation("1""request_context_doc (bool)" "\0" "src/m-editor/file-editor.cc" ":" "1047")); | |||
1048 | _menu_bar->addMenu (_help_menu); | |||
1049 | ||||
1050 | // shortcuts | |||
1051 | set_shortcuts (true); | |||
1052 | ||||
1053 | // layout | |||
1054 | QVBoxLayout *vbox_layout = new QVBoxLayout (); | |||
1055 | vbox_layout->addWidget (_menu_bar); | |||
1056 | vbox_layout->addWidget (_tool_bar); | |||
1057 | vbox_layout->addWidget (_tab_widget); | |||
1058 | vbox_layout->setMargin (0); | |||
1059 | editor_widget->setLayout (vbox_layout); | |||
1060 | setWidget (editor_widget); | |||
1061 | ||||
1062 | // signals | |||
1063 | connect (this, SIGNAL (request_settings_dialog (const QString&))qFlagLocation("2""request_settings_dialog (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1063"), | |||
1064 | main_win (), | |||
1065 | SLOT (process_settings_dialog_request (const QString&))qFlagLocation("1""process_settings_dialog_request (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1065")); | |||
1066 | ||||
1067 | connect (main_win (), SIGNAL (new_file_signal (const QString&))qFlagLocation("2""new_file_signal (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1067"), | |||
1068 | this, SLOT (request_new_file (const QString&))qFlagLocation("1""request_new_file (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1068")); | |||
1069 | ||||
1070 | connect (main_win (), SIGNAL (open_file_signal (const QString&))qFlagLocation("2""open_file_signal (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1070"), | |||
1071 | this, SLOT (request_open_file (const QString&))qFlagLocation("1""request_open_file (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1071")); | |||
1072 | ||||
1073 | connect (new_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1073"), | |||
1074 | this, SLOT (request_new_file ())qFlagLocation("1""request_new_file ()" "\0" "src/m-editor/file-editor.cc" ":" "1074")); | |||
1075 | ||||
1076 | connect (open_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1076"), | |||
1077 | this, SLOT (request_open_file ())qFlagLocation("1""request_open_file ()" "\0" "src/m-editor/file-editor.cc" ":" "1077")); | |||
1078 | ||||
1079 | connect (_undo_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1079"), | |||
1080 | this, SLOT (request_undo ())qFlagLocation("1""request_undo ()" "\0" "src/m-editor/file-editor.cc" ":" "1080")); | |||
1081 | ||||
1082 | connect (_redo_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1082"), | |||
1083 | this, SLOT (request_redo ())qFlagLocation("1""request_redo ()" "\0" "src/m-editor/file-editor.cc" ":" "1083")); | |||
1084 | ||||
1085 | connect (_copy_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1085"), | |||
1086 | this, SLOT (request_copy ())qFlagLocation("1""request_copy ()" "\0" "src/m-editor/file-editor.cc" ":" "1086")); | |||
1087 | ||||
1088 | connect (_cut_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1088"), | |||
1089 | this, SLOT (request_cut ())qFlagLocation("1""request_cut ()" "\0" "src/m-editor/file-editor.cc" ":" "1089")); | |||
1090 | ||||
1091 | connect (_paste_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1091"), | |||
1092 | this, SLOT (request_paste ())qFlagLocation("1""request_paste ()" "\0" "src/m-editor/file-editor.cc" ":" "1092")); | |||
1093 | ||||
1094 | connect (_save_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1094"), | |||
1095 | this, SLOT (request_save_file ())qFlagLocation("1""request_save_file ()" "\0" "src/m-editor/file-editor.cc" ":" "1095")); | |||
1096 | ||||
1097 | connect (_save_as_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1097"), | |||
1098 | this, SLOT (request_save_file_as ())qFlagLocation("1""request_save_file_as ()" "\0" "src/m-editor/file-editor.cc" ":" "1098")); | |||
1099 | ||||
1100 | connect (_print_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1100"), | |||
1101 | this, SLOT (request_print_file ())qFlagLocation("1""request_print_file ()" "\0" "src/m-editor/file-editor.cc" ":" "1101")); | |||
1102 | ||||
1103 | connect (_run_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1103"), | |||
1104 | this, SLOT (request_run_file ())qFlagLocation("1""request_run_file ()" "\0" "src/m-editor/file-editor.cc" ":" "1104")); | |||
1105 | ||||
1106 | connect (_toggle_bookmark_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1106"), | |||
1107 | this, SLOT (request_toggle_bookmark ())qFlagLocation("1""request_toggle_bookmark ()" "\0" "src/m-editor/file-editor.cc" ":" "1107")); | |||
1108 | ||||
1109 | connect (_next_bookmark_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1109"), | |||
1110 | this, SLOT (request_next_bookmark ())qFlagLocation("1""request_next_bookmark ()" "\0" "src/m-editor/file-editor.cc" ":" "1110")); | |||
1111 | ||||
1112 | connect (_previous_bookmark_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1112"), | |||
1113 | this, SLOT (request_previous_bookmark ())qFlagLocation("1""request_previous_bookmark ()" "\0" "src/m-editor/file-editor.cc" ":" "1113")); | |||
1114 | ||||
1115 | connect (_remove_bookmark_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1115"), | |||
1116 | this, SLOT (request_remove_bookmark ())qFlagLocation("1""request_remove_bookmark ()" "\0" "src/m-editor/file-editor.cc" ":" "1116")); | |||
1117 | ||||
1118 | connect (toggle_breakpoint_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1118"), | |||
1119 | this, SLOT (request_toggle_breakpoint ())qFlagLocation("1""request_toggle_breakpoint ()" "\0" "src/m-editor/file-editor.cc" ":" "1119")); | |||
1120 | ||||
1121 | connect (next_breakpoint_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1121"), | |||
1122 | this, SLOT (request_next_breakpoint ())qFlagLocation("1""request_next_breakpoint ()" "\0" "src/m-editor/file-editor.cc" ":" "1122")); | |||
1123 | ||||
1124 | connect (previous_breakpoint_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1124"), | |||
1125 | this, SLOT (request_previous_breakpoint ())qFlagLocation("1""request_previous_breakpoint ()" "\0" "src/m-editor/file-editor.cc" ":" "1125")); | |||
1126 | ||||
1127 | connect (remove_all_breakpoints_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1127"), | |||
1128 | this, SLOT (request_remove_breakpoint ())qFlagLocation("1""request_remove_breakpoint ()" "\0" "src/m-editor/file-editor.cc" ":" "1128")); | |||
1129 | ||||
1130 | connect (_comment_selection_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1130"), | |||
1131 | this, SLOT (request_comment_selected_text ())qFlagLocation("1""request_comment_selected_text ()" "\0" "src/m-editor/file-editor.cc" ":" "1131")); | |||
1132 | ||||
1133 | connect (_uncomment_selection_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1133"), | |||
1134 | this, SLOT (request_uncomment_selected_text ())qFlagLocation("1""request_uncomment_selected_text ()" "\0" "src/m-editor/file-editor.cc" ":" "1134")); | |||
1135 | ||||
1136 | connect (_find_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1136"), | |||
1137 | this, SLOT (request_find ())qFlagLocation("1""request_find ()" "\0" "src/m-editor/file-editor.cc" ":" "1137")); | |||
1138 | ||||
1139 | connect (_goto_line_action, SIGNAL (triggered ())qFlagLocation("2""triggered ()" "\0" "src/m-editor/file-editor.cc" ":" "1139"), | |||
1140 | this, SLOT (request_goto_line ())qFlagLocation("1""request_goto_line ()" "\0" "src/m-editor/file-editor.cc" ":" "1140")); | |||
1141 | ||||
1142 | connect (_mru_file_menu, SIGNAL (triggered (QAction *))qFlagLocation("2""triggered (QAction *)" "\0" "src/m-editor/file-editor.cc" ":" "1142"), | |||
1143 | this, SLOT (request_mru_open_file (QAction *))qFlagLocation("1""request_mru_open_file (QAction *)" "\0" "src/m-editor/file-editor.cc" ":" "1143")); | |||
1144 | ||||
1145 | mru_menu_update (); | |||
1146 | ||||
1147 | connect (_tab_widget, SIGNAL (tabCloseRequested (int))qFlagLocation("2""tabCloseRequested (int)" "\0" "src/m-editor/file-editor.cc" ":" "1147"), | |||
1148 | this, SLOT (handle_tab_close_request (int))qFlagLocation("1""handle_tab_close_request (int)" "\0" "src/m-editor/file-editor.cc" ":" "1148")); | |||
1149 | ||||
1150 | connect (_tab_widget, SIGNAL (currentChanged (int))qFlagLocation("2""currentChanged (int)" "\0" "src/m-editor/file-editor.cc" ":" "1150"), | |||
1151 | this, SLOT (active_tab_changed (int))qFlagLocation("1""active_tab_changed (int)" "\0" "src/m-editor/file-editor.cc" ":" "1151")); | |||
1152 | ||||
1153 | resize (500, 400); | |||
1154 | setWindowIcon (QIcon (":/actions/icons/logo.png")); | |||
1155 | set_title ("Editor"); | |||
1156 | ||||
1157 | //restore previous session | |||
1158 | if (settings->value ("editor/restoreSession", true).toBool ()) | |||
1159 | { | |||
1160 | QStringList sessionFileNames | |||
1161 | = settings->value ("editor/savedSessionTabs", | |||
1162 | QStringList ()).toStringList (); | |||
1163 | ||||
1164 | for (int n = 0; n < sessionFileNames.count (); ++n) | |||
1165 | request_open_file (sessionFileNames.at (n)); | |||
1166 | } | |||
1167 | ||||
1168 | check_actions (); | |||
1169 | } | |||
1170 | ||||
1171 | void | |||
1172 | file_editor::add_file_editor_tab (file_editor_tab *f, const QString& fn) | |||
1173 | { | |||
1174 | _tab_widget->addTab (f, fn); | |||
1175 | ||||
1176 | // Signals from the file editor_tab | |||
1177 | connect (f, SIGNAL (file_name_changed (const QString&, const QString&))qFlagLocation("2""file_name_changed (const QString&, const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1177"), | |||
1178 | this, SLOT (handle_file_name_changed (const QString&,qFlagLocation("1""handle_file_name_changed (const QString&, const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1179") | |||
1179 | const QString&))qFlagLocation("1""handle_file_name_changed (const QString&, const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1179")); | |||
1180 | ||||
1181 | connect (f, SIGNAL (editor_state_changed (bool, const QString&))qFlagLocation("2""editor_state_changed (bool, const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1181"), | |||
1182 | this, SLOT (handle_editor_state_changed (bool, const QString&))qFlagLocation("1""handle_editor_state_changed (bool, const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1182")); | |||
1183 | ||||
1184 | connect (f, SIGNAL (tab_remove_request ())qFlagLocation("2""tab_remove_request ()" "\0" "src/m-editor/file-editor.cc" ":" "1184"), | |||
1185 | this, SLOT (handle_tab_remove_request ())qFlagLocation("1""handle_tab_remove_request ()" "\0" "src/m-editor/file-editor.cc" ":" "1185")); | |||
1186 | ||||
1187 | connect (f, SIGNAL (add_filename_to_list (const QString&, QWidget*))qFlagLocation("2""add_filename_to_list (const QString&, QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1187"), | |||
1188 | this, SLOT (handle_add_filename_to_list (const QString&, QWidget*))qFlagLocation("1""handle_add_filename_to_list (const QString&, QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1188")); | |||
1189 | ||||
1190 | connect (f, SIGNAL (editor_check_conflict_save (const QString&, bool))qFlagLocation("2""editor_check_conflict_save (const QString&, bool)" "\0" "src/m-editor/file-editor.cc" ":" "1190"), | |||
1191 | this, SLOT (check_conflict_save (const QString&, bool))qFlagLocation("1""check_conflict_save (const QString&, bool)" "\0" "src/m-editor/file-editor.cc" ":" "1191")); | |||
1192 | ||||
1193 | connect (f, SIGNAL (mru_add_file (const QString&))qFlagLocation("2""mru_add_file (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1193"), | |||
1194 | this, SLOT (handle_mru_add_file (const QString&))qFlagLocation("1""handle_mru_add_file (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1194")); | |||
1195 | ||||
1196 | connect (f, SIGNAL (run_file_signal (const QFileInfo&))qFlagLocation("2""run_file_signal (const QFileInfo&)" "\0" "src/m-editor/file-editor.cc" ":" "1196"), | |||
1197 | main_win (), SLOT (run_file_in_terminal (const QFileInfo&))qFlagLocation("1""run_file_in_terminal (const QFileInfo&)" "\0" "src/m-editor/file-editor.cc" ":" "1197")); | |||
1198 | ||||
1199 | connect (f, SIGNAL (execute_command_in_terminal_signal (const QString&))qFlagLocation("2""execute_command_in_terminal_signal (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1199"), | |||
1200 | main_win (), SLOT (execute_command_in_terminal (const QString&))qFlagLocation("1""execute_command_in_terminal (const QString&)" "\0" "src/m-editor/file-editor.cc" ":" "1200")); | |||
1201 | ||||
1202 | // Signals from the file_editor non-trivial operations | |||
1203 | connect (this, SIGNAL (fetab_settings_changed (const QSettings *))qFlagLocation("2""fetab_settings_changed (const QSettings *)" "\0" "src/m-editor/file-editor.cc" ":" "1203"), | |||
1204 | f, SLOT (notice_settings (const QSettings *))qFlagLocation("1""notice_settings (const QSettings *)" "\0" "src/m-editor/file-editor.cc" ":" "1204")); | |||
1205 | ||||
1206 | connect (this, SIGNAL (fetab_close_request (const QWidget*,bool))qFlagLocation("2""fetab_close_request (const QWidget*,bool)" "\0" "src/m-editor/file-editor.cc" ":" "1206"), | |||
1207 | f, SLOT (conditional_close (const QWidget*,bool))qFlagLocation("1""conditional_close (const QWidget*,bool)" "\0" "src/m-editor/file-editor.cc" ":" "1207")); | |||
1208 | ||||
1209 | connect (this, SIGNAL (fetab_change_request (const QWidget*))qFlagLocation("2""fetab_change_request (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1209"), | |||
1210 | f, SLOT (change_editor_state (const QWidget*))qFlagLocation("1""change_editor_state (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1210")); | |||
1211 | ||||
1212 | connect (this, SIGNAL (fetab_file_name_query (const QWidget*))qFlagLocation("2""fetab_file_name_query (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1212"), | |||
1213 | f, SLOT (file_name_query (const QWidget*))qFlagLocation("1""file_name_query (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1213")); | |||
1214 | ||||
1215 | connect (this, SIGNAL (fetab_save_file (const QWidget*, const QString&,qFlagLocation("2""fetab_save_file (const QWidget*, const QString&, bool)" "\0" "src/m-editor/file-editor.cc" ":" "1216") | |||
1216 | bool))qFlagLocation("2""fetab_save_file (const QWidget*, const QString&, bool)" "\0" "src/m-editor/file-editor.cc" ":" "1216"), | |||
1217 | f, SLOT (save_file (const QWidget*, const QString&, bool))qFlagLocation("1""save_file (const QWidget*, const QString&, bool)" "\0" "src/m-editor/file-editor.cc" ":" "1217")); | |||
1218 | ||||
1219 | // Signals from the file_editor trivial operations | |||
1220 | connect (this, SIGNAL (fetab_undo (const QWidget*))qFlagLocation("2""fetab_undo (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1220"), | |||
1221 | f, SLOT (undo (const QWidget*))qFlagLocation("1""undo (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1221")); | |||
1222 | ||||
1223 | connect (this, SIGNAL (fetab_redo (const QWidget*))qFlagLocation("2""fetab_redo (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1223"), | |||
1224 | f, SLOT (redo (const QWidget*))qFlagLocation("1""redo (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1224")); | |||
1225 | ||||
1226 | connect (this, SIGNAL (fetab_copy (const QWidget*))qFlagLocation("2""fetab_copy (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1226"), | |||
1227 | f, SLOT (copy (const QWidget*))qFlagLocation("1""copy (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1227")); | |||
1228 | ||||
1229 | connect (this, SIGNAL (fetab_cut (const QWidget*))qFlagLocation("2""fetab_cut (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1229"), | |||
1230 | f, SLOT (cut (const QWidget*))qFlagLocation("1""cut (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1230")); | |||
1231 | ||||
1232 | connect (this, SIGNAL (fetab_paste (const QWidget*))qFlagLocation("2""fetab_paste (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1232"), | |||
1233 | f, SLOT (paste (const QWidget*))qFlagLocation("1""paste (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1233")); | |||
1234 | ||||
1235 | connect (this, SIGNAL (fetab_context_help (const QWidget*, bool))qFlagLocation("2""fetab_context_help (const QWidget*, bool)" "\0" "src/m-editor/file-editor.cc" ":" "1235"), | |||
1236 | f, SLOT (context_help (const QWidget*, bool))qFlagLocation("1""context_help (const QWidget*, bool)" "\0" "src/m-editor/file-editor.cc" ":" "1236")); | |||
1237 | ||||
1238 | connect (this, SIGNAL (fetab_context_edit (const QWidget*))qFlagLocation("2""fetab_context_edit (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1238"), | |||
1239 | f, SLOT (context_edit (const QWidget*))qFlagLocation("1""context_edit (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1239")); | |||
1240 | ||||
1241 | connect (this, SIGNAL (fetab_save_file (const QWidget*))qFlagLocation("2""fetab_save_file (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1241"), | |||
1242 | f, SLOT (save_file (const QWidget*))qFlagLocation("1""save_file (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1242")); | |||
1243 | ||||
1244 | connect (this, SIGNAL (fetab_save_file_as (const QWidget*))qFlagLocation("2""fetab_save_file_as (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1244"), | |||
1245 | f, SLOT (save_file_as (const QWidget*))qFlagLocation("1""save_file_as (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1245")); | |||
1246 | ||||
1247 | connect (this, SIGNAL (fetab_print_file (const QWidget*))qFlagLocation("2""fetab_print_file (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1247"), | |||
1248 | f, SLOT (print_file (const QWidget*))qFlagLocation("1""print_file (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1248")); | |||
1249 | ||||
1250 | connect (this, SIGNAL (fetab_run_file (const QWidget*))qFlagLocation("2""fetab_run_file (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1250"), | |||
1251 | f, SLOT (run_file (const QWidget*))qFlagLocation("1""run_file (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1251")); | |||
1252 | ||||
1253 | connect (this, SIGNAL (fetab_context_run (const QWidget*))qFlagLocation("2""fetab_context_run (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1253"), | |||
1254 | f, SLOT (context_run (const QWidget*))qFlagLocation("1""context_run (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1254")); | |||
1255 | ||||
1256 | connect (this, SIGNAL (fetab_toggle_bookmark (const QWidget*))qFlagLocation("2""fetab_toggle_bookmark (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1256"), | |||
1257 | f, SLOT (toggle_bookmark (const QWidget*))qFlagLocation("1""toggle_bookmark (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1257")); | |||
1258 | ||||
1259 | connect (this, SIGNAL (fetab_next_bookmark (const QWidget*))qFlagLocation("2""fetab_next_bookmark (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1259"), | |||
1260 | f, SLOT (next_bookmark (const QWidget*))qFlagLocation("1""next_bookmark (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1260")); | |||
1261 | ||||
1262 | connect (this, SIGNAL (fetab_previous_bookmark (const QWidget*))qFlagLocation("2""fetab_previous_bookmark (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1262"), | |||
1263 | f, SLOT (previous_bookmark (const QWidget*))qFlagLocation("1""previous_bookmark (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1263")); | |||
1264 | ||||
1265 | connect (this, SIGNAL (fetab_remove_bookmark (const QWidget*))qFlagLocation("2""fetab_remove_bookmark (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1265"), | |||
1266 | f, SLOT (remove_bookmark (const QWidget*))qFlagLocation("1""remove_bookmark (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1266")); | |||
1267 | ||||
1268 | connect (this, SIGNAL (fetab_toggle_breakpoint (const QWidget*))qFlagLocation("2""fetab_toggle_breakpoint (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1268"), | |||
1269 | f, SLOT (toggle_breakpoint (const QWidget*))qFlagLocation("1""toggle_breakpoint (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1269")); | |||
1270 | ||||
1271 | connect (this, SIGNAL (fetab_next_breakpoint (const QWidget*))qFlagLocation("2""fetab_next_breakpoint (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1271"), | |||
1272 | f, SLOT (next_breakpoint (const QWidget*))qFlagLocation("1""next_breakpoint (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1272")); | |||
1273 | ||||
1274 | connect (this, SIGNAL (fetab_previous_breakpoint (const QWidget*))qFlagLocation("2""fetab_previous_breakpoint (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1274"), | |||
1275 | f, SLOT (previous_breakpoint (const QWidget*))qFlagLocation("1""previous_breakpoint (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1275")); | |||
1276 | ||||
1277 | connect (this, SIGNAL (fetab_remove_all_breakpoints (const QWidget*))qFlagLocation("2""fetab_remove_all_breakpoints (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1277"), | |||
1278 | f, SLOT (remove_all_breakpoints (const QWidget*))qFlagLocation("1""remove_all_breakpoints (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1278")); | |||
1279 | ||||
1280 | connect (this, SIGNAL (fetab_comment_selected_text (const QWidget*))qFlagLocation("2""fetab_comment_selected_text (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1280"), | |||
1281 | f, SLOT (comment_selected_text (const QWidget*))qFlagLocation("1""comment_selected_text (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1281")); | |||
1282 | ||||
1283 | connect (this, SIGNAL (fetab_uncomment_selected_text (const QWidget*))qFlagLocation("2""fetab_uncomment_selected_text (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1283"), | |||
1284 | f, SLOT (uncomment_selected_text (const QWidget*))qFlagLocation("1""uncomment_selected_text (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1284")); | |||
1285 | ||||
1286 | connect (this, SIGNAL (fetab_find (const QWidget*))qFlagLocation("2""fetab_find (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1286"), | |||
1287 | f, SLOT (find (const QWidget*))qFlagLocation("1""find (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1287")); | |||
1288 | ||||
1289 | connect (this, SIGNAL (fetab_goto_line (const QWidget*, int))qFlagLocation("2""fetab_goto_line (const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1289"), | |||
1290 | f, SLOT (goto_line (const QWidget*, int))qFlagLocation("1""goto_line (const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1290")); | |||
1291 | ||||
1292 | connect (this, SIGNAL (fetab_set_focus (const QWidget*))qFlagLocation("2""fetab_set_focus (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1292"), | |||
1293 | f, SLOT (set_focus (const QWidget*))qFlagLocation("1""set_focus (const QWidget*)" "\0" "src/m-editor/file-editor.cc" ":" "1293")); | |||
1294 | ||||
1295 | connect (this, SIGNAL (fetab_insert_debugger_pointer (const QWidget*, int))qFlagLocation("2""fetab_insert_debugger_pointer (const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1295"), | |||
1296 | f, SLOT (insert_debugger_pointer (const QWidget*, int))qFlagLocation("1""insert_debugger_pointer (const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1296")); | |||
1297 | ||||
1298 | connect (this, SIGNAL (fetab_delete_debugger_pointer (const QWidget*, int))qFlagLocation("2""fetab_delete_debugger_pointer (const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1298"), | |||
1299 | f, SLOT (delete_debugger_pointer (const QWidget*, int))qFlagLocation("1""delete_debugger_pointer (const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1299")); | |||
1300 | ||||
1301 | connect (this, SIGNAL (fetab_do_breakpoint_marker (bool, const QWidget*,qFlagLocation("2""fetab_do_breakpoint_marker (bool, const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1302") | |||
1302 | int))qFlagLocation("2""fetab_do_breakpoint_marker (bool, const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1302"), | |||
1303 | f, SLOT (do_breakpoint_marker (bool, const QWidget*, int))qFlagLocation("1""do_breakpoint_marker (bool, const QWidget*, int)" "\0" "src/m-editor/file-editor.cc" ":" "1303")); | |||
1304 | ||||
1305 | _tab_widget->setCurrentWidget (f); | |||
1306 | ||||
1307 | check_actions (); | |||
1308 | } | |||
1309 | ||||
1310 | void | |||
1311 | file_editor::copyClipboard () | |||
1312 | { | |||
1313 | QWidget * foc_w = focusWidget (); | |||
1314 | ||||
1315 | if (foc_w && foc_w->inherits ("octave_qscintilla")) | |||
1316 | { | |||
1317 | request_copy (); | |||
1318 | } | |||
1319 | } | |||
1320 | void | |||
1321 | file_editor::pasteClipboard () | |||
1322 | { | |||
1323 | QWidget * foc_w = focusWidget (); | |||
1324 | ||||
1325 | if (foc_w && foc_w->inherits ("octave_qscintilla")) | |||
1326 | { | |||
1327 | request_paste (); | |||
1328 | } | |||
1329 | } | |||
1330 | ||||
1331 | void | |||
1332 | file_editor::set_shortcuts (bool set) | |||
1333 | { | |||
1334 | if (set) | |||
1335 | { | |||
1336 | _comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_R); | |||
1337 | _uncomment_selection_action->setShortcut (Qt::SHIFT | |||
1338 | + Qt::ControlModifier | |||
1339 | + Qt::Key_R); | |||
1340 | ||||
1341 | _copy_action->setShortcut (QKeySequence::Copy); | |||
1342 | _cut_action->setShortcut (QKeySequence::Cut); | |||
1343 | _paste_action->setShortcut (QKeySequence::Paste); | |||
1344 | _context_help_action->setShortcut (QKeySequence::HelpContents); | |||
1345 | _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1); | |||
1346 | ||||
1347 | _find_action->setShortcut (QKeySequence::Find); | |||
1348 | _goto_line_action->setShortcut (Qt::ControlModifier+ Qt::Key_G); | |||
1349 | ||||
1350 | _next_bookmark_action->setShortcut (Qt::Key_F2); | |||
1351 | _previous_bookmark_action->setShortcut (Qt::SHIFT + Qt::Key_F2); | |||
1352 | _toggle_bookmark_action->setShortcut (Qt::Key_F7); | |||
1353 | ||||
1354 | _print_action->setShortcut (QKeySequence::Print); | |||
1355 | _run_action->setShortcut (Qt::Key_F5); | |||
1356 | _context_run_action->setShortcut (Qt::Key_F9); | |||
1357 | ||||
1358 | _context_edit_action->setShortcut (Qt::ControlModifier + Qt::Key_E); | |||
1359 | _save_action->setShortcut (QKeySequence::Save); | |||
1360 | _save_as_action->setShortcut (QKeySequence::SaveAs); | |||
1361 | _close_action->setShortcut (QKeySequence::Close); | |||
1362 | ||||
1363 | _redo_action->setShortcut (QKeySequence::Redo); | |||
1364 | _undo_action->setShortcut (QKeySequence::Undo); | |||
1365 | } | |||
1366 | else | |||
1367 | { | |||
1368 | QKeySequence no_key = QKeySequence (); | |||
1369 | ||||
1370 | _comment_selection_action->setShortcut (no_key); | |||
1371 | _uncomment_selection_action->setShortcut (no_key); | |||
1372 | ||||
1373 | _copy_action->setShortcut (no_key); | |||
1374 | _cut_action->setShortcut (no_key); | |||
1375 | _paste_action->setShortcut (no_key); | |||
1376 | _context_help_action->setShortcut (no_key); | |||
1377 | ||||
1378 | _find_action->setShortcut (no_key); | |||
1379 | _goto_line_action->setShortcut (no_key); | |||
1380 | ||||
1381 | _next_bookmark_action->setShortcut (no_key); | |||
1382 | _previous_bookmark_action->setShortcut (no_key); | |||
1383 | _toggle_bookmark_action->setShortcut (no_key); | |||
1384 | ||||
1385 | _print_action->setShortcut (no_key); | |||
1386 | _run_action->setShortcut (no_key); | |||
1387 | _context_run_action->setShortcut (no_key); | |||
1388 | ||||
1389 | _context_edit_action->setShortcut (no_key); | |||
1390 | _save_action->setShortcut (no_key); | |||
1391 | _save_as_action->setShortcut (no_key); | |||
1392 | _close_action->setShortcut (no_key); | |||
1393 | ||||
1394 | _redo_action->setShortcut (no_key); | |||
1395 | _undo_action->setShortcut (no_key); | |||
1396 | } | |||
1397 | } | |||
1398 | ||||
1399 | void | |||
1400 | file_editor::check_actions () | |||
1401 | { | |||
1402 | bool have_tabs = _tab_widget->count () > 0; | |||
1403 | ||||
1404 | _comment_selection_action->setEnabled (have_tabs); | |||
1405 | _uncomment_selection_action->setEnabled (have_tabs); | |||
1406 | ||||
1407 | _paste_action->setEnabled (have_tabs); | |||
1408 | _context_help_action->setEnabled (have_tabs); | |||
1409 | _context_doc_action->setEnabled (have_tabs); | |||
1410 | ||||
1411 | _find_action->setEnabled (have_tabs); | |||
1412 | _goto_line_action->setEnabled (have_tabs); | |||
1413 | ||||
1414 | _next_bookmark_action->setEnabled (have_tabs); | |||
1415 | _previous_bookmark_action->setEnabled (have_tabs); | |||
1416 | _toggle_bookmark_action->setEnabled (have_tabs); | |||
1417 | _remove_bookmark_action->setEnabled (have_tabs); | |||
1418 | ||||
1419 | _print_action->setEnabled (have_tabs); | |||
1420 | _run_action->setEnabled (have_tabs); | |||
1421 | ||||
1422 | _context_edit_action->setEnabled (have_tabs); | |||
1423 | _save_action->setEnabled (have_tabs); | |||
1424 | _save_as_action->setEnabled (have_tabs); | |||
1425 | _close_action->setEnabled (have_tabs); | |||
1426 | _close_all_action->setEnabled (have_tabs); | |||
1427 | _close_others_action->setEnabled (have_tabs && _tab_widget->count () > 1); | |||
1428 | ||||
1429 | _undo_action->setEnabled (have_tabs); | |||
1430 | _redo_action->setEnabled (have_tabs); | |||
1431 | } | |||
1432 | ||||
1433 | ||||
1434 | #endif |