Mercurial > octave-nkf
annotate gui/src/VariablesDockWidget.cpp @ 13541:b48ac9ad8de0
Highly improved separation of model and view classes.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 26 Jul 2011 23:04:52 +0200 |
parents | 869c62c15e95 |
children | e440b3f32f02 |
rev | line source |
---|---|
13504
13e3d60aff2d
Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
1 /* OctaveGUI - A graphical user interface for Octave |
13501 | 2 * Copyright (C) 2011 Jacob Dawid |
3 * jacob.dawid@googlemail.com | |
4 * | |
5 * This program is free software: you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation, either version 3 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 */ | |
18 | |
19 #include "VariablesDockWidget.h" | |
20 #include <QHBoxLayout> | |
21 #include <QVBoxLayout> | |
22 #include <QPushButton> | |
23 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
24 VariablesDockWidget::VariablesDockWidget (QWidget * parent):QDockWidget |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
25 (parent) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
26 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
27 setObjectName ("VariablesDockWidget"); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
28 construct (); |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
29 |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
30 connect (OctaveLink::instance(), SIGNAL (symbolTableChanged()), this, SLOT (fetchSymbolTable())); |
13501 | 31 } |
32 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
33 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
34 VariablesDockWidget::construct () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
35 { |
13523
103b7bebb38f
Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
36 setWindowTitle (tr ("Workspace")); |
103b7bebb38f
Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
37 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
38 m_updateSemaphore = new QSemaphore (1); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
39 QStringList headerLabels; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
40 headerLabels << tr ("Name") << tr ("Type") << tr ("Value"); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
41 m_variablesTreeWidget = new QTreeWidget (this); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
42 m_variablesTreeWidget->setHeaderHidden (false); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
43 m_variablesTreeWidget->setHeaderLabels (headerLabels); |
13523
103b7bebb38f
Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
44 |
103b7bebb38f
Moved load/save/clear workspace into main menu.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
45 setWidget (new QWidget (this)); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
46 QVBoxLayout *layout = new QVBoxLayout (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
47 layout->addWidget (m_variablesTreeWidget); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
48 layout->setMargin (2); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
49 widget ()->setLayout (layout); |
13501 | 50 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
51 QTreeWidgetItem *treeWidgetItem = new QTreeWidgetItem (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
52 treeWidgetItem->setData (0, 0, QString (tr ("Local"))); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
53 m_variablesTreeWidget->insertTopLevelItem (0, treeWidgetItem); |
13501 | 54 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
55 treeWidgetItem = new QTreeWidgetItem (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
56 treeWidgetItem->setData (0, 0, QString (tr ("Global"))); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
57 m_variablesTreeWidget->insertTopLevelItem (1, treeWidgetItem); |
13501 | 58 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
59 treeWidgetItem = new QTreeWidgetItem (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
60 treeWidgetItem->setData (0, 0, QString (tr ("Persistent"))); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
61 m_variablesTreeWidget->insertTopLevelItem (2, treeWidgetItem); |
13501 | 62 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
63 treeWidgetItem = new QTreeWidgetItem (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
64 treeWidgetItem->setData (0, 0, QString (tr ("Hidden"))); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
65 m_variablesTreeWidget->insertTopLevelItem (3, treeWidgetItem); |
13501 | 66 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
67 m_variablesTreeWidget->expandAll (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
68 m_variablesTreeWidget->setAlternatingRowColors (true); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
69 m_variablesTreeWidget->setAnimated (true); |
13501 | 70 } |
71 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
72 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
73 VariablesDockWidget::updateTreeEntry (QTreeWidgetItem * treeItem, |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
74 SymbolRecord symbolRecord) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
75 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
76 treeItem->setData (0, 0, QString (symbolRecord.name ().c_str ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
77 treeItem->setData (1, 0, |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
78 QString (symbolRecord.varval ().type_name ().c_str ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
79 treeItem->setData (2, 0, |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
80 OctaveLink::octaveValueAsQString (symbolRecord. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
81 varval ())); |
13501 | 82 } |
83 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
84 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
85 VariablesDockWidget::setVariablesList (QList < SymbolRecord > symbolTable) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
86 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
87 m_updateSemaphore->acquire (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
88 // Split the symbol table into its different scopes. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
89 QList < SymbolRecord > localSymbolTable; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
90 QList < SymbolRecord > globalSymbolTable; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
91 QList < SymbolRecord > persistentSymbolTable; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
92 QList < SymbolRecord > hiddenSymbolTable; |
13501 | 93 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
94 foreach (SymbolRecord symbolRecord, symbolTable) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
95 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
96 // It's true that being global or hidden includes it's can mean it's also locally visible, |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
97 // but we want to distinguish that here. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
98 if (symbolRecord.is_local () && !symbolRecord.is_global () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
99 && !symbolRecord.is_hidden ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
100 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
101 localSymbolTable.append (symbolRecord); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
102 } |
13501 | 103 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
104 if (symbolRecord.is_global ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
105 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
106 globalSymbolTable.append (symbolRecord); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
107 } |
13501 | 108 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
109 if (symbolRecord.is_persistent ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
110 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
111 persistentSymbolTable.append (symbolRecord); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
112 } |
13501 | 113 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
114 if (symbolRecord.is_hidden ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
115 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
116 hiddenSymbolTable.append (symbolRecord); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
117 } |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
118 } |
13501 | 119 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
120 updateScope (0, localSymbolTable); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
121 updateScope (1, globalSymbolTable); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
122 updateScope (2, persistentSymbolTable); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
123 updateScope (3, hiddenSymbolTable); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
124 m_updateSemaphore->release (); |
13501 | 125 } |
126 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
127 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
128 VariablesDockWidget::updateScope (int topLevelItemIndex, |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
129 QList < SymbolRecord > symbolTable) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
130 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
131 // This method may be a little bit confusing; variablesList is a complete list of all |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
132 // variables that are in the workspace currently. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
133 QTreeWidgetItem *topLevelItem = |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
134 m_variablesTreeWidget->topLevelItem (topLevelItemIndex); |
13501 | 135 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
136 // First we check, if any variables that exist in the model tree have to be updated |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
137 // or created. So we walk the variablesList check against the tree. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
138 foreach (SymbolRecord symbolRecord, symbolTable) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
139 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
140 int childCount = topLevelItem->childCount (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
141 bool alreadyExists = false; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
142 QTreeWidgetItem *child; |
13501 | 143 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
144 // Search for the corresponding item in the tree. If it has been found, child |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
145 // will contain the appropriate QTreeWidgetItem* pointing at it. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
146 for (int i = 0; i < childCount; i++) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
147 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
148 child = topLevelItem->child (i); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
149 if (child->data (0, 0).toString () == |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
150 QString (symbolRecord.name ().c_str ())) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
151 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
152 alreadyExists = true; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
153 break; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
154 } |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
155 } |
13501 | 156 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
157 // If it already exists, just update it. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
158 if (alreadyExists) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
159 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
160 updateTreeEntry (child, symbolRecord); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
161 } |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
162 else |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
163 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
164 // It does not exist, so create a new one and set the right values. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
165 child = new QTreeWidgetItem (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
166 updateTreeEntry (child, symbolRecord); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
167 topLevelItem->addChild (child); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
168 } |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
169 } |
13501 | 170 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
171 // Check the tree against the list for deleted variables. |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
172 for (int i = 0; i < topLevelItem->childCount (); i++) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
173 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
174 bool existsInVariableList = false; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
175 QTreeWidgetItem *child = topLevelItem->child (i); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
176 foreach (SymbolRecord symbolRecord, symbolTable) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
177 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
178 if (QString (symbolRecord.name ().c_str ()) == |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
179 child->data (0, 0).toString ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
180 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
181 existsInVariableList = true; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
182 } |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
183 } |
13501 | 184 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
185 if (!existsInVariableList) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
186 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
187 topLevelItem->removeChild (child); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
188 delete child; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
189 i--; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
190 } |
13501 | 191 } |
192 } | |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13523
diff
changeset
|
193 |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13523
diff
changeset
|
194 void |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13523
diff
changeset
|
195 VariablesDockWidget::noticeSettings () |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13523
diff
changeset
|
196 { |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13523
diff
changeset
|
197 |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13523
diff
changeset
|
198 } |
13541
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
199 |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
200 void |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
201 VariablesDockWidget::fetchSymbolTable () |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
202 { |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
203 QList < SymbolRecord > symbolTable = OctaveLink::instance ()->copyCurrentSymbolTable (); |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
204 setVariablesList (symbolTable); |
b48ac9ad8de0
Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
205 } |