Mercurial > octave
changeset 27400:7cf857166440
connect signals when creating file_editor_tab in file editor
* file-editor.h, file-editor.cc (file_editor::make_file_editor_tab):
New function. Create file_editor_tab object and connect signals.
(file_editor::add_file_editor_tab): Don't connect signals here.
(file_editor::request_new_file, file_editor::request_open_file):
Use make_file_editor_tab instead of creating object directly with new.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 12 Sep 2019 17:01:34 -0400 |
parents | fe6a64dc8605 |
children | 1f595192b5a5 |
files | libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h |
diffstat | 2 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc Thu Sep 12 13:30:05 2019 -0400 +++ b/libgui/src/m-editor/file-editor.cc Thu Sep 12 17:01:34 2019 -0400 @@ -467,7 +467,7 @@ // 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 (m_ced); + file_editor_tab *fileEditorTab = make_file_editor_tab (m_ced); add_file_editor_tab (fileEditorTab, ""); // new tab with empty title fileEditorTab->new_file (commands); // title is updated here activate (); // focus editor and new tab @@ -1410,7 +1410,7 @@ // If <unnamed> was absent or modified, create a new tab. if (! fileEditorTab) - fileEditorTab = new file_editor_tab (); + fileEditorTab = make_file_editor_tab (); fileEditorTab->set_encoding (encoding); QString result = fileEditorTab->load_file (openFileName); @@ -2234,13 +2234,10 @@ check_actions (); } - void file_editor::add_file_editor_tab (file_editor_tab *f, const QString& fn, - int index) + file_editor_tab * + file_editor::make_file_editor_tab (const QString& directory) { - if (index == -1) - m_tab_widget->addTab (f, fn); - else - m_tab_widget->insertTab (index, f, fn); + file_editor_tab *f = new file_editor_tab (directory); // signals from the qscintilla edit area connect (f->qsci_edit_area (), SIGNAL (status_update (bool, bool)), @@ -2440,6 +2437,17 @@ connect (f, SIGNAL (interpreter_event (const meth_callback&)), this, SIGNAL (interpreter_event (const meth_callback&))); + return f; + } + + void file_editor::add_file_editor_tab (file_editor_tab *f, const QString& fn, + int index) + { + if (index == -1) + m_tab_widget->addTab (f, fn); + else + m_tab_widget->insertTab (index, f, fn); + m_tab_widget->setCurrentWidget (f); check_actions ();
--- a/libgui/src/m-editor/file-editor.h Thu Sep 12 13:30:05 2019 -0400 +++ b/libgui/src/m-editor/file-editor.h Thu Sep 12 17:01:34 2019 -0400 @@ -320,6 +320,8 @@ private: + file_editor_tab * make_file_editor_tab (const QString& directory = ""); + bool is_editor_console_tabbed (void); void construct (void); void add_file_editor_tab (file_editor_tab *f, const QString& fn,