annotate libgui/src/variable-editor.h @ 23927:e3a36f84d01d

provide variable-editor widget for the GUI This patch is the work of RĂ¼diger Sonderfeld <ruediger on savannah> Philip Nienhuis Michael Barnes <mjbcode@runbox.com> jwe * libgui/src/variable-editor.cc, libgui/src/variable-editor.h, libgui/src/variable-editor-model.cc, libgui/src/variable-editor-model.h:: New files. * libgui/src/module.mk: Update. * main-window.cc, main-window.h (main_window::main_window): Initialize variable_editor_window. (main_window::~main_window): Delete variable_editor_window. (main_window::connect_uiwidget_links): Connect variable window signals to octave_qt_link slots and callbacks. Add variable editor to menus. (main_window::variable_editor_callback, main_window::force_refresh_workspace, main_window::edit_variable, main_window::clear_variable_editor_cache): New functions. (main_window::configure_shortcuts): Also configure variable editor shortcuts. * resource-manager.cc, resource-manager.h (varedit_color_chars, varedit_color_names, varedit_default_colors): New functions. * settings-dialog.ui: New configuration info for variable editor. * settings-dialog.cc, settings-dialog.h (settings_dialog::read_varedit_colors, settings_dialog::write_varedit_colors): New functions. (settings_dialog::settings_dialog, settings_dialog::write_changed_settings): Also handle settings for variable editor. * workspace-model.h (workspace_model::prompt_variable_editor): New signal. * workspace-view.cc, workspace-view.h (workspace_view::workspace_view): Also connect eidt_variable_signal to edit_variable slot. (workspace_view::contextmenu_requested): Handle opening variabl in variable editor. (workspace_view::handle_contextmenu_edit): New function. (workspace_view::edit_variable_signal): New signal. * octave-link.cc, octave-link.h (Fopenvar): New function. (octave_link::post_event, octave_link::do_post_event): New variants for methods with two, three, or four arguments. (octave_link::set_workspace): New argument, update_variable_editor. (octave_link::openvar): New function. (octave_link::do_openvar): New pure virtual. * octave-qt-link.cc, octave-qt-link.h (octave_qt_link::do_set_workspace): New argument, update_variable_editor. (octave_qt_link::do_set_workspace): Optionally emit refresh_variable_editor signal (octave_qt_link::do_openvar): New function. (octave_qt_link::open_variable, octave_qt_link::refresh_variable_editor): New signals. * gui.txi: Document openvar. * variables.cc, variables.h (symbol_exist): New function. * action-container.h (action_container::method_arg2_elem, action_container::method_arg3_elem, action_container::method_arg4_elem): New classes. (action_container::add_method): New variants for two, three, or four arguments.
author Michael Barnes <mjbcode@runbox.com>
date Fri, 19 May 2017 18:15:48 +0200
parents
children 665507c3c29d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
1 /*
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
2
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
3 Copyright (C) 2015 Michael Barnes
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
4 Copyright (C) 2013 RĂ¼diger Sonderfeld
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
5 Copyright (C) 2013 John W. Eaton
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
6
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
7 This file is part of Octave.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
8
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
12 option) any later version.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
13
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
17 for more details.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
18
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
20 along with Octave; see the file COPYING. If not, see
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
21 <http://www.gnu.org/licenses/>.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
22
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
23 */
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
24
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
25 #ifndef variable_editor_h
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
26 #define variable_editor_h
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
27
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
28 #include "octave-dock-widget.h"
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
29 #include <QHeaderView>
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
30 #include <QSettings>
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
31
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
32 class QTabWidget;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
33 class QToolBar;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
34 class QMainWindow;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
35 class QTableView;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
36 class QModelIndex;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
37
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
38 class variable_editor : public octave_dock_widget
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
39 {
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
40 Q_OBJECT
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
41
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
42 public:
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
43
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
44 variable_editor (QWidget *parent = nullptr);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
45
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
46 //~variable_editor ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
47
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
48 void edit_variable (const QString& name);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
49
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
50 /// Clear all the models' data cache
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
51 void clear_data_cache ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
52
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
53 bool has_focus ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
54
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
55 static QList<QColor> default_colors ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
56 static QStringList color_names ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
57
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
58 public slots:
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
59
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
60 void callUpdate (const QModelIndex&,const QModelIndex&);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
61
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
62 void notice_settings (const QSettings *);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
63
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
64 protected slots:
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
65
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
66 void closeEvent (QCloseEvent *);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
67
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
68 void closeTab (int idx);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
69
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
70 void contextmenu_requested (const QPoint& pt);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
71 void columnmenu_requested (const QPoint& pt);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
72 void rowmenu_requested (const QPoint& pt);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
73
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
74 void double_click (const QModelIndex& idx);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
75
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
76 void save ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
77 void clearContent ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
78 void cutClipboard ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
79 void copyClipboard ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
80 void pasteClipboard ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
81 void pasteTableClipboard ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
82 void createVariable ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
83 void transposeContent ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
84 void up ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
85
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
86 void delete_selected();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
87
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
88 /** Send command to Octave interpreter.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
89 * %1 in CMD is replaced with the value of selected_to_octave.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
90 */
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
91 void relay_command (const QString& cmd);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
92
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
93 signals:
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
94
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
95 void updated ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
96 void finished ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
97 void command_requested (const QString& cmd);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
98
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
99 private:
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
100 QMainWindow *main;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
101 QToolBar *tool_bar;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
102 QTabWidget *tab_widget;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
103
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
104 int default_width;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
105 int default_height;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
106 int add_font_height;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
107
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
108 bool autofit;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
109 bool autofit_max;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
110 bool use_terminal_font;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
111 bool alternate_rows;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
112
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
113 QString stylesheet;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
114
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
115 QFont font;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
116
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
117 // If use_terminal_font then this will be different since "font"
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
118 // will contain the terminal font.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
119 QFont sel_font;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
120 QList<QColor> table_colors;
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
121
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
122 void update_colors ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
123
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
124 void construct_tool_bar ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
125
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
126 // Convert selection to an Octave expression.
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
127 QString selected_to_octave ();
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
128
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
129 QList<int> octave_to_coords (QString&);
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
130 };
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
131
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
diff changeset
132 #endif //variable_editor_h