# HG changeset patch # User Torsten # Date 1454045074 -3600 # Node ID e8c3590da9ff7f67726fccb300fbe26e7aead9b3 # Parent 95feb42d7a975bd81283707cb8be70a52f25fe0a update directory in gui after add-path/change-dir dialog * file-editor-tab.cc (file_editor_tab): get main window from editor which is given as argument; (add_breakpoint_callback, remove_breakpoint_callback, remove_all_breakpoints_callback): call file_in_path via the instance of octave_qt_link since it is not static anymore * file-editor-tab.h: include main-window.h, contructor gets editor widget as first argument, store the main window widget in a class variable * file-editor.cc (request_new_file, request_open_file): pass own pointer to a new file editor tab * main-window.cc (run_file_callback): pass the instance of octave_qt_link to the octave cmd * main-window.h: new function returning the instance of octave_qt_link * octave-cmd.cc (execute): call file_in_path via instance (not static) * octave-cmd.h: instance of octave_qt_link is given as argument and stored in a class variable * octave-qt-link.cc (file_in_path): update gui directory when user wants to change the directory * octave-qt-link.h: file_in_path is normal memebr, not static anymore diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/m-editor/file-editor-tab.cc Fri Jan 29 06:24:34 2016 +0100 @@ -61,14 +61,14 @@ #include #include +#include "file-ops.h" + #include "resource-manager.h" #include "file-editor-tab.h" #include "file-editor.h" #include "octave-txt-lexer.h" #include "marker.h" -#include "file-ops.h" - #include "debug.h" #include "octave-qt-link.h" #include "version.h" @@ -86,13 +86,15 @@ */ // Make parent null for the file editor tab so that warning // WindowModal messages don't affect grandparents. -file_editor_tab::file_editor_tab (const QString& directory_arg) +file_editor_tab::file_editor_tab (octave_dock_widget *editor, + const QString& directory_arg) { _lexer_apis = 0; _is_octave_file = true; _lines_changed = false; _ced = directory_arg; + _main_win = static_cast (editor->parent ()); _file_name = ""; _file_system_watcher.setObjectName ("_qt_autotest_force_engine_poller"); @@ -842,7 +844,7 @@ bp_table::intmap line_info; line_info[0] = info.line; - if (octave_qt_link::file_in_path (info.file, info.dir)) + if (_main_win->get_octave_qt_link ()->file_in_path (info.file, info.dir)) bp_table::add_breakpoint (info.function_name, line_info); } @@ -852,14 +854,14 @@ bp_table::intmap line_info; line_info[0] = info.line; - if (octave_qt_link::file_in_path (info.file, info.dir)) + if (_main_win->get_octave_qt_link ()->file_in_path (info.file, info.dir)) bp_table::remove_breakpoint (info.function_name, line_info); } void file_editor_tab::remove_all_breakpoints_callback (const bp_info& info) { - if (octave_qt_link::file_in_path (info.file, info.dir)) + if (_main_win->get_octave_qt_link ()->file_in_path (info.file, info.dir)) bp_table::remove_all_breakpoints_in_file (info.function_name, true); } diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/m-editor/file-editor-tab.h Fri Jan 29 06:24:34 2016 +0100 @@ -43,6 +43,7 @@ #include "find-dialog.h" #include "octave-qscintilla.h" #include "builtin-defun-decls.h" +#include "main-window.h" #include "marker.h" /* Only needed for typedef of "QIntList", which may be typedefed elsewhere. Could use common location. */ @@ -56,7 +57,7 @@ public: - file_editor_tab (const QString& directory = ""); + file_editor_tab (octave_dock_widget *editor, const QString& directory = ""); ~file_editor_tab (void); @@ -254,6 +255,7 @@ void update_eol_indicator (); octave_qscintilla *_edit_area; + main_window *_main_win; QStatusBar *_status_bar; QLabel *_row_indicator; diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/m-editor/file-editor.cc Fri Jan 29 06:24:34 2016 +0100 @@ -201,7 +201,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 (ced); + file_editor_tab *fileEditorTab = new file_editor_tab (this, ced); if (fileEditorTab) { add_file_editor_tab (fileEditorTab, ""); // new tab with empty title @@ -451,7 +451,7 @@ } else { - file_editor_tab *fileEditorTab = new file_editor_tab (); + file_editor_tab *fileEditorTab = new file_editor_tab (this); if (fileEditorTab) { fileEditorTab->set_encoding (encoding); diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/main-window.cc --- a/libgui/src/main-window.cc Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/main-window.cc Fri Jan 29 06:24:34 2016 +0100 @@ -338,7 +338,7 @@ void main_window::run_file_callback (const QFileInfo& info) { - octave_cmd_eval *cmd = new octave_cmd_eval (info); + octave_cmd_eval *cmd = new octave_cmd_eval (info, _octave_qt_link); _cmd_queue.add_cmd (cmd); } diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/main-window.h --- a/libgui/src/main-window.h Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/main-window.h Fri Jan 29 06:24:34 2016 +0100 @@ -82,6 +82,8 @@ void focus_command_window (void); + octave_qt_link* get_octave_qt_link () { return _octave_qt_link; }; + signals: void active_dock_changed (octave_dock_widget *, octave_dock_widget *); diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/octave-cmd.cc --- a/libgui/src/octave-cmd.cc Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/octave-cmd.cc Fri Jan 29 06:24:34 2016 +0100 @@ -33,6 +33,7 @@ #include "builtin-defun-decls.h" #include "utils.h" +#include "main-window.h" // --------------------------------------------------------------------- // class octave_cmd_exec: executing a command @@ -65,7 +66,7 @@ { // valid identifier: call as function with possibility to debug std::string path = _info.absolutePath ().toStdString (); - if (octave_qt_link::file_in_path (file_path, path)) + if (_octave_qt_link->file_in_path (file_path, path)) command_editor::replace_line (function_name.toStdString ()); } else diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/octave-cmd.h --- a/libgui/src/octave-cmd.h Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/octave-cmd.h Fri Jan 29 06:24:34 2016 +0100 @@ -66,12 +66,18 @@ { public: - octave_cmd_eval (const QFileInfo& info) : octave_cmd () { _info = info; }; + octave_cmd_eval (const QFileInfo& info, + octave_qt_link* octave_qt_link) : octave_cmd () + { _info = info; + _octave_qt_link = octave_qt_link; + }; + void execute (); protected: QFileInfo _info; + octave_qt_link *_octave_qt_link; }; diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/octave-qt-link.cc --- a/libgui/src/octave-qt-link.cc Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/octave-qt-link.cc Fri Jan 29 06:24:34 2016 +0100 @@ -617,6 +617,7 @@ { case 1: Fcd (ovl (dir)); + update_directory (); ok = true; break; diff -r 95feb42d7a97 -r e8c3590da9ff libgui/src/octave-qt-link.h --- a/libgui/src/octave-qt-link.h Thu Jan 28 14:37:54 2016 -0500 +++ b/libgui/src/octave-qt-link.h Fri Jan 29 06:24:34 2016 +0100 @@ -129,7 +129,7 @@ void do_set_default_prompts (std::string& ps1, std::string& ps2, std::string& ps4); - static bool file_in_path (const std::string& file, const std::string& dir); + bool file_in_path (const std::string& file, const std::string& dir); void do_show_preferences (void);