annotate libgui/src/octave-qt-link.h @ 16502:45ae1038ee89

allow renaming of variables in workspace viewer * main-window.h, main-window.cc (main_window::handle_rename_variable_request): New function. (main_window::construct_octave_qt_link): Connect _workspace_model::rename_variable to main_window::handle_rename_variable_request. (main_window::rename_variable_callback): New function. * octave-qt-link.h, octave-qt-link.cc (octave_qt_link::do_set_workspace, octave_qt_link::set_workspace_signal): New argument, top_level. Change all uses. * octave-link.h, octave-link.cc (octave_link::post_event): Provide two-argument version. (octave_link::set_workspace, octave_link::do_set_workspace): New argument, top_level. Change all uses. * workspace-model.h, workspace-model.cc (workspace_model::flags): Conditionally add Qt::ItemIsEditable to flags. (workspace_model::data): Also return value for column 0 if it is editable. (workspace_model::setData): Handle setting new values. (workspace_model::_top_level): New data member. (workspace_model::set_workspace): New argument, top_level. (workspace_model::rename_variable): New signal. * workspace-view.h, workspace-view.cc (variable_name_editor): New class. (workspace_view::var_name_editor): New data member. (workspace_view::workspace_view): Initialize it. Set var_name_editor as delegate for column 0. (workspace_view::~workspace_view): Delete var_name_editor. (workspace_view::item_double_clicked): Delete. * symtab.h (symbol_table::rename, symbol_table::do_rename, symbol_table::symbol_record::rename): New functions.
author John W. Eaton <jwe@octave.org>
date Fri, 12 Apr 2013 14:50:56 -0400
parents 8b783661e03f
children 7f2395651a1c
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
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16479
diff changeset
52 octave_qt_link (octave_main_thread *mt);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53
16479
7a71ea0b7ae9 eliminate event listener class
John W. Eaton <jwe@octave.org>
parents: 16468
diff changeset
54 ~octave_qt_link (void);
16415
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
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16479
diff changeset
58 bool do_exit (int status);
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16479
diff changeset
59
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
60 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
61
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
62 void do_change_directory (const std::string& dir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
63
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
64 void do_set_workspace (bool top_level,
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
65 const std::list<workspace_element>& ws);
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
66
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
67 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
68
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
69 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
70 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
71 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
72
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 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
74 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
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_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
77 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
78 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
79
16419
16bfbf9136d3 avoid creating unnecessary octave_value objects for octave_link calls
John W. Eaton <jwe@octave.org>
parents: 16415
diff changeset
80 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
81
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 private:
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 // No copying!
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 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
87
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 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
89
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
90 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
91 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
92
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 // Thread running octave_main.
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 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
95
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
96 signals:
04c4dd7fd3ce use signal for octave_link::update_dbstop_marker
John W. Eaton <jwe@octave.org>
parents: 16422
diff changeset
97
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16479
diff changeset
98 void exit_signal (int status);
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16479
diff changeset
99
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
100 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
101
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
102 void change_directory_signal (const QString& dir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
103
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
104 void set_workspace_signal (bool top_level,
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
105 const QString& scopes,
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
106 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
107 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
108 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
109 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
110
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
111 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
112
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
113 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
114 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
115 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
116
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
117 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
118 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
119
16443
7a2ee6ea7800 rename dbstop -> breakpoint in GUI interface functions
John W. Eaton <jwe@octave.org>
parents: 16438
diff changeset
120 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
121 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
122
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
123 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
124 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
125 };
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126
16422
436f6e0e4268 include file cleanup for octave-qt-link files
John W. Eaton <jwe@octave.org>
parents: 16420
diff changeset
127 #endif