changeset 21148:e8c3590da9ff

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
author Torsten <ttl@justmail.de>
date Fri, 29 Jan 2016 06:24:34 +0100
parents 95feb42d7a97
children 7962dbca527f
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc libgui/src/main-window.cc libgui/src/main-window.h libgui/src/octave-cmd.cc libgui/src/octave-cmd.h libgui/src/octave-qt-link.cc libgui/src/octave-qt-link.h
diffstat 9 files changed, 27 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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 <QDialogButtonBox>
 #include <QPushButton>
 
+#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<main_window*> (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);
 }
 
--- 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;
--- 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);
--- 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);
 }
 
--- 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 *);
--- 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
--- 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;
 };
 
 
--- 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;
 
--- 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);