annotate libgui/src/workspace-view.cc @ 24695:3048291bbed6

enter/return in workspace view also opens the variable for editing * workspace-view.cc (workspace_view): use signal activated instead of doubleClicked
author Torsten <mttl@mailbox.org>
date Tue, 06 Feb 2018 22:09:22 +0100
parents 1f1ac73910ab
children 08c92c9d48e3
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
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 2013-2017 John W. Eaton
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22250
diff changeset
4 Copyright (C) 2011-2016 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 <QInputDialog>
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 <QApplication>
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
30 #include <QClipboard>
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
31 #include <QMessageBox>
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
32 #include <QLineEdit>
15460
7f36f7dc25b2 save and restore the columns order and width of the workspace-view
Torsten <ttl@justmail.de>
parents: 15389
diff changeset
33 #include <QHeaderView>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
34 #include <QHBoxLayout>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
35 #include <QVBoxLayout>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
36 #include <QPushButton>
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
37 #include <QMenu>
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
38 #include <QLabel>
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
39 #include <QCompleter>
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
40 #include <QSignalMapper>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
41
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
42 #include "workspace-view.h"
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
43 #include "resource-manager.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23449
diff changeset
44
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23449
diff changeset
45 #include "interpreter-private.h"
24362
3fc24b792a24 avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24361
diff changeset
46 #include "symscope.h"
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
47
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
48 workspace_view::workspace_view (QWidget *p)
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
49 : octave_dock_widget (p), m_view (new QTableView (this))
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
50 {
13683
25dc40d24a44 Renamed VariablesDockWidget to WorkspaceView and optimized memory footprint for 30%.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13678
diff changeset
51 setObjectName ("WorkspaceView");
16478
079ec7ce60e0 delete useless connection; style fixes
John W. Eaton <jwe@octave.org>
parents: 16477
diff changeset
52 setWindowIcon (QIcon (":/actions/icons/logo.png"));
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
53 set_title (tr ("Workspace"));
16459
cbc39a3d0c42 improve encapsulation of workspace window object
John W. Eaton <jwe@octave.org>
parents: 16445
diff changeset
54 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
55
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
56 m_filter = new QComboBox (this);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
57 m_filter->setToolTip (tr ("Enter text to filter the workspace"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
58 m_filter->setEditable (true);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
59 m_filter->setMaxCount (MaxFilterHistory);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
60 m_filter->setInsertPolicy (QComboBox::NoInsert);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
61 m_filter->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon);
19846
72fe9df87fe8 improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
62 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
63 m_filter->setSizePolicy (sizePol);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
64 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
65
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
66 QLabel *filter_label = new QLabel (tr ("Filter"));
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
67
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
68 m_filter_checkbox = new QCheckBox ();
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
69
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
70 m_view->setWordWrap (false);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
71 m_view->setContextMenuPolicy (Qt::CustomContextMenu);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
72 m_view->setShowGrid (false);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
73 (m_view->verticalHeader) ()->hide ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
74 m_view->setAlternatingRowColors (true);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
75 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
76
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
77 // Set an empty widget, so we can assign a layout to it.
13523
103b7bebb38f Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13506
diff changeset
78 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
79
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
80 // Create the layouts
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
81 m_filter_widget = new QWidget (this);
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
82 QHBoxLayout *filter_layout = new QHBoxLayout ();
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
83
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
84 filter_layout->addWidget (filter_label);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
85 filter_layout->addWidget (m_filter_checkbox);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
86 filter_layout->addWidget (m_filter);
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
87 filter_layout->setMargin(0);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
88 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
89
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
90 QVBoxLayout *ws_layout = new QVBoxLayout ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
91 ws_layout->addWidget (m_filter_widget);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
92 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
93
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
94 QSettings *settings = resource_manager::get_settings ();
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
95
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
96 if (settings)
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
97 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
98 m_filter_shown = settings->value ("workspaceview/filter_shown",true).toBool ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
99 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
100
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
101 ws_layout->setMargin (2);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
102
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
103 // Set the empty widget to have our layout.
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
104 widget ()->setLayout (ws_layout);
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
105
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
106 // 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
107
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 //enable sorting (setting column and order after model was set)
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
109 m_view->setSortingEnabled (true);
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
110 // Initialize column order and width of the workspace
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
111 m_view->horizontalHeader ()->restoreState (settings->value ("workspaceview/column_state").toByteArray ());
22250
2fd4f1a3f4a8 allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
112
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
113 // Set header properties for sorting
22250
2fd4f1a3f4a8 allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
114 #if defined (HAVE_QT4)
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
115 m_view->horizontalHeader ()->setClickable (true);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
116 m_view->horizontalHeader ()->setMovable (true);
22250
2fd4f1a3f4a8 allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
117 #else
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
118 m_view->horizontalHeader ()->setSectionsClickable (true);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
119 m_view->horizontalHeader ()->setSectionsMovable (true);
22250
2fd4f1a3f4a8 allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
120 #endif
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
121 m_view->horizontalHeader ()->setSortIndicator (settings->value ("workspaceview/sort_by_column",0).toInt (),
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
122 static_cast<Qt::SortOrder>
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
123 (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
124 m_view->horizontalHeader ()->setSortIndicatorShown (true);
19982
9a8be23d2c05 extend sorting of workspave view widget
Torsten <ttl@justmail.de>
parents: 19981
diff changeset
125
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
126 m_view->horizontalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
127 connect (m_view->horizontalHeader (),
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
128 SIGNAL (customContextMenuRequested (const QPoint &)),
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
129 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
130
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
131 // Init state of the filter
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
132 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
133
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
134 bool filter_state =
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
135 settings->value ("workspaceview/filter_active", false).toBool ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
136 m_filter_checkbox->setChecked (filter_state);
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
137 filter_activate (filter_state);
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
138 }
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
139
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
140 // 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
141
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
142 connect (m_filter, SIGNAL (editTextChanged (const QString&)),
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
143 this, SLOT (filter_update (const QString&)));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
144 connect (m_filter_checkbox, SIGNAL (toggled (bool)),
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
145 this, SLOT (filter_activate (bool)));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
146 connect (m_filter->lineEdit (), SIGNAL (editingFinished ()),
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
147 this, SLOT (update_filter_history ()));
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
148
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
149 connect (m_view, SIGNAL (customContextMenuRequested (const QPoint&)),
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
150 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
151
24695
3048291bbed6 enter/return in workspace view also opens the variable for editing
Torsten <mttl@mailbox.org>
parents: 24648
diff changeset
152 connect (m_view, SIGNAL (activated (QModelIndex)),
23945
cf16f6521180 double clicking a variable in workspace view opens variable editor (bug #51843)
Torsten <mttl@mailbox.org>
parents: 23927
diff changeset
153 this, SLOT (handle_contextmenu_edit (void)));
cf16f6521180 double clicking a variable in workspace view opens variable editor (bug #51843)
Torsten <mttl@mailbox.org>
parents: 23927
diff changeset
154
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
155 connect (this, SIGNAL (command_requested (const QString&)),
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16521
diff changeset
156 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
157
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
158 connect (this,
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
159 SIGNAL (edit_variable_signal (const QString&, const octave_value&)),
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
160 p, SLOT (edit_variable (const QString&, const octave_value&)));
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13536
diff changeset
161 }
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13541
diff changeset
162
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
163 void workspace_view::setModel (workspace_model *model)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
164 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
165 m_filter_model.setSourceModel (model);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
166 m_filter_model.setFilterKeyColumn(0);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
167
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
168 m_view->setModel (&m_filter_model);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
169
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
170 // set the sorting after a model was set, it would be ignored otherwise
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
171 QSettings *settings = resource_manager::get_settings ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
172 m_view->sortByColumn (settings->value ("workspaceview/sort_by_column",0).toInt (),
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
173 static_cast<Qt::SortOrder> (settings->value ("workspaceview/sort_order", Qt::AscendingOrder).toUInt ()));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
174
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
175 m_model = model;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
176 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
177
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
178 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
179 workspace_view::notice_settings (const QSettings *settings)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
180 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
181 int i;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
182
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
183 m_model->notice_settings (settings); // update colors of model first
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
184
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
185 for (i = 0; i < m_columns_shown_keys.size (); i++)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
186 m_view->setColumnHidden (i + 1, ! settings->value (m_columns_shown_keys.at (i),true).toBool ());
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
187
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
188 QString tool_tip;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
189
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
190 if (! settings->value ("workspaceview/hide_tool_tips",false).toBool ())
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
191 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
192 tool_tip = QString (tr ("View the variables in the active workspace.<br>"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
193 tool_tip += QString (tr ("Colors for variable attributes:"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
194 for (i = 0; i < resource_manager::storage_class_chars ().length (); i++)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
195 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
196 tool_tip +=
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
197 QString (R"(<div style="background-color:%1;color:#000000">%2</div>)")
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
198 .arg (m_model->storage_class_color (i).name ())
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
199 .arg (resource_manager::storage_class_names ().at (i));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
200 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
201 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
202
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
203 setToolTip (tool_tip);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
204
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
205 m_columns_shown = QStringList ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
206 m_columns_shown.append (tr ("Class"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
207 m_columns_shown.append (tr ("Dimension"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
208 m_columns_shown.append (tr ("Value"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
209 m_columns_shown.append (tr ("Attribute"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
210
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
211 m_columns_shown_keys = QStringList ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
212 m_columns_shown_keys.append ("workspaceview/show_class");
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
213 m_columns_shown_keys.append ("workspaceview/show_dimension");
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
214 m_columns_shown_keys.append ("workspaceview/show_value");
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
215 m_columns_shown_keys.append ("workspaceview/show_attribute");
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
216
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
217 m_sig_mapper = nullptr;
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13536
diff changeset
218 }
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13541
diff changeset
219
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
220 void
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
221 workspace_view::save_settings (void)
14997
2d6766e93f7b The GUI now remembers when categories in the workspace view have been closed. Bug #36885
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14874
diff changeset
222 {
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 14997
diff changeset
223 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
224
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
225 if (! settings)
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
226 return;
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
227
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
228 settings->setValue ("workspaceview/column_state",
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
229 m_view->horizontalHeader ()->saveState ());
19982
9a8be23d2c05 extend sorting of workspave view widget
Torsten <ttl@justmail.de>
parents: 19981
diff changeset
230
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
231 int sort_column = m_view->horizontalHeader ()->sortIndicatorSection ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
232 Qt::SortOrder sort_order = m_view->horizontalHeader ()->sortIndicatorOrder ();
19982
9a8be23d2c05 extend sorting of workspave view widget
Torsten <ttl@justmail.de>
parents: 19981
diff changeset
233 settings->setValue ("workspaceview/sort_by_column", sort_column);
9a8be23d2c05 extend sorting of workspave view widget
Torsten <ttl@justmail.de>
parents: 19981
diff changeset
234 settings->setValue ("workspaceview/sort_order", sort_order);
9a8be23d2c05 extend sorting of workspave view widget
Torsten <ttl@justmail.de>
parents: 19981
diff changeset
235
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
236 settings->setValue ("workspaceview/filter_active",
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
237 m_filter_checkbox->isChecked ());
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
238 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
239
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
240 QStringList mru;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
241 for (int i = 0; i < m_filter->count (); i++)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
242 mru.append (m_filter->itemText (i));
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
243 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
244
16175
6f83158c714c gui: make sure settings are really written into the settings file
Torsten <ttl@justmail.de>
parents: 15552
diff changeset
245 settings->sync ();
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
246
24299
deba10d3309b * workspae_view (save_settings): add missing call to virtual base function
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
247 octave_dock_widget::save_settings ();
deba10d3309b * workspae_view (save_settings): add missing call to virtual base function
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
248
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
249 if (m_sig_mapper)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
250 delete m_sig_mapper;
16610
a1f613e5066d workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents: 16575
diff changeset
251 }
a1f613e5066d workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents: 16575
diff changeset
252
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
253 void
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
254 workspace_view::closeEvent (QCloseEvent *e)
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13541
diff changeset
255 {
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
256 emit active_changed (false);
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
257 QDockWidget::closeEvent (e);
13577
e440b3f32f02 Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13541
diff changeset
258 }
15552
bbbb89cc338f make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents: 15460
diff changeset
259
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
260 void
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
261 workspace_view::filter_update (const QString& expression)
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
262 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
263 m_filter_model.setFilterWildcard (expression);
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
264 handle_model_changed ();
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
265 }
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
266
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
267 void
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
268 workspace_view::filter_activate (bool state)
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
269 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
270 m_filter->setEnabled (state);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
271 m_filter_model.setDynamicSortFilter (state);
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
272
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
273 if (state)
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
274 filter_update (m_filter->currentText ());
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
275 else
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
276 filter_update (QString ());
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
277 }
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
278
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
279 void
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
280 workspace_view::update_filter_history (void)
19538
e4b25475ef3d provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents: 19433
diff changeset
281 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
282 QString text = m_filter->currentText (); // get current text
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
283 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
284
010cef260698 improve filter of workspace view
Torsten <ttl@justmail.de>
parents: 19539
diff changeset
285 if (index > -1)
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
286 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
287
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
288 m_filter->insertItem (0, text); // (re)insert at beginning
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
289 m_filter->setCurrentIndex (0);
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
290 }
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
291
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
292 void
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
293 workspace_view::header_contextmenu_requested (const QPoint& mpos)
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
294 {
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
295 QMenu menu (this);
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
296
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
297 if (m_sig_mapper)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
298 delete m_sig_mapper;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
299 m_sig_mapper = new QSignalMapper (this);
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
300
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
301 QSettings *settings = resource_manager::get_settings ();
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
302
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
303 for (int i = 0; i < m_columns_shown.size (); i++)
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
304 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
305 QAction *action = menu.addAction (m_columns_shown.at (i),
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
306 m_sig_mapper, SLOT (map ()));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
307 m_sig_mapper->setMapping (action, i);
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
308 action->setCheckable (true);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
309 action->setChecked (settings->value (m_columns_shown_keys.at (i),true).toBool ());
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
310 }
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
311
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
312 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
313
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
314 menu.exec (m_view->mapToGlobal (mpos));
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
315 }
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
316
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
317 void
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
318 workspace_view::toggle_header (int col)
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
319 {
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
320 QSettings *settings = resource_manager::get_settings ();
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
321
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
322 QString key = m_columns_shown_keys.at (col);
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
323 bool shown = settings->value (key,true).toBool ();
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
324
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
325 m_view->setColumnHidden (col + 1, shown);
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
326
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
327 settings->setValue (key, ! shown);
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
328 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
329
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 21724
diff changeset
330 octave_dock_widget::save_settings ();
20641
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
331 }
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
332
2b0886f2c186 add possibility to hide columns of workspace view
Torsten <ttl@justmail.de>
parents: 20570
diff changeset
333 void
16572
17941fedd4ce Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16570
diff changeset
334 workspace_view::contextmenu_requested (const QPoint& qpos)
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
335 {
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
336 QMenu menu (this);
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
337
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
338 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
339
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
340 // if it isnt Local, Glocal etc, allow the ctx menu
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17744
diff changeset
341 if (index.isValid () && index.column () == 0)
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
342 {
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
343 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
344
23945
cf16f6521180 double clicking a variable in workspace view opens variable editor (bug #51843)
Torsten <mttl@mailbox.org>
parents: 23927
diff changeset
345 menu.addAction (tr ("Open in Variable Editor"), this,
cf16f6521180 double clicking a variable in workspace view opens variable editor (bug #51843)
Torsten <mttl@mailbox.org>
parents: 23927
diff changeset
346 SLOT (handle_contextmenu_edit ()));
cf16f6521180 double clicking a variable in workspace view opens variable editor (bug #51843)
Torsten <mttl@mailbox.org>
parents: 23927
diff changeset
347
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
348 menu.addAction (tr ("Copy name"), this,
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
349 SLOT (handle_contextmenu_copy ()));
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
350
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
351 menu.addAction (tr ("Copy value"), this,
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
352 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
353
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
354 QAction *rename = menu.addAction (tr ("Rename"), this,
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
355 SLOT (handle_contextmenu_rename ()));
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
356
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
357 QAbstractItemModel *m = m_view->model ();
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
358 const workspace_model *wm = static_cast<const workspace_model *> (m);
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
359
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
360 if (! wm->is_top_level ())
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
361 {
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
362 rename->setDisabled (true);
20763
28eae9b7aa30 Tweak GUI ToolTip strings for consistency.
Armin Müller <arm.in@web.de>
parents: 20388
diff changeset
363 rename->setToolTip (tr ("Only top-level symbols may be renamed"));
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
364 }
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
365
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
366 menu.addSeparator ();
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
367
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23803
diff changeset
368 menu.addAction ("disp (" + var_name + ')', this,
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
369 SLOT (handle_contextmenu_disp ()));
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
370
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23803
diff changeset
371 menu.addAction ("plot (" + var_name + ')', this,
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
372 SLOT (handle_contextmenu_plot ()));
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
373
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23803
diff changeset
374 menu.addAction ("stem (" + var_name + ')', this,
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
375 SLOT (handle_contextmenu_stem ()));
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
376
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
377 menu.addSeparator ();
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
378
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
379 }
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
380
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
381 if (m_filter_shown)
20570
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
382 menu.addAction (tr ("Hide filter"), this,
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
383 SLOT (handle_contextmenu_filter ()));
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
384 else
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
385 menu.addAction (tr ("Show filter"), this,
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
386 SLOT (handle_contextmenu_filter ()));
734d446560a8 possibility to hide filters in history and workspace view (bug#45428)
Torsten <ttl@justmail.de>
parents: 20388
diff changeset
387
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
388 menu.exec (m_view->mapToGlobal (qpos));
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
389 }
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
390
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
391 void
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
392 workspace_view::handle_contextmenu_copy (void)
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
393 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
394 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
395
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
396 if (index.isValid ())
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
397 {
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
398 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
399
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
400 QClipboard *clipboard = QApplication::clipboard ();
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
401
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
402 clipboard->setText (var_name);
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
403 }
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
404 }
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
405
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
406 void
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
407 workspace_view::handle_contextmenu_copy_value (void)
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
408 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
409 QModelIndex index = m_view->currentIndex ();
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
410
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
411 if (index.isValid ())
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
412 {
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
413 QString var_name = get_var_name (index);
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
414
24361
8bcfddad15ec use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents: 24301
diff changeset
415 octave::symbol_scope scope
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
416 = octave::__get_current_scope__ ("workspace_view::handle_contextmenu_copy_value");
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23449
diff changeset
417
24361
8bcfddad15ec use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents: 24301
diff changeset
418 octave_value val = scope ? scope.varval (var_name.toStdString ()) : 0;
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
419 std::ostringstream buf;
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
420 val.print_raw (buf, true);
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
421
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
422 QClipboard *clipboard = QApplication::clipboard ();
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
423 clipboard->setText (QString::fromStdString (buf.str ()));
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
424 }
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
425 }
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
426
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
427 void
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
428 workspace_view::handle_contextmenu_rename (void)
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
429 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
430 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
431
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
432 if (index.isValid ())
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
433 {
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
434 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
435
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
436 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
437
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
438 inputDialog->setOptions (QInputDialog::NoButtons);
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
439
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
440 bool ok = false;
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
441
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
442 QString new_name
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23693
diff changeset
443 = inputDialog->getText (nullptr, "Rename Variable", "New name:",
21568
3d60ed163b70 maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents: 21301
diff changeset
444 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
445
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
446 if (ok && ! new_name.isEmpty ())
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
447 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
448 QAbstractItemModel *m = m_view->model ();
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
449 m->setData (index, new_name, Qt::EditRole);
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
450 }
16521
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
451 }
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
452 }
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
453
dbc7018be4be use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
454 void
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
455 workspace_view::handle_contextmenu_edit (void)
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
456 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
457 QModelIndex index = m_view->currentIndex ();
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
458
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
459 if (index.isValid ())
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
460 {
24648
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
461 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
462
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
463 octave::symbol_scope scope = m_model->scope ();
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
464
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
465 octave_value val;
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
466 if (scope)
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
467 val = scope.varval (var_name.toStdString ());
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
468
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
469 emit edit_variable_signal (var_name, val);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
470 }
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
471 }
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
472
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
473 void
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
474 workspace_view::handle_contextmenu_disp (void)
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
475 {
16575
1a1f8199b5bb generate single-line commands from workspace view context menu
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
476 relay_contextmenu_command ("disp");
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
477 }
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
478
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
479 void
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
480 workspace_view::handle_contextmenu_plot (void)
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
481 {
16575
1a1f8199b5bb generate single-line commands from workspace view context menu
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
482 relay_contextmenu_command ("figure (); plot");
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
483 }
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
484
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
485 void
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
486 workspace_view::handle_contextmenu_stem (void)
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
487 {
16575
1a1f8199b5bb generate single-line commands from workspace view context menu
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
488 relay_contextmenu_command ("figure (); stem");
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
489 }
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
490
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
491 void
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
492 workspace_view::handle_contextmenu_filter (void)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
493 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
494 m_filter_shown = ! m_filter_shown;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
495 m_filter_widget->setVisible (m_filter_shown);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
496 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
497
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
498 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
499 workspace_view::handle_model_changed (void)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
500 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
501 // m_view->resizeRowsToContents ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
502 // Just modify those rows that have been added rather than go through
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
503 // the whole list. For-loop test will handle when number of rows reduced.
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
504 QFontMetrics fm = m_view->fontMetrics ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
505 int row_height = fm.height ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
506 int new_row_count = m_filter_model.rowCount ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
507 for (int i = m_view_previous_row_count; i < new_row_count; i++)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
508 m_view->setRowHeight (i, row_height);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
509 m_view_previous_row_count = new_row_count;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
510 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
511
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
512 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
513 workspace_view::copyClipboard ()
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
514 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
515 if (m_view->hasFocus ())
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
516 handle_contextmenu_copy ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
517 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
518
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
519 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
520 workspace_view::selectAll ()
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
521 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
522 if (m_view->hasFocus ())
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
523 m_view->selectAll ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
524 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
525
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
526 void
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
527 workspace_view::relay_contextmenu_command (const QString& cmdname)
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
528 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
529 QModelIndex index = m_view->currentIndex ();
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
530
16477
64727ed135cb use QTableView instead of QTreeView to display workspace
John Donoghue <john.donoghue@ieee.org>
parents: 16468
diff changeset
531 if (index.isValid ())
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
532 {
19433
2f0c21339e9d values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents: 19162
diff changeset
533 QString 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
534
16575
1a1f8199b5bb generate single-line commands from workspace view context menu
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
535 emit command_requested (cmdname + " (" + var_name + ");");
16462
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
536 }
8c666c7b0e5d Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents: 16459
diff changeset
537 }
16572
17941fedd4ce Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16570
diff changeset
538
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
539 QString
24648
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
540 workspace_view::get_var_name (const QModelIndex& index)
16572
17941fedd4ce Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16570
diff changeset
541 {
24648
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
542 // We are using a sort model proxy so m_model won't provide the
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
543 // correct ordering.
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
544
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
545 QAbstractItemModel *m = m_view->model ();
24648
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
546
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
547 QMap<int, QVariant> item_data
1f1ac73910ab respect sorting in variable editor (bug #51843)
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
548 = 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
549
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23945
diff changeset
550 return item_data[0].toString ();
16610
a1f613e5066d workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents: 16575
diff changeset
551 }