1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file. Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "treewalker.h"
43 #include "ui4.h"
44
45 QT_BEGIN_NAMESPACE
46
acceptUI(DomUI * ui)47 void TreeWalker::acceptUI(DomUI *ui)
48 {
49 acceptWidget(ui->elementWidget());
50 if (const DomButtonGroups *domButtonGroups = ui->elementButtonGroups())
51 acceptButtonGroups(domButtonGroups);
52
53 acceptTabStops(ui->elementTabStops());
54
55 if (ui->elementImages())
56 acceptImages(ui->elementImages());
57 }
58
acceptLayoutDefault(DomLayoutDefault * layoutDefault)59 void TreeWalker::acceptLayoutDefault(DomLayoutDefault *layoutDefault)
60 {
61 Q_UNUSED(layoutDefault);
62 }
63
acceptLayoutFunction(DomLayoutFunction * layoutFunction)64 void TreeWalker::acceptLayoutFunction(DomLayoutFunction *layoutFunction)
65 {
66 Q_UNUSED(layoutFunction);
67 }
68
acceptTabStops(DomTabStops * tabStops)69 void TreeWalker::acceptTabStops(DomTabStops *tabStops)
70 {
71 Q_UNUSED(tabStops);
72 }
73
acceptLayout(DomLayout * layout)74 void TreeWalker::acceptLayout(DomLayout *layout)
75 {
76 for (int i=0; i<layout->elementProperty().size(); ++i)
77 acceptProperty(layout->elementProperty().at(i));
78
79 for (int i=0; i<layout->elementItem().size(); ++i)
80 acceptLayoutItem(layout->elementItem().at(i));
81 }
82
acceptLayoutItem(DomLayoutItem * layoutItem)83 void TreeWalker::acceptLayoutItem(DomLayoutItem *layoutItem)
84 {
85 switch (layoutItem->kind()) {
86 case DomLayoutItem::Widget:
87 acceptWidget(layoutItem->elementWidget());
88 return;
89 case DomLayoutItem::Layout:
90 acceptLayout(layoutItem->elementLayout());
91 return;
92 case DomLayoutItem::Spacer:
93 acceptSpacer(layoutItem->elementSpacer());
94 return;
95 case DomLayoutItem::Unknown:
96 break;
97 }
98
99 Q_ASSERT( 0 );
100 }
101
acceptWidget(DomWidget * widget)102 void TreeWalker::acceptWidget(DomWidget *widget)
103 {
104 for (int i=0; i<widget->elementAction().size(); ++i)
105 acceptAction(widget->elementAction().at(i));
106
107 for (int i=0; i<widget->elementActionGroup().size(); ++i)
108 acceptActionGroup(widget->elementActionGroup().at(i));
109
110 for (int i=0; i<widget->elementAddAction().size(); ++i)
111 acceptActionRef(widget->elementAddAction().at(i));
112
113 for (int i=0; i<widget->elementProperty().size(); ++i)
114 acceptProperty(widget->elementProperty().at(i));
115
116
117
118 // recurse down
119 DomWidgets childWidgets;
120 for (int i=0; i<widget->elementWidget().size(); ++i) {
121 DomWidget *child = widget->elementWidget().at(i);
122 childWidgets += child;
123 acceptWidget(child);
124 }
125
126 if (!widget->elementLayout().isEmpty())
127 acceptLayout(widget->elementLayout().at(0));
128
129 const DomScripts scripts(widget->elementScript());
130 acceptWidgetScripts(scripts, widget, childWidgets);
131 }
132
acceptSpacer(DomSpacer * spacer)133 void TreeWalker::acceptSpacer(DomSpacer *spacer)
134 {
135 for (int i=0; i<spacer->elementProperty().size(); ++i)
136 acceptProperty(spacer->elementProperty().at(i));
137 }
138
acceptColor(DomColor * color)139 void TreeWalker::acceptColor(DomColor *color)
140 {
141 Q_UNUSED(color);
142 }
143
acceptColorGroup(DomColorGroup * colorGroup)144 void TreeWalker::acceptColorGroup(DomColorGroup *colorGroup)
145 {
146 Q_UNUSED(colorGroup);
147 }
148
acceptPalette(DomPalette * palette)149 void TreeWalker::acceptPalette(DomPalette *palette)
150 {
151 acceptColorGroup(palette->elementActive());
152 acceptColorGroup(palette->elementInactive());
153 acceptColorGroup(palette->elementDisabled());
154 }
155
acceptFont(DomFont * font)156 void TreeWalker::acceptFont(DomFont *font)
157 {
158 Q_UNUSED(font);
159 }
160
acceptPoint(DomPoint * point)161 void TreeWalker::acceptPoint(DomPoint *point)
162 {
163 Q_UNUSED(point);
164 }
165
acceptRect(DomRect * rect)166 void TreeWalker::acceptRect(DomRect *rect)
167 {
168 Q_UNUSED(rect);
169 }
170
acceptSizePolicy(DomSizePolicy * sizePolicy)171 void TreeWalker::acceptSizePolicy(DomSizePolicy *sizePolicy)
172 {
173 Q_UNUSED(sizePolicy);
174 }
175
acceptSize(DomSize * size)176 void TreeWalker::acceptSize(DomSize *size)
177 {
178 Q_UNUSED(size);
179 }
180
acceptDate(DomDate * date)181 void TreeWalker::acceptDate(DomDate *date)
182 {
183 Q_UNUSED(date);
184 }
185
acceptTime(DomTime * time)186 void TreeWalker::acceptTime(DomTime *time)
187 {
188 Q_UNUSED(time);
189 }
190
acceptDateTime(DomDateTime * dateTime)191 void TreeWalker::acceptDateTime(DomDateTime *dateTime)
192 {
193 Q_UNUSED(dateTime);
194 }
195
acceptProperty(DomProperty * property)196 void TreeWalker::acceptProperty(DomProperty *property)
197 {
198 switch (property->kind()) {
199 case DomProperty::Bool:
200 case DomProperty::Color:
201 case DomProperty::Cstring:
202 case DomProperty::Cursor:
203 case DomProperty::CursorShape:
204 case DomProperty::Enum:
205 case DomProperty::Font:
206 case DomProperty::Pixmap:
207 case DomProperty::IconSet:
208 case DomProperty::Palette:
209 case DomProperty::Point:
210 case DomProperty::PointF:
211 case DomProperty::Rect:
212 case DomProperty::RectF:
213 case DomProperty::Set:
214 case DomProperty::Locale:
215 case DomProperty::SizePolicy:
216 case DomProperty::Size:
217 case DomProperty::SizeF:
218 case DomProperty::String:
219 case DomProperty::Number:
220 case DomProperty::LongLong:
221 case DomProperty::Char:
222 case DomProperty::Date:
223 case DomProperty::Time:
224 case DomProperty::DateTime:
225 case DomProperty::Url:
226 case DomProperty::Unknown:
227 case DomProperty::StringList:
228 case DomProperty::Float:
229 case DomProperty::Double:
230 case DomProperty::UInt:
231 case DomProperty::ULongLong:
232 case DomProperty::Brush:
233 break;
234 }
235 }
236
acceptCustomWidgets(DomCustomWidgets * customWidgets)237 void TreeWalker::acceptCustomWidgets(DomCustomWidgets *customWidgets)
238 {
239 for (int i=0; i<customWidgets->elementCustomWidget().size(); ++i)
240 acceptCustomWidget(customWidgets->elementCustomWidget().at(i));
241 }
242
acceptCustomWidget(DomCustomWidget * customWidget)243 void TreeWalker::acceptCustomWidget(DomCustomWidget *customWidget)
244 {
245 Q_UNUSED(customWidget);
246 }
247
acceptAction(DomAction * action)248 void TreeWalker::acceptAction(DomAction *action)
249 {
250 Q_UNUSED(action);
251 }
252
acceptActionGroup(DomActionGroup * actionGroup)253 void TreeWalker::acceptActionGroup(DomActionGroup *actionGroup)
254 {
255 for (int i=0; i<actionGroup->elementAction().size(); ++i)
256 acceptAction(actionGroup->elementAction().at(i));
257
258 for (int i=0; i<actionGroup->elementActionGroup().size(); ++i)
259 acceptActionGroup(actionGroup->elementActionGroup().at(i));
260 }
261
acceptActionRef(DomActionRef * actionRef)262 void TreeWalker::acceptActionRef(DomActionRef *actionRef)
263 {
264 Q_UNUSED(actionRef);
265 }
266
acceptImages(DomImages * images)267 void TreeWalker::acceptImages(DomImages *images)
268 {
269 for (int i=0; i<images->elementImage().size(); ++i)
270 acceptImage(images->elementImage().at(i));
271 }
272
acceptImage(DomImage * image)273 void TreeWalker::acceptImage(DomImage *image)
274 {
275 Q_UNUSED(image);
276 }
277
acceptIncludes(DomIncludes * includes)278 void TreeWalker::acceptIncludes(DomIncludes *includes)
279 {
280 for (int i=0; i<includes->elementInclude().size(); ++i)
281 acceptInclude(includes->elementInclude().at(i));
282 }
283
acceptInclude(DomInclude * incl)284 void TreeWalker::acceptInclude(DomInclude *incl)
285 {
286 Q_UNUSED(incl);
287 }
288
acceptConnections(DomConnections * connections)289 void TreeWalker::acceptConnections(DomConnections *connections)
290 {
291 for (int i=0; i<connections->elementConnection().size(); ++i)
292 acceptConnection(connections->elementConnection().at(i));
293 }
294
acceptConnection(DomConnection * connection)295 void TreeWalker::acceptConnection(DomConnection *connection)
296 {
297 acceptConnectionHints(connection->elementHints());
298 }
299
acceptConnectionHints(DomConnectionHints * connectionHints)300 void TreeWalker::acceptConnectionHints(DomConnectionHints *connectionHints)
301 {
302 for (int i=0; i<connectionHints->elementHint().size(); ++i)
303 acceptConnectionHint(connectionHints->elementHint().at(i));
304 }
305
acceptConnectionHint(DomConnectionHint * connectionHint)306 void TreeWalker::acceptConnectionHint(DomConnectionHint *connectionHint)
307 {
308 Q_UNUSED(connectionHint);
309 }
310
acceptWidgetScripts(const DomScripts &,DomWidget *,const DomWidgets &)311 void TreeWalker::acceptWidgetScripts(const DomScripts &, DomWidget *, const DomWidgets &)
312 {
313 }
314
acceptButtonGroups(const DomButtonGroups * domButtonGroups)315 void TreeWalker::acceptButtonGroups(const DomButtonGroups *domButtonGroups)
316 {
317 typedef QList<DomButtonGroup*> DomButtonGroupList;
318 const DomButtonGroupList domGroups = domButtonGroups->elementButtonGroup();
319 const DomButtonGroupList::const_iterator cend = domGroups.constEnd();
320 for (DomButtonGroupList::const_iterator it = domGroups.constBegin(); it != cend; ++it)
321 acceptButtonGroup(*it);
322 }
323
acceptButtonGroup(const DomButtonGroup *)324 void TreeWalker::acceptButtonGroup(const DomButtonGroup *)
325 {
326 }
327
328 QT_END_NAMESPACE
329