Mercurial > octave-nkf
annotate libgui/src/workspace-view.cc @ 16468:0f143f68078d
use signal/slot for updating workspace instead of using event listener
* main-window.h, main-window.cc: Clean up list of include files.
(main_window::prepare_to_exit): Rename from prepare_to_quit. Change
all uses.
(main_window::update_workspace): Delete.
(main_window::construct): Don't connect
_octave_qt_event_listener:update_workspace_signal to
main_window::update_workspace.
(main_window::construct_octave_qt_link):
Connect _octave_qt_link::set_workspace_signal to
_workspace_model::set_workspace.
Connect _octave_qt_link::clear_workspace_signal to
_workspace_model::clear_workspace.
* symbol-information.h, symbol-information.cc: Delete
* libgui/src/module.mk (noinst_HEADERS, src_libgui_src_la_SOURCES):
Remove them from the lists.
* octave-qt-link.h, octave-qt-link.cc: Don't use symbol_information to
store workspace info.
(octave_qt_link::do_update_workspace): Delete.
(octave_qt_link::do_set_workspace,
octave_qt_link::do_clear_workspace): New functions.
(octave_qt_link::do_pre_input_event): Don't call do_update_workspace.
(octave_qt_link::set_workspace_signal,
octave_qt_link::clear_workspace_signal): New signals.
* workspace-model.h, workspace-model.cc: Don't use symbol_information
to store workspace info. Accept workspace info through a signal/slot
combination, not by asking the symbol table.
(workspace_model::request_update_workspace,
(workspace_model::update_workspace_callback): Delete.
(workspace_model::set_workspace, workspace_model::clear_workspace,
workspace_model::clear_data, workspace_model::clear_tree,
workspace_model::update_tree, workspace_model::append_tree):
New functions.
* workspace-view.h, workspace-view.cc (workspace_view::model_changed):
Don't call update_workspace_callback. The model now signals the view
when it has changed.
* input.cc (octave_base_reader::octave_gets, get_debug_input):
Call octave_link::set_workspace just prior to prompting for input.
* workspace-element.h: New file.
* libinterp/interpfcn/module.mk (INTERPFCN_INC): Include it in the list.
* octave-link.cc: Don't include symtab.h.
* octave-link.h (octave_link::update_workspace): Delete.
(octave_link::set_workspace, octave_link::do_set_workspace,
* octave_link::clear_workspace, octave_link::do_clear_workspace):
New functions.
* symtab.h, symtab.cc (symbol_table::workspace_info,
symbol_table::do_workspace_info): New functions.
* ov.h (octave_value::short_disp): New function.
* ov-base.h, ov-base.cc (octave_base_value::short_disp): New function.
* ov-base-scalar.h, ov-base-scalar.cc
(octave_base_scalar<ST>::short_disp): New function.
* ov-range.h, ov-range.cc (octave_range::short_disp): New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 08 Apr 2013 12:01:24 -0400 |
parents | 8e2a853cdd7d |
children | 64727ed135cb |
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 |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
4 Copyright (C) 2011-2012 Jacob Dawid |
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 |
14707
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
28 #include "workspace-view.h" |
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
|
29 #include "resource-manager.h" |
15460
7f36f7dc25b2
save and restore the columns order and width of the workspace-view
Torsten <ttl@justmail.de>
parents:
15389
diff
changeset
|
30 #include <QHeaderView> |
13501 | 31 #include <QHBoxLayout> |
32 #include <QVBoxLayout> | |
33 #include <QPushButton> | |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
34 #include <QMenu> |
13501 | 35 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
36 workspace_view::workspace_view (QWidget *p) |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
37 : octave_dock_widget (p) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
38 { |
13683
25dc40d24a44
Renamed VariablesDockWidget to WorkspaceView and optimized memory footprint for 30%.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13678
diff
changeset
|
39 setObjectName ("WorkspaceView"); |
15552
bbbb89cc338f
make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents:
15460
diff
changeset
|
40 setWindowIcon (QIcon(":/actions/icons/logo.png")); |
13523
103b7bebb38f
Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
41 setWindowTitle (tr ("Workspace")); |
16459
cbc39a3d0c42
improve encapsulation of workspace window object
John W. Eaton <jwe@octave.org>
parents:
16445
diff
changeset
|
42 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
|
43 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
44 view = new QTreeView (this); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
45 |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
46 view->setHeaderHidden (false); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
47 view->setAlternatingRowColors (true); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
48 view->setAnimated (false); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
49 view->setTextElideMode (Qt::ElideRight); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
50 view->setWordWrap (false); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
51 view->setContextMenuPolicy (Qt::CustomContextMenu); |
13523
103b7bebb38f
Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
52 |
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
|
53 // 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
|
54 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
|
55 |
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
|
56 // 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
|
57 QVBoxLayout *vbox_layout = new QVBoxLayout (); |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
58 vbox_layout->addWidget (view); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
59 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
|
60 |
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
|
61 // 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
|
62 widget ()->setLayout (vbox_layout); |
13501 | 63 |
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
|
64 // 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
|
65 |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14997
diff
changeset
|
66 QSettings *settings = resource_manager::get_settings (); |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14997
diff
changeset
|
67 |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14997
diff
changeset
|
68 // FIXME -- what should happen if settings is 0? |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14997
diff
changeset
|
69 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
70 _explicit_collapse.local |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
71 = settings->value ("workspaceview/local_collapsed", false).toBool (); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
72 |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
73 _explicit_collapse.global |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
74 = settings->value ("workspaceview/global_collapsed", false).toBool (); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
75 |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
76 _explicit_collapse.persistent |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
77 = settings->value ("workspaceview/persistent_collapsed", false).toBool (); |
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
|
78 |
15460
7f36f7dc25b2
save and restore the columns order and width of the workspace-view
Torsten <ttl@justmail.de>
parents:
15389
diff
changeset
|
79 // Initialize column order and width of the workspace |
7f36f7dc25b2
save and restore the columns order and width of the workspace-view
Torsten <ttl@justmail.de>
parents:
15389
diff
changeset
|
80 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
81 view->header ()->restoreState (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
|
82 |
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
|
83 // Connect signals and slots. |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
84 connect (view, SIGNAL (collapsed (QModelIndex)), |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
85 this, SLOT (collapse_requested (QModelIndex))); |
16459
cbc39a3d0c42
improve encapsulation of workspace window object
John W. Eaton <jwe@octave.org>
parents:
16445
diff
changeset
|
86 |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
87 connect (view, SIGNAL (expanded (QModelIndex)), |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
88 this, SLOT (expand_requested (QModelIndex))); |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
89 |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
90 connect (view, SIGNAL (doubleClicked (QModelIndex)), |
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
|
91 this, SLOT (item_double_clicked (QModelIndex))); |
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
|
92 |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
93 connect (view, SIGNAL (customContextMenuRequested(const QPoint&)), |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
94 this, SLOT(contextmenu_requested (const QPoint&))); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
95 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
96 connect (this, SIGNAL (command_requested (const QString&)), |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
97 p, SLOT (handle_command_double_clicked(const QString&))); |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
98 } |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
99 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
100 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
|
101 { |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
14997
diff
changeset
|
102 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
|
103 |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
104 settings->setValue ("workspaceview/local_collapsed", |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
105 _explicit_collapse.local); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
106 |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
107 settings->setValue ("workspaceview/global_collapsed", |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
108 _explicit_collapse.global); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
109 |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
110 settings->setValue ("workspaceview/persistent_collapsed", |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
111 _explicit_collapse.persistent); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
112 |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
113 settings->setValue("workspaceview/column_state", |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
114 view->header ()->saveState ()); |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
115 |
16175
6f83158c714c
gui: make sure settings are really written into the settings file
Torsten <ttl@justmail.de>
parents:
15552
diff
changeset
|
116 settings->sync (); |
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
|
117 } |
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
|
118 |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
119 void |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
120 workspace_view::model_changed () |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
121 { |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
122 QAbstractItemModel *m = view->model (); |
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
123 |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
124 // This code is very quirky and requires some explanation. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
125 // Usually, we should not deal with collapsing or expanding ourselves, |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
126 // because the view itself determines (based on the model) whether it |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
127 // is appropriate to collapse or expand items. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
128 // |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
129 // Now, the logic requires that we update our model item by item, which |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
130 // would make it work correctly, but this is extremely slow and scales |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
131 // very bad (O(n^2)). That's why we throw away our model and rebuild it |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
132 // completely from scratch (O(n)), which is why the view renders all |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
133 // displayed data as invalid. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
134 // |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
135 // In order to make collapsing/expanding work again, we need to set |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
136 // flags ourselves here. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
137 |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
138 QModelIndex local_model_index = m->index (0, 0); |
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
139 QModelIndex global_model_index = m->index (1, 0); |
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
140 QModelIndex persistent_model_index = m->index (2, 0); |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
141 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
142 if (_explicit_collapse.local) |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
143 view->collapse (local_model_index); |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
144 else |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
145 view->expand (local_model_index); |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
146 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
147 if (_explicit_collapse.global) |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
148 view->collapse (global_model_index); |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
149 else |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
150 view->expand (global_model_index); |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
151 |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
152 if (_explicit_collapse.persistent) |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
153 view->collapse (persistent_model_index); |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
154 else |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
155 view->expand (persistent_model_index); |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
156 } |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
157 |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
158 void |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
159 workspace_view::collapse_requested (QModelIndex index) |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
160 { |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
161 // This code is very quirky and requires some explanation. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
162 // Usually, we should not deal with collapsing or expanding ourselves, |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
163 // because the view itself determines (based on the model) whether it |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
164 // is appropriate to collapse or expand items. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
165 // |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
166 // Now, the logic requires that we update our model item by item, which |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
167 // would make it work correctly, but this is extremely slow and scales |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
168 // very bad (O(n^2)). That's why we throw away our model and rebuild it |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
169 // completely from scratch (O(n)), which is why the view renders all |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
170 // displayed data as invalid. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
171 // |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
172 // In order to make collapsing/expanding work again, we need to set |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
173 // flags ourselves here. |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
174 QAbstractItemModel *m = view->model (); |
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
175 |
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
176 QMap<int, QVariant> item_data = m->itemData (index); |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
177 |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
178 if (item_data[0] == "Local") |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
179 _explicit_collapse.local = true; |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
180 |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
181 if (item_data[0] == "Global") |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
182 _explicit_collapse.global = true; |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
183 |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
184 if (item_data[0] == "Persistent") |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
185 _explicit_collapse.persistent = true; |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
186 } |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
187 |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
188 void |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
189 workspace_view::expand_requested (QModelIndex index) |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
190 { |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
191 // This code is very quirky and requires some explanation. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
192 // Usually, we should not deal with collapsing or expanding ourselves, |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
193 // because the view itself determines (based on the model) whether it |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
194 // is appropriate to collapse or expand items. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
195 // |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
196 // Now, the logic requires that we update our model item by item, which |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
197 // would make it work correctly, but this is extremely slow and scales |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
198 // very bad (O(n^2)). That's why we throw away our model and rebuild it |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
199 // completely from scratch (O(n)), which is why the view renders all |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
200 // displayed data as invalid. |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
201 // |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
202 // In order to make collapsing/expanding work again, we need to do set |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
203 // flags ourselves here. |
16445
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
204 QAbstractItemModel *m = view->model (); |
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
205 |
3f8d3fc907af
store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents:
16444
diff
changeset
|
206 QMap<int, QVariant> item_data = m->itemData (index); |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
207 |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
208 if (item_data[0] == "Local") |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
209 _explicit_collapse.local = false; |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
210 |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
211 if (item_data[0] == "Global") |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
212 _explicit_collapse.global = false; |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
213 |
14761
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
214 if (item_data[0] == "Persistent") |
8c4d5029d933
Collapsing/Expanding items now works with a workaround.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14720
diff
changeset
|
215 _explicit_collapse.persistent = false; |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
216 } |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
217 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
218 void |
15389
f918db8102d5
eliminate use of Q_UNUSED macro
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
219 workspace_view::item_double_clicked (QModelIndex) |
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
|
220 { |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
221 // TODO: Implement opening a dialog that allows the user to change a |
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
222 // variable in the workspace. |
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
|
223 } |
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
|
224 |
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
|
225 void |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
226 workspace_view::closeEvent (QCloseEvent *e) |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
227 { |
14712
5cb54cca8a06
Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14709
diff
changeset
|
228 emit active_changed (false); |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15367
diff
changeset
|
229 QDockWidget::closeEvent (e); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13541
diff
changeset
|
230 } |
15552
bbbb89cc338f
make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents:
15460
diff
changeset
|
231 |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
232 void |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
233 workspace_view::contextmenu_requested (const QPoint& pos) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
234 { |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
235 QMenu menu (this); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
236 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
237 QModelIndex index = view->indexAt (pos); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
238 QAbstractItemModel *m = view->model (); |
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 // if it isnt Local, Glocal etc, allow the ctx menu |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
241 if (index.parent() != QModelIndex()) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
242 { |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
243 QMap<int, QVariant> item_data = m->itemData (index); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
244 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
245 QString var_name = item_data[0].toString (); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
246 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
247 menu.addAction ("disp(" + var_name + ")", this, |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
248 SLOT (handle_contextmenu_disp ())); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
249 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
250 menu.addAction ("plot(" + var_name + ")", this, |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
251 SLOT (handle_contextmenu_plot ())); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
252 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
253 menu.addAction ("stem(" + var_name + ")", this, |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
254 SLOT (handle_contextmenu_stem ())); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
255 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
256 menu.exec (view->mapToGlobal (pos)); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
257 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
258 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
259 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
260 void |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
261 workspace_view::handle_contextmenu_disp (void) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
262 { |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
263 relay_contextmenu_command ("disp"); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
264 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
265 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
266 void |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
267 workspace_view::handle_contextmenu_plot (void) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
268 { |
16463
8e2a853cdd7d
derive workspace_view from octave_dock_widget; style fixes
John W. Eaton <jwe@octave.org>
parents:
16462
diff
changeset
|
269 relay_contextmenu_command ("figure;\nplot"); |
16462
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
270 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
271 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
272 void |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
273 workspace_view::handle_contextmenu_stem (void) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
274 { |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
275 relay_contextmenu_command ("figure;\nstem"); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
276 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
277 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
278 void |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
279 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
|
280 { |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
281 QModelIndex index = view->currentIndex (); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
282 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
283 if (index.parent () != QModelIndex ()) |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
284 { |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
285 QAbstractItemModel *m = view->model (); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
286 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
287 QMap<int, QVariant> item_data = m->itemData (index); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
288 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
289 QString var_name = item_data[0].toString (); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
290 |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
291 emit command_requested (cmdname + "(" + var_name + ")\n"); |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
292 } |
8c666c7b0e5d
Added context menu to workspace variable display
John Donoghue <john.donoghue@ieee.org>
parents:
16459
diff
changeset
|
293 } |