Mercurial > octave
annotate libgui/src/workspace-model.cc @ 24766:08c92c9d48e3
move workspace view and model classes inside octave namespace
* workspace-model.h, workspace-model.cc, workspace-view.h,
workspace-view.cc: Move class declarations and definitions inside
octave namespace. Eliminate octave:: namespace qualifiers where
possible.
* octave-qt-link.h, octave-qt-link.cc: Eliminate octave:: namespace
qualifiers where possible.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 15 Feb 2018 16:52:54 -0500 |
parents | f61502510d08 |
children | 6652d3823428 |
rev | line source |
---|---|
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
1 /* |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2013-2017 John W. Eaton |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22250
diff
changeset
|
4 Copyright (C) 2011-2016 Jacob Dawid |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
5 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
6 This file is part of Octave. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
7 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24396
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24396
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
11 (at your option) any later version. |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
16 GNU General Public License for more details. |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
17 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
19 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24396
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
21 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
22 */ |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
23 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
25 # include "config.h" |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14879
diff
changeset
|
26 #endif |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14879
diff
changeset
|
27 |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
28 #include <QTreeWidget> |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16527
diff
changeset
|
29 #include <QSettings> |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14879
diff
changeset
|
30 |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
31 #include "symscope.h" |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
32 #include "utils.h" |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
33 |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16527
diff
changeset
|
34 #include "resource-manager.h" |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
14879
diff
changeset
|
35 #include "workspace-model.h" |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
36 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
37 namespace octave |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
38 { |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
39 workspace_model::workspace_model (QObject *p) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
40 : QAbstractTableModel (p) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
41 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
42 m_columnNames.append (tr ("Name")); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
43 m_columnNames.append (tr ("Class")); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
44 m_columnNames.append (tr ("Dimension")); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
45 m_columnNames.append (tr ("Value")); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
46 m_columnNames.append (tr ("Attribute")); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
47 |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
48 for (int i = 0; i < resource_manager::storage_class_chars ().length (); i++) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
49 m_storage_class_colors.append (QColor (Qt::white)); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
50 |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
51 } |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
52 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
53 QList<QColor> |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
54 workspace_model::storage_class_default_colors (void) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
55 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
56 QList<QColor> colors; |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
57 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
58 if (colors.isEmpty ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
59 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
60 colors << QColor (190, 255, 255) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
61 << QColor (220, 255, 220) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
62 << QColor (220, 220, 255) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
63 << QColor (255, 255, 190) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
64 << QColor (255, 220, 220) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
65 << QColor (255, 190, 255); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
66 } |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
67 |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
68 return colors; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
69 } |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
70 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
71 QStringList |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
72 workspace_model::storage_class_names (void) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
73 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
74 QStringList names; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
75 |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
76 if (names.isEmpty ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
77 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
78 names << QObject::tr ("automatic") |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
79 << QObject::tr ("function") |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
80 << QObject::tr ("global") |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
81 << QObject::tr ("hidden") |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
82 << QObject::tr ("inherited") |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
83 << QObject::tr ("persistent"); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
84 } |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
85 |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
86 return names; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
87 } |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
88 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
89 int |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
90 workspace_model::rowCount (const QModelIndex&) const |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
91 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
92 return m_symbols.size (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
93 } |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
94 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
95 int |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
96 workspace_model::columnCount (const QModelIndex&) const |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
97 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
98 return m_columnNames.size (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
99 } |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
100 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
101 Qt::ItemFlags |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
102 workspace_model::flags (const QModelIndex& idx) const |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
103 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
104 Qt::ItemFlags retval = Qt::NoItemFlags; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
105 |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
106 if (idx.isValid ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
107 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
108 retval |= Qt::ItemIsEnabled; |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
109 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
110 if (m_top_level && idx.column () == 0) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
111 retval |= Qt::ItemIsSelectable; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
112 } |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
113 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
114 return retval; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
115 } |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
116 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
117 QVariant |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
118 workspace_model::headerData (int section, Qt::Orientation orientation, |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
119 int role) const |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
120 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
121 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
122 return m_columnNames[section]; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
123 else |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
124 return QVariant (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
125 } |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
126 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
127 QVariant |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
128 workspace_model::data (const QModelIndex& idx, int role) const |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
129 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
130 QVariant retval; |
16478
079ec7ce60e0
delete useless connection; style fixes
John W. Eaton <jwe@octave.org>
parents:
16477
diff
changeset
|
131 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
132 if (idx.isValid ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
133 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
134 if (role == Qt::BackgroundColorRole) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
135 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
136 QString class_chars = resource_manager::storage_class_chars (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
137 int actual_class |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
138 = class_chars.indexOf (m_scopes[idx.row ()].toLatin1 ()); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
139 if (actual_class >= 0) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
140 return QVariant (m_storage_class_colors.at (actual_class)); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
141 else |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
142 return retval; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
143 } |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
144 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
145 if (role == Qt::DisplayRole |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
146 || (idx.column () == 0 && role == Qt::EditRole) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
147 || (idx.column () == 0 && role == Qt::ToolTipRole)) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
148 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
149 switch (idx.column ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
150 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
151 case 0: |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
152 if (role == Qt::ToolTipRole) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
153 retval |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
154 = QVariant (tr ("Right click to copy, rename, or display")); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
155 else |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
156 retval = QVariant (m_symbols[idx.row ()]); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
157 break; |
16478
079ec7ce60e0
delete useless connection; style fixes
John W. Eaton <jwe@octave.org>
parents:
16477
diff
changeset
|
158 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
159 case 1: |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
160 retval = QVariant (m_class_names[idx.row ()]); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
161 break; |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
162 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
163 case 2: |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
164 retval = QVariant (m_dimensions[idx.row ()]); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
165 break; |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16527
diff
changeset
|
166 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
167 case 3: |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
168 retval = QVariant (m_values[idx.row ()]); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
169 break; |
16527
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16521
diff
changeset
|
170 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
171 case 4: |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
172 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
173 QString sclass; |
17826
574ab045f70c
restore display of "persistent", "automatic", etc. removed by 53f433bae63b
John W. Eaton <jwe@octave.org>
parents:
17824
diff
changeset
|
174 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
175 QString class_chars = resource_manager::storage_class_chars (); |
17826
574ab045f70c
restore display of "persistent", "automatic", etc. removed by 53f433bae63b
John W. Eaton <jwe@octave.org>
parents:
17824
diff
changeset
|
176 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
177 int actual_class |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
178 = class_chars.indexOf (m_scopes[idx.row ()].toLatin1 ()); |
17826
574ab045f70c
restore display of "persistent", "automatic", etc. removed by 53f433bae63b
John W. Eaton <jwe@octave.org>
parents:
17824
diff
changeset
|
179 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
180 if (actual_class >= 0) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
181 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
182 QStringList class_names |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
183 = resource_manager::storage_class_names (); |
17826
574ab045f70c
restore display of "persistent", "automatic", etc. removed by 53f433bae63b
John W. Eaton <jwe@octave.org>
parents:
17824
diff
changeset
|
184 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
185 sclass = class_names.at (actual_class); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
186 } |
17826
574ab045f70c
restore display of "persistent", "automatic", etc. removed by 53f433bae63b
John W. Eaton <jwe@octave.org>
parents:
17824
diff
changeset
|
187 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
188 if (m_complex_flags[idx.row ()]) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
189 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
190 if (sclass.isEmpty ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
191 sclass = tr ("complex"); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
192 else |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
193 sclass += ", " + tr ("complex"); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
194 } |
17826
574ab045f70c
restore display of "persistent", "automatic", etc. removed by 53f433bae63b
John W. Eaton <jwe@octave.org>
parents:
17824
diff
changeset
|
195 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
196 retval = QVariant (sclass); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
197 } |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
198 break; |
17826
574ab045f70c
restore display of "persistent", "automatic", etc. removed by 53f433bae63b
John W. Eaton <jwe@octave.org>
parents:
17824
diff
changeset
|
199 } |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
200 } |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
201 } |
16478
079ec7ce60e0
delete useless connection; style fixes
John W. Eaton <jwe@octave.org>
parents:
16477
diff
changeset
|
202 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
203 return retval; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
204 } |
14664
664f54233c98
Extracted model code from the WorkspaceView and rearranged it in a new model class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
205 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
206 bool |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
207 workspace_model::setData (const QModelIndex& idx, const QVariant& value, |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
208 int role) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
209 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
210 bool retval = false; |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
211 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
212 if (idx.column () == 0 && role == Qt::EditRole) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
213 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
214 QString qold_name = m_symbols[idx.row ()]; |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
215 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
216 QString qnew_name = value.toString (); |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
217 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
218 std::string new_name = qnew_name.toStdString (); |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
219 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
220 if (valid_identifier (new_name)) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
221 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
222 emit rename_variable (qold_name, qnew_name); |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
223 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
224 retval = true; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
225 } |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
226 } |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
227 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
228 return retval; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
229 } |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16478
diff
changeset
|
230 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
231 void |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
232 workspace_model::set_workspace (bool top_level, bool /* debug */, |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
233 const symbol_scope& scope) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
234 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
235 clear_data (); |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
236 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
237 m_top_level = top_level; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
238 m_scope = scope; |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
239 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
240 update_table (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
241 } |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
242 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
243 void |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
244 workspace_model::clear_workspace (void) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
245 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
246 clear_data (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
247 update_table (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
248 } |
15402
7f423c6111c6
refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents:
15388
diff
changeset
|
249 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
250 void |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
251 workspace_model::notice_settings (const QSettings *settings) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
252 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
253 QList<QColor> default_colors = |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
254 resource_manager::storage_class_default_colors (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
255 QString class_chars = resource_manager::storage_class_chars (); |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16527
diff
changeset
|
256 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
257 for (int i = 0; i < class_chars.length (); i++) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
258 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
259 QVariant default_var = default_colors.at (i); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
260 QColor setting_color = settings->value ("workspaceview/color_" |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
261 + class_chars.mid (i,1), |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
262 default_var).value<QColor> (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
263 m_storage_class_colors.replace (i,setting_color); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
264 } |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
265 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
266 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
267 void |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
268 workspace_model::clear_data (void) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
269 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
270 m_top_level = false; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
271 m_scope = symbol_scope (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
272 m_scopes = QString (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
273 m_symbols = QStringList (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
274 m_class_names = QStringList (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
275 m_dimensions = QStringList (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
276 m_values = QStringList (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
277 m_complex_flags = QIntList (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
278 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
279 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
280 void |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
281 workspace_model::update_table (void) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
282 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
283 beginResetModel (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
284 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
285 std::list<symbol_record> sr_list = m_scope.all_variables (); |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
286 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
287 symbol_record::context_id context = m_scope.current_context (); |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
288 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
289 for (const auto& sr : sr_list) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
290 { |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
291 std::string nm = sr.name (); |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
292 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
293 octave_value val = sr.varval (context); |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
294 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
295 // FIXME: fix size for objects, see kluge in variables.cc |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
296 //dim_vector dv = val.dims (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
297 octave_value tmp = val; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
298 Matrix sz = tmp.size (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
299 dim_vector dv = dim_vector::alloc (sz.numel ()); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
300 for (octave_idx_type i = 0; i < dv.ndims (); i++) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
301 dv(i) = sz(i); |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
302 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
303 char storage = ' '; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
304 if (sr.is_global ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
305 storage = 'g'; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
306 else if (sr.is_persistent ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
307 storage = 'p'; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
308 else if (sr.is_automatic ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
309 storage = 'a'; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
310 else if (sr.is_formal ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
311 storage = 'f'; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
312 else if (sr.is_hidden ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
313 storage = 'h'; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
314 else if (sr.is_inherited ()) |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
315 storage = 'i'; |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
316 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
317 std::ostringstream buf; |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
318 val.short_disp (buf); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
319 std::string short_disp_str = buf.str (); |
24645
f61502510d08
restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
320 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
321 m_scopes.append (storage); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
322 m_symbols.append (QString::fromStdString (nm)); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
323 m_class_names.append (QString::fromStdString (val.class_name ())); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
324 m_dimensions.append (QString::fromStdString (dv.str ())); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
325 m_values.append (QString::fromStdString (short_disp_str)); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
326 m_complex_flags.append (val.iscomplex ()); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
327 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
328 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
329 endResetModel (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
330 |
24766
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
331 emit model_changed (); |
08c92c9d48e3
move workspace view and model classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
332 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
333 } |