Mercurial > hg > octave-nkf
view libgui/src/m-editor/file-editor.cc @ 15848:424edeca3c66
Redo portions of file editor to use more signals/slots rather than casting.
* file-editor-tab.cc, file-editor-tab.h (file_editor_tab::~file_editor_tab):
Add. Delete lexer to prevent memory leak. Delete _edit_area to prevent memory
leak. (file_editor_tab::conditional_close): Add. Simple slot that uses QWidget
pointer as unique ID, not for function call.
(file_editor_tab::file_name_query): Add. Simple slot that signals file name to
whomever is connected. (file_editor_tab::find,
file_editor_tab : public QWidget): Removed use of exec() and keep a pointer to
the find_dialog as a member. Toggle hide()/show() via a connected slot to
toggle visibility as desired.
* file-editor.cc, file-editor.h, file-editor-tab.cc file-editor-tab.h
(file_editor : public file_editor_interface, file_editor_tab : public QWidget,
file_editor_tab::file_editor_tab, file_editor_tab::closeEvent,
file_editor_tab::load_file, file_editor_tab::new_file,
file_editor_tab::run_file): Remove _file_editor pointer member from
file_editor_tab and rid file_editor::get_main_window from file_editor. There
should be no need for such information about higher-level hierarchy inside
lower-level objects. (file_editor::request_open_file,
file_editor_tab::open_file): Move QFileDialog to file_editor::request_open_file
and delete file_editor_tab::open_file since most of the remaining functionality
is in file_editor_tab::load_file. (file_editor::active_editor_tab): Deleted.
(file_editor::fetab_change_request, file_editor_tab::change_editor_state):
Added to initiate a request for the editor tab to change focus.
(file_editor_tab::editor_state_changed): Added arguments to pass the copy
status and the directory path so that editor doesn't have to call functions for
such information. (file_editor::handle_editor_state_changed): Add copying
directory of the file_editor_tab to the current editing directory.
(file_editor::check_conflict_save, file_editor_tab::editor_check_conflict_save,
file_editor_tab::save_file_as, file_editor_tab::handle_save_file_as_answer):
Moved a portion of the save-file-as dialog mechanism to the file_editor where
all file names can be obtained to check for conflict with already open files.
The new signal indicates to the editor that a name check be done, and in turn
the editor signals the tab to save the file.
* main-window.cc, file-editor.cc, file-editor.h, file-editor-interface.h
(file_editor::terminal, file_editor : public file_editor_interface,
file_editor_interface : public QDockWidget): Since file_editor_tab no longer
looks up to main_window, remove _main_window and _terminal from file_editor and
file_editor_interface, as well as file_editor::terminal.
* file-editor-tab.cc (file_editor_tab::file_has_changed): Make the dialog
boxes non-modal and use slots to handle user answers.
(file_editor_tab::closeEvent): Remove portion that accesses upper hierarchy
member functions, can find better approaches.
(file_editor_tab::file_editor_tab): Make there no parent for QsciScintilla so
that window modality can be set to individual editor.
* file-editor-tab.cc, file-editor.cc (file_editor_tab::load_file): Use show()
member rather than exec() and set modality to window so that rest of
application may function. Return a QString with message rather than a boolean.
* file-editor-tab.cc, (file_editor_tab::file_has_changed): Remove static
variable alreadyAsking. Multiple file_editor_tabs are using this code so do
not want to block recognition of multiple file having changed on disk
(bug #37406). Instead, simply stop tracking via the file watcher.
(file_editor_tab::save_file, file_editor_tab::save_file_as,
file_editor_tab::handle_save_file_as_answer,
file_editor_tab::handle_save_file_as_answer_close): Added a remove_on_success
variable. Changed the QFileDialog to WindowModal and created slots to handle
file selected signal and finished signal. Signal/slot connects vary based upon
remove_on_success setting. (file_editor_tab::check_file_modified): Changed the
QFileDialog to NonModal and attach some slots. Editor tab can't be parent in
case deleted, so use read-only state of the editor area.
* file-editor-tab.h (file_editor_tab : public QWidget): New signals for
file_editor for tab and file name management. (file_editor_tab::get_file_name):
Delete.
* file-editor.h (file_editor : public file_editor_interface): Make QStringList
sessionFileNames a member of file_editor so that it can retain data between
file_editor_tab signals. Also can be used for checking precense of filenames
and prevent opening multiple copies (bug #36869) Added signals for file editor
tabs--settings_changed, fetab_close_request, and query_file_name. Three new
slots for tab and file name management.
* file-editor-interface.h, file-editor.h
(file_editor_interface::add_file_editor_tab, file_editor::add_file_editor_tab):
Made the text name for the tab an input variable.
* file-editor.cc (file_editor::~file_editor): Replace dynamic_cast with simple
signal querying all file editor tabs for file names which end up in
savedSessionTabs. (file_editor::handle_file_name_changed): Dynamic cast not
necessary since QObject and QWidget are compatible.
(file_editor::handle_tab_close_request): Replace dynamic_cast with signal to
request file_editor_tab with associated tabID tag should close.
(file_editor::handle_tab_remove_request): Rename of handle_tab_close_request.
Instead of dynamic cast, loop through pointers comparing QWidget* to QObject*,
if same tag remove tab via index and also delete which fixes a memory leak.
(file_editor::handle_add_filename_to_list): Simple slot that uses append() of
the list member functions. (file_editor::notice_settings): Rather than dynamic
cast, emit signal for the file_editor_tabs. (file_editor::add_file_editor_tab):
New variety of connections for improved flow. (file_editor::request_open_file):
Given error messages are made WindowModal, the tab shouldn't be delete if file
open is not successful. The file_editor_tab takes care of that.
(file_editor::request_open_file): Added check and message box for the
requested file already open in editor. For the non-interactive overloaded
version, open a message dialog box to tell the user file not found, e.g.,
could not find file in the settings when launched.
(file_editor::request_open_file): Inquire file names and update list before
checking for existence of files. Supply empty title to editor tab then have
file_editor_tab update name.
* file-editor-tab.h, file-editor-tab.cc, file-editor.cc
(file_editor_tab::run_file): New signal process_octave_code.
(file_editor::add_file_editor_tab): Connect signal process_octave_code to
file_editor's parent's slot handle_command_double_clicked.
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Sun, 23 Dec 2012 14:33:48 -0600 |
parents | bbbb89cc338f |
children | feba9ff6e6a8 |
line wrap: on
line source
/* Copyright (C) 2011-2012 Jacob Dawid This file is part of Octave. Octave is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Octave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "file-editor.h" #include "resource-manager.h" #include <QVBoxLayout> #include <QApplication> #include <QFile> #include <QFont> #include <QFileDialog> #include <QMessageBox> #include <QStyle> #include <QTextStream> #include "octave-link.h" file_editor::file_editor (QWidget *p) : file_editor_interface (p) { // Set current editing directory before construct because loaded // files will change ced accordingly. ced = QDir::currentPath (); construct (); setVisible (false); } file_editor::~file_editor () { QSettings *settings = resource_manager::get_settings (); fetFileNames.clear (); if (settings->value ("editor/restoreSession",true).toBool ()) { // Have all file editor tabs signal what their file names are. emit fetab_file_name_query (0); } settings->setValue ("editor/savedSessionTabs", fetFileNames); settings->sync (); } QMenu * file_editor::debug_menu () { return _debug_menu; } QToolBar * file_editor::toolbar () { return _tool_bar; } void file_editor::handle_entered_debug_mode () { _run_action->setEnabled (false); } void file_editor::handle_quit_debug_mode () { _run_action->setEnabled (true); } void file_editor::request_new_file () { // New file isn't a file_editor_tab function since the file // editor tab has yet to be created and there is no object to // pass a signal to. Hence, functionality is here. file_editor_tab *fileEditorTab = new file_editor_tab (ced); if (fileEditorTab) { add_file_editor_tab (fileEditorTab, UNNAMED_FILE); fileEditorTab->new_file (); } } void file_editor::request_open_file () { // Open file isn't a file_editor_tab function since the file // editor tab has yet to be created and there is no object to // pass a signal to. Hence, functionality is here. // Create a NonModal message. QFileDialog* fileDialog = new QFileDialog (this); fileDialog->setNameFilter (SAVE_FILE_FILTER); fileDialog->setAcceptMode (QFileDialog::AcceptOpen); fileDialog->setViewMode (QFileDialog::Detail); fileDialog->setDirectory (ced); connect (fileDialog, SIGNAL (fileSelected (const QString&)), this, SLOT (request_open_file (const QString&))); fileDialog->setWindowModality (Qt::NonModal); fileDialog->setAttribute (Qt::WA_DeleteOnClose); fileDialog->show (); } void file_editor::request_open_file (const QString& openFileName) { if (openFileName.isEmpty ()) { // ?? Not sure this will happen. This routine isn't even called // if the user hasn't selected a file. } else { // Have all file editor tabs signal what their file names are. fetFileNames.clear (); emit fetab_file_name_query (0); // Check whether this file is already open in the editor. if (fetFileNames.contains (openFileName, Qt::CaseSensitive)) { // Create a NonModal message so nothing is blocked and // bring the existing file forward. QMessageBox* msgBox = new QMessageBox ( QMessageBox::Critical, tr ("Octave Editor"), tr ("File %1 is already open in the editor."). arg (openFileName), QMessageBox::Ok, 0); msgBox->setWindowModality (Qt::NonModal); msgBox->setAttribute (Qt::WA_DeleteOnClose); msgBox->show (); for(int i = 0; i < _tab_widget->count (); i++) { if (_tab_widget->tabText (i) == openFileName) { _tab_widget->setCurrentIndex (i); break; } } return; } file_editor_tab *fileEditorTab = new file_editor_tab (); if (fileEditorTab) { QString result = fileEditorTab->load_file(openFileName); if (result == "") { // Supply empty title then have the file_editor_tab update // with full or short name. add_file_editor_tab (fileEditorTab, ""); fileEditorTab->update_window_title (false); } else { delete fileEditorTab; // Create a NonModal message about error. QMessageBox* msgBox = new QMessageBox ( QMessageBox::Critical, tr ("Octave Editor"), tr ("Could not open file %1 for read:\n%2."). arg (openFileName).arg (result), QMessageBox::Ok, 0); msgBox->setWindowModality (Qt::NonModal); msgBox->setAttribute (Qt::WA_DeleteOnClose); msgBox->show (); } } } } void file_editor::check_conflict_save (const QString& saveFileName, bool remove_on_success) { // Have all file editor tabs signal what their file names are. fetFileNames.clear (); emit fetab_file_name_query (0); // If one of those names matches the desired name, that's a conflict. if (fetFileNames.contains (saveFileName, Qt::CaseSensitive)) { // Note: to overwrite the contents of some other file editor tab // with the same name requires identifying which file editor tab // that is (not too difficult) then close that tab. Of course, // that could trigger another dialog box if the file editor tab // with the same name has modifications in it. This could become // somewhat confusing to the user. For now, opt to do nothing. // Create a NonModal message about error. QMessageBox* msgBox = new QMessageBox ( QMessageBox::Critical, tr ("Octave Editor"), tr ("File not saved! You've selected a file name\n\n %1\n\nwhich is the same as an already open file in the editor. (Could allow overwriting, with message, if that is what folks want.)"). arg (saveFileName), QMessageBox::Ok, 0); msgBox->setWindowModality (Qt::NonModal); msgBox->setAttribute (Qt::WA_DeleteOnClose); msgBox->show (); return; } QObject* saveFileObject = sender (); QWidget* saveFileWidget = 0; for(int i = 0; i < _tab_widget->count (); i++) { if (_tab_widget->widget (i) == saveFileObject) { saveFileWidget = _tab_widget->widget (i); break; } } if (!saveFileWidget) { // Create a NonModal message about error. QMessageBox* msgBox = new QMessageBox ( QMessageBox::Critical, tr ("Octave Editor"), tr ("The associated file editor tab has disappeared. It was likely closed by some means."), QMessageBox::Ok, 0); msgBox->setWindowModality (Qt::NonModal); msgBox->setAttribute (Qt::WA_DeleteOnClose); msgBox->show (); return; } // Can save without conflict, have the file editor tab do so. emit fetab_save_file (saveFileWidget, saveFileName, remove_on_success); } void file_editor::request_undo () { emit fetab_undo (_tab_widget->currentWidget ()); } void file_editor::request_redo () { emit fetab_redo (_tab_widget->currentWidget ()); } void file_editor::request_copy () { emit fetab_copy (_tab_widget->currentWidget ()); } void file_editor::request_cut () { emit fetab_cut (_tab_widget->currentWidget ()); } void file_editor::request_paste () { emit fetab_paste (_tab_widget->currentWidget ()); } void file_editor::request_save_file () { emit fetab_save_file (_tab_widget->currentWidget ()); } void file_editor::request_save_file_as () { emit fetab_save_file_as (_tab_widget->currentWidget ()); } void file_editor::request_run_file () { emit fetab_run_file (_tab_widget->currentWidget ()); } void file_editor::request_toggle_bookmark () { emit fetab_toggle_bookmark (_tab_widget->currentWidget ()); } void file_editor::request_next_bookmark () { emit fetab_next_bookmark (_tab_widget->currentWidget ()); } void file_editor::request_previous_bookmark () { emit fetab_previous_bookmark (_tab_widget->currentWidget ()); } void file_editor::request_remove_bookmark () { emit fetab_remove_bookmark (_tab_widget->currentWidget ()); } void file_editor::request_toggle_breakpoint () { emit fetab_toggle_breakpoint (_tab_widget->currentWidget ()); } void file_editor::request_next_breakpoint () { emit fetab_next_breakpoint (_tab_widget->currentWidget ()); } void file_editor::request_previous_breakpoint () { emit fetab_previous_breakpoint (_tab_widget->currentWidget ()); } void file_editor::request_remove_breakpoint () { emit fetab_remove_all_breakpoints (_tab_widget->currentWidget ()); } void file_editor::request_comment_selected_text () { emit fetab_comment_selected_text (_tab_widget->currentWidget ()); } void file_editor::request_uncomment_selected_text () { emit fetab_uncomment_selected_text (_tab_widget->currentWidget ()); } void file_editor::request_find () { emit fetab_find (_tab_widget->currentWidget ()); } void file_editor::handle_file_name_changed (const QString& fileName) { QObject *fileEditorTab = sender(); if (fileEditorTab) { for(int i = 0; i < _tab_widget->count (); i++) { if (_tab_widget->widget (i) == fileEditorTab) { _tab_widget->setTabText (i, fileName); } } } } void file_editor::handle_tab_close_request (int index) { // Signal to the tabs a request to close whomever matches the identifying // tag (i.e., unique widget pointer). The reason for this indirection is // that it will enable a file editor widget to toss up a non-static // dialog box and later signal that it wants to be removed. QWidget *tabID = _tab_widget->widget (index); emit fetab_close_request (tabID); } void file_editor::handle_tab_remove_request () { QObject *fileEditorTab = sender(); if (fileEditorTab) { for(int i = 0; i < _tab_widget->count (); i++) { if (_tab_widget->widget (i) == fileEditorTab) { _tab_widget->removeTab (i); delete fileEditorTab; } } } } void file_editor::handle_add_filename_to_list (const QString& fileName) { fetFileNames.append (fileName); } void file_editor::active_tab_changed (int index) { emit fetab_change_request (_tab_widget->widget (index)); } void file_editor::handle_editor_state_changed (bool copy_available, const QString& file_name) { // In case there is some scenario where traffic could be coming from // all the file editor tabs, just process info from the current active tab. if (sender() == _tab_widget->currentWidget ()) { _copy_action->setEnabled (copy_available); _cut_action->setEnabled (copy_available); if (!file_name.isEmpty ()) { ced = QDir::cleanPath (file_name); int lastslash = ced.lastIndexOf ('/'); // Test against > 0 because if somehow the directory is "/" the // slash should be retained. Otherwise, last slash is removed. if (lastslash > 0 && lastslash != ced.count ()) { ced = ced.left (lastslash); } } setFocusProxy (_tab_widget->currentWidget ()); } } void file_editor::notice_settings () { // Relay signal to file editor tabs. emit fetab_settings_changed (); } // slot for signal that is emitted when floating property changes void file_editor::top_level_changed (bool floating) { if(floating) { setWindowFlags(Qt::Window); // make a window from the widget when floating show(); // make it visible again since setWindowFlag hides it } } void file_editor::construct () { QWidget *editor_widget = new QWidget (this); QStyle *editor_style = QApplication::style (); _menu_bar = new QMenuBar (editor_widget); _tool_bar = new QToolBar (editor_widget); _tab_widget = new QTabWidget (editor_widget); _tab_widget->setTabsClosable (true); QAction *new_action = new QAction (QIcon(":/actions/icons/filenew.png"), tr("&New File"), _tool_bar); QAction *open_action = new QAction (QIcon(":/actions/icons/fileopen.png"), tr("&Open File"), _tool_bar); QAction *save_action = new QAction (QIcon(":/actions/icons/filesave.png"), tr("&Save File"), _tool_bar); QAction *save_as_action = new QAction (QIcon(":/actions/icons/filesaveas.png"), tr("Save File &As"), _tool_bar); QAction *undo_action = new QAction (QIcon(":/actions/icons/undo.png"), tr("&Undo"), _tool_bar); QAction *redo_action = new QAction (QIcon(":/actions/icons/redo.png"), tr("&Redo"), _tool_bar); _copy_action = new QAction (QIcon(":/actions/icons/editcopy.png"), tr ("&Copy"), _tool_bar); _cut_action = new QAction (QIcon(":/actions/icons/editcut.png"), tr ("Cu&t"), _tool_bar); QAction *paste_action = new QAction (QIcon (":/actions/icons/editpaste.png"), tr("Paste"), _tool_bar); QAction *next_bookmark_action = new QAction (tr ("&Next Bookmark"),_tool_bar); QAction *previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"),_tool_bar); QAction *toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"),_tool_bar); QAction *remove_bookmark_action = new QAction (tr ("&Remove All Bookmarks"),_tool_bar); QAction *next_breakpoint_action = new QAction (QIcon (":/actions/icons/bp_next.png"), tr ("&Next breakpoint"), _tool_bar); QAction *previous_breakpoint_action = new QAction (QIcon (":/actions/icons/bp_prev.png"), tr ("Pre&vious breakpoint"), _tool_bar); QAction *toggle_breakpoint_action = new QAction (QIcon (":/actions/icons/bp_toggle.png"), tr ("Toggle &breakpoint"), _tool_bar); QAction *remove_all_breakpoints_action = new QAction (QIcon (":/actions/icons/bp_rm_all.png"), tr ("&Remove All breakpoints"), _tool_bar); QAction *comment_selection_action = new QAction (tr ("&Comment Selected Text"),_tool_bar); QAction *uncomment_selection_action = new QAction (tr ("&Uncomment Selected Text"),_tool_bar); QAction *find_action = new QAction (QIcon(":/actions/icons/find.png"), tr ("&Find and Replace"), _tool_bar); _run_action = new QAction (QIcon(":/actions/icons/artsbuilderexecute.png"), tr("Save File And Run"), _tool_bar); // some actions are disabled from the beginning _copy_action->setEnabled(false); _cut_action->setEnabled(false); _run_action->setShortcut (Qt::ControlModifier+ Qt::Key_R); _run_action->setShortcutContext (Qt::WindowShortcut); next_bookmark_action->setShortcut (Qt::Key_F2); next_bookmark_action->setShortcutContext (Qt::WindowShortcut); previous_bookmark_action->setShortcut (Qt::SHIFT + Qt::Key_F2); previous_bookmark_action->setShortcutContext (Qt::WindowShortcut); toggle_bookmark_action->setShortcut (Qt::Key_F7); toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_7); comment_selection_action->setShortcutContext (Qt::WindowShortcut); uncomment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_8); uncomment_selection_action->setShortcutContext(Qt::WindowShortcut); find_action->setShortcut (Qt::ControlModifier+Qt::Key_F); find_action->setShortcutContext (Qt::WindowShortcut); // toolbar _tool_bar->addAction (new_action); _tool_bar->addAction (open_action); _tool_bar->addAction (save_action); _tool_bar->addAction (save_as_action); _tool_bar->addSeparator (); _tool_bar->addAction (undo_action); _tool_bar->addAction (redo_action); _tool_bar->addAction (_copy_action); _tool_bar->addAction (_cut_action); _tool_bar->addAction (paste_action); _tool_bar->addSeparator (); _tool_bar->addAction (find_action); _tool_bar->addAction (_run_action); _tool_bar->addSeparator (); _tool_bar->addAction (toggle_breakpoint_action); _tool_bar->addAction (next_breakpoint_action); _tool_bar->addAction (previous_breakpoint_action); _tool_bar->addAction (remove_all_breakpoints_action); // menu bar QMenu *fileMenu = new QMenu (tr ("&File"), _menu_bar); fileMenu->addAction (new_action); fileMenu->addAction (open_action); fileMenu->addAction (save_action); fileMenu->addAction (save_as_action); fileMenu->addSeparator (); _menu_bar->addMenu (fileMenu); QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); editMenu->addAction (undo_action); editMenu->addAction (redo_action); editMenu->addSeparator (); editMenu->addAction (_copy_action); editMenu->addAction (_cut_action); editMenu->addAction (paste_action); editMenu->addSeparator (); editMenu->addAction (find_action); editMenu->addSeparator (); editMenu->addAction (comment_selection_action); editMenu->addAction (uncomment_selection_action); editMenu->addSeparator (); editMenu->addAction (toggle_bookmark_action); editMenu->addAction (next_bookmark_action); editMenu->addAction (previous_bookmark_action); editMenu->addAction (remove_bookmark_action); _menu_bar->addMenu (editMenu); _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); _debug_menu->addAction (toggle_breakpoint_action); _debug_menu->addAction (next_breakpoint_action); _debug_menu->addAction (previous_breakpoint_action); _debug_menu->addAction (remove_all_breakpoints_action); _debug_menu->addSeparator (); // The other debug actions will be added by the main window. _menu_bar->addMenu (_debug_menu); QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); _run_menu->addAction (_run_action); _menu_bar->addMenu (_run_menu); QVBoxLayout *vbox_layout = new QVBoxLayout (); vbox_layout->addWidget (_menu_bar); vbox_layout->addWidget (_tool_bar); vbox_layout->addWidget (_tab_widget); vbox_layout->setMargin (0); editor_widget->setLayout (vbox_layout); setWidget (editor_widget); connect (new_action, SIGNAL (triggered ()), this, SLOT (request_new_file ())); connect (open_action, SIGNAL (triggered ()), this, SLOT (request_open_file ())); connect (undo_action, SIGNAL (triggered ()), this, SLOT (request_undo ())); connect (redo_action, SIGNAL (triggered ()), this, SLOT (request_redo ())); connect (_copy_action, SIGNAL (triggered ()), this, SLOT (request_copy ())); connect (_cut_action, SIGNAL (triggered ()), this, SLOT (request_cut ())); connect (paste_action, SIGNAL (triggered ()), this, SLOT (request_paste ())); connect (save_action, SIGNAL (triggered ()), this, SLOT (request_save_file ())); connect (save_as_action, SIGNAL (triggered ()), this, SLOT (request_save_file_as ())); connect (_run_action, SIGNAL (triggered ()), this, SLOT (request_run_file ())); connect (toggle_bookmark_action, SIGNAL (triggered ()), this, SLOT (request_toggle_bookmark ())); connect (next_bookmark_action, SIGNAL (triggered ()), this, SLOT (request_next_bookmark ())); connect (previous_bookmark_action, SIGNAL (triggered ()), this, SLOT (request_previous_bookmark ())); connect (remove_bookmark_action, SIGNAL (triggered ()), this, SLOT (request_remove_bookmark ())); connect (toggle_breakpoint_action, SIGNAL (triggered ()), this, SLOT (request_toggle_breakpoint ())); connect (next_breakpoint_action, SIGNAL (triggered ()), this, SLOT (request_next_breakpoint ())); connect (previous_breakpoint_action, SIGNAL (triggered ()), this, SLOT (request_previous_breakpoint ())); connect (remove_all_breakpoints_action, SIGNAL (triggered ()), this, SLOT (request_remove_breakpoint ())); connect (comment_selection_action, SIGNAL (triggered ()), this, SLOT (request_comment_selected_text ())); connect (uncomment_selection_action, SIGNAL (triggered ()), this, SLOT (request_uncomment_selected_text ())); connect (find_action, SIGNAL (triggered ()), this, SLOT (request_find ())); connect (_tab_widget, SIGNAL (tabCloseRequested (int)), this, SLOT (handle_tab_close_request (int))); connect (_tab_widget, SIGNAL (currentChanged(int)), this, SLOT (active_tab_changed (int))); // topLevelChanged is emitted when floating property changes (floating = true) connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool))); resize (500, 400); setWindowIcon (QIcon(":/actions/icons/logo.png")); setWindowTitle ("Editor"); //restore previous session QSettings *settings = resource_manager::get_settings (); if (settings->value ("editor/restoreSession",true).toBool ()) { QStringList sessionFileNames = settings->value("editor/savedSessionTabs", QStringList()).toStringList (); for (int n=0; n < sessionFileNames.count (); ++n) request_open_file (sessionFileNames.at (n)); } } void file_editor::add_file_editor_tab (file_editor_tab *f, const QString &fn) { _tab_widget->addTab (f, fn); // Signals from the file editor_tab connect (f, SIGNAL (file_name_changed (const QString&)), this, SLOT (handle_file_name_changed (const QString&))); connect (f, SIGNAL (editor_state_changed (bool, const QString&)), this, SLOT (handle_editor_state_changed (bool, const QString&))); connect (f, SIGNAL (tab_remove_request ()), this, SLOT (handle_tab_remove_request ())); connect (f, SIGNAL (add_filename_to_list (const QString&)), this, SLOT (handle_add_filename_to_list (const QString&))); connect (f, SIGNAL (editor_check_conflict_save (const QString&, bool)), this, SLOT (check_conflict_save (const QString&, bool))); connect (f, SIGNAL (process_octave_code (const QString&)), parent (), SLOT (handle_command_double_clicked (const QString&))); // Signals from the file_editor non-trivial operations connect (this, SIGNAL (fetab_settings_changed ()), f, SLOT (notice_settings ())); connect (this, SIGNAL (fetab_close_request (const QWidget*)), f, SLOT (conditional_close (const QWidget*))); connect (this, SIGNAL (fetab_change_request (const QWidget*)), f, SLOT (change_editor_state (const QWidget*))); connect (this, SIGNAL (fetab_file_name_query (const QWidget*)), f, SLOT (file_name_query (const QWidget*))); connect (this, SIGNAL (fetab_save_file (const QWidget*, const QString&, bool)), f, SLOT (save_file (const QWidget*, const QString&, bool))); // Signals from the file_editor trivial operations connect (this, SIGNAL (fetab_undo (const QWidget*)), f, SLOT (undo (const QWidget*))); connect (this, SIGNAL (fetab_redo (const QWidget*)), f, SLOT (redo (const QWidget*))); connect (this, SIGNAL (fetab_copy (const QWidget*)), f, SLOT (copy (const QWidget*))); connect (this, SIGNAL (fetab_cut (const QWidget*)), f, SLOT (cut (const QWidget*))); connect (this, SIGNAL (fetab_paste (const QWidget*)), f, SLOT (paste (const QWidget*))); connect (this, SIGNAL (fetab_save_file (const QWidget*)), f, SLOT (save_file (const QWidget*))); connect (this, SIGNAL (fetab_save_file_as (const QWidget*)), f, SLOT (save_file_as (const QWidget*))); connect (this, SIGNAL (fetab_run_file (const QWidget*)), f, SLOT (run_file (const QWidget*))); connect (this, SIGNAL (fetab_toggle_bookmark (const QWidget*)), f, SLOT (toggle_bookmark (const QWidget*))); connect (this, SIGNAL (fetab_next_bookmark (const QWidget*)), f, SLOT (next_bookmark (const QWidget*))); connect (this, SIGNAL (fetab_previous_bookmark (const QWidget*)), f, SLOT (previous_bookmark (const QWidget*))); connect (this, SIGNAL (fetab_remove_bookmark (const QWidget*)), f, SLOT (remove_bookmark (const QWidget*))); connect (this, SIGNAL (fetab_toggle_breakpoint (const QWidget*)), f, SLOT (toggle_breakpoint (const QWidget*))); connect (this, SIGNAL (fetab_next_breakpoint (const QWidget*)), f, SLOT (next_breakpoint (const QWidget*))); connect (this, SIGNAL (fetab_previous_breakpoint (const QWidget*)), f, SLOT (previous_breakpoint (const QWidget*))); connect (this, SIGNAL (fetab_remove_all_breakpoints (const QWidget*)), f, SLOT (remove_all_breakpoints (const QWidget*))); connect (this, SIGNAL (fetab_comment_selected_text (const QWidget*)), f, SLOT (comment_selected_text (const QWidget*))); connect (this, SIGNAL (fetab_uncomment_selected_text (const QWidget*)), f, SLOT (uncomment_selected_text (const QWidget*))); connect (this, SIGNAL (fetab_find (const QWidget*)), f, SLOT (find (const QWidget*))); _tab_widget->setCurrentWidget (f); }