Mercurial > octave-nkf
annotate libgui/src/workspace-view.cc @ 19572:e4b25475ef3d gui-release
provide a filter for the workspace view (bug #41222)
* workspace_view.cc (constructor): new combo-box for filter expressions,
new check box for enable/disable filter, connect related signals, get
last state of filter and check box from settings file;
(destructor): write state of filter and check box into settings file;
(setModel): use a filter proxy model between model and table view;
(filter_update): new slot for updating the filter expression;
(filter_activate): new slot enabling or disabling the filter;
(update_filter_history): new slot for saving the filter expression when
its edtitign has finished;
(handle_model_changed): actual row count is now taken from the filter model
* workspace_view.h: new slots filter_activate, filter_update, and
update_filter_history; new class variables for check box, filter combo box,
and filter model
author | Torsten <ttl@justmail.de> |
---|---|
date | Wed, 07 Jan 2015 18:16:28 +0100 |
parents | 2f0c21339e9d |
children | 77e58a7945b3 |
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 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
3 Copyright (C) 2013 John W. Eaton |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
16881
diff
changeset
|
4 Copyright (C) 2011-2013 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 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
8 Octave is free software; you can redistribute it and/or modify it |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
9 under the terms of the GNU General Public License as published by the |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
10 Free Software Foundation; either version 3 of the License, or (at your |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
11 option) any later version. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
12 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
16 for more details. |
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 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
20 <http://www.gnu.org/licenses/>. |
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 | 23 |
15286
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15204
diff
changeset
|
24 #ifdef HAVE_CONFIG_H |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15204
diff
changeset
|
25 #include <config.h> |
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 | 34 #include <QHBoxLayout> |
35 #include <QVBoxLayout> | |
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> |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
38 #include <QLabel> |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
39 #include <QCompleter> |
13501 | 40 |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
41 #include "workspace-view.h" |
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
42 #include "resource-manager.h" |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
43 #include "symtab.h" |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
44 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
45 workspace_view::workspace_view (QWidget *p) |
16521
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
46 : octave_dock_widget (p), view (new QTableView (this)) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
47 { |
13683
25dc40d24a44
Renamed VariablesDockWidget to WorkspaceView and optimized memory footprint for 30%.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13678
diff
changeset
|
48 setObjectName ("WorkspaceView"); |
16478
079ec7ce60e0
delete useless connection; style fixes
John W. Eaton <jwe@octave.org>
parents:
16477
diff
changeset
|
49 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
|
50 set_title (tr ("Workspace")); |
16459
cbc39a3d0c42
improve encapsulation of workspace window object
John W. Eaton <jwe@octave.org>
parents:
16445
diff
changeset
|
51 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
|
52 |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
53 _filter = new QComboBox (this); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
54 _filter->setToolTip (tr ("Enter the path or filename")); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
55 _filter->setEditable (true); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
56 _filter->setMaxCount (MaxFilterHistory); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
57 _filter->setInsertPolicy (QComboBox::NoInsert); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
58 _filter->setSizeAdjustPolicy ( |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
59 QComboBox::AdjustToMinimumContentsLengthWithIcon); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
60 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Maximum); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
61 _filter->setSizePolicy (sizePol); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
62 _filter->completer ()->setCaseSensitivity (Qt::CaseSensitive); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
63 |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
64 QLabel *filter_label = new QLabel (tr ("Filter")); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
65 |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
66 _filter_checkbox = new QCheckBox (); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
67 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
68 view->setWordWrap (false); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
69 view->setContextMenuPolicy (Qt::CustomContextMenu); |
19196
362071d9bf5b
replace grid with alternating row colors in workspace view (bug #43196)
Torsten <ttl@justmail.de>
parents:
19076
diff
changeset
|
70 view->setShowGrid (false); |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
71 (view->verticalHeader) ()->hide (); |
19196
362071d9bf5b
replace grid with alternating row colors in workspace view (bug #43196)
Torsten <ttl@justmail.de>
parents:
19076
diff
changeset
|
72 view->setAlternatingRowColors (true); |
16572
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
73 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
|
74 |
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
|
75 // 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
|
76 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
|
77 |
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
|
78 // Create a new layout and add widgets to it. |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
79 QVBoxLayout *vbox_layout = new QVBoxLayout (); |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
80 QHBoxLayout *hbox_layout = new QHBoxLayout (); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
81 hbox_layout->addWidget (filter_label); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
82 hbox_layout->addWidget (_filter_checkbox); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
83 hbox_layout->addWidget (_filter); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
84 vbox_layout->addLayout (hbox_layout); |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
85 vbox_layout->addWidget (view); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
86 vbox_layout->setMargin (2); |
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
|
87 |
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
|
88 // Set the empty widget to have our layout. |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
89 widget ()->setLayout (vbox_layout); |
13501 | 90 |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
91 // Filter model |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
92 _filter_model = new QSortFilterProxyModel (); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
93 _filter_model->setFilterKeyColumn(0); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
94 |
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
|
95 // 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
|
96 |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14997
diff
changeset
|
97 QSettings *settings = resource_manager::get_settings (); |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14997
diff
changeset
|
98 |
15460
7f36f7dc25b2
save and restore the columns order and width of the workspace-view
Torsten <ttl@justmail.de>
parents:
15389
diff
changeset
|
99 // Initialize column order and width of the workspace |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 view->horizontalHeader ()->restoreState ( |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 settings->value ("workspaceview/column_state").toByteArray ()); |
15460
7f36f7dc25b2
save and restore the columns order and width of the workspace-view
Torsten <ttl@justmail.de>
parents:
15389
diff
changeset
|
102 |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
103 // Init state of the filter |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
104 _filter->addItems (settings->value ("workspaceview/mru_list").toStringList ()); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
105 |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
106 bool filter_state = |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
107 settings->value ("workspaceview/filter_active", false).toBool (); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
108 _filter_checkbox->setChecked (filter_state); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
109 filter_activate (filter_state); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
110 |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
111 // 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
|
112 |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
113 connect (_filter, SIGNAL (editTextChanged (const QString&)), |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
114 this, SLOT (filter_update (const QString&))); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
115 connect (_filter_checkbox, SIGNAL (toggled (bool)), |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
116 this, SLOT (filter_activate (bool))); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
117 connect (_filter->lineEdit (), SIGNAL (editingFinished ()), |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
118 this, SLOT (update_filter_history ())); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
119 |
16478
079ec7ce60e0
delete useless connection; style fixes
John W. Eaton <jwe@octave.org>
parents:
16477
diff
changeset
|
120 connect (view, SIGNAL (customContextMenuRequested (const QPoint&)), |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 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
|
122 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
123 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
|
124 p, SLOT (execute_command_in_terminal (const QString&))); |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
125 |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
126 } |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
127 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
128 workspace_view::~workspace_view (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
|
129 { |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14997
diff
changeset
|
130 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
|
131 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
132 settings->setValue ("workspaceview/column_state", |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 view->horizontalHeader ()->saveState ()); |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
134 settings->setValue ("workspaceview/filter_active", |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
135 _filter_checkbox->isChecked ()); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
136 |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
137 QStringList mru; |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
138 for (int i = 0; i < _filter->count (); i++) |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
139 mru.append (_filter->itemText (i)); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
140 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
|
141 |
16175
6f83158c714c
gui: make sure settings are really written into the settings file
Torsten <ttl@justmail.de>
parents:
15552
diff
changeset
|
142 settings->sync (); |
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
|
143 } |
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
|
144 |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
145 void workspace_view::setModel (workspace_model *model) |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
146 { |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
147 _filter_model->setSourceModel (model); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
148 view->setModel (_filter_model); |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
149 _model = model; |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
150 } |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
151 |
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
|
152 void |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
153 workspace_view::closeEvent (QCloseEvent *e) |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
154 { |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
155 emit active_changed (false); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
156 QDockWidget::closeEvent (e); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
157 } |
15552
bbbb89cc338f
make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents:
15460
diff
changeset
|
158 |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
159 void |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
160 workspace_view::filter_update (const QString& expression) |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
161 { |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
162 _filter_model->setFilterRegExp (QRegExp (expression, |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
163 Qt::CaseSensitive, QRegExp::FixedString)); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
164 handle_model_changed (); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
165 } |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
166 |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
167 void |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
168 workspace_view::filter_activate (bool state) |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
169 { |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
170 _filter->setEnabled (state); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
171 _filter_model->setDynamicSortFilter (state); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
172 |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
173 if (state) |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
174 filter_update (_filter->currentText ()); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
175 else |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
176 filter_update (QString ()); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
177 } |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
178 |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
179 void |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
180 workspace_view::update_filter_history () |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
181 { |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
182 QString text = _filter->currentText (); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
183 if (! text.isEmpty () && _filter->findText (text) == -1) |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
184 _filter->insertItem (0, _filter->currentText ()); |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
185 } |
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
186 |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
187 QString |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
188 workspace_view::get_var_name (QModelIndex index) |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
189 { |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
190 index = index.sibling (index.row (), 0); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
191 QAbstractItemModel *m = view->model (); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
192 QMap<int, QVariant> item_data = m->itemData (index); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
193 |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
194 return item_data[0].toString (); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
195 } |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
196 |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
197 void |
16572
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
198 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
|
199 { |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
200 QMenu menu (this); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
201 |
16572
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
202 QModelIndex index = view->indexAt (qpos); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
203 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
204 // 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
|
205 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
|
206 { |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
207 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
|
208 |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
209 menu.addAction (tr ("Copy name"), this, |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
210 SLOT (handle_contextmenu_copy ())); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
211 |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
212 menu.addAction (tr ("Copy value"), this, |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
213 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
|
214 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
215 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
|
216 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
|
217 |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
218 QAbstractItemModel *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
|
219 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
|
220 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
221 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
|
222 { |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
223 rename->setDisabled (true); |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
224 rename->setToolTip (tr ("Only top-level symbols may be renamed.")); |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
225 } |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
226 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
227 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
|
228 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
229 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
|
230 SLOT (handle_contextmenu_disp ())); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
231 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
232 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
|
233 SLOT (handle_contextmenu_plot ())); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
234 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
235 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
|
236 SLOT (handle_contextmenu_stem ())); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
237 |
16572
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
238 menu.exec (view->mapToGlobal (qpos)); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
239 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
240 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
241 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
242 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
|
243 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
|
244 { |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
245 QModelIndex index = view->currentIndex (); |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
246 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
247 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
|
248 { |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
249 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
|
250 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
251 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
|
252 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
253 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
|
254 } |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
255 } |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
256 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
257 void |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
258 workspace_view::handle_contextmenu_copy_value (void) |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
259 { |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
260 QModelIndex index = view->currentIndex (); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
261 |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
262 if (index.isValid ()) |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
263 { |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
264 QString var_name = get_var_name (index); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
265 |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
266 octave_value val = symbol_table::varval (var_name.toStdString ()); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
267 std::ostringstream buf; |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
268 val.print_raw (buf, true); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
269 |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
270 QClipboard *clipboard = QApplication::clipboard (); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
271 clipboard->setText (QString::fromStdString (buf.str ())); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
272 } |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
273 } |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
274 |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
275 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
|
276 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
|
277 { |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
278 QModelIndex index = view->currentIndex (); |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
279 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
280 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
|
281 { |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
282 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
|
283 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
284 QInputDialog* inputDialog = new QInputDialog (); |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
285 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
286 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
|
287 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
288 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
|
289 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
290 QString new_name |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
291 = inputDialog->getText (0, "Rename Variable", "New name:", |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
292 QLineEdit::Normal, var_name, &ok); |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
293 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
294 if (ok && ! new_name.isEmpty ()) |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
295 { |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
296 QAbstractItemModel *m = view->model (); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
297 m->setData (index, new_name, Qt::EditRole); |
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
298 } |
16521
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
299 } |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
300 } |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
301 |
dbc7018be4be
use context menu for workspace viewer rename and copy to clipboard operations
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
302 void |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
303 workspace_view::handle_contextmenu_disp (void) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
304 { |
16575
1a1f8199b5bb
generate single-line commands from workspace view context menu
John W. Eaton <jwe@octave.org>
parents:
16572
diff
changeset
|
305 relay_contextmenu_command ("disp"); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
306 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
307 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
308 void |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
309 workspace_view::handle_contextmenu_plot (void) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
310 { |
16575
1a1f8199b5bb
generate single-line commands from workspace view context menu
John W. Eaton <jwe@octave.org>
parents:
16572
diff
changeset
|
311 relay_contextmenu_command ("figure (); plot"); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
312 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
313 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
314 void |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
315 workspace_view::handle_contextmenu_stem (void) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
316 { |
16575
1a1f8199b5bb
generate single-line commands from workspace view context menu
John W. Eaton <jwe@octave.org>
parents:
16572
diff
changeset
|
317 relay_contextmenu_command ("figure (); stem"); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
318 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
319 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
320 void |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
321 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
|
322 { |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
323 QModelIndex index = view->currentIndex (); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
324 |
16477
64727ed135cb
use QTableView instead of QTreeView to display workspace
John Donoghue <john.donoghue@ieee.org>
parents:
16468
diff
changeset
|
325 if (index.isValid ()) |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
326 { |
19467
2f0c21339e9d
values of variables in workspace view copyable (bug #43674)
Torsten <ttl@justmail.de>
parents:
19196
diff
changeset
|
327 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
|
328 |
16575
1a1f8199b5bb
generate single-line commands from workspace view context menu
John W. Eaton <jwe@octave.org>
parents:
16572
diff
changeset
|
329 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
|
330 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
331 } |
16572
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
332 |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
333 void |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
334 workspace_view::handle_model_changed (void) |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
335 { |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
336 // view->resizeRowsToContents (); |
16572
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
337 // Just modify those rows that have been added rather than go through |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
338 // the whole list. For-loop test will handle when number of rows reduced. |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
339 QFontMetrics fm = view->fontMetrics (); |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
340 int row_height = fm.height (); |
19572
e4b25475ef3d
provide a filter for the workspace view (bug #41222)
Torsten <ttl@justmail.de>
parents:
19467
diff
changeset
|
341 int new_row_count = _filter_model->rowCount (); |
16572
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
342 for (int i = view_previous_row_count; i < new_row_count; i++) |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
343 view->setRowHeight (i, row_height); |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
344 view_previous_row_count = new_row_count; |
17941fedd4ce
Change workspace row height to font height.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16570
diff
changeset
|
345 } |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
346 |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
347 void |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
348 workspace_view::notice_settings (const QSettings *settings) |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
349 { |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
350 _model->notice_settings (settings); // update colors of model first |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
351 |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
352 QString tool_tip; |
19076
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
353 |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
354 if (!settings->value ("workspaceview/hide_tool_tips",false).toBool ()) |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
355 { |
19076
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
356 tool_tip = QString (tr ("View the variables in the active workspace.<br>")); |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
357 tool_tip += QString (tr ("Colors for variable attributes:")); |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
358 for (int i = 0; i < resource_manager::storage_class_chars ().length (); i++) |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
359 { |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
360 tool_tip += |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
361 QString ("<div style=\"background-color:%1;color:#000000\">%2</div>") |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
362 .arg (_model->storage_class_color (i).name ()) |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
363 .arg (resource_manager::storage_class_names ().at (i)); |
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
364 } |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
365 } |
19076
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
366 |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
367 setToolTip (tool_tip); |
19076
110702c507e3
user setting for hiding the tool tip in the workspace view (part of bug #42306)
Torsten <ttl@justmail.de>
parents:
18568
diff
changeset
|
368 |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16575
diff
changeset
|
369 } |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
370 |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
371 void |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
372 workspace_view::copyClipboard () |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
373 { |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
374 if (view->hasFocus ()) |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
375 handle_contextmenu_copy (); |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
376 } |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16798
diff
changeset
|
377 |
18568
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18345
diff
changeset
|
378 void |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18345
diff
changeset
|
379 workspace_view::selectAll () |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18345
diff
changeset
|
380 { |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18345
diff
changeset
|
381 if (view->hasFocus ()) |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18345
diff
changeset
|
382 view->selectAll (); |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18345
diff
changeset
|
383 } |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
18345
diff
changeset
|
384 |