Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/src/layout.cpp

Source at commit 1322 created 9 years 5 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 * $Id: layout.cpp,v 1.2 2001/03/19 19:27:41 root Exp $
4 *
5 *
6 * Copyright (C) 1997-2011 by Dimitri van Heesch.
7 *
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
13 *
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
16 *
17 */
18
19#include "layout.h"
20#include "message.h"
21#include "language.h"
22#include "vhdldocgen.h"
23#include "util.h"
24
25#include <qxml.h>
26#include <qfile.h>
27#include <qstring.h>
28#include <qfileinfo.h>
29#include <qtextstream.h>
30
31static const char layout_default[] =
32#include "layout_default.h"
33;
34
35static bool elemIsVisible(const QXmlAttributes &attrib,bool defVal=TRUE)
36{
37 QCString visible = convertToQCString(attrib.value("visible"));
38 if (visible.isEmpty()) return defVal;
39 if (visible.at(0)=='$' && visible.length()>1)
40 {
41 QCString id = visible.mid(1);
42 ConfigOption *opt = Config::instance()->get(id);
43 if (opt && opt->kind()==ConfigOption::O_Bool)
44 {
45 return *((ConfigBool *)opt)->valueRef();
46 }
47 else if (!opt)
48 {
49 err("error: found unsupported value %s for visible attribute in layout file\n",
50 visible.data());
51 }
52 }
53 return visible!="no" && visible!="0";
54}
55
56//---------------------------------------------------------------------------------
57
58LayoutNavEntry *LayoutNavEntry::find(LayoutNavEntry::Kind kind) const
59{
60 LayoutNavEntry *result=0;
61 QListIterator<LayoutNavEntry> li(m_children);
62 LayoutNavEntry *entry;
63 for (li.toFirst();(entry=li.current());++li)
64 {
65 // depth first search, needed to find the entry furthest from the
66 // root in case an entry is in the tree twice
67 result = entry->find(kind);
68 if (result) return result;
69 if (entry->kind()==kind)
70 {
71 return entry;
72 }
73 }
74 return result;
75}
76
77//---------------------------------------------------------------------------------
78
79class LayoutParser : public QXmlDefaultHandler
80{
81 private:
82 class StartElementHandler
83 {
84 typedef void (LayoutParser::*Handler)(const QXmlAttributes &attrib);
85 public:
86 StartElementHandler(LayoutParser *parent, Handler h)
87 : m_parent(parent), m_handler(h) {}
88 virtual ~StartElementHandler() {}
89 virtual void operator()(const QXmlAttributes &attrib)
90 {
91 (m_parent->*m_handler)(attrib);
92 }
93 protected:
94 StartElementHandler() : m_parent(0), m_handler(0) {}
95 private:
96 LayoutParser *m_parent;
97 Handler m_handler;
98 };
99
100 class StartElementHandlerKind : public StartElementHandler
101 {
102 typedef void (LayoutParser::*Handler)(LayoutDocEntry::Kind kind,
103 const QXmlAttributes &attrib);
104 public:
105 StartElementHandlerKind(LayoutParser *parent, LayoutDocEntry::Kind k,Handler h)
106 : m_parent(parent), m_kind(k), m_handler(h) {}
107 void operator()(const QXmlAttributes &attrib)
108 {
109 (m_parent->*m_handler)(m_kind,attrib);
110 }
111 private:
112 LayoutParser *m_parent;
113 LayoutDocEntry::Kind m_kind;
114 Handler m_handler;
115 };
116
117 class StartElementHandlerSection : public StartElementHandler
118 {
119 typedef void (LayoutParser::*Handler)(LayoutDocEntry::Kind kind,
120 const QXmlAttributes &attrib,
121 const QCString &title);
122 public:
123 StartElementHandlerSection(LayoutParser *parent, LayoutDocEntry::Kind k,Handler h,
124 const QCString &title)
125 : m_parent(parent), m_kind(k), m_handler(h), m_title(title) {}
126 void operator()(const QXmlAttributes &attrib)
127 {
128 (m_parent->*m_handler)(m_kind,attrib,m_title);
129 }
130 private:
131 LayoutParser *m_parent;
132 LayoutDocEntry::Kind m_kind;
133 Handler m_handler;
134 QCString m_title;
135 };
136
137 class StartElementHandlerMember : public StartElementHandler
138 {
139 typedef void (LayoutParser::*Handler)(const QXmlAttributes &attrib,
140 MemberList::ListType type,
141 const QCString &title,
142 const QCString &subtitle);
143 public:
144 StartElementHandlerMember(LayoutParser *parent,
145 Handler h,
146 MemberList::ListType type,
147 const QCString &tl,
148 const QCString &ss = QCString()
149 )
150 : m_parent(parent), m_handler(h), m_type(type),
151 m_title(tl), m_subscript(ss) {}
152 void operator()(const QXmlAttributes &attrib)
153 {
154 (m_parent->*m_handler)(attrib,m_type,m_title,m_subscript);
155 }
156 private:
157 LayoutParser *m_parent;
158 Handler m_handler;
159 MemberList::ListType m_type;
160 QCString m_title;
161 QCString m_subscript;
162 };
163
164 class StartElementHandlerNavEntry : public StartElementHandler
165 {
166 typedef void (LayoutParser::*Handler)(LayoutNavEntry::Kind kind,
167 const QXmlAttributes &attrib,
168 const QCString &title);
169 public:
170 StartElementHandlerNavEntry(LayoutParser *parent,
171 LayoutNavEntry::Kind kind,
172 Handler h,
173 const QCString &tl
174 )
175 : m_parent(parent), m_kind(kind), m_handler(h), m_title(tl) {}
176 void operator()(const QXmlAttributes &attrib)
177 {
178 (m_parent->*m_handler)(m_kind,attrib,m_title);
179 }
180 private:
181 LayoutParser *m_parent;
182 LayoutNavEntry::Kind m_kind;
183 Handler m_handler;
184 QCString m_title;
185 };
186
187 class EndElementHandler
188 {
189 typedef void (LayoutParser::*Handler)();
190 public:
191 EndElementHandler(LayoutParser *parent, Handler h) : m_parent(parent), m_handler(h) {}
192 void operator()() { (m_parent->*m_handler)(); }
193 private:
194 LayoutParser *m_parent;
195 Handler m_handler;
196 };
197
198
199 public:
200 static LayoutParser &instance()
201 {
202 static LayoutParser *theInstance = new LayoutParser;
203 return *theInstance;
204 }
205 void init()
206 {
207 m_sHandler.setAutoDelete(TRUE);
208 m_eHandler.setAutoDelete(TRUE);
209 m_part = -1; // invalid
210 m_rootNav = 0;
211
212 bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
213 bool vhdlOpt = Config_getBool("OPTIMIZE_OUTPUT_VHDL");
214 bool javaOpt = Config_getBool("OPTIMIZE_OUTPUT_JAVA");
215
216 // start & end handlers
217 m_sHandler.insert("doxygenlayout",
218 new StartElementHandler(this,&LayoutParser::startLayout));
219 m_eHandler.insert("doxygenlayout",
220 new EndElementHandler(this,&LayoutParser::endLayout));
221
222 // class layout handlers
223 m_sHandler.insert("navindex",
224 new StartElementHandler(this,&LayoutParser::startNavIndex));
225 m_sHandler.insert("navindex/tab",
226 new StartElementHandler(this,&LayoutParser::startNavEntry));
227 m_eHandler.insert("navindex/tab",
228 new EndElementHandler(this,&LayoutParser::endNavEntry));
229 m_eHandler.insert("navindex",
230 new EndElementHandler(this,&LayoutParser::endNavIndex));
231
232 // class layout handlers
233 m_sHandler.insert("class",
234 new StartElementHandler(this,&LayoutParser::startClass));
235 m_sHandler.insert("class/briefdescription",
236 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
237 m_sHandler.insert("class/detaileddescription",
238 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
239 theTranslator->trDetailedDescription()));
240 m_sHandler.insert("class/authorsection",
241 new StartElementHandlerKind(this,LayoutDocEntry::AuthorSection,&LayoutParser::startSimpleEntry));
242 m_sHandler.insert("class/includes",
243 new StartElementHandlerKind(this,LayoutDocEntry::ClassIncludes,&LayoutParser::startSimpleEntry));
244 m_sHandler.insert("class/inheritancegraph",
245 new StartElementHandlerKind(this,LayoutDocEntry::ClassInheritanceGraph,&LayoutParser::startSimpleEntry));
246 m_sHandler.insert("class/collaborationgraph",
247 new StartElementHandlerKind(this,LayoutDocEntry::ClassCollaborationGraph,&LayoutParser::startSimpleEntry));
248 m_sHandler.insert("class/allmemberslink",
249 new StartElementHandlerKind(this,LayoutDocEntry::ClassAllMembersLink,&LayoutParser::startSimpleEntry));
250 m_sHandler.insert("class/usedfiles",
251 new StartElementHandlerKind(this,LayoutDocEntry::ClassUsedFiles,&LayoutParser::startSimpleEntry));
252 m_sHandler.insert("class/memberdecl",
253 new StartElementHandler(this,&LayoutParser::startMemberDecl));
254 m_sHandler.insert("class/memberdecl/membergroups",
255 new StartElementHandlerKind(this,LayoutDocEntry::MemberGroups,&LayoutParser::startSimpleEntry));
256 m_sHandler.insert("class/memberdecl/nestedclasses",
257 new StartElementHandlerSection(this,LayoutDocEntry::ClassNestedClasses,&LayoutParser::startSectionEntry,
258 vhdlOpt ? VhdlDocGen::trVhdlType(VhdlDocGen::ARCHITECTURE,FALSE) :
259 fortranOpt ? theTranslator->trDataTypes() :
260 theTranslator->trCompounds()
261 ));
262 m_sHandler.insert("class/memberdecl/publictypes",
263 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
264 MemberList::pubTypes,theTranslator->trPublicTypes()));
265 m_sHandler.insert("class/memberdecl/publicslots",
266 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
267 MemberList::pubSlots,theTranslator->trPublicSlots()));
268 m_sHandler.insert("class/memberdecl/signals",
269 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
270 MemberList::signals,theTranslator->trSignals()));
271 m_sHandler.insert("class/memberdecl/publicmethods",
272 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
273 MemberList::pubMethods,theTranslator->trPublicMembers()));
274 m_sHandler.insert("class/memberdecl/publicstaticmethods",
275 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
276 MemberList::pubStaticMethods,theTranslator->trStaticPublicMembers()));
277 m_sHandler.insert("class/memberdecl/publicattributes",
278 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
279 MemberList::pubAttribs,theTranslator->trPublicAttribs()));
280 m_sHandler.insert("class/memberdecl/publicstaticattributes",
281 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
282 MemberList::pubStaticAttribs,theTranslator->trStaticPublicAttribs()));
283 m_sHandler.insert("class/memberdecl/protectedtypes",
284 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
285 MemberList::proTypes,theTranslator->trProtectedTypes()));
286 m_sHandler.insert("class/memberdecl/protectedslots",
287 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
288 MemberList::proSlots,theTranslator->trProtectedSlots()));
289 m_sHandler.insert("class/memberdecl/protectedmethods",
290 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
291 MemberList::proMethods,theTranslator->trProtectedMembers()));
292 m_sHandler.insert("class/memberdecl/protectedstaticmethods",
293 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
294 MemberList::proStaticMethods,theTranslator->trStaticProtectedMembers()));
295 m_sHandler.insert("class/memberdecl/protectedattributes",
296 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
297 MemberList::proAttribs,theTranslator->trProtectedAttribs()));
298 m_sHandler.insert("class/memberdecl/protectedstaticattributes",
299 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
300 MemberList::proStaticAttribs,theTranslator->trStaticProtectedAttribs()));
301 m_sHandler.insert("class/memberdecl/packagetypes",
302 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
303 MemberList::pacTypes,theTranslator->trPackageTypes()));
304 m_sHandler.insert("class/memberdecl/packagemethods",
305 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
306 MemberList::pacMethods,theTranslator->trPackageMembers()));
307 m_sHandler.insert("class/memberdecl/packagestaticmethods",
308 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
309 MemberList::pacStaticMethods,theTranslator->trStaticPackageMembers()));
310 m_sHandler.insert("class/memberdecl/packageattributes",
311 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
312 MemberList::pacAttribs,theTranslator->trPackageAttribs()));
313 m_sHandler.insert("class/memberdecl/packagestaticattributes",
314 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
315 MemberList::pacStaticAttribs,theTranslator->trStaticPackageAttribs()));
316 m_sHandler.insert("class/memberdecl/properties",
317 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
318 MemberList::properties,theTranslator->trProperties()));
319 m_sHandler.insert("class/memberdecl/events",
320 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
321 MemberList::events,theTranslator->trEvents()));
322 m_sHandler.insert("class/memberdecl/privatetypes",
323 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
324 MemberList::priTypes,theTranslator->trPrivateTypes()));
325 m_sHandler.insert("class/memberdecl/privateslots",
326 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
327 MemberList::priSlots,theTranslator->trPrivateSlots()));
328 m_sHandler.insert("class/memberdecl/privatemethods",
329 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
330 MemberList::priMethods,theTranslator->trPrivateMembers()));
331 m_sHandler.insert("class/memberdecl/privatestaticmethods",
332 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
333 MemberList::priStaticMethods,theTranslator->trStaticPrivateMembers()));
334 m_sHandler.insert("class/memberdecl/privateattributes",
335 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
336 MemberList::priAttribs,theTranslator->trPrivateAttribs()));
337 m_sHandler.insert("class/memberdecl/privatestaticattributes",
338 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
339 MemberList::priStaticAttribs,theTranslator->trStaticPrivateAttribs()));
340 m_sHandler.insert("class/memberdecl/friends",
341 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
342 MemberList::friends,theTranslator->trFriends()));
343 m_sHandler.insert("class/memberdecl/related",
344 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
345 MemberList::related,theTranslator->trRelatedFunctions(),
346 theTranslator->trRelatedSubscript()));
347 m_eHandler.insert("class/memberdecl",
348 new EndElementHandler(this,&LayoutParser::endMemberDecl));
349 m_sHandler.insert("class/memberdef",
350 new StartElementHandler(this,&LayoutParser::startMemberDef));
351 m_sHandler.insert("class/memberdef/typedefs",
352 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
353 MemberList::typedefMembers,theTranslator->trMemberTypedefDocumentation()));
354 m_sHandler.insert("class/memberdef/enums",
355 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
356 MemberList::enumMembers,theTranslator->trMemberEnumerationDocumentation()));
357 m_sHandler.insert("class/memberdef/constructors",
358 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
359 MemberList::constructors,theTranslator->trConstructorDocumentation()));
360 m_sHandler.insert("class/memberdef/functions",
361 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
362 MemberList::functionMembers,
363 fortranOpt ?
364 theTranslator->trMemberFunctionDocumentationFortran() :
365 theTranslator->trMemberFunctionDocumentation()));
366 m_sHandler.insert("class/memberdef/related",
367 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
368 MemberList::relatedMembers,theTranslator->trRelatedFunctionDocumentation()));
369 m_sHandler.insert("class/memberdef/variables",
370 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
371 MemberList::variableMembers,theTranslator->trMemberDataDocumentation()));
372 m_sHandler.insert("class/memberdef/properties",
373 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
374 MemberList::propertyMembers,theTranslator->trPropertyDocumentation()));
375 m_sHandler.insert("class/memberdef/events",
376 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
377 MemberList::eventMembers,theTranslator->trEventDocumentation()));
378 m_eHandler.insert("class/memberdef",
379 new EndElementHandler(this,&LayoutParser::endMemberDef));
380 m_eHandler.insert("class",
381 new EndElementHandler(this,&LayoutParser::endClass));
382
383
384 // namespace layout handlers
385 m_sHandler.insert("namespace",
386 new StartElementHandler(this,&LayoutParser::startNamespace));
387 m_sHandler.insert("namespace/briefdescription",
388 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
389 m_sHandler.insert("namespace/detaileddescription",
390 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
391 theTranslator->trDetailedDescription()));
392 m_sHandler.insert("namespace/authorsection",
393 new StartElementHandlerKind(this,LayoutDocEntry::AuthorSection,&LayoutParser::startSimpleEntry));
394 m_sHandler.insert("namespace/memberdecl",
395 new StartElementHandler(this,&LayoutParser::startMemberDecl));
396 m_sHandler.insert("namespace/memberdecl/nestednamespaces",
397 new StartElementHandlerSection(this,LayoutDocEntry::NamespaceNestedNamespaces,&LayoutParser::startSectionEntry,
398 javaOpt ? theTranslator->trPackages() :
399 fortranOpt ? theTranslator->trModules() :
400 theTranslator->trNamespaces()
401 ));
402 m_sHandler.insert("namespace/memberdecl/classes",
403 new StartElementHandlerSection(this,LayoutDocEntry::NamespaceClasses,&LayoutParser::startSectionEntry,
404 vhdlOpt ? VhdlDocGen::trVhdlType(VhdlDocGen::ARCHITECTURE,FALSE) :
405 fortranOpt ? theTranslator->trDataTypes() :
406 theTranslator->trCompounds()
407 ));
408 m_sHandler.insert("namespace/memberdecl/membergroups",
409 new StartElementHandlerKind(this,LayoutDocEntry::MemberGroups,&LayoutParser::startSimpleEntry));
410 m_sHandler.insert("namespace/memberdecl/typedefs",
411 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
412 MemberList::decTypedefMembers,theTranslator->trTypedefs()));
413 m_sHandler.insert("namespace/memberdecl/enums",
414 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
415 MemberList::decEnumMembers,theTranslator->trEnumerations()));
416 m_sHandler.insert("namespace/memberdecl/functions",
417 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
418 MemberList::decFuncMembers,
419 fortranOpt ? theTranslator->trSubprograms() :
420 vhdlOpt ? VhdlDocGen::trFunctionAndProc() :
421 theTranslator->trFunctions()));
422 m_sHandler.insert("namespace/memberdecl/variables",
423 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
424 MemberList::decVarMembers,theTranslator->trVariables()));
425 m_eHandler.insert("namespace/memberdecl",
426 new EndElementHandler(this,&LayoutParser::endMemberDecl));
427 m_sHandler.insert("namespace/memberdef",
428 new StartElementHandler(this,&LayoutParser::startMemberDef));
429 m_sHandler.insert("namespace/memberdef/typedefs",
430 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
431 MemberList::docTypedefMembers,theTranslator->trTypedefDocumentation()));
432 m_sHandler.insert("namespace/memberdef/enums",
433 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
434 MemberList::docEnumMembers,theTranslator->trEnumerationTypeDocumentation()));
435 m_sHandler.insert("namespace/memberdef/functions",
436 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
437 MemberList::docFuncMembers,
438 fortranOpt ?
439 theTranslator->trSubprogramDocumentation() :
440 theTranslator->trFunctionDocumentation()));
441 m_sHandler.insert("namespace/memberdef/variables",
442 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
443 MemberList::docVarMembers,theTranslator->trVariableDocumentation()));
444 m_eHandler.insert("namespace/memberdef",
445 new EndElementHandler(this,&LayoutParser::endMemberDef));
446 m_eHandler.insert("namespace",
447 new EndElementHandler(this,&LayoutParser::endNamespace));
448
449 // file layout handlers
450 m_sHandler.insert("file",
451 new StartElementHandler(this,&LayoutParser::startFile));
452 m_sHandler.insert("file/briefdescription",
453 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
454 m_sHandler.insert("file/detaileddescription",
455 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
456 theTranslator->trDetailedDescription()));
457 m_sHandler.insert("file/authorsection",
458 new StartElementHandlerKind(this,LayoutDocEntry::AuthorSection,&LayoutParser::startSimpleEntry));
459 m_sHandler.insert("file/includes",
460 new StartElementHandlerKind(this,LayoutDocEntry::FileIncludes,&LayoutParser::startSimpleEntry));
461 m_sHandler.insert("file/includegraph",
462 new StartElementHandlerKind(this,LayoutDocEntry::FileIncludeGraph,&LayoutParser::startSimpleEntry));
463 m_sHandler.insert("file/includedbygraph",
464 new StartElementHandlerKind(this,LayoutDocEntry::FileIncludedByGraph,&LayoutParser::startSimpleEntry));
465 m_sHandler.insert("file/sourcelink",
466 new StartElementHandlerKind(this,LayoutDocEntry::FileSourceLink,&LayoutParser::startSimpleEntry));
467 m_sHandler.insert("file/memberdecl/membergroups",
468 new StartElementHandlerKind(this,LayoutDocEntry::MemberGroups,&LayoutParser::startSimpleEntry));
469 m_sHandler.insert("file/memberdecl",
470 new StartElementHandler(this,&LayoutParser::startMemberDecl));
471 m_sHandler.insert("file/memberdecl/classes",
472 new StartElementHandlerSection(this,LayoutDocEntry::FileClasses,&LayoutParser::startSectionEntry,
473 vhdlOpt ? VhdlDocGen::trVhdlType(VhdlDocGen::ARCHITECTURE,FALSE) :
474 fortranOpt ? theTranslator->trDataTypes() :
475 theTranslator->trCompounds()
476 ));
477 m_sHandler.insert("file/memberdecl/namespaces",
478 new StartElementHandlerSection(this,LayoutDocEntry::FileNamespaces,&LayoutParser::startSectionEntry,
479 javaOpt ? theTranslator->trPackages() :
480 fortranOpt ? theTranslator->trModules() :
481 theTranslator->trNamespaces()
482 ));
483 m_sHandler.insert("file/memberdecl/defines",
484 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
485 MemberList::decDefineMembers,theTranslator->trDefines()));
486 m_sHandler.insert("file/memberdecl/typedefs",
487 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
488 MemberList::decTypedefMembers,theTranslator->trTypedefs()));
489 m_sHandler.insert("file/memberdecl/enums",
490 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
491 MemberList::decEnumMembers,theTranslator->trEnumerations()));
492 m_sHandler.insert("file/memberdecl/functions",
493 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
494 MemberList::decFuncMembers,
495 fortranOpt ? theTranslator->trSubprograms() :
496 vhdlOpt ? VhdlDocGen::trFunctionAndProc() :
497 theTranslator->trFunctions())) ;
498 m_sHandler.insert("file/memberdecl/variables",
499 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
500 MemberList::decVarMembers,theTranslator->trVariables()));
501
502 m_eHandler.insert("file/memberdecl",
503 new EndElementHandler(this,&LayoutParser::endMemberDecl));
504 m_sHandler.insert("file/memberdef",
505 new StartElementHandler(this,&LayoutParser::startMemberDef));
506 m_sHandler.insert("file/memberdef/defines",
507 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
508 MemberList::docDefineMembers,theTranslator->trDefineDocumentation()));
509 m_sHandler.insert("file/memberdef/typedefs",
510 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
511 MemberList::docTypedefMembers,theTranslator->trTypedefDocumentation()));
512 m_sHandler.insert("file/memberdef/enums",
513 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
514 MemberList::docEnumMembers,theTranslator->trEnumerationTypeDocumentation()));
515 m_sHandler.insert("file/memberdef/functions",
516 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
517 MemberList::docFuncMembers,theTranslator->trFunctionDocumentation()));
518 m_sHandler.insert("file/memberdef/variables",
519 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
520 MemberList::docVarMembers,theTranslator->trVariableDocumentation()));
521 m_eHandler.insert("file/memberdef",
522 new EndElementHandler(this,&LayoutParser::endMemberDef));
523 m_eHandler.insert("file",
524 new EndElementHandler(this,&LayoutParser::endFile));
525
526 // group layout handlers
527 m_sHandler.insert("group",
528 new StartElementHandler(this,&LayoutParser::startGroup));
529 m_sHandler.insert("group/briefdescription",
530 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
531 m_sHandler.insert("group/detaileddescription",
532 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
533 theTranslator->trDetailedDescription()));
534 m_sHandler.insert("group/authorsection",
535 new StartElementHandlerKind(this,LayoutDocEntry::AuthorSection,&LayoutParser::startSimpleEntry));
536 m_sHandler.insert("group/groupgraph",
537 new StartElementHandlerKind(this,LayoutDocEntry::GroupGraph,&LayoutParser::startSimpleEntry));
538 m_sHandler.insert("group/memberdecl/membergroups",
539 new StartElementHandlerKind(this,LayoutDocEntry::MemberGroups,&LayoutParser::startSimpleEntry));
540 m_sHandler.insert("group/memberdecl",
541 new StartElementHandler(this,&LayoutParser::startMemberDecl));
542 m_sHandler.insert("group/memberdecl/classes",
543 new StartElementHandlerSection(this,LayoutDocEntry::GroupClasses,&LayoutParser::startSectionEntry,
544 vhdlOpt ? VhdlDocGen::trVhdlType(VhdlDocGen::ARCHITECTURE,FALSE) :
545 fortranOpt ? theTranslator->trDataTypes() :
546 theTranslator->trCompounds()
547 ));
548 m_sHandler.insert("group/memberdecl/namespaces",
549 new StartElementHandlerSection(this,LayoutDocEntry::GroupNamespaces,&LayoutParser::startSectionEntry,
550 javaOpt ? theTranslator->trPackages() :
551 fortranOpt ? theTranslator->trModules() :
552 theTranslator->trNamespaces()
553 ));
554 m_sHandler.insert("group/memberdecl/dirs",
555 new StartElementHandlerSection(this,LayoutDocEntry::GroupDirs,&LayoutParser::startSectionEntry,
556 theTranslator->trDirectories()
557 ));
558 m_sHandler.insert("group/memberdecl/nestedgroups",
559 new StartElementHandlerSection(this,LayoutDocEntry::GroupNestedGroups,&LayoutParser::startSectionEntry,
560 theTranslator->trModules()
561 ));
562 m_sHandler.insert("group/memberdecl/files",
563 new StartElementHandlerSection(this,LayoutDocEntry::GroupFiles,&LayoutParser::startSectionEntry,
564 theTranslator->trFile(TRUE,FALSE)
565 ));
566
567 m_sHandler.insert("group/memberdecl/defines",
568 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
569 MemberList::decDefineMembers,theTranslator->trDefines()));
570 m_sHandler.insert("group/memberdecl/typedefs",
571 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
572 MemberList::decTypedefMembers,theTranslator->trTypedefs()));
573 m_sHandler.insert("group/memberdecl/enums",
574 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
575 MemberList::decEnumMembers,theTranslator->trEnumerations()));
576 m_sHandler.insert("group/memberdecl/enumvalues",
577 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
578 MemberList::decEnumValMembers,theTranslator->trEnumerationValues()));
579 m_sHandler.insert("group/memberdecl/functions",
580 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
581 MemberList::decFuncMembers,
582 fortranOpt ? theTranslator->trSubprograms() :
583 vhdlOpt ? VhdlDocGen::trFunctionAndProc() :
584 theTranslator->trFunctions()));
585 m_sHandler.insert("group/memberdecl/variables",
586 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
587 MemberList::decVarMembers,theTranslator->trVariables()));
588 m_sHandler.insert("group/memberdecl/signals",
589 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
590 MemberList::decSignalMembers,theTranslator->trSignals()));
591 m_sHandler.insert("group/memberdecl/publicslots",
592 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
593 MemberList::decPubSlotMembers,theTranslator->trPublicSlots()));
594 m_sHandler.insert("group/memberdecl/protectedslots",
595 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
596 MemberList::decProSlotMembers,theTranslator->trProtectedSlots()));
597 m_sHandler.insert("group/memberdecl/privateslots",
598 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
599 MemberList::decPriSlotMembers,theTranslator->trPrivateSlots()));
600 m_sHandler.insert("group/memberdecl/events",
601 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
602 MemberList::decEventMembers,theTranslator->trEvents()));
603 m_sHandler.insert("group/memberdecl/properties",
604 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
605 MemberList::decPropMembers,theTranslator->trProperties()));
606 m_sHandler.insert("group/memberdecl/friends",
607 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
608 MemberList::decFriendMembers,theTranslator->trFriends()));
609 m_eHandler.insert("group/memberdecl",
610 new EndElementHandler(this,&LayoutParser::endMemberDecl));
611 m_sHandler.insert("group/memberdef",
612 new StartElementHandler(this,&LayoutParser::startMemberDef));
613 m_sHandler.insert("group/memberdef/pagedocs",
614 new StartElementHandlerKind(this,LayoutDocEntry::GroupPageDocs,&LayoutParser::startSimpleEntry));
615 m_sHandler.insert("group/memberdef/inlineclasses",
616 new StartElementHandlerSection(this,LayoutDocEntry::GroupInlineClasses,&LayoutParser::startSectionEntry,
617 fortranOpt ? theTranslator->trTypeDocumentation() :
618 theTranslator->trClassDocumentation()
619 ));
620 m_sHandler.insert("group/memberdef/defines",
621 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
622 MemberList::docDefineMembers,theTranslator->trDefineDocumentation()));
623 m_sHandler.insert("group/memberdef/typedefs",
624 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
625 MemberList::docTypedefMembers,theTranslator->trTypedefDocumentation()));
626 m_sHandler.insert("group/memberdef/enums",
627 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
628 MemberList::docEnumMembers,theTranslator->trEnumerationTypeDocumentation()));
629 m_sHandler.insert("group/memberdef/enumvalues",
630 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
631 MemberList::docEnumValMembers,theTranslator->trEnumerationValueDocumentation()));
632 m_sHandler.insert("group/memberdef/functions",
633 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
634 MemberList::docFuncMembers,
635 fortranOpt?
636 theTranslator->trSubprogramDocumentation():
637 theTranslator->trFunctionDocumentation()));
638 m_sHandler.insert("group/memberdef/variables",
639 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
640 MemberList::docVarMembers,theTranslator->trVariableDocumentation()));
641 m_sHandler.insert("group/memberdef/signals",
642 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
643 MemberList::docSignalMembers,theTranslator->trSignals()));
644 m_sHandler.insert("group/memberdef/publicslots",
645 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
646 MemberList::docPubSlotMembers,theTranslator->trPublicSlots()));
647 m_sHandler.insert("group/memberdef/protectedslots",
648 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
649 MemberList::docProSlotMembers,theTranslator->trProtectedSlots()));
650 m_sHandler.insert("group/memberdef/privateslots",
651 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
652 MemberList::docPriSlotMembers,theTranslator->trPrivateSlots()));
653 m_sHandler.insert("group/memberdef/events",
654 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
655 MemberList::docEventMembers,theTranslator->trEvents()));
656 m_sHandler.insert("group/memberdef/properties",
657 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
658 MemberList::docPropMembers,theTranslator->trProperties()));
659 m_sHandler.insert("group/memberdef/friends",
660 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
661 MemberList::docFriendMembers,theTranslator->trFriends()));
662 m_eHandler.insert("group/memberdef",
663 new EndElementHandler(this,&LayoutParser::endMemberDef));
664 m_eHandler.insert("group",
665 new EndElementHandler(this,&LayoutParser::endGroup));
666
667 // directory layout handlers
668 m_sHandler.insert("directory",
669 new StartElementHandler(this,&LayoutParser::startDirectory));
670 m_sHandler.insert("directory/briefdescription",
671 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
672 m_sHandler.insert("directory/detaileddescription",
673 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
674 theTranslator->trDetailedDescription()));
675 m_sHandler.insert("directory/directorygraph",
676 new StartElementHandlerKind(this,LayoutDocEntry::DirGraph,&LayoutParser::startSimpleEntry));
677 m_sHandler.insert("directory/memberdecl",
678 new StartElementHandler(this,&LayoutParser::startMemberDecl));
679 m_sHandler.insert("directory/memberdecl/dirs",
680 new StartElementHandlerKind(this,LayoutDocEntry::DirSubDirs,&LayoutParser::startSimpleEntry));
681 m_sHandler.insert("directory/memberdecl/files",
682 new StartElementHandlerKind(this,LayoutDocEntry::DirFiles,&LayoutParser::startSimpleEntry));
683 m_eHandler.insert("directory/memberdecl",
684 new EndElementHandler(this,&LayoutParser::endMemberDecl));
685 m_eHandler.insert("directory",
686 new EndElementHandler(this,&LayoutParser::endDirectory));
687 }
688
689 void startSimpleEntry(LayoutDocEntry::Kind k,const QXmlAttributes &attrib)
690 {
691 bool isVisible = elemIsVisible(attrib);
692 if (m_part!=-1 && isVisible)
693 {
694 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
695 new LayoutDocEntrySimple(k));
696 }
697 }
698
699 void startSectionEntry(LayoutDocEntry::Kind k,const QXmlAttributes &attrib,
700 const QCString &title)
701 {
702 bool isVisible = elemIsVisible(attrib);
703 QCString userTitle = convertToQCString(attrib.value("title"));
704 //printf("startSectionEntry: title='%s' userTitle='%s'\n",
705 // title.data(),userTitle.data());
706 if (userTitle.isEmpty()) userTitle = title;
707 if (m_part!=-1 && isVisible)
708 {
709 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
710 new LayoutDocEntrySection(k,userTitle));
711 }
712 }
713
714
715 void startMemberDeclEntry(const QXmlAttributes &attrib,MemberList::ListType type,
716 const QCString &title,const QCString &subscript)
717 {
718 //QCString visible = convertToQCString(attrib.value("visible"));
719 //bool isVisible = visible.isEmpty() || (visible!="no" && visible!="0");
720 QCString userTitle = convertToQCString(attrib.value("title"));
721 QCString userSubscript = convertToQCString(attrib.value("subtitle"));
722 if (userTitle.isEmpty()) userTitle = title;
723 if (userSubscript.isEmpty()) userSubscript = subscript;
724 //printf("memberdecl: %s\n",userTitle.data());
725 if (m_part!=-1 /*&& isVisible*/)
726 {
727 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
728 new LayoutDocEntryMemberDecl(type,userTitle,userSubscript));
729 }
730 }
731
732 void startMemberDefEntry(const QXmlAttributes &attrib,MemberList::ListType type,
733 const QCString &title,const QCString &)
734 {
735 QCString userTitle = convertToQCString(attrib.value("title"));
736 if (userTitle.isEmpty()) userTitle = title;
737 //printf("memberdef: %s\n",userTitle.data());
738 if (m_part!=-1 /*&& isVisible*/)
739 {
740 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
741 new LayoutDocEntryMemberDef(type,userTitle));
742 }
743 }
744
745 void startLayout(const QXmlAttributes &)
746 {
747 }
748
749 void endLayout()
750 {
751 }
752
753 void startNavIndex(const QXmlAttributes &)
754 {
755 m_scope="navindex/";
756 m_rootNav = LayoutDocManager::instance().rootNavEntry();
757 m_rootNav->clear();
758 }
759
760 void endNavIndex()
761 {
762 m_scope="";
763 if (!m_rootNav->find(LayoutNavEntry::MainPage))
764 {
765 // no MainPage node... add one the first item of the root node...
766 new LayoutNavEntry(m_rootNav,LayoutNavEntry::MainPage, TRUE,
767 /*Config_getBool("GENERATE_TREEVIEW") ? "main" :*/ "index",
768 theTranslator->trMainPage(),TRUE);
769 }
770 }
771
772 void startNavEntry(const QXmlAttributes &attrib)
773 {
774 static bool javaOpt = Config_getBool("OPTIMIZE_OUTPUT_JAVA");
775 static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
776 static bool vhdlOpt = Config_getBool("OPTIMIZE_OUTPUT_VHDL");
777 static bool hasGraphicalHierarchy = Config_getBool("HAVE_DOT") &&
778 Config_getBool("GRAPHICAL_HIERARCHY");
779 static bool extractAll = Config_getBool("EXTRACT_ALL");
780 static struct NavEntryMap
781 {
782 const char *typeStr; // type attribute name in the XML file
783 LayoutNavEntry::Kind kind; // corresponding enum name
784 QCString mainName; // default title for an item if it has children
785 QCString subName; // optional name for an item if it is rendered as a child
786 QCString intro; // introduction text to be put on the index page
787 QCString baseFile; // base name of the file containing the index page
788 } mapping[] =
789 {
790 { "mainpage",
791 LayoutNavEntry::MainPage,
792 theTranslator->trMainPage(),
793 QCString(),
794 QCString(),
795 "index"
796 },
797 { "pages",
798 LayoutNavEntry::Pages,
799 theTranslator->trRelatedPages(),
800 QCString(),
801 theTranslator->trRelatedPagesDescription(),
802 "pages"
803 },
804 { "modules",
805 LayoutNavEntry::Modules,
806 theTranslator->trModules(),
807 QCString(),
808 theTranslator->trModulesDescription(),
809 "modules"
810 },
811 { "namespaces",
812 LayoutNavEntry::Namespaces,
813 javaOpt ? theTranslator->trPackages() : fortranOpt ? theTranslator->trModules() : theTranslator->trNamespaces(),
814 javaOpt ? theTranslator->trPackages() : fortranOpt ? theTranslator->trModulesList() : theTranslator->trNamespaceList(),
815 javaOpt ? theTranslator->trPackageListDescription() : fortranOpt ? theTranslator->trModulesListDescription(extractAll) : theTranslator->trNamespaceListDescription(extractAll),
816 "namespaces"
817 },
818 { "namespacemembers",
819 LayoutNavEntry::NamespaceMembers,
820 javaOpt ? theTranslator->trPackageMembers() : fortranOpt ? theTranslator->trModulesMembers() : theTranslator->trNamespaceMembers(),
821 QCString(),
822 fortranOpt ? theTranslator->trModulesMemberDescription(extractAll) : theTranslator->trNamespaceMemberDescription(extractAll),
823 "namespacemembers"
824 },
825 { "classindex",
826 LayoutNavEntry::Classes,
827 fortranOpt ? theTranslator->trDataTypes() : vhdlOpt ? VhdlDocGen::trDesignUnits() : theTranslator->trCompoundIndex(),
828 QCString(),
829 QCString(),
830 "classes"
831 },
832 { "classes",
833 LayoutNavEntry::ClassAnnotated,
834 fortranOpt ? theTranslator->trCompoundListFortran() : vhdlOpt ? VhdlDocGen::trDesignUnitList() : theTranslator->trClasses(),
835 theTranslator->trCompoundList(),
836 fortranOpt ? theTranslator->trCompoundListDescriptionFortran() : vhdlOpt ? VhdlDocGen::trDesignUnitListDescription() : theTranslator->trCompoundListDescription(),
837 "annotated"
838 },
839 { "hierarchy",
840 LayoutNavEntry::ClassHierarchy,
841 vhdlOpt ? VhdlDocGen::trDesignUnitHierarchy() : theTranslator->trClassHierarchy(),
842 QCString(),
843 theTranslator->trClassHierarchyDescription(),
844 hasGraphicalHierarchy ? "inherits" : "hierarchy"
845 },
846 { "classmembers",
847 LayoutNavEntry::ClassMembers,
848 fortranOpt ? theTranslator->trCompoundMembersFortran() : vhdlOpt ? VhdlDocGen::trDesignUnitMembers() : theTranslator->trCompoundMembers(),
849 QCString(),
850 fortranOpt ? theTranslator->trCompoundMembersDescriptionFortran(extractAll) : theTranslator->trCompoundMembersDescription(extractAll),
851 "functions"
852 },
853 { "files",
854 LayoutNavEntry::Files,
855 theTranslator->trFile(TRUE,FALSE),
856 theTranslator->trFileList(),
857 theTranslator->trFileListDescription(extractAll),
858 "files"
859 },
860 { "globals",
861 LayoutNavEntry::FileGlobals,
862 theTranslator->trFileMembers(),
863 QCString(),
864 theTranslator->trFileMembersDescription(extractAll),
865 "globals"
866 },
867 { "dirs",
868 LayoutNavEntry::Dirs,
869 theTranslator->trDirectories(),
870 QCString(),
871 theTranslator->trDirDescription(),
872 "dirs"
873 },
874 { "examples",
875 LayoutNavEntry::Examples,
876 theTranslator->trExamples(),
877 QCString(),
878 theTranslator->trExamplesDescription(),
879 "examples"
880 },
881 { 0, // end of list
882 (LayoutNavEntry::Kind)0,
883 QCString(),
884 QCString(),
885 QCString(),
886 QCString()
887 }
888 };
889 LayoutNavEntry::Kind kind;
890 // find type in the table
891 int i=0;
892 QString type = attrib.value("type");
893 while (mapping[i].typeStr)
894 {
895 if (mapping[i].typeStr==type)
896 {
897 kind = mapping[i].kind;
898 break;
899 }
900 i++;
901 }
902 if (mapping[i].typeStr==0)
903 {
904 if (type.isEmpty())
905 {
906 err("error: an entry tag within a navindex has no type attribute! Check your layout file!\n");
907 }
908 else
909 {
910 err("error: the type '%s' is not supported for the entry tag within a navindex! Check your layout file!\n");
911 }
912 return;
913 }
914 QCString baseFile = mapping[i].baseFile;
915 QCString title = convertToQCString(attrib.value("title"));
916 bool isVisible = elemIsVisible(attrib);
917 if (title.isEmpty()) // use default title
918 {
919 title = mapping[i].mainName; // use title for main row
920 if (m_rootNav!=LayoutDocManager::instance().rootNavEntry() && !mapping[i].subName.isEmpty())
921 {
922 title = mapping[i].subName; // if this is a child of another row, use the subName if available
923 // this is mainly done to get compatible naming with older versions.
924 }
925 }
926 QCString intro = convertToQCString(attrib.value("intro"));
927 if (intro.isEmpty()) // use default intro text
928 {
929 intro = mapping[i].intro;
930 }
931 // create new item and make it the new root
932 m_rootNav = new LayoutNavEntry(m_rootNav,kind,kind==LayoutNavEntry::MainPage?TRUE:isVisible,baseFile,title,intro);
933 }
934
935 void endNavEntry()
936 {
937 // set the root back to the parent
938 m_rootNav = m_rootNav->parent();
939 }
940
941 void startClass(const QXmlAttributes &)
942 {
943 LayoutDocManager::instance().clear(LayoutDocManager::Class);
944 m_scope="class/";
945 m_part = (int)LayoutDocManager::Class;
946 }
947
948 void endClass()
949 {
950 m_scope="";
951 m_part = -1;
952 }
953
954 void startNamespace(const QXmlAttributes &)
955 {
956 LayoutDocManager::instance().clear(LayoutDocManager::Namespace);
957 m_scope="namespace/";
958 m_part = (int)LayoutDocManager::Namespace;
959 }
960
961 void endNamespace()
962 {
963 m_scope="";
964 m_part = -1;
965 }
966
967 void startFile(const QXmlAttributes &)
968 {
969 LayoutDocManager::instance().clear(LayoutDocManager::File);
970 m_scope="file/";
971 m_part = (int)LayoutDocManager::File;
972 }
973
974 void endFile()
975 {
976 m_scope="";
977 m_part = -1;
978 }
979
980 void startGroup(const QXmlAttributes &)
981 {
982 LayoutDocManager::instance().clear(LayoutDocManager::Group);
983 m_scope="group/";
984 m_part = (int)LayoutDocManager::Group;
985 }
986
987 void endGroup()
988 {
989 m_scope="";
990 m_part = -1;
991 }
992
993 void startDirectory(const QXmlAttributes &)
994 {
995 LayoutDocManager::instance().clear(LayoutDocManager::Directory);
996 m_scope="directory/";
997 m_part = (int)LayoutDocManager::Directory;
998 }
999
1000 void endDirectory()
1001 {
1002 m_scope="";
1003 m_part = -1;
1004 }
1005
1006 void startMemberDef(const QXmlAttributes &)
1007 {
1008 m_scope+="memberdef/";
1009 if (m_part!=-1)
1010 {
1011 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
1012 new LayoutDocEntrySimple(LayoutDocEntry::MemberDefStart));
1013 }
1014 }
1015
1016 void endMemberDef()
1017 {
1018 int i=m_scope.findRev("memberdef/");
1019 if (i!=-1)
1020 {
1021 m_scope=m_scope.left(i);
1022 if (m_part!=-1)
1023 {
1024 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
1025 new LayoutDocEntrySimple(LayoutDocEntry::MemberDefEnd));
1026 }
1027 }
1028 }
1029
1030 void startMemberDecl(const QXmlAttributes &)
1031 {
1032 m_scope+="memberdecl/";
1033 if (m_part!=-1)
1034 {
1035 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
1036 new LayoutDocEntrySimple(LayoutDocEntry::MemberDeclStart));
1037 }
1038 }
1039
1040 void endMemberDecl()
1041 {
1042 int i=m_scope.findRev("memberdecl/");
1043 if (i!=-1)
1044 {
1045 m_scope=m_scope.left(i);
1046 if (m_part!=-1)
1047 {
1048 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
1049 new LayoutDocEntrySimple(LayoutDocEntry::MemberDeclEnd));
1050 }
1051 }
1052 }
1053
1054 // reimplemented from QXmlDefaultHandler
1055 bool startElement( const QString&, const QString&,
1056 const QString& name, const QXmlAttributes& attrib )
1057 {
1058 //printf("startElement [%s]::[%s]\n",m_scope.data(),name.data());
1059 StartElementHandler *handler = m_sHandler[m_scope+name];
1060 if (handler)
1061 {
1062 (*handler)(attrib);
1063 }
1064 else
1065 {
1066 err("error: Unexpected start tag `%s' found in scope='%s'!\n",
1067 name.data(),m_scope.data());
1068 }
1069 return TRUE;
1070 }
1071 bool endElement( const QString&, const QString&, const QString& name )
1072 {
1073 //printf("endElement [%s]::[%s]\n",m_scope.data(),name.data());
1074 EndElementHandler *handler;
1075 if (!m_scope.isEmpty() && m_scope.right(name.length()+1)==name+"/")
1076 { // element ends current scope
1077 handler = m_eHandler[m_scope.left(m_scope.length()-1)];
1078 }
1079 else // continue with current scope
1080 {
1081 handler = m_eHandler[m_scope+name];
1082 }
1083 if (handler)
1084 {
1085 (*handler)();
1086 }
1087 return TRUE;
1088 }
1089 bool startDocument()
1090 {
1091 return TRUE;
1092 }
1093
1094 private:
1095 LayoutParser() : m_sHandler(163), m_eHandler(17) { }
1096
1097 QDict<StartElementHandler> m_sHandler;
1098 QDict<EndElementHandler> m_eHandler;
1099 QString m_scope;
1100 int m_part;
1101 LayoutNavEntry *m_rootNav;
1102};
1103
1104//---------------------------------------------------------------------------------
1105
1106class LayoutErrorHandler : public QXmlErrorHandler
1107{
1108 public:
1109 bool warning( const QXmlParseException &exception )
1110 {
1111 err("error: at line %d column %d: %s\n",
1112 exception.lineNumber(),exception.columnNumber(),
1113 exception.message().data());
1114 return FALSE;
1115 }
1116 bool error( const QXmlParseException &exception )
1117 {
1118 err("error: at line %d column %d: %s\n",
1119 exception.lineNumber(),exception.columnNumber(),
1120 exception.message().data());
1121 return FALSE;
1122 }
1123 bool fatalError( const QXmlParseException &exception )
1124 {
1125 err("error: at line %d column %d: %s\n",
1126 exception.lineNumber(),exception.columnNumber(),
1127 exception.message().data());
1128 return FALSE;
1129 }
1130 QString errorString() { return ""; }
1131
1132 private:
1133 QString errorMsg;
1134};
1135
1136//---------------------------------------------------------------------------------
1137
1138class LayoutDocManager::Private
1139{
1140 public:
1141 QList<LayoutDocEntry> docEntries[LayoutDocManager::NrParts];
1142 LayoutNavEntry *rootNav;
1143};
1144
1145LayoutDocManager::LayoutDocManager()
1146{
1147 d = new Private;
1148 int i;
1149 for (i=0;i<LayoutDocManager::NrParts;i++)
1150 {
1151 d->docEntries[i].setAutoDelete(TRUE);
1152 }
1153 d->rootNav = new LayoutNavEntry;
1154 LayoutParser::instance().init();
1155}
1156
1157
1158void LayoutDocManager::init()
1159{
1160 // parse the default layout
1161 LayoutErrorHandler errorHandler;
1162 QXmlInputSource source;
1163 source.setData( layout_default );
1164 QXmlSimpleReader reader;
1165 reader.setContentHandler( &LayoutParser::instance() );
1166 reader.setErrorHandler( &errorHandler );
1167 reader.parse( source );
1168}
1169
1170LayoutDocManager::~LayoutDocManager()
1171{
1172 delete d->rootNav;
1173 delete d;
1174}
1175
1176LayoutDocManager & LayoutDocManager::instance()
1177{
1178 static LayoutDocManager *theInstance = new LayoutDocManager;
1179 return *theInstance;
1180}
1181
1182const QList<LayoutDocEntry> &LayoutDocManager::docEntries(LayoutDocManager::LayoutPart part) const
1183{
1184 return d->docEntries[(int)part];
1185}
1186
1187LayoutNavEntry* LayoutDocManager::rootNavEntry() const
1188{
1189 return d->rootNav;
1190}
1191
1192void LayoutDocManager::addEntry(LayoutDocManager::LayoutPart p,LayoutDocEntry *e)
1193{
1194 d->docEntries[(int)p].append(e);
1195}
1196
1197void LayoutDocManager::clear(LayoutDocManager::LayoutPart p)
1198{
1199 d->docEntries[(int)p].clear();
1200}
1201
1202void LayoutDocManager::parse(QTextStream &t)
1203{
1204 LayoutErrorHandler errorHandler;
1205 QXmlInputSource source( t );
1206 QXmlSimpleReader reader;
1207 reader.setContentHandler( &LayoutParser::instance() );
1208 reader.setErrorHandler( &errorHandler );
1209 reader.parse( source );
1210}
1211
1212//---------------------------------------------------------------------------------
1213
1214void writeDefaultLayoutFile(const char *fileName)
1215{
1216 QFile f(fileName);
1217 if (!f.open(IO_WriteOnly))
1218 {
1219 err("Failed to open file %s for writing!\n",fileName);
1220 return;
1221 }
1222 QTextStream t(&f);
1223 t << layout_default;
1224}
1225

Archive Download this file

Revision: 1322