GNU Octave  4.4.1
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-2018 John W. Eaton
4 Copyright (C) 2015 Michael Barnes
5 Copyright (C) 2013 RĂ¼diger Sonderfeld
6 
7 This file is part of Octave.
8 
9 Octave is free software: you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation, either version 3 of the License, or (at your
12 option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <https://www.gnu.org/licenses/>.
22 
23 */
24 
25 #if ! defined (variable_editor_h)
26 #define variable_editor_h 1
27 
28 #include <QHeaderView>
29 #include <QSettings>
30 #include <QStackedWidget>
31 #include <QTableView>
32 
33 #include "octave-dock-widget.h"
34 #include "tab-bar.h"
35 
36 class octave_value;
37 
38 class QModelIndex;
39 class QTextEdit;
40 class QToolBar;
41 
42 namespace octave
43 {
44  class variable_editor_model;
45  class variable_editor_view;
46 
47  // The individual variable subwindow class
48 
50  {
51  Q_OBJECT
52 
53  public:
54 
55  variable_dock_widget (QWidget *p = nullptr);
56 
57  signals:
58 
59  void variable_focused_signal (const QString& name);
60 
61  protected:
62 
63  virtual void closeEvent (QCloseEvent *e);
64 
65  void resizeEvent (QResizeEvent *event);
66 
67  public slots:
68 
69  void handle_focus_change (QWidget *old, QWidget *now);
70 
71  private slots:
72 
73  void change_floating (bool);
74 
75  void change_existence (bool);
76 
77  void toplevel_change (bool);
78 
79  void change_fullscreen (void);
80 
81  protected:
82 
83  QFrame *m_frame;
84 
85 #if defined (HAVE_QGUIAPPLICATION)
86 
87  QAction *m_fullscreen_action;
88 
89  bool m_full_screen;
90 
91  bool m_prev_floating;
92 
93  QRect m_prev_geom;
94 
95 #endif
96  };
97 
99  {
100  Q_OBJECT
101 
102  public:
103 
104  variable_editor_stack (QWidget *p = nullptr);
105 
107 
108  QTextEdit *disp_view (void) {return m_disp_view;};
109 
110  signals:
111 
112  void command_signal (const QString& cmd);
113 
114  void edit_variable_signal (const QString& name, const octave_value& val);
115 
116  public slots:
117 
118  void set_editable (bool editable);
119 
120  void levelUp (void);
121 
122  void save (void);
123 
124  private:
125 
126  QTextEdit *make_disp_view (QWidget *parent);
127 
129 
131  };
132 
133 
135  {
136  Q_OBJECT
137 
138  public:
139 
140  variable_editor_view (QWidget *p = nullptr);
141 
142  void setModel (QAbstractItemModel *model);
143 
144  signals:
145 
146  void command_signal (const QString& cmd);
147 
148  void add_edit_actions_signal (QMenu *menu, const QString& qualifier_string);
149 
150  public slots:
151 
152  void createVariable (void);
153 
154  void transposeContent (void);
155 
156  QList<int> range_selected (void);
157 
158  void delete_selected (void);
159 
160  void clearContent (void);
161 
162  void cutClipboard (void);
163 
164  void copyClipboard (void);
165 
166  void pasteClipboard (void);
167 
168  void pasteTableClipboard (void);
169 
170  void handle_horizontal_scroll_action (int action);
171 
172  void handle_vertical_scroll_action (int action);
173 
174  void createContextMenu (const QPoint& pt);
175 
176  void createColumnMenu (const QPoint& pt);
177 
178  void createRowMenu (const QPoint& pt);
179 
180  // Convert selection to an Octave expression.
181  QString selected_to_octave (void);
182 
183  void selected_command_requested (const QString& cmd);
184 
185  private:
186 
187  void add_edit_actions (QMenu *menu, const QString& qualifier_string);
188 
190  };
191 
192  // Gadgets to keep track and restore what variable window
193  // was in focus just prior to selecting something on the
194  // menu bar
195 
197  {
198  Q_OBJECT
199 
200  public:
201 
202  HoverToolButton (QWidget *parent = nullptr);
203 
204  signals:
205 
206  void hovered_signal (void);
207 
208  void popup_shown_signal (void);
209 
210  protected:
211 
212  bool eventFilter (QObject *obj, QEvent *ev);
213  };
214 
216  {
217  Q_OBJECT
218 
219  public:
220 
221  ReturnFocusToolButton (QWidget *parent = nullptr);
222 
223  signals:
224 
225  void about_to_activate (void);
226 
227  protected:
228 
229  bool eventFilter (QObject *obj, QEvent *ev);
230  };
231 
232  class ReturnFocusMenu : public QMenu
233  {
234  Q_OBJECT
235 
236  public:
237 
238  ReturnFocusMenu (QWidget *parent = nullptr);
239 
240  signals:
241 
242  void about_to_activate (void);
243 
244  protected:
245 
246  bool eventFilter (QObject *obj, QEvent *ev);
247  };
248 
249  // The variable editor class
250 
252  {
253  Q_OBJECT
254 
255  public:
256 
257  variable_editor (QWidget *parent = nullptr);
258 
259  ~variable_editor (void) = default;
260 
261  // No copying!
262 
263  variable_editor (const variable_editor&) = delete;
264 
265  variable_editor& operator = (const variable_editor&) = delete;
266 
267  void refresh (void);
268 
269  static QList<QColor> default_colors (void);
270 
271  static QStringList color_names (void);
272 
273  void tab_to_front (void);
274 
275  public slots:
276 
277  void callUpdate (const QModelIndex&, const QModelIndex&);
278 
279  void notice_settings (const QSettings *);
280 
281  void edit_variable (const QString& name, const octave_value& val);
282 
283  void variable_destroyed (QObject *obj);
284 
285  void variable_focused (const QString& name);
286 
287  void record_hovered_focus_variable (void);
288 
289  void restore_hovered_focus_variable (void);
290 
291  protected slots:
292 
293  void closeEvent (QCloseEvent *);
294 
295  void save (void);
296 
297  void cutClipboard (void);
298 
299  void copyClipboard (void);
300 
301  void pasteClipboard (void);
302 
303  void pasteTableClipboard (void);
304 
305  void levelUp (void);
306 
307  // Send command to Octave interpreter.
308  // %1 in CMD is replaced with the value of selected_to_octave.
309  void relay_selected_command (const QString& cmd);
310 
311  signals:
312 
313  void updated (void);
314 
315  void finished (void);
316 
317  void command_signal (const QString& cmd);
318 
319  void refresh_signal (void);
320 
321  void clear_content_signal (void);
322 
323  void copy_clipboard_signal (void);
324 
325  void paste_clipboard_signal (void);
326 
327  void paste_table_clipboard_signal (void);
328 
329  void level_up_signal (void);
330 
331  void save_signal (void);
332 
333  void delete_selected_signal (void);
334 
335  void selected_command_signal (const QString& cmd);
336 
337  protected:
338 
339  void focusInEvent (QFocusEvent *ev);
340 
341  void focusOutEvent (QFocusEvent *ev);
342 
343  private:
344 
345  QAction * add_action (QMenu *menu, const QIcon& icon, const QString& text,
346  const char *member);
347 
349 
350  QToolBar *m_tool_bar;
351 
353 
355 
357 
359 
361 
362  QString m_stylesheet;
363 
364  QFont m_font;
365 
366  // If use_terminal_font is true then this will be different since
367  // "font" will contain the terminal font.
368  QFont m_sel_font;
369 
371 
372  void update_colors (void);
373 
374  QAction *add_tool_bar_button (const QIcon &icon, const QString &text,
375  const QObject *receiver, const char *member);
376 
377  void construct_tool_bar (void);
378 
380 
382 
384  };
385 }
386 
387 #endif
void command_signal(const QString &cmd)
void focusOutEvent(QFocusEvent *ev)
static QStringList color_names(void)
void add_edit_actions(QMenu *menu, const QString &qualifier_string)
ReturnFocusMenu(QWidget *parent=nullptr)
void closeEvent(QCloseEvent *)
void resizeEvent(QResizeEvent *event)
void selected_command_requested(const QString &cmd)
void focusInEvent(QFocusEvent *ev)
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
variable_dock_widget(QWidget *p=nullptr)
octave::sys::time now
Definition: data.cc:6251
void callUpdate(const QModelIndex &, const QModelIndex &)
void set_editable(bool editable)
bool eventFilter(QObject *obj, QEvent *ev)
variable_editor_model * m_var_model
void record_hovered_focus_variable(void)
void createContextMenu(const QPoint &pt)
virtual void closeEvent(QCloseEvent *e)
void edit_variable_signal(const QString &name, const octave_value &val)
i e
Definition: data.cc:2591
void paste_clipboard_signal(void)
void add_edit_actions_signal(QMenu *menu, const QString &qualifier_string)
QTextEdit * make_disp_view(QWidget *parent)
void createRowMenu(const QPoint &pt)
variable_editor(QWidget *parent=nullptr)
void restore_hovered_focus_variable(void)
void about_to_activate(void)
ReturnFocusToolButton(QWidget *parent=nullptr)
void variable_destroyed(QObject *obj)
QAction * add_tool_bar_button(const QIcon &icon, const QString &text, const QObject *receiver, const char *member)
nd deftypefn *std::string name
Definition: sysdep.cc:647
void variable_focused(const QString &name)
void popup_shown_signal(void)
static QList< QColor > default_colors(void)
variable_editor & operator=(const variable_editor &)=delete
~variable_editor(void)=default
void variable_focused_signal(const QString &name)
variable_editor_view * edit_view(void)
bool eventFilter(QObject *obj, QEvent *ev)
HoverToolButton(QWidget *parent=nullptr)
void edit_variable(const QString &name, const octave_value &val)
QList< QColor > m_table_colors
void delete_selected_signal(void)
void handle_horizontal_scroll_action(int action)
void notice_settings(const QSettings *)
void setModel(QAbstractItemModel *model)
p
Definition: lu.cc:138
QList< int > range_selected(void)
void handle_focus_change(QWidget *old, QWidget *now)
void createColumnMenu(const QPoint &pt)
bool eventFilter(QObject *obj, QEvent *ev)
variable_editor_view(QWidget *p=nullptr)
void copy_clipboard_signal(void)
void relay_selected_command(const QString &cmd)
variable_editor_view * m_edit_view
void paste_table_clipboard_signal(void)
variable_editor_stack(QWidget *p=nullptr)
void handle_vertical_scroll_action(int action)
void command_signal(const QString &cmd)
void command_signal(const QString &cmd)
QAction * add_action(QMenu *menu, const QIcon &icon, const QString &text, const char *member)
void clear_content_signal(void)
void selected_command_signal(const QString &cmd)