annotate libgui/src/workspace-view.cc @ 27412:da1f59fe04b3

try to use consitent ordering for include files in libgui sources Use alphabetical ordering for include files in libgui sources. Group in blocks in teh following order: standard header files Qt header files libgui header files liboctave header files libinterp header files Use forward declarations for Octave classes where possible. Files affected: color-picker.h, dialog.cc, dialog.h, documentation-dock-widget.h, documentation.cc, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.h, gui-preferences-mw.h, gui-preferences.h, history-dock-widget.cc, history-dock-widget.h, interpreter-qobject.cc, m-editor/file-editor-interface.h, m-editor/file-editor-tab.cc, m-editor/file-editor-tab.h, m-editor/file-editor.cc, m-editor/file-editor.h, m-editor/marker.h, m-editor/octave-qscintilla.cc, m-editor/octave-qscintilla.h, main-window.cc, main-window.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, qt-application.cc, qt-interpreter-events.cc, qt-interpreter-events.h, resource-manager.cc, resource-manager.h, set-path-dialog.cc, set-path-dialog.h, set-path-model.cc, set-path-model.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, tab-bar.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, and workspace-view.h.
author John W. Eaton <jwe@octave.org>
date Sun, 15 Sep 2019 12:28:23 -0400
parents 5ca84fb30205
children c7a898396151
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
1 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26117
diff changeset
3 Copyright (C) 2013-2019 John W. Eaton
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26117
diff changeset
4 Copyright (C) 2011-2019 Jacob Dawid
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
5
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
6 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
7
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24362
diff changeset
8 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22411
diff changeset
9 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24362
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22411
diff changeset
11 (at your option) any later version.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22411
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22411
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22411
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22411
diff changeset
16 GNU General Public License for more details.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
17
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
18 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
19 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24362
diff changeset
20 <https://www.gnu.org/licenses/>.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
22 */
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
23
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21568
diff changeset
24 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
25 # include "config.h"
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
26 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
27
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
28 #include <QApplication>
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
29 #include <QClipboard>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
30 #include <QCompleter>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
31 #include <QHBoxLayout>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
32 #include <QHeaderView>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
33 #include <QInputDialog>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
34 #include <QLabel>
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
35 #include <QLineEdit>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
36 #include <QMenu>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
37 #include <QMessageBox>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
38 #include <QPushButton>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
39 #include <QSignalMapper>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
40 #include <QVBoxLayout>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
41
25974
c3cd63006870 add preference for disabling workspace colors for different attributes
Torsten <mttl@mailbox.org>
parents: 25623
diff changeset
42 #include "gui-preferences.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
43 #include "resource-manager.h"
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
44 #include "workspace-view.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23449
diff changeset
45
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23449
diff changeset
46 #include "interpreter-private.h"
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
47 #include "interpreter.h"
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 25974
diff changeset
48 #include "syminfo.h"
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
49
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
50 namespace octave
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
51 {
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
52 workspace_view::workspace_view (QWidget *p)
25355
5bb07f6e3707 fix uninitialized settings of octave dock widgets at startup (bug #53835)
Torsten <mttl@mailbox.org>
parents: 25354
diff changeset
53 : octave_dock_widget ("WorkspaceView", p), m_view (new QTableView (this))
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
54 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
55 setWindowIcon (QIcon (":/actions/icons/logo.png"));
25508
3edae6ba1fcd use a custom title bar widget for the main dock widgets
Torsten <mttl@mailbox.org>
parents: 25355
diff changeset
56 set_title (tr ("Workspace"));
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
57 setStatusTip (tr ("View the variables in the active workspace."));
13523
103b7bebb38f Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13506
diff changeset
58
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
59 m_filter = new QComboBox (this);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
60 m_filter->setToolTip (tr ("Enter text to filter the workspace"));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
61 m_filter->setEditable (true);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
62 m_filter->setMaxCount (MaxFilterHistory);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
63 m_filter->setInsertPolicy (QComboBox::NoInsert);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
64 m_filter->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
65 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
66 m_filter->setSizePolicy (sizePol);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
67 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
68
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
69 QLabel *filter_label = new QLabel (tr ("Filter"));
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
70
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
71 m_filter_checkbox = new QCheckBox ();
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
72
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
73 m_view->setWordWrap (false);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
74 m_view->setContextMenuPolicy (Qt::CustomContextMenu);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
75 m_view->setShowGrid (false);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
76 (m_view->verticalHeader) ()->hide ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
77 m_view->setAlternatingRowColors (true);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
78 m_view_previous_row_count = 0;
13523
103b7bebb38f Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13506
diff changeset
79
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
80 // Set an empty widget, so we can assign a layout to it.
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
81 setWidget (new QWidget (this));
14874
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14783
diff changeset
82
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
83 // Create the layouts
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
84 m_filter_widget = new QWidget (this);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
85 QHBoxLayout *filter_layout = new QHBoxLayout ();
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
86
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
87 filter_layout->addWidget (filter_label);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
88 filter_layout->addWidget (m_filter_checkbox);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
89 filter_layout->addWidget (m_filter);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
90 filter_layout->setMargin(0);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
91 m_filter_widget->setLayout (filter_layout);
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
92
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
93 QVBoxLayout *ws_layout = new QVBoxLayout ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
94 ws_layout->addWidget (m_filter_widget);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
95 ws_layout->addWidget (m_view);
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
96
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
97 QSettings *settings = resource_manager::get_settings ();
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
98
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
99 if (settings)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
100 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
101 m_filter_shown = settings->value ("workspaceview/filter_shown",true).toBool ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
102 m_filter_widget->setVisible (m_filter_shown);
14874
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14783
diff changeset
103
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
104 ws_layout->setMargin (2);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
105
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
106 // Set the empty widget to have our layout.
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
107 widget ()->setLayout (ws_layout);
22177
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
108
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
109 // Initialize collapse/expand state of the workspace subcategories.
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 14997
diff changeset
110
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
111 //enable sorting (setting column and order after model was set)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
112 m_view->setSortingEnabled (true);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
113 // Initialize column order and width of the workspace
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
114 m_view->horizontalHeader ()->restoreState
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
115 (settings->value ("workspaceview/column_state").toByteArray ());
22250
2fd4f1a3f4a8 allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
116
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
117 // Set header properties for sorting
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24775
diff changeset
118 #if defined (HAVE_QHEADERVIEW_SETSECTIONSCLICKABLE)
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24775
diff changeset
119 m_view->horizontalHeader ()->setSectionsClickable (true);
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24775
diff changeset
120 #else
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
121 m_view->horizontalHeader ()->setClickable (true);
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24775
diff changeset
122 #endif
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24775
diff changeset
123 #if defined (HAVE_QHEADERVIEW_SETSECTIONSMOVABLE)
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24775
diff changeset
124 m_view->horizontalHeader ()->setSectionsMovable (true);
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24775
diff changeset
125 #else
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
126 m_view->horizontalHeader ()->setMovable (true);
22250
2fd4f1a3f4a8 allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
127 #endif
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
128 m_view->horizontalHeader ()->setSortIndicator (settings->value ("workspaceview/sort_by_column",0).toInt (),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
129 static_cast<Qt::SortOrder>
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
130 (settings->value ("workspaceview/sort_order", Qt::AscendingOrder).toUInt ()));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
131 m_view->horizontalHeader ()->setSortIndicatorShown (true);
19982
9a8be23d2c05 extend sorting of workspave view widget
Torsten <ttl@justmail.de>
parents: 19981
diff changeset
132
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
133 m_view->horizontalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
134 connect (m_view->horizontalHeader (),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
135 SIGNAL (customContextMenuRequested (const QPoint &)),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
136 this, SLOT (header_contextmenu_requested (const QPoint &)));
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
137
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
138 // Init state of the filter
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
139 m_filter->addItems (settings->value ("workspaceview/mru_list").toStringList ());
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
140
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
141 bool filter_state =
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
142 settings->value ("workspaceview/filter_active", false).toBool ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
143 m_filter_checkbox->setChecked (filter_state);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
144 filter_activate (filter_state);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
145 }
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
146
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
147 // Connect signals and slots.
14874
5d74d8b982a5 Forgot to have a fallback lexer when the file suffix is unknown. Removed unused variable and added comments.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14783
diff changeset
148
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
149 connect (m_filter, SIGNAL (editTextChanged (const QString&)),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
150 this, SLOT (filter_update (const QString&)));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
151 connect (m_filter_checkbox, SIGNAL (toggled (bool)),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
152 this, SLOT (filter_activate (bool)));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
153 connect (m_filter->lineEdit (), SIGNAL (editingFinished ()),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
154 this, SLOT (update_filter_history ()));
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
155
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
156 connect (m_view, SIGNAL (customContextMenuRequested (const QPoint&)),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
157 this, SLOT (contextmenu_requested (const QPoint&)));
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
158
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
159 connect (m_view, SIGNAL (activated (QModelIndex)),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
160 this, SLOT (handle_contextmenu_edit (void)));
23945
cf16f6521180 double clicking a variable in workspace view opens variable editor (bug #51843)
Torsten <mttl@mailbox.org>
parents: 23927
diff changeset
161
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
162 connect (this, SIGNAL (command_requested (const QString&)),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
163 p, SLOT (execute_command_in_terminal (const QString&)));
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
164
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
165 connect (this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
166 SIGNAL (edit_variable_signal (const QString&, const octave_value&)),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
167 p, SLOT (edit_variable (const QString&, const octave_value&)));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
168 }
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13541
diff changeset
169
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
170 void workspace_view::setModel (workspace_model *model)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
171 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
172 m_filter_model.setSourceModel (model);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
173 m_filter_model.setFilterKeyColumn(0);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
174
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
175 m_view->setModel (&m_filter_model);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
176
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
177 // set the sorting after a model was set, it would be ignored otherwise
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
178 QSettings *settings = resource_manager::get_settings ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
179 m_view->sortByColumn (settings->value ("workspaceview/sort_by_column",0).toInt (),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
180 static_cast<Qt::SortOrder> (settings->value ("workspaceview/sort_order", Qt::AscendingOrder).toUInt ()));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
181
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
182 m_model = model;
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
183 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
184
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
185 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
186 workspace_view::notice_settings (const QSettings *settings)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
187 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
188 int i;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
189
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
190 m_model->notice_settings (settings); // update colors of model first
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
191
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
192 for (i = 0; i < m_columns_shown_keys.size (); i++)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
193 m_view->setColumnHidden (i + 1, ! settings->value (m_columns_shown_keys.at (i),true).toBool ());
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
194
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
195 QString tool_tip;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
196
25974
c3cd63006870 add preference for disabling workspace colors for different attributes
Torsten <mttl@mailbox.org>
parents: 25623
diff changeset
197 if (settings->value (ws_enable_colors.key, ws_enable_colors.def).toBool ()
c3cd63006870 add preference for disabling workspace colors for different attributes
Torsten <mttl@mailbox.org>
parents: 25623
diff changeset
198 && ! settings->value (ws_hide_tool_tips.key, ws_hide_tool_tips.def).toBool ())
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
199 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
200 tool_tip = QString (tr ("View the variables in the active workspace.<br>"));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
201 tool_tip += QString (tr ("Colors for variable attributes:"));
27033
c76dd670a7a5 automatic selection of foreground color in worspace view (bug #53995)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26661
diff changeset
202 int colors = resource_manager::storage_class_chars ().length ();
c76dd670a7a5 automatic selection of foreground color in worspace view (bug #53995)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26661
diff changeset
203 for (i = 0; i < colors; i++)
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
204 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
205 tool_tip +=
27033
c76dd670a7a5 automatic selection of foreground color in worspace view (bug #53995)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26661
diff changeset
206 QString (R"(<div style="background-color:%1;color:%2">%3</div>)")
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
207 .arg (m_model->storage_class_color (i).name ())
27033
c76dd670a7a5 automatic selection of foreground color in worspace view (bug #53995)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26661
diff changeset
208 .arg (m_model->storage_class_color (i + colors).name ())
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
209 .arg (resource_manager::storage_class_names ().at (i));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
210 }
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
211 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
212
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
213 setToolTip (tool_tip);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
214
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
215 m_columns_shown = QStringList ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
216 m_columns_shown.append (tr ("Class"));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
217 m_columns_shown.append (tr ("Dimension"));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
218 m_columns_shown.append (tr ("Value"));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
219 m_columns_shown.append (tr ("Attribute"));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
220
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
221 m_columns_shown_keys = QStringList ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
222 m_columns_shown_keys.append ("workspaceview/show_class");
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
223 m_columns_shown_keys.append ("workspaceview/show_dimension");
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
224 m_columns_shown_keys.append ("workspaceview/show_value");
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
225 m_columns_shown_keys.append ("workspaceview/show_attribute");
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
226
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
227 m_sig_mapper = nullptr;
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
228 }
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13541
diff changeset
229
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
230 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
231 workspace_view::save_settings (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
232 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
233 QSettings *settings = resource_manager::get_settings ();
16463
8e2a853cdd7d derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents: 16462
diff changeset
234
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
235 if (! settings)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
236 return;
22177
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
237
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
238 settings->setValue ("workspaceview/column_state",
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
239 m_view->horizontalHeader ()->saveState ());
19982
9a8be23d2c05 extend sorting of workspave view widget
Torsten <ttl@justmail.de>
parents: 19981
diff changeset
240
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
241 int sort_column = m_view->horizontalHeader ()->sortIndicatorSection ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
242 Qt::SortOrder sort_order = m_view->horizontalHeader ()->sortIndicatorOrder ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
243 settings->setValue ("workspaceview/sort_by_column", sort_column);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
244 settings->setValue ("workspaceview/sort_order", sort_order);
19982
9a8be23d2c05 extend sorting of workspave view widget
Torsten <ttl@justmail.de>
parents: 19981
diff changeset
245
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
246 settings->setValue ("workspaceview/filter_active",
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
247 m_filter_checkbox->isChecked ());
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
248 settings->setValue ("workspaceview/filter_shown", m_filter_shown);
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
249
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
250 QStringList mru;
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
251 for (int i = 0; i < m_filter->count (); i++)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
252 mru.append (m_filter->itemText (i));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
253 settings->setValue ("workspaceview/mru_list", mru);
16463
8e2a853cdd7d derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents: 16462
diff changeset
254
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
255 settings->sync ();
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
256
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
257 octave_dock_widget::save_settings ();
24299
deba10d3309b * workspae_view (save_settings): add missing call to virtual base function
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
258
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
259 if (m_sig_mapper)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
260 delete m_sig_mapper;
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
261 }
16610
a1f613e5066d workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents: 16575
diff changeset
262
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
263 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
264 workspace_view::filter_update (const QString& expression)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
265 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
266 m_filter_model.setFilterWildcard (expression);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
267 handle_model_changed ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
268 }
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
269
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
270 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
271 workspace_view::filter_activate (bool state)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
272 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
273 m_filter->setEnabled (state);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
274 m_filter_model.setDynamicSortFilter (state);
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
275
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
276 if (state)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
277 filter_update (m_filter->currentText ());
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
278 else
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
279 filter_update (QString ());
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
280 }
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
281
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
282 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
283 workspace_view::update_filter_history (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
284 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
285 QString text = m_filter->currentText (); // get current text
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
286 int index = m_filter->findText (text); // and its actual index
19562
010cef260698 improve filter of workspace view
Torsten <ttl@justmail.de>
parents: 19539
diff changeset
287
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
288 if (index > -1)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
289 m_filter->removeItem (index); // remove if already existing
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
290
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
291 m_filter->insertItem (0, text); // (re)insert at beginning
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
292 m_filter->setCurrentIndex (0);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
293 }
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
294
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
295 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
296 workspace_view::header_contextmenu_requested (const QPoint& mpos)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
297 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
298 QMenu menu (this);
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
299
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
300 if (m_sig_mapper)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
301 delete m_sig_mapper;
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
302 m_sig_mapper = new QSignalMapper (this);
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
303
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
304 QSettings *settings = resource_manager::get_settings ();
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
305
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
306 for (int i = 0; i < m_columns_shown.size (); i++)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
307 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
308 QAction *action = menu.addAction (m_columns_shown.at (i),
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
309 m_sig_mapper, SLOT (map ()));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
310 m_sig_mapper->setMapping (action, i);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
311 action->setCheckable (true);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
312 action->setChecked (settings->value (m_columns_shown_keys.at (i),true).toBool ());
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
313 }
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
314
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
315 connect (m_sig_mapper, SIGNAL (mapped (int)), this, SLOT (toggle_header (int)));
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
316
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
317 menu.exec (m_view->mapToGlobal (mpos));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
318 }
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
319
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
320 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
321 workspace_view::toggle_header (int col)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
322 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
323 QSettings *settings = resource_manager::get_settings ();
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
324
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
325 QString key = m_columns_shown_keys.at (col);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
326 bool shown = settings->value (key,true).toBool ();
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
327
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
328 m_view->setColumnHidden (col + 1, shown);
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
329
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
330 settings->setValue (key, ! shown);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
331 settings->sync ();
22177
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
332
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
333 octave_dock_widget::save_settings ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
334 }
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
335
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
336 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
337 workspace_view::contextmenu_requested (const QPoint& qpos)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
338 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
339 QMenu menu (this);
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
340
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
341 QModelIndex index = m_view->indexAt (qpos);
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
342
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
343 // if it isnt Local, Glocal etc, allow the ctx menu
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
344 if (index.isValid () && index.column () == 0)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
345 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
346 QString var_name = get_var_name (index);
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
347
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
348 menu.addAction (tr ("Open in Variable Editor"), this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
349 SLOT (handle_contextmenu_edit ()));
23945
cf16f6521180 double clicking a variable in workspace view opens variable editor (bug #51843)
Torsten <mttl@mailbox.org>
parents: 23927
diff changeset
350
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
351 menu.addAction (tr ("Copy name"), this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
352 SLOT (handle_contextmenu_copy ()));
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
353
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
354 menu.addAction (tr ("Copy value"), this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
355 SLOT (handle_contextmenu_copy_value ()));
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
356
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
357 QAction *rename = menu.addAction (tr ("Rename"), this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
358 SLOT (handle_contextmenu_rename ()));
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
359
27192
8779c631d55f fix access to top_level info flag when creating workspace view context menu
John W. Eaton <jwe@octave.org>
parents: 27033
diff changeset
360 // Use m_model here instead of using "m_view->model ()" because
8779c631d55f fix access to top_level info flag when creating workspace view context menu
John W. Eaton <jwe@octave.org>
parents: 27033
diff changeset
361 // that points to the proxy model.
8779c631d55f fix access to top_level info flag when creating workspace view context menu
John W. Eaton <jwe@octave.org>
parents: 27033
diff changeset
362 if (! m_model->is_top_level ())
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
363 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
364 rename->setDisabled (true);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
365 rename->setToolTip (tr ("Only top-level symbols may be renamed"));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
366 }
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
367
24775
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
368 menu.addAction ("Clear " + var_name, this,
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
369 SLOT (handle_contextmenu_clear ()));
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
370
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
371 menu.addSeparator ();
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
372
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
373 menu.addAction ("disp (" + var_name + ')', this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
374 SLOT (handle_contextmenu_disp ()));
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
375
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
376 menu.addAction ("plot (" + var_name + ')', this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
377 SLOT (handle_contextmenu_plot ()));
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
378
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
379 menu.addAction ("stem (" + var_name + ')', this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
380 SLOT (handle_contextmenu_stem ()));
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
381
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
382 menu.addSeparator ();
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
383
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
384 }
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
385
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
386 if (m_filter_shown)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
387 menu.addAction (tr ("Hide filter"), this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
388 SLOT (handle_contextmenu_filter ()));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
389 else
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
390 menu.addAction (tr ("Show filter"), this,
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
391 SLOT (handle_contextmenu_filter ()));
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
392
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
393 menu.exec (m_view->mapToGlobal (qpos));
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
394 }
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
395
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
396 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
397 workspace_view::handle_contextmenu_copy (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
398 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
399 QModelIndex index = m_view->currentIndex ();
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
400
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
401 if (index.isValid ())
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
402 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
403 QString var_name = get_var_name (index);
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
404
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
405 QClipboard *clipboard = QApplication::clipboard ();
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
406
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
407 clipboard->setText (var_name);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
408 }
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
409 }
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
410
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
411 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
412 workspace_view::handle_contextmenu_copy_value (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
413 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
414 QModelIndex index = m_view->currentIndex ();
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
415
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
416 if (index.isValid ())
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
417 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
418 QString var_name = get_var_name (index);
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
419
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
420 emit interpreter_event
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
421 ([var_name] (interpreter& interp)
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
422 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
423 // INTERPRETER THREAD
27375
2fb37768085d mark locations in GUI that should be checked for thread safety
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
424
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
425 octave_value val = interp.varval (var_name.toStdString ());
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
426
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
427 if (val.is_undefined ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
428 val = 0;
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23449
diff changeset
429
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
430 std::ostringstream buf;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
431 val.print_raw (buf, true);
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
432
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
433 // FIXME: is the following operation thread safe or should
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
434 // it be done with a signal/slot connection?
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
435
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
436 QClipboard *clipboard = QApplication::clipboard ();
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
437 clipboard->setText (QString::fromStdString (buf.str ()));
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
438 });
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
439 }
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
440 }
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
441
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
442 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
443 workspace_view::handle_contextmenu_rename (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
444 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
445 QModelIndex index = m_view->currentIndex ();
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
446
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
447 if (index.isValid ())
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
448 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
449 QString var_name = get_var_name (index);
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
450
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
451 QInputDialog *inputDialog = new QInputDialog ();
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
452
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
453 inputDialog->setOptions (QInputDialog::NoButtons);
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
454
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
455 bool ok = false;
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
456
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
457 QString new_name
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
458 = inputDialog->getText (nullptr, "Rename Variable", "New name:",
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
459 QLineEdit::Normal, var_name, &ok);
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
460
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
461 if (ok && ! new_name.isEmpty ())
27220
9a4a9fcc186b connect workspace view rename variable signal to main window slot
John W. Eaton <jwe@octave.org>
parents: 27192
diff changeset
462 emit rename_variable_signal (var_name, new_name);
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
463 }
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
464 }
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
465
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
466 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
467 workspace_view::handle_contextmenu_edit (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
468 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
469 QModelIndex index = m_view->currentIndex ();
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
470
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
471 if (index.isValid ())
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
472 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
473 QString var_name = get_var_name (index);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
474
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 25974
diff changeset
475 symbol_info_list syminfo = m_model->get_symbol_info ();
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 25974
diff changeset
476 octave_value val = syminfo.varval (var_name.toStdString ());
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
477
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
478 emit edit_variable_signal (var_name, val);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
479 }
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
480 }
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
481
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
482 void
24775
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
483 workspace_view::handle_contextmenu_clear (void)
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
484 {
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
485 relay_contextmenu_command ("clear", true);
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
486 }
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
487
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
488 void
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
489 workspace_view::handle_contextmenu_disp (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
490 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
491 relay_contextmenu_command ("disp");
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
492 }
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
493
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
494 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
495 workspace_view::handle_contextmenu_plot (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
496 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
497 relay_contextmenu_command ("figure (); plot");
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
498 }
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
499
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
500 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
501 workspace_view::handle_contextmenu_stem (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
502 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
503 relay_contextmenu_command ("figure (); stem");
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
504 }
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
505
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
506 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
507 workspace_view::handle_contextmenu_filter (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
508 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
509 m_filter_shown = ! m_filter_shown;
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
510 m_filter_widget->setVisible (m_filter_shown);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
511 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
512
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
513 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
514 workspace_view::handle_model_changed (void)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
515 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
516 // m_view->resizeRowsToContents ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
517 // Just modify those rows that have been added rather than go through
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
518 // the whole list. For-loop test will handle when number of rows reduced.
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
519 QFontMetrics fm = m_view->fontMetrics ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
520 int row_height = fm.height ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
521 int new_row_count = m_filter_model.rowCount ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
522 for (int i = m_view_previous_row_count; i < new_row_count; i++)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
523 m_view->setRowHeight (i, row_height);
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
524 m_view_previous_row_count = new_row_count;
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
525 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
526
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
527 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
528 workspace_view::copyClipboard ()
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
529 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
530 if (m_view->hasFocus ())
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
531 handle_contextmenu_copy ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
532 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
533
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
534 void
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
535 workspace_view::selectAll ()
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
536 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
537 if (m_view->hasFocus ())
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
538 m_view->selectAll ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
539 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
540
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
541 void
24775
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
542 workspace_view::relay_contextmenu_command (const QString& cmdname, bool str)
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
543 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
544 QModelIndex index = m_view->currentIndex ();
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
545
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
546 if (index.isValid ())
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
547 {
24775
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
548 QString var_name;
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
549
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
550 if (str)
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
551 var_name = "\'" + get_var_name (index) + "\'";
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
552 else
3da6c628873a clear variable via context menu of workspace view (bug #53149)
Torsten <mttl@mailbox.org>
parents: 24766
diff changeset
553 var_name = get_var_name (index);
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
554
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
555 emit command_requested (cmdname + " (" + var_name + ");");
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
556 }
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
557 }
16572
17941fedd4ce Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16570
diff changeset
558
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
559 QString
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
560 workspace_view::get_var_name (const QModelIndex& index)
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
561 {
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
562 // We are using a sort model proxy so m_model won't provide the
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
563 // correct ordering.
24648
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
564
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
565 QAbstractItemModel *m = m_view->model ();
24648
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
566
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
567 QMap<int, QVariant> item_data
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
568 = m->itemData (index.sibling (index.row (), 0));
19042
110702c507e3 user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
569
24766
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
570 return item_data[0].toString ();
08c92c9d48e3 move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24695
diff changeset
571 }
16610
a1f613e5066d workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents: 16575
diff changeset
572 }