annotate libgui/src/octave-qt-link.h @ 16468:0f143f68078d

use signal/slot for updating workspace instead of using event listener * main-window.h, main-window.cc: Clean up list of include files. (main_window::prepare_to_exit): Rename from prepare_to_quit. Change all uses. (main_window::update_workspace): Delete. (main_window::construct): Don't connect _octave_qt_event_listener:update_workspace_signal to main_window::update_workspace. (main_window::construct_octave_qt_link): Connect _octave_qt_link::set_workspace_signal to _workspace_model::set_workspace. Connect _octave_qt_link::clear_workspace_signal to _workspace_model::clear_workspace. * symbol-information.h, symbol-information.cc: Delete * libgui/src/module.mk (noinst_HEADERS, src_libgui_src_la_SOURCES): Remove them from the lists. * octave-qt-link.h, octave-qt-link.cc: Don't use symbol_information to store workspace info. (octave_qt_link::do_update_workspace): Delete. (octave_qt_link::do_set_workspace, octave_qt_link::do_clear_workspace): New functions. (octave_qt_link::do_pre_input_event): Don't call do_update_workspace. (octave_qt_link::set_workspace_signal, octave_qt_link::clear_workspace_signal): New signals. * workspace-model.h, workspace-model.cc: Don't use symbol_information to store workspace info. Accept workspace info through a signal/slot combination, not by asking the symbol table. (workspace_model::request_update_workspace, (workspace_model::update_workspace_callback): Delete. (workspace_model::set_workspace, workspace_model::clear_workspace, workspace_model::clear_data, workspace_model::clear_tree, workspace_model::update_tree, workspace_model::append_tree): New functions. * workspace-view.h, workspace-view.cc (workspace_view::model_changed): Don't call update_workspace_callback. The model now signals the view when it has changed. * input.cc (octave_base_reader::octave_gets, get_debug_input): Call octave_link::set_workspace just prior to prompting for input. * workspace-element.h: New file. * libinterp/interpfcn/module.mk (INTERPFCN_INC): Include it in the list. * octave-link.cc: Don't include symtab.h. * octave-link.h (octave_link::update_workspace): Delete. (octave_link::set_workspace, octave_link::do_set_workspace, * octave_link::clear_workspace, octave_link::do_clear_workspace): New functions. * symtab.h, symtab.cc (symbol_table::workspace_info, symbol_table::do_workspace_info): New functions. * ov.h (octave_value::short_disp): New function. * ov-base.h, ov-base.cc (octave_base_value::short_disp): New function. * ov-base-scalar.h, ov-base-scalar.cc (octave_base_scalar<ST>::short_disp): New function. * ov-range.h, ov-range.cc (octave_range::short_disp): New function.
author John W. Eaton <jwe@octave.org>
date Mon, 08 Apr 2013 12:01:24 -0400
parents 7a2ee6ea7800
children 7a71ea0b7ae9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 2013 John W. Eaton
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 Copyright (C) 2011-2012 Jacob Dawid
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 Copyright (C) 2011-2012 John P. Swensen
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 This file is part of Octave.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 option) any later version.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 for more details.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 along with Octave; see the file COPYING. If not, see
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 <http://www.gnu.org/licenses/>.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 */
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #ifndef OCTAVE_QT_LINK_H
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #define OCTAVE_QT_LINK_H
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
28 #include <list>
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <string>
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
31 #include <QList>
16423
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
32 #include <QObject>
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
33 #include <QString>
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
34
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include "octave-link.h"
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "octave-main-thread.h"
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 // \class OctaveLink
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 // \brief Provides threadsafe access to octave.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 // \author Jacob Dawid
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 //
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 // This class is a wrapper around octave and provides thread safety by
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 // buffering access operations to octave and executing them in the
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 // readline event hook, which lives in the octave thread.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45
16423
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
46 class octave_qt_link : public QObject, public octave_link
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 {
16423
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
48 Q_OBJECT
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
49
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 public:
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 octave_qt_link (void);
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 ~octave_qt_link (void) { }
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
16432
fe4cd846c3e7 separate octave interpreter thread creation from execution
John W. Eaton <jwe@octave.org>
parents: 16431
diff changeset
56 void execute_interpreter (void);
fe4cd846c3e7 separate octave interpreter thread creation from execution
John W. Eaton <jwe@octave.org>
parents: 16431
diff changeset
57
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
58 bool do_edit_file (const std::string& file);
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
59
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
60 void do_change_directory (const std::string& dir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
61
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
62 void do_set_workspace (const std::list<workspace_element>& ws);
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
63 void do_clear_workspace (void);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
65 void do_set_history (const string_vector& hist);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
66 void do_append_history (const std::string& hist_entry);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
67 void do_clear_history (void);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 void do_pre_input_event (void);
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 void do_post_input_event (void);
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16415
diff changeset
72 void do_enter_debugger_event (const std::string& file, int line);
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
73 void do_execute_in_debugger_event (const std::string& file, int line);
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
74 void do_exit_debugger_event (void);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16415
diff changeset
76 void do_update_breakpoint (bool insert, const std::string& file, int line);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 private:
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 // No copying!
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 octave_qt_link (const octave_qt_link&);
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 octave_qt_link& operator = (const octave_qt_link&);
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
16426
203976ae18d1 use signals for octave_link::enter_debugger_event and octave_link::exit_debugger_event
John W. Eaton <jwe@octave.org>
parents: 16424
diff changeset
86 void do_insert_debugger_pointer (const std::string& file, int line);
203976ae18d1 use signals for octave_link::enter_debugger_event and octave_link::exit_debugger_event
John W. Eaton <jwe@octave.org>
parents: 16424
diff changeset
87 void do_delete_debugger_pointer (const std::string& file, int line);
203976ae18d1 use signals for octave_link::enter_debugger_event and octave_link::exit_debugger_event
John W. Eaton <jwe@octave.org>
parents: 16424
diff changeset
88
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 // Thread running octave_main.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 octave_main_thread *main_thread;
16423
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
91
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
92 signals:
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
93
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
94 void edit_file_signal (const QString& file);
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
95
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
96 void change_directory_signal (const QString& dir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
97
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
98 void set_workspace_signal (const QString& scopes,
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
99 const QStringList& symbols,
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
100 const QStringList& class_names,
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
101 const QStringList& dimensions,
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
102 const QStringList& values);
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
103
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
104 void clear_workspace_signal (void);
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
105
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
106 void set_history_signal (const QStringList& hist);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
107 void append_history_signal (const QString& hist_entry);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
108 void clear_history_signal (void);
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
109
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
110 void enter_debugger_signal (void);
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
111 void exit_debugger_signal (void);
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
112
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
113 void update_breakpoint_marker_signal (bool insert, const QString& file,
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
114 int line);
16426
203976ae18d1 use signals for octave_link::enter_debugger_event and octave_link::exit_debugger_event
John W. Eaton <jwe@octave.org>
parents: 16424
diff changeset
115
203976ae18d1 use signals for octave_link::enter_debugger_event and octave_link::exit_debugger_event
John W. Eaton <jwe@octave.org>
parents: 16424
diff changeset
116 void insert_debugger_pointer_signal (const QString&, int);
203976ae18d1 use signals for octave_link::enter_debugger_event and octave_link::exit_debugger_event
John W. Eaton <jwe@octave.org>
parents: 16424
diff changeset
117 void delete_debugger_pointer_signal (const QString&, int);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 };
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
16422
436f6e0e4268 include file cleanup for octave-qt-link files
John W. Eaton <jwe@octave.org>
parents: 16420
diff changeset
120 #endif