GNU Octave  6.2.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-2021 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"
37 #include "tab-bar.h"
38 
39 class octave_value;
40 
41 class QModelIndex;
42 class QTextEdit;
43 class QToolBar;
44 
45 namespace octave
46 {
47  class base_qobject;
48 
49  class variable_editor_model;
50  class variable_editor_view;
51 
52  // The individual variable subwindow class
53 
55  {
56  Q_OBJECT
57 
58  public:
59 
61 
62  signals:
63 
64  void variable_focused_signal (const QString& name);
65 
66  protected:
67 
68  virtual void closeEvent (QCloseEvent *e);
69 
70  void resizeEvent (QResizeEvent *event);
71 
72  public slots:
73 
74  void handle_focus_change (QWidget *old, QWidget *now);
75 
76  private slots:
77 
78  void change_floating (bool);
79 
80  void change_existence (bool);
81 
82  void toplevel_change (bool);
83 
84  void change_fullscreen (void);
85 
86  protected:
87 
88  QFrame *m_frame;
89 
90 #if defined (HAVE_QGUIAPPLICATION)
91 
92  QAction *m_fullscreen_action;
93 
94  bool m_full_screen;
95 
96  bool m_prev_floating;
97 
98  QRect m_prev_geom;
99 
100 #endif
101 
102 // See Octave bug #53807 and https://bugreports.qt.io/browse/QTBUG-44813
103 #define QTBUG_44813_FIX_VERSION 0x999999
104  signals:
105 
106  void queue_unfloat_float (void);
107 
108  void queue_float (void);
109 
110  protected slots:
111 
112  void unfloat_float (void);
113 
114  void refloat (void);
115 
116 #if (QT_VERSION >= 0x050302) && (QT_VERSION <= QTBUG_44813_FIX_VERSION)
117  protected:
118 
119  bool event (QEvent *event);
120 
121  private:
122 
123  bool m_waiting_for_mouse_move;
124 
125  bool m_waiting_for_mouse_button_release;
126 #endif
127  };
128 
130  {
131  Q_OBJECT
132 
133  public:
134 
136 
138 
139  QTextEdit *disp_view (void) {return m_disp_view;};
140 
141  signals:
142 
143  void command_signal (const QString& cmd);
144 
145  void edit_variable_signal (const QString& name, const octave_value& val);
146 
147  public slots:
148 
149  void set_editable (bool editable);
150 
151  void levelUp (void);
152 
153  void save (void);
154 
155  private:
156 
157  QTextEdit *make_disp_view (QWidget *parent);
158 
160 
162 
164  };
165 
166 
168  {
169  Q_OBJECT
170 
171  public:
172 
173  variable_editor_view (QWidget *p, base_qobject& oct_qobj);
174 
175  void setModel (QAbstractItemModel *model);
176 
177  signals:
178 
179  void command_signal (const QString& cmd);
180 
181  void add_edit_actions_signal (QMenu *menu, const QString& qualifier_string);
182 
183  public slots:
184 
185  void createVariable (void);
186 
187  void transposeContent (void);
188 
189  QList<int> range_selected (void);
190 
191  void delete_selected (void);
192 
193  void clearContent (void);
194 
195  void cutClipboard (void);
196 
197  void copyClipboard (void);
198 
199  void pasteClipboard (void);
200 
201  void handle_horizontal_scroll_action (int action);
202 
203  void handle_vertical_scroll_action (int action);
204 
205  void createContextMenu (const QPoint& pt);
206 
207  void createColumnMenu (const QPoint& pt);
208 
209  void createRowMenu (const QPoint& pt);
210 
211  void selected_command_requested (const QString& cmd);
212 
213  private:
214 
215  void add_edit_actions (QMenu *menu, const QString& qualifier_string);
216 
218 
220  };
221 
222  // Gadgets to keep track of and restore what variable window was in focus
223  // just prior to selecting something on the menu bar.
224 
226  {
227  Q_OBJECT
228 
229  public:
230 
231  HoverToolButton (QWidget *parent = nullptr);
232 
233  signals:
234 
235  void hovered_signal (void);
236 
237  void popup_shown_signal (void);
238 
239  protected:
240 
241  bool eventFilter (QObject *obj, QEvent *ev);
242  };
243 
245  {
246  Q_OBJECT
247 
248  public:
249 
250  ReturnFocusToolButton (QWidget *parent = nullptr);
251 
252  signals:
253 
254  void about_to_activate (void);
255 
256  protected:
257 
258  bool eventFilter (QObject *obj, QEvent *ev);
259  };
260 
261  class ReturnFocusMenu : public QMenu
262  {
263  Q_OBJECT
264 
265  public:
266 
267  ReturnFocusMenu (QWidget *parent = nullptr);
268 
269  signals:
270 
271  void about_to_activate (void);
272 
273  protected:
274 
275  bool eventFilter (QObject *obj, QEvent *ev);
276  };
277 
278  // The variable editor class
279 
281  {
282  Q_OBJECT
283 
284  public:
285 
286  variable_editor (QWidget *parent, base_qobject& oct_qobj);
287 
288  ~variable_editor (void) = default;
289 
290  // No copying!
291 
292  variable_editor (const variable_editor&) = delete;
293 
295 
296  void refresh (void);
297 
298  void tab_to_front (void);
299 
300  signals:
301 
302  void updated (void);
303 
304  void finished (void);
305 
306  void command_signal (const QString& cmd);
307 
308  void refresh_signal (void);
309 
310  void clear_content_signal (void);
311 
313 
315 
316  void level_up_signal (void);
317 
318  void save_signal (void);
319 
321 
322  public slots:
323 
324  void callUpdate (const QModelIndex&, const QModelIndex&);
325 
326  void notice_settings (const gui_settings *);
327 
328  void edit_variable (const QString& name, const octave_value& val);
329 
330  void variable_destroyed (QObject *obj);
331 
332  void variable_focused (const QString& name);
333 
334  void record_hovered_focus_variable (void);
335 
336  void restore_hovered_focus_variable (void);
337 
338  protected slots:
339 
340  void closeEvent (QCloseEvent *);
341 
342  void save (void);
343 
344  void cutClipboard (void);
345 
346  void copyClipboard (void);
347 
348  void pasteClipboard (void);
349 
350  void levelUp (void);
351 
352  protected:
353 
354  void focusInEvent (QFocusEvent *ev);
355 
356  private:
357 
358  QAction * add_action (QMenu *menu, const QIcon& icon, const QString& text,
359  const char *member);
360 
362 
363  QToolBar *m_tool_bar;
364 
366 
368 
370 
372 
374 
375  QString m_stylesheet;
376 
377  QFont m_font;
378 
379  // If use_terminal_font is true then this will be different since
380  // "font" will contain the terminal font.
381  QFont m_sel_font;
382 
384 
385  void update_colors (void);
386 
387  QAction *add_tool_bar_button (const QIcon &icon, const QString &text,
388  const QObject *receiver, const char *member);
389 
390  void construct_tool_bar (void);
391 
393 
395 
396  QSignalMapper *m_plot_mapper;
397 
399 
401  };
402 }
403 
404 #endif
HoverToolButton(QWidget *parent=nullptr)
bool eventFilter(QObject *obj, QEvent *ev)
void popup_shown_signal(void)
bool eventFilter(QObject *obj, QEvent *ev)
void about_to_activate(void)
ReturnFocusMenu(QWidget *parent=nullptr)
ReturnFocusToolButton(QWidget *parent=nullptr)
bool eventFilter(QObject *obj, QEvent *ev)
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)
virtual void closeEvent(QCloseEvent *e)
void variable_focused_signal(const QString &name)
void edit_variable_signal(const QString &name, const octave_value &val)
variable_editor_view * m_edit_view
variable_editor_stack(QWidget *p, base_qobject &oct_qobj)
variable_editor_view * edit_view(void)
void command_signal(const QString &cmd)
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)
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 *)
QAction * add_action(QMenu *menu, const QIcon &icon, const QString &text, const char *member)
void copy_clipboard_signal(void)
void record_hovered_focus_variable(void)
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(void)=default
variable_dock_widget * m_focus_widget_vdw
dw_main_window * m_main
variable_editor & operator=(const variable_editor &)=delete
variable_editor(const variable_editor &)=delete
void paste_clipboard_signal(void)
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
QString name