GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
variable-editor.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2013-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_variable_editor_h)
27#define octave_variable_editor_h 1
28
29#include <QHeaderView>
30#include <QSignalMapper>
31#include <QStackedWidget>
32#include <QTableView>
33
34#include "dw-main-window.h"
35#include "gui-settings.h"
36#include "octave-dock-widget.h"
38#include "tab-bar.h"
39
40class octave_value;
41
42class QModelIndex;
43class QTextEdit;
44class QToolBar;
45
46namespace octave
47{
48 class base_qobject;
49
50 class variable_editor_model;
51 class variable_editor_view;
52
53 // The individual variable subwindow class
54
56 {
57 Q_OBJECT
58
59 public:
60
62
63 ~variable_dock_widget (void) = default;
64
65 signals:
66
67 void variable_focused_signal (const QString& name);
68
69 protected:
70
71 virtual void closeEvent (QCloseEvent *e);
72
73 void resizeEvent (QResizeEvent *event);
74
75 public slots:
76
77 void handle_focus_change (QWidget *old, QWidget *now);
78
79 private slots:
80
81 void change_floating (bool);
82
83 void change_existence (bool);
84
85 void toplevel_change (bool);
86
87 void change_fullscreen (void);
88
89 protected:
90
91 QFrame *m_frame;
92
94
96
98
100
101// See Octave bug #53807 and https://bugreports.qt.io/browse/QTBUG-44813
102#define QTBUG_44813_FIX_VERSION 0x999999
103 signals:
104
106
107 void queue_float (void);
108
109 protected slots:
110
111 void unfloat_float (void);
112
113 void refloat (void);
114
115#if (QT_VERSION >= 0x050302) && (QT_VERSION <= QTBUG_44813_FIX_VERSION)
116 protected:
117
118 bool event (QEvent *event);
119
120 private:
121
122 bool m_waiting_for_mouse_move;
123
124 bool m_waiting_for_mouse_button_release;
125#endif
126 };
127
129 {
130 Q_OBJECT
131
132 public:
133
135
136 ~variable_editor_stack (void) = default;
137
139
140 QTextEdit * disp_view (void) {return m_disp_view;};
141
142 signals:
143
144 void edit_variable_signal (const QString& name, const octave_value& val);
145
146 void do_save_signal (const QString& format, const QString& save_opts);
147
150
151 public slots:
152
153 void set_editable (bool editable);
154
155 void levelUp (void);
156
157 void save (const QString& format = QString ());
158
159 void do_save (const QString& format, const QString& save_opts);
160
161 private:
162
163 QTextEdit * make_disp_view (QWidget *parent);
164
166
168
170 };
171
172
174 {
175 Q_OBJECT
176
177 public:
178
180
181 ~variable_editor_view (void) = default;
182
183 void setModel (QAbstractItemModel *model);
184
185 signals:
186
187 void command_signal (const QString& cmd);
188
189 void add_edit_actions_signal (QMenu *menu, const QString& qualifier_string);
190
191 public slots:
192
193 void createVariable (void);
194
195 void transposeContent (void);
196
198
199 void delete_selected (void);
200
201 void clearContent (void);
202
203 void cutClipboard (void);
204
205 void copyClipboard (void);
206
207 void pasteClipboard (void);
208
209 void handle_horizontal_scroll_action (int action);
210
211 void handle_vertical_scroll_action (int action);
212
213 void createContextMenu (const QPoint& pt);
214
215 void createColumnMenu (const QPoint& pt);
216
217 void createRowMenu (const QPoint& pt);
218
219 void selected_command_requested (const QString& cmd);
220
221 private:
222
223 void add_edit_actions (QMenu *menu, const QString& qualifier_string);
224
226
228 };
229
230 // Gadgets to keep track of and restore what variable window was in focus
231 // just prior to selecting something on the menu bar.
232
234 {
235 Q_OBJECT
236
237 public:
238
239 HoverToolButton (QWidget *parent = nullptr);
240
241 ~HoverToolButton (void) = default;
242
243 signals:
244
245 void hovered_signal (void);
246
248
249 protected:
250
251 bool eventFilter (QObject *obj, QEvent *ev);
252 };
253
255 {
256 Q_OBJECT
257
258 public:
259
260 ReturnFocusToolButton (QWidget *parent = nullptr);
261
262 ~ReturnFocusToolButton (void) = default;
263
264 signals:
265
266 void about_to_activate (void);
267
268 protected:
269
270 bool eventFilter (QObject *obj, QEvent *ev);
271 };
272
273 class ReturnFocusMenu : public QMenu
274 {
275 Q_OBJECT
276
277 public:
278
279 ReturnFocusMenu (QWidget *parent = nullptr);
280
281 ~ReturnFocusMenu (void) = default;
282
283 signals:
284
285 void about_to_activate (void);
286
287 protected:
288
289 bool eventFilter (QObject *obj, QEvent *ev);
290 };
291
292 // The variable editor class
293
295 {
296 Q_OBJECT
297
298 public:
299
300 variable_editor (QWidget *parent, base_qobject& oct_qobj);
301
302 ~variable_editor (void);
303
304 // No copying!
305
307
309
310 void refresh (void);
311
312 void tab_to_front (void);
313
314 signals:
315
316 void updated (void);
317
318 void finished (void);
319
320 void command_signal (const QString& cmd);
321
322 void refresh_signal (void);
323
325
327
329
330 void level_up_signal (void);
331
332 void save_signal (void);
333
335
338
339 public slots:
340
341 void callUpdate (const QModelIndex&, const QModelIndex&);
342
343 void notice_settings (const gui_settings *);
344
345 void edit_variable (const QString& name, const octave_value& val);
346
347 void variable_destroyed (QObject *obj);
348
349 void variable_focused (const QString& name);
350
352
354
355 protected slots:
356
357 void closeEvent (QCloseEvent *);
358
359 void save (void);
360
361 void cutClipboard (void);
362
363 void copyClipboard (void);
364
365 void pasteClipboard (void);
366
367 void levelUp (void);
368
369 protected:
370
371 void focusInEvent (QFocusEvent *ev);
372
373 private:
374
376
377 QToolBar *m_tool_bar;
379
381
383
385
387
389
391
392 QFont m_font;
393
394 // If use_terminal_font is true then this will be different since
395 // "font" will contain the terminal font.
397
399
400 void update_colors (void);
401
402 QAction * add_tool_bar_button (const QIcon& icon, const QString& text,
403 const QObject *receiver, const char *member);
404
405 void construct_tool_bar (void);
406
408
410
411 QSignalMapper *m_plot_mapper;
412 QSignalMapper *m_save_mapper;
413
415
417 };
418}
419
420#endif
HoverToolButton(QWidget *parent=nullptr)
bool eventFilter(QObject *obj, QEvent *ev)
~HoverToolButton(void)=default
void popup_shown_signal(void)
bool eventFilter(QObject *obj, QEvent *ev)
void about_to_activate(void)
ReturnFocusMenu(QWidget *parent=nullptr)
~ReturnFocusMenu(void)=default
ReturnFocusToolButton(QWidget *parent=nullptr)
bool eventFilter(QObject *obj, QEvent *ev)
~ReturnFocusToolButton(void)=default
Base class for Octave interfaces that use Qt.
void resizeEvent(QResizeEvent *event)
variable_dock_widget(QWidget *p, base_qobject &oct_qobj)
void handle_focus_change(QWidget *old, QWidget *now)
~variable_dock_widget(void)=default
virtual void closeEvent(QCloseEvent *e)
void variable_focused_signal(const QString &name)
void do_save(const QString &format, const QString &save_opts)
void edit_variable_signal(const QString &name, const octave_value &val)
variable_editor_view * m_edit_view
void do_save_signal(const QString &format, const QString &save_opts)
variable_editor_stack(QWidget *p, base_qobject &oct_qobj)
~variable_editor_stack(void)=default
void save(const QString &format=QString())
void interpreter_event(const meth_callback &meth)
void interpreter_event(const fcn_callback &fcn)
variable_editor_view * edit_view(void)
void set_editable(bool editable)
QTextEdit * make_disp_view(QWidget *parent)
void add_edit_actions(QMenu *menu, const QString &qualifier_string)
QList< int > range_selected(void)
void createColumnMenu(const QPoint &pt)
void selected_command_requested(const QString &cmd)
~variable_editor_view(void)=default
void command_signal(const QString &cmd)
variable_editor_model * m_var_model
void createContextMenu(const QPoint &pt)
variable_editor_view(QWidget *p, base_qobject &oct_qobj)
void add_edit_actions_signal(QMenu *menu, const QString &qualifier_string)
void handle_vertical_scroll_action(int action)
void createRowMenu(const QPoint &pt)
void setModel(QAbstractItemModel *model)
void handle_horizontal_scroll_action(int action)
void variable_destroyed(QObject *obj)
void clear_content_signal(void)
void closeEvent(QCloseEvent *)
void copy_clipboard_signal(void)
void record_hovered_focus_variable(void)
void interpreter_event(const fcn_callback &fcn)
QList< QColor > m_table_colors
QAction * add_tool_bar_button(const QIcon &icon, const QString &text, const QObject *receiver, const char *member)
variable_editor(QWidget *parent, base_qobject &oct_qobj)
void notice_settings(const gui_settings *)
variable_editor & operator=(const variable_editor &)=delete
void interpreter_event(const meth_callback &meth)
variable_dock_widget * m_focus_widget_vdw
dw_main_window * m_main
variable_editor(const variable_editor &)=delete
void paste_clipboard_signal(void)
QSignalMapper * m_save_mapper
void edit_variable(const QString &name, const octave_value &val)
void focusInEvent(QFocusEvent *ev)
void delete_selected_signal(void)
void command_signal(const QString &cmd)
void restore_hovered_focus_variable(void)
void callUpdate(const QModelIndex &, const QModelIndex &)
void variable_focused(const QString &name)
QSignalMapper * m_plot_mapper
OCTAVE_NAMESPACE_BEGIN typedef std::function< void(void)> fcn_callback
Definition: event-manager.h:47
std::function< void(interpreter &)> meth_callback
Definition: event-manager.h:48
QString name
std::size_t format(std::ostream &os, const char *fmt,...)
Definition: utils.cc:1471