author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:10:48 +0300 | |
changeset 30 | 5dc02b23752f |
parent 18 | 2f34d5167611 |
child 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the tools applications of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
/* |
|
43 |
tree.cpp |
|
44 |
*/ |
|
45 |
||
46 |
#include <QDomDocument> |
|
47 |
||
48 |
#include "atom.h" |
|
49 |
#include "doc.h" |
|
50 |
#include "htmlgenerator.h" |
|
51 |
#include "location.h" |
|
52 |
#include "node.h" |
|
53 |
#include "text.h" |
|
54 |
#include "tree.h" |
|
55 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
56 |
#include <limits.h> |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
57 |
#include <qdebug.h> |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
58 |
|
0 | 59 |
QT_BEGIN_NAMESPACE |
60 |
||
61 |
struct InheritanceBound |
|
62 |
{ |
|
63 |
Node::Access access; |
|
64 |
QStringList basePath; |
|
65 |
QString dataTypeWithTemplateArgs; |
|
66 |
InnerNode *parent; |
|
67 |
||
68 |
InheritanceBound() |
|
69 |
: access(Node::Public) { } |
|
70 |
InheritanceBound(Node::Access access0, |
|
71 |
const QStringList& basePath0, |
|
72 |
const QString &dataTypeWithTemplateArgs0, |
|
73 |
InnerNode *parent) |
|
74 |
: access(access0), basePath(basePath0), |
|
75 |
dataTypeWithTemplateArgs(dataTypeWithTemplateArgs0), |
|
76 |
parent(parent) { } |
|
77 |
}; |
|
78 |
||
79 |
struct Target |
|
80 |
{ |
|
81 |
Node *node; |
|
82 |
Atom *atom; |
|
83 |
int priority; |
|
84 |
}; |
|
85 |
||
86 |
typedef QMap<PropertyNode::FunctionRole, QString> RoleMap; |
|
87 |
typedef QMap<PropertyNode *, RoleMap> PropertyMap; |
|
88 |
typedef QMultiMap<QString, Node *> GroupMap; |
|
89 |
typedef QMultiHash<QString, FakeNode *> FakeNodeHash; |
|
90 |
typedef QMultiHash<QString, Target> TargetHash; |
|
91 |
||
92 |
class TreePrivate |
|
93 |
{ |
|
94 |
public: |
|
95 |
QMap<ClassNode *, QList<InheritanceBound> > unresolvedInheritanceMap; |
|
96 |
PropertyMap unresolvedPropertyMap; |
|
97 |
GroupMap groupMap; |
|
98 |
QMultiMap<QString, QString> publicGroupMap; |
|
99 |
FakeNodeHash fakeNodesByTitle; |
|
100 |
TargetHash targetHash; |
|
101 |
QList<QPair<ClassNode*,QString> > basesList; |
|
102 |
QList<QPair<FunctionNode*,QString> > relatedList; |
|
103 |
}; |
|
104 |
||
105 |
/*! |
|
106 |
\class Tree |
|
107 |
*/ |
|
108 |
||
109 |
/*! |
|
110 |
The default constructor is the only constructor. |
|
111 |
*/ |
|
112 |
Tree::Tree() |
|
113 |
: roo(0, "") |
|
114 |
{ |
|
115 |
priv = new TreePrivate; |
|
116 |
} |
|
117 |
||
118 |
/*! |
|
119 |
The destructor deletes the internal, private tree. |
|
120 |
*/ |
|
121 |
Tree::~Tree() |
|
122 |
{ |
|
123 |
delete priv; |
|
124 |
} |
|
125 |
||
126 |
/*! |
|
127 |
*/ |
|
128 |
Node *Tree::findNode(const QStringList &path, Node *relative, int findFlags) |
|
129 |
{ |
|
130 |
return const_cast<Node*>(const_cast<const Tree*>(this)->findNode(path, |
|
131 |
relative, |
|
132 |
findFlags)); |
|
133 |
} |
|
134 |
||
135 |
/*! |
|
136 |
*/ |
|
137 |
const Node *Tree::findNode(const QStringList &path, |
|
138 |
const Node *relative, |
|
139 |
int findFlags) const |
|
140 |
{ |
|
141 |
if (!relative) |
|
142 |
relative = root(); |
|
143 |
||
144 |
do { |
|
145 |
const Node *node = relative; |
|
146 |
int i; |
|
147 |
||
148 |
for (i = 0; i < path.size(); ++i) { |
|
149 |
if (node == 0 || !node->isInnerNode()) |
|
150 |
break; |
|
151 |
||
152 |
const Node *next = |
|
153 |
static_cast<const InnerNode*>(node)->findNode(path.at(i)); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
154 |
|
0 | 155 |
if (!next && (findFlags & SearchEnumValues) && i == path.size()-1) |
156 |
next = static_cast<const InnerNode*>(node)->findEnumNodeForValue(path.at(i)); |
|
157 |
||
158 |
if (!next && node->type() == Node::Class && (findFlags & SearchBaseClasses)) { |
|
159 |
NodeList baseClasses = allBaseClasses(static_cast<const ClassNode *>(node)); |
|
160 |
foreach (const Node *baseClass, baseClasses) { |
|
161 |
next = static_cast<const InnerNode *>(baseClass)->findNode(path.at(i)); |
|
162 |
if (!next && (findFlags & SearchEnumValues) && i == path.size() - 1) |
|
163 |
next = static_cast<const InnerNode *>(baseClass) |
|
164 |
->findEnumNodeForValue(path.at(i)); |
|
165 |
if (next) |
|
166 |
break; |
|
167 |
} |
|
168 |
} |
|
169 |
node = next; |
|
170 |
} |
|
171 |
if (node && i == path.size() |
|
172 |
&& (!(findFlags & NonFunction) || node->type() != Node::Function |
|
173 |
|| ((FunctionNode *)node)->metaness() == FunctionNode::MacroWithoutParams)) |
|
174 |
return node; |
|
175 |
relative = relative->parent(); |
|
176 |
} while (relative); |
|
177 |
||
178 |
return 0; |
|
179 |
} |
|
180 |
||
181 |
/*! |
|
182 |
Find the node with the specified \a path name of the |
|
183 |
specified \a type. |
|
184 |
*/ |
|
185 |
Node *Tree::findNode(const QStringList &path, |
|
186 |
Node::Type type, |
|
187 |
Node *relative, |
|
188 |
int findFlags) |
|
189 |
{ |
|
190 |
return const_cast<Node*>(const_cast<const Tree*>(this)->findNode(path, |
|
191 |
type, |
|
192 |
relative, |
|
193 |
findFlags)); |
|
194 |
} |
|
195 |
||
196 |
/*! |
|
197 |
Find the node with the specified \a path name of the |
|
198 |
specified \a type. |
|
199 |
*/ |
|
200 |
const Node *Tree::findNode(const QStringList &path, |
|
201 |
Node::Type type, |
|
202 |
const Node *relative, |
|
203 |
int findFlags) const |
|
204 |
{ |
|
205 |
const Node *node = findNode(path, relative, findFlags); |
|
206 |
if (node != 0 && node->type() == type) |
|
207 |
return node; |
|
208 |
return 0; |
|
209 |
} |
|
210 |
||
211 |
/*! |
|
212 |
*/ |
|
213 |
FunctionNode *Tree::findFunctionNode(const QStringList& path, |
|
214 |
Node *relative, |
|
215 |
int findFlags) |
|
216 |
{ |
|
217 |
return const_cast<FunctionNode *>( |
|
218 |
const_cast<const Tree *>(this)->findFunctionNode(path, |
|
219 |
relative, |
|
220 |
findFlags)); |
|
221 |
} |
|
222 |
||
223 |
/*! |
|
224 |
*/ |
|
225 |
const FunctionNode *Tree::findFunctionNode(const QStringList &path, |
|
226 |
const Node *relative, |
|
227 |
int findFlags) const |
|
228 |
{ |
|
229 |
if (!relative) |
|
230 |
relative = root(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
|
0 | 232 |
do { |
233 |
const Node *node = relative; |
|
234 |
int i; |
|
235 |
||
236 |
for (i = 0; i < path.size(); ++i) { |
|
237 |
if (node == 0 || !node->isInnerNode()) |
|
238 |
break; |
|
239 |
||
240 |
const Node *next; |
|
241 |
if (i == path.size() - 1) |
|
242 |
next = ((InnerNode *) node)->findFunctionNode(path.at(i)); |
|
243 |
else |
|
244 |
next = ((InnerNode *) node)->findNode(path.at(i)); |
|
245 |
||
246 |
if (!next && node->type() == Node::Class && |
|
247 |
(findFlags & SearchBaseClasses)) { |
|
248 |
NodeList baseClasses = allBaseClasses(static_cast<const ClassNode *>(node)); |
|
249 |
foreach (const Node *baseClass, baseClasses) { |
|
250 |
if (i == path.size() - 1) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
251 |
next = static_cast<const InnerNode *>(baseClass)->findFunctionNode(path.at(i)); |
0 | 252 |
else |
253 |
next = static_cast<const InnerNode *>(baseClass)->findNode(path.at(i)); |
|
254 |
||
255 |
if (next) |
|
256 |
break; |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
node = next; |
|
261 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
262 |
if (node && i == path.size() && node->isFunction()) { |
0 | 263 |
// CppCodeParser::processOtherMetaCommand ensures that reimplemented |
264 |
// functions are private. |
|
265 |
const FunctionNode *func = static_cast<const FunctionNode*>(node); |
|
266 |
while (func->access() == Node::Private) { |
|
267 |
const FunctionNode *from = func->reimplementedFrom(); |
|
268 |
if (from != 0) { |
|
269 |
if (from->access() != Node::Private) |
|
270 |
return from; |
|
271 |
else |
|
272 |
func = from; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
273 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
else |
0 | 275 |
break; |
276 |
} |
|
277 |
return func; |
|
278 |
} |
|
279 |
relative = relative->parent(); |
|
280 |
} while (relative); |
|
281 |
||
282 |
return 0; |
|
283 |
} |
|
284 |
||
285 |
/*! |
|
286 |
*/ |
|
287 |
FunctionNode *Tree::findFunctionNode(const QStringList &parentPath, |
|
288 |
const FunctionNode *clone, |
|
289 |
Node *relative, |
|
290 |
int findFlags) |
|
291 |
{ |
|
292 |
return const_cast<FunctionNode *>( |
|
293 |
const_cast<const Tree *>(this)->findFunctionNode(parentPath, |
|
294 |
clone, |
|
295 |
relative, |
|
296 |
findFlags)); |
|
297 |
} |
|
298 |
||
299 |
/*! |
|
300 |
*/ |
|
301 |
const FunctionNode *Tree::findFunctionNode(const QStringList &parentPath, |
|
302 |
const FunctionNode *clone, |
|
303 |
const Node *relative, |
|
304 |
int findFlags) const |
|
305 |
{ |
|
306 |
const Node *parent = findNode(parentPath, relative, findFlags); |
|
307 |
if (parent == 0 || !parent->isInnerNode()) { |
|
308 |
return 0; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
310 |
else { |
0 | 311 |
return ((InnerNode *)parent)->findFunctionNode(clone); |
312 |
} |
|
313 |
} |
|
314 |
||
315 |
static const int NumSuffixes = 3; |
|
316 |
static const char * const suffixes[NumSuffixes] = { "", "s", "es" }; |
|
317 |
||
318 |
/*! |
|
319 |
*/ |
|
320 |
const FakeNode *Tree::findFakeNodeByTitle(const QString &title) const |
|
321 |
{ |
|
322 |
for (int pass = 0; pass < NumSuffixes; ++pass) { |
|
323 |
FakeNodeHash::const_iterator i = |
|
324 |
priv->fakeNodesByTitle.find(Doc::canonicalTitle(title + suffixes[pass])); |
|
325 |
if (i != priv->fakeNodesByTitle.constEnd()) { |
|
326 |
FakeNodeHash::const_iterator j = i; |
|
327 |
++j; |
|
328 |
if (j != priv->fakeNodesByTitle.constEnd() && j.key() == i.key()) { |
|
329 |
QList<Location> internalLocations; |
|
330 |
while (j != priv->fakeNodesByTitle.constEnd()) { |
|
331 |
if (j.key() == i.key() && j.value()->url().isEmpty()) |
|
332 |
internalLocations.append(j.value()->doc().location()); |
|
333 |
++j; |
|
334 |
} |
|
335 |
if (internalLocations.size() > 0) { |
|
336 |
i.value()->doc().location().warning( |
|
337 |
tr("Page '%1' defined in more than one location:").arg(title)); |
|
338 |
foreach (const Location &location, internalLocations) |
|
339 |
location.warning(tr("(defined here)")); |
|
340 |
} |
|
341 |
} |
|
342 |
return i.value(); |
|
343 |
} |
|
344 |
} |
|
345 |
return 0; |
|
346 |
} |
|
347 |
||
348 |
/*! |
|
349 |
*/ |
|
350 |
const Node* |
|
351 |
Tree::findUnambiguousTarget(const QString &target, Atom *&atom) const |
|
352 |
{ |
|
353 |
Target bestTarget = {0, 0, INT_MAX}; |
|
354 |
int numBestTargets = 0; |
|
355 |
||
356 |
for (int pass = 0; pass < NumSuffixes; ++pass) { |
|
357 |
TargetHash::const_iterator i = |
|
358 |
priv->targetHash.find(Doc::canonicalTitle(target + suffixes[pass])); |
|
359 |
if (i != priv->targetHash.constEnd()) { |
|
360 |
TargetHash::const_iterator j = i; |
|
361 |
do { |
|
362 |
const Target &candidate = j.value(); |
|
363 |
if (candidate.priority < bestTarget.priority) { |
|
364 |
bestTarget = candidate; |
|
365 |
numBestTargets = 1; |
|
366 |
} else if (candidate.priority == bestTarget.priority) { |
|
367 |
++numBestTargets; |
|
368 |
} |
|
369 |
++j; |
|
370 |
} while (j != priv->targetHash.constEnd() && j.key() == i.key()); |
|
371 |
||
372 |
if (numBestTargets == 1) { |
|
373 |
atom = bestTarget.atom; |
|
374 |
return bestTarget.node; |
|
375 |
} |
|
376 |
} |
|
377 |
} |
|
378 |
return 0; |
|
379 |
} |
|
380 |
||
381 |
/*! |
|
382 |
*/ |
|
383 |
Atom *Tree::findTarget(const QString &target, const Node *node) const |
|
384 |
{ |
|
385 |
for (int pass = 0; pass < NumSuffixes; ++pass) { |
|
386 |
QString key = Doc::canonicalTitle(target + suffixes[pass]); |
|
387 |
TargetHash::const_iterator i = priv->targetHash.find(key); |
|
388 |
||
389 |
if (i != priv->targetHash.constEnd()) { |
|
390 |
do { |
|
391 |
if (i.value().node == node) |
|
392 |
return i.value().atom; |
|
393 |
++i; |
|
394 |
} while (i != priv->targetHash.constEnd() && i.key() == key); |
|
395 |
} |
|
396 |
} |
|
397 |
return 0; |
|
398 |
} |
|
399 |
||
400 |
/*! |
|
401 |
*/ |
|
402 |
void Tree::addBaseClass(ClassNode *subclass, Node::Access access, |
|
403 |
const QStringList &basePath, |
|
404 |
const QString &dataTypeWithTemplateArgs, |
|
405 |
InnerNode *parent) |
|
406 |
{ |
|
407 |
priv->unresolvedInheritanceMap[subclass].append( |
|
408 |
InheritanceBound(access, |
|
409 |
basePath, |
|
410 |
dataTypeWithTemplateArgs, |
|
411 |
parent) |
|
412 |
); |
|
413 |
} |
|
414 |
||
415 |
||
416 |
/*! |
|
417 |
*/ |
|
418 |
void Tree::addPropertyFunction(PropertyNode *property, |
|
419 |
const QString &funcName, |
|
420 |
PropertyNode::FunctionRole funcRole) |
|
421 |
{ |
|
422 |
priv->unresolvedPropertyMap[property].insert(funcRole, funcName); |
|
423 |
} |
|
424 |
||
425 |
/*! |
|
426 |
This function adds the \a node to the \a group. The group |
|
427 |
can be listed anywhere using the \e{annotated list} command. |
|
428 |
*/ |
|
429 |
void Tree::addToGroup(Node *node, const QString &group) |
|
430 |
{ |
|
431 |
priv->groupMap.insert(group, node); |
|
432 |
} |
|
433 |
||
434 |
/*! |
|
435 |
*/ |
|
436 |
QMultiMap<QString, Node *> Tree::groups() const |
|
437 |
{ |
|
438 |
return priv->groupMap; |
|
439 |
} |
|
440 |
||
441 |
/*! |
|
442 |
*/ |
|
443 |
void Tree::addToPublicGroup(Node *node, const QString &group) |
|
444 |
{ |
|
445 |
priv->publicGroupMap.insert(node->name(), group); |
|
446 |
addToGroup(node, group); |
|
447 |
} |
|
448 |
||
449 |
/*! |
|
450 |
*/ |
|
451 |
QMultiMap<QString, QString> Tree::publicGroups() const |
|
452 |
{ |
|
453 |
return priv->publicGroupMap; |
|
454 |
} |
|
455 |
||
456 |
/*! |
|
457 |
*/ |
|
458 |
void Tree::resolveInheritance(NamespaceNode *rootNode) |
|
459 |
{ |
|
460 |
if (!rootNode) |
|
461 |
rootNode = root(); |
|
462 |
||
463 |
for (int pass = 0; pass < 2; pass++) { |
|
464 |
NodeList::ConstIterator c = rootNode->childNodes().begin(); |
|
465 |
while (c != rootNode->childNodes().end()) { |
|
466 |
if ((*c)->type() == Node::Class) |
|
467 |
resolveInheritance(pass, (ClassNode *) *c); |
|
468 |
else if ((*c)->type() == Node::Namespace) { |
|
469 |
NamespaceNode *ns = static_cast<NamespaceNode*>(*c); |
|
470 |
resolveInheritance(ns); |
|
471 |
} |
|
472 |
++c; |
|
473 |
} |
|
474 |
if (rootNode == root()) |
|
475 |
priv->unresolvedInheritanceMap.clear(); |
|
476 |
} |
|
477 |
} |
|
478 |
||
479 |
/*! |
|
480 |
*/ |
|
481 |
void Tree::resolveProperties() |
|
482 |
{ |
|
483 |
PropertyMap::ConstIterator propEntry; |
|
484 |
||
485 |
propEntry = priv->unresolvedPropertyMap.begin(); |
|
486 |
while (propEntry != priv->unresolvedPropertyMap.end()) { |
|
487 |
PropertyNode *property = propEntry.key(); |
|
488 |
InnerNode *parent = property->parent(); |
|
489 |
QString getterName = (*propEntry)[PropertyNode::Getter]; |
|
490 |
QString setterName = (*propEntry)[PropertyNode::Setter]; |
|
491 |
QString resetterName = (*propEntry)[PropertyNode::Resetter]; |
|
492 |
QString notifierName = (*propEntry)[PropertyNode::Notifier]; |
|
493 |
||
494 |
NodeList::ConstIterator c = parent->childNodes().begin(); |
|
495 |
while (c != parent->childNodes().end()) { |
|
496 |
if ((*c)->type() == Node::Function) { |
|
497 |
FunctionNode *function = static_cast<FunctionNode *>(*c); |
|
498 |
if (function->access() == property->access() && |
|
499 |
(function->status() == property->status() || |
|
500 |
function->doc().isEmpty())) { |
|
501 |
if (function->name() == getterName) { |
|
502 |
property->addFunction(function, PropertyNode::Getter); |
|
503 |
} else if (function->name() == setterName) { |
|
504 |
property->addFunction(function, PropertyNode::Setter); |
|
505 |
} else if (function->name() == resetterName) { |
|
506 |
property->addFunction(function, PropertyNode::Resetter); |
|
507 |
} else if (function->name() == notifierName) { |
|
508 |
property->addSignal(function, PropertyNode::Notifier); |
|
509 |
} |
|
510 |
} |
|
511 |
} |
|
512 |
++c; |
|
513 |
} |
|
514 |
++propEntry; |
|
515 |
} |
|
516 |
||
517 |
propEntry = priv->unresolvedPropertyMap.begin(); |
|
518 |
while (propEntry != priv->unresolvedPropertyMap.end()) { |
|
519 |
PropertyNode *property = propEntry.key(); |
|
520 |
// redo it to set the property functions |
|
521 |
if (property->overriddenFrom()) |
|
522 |
property->setOverriddenFrom(property->overriddenFrom()); |
|
523 |
++propEntry; |
|
524 |
} |
|
525 |
||
526 |
priv->unresolvedPropertyMap.clear(); |
|
527 |
} |
|
528 |
||
529 |
/*! |
|
530 |
*/ |
|
531 |
void Tree::resolveInheritance(int pass, ClassNode *classe) |
|
532 |
{ |
|
533 |
if (pass == 0) { |
|
534 |
QList<InheritanceBound> bounds = priv->unresolvedInheritanceMap[classe]; |
|
535 |
QList<InheritanceBound>::ConstIterator b = bounds.begin(); |
|
536 |
while (b != bounds.end()) { |
|
537 |
ClassNode *baseClass = (ClassNode*)findNode((*b).basePath, |
|
538 |
Node::Class); |
|
539 |
if (!baseClass && (*b).parent) |
|
540 |
baseClass = (ClassNode*)findNode((*b).basePath, |
|
541 |
Node::Class, |
|
542 |
(*b).parent); |
|
543 |
if (baseClass) |
|
544 |
classe->addBaseClass((*b).access, |
|
545 |
baseClass, |
|
546 |
(*b).dataTypeWithTemplateArgs); |
|
547 |
++b; |
|
548 |
} |
|
549 |
} |
|
550 |
else { |
|
551 |
NodeList::ConstIterator c = classe->childNodes().begin(); |
|
552 |
while (c != classe->childNodes().end()) { |
|
553 |
if ((*c)->type() == Node::Function) { |
|
554 |
FunctionNode *func = (FunctionNode *) *c; |
|
555 |
FunctionNode *from = findVirtualFunctionInBaseClasses(classe, func); |
|
556 |
if (from != 0) { |
|
557 |
if (func->virtualness() == FunctionNode::NonVirtual) |
|
558 |
func->setVirtualness(FunctionNode::ImpureVirtual); |
|
559 |
func->setReimplementedFrom(from); |
|
560 |
} |
|
561 |
} |
|
562 |
else if ((*c)->type() == Node::Property) { |
|
563 |
fixPropertyUsingBaseClasses(classe, static_cast<PropertyNode *>(*c)); |
|
564 |
} |
|
565 |
++c; |
|
566 |
} |
|
567 |
} |
|
568 |
} |
|
569 |
||
570 |
/*! |
|
571 |
*/ |
|
572 |
void Tree::resolveGroups() |
|
573 |
{ |
|
574 |
GroupMap::const_iterator i; |
|
575 |
QString prevGroup; |
|
576 |
for (i = priv->groupMap.constBegin(); i != priv->groupMap.constEnd(); ++i) { |
|
577 |
if (i.value()->access() == Node::Private) |
|
578 |
continue; |
|
579 |
||
580 |
FakeNode *fake = |
|
581 |
static_cast<FakeNode*>(findNode(QStringList(i.key()),Node::Fake)); |
|
582 |
if (fake && fake->subType() == Node::Group) { |
|
583 |
fake->addGroupMember(i.value()); |
|
584 |
} |
|
585 |
#if 0 |
|
586 |
else { |
|
587 |
if (prevGroup != i.key()) |
|
588 |
i.value()->doc().location().warning(tr("No such group '%1'").arg(i.key())); |
|
589 |
} |
|
590 |
#endif |
|
591 |
||
592 |
prevGroup = i.key(); |
|
593 |
} |
|
594 |
||
595 |
//priv->groupMap.clear(); |
|
596 |
} |
|
597 |
||
598 |
/*! |
|
599 |
*/ |
|
600 |
void Tree::resolveTargets() |
|
601 |
{ |
|
602 |
// need recursion |
|
603 |
||
604 |
foreach (Node *child, roo.childNodes()) { |
|
605 |
if (child->type() == Node::Fake) { |
|
606 |
FakeNode *node = static_cast<FakeNode *>(child); |
|
607 |
priv->fakeNodesByTitle.insert(Doc::canonicalTitle(node->title()), node); |
|
608 |
} |
|
609 |
||
610 |
if (child->doc().hasTableOfContents()) { |
|
611 |
const QList<Atom *> &toc = child->doc().tableOfContents(); |
|
612 |
Target target; |
|
613 |
target.node = child; |
|
614 |
target.priority = 3; |
|
615 |
||
616 |
for (int i = 0; i < toc.size(); ++i) { |
|
617 |
target.atom = toc.at(i); |
|
618 |
QString title = Text::sectionHeading(target.atom).toString(); |
|
619 |
if (!title.isEmpty()) |
|
620 |
priv->targetHash.insert(Doc::canonicalTitle(title), target); |
|
621 |
} |
|
622 |
} |
|
623 |
if (child->doc().hasKeywords()) { |
|
624 |
const QList<Atom *> &keywords = child->doc().keywords(); |
|
625 |
Target target; |
|
626 |
target.node = child; |
|
627 |
target.priority = 1; |
|
628 |
||
629 |
for (int i = 0; i < keywords.size(); ++i) { |
|
630 |
target.atom = keywords.at(i); |
|
631 |
priv->targetHash.insert(Doc::canonicalTitle(target.atom->string()), target); |
|
632 |
} |
|
633 |
} |
|
634 |
if (child->doc().hasTargets()) { |
|
635 |
const QList<Atom *> &toc = child->doc().targets(); |
|
636 |
Target target; |
|
637 |
target.node = child; |
|
638 |
target.priority = 2; |
|
639 |
||
640 |
for (int i = 0; i < toc.size(); ++i) { |
|
641 |
target.atom = toc.at(i); |
|
642 |
priv->targetHash.insert(Doc::canonicalTitle(target.atom->string()), target); |
|
643 |
} |
|
644 |
} |
|
645 |
} |
|
646 |
} |
|
647 |
||
648 |
/*! |
|
649 |
*/ |
|
650 |
void Tree::fixInheritance(NamespaceNode *rootNode) |
|
651 |
{ |
|
652 |
if (!rootNode) |
|
653 |
rootNode = root(); |
|
654 |
||
655 |
NodeList::ConstIterator c = rootNode->childNodes().begin(); |
|
656 |
while (c != rootNode->childNodes().end()) { |
|
657 |
if ((*c)->type() == Node::Class) |
|
658 |
static_cast<ClassNode *>(*c)->fixBaseClasses(); |
|
659 |
else if ((*c)->type() == Node::Namespace) { |
|
660 |
NamespaceNode *ns = static_cast<NamespaceNode*>(*c); |
|
661 |
fixInheritance(ns); |
|
662 |
} |
|
663 |
++c; |
|
664 |
} |
|
665 |
} |
|
666 |
||
667 |
/*! |
|
668 |
*/ |
|
669 |
FunctionNode *Tree::findVirtualFunctionInBaseClasses(ClassNode *classe, |
|
670 |
FunctionNode *clone) |
|
671 |
{ |
|
672 |
QList<RelatedClass>::ConstIterator r = classe->baseClasses().begin(); |
|
673 |
while (r != classe->baseClasses().end()) { |
|
674 |
FunctionNode *func; |
|
675 |
if (((func = findVirtualFunctionInBaseClasses((*r).node, clone)) != 0 || |
|
676 |
(func = (*r).node->findFunctionNode(clone)) != 0)) { |
|
677 |
if (func->virtualness() != FunctionNode::NonVirtual) |
|
678 |
return func; |
|
679 |
} |
|
680 |
++r; |
|
681 |
} |
|
682 |
return 0; |
|
683 |
} |
|
684 |
||
685 |
/*! |
|
686 |
*/ |
|
687 |
void Tree::fixPropertyUsingBaseClasses(ClassNode *classe, |
|
688 |
PropertyNode *property) |
|
689 |
{ |
|
690 |
QList<RelatedClass>::const_iterator r = classe->baseClasses().begin(); |
|
691 |
while (r != classe->baseClasses().end()) { |
|
692 |
PropertyNode *baseProperty = |
|
693 |
static_cast<PropertyNode *>(r->node->findNode(property->name(), |
|
694 |
Node::Property)); |
|
695 |
if (baseProperty) { |
|
696 |
fixPropertyUsingBaseClasses(r->node, baseProperty); |
|
697 |
property->setOverriddenFrom(baseProperty); |
|
698 |
} |
|
699 |
else { |
|
700 |
fixPropertyUsingBaseClasses(r->node, property); |
|
701 |
} |
|
702 |
++r; |
|
703 |
} |
|
704 |
} |
|
705 |
||
706 |
/*! |
|
707 |
*/ |
|
708 |
NodeList Tree::allBaseClasses(const ClassNode *classe) const |
|
709 |
{ |
|
710 |
NodeList result; |
|
711 |
foreach (const RelatedClass &r, classe->baseClasses()) { |
|
712 |
result += r.node; |
|
713 |
result += allBaseClasses(r.node); |
|
714 |
} |
|
715 |
return result; |
|
716 |
} |
|
717 |
||
718 |
/*! |
|
719 |
*/ |
|
720 |
void Tree::readIndexes(const QStringList &indexFiles) |
|
721 |
{ |
|
722 |
foreach (const QString &indexFile, indexFiles) |
|
723 |
readIndexFile(indexFile); |
|
724 |
} |
|
725 |
||
726 |
/*! |
|
727 |
Read the QDomDocument at \a path and get the index from it. |
|
728 |
*/ |
|
729 |
void Tree::readIndexFile(const QString &path) |
|
730 |
{ |
|
731 |
QFile file(path); |
|
732 |
if (file.open(QFile::ReadOnly)) { |
|
733 |
QDomDocument document; |
|
734 |
document.setContent(&file); |
|
735 |
file.close(); |
|
736 |
||
737 |
QDomElement indexElement = document.documentElement(); |
|
738 |
QString indexUrl = indexElement.attribute("url", ""); |
|
739 |
priv->basesList.clear(); |
|
740 |
priv->relatedList.clear(); |
|
741 |
||
742 |
// Scan all elements in the XML file, constructing a map that contains |
|
743 |
// base classes for each class found. |
|
744 |
||
745 |
QDomElement child = indexElement.firstChildElement(); |
|
746 |
while (!child.isNull()) { |
|
747 |
readIndexSection(child, root(), indexUrl); |
|
748 |
child = child.nextSiblingElement(); |
|
749 |
} |
|
750 |
||
751 |
// Now that all the base classes have been found for this index, |
|
752 |
// arrange them into an inheritance hierarchy. |
|
753 |
||
754 |
resolveIndex(); |
|
755 |
} |
|
756 |
} |
|
757 |
||
758 |
/*! |
|
759 |
*/ |
|
760 |
void Tree::readIndexSection(const QDomElement &element, |
|
761 |
InnerNode *parent, |
|
762 |
const QString &indexUrl) |
|
763 |
{ |
|
764 |
QString name = element.attribute("name"); |
|
765 |
QString href = element.attribute("href"); |
|
766 |
||
767 |
Node *section; |
|
768 |
Location location; |
|
769 |
||
770 |
if (element.nodeName() == "namespace") { |
|
771 |
section = new NamespaceNode(parent, name); |
|
772 |
||
773 |
if (!indexUrl.isEmpty()) |
|
774 |
location = Location(indexUrl + "/" + name.toLower() + ".html"); |
|
775 |
else if (!indexUrl.isNull()) |
|
776 |
location = Location(name.toLower() + ".html"); |
|
777 |
||
778 |
} |
|
779 |
else if (element.nodeName() == "class") { |
|
780 |
section = new ClassNode(parent, name); |
|
781 |
priv->basesList.append(QPair<ClassNode*,QString>( |
|
782 |
static_cast<ClassNode*>(section), element.attribute("bases"))); |
|
783 |
||
784 |
if (!indexUrl.isEmpty()) |
|
785 |
location = Location(indexUrl + "/" + name.toLower() + ".html"); |
|
786 |
else if (!indexUrl.isNull()) |
|
787 |
location = Location(name.toLower() + ".html"); |
|
788 |
||
789 |
} |
|
790 |
else if (element.nodeName() == "page") { |
|
791 |
Node::SubType subtype; |
|
792 |
if (element.attribute("subtype") == "example") |
|
793 |
subtype = Node::Example; |
|
794 |
else if (element.attribute("subtype") == "header") |
|
795 |
subtype = Node::HeaderFile; |
|
796 |
else if (element.attribute("subtype") == "file") |
|
797 |
subtype = Node::File; |
|
798 |
else if (element.attribute("subtype") == "group") |
|
799 |
subtype = Node::Group; |
|
800 |
else if (element.attribute("subtype") == "module") |
|
801 |
subtype = Node::Module; |
|
802 |
else if (element.attribute("subtype") == "page") |
|
803 |
subtype = Node::Page; |
|
804 |
else if (element.attribute("subtype") == "externalpage") |
|
805 |
subtype = Node::ExternalPage; |
|
806 |
else |
|
807 |
return; |
|
808 |
||
809 |
FakeNode *fakeNode = new FakeNode(parent, name, subtype); |
|
810 |
fakeNode->setTitle(element.attribute("title")); |
|
811 |
||
812 |
if (element.hasAttribute("location")) |
|
813 |
name = element.attribute("location", ""); |
|
814 |
||
815 |
if (!indexUrl.isEmpty()) |
|
816 |
location = Location(indexUrl + "/" + name); |
|
817 |
else if (!indexUrl.isNull()) |
|
818 |
location = Location(name); |
|
819 |
||
820 |
section = fakeNode; |
|
821 |
||
822 |
} |
|
823 |
else if (element.nodeName() == "enum") { |
|
824 |
EnumNode *enumNode = new EnumNode(parent, name); |
|
825 |
||
826 |
if (!indexUrl.isEmpty()) |
|
827 |
location = |
|
828 |
Location(indexUrl + "/" + parent->name().toLower() + ".html"); |
|
829 |
else if (!indexUrl.isNull()) |
|
830 |
location = Location(parent->name().toLower() + ".html"); |
|
831 |
||
832 |
QDomElement child = element.firstChildElement("value"); |
|
833 |
while (!child.isNull()) { |
|
834 |
EnumItem item(child.attribute("name"), child.attribute("value")); |
|
835 |
enumNode->addItem(item); |
|
836 |
child = child.nextSiblingElement("value"); |
|
837 |
} |
|
838 |
||
839 |
section = enumNode; |
|
840 |
||
841 |
} else if (element.nodeName() == "typedef") { |
|
842 |
section = new TypedefNode(parent, name); |
|
843 |
||
844 |
if (!indexUrl.isEmpty()) |
|
845 |
location = |
|
846 |
Location(indexUrl + "/" + parent->name().toLower() + ".html"); |
|
847 |
else if (!indexUrl.isNull()) |
|
848 |
location = Location(parent->name().toLower() + ".html"); |
|
849 |
||
850 |
} |
|
851 |
else if (element.nodeName() == "property") { |
|
852 |
section = new PropertyNode(parent, name); |
|
853 |
||
854 |
if (!indexUrl.isEmpty()) |
|
855 |
location = |
|
856 |
Location(indexUrl + "/" + parent->name().toLower() + ".html"); |
|
857 |
else if (!indexUrl.isNull()) |
|
858 |
location = Location(parent->name().toLower() + ".html"); |
|
859 |
||
860 |
} else if (element.nodeName() == "function") { |
|
861 |
FunctionNode::Virtualness virt; |
|
862 |
if (element.attribute("virtual") == "non") |
|
863 |
virt = FunctionNode::NonVirtual; |
|
864 |
else if (element.attribute("virtual") == "impure") |
|
865 |
virt = FunctionNode::ImpureVirtual; |
|
866 |
else if (element.attribute("virtual") == "pure") |
|
867 |
virt = FunctionNode::PureVirtual; |
|
868 |
else |
|
869 |
return; |
|
870 |
||
871 |
FunctionNode::Metaness meta; |
|
872 |
if (element.attribute("meta") == "plain") |
|
873 |
meta = FunctionNode::Plain; |
|
874 |
else if (element.attribute("meta") == "signal") |
|
875 |
meta = FunctionNode::Signal; |
|
876 |
else if (element.attribute("meta") == "slot") |
|
877 |
meta = FunctionNode::Slot; |
|
878 |
else if (element.attribute("meta") == "constructor") |
|
879 |
meta = FunctionNode::Ctor; |
|
880 |
else if (element.attribute("meta") == "destructor") |
|
881 |
meta = FunctionNode::Dtor; |
|
882 |
else if (element.attribute("meta") == "macro") |
|
883 |
meta = FunctionNode::MacroWithParams; |
|
884 |
else if (element.attribute("meta") == "macrowithparams") |
|
885 |
meta = FunctionNode::MacroWithParams; |
|
886 |
else if (element.attribute("meta") == "macrowithoutparams") |
|
887 |
meta = FunctionNode::MacroWithoutParams; |
|
888 |
else |
|
889 |
return; |
|
890 |
||
891 |
FunctionNode *functionNode = new FunctionNode(parent, name); |
|
892 |
functionNode->setReturnType(element.attribute("return")); |
|
893 |
functionNode->setVirtualness(virt); |
|
894 |
functionNode->setMetaness(meta); |
|
895 |
functionNode->setConst(element.attribute("const") == "true"); |
|
896 |
functionNode->setStatic(element.attribute("static") == "true"); |
|
897 |
functionNode->setOverload(element.attribute("overload") == "true"); |
|
898 |
||
899 |
if (element.hasAttribute("relates") |
|
900 |
&& element.attribute("relates") != parent->name()) { |
|
901 |
priv->relatedList.append( |
|
902 |
QPair<FunctionNode*,QString>(functionNode, |
|
903 |
element.attribute("relates"))); |
|
904 |
} |
|
905 |
||
906 |
QDomElement child = element.firstChildElement("parameter"); |
|
907 |
while (!child.isNull()) { |
|
908 |
// Do not use the default value for the parameter; it is not |
|
909 |
// required, and has been known to cause problems. |
|
910 |
Parameter parameter(child.attribute("left"), |
|
911 |
child.attribute("right"), |
|
912 |
child.attribute("name"), |
|
913 |
""); // child.attribute("default") |
|
914 |
functionNode->addParameter(parameter); |
|
915 |
child = child.nextSiblingElement("parameter"); |
|
916 |
} |
|
917 |
||
918 |
section = functionNode; |
|
919 |
||
920 |
if (!indexUrl.isEmpty()) |
|
921 |
location = |
|
922 |
Location(indexUrl + "/" + parent->name().toLower() + ".html"); |
|
923 |
else if (!indexUrl.isNull()) |
|
924 |
location = Location(parent->name().toLower() + ".html"); |
|
925 |
||
926 |
} |
|
927 |
else if (element.nodeName() == "variable") { |
|
928 |
section = new VariableNode(parent, name); |
|
929 |
||
930 |
if (!indexUrl.isEmpty()) |
|
931 |
location = Location(indexUrl + "/" + parent->name().toLower() + ".html"); |
|
932 |
else if (!indexUrl.isNull()) |
|
933 |
location = Location(parent->name().toLower() + ".html"); |
|
934 |
||
935 |
} |
|
936 |
else if (element.nodeName() == "keyword") { |
|
937 |
Target target; |
|
938 |
target.node = parent; |
|
939 |
target.priority = 1; |
|
940 |
target.atom = new Atom(Atom::Target, name); |
|
941 |
priv->targetHash.insert(name, target); |
|
942 |
return; |
|
943 |
||
944 |
} |
|
945 |
else if (element.nodeName() == "target") { |
|
946 |
Target target; |
|
947 |
target.node = parent; |
|
948 |
target.priority = 2; |
|
949 |
target.atom = new Atom(Atom::Target, name); |
|
950 |
priv->targetHash.insert(name, target); |
|
951 |
return; |
|
952 |
||
953 |
} |
|
954 |
else if (element.nodeName() == "contents") { |
|
955 |
Target target; |
|
956 |
target.node = parent; |
|
957 |
target.priority = 3; |
|
958 |
target.atom = new Atom(Atom::Target, name); |
|
959 |
priv->targetHash.insert(name, target); |
|
960 |
return; |
|
961 |
||
962 |
} |
|
963 |
else |
|
964 |
return; |
|
965 |
||
966 |
QString access = element.attribute("access"); |
|
967 |
if (access == "public") |
|
968 |
section->setAccess(Node::Public); |
|
969 |
else if (access == "protected") |
|
970 |
section->setAccess(Node::Protected); |
|
971 |
else if (access == "private") |
|
972 |
section->setAccess(Node::Private); |
|
973 |
else |
|
974 |
section->setAccess(Node::Public); |
|
975 |
||
976 |
if (element.nodeName() != "page") { |
|
977 |
QString threadSafety = element.attribute("threadsafety"); |
|
978 |
if (threadSafety == "non-reentrant") |
|
979 |
section->setThreadSafeness(Node::NonReentrant); |
|
980 |
else if (threadSafety == "reentrant") |
|
981 |
section->setThreadSafeness(Node::Reentrant); |
|
982 |
else if (threadSafety == "thread safe") |
|
983 |
section->setThreadSafeness(Node::ThreadSafe); |
|
984 |
else |
|
985 |
section->setThreadSafeness(Node::UnspecifiedSafeness); |
|
986 |
} |
|
987 |
else |
|
988 |
section->setThreadSafeness(Node::UnspecifiedSafeness); |
|
989 |
||
990 |
QString status = element.attribute("status"); |
|
991 |
if (status == "compat") |
|
992 |
section->setStatus(Node::Compat); |
|
993 |
else if (status == "obsolete") |
|
994 |
section->setStatus(Node::Obsolete); |
|
995 |
else if (status == "deprecated") |
|
996 |
section->setStatus(Node::Deprecated); |
|
997 |
else if (status == "preliminary") |
|
998 |
section->setStatus(Node::Preliminary); |
|
999 |
else if (status == "commendable") |
|
1000 |
section->setStatus(Node::Commendable); |
|
1001 |
else if (status == "internal") |
|
1002 |
section->setStatus(Node::Internal); |
|
1003 |
else if (status == "main") |
|
1004 |
section->setStatus(Node::Main); |
|
1005 |
else |
|
1006 |
section->setStatus(Node::Commendable); |
|
1007 |
||
1008 |
section->setModuleName(element.attribute("module")); |
|
1009 |
if (!indexUrl.isEmpty()) { |
|
1010 |
if (indexUrl.startsWith(".")) |
|
1011 |
section->setUrl(href); |
|
1012 |
else |
|
1013 |
section->setUrl(indexUrl + "/" + href); |
|
1014 |
} |
|
1015 |
||
1016 |
// Create some content for the node. |
|
1017 |
QSet<QString> emptySet; |
|
1018 |
||
1019 |
Doc doc(location, location, " ", emptySet); // placeholder |
|
1020 |
section->setDoc(doc); |
|
1021 |
||
1022 |
if (section->isInnerNode()) { |
|
1023 |
InnerNode *inner = static_cast<InnerNode*>(section); |
|
1024 |
if (inner) { |
|
1025 |
QDomElement child = element.firstChildElement(); |
|
1026 |
||
1027 |
while (!child.isNull()) { |
|
1028 |
if (element.nodeName() == "class") |
|
1029 |
readIndexSection(child, inner, indexUrl); |
|
1030 |
else if (element.nodeName() == "page") |
|
1031 |
readIndexSection(child, inner, indexUrl); |
|
1032 |
else if (element.nodeName() == "namespace" && !name.isEmpty()) |
|
1033 |
// The root node in the index is a namespace with an empty name. |
|
1034 |
readIndexSection(child, inner, indexUrl); |
|
1035 |
else |
|
1036 |
readIndexSection(child, parent, indexUrl); |
|
1037 |
||
1038 |
child = child.nextSiblingElement(); |
|
1039 |
} |
|
1040 |
} |
|
1041 |
} |
|
1042 |
} |
|
1043 |
||
1044 |
/*! |
|
1045 |
*/ |
|
1046 |
QString Tree::readIndexText(const QDomElement &element) |
|
1047 |
{ |
|
1048 |
QString text; |
|
1049 |
QDomNode child = element.firstChild(); |
|
1050 |
while (!child.isNull()) { |
|
1051 |
if (child.isText()) |
|
1052 |
text += child.toText().nodeValue(); |
|
1053 |
child = child.nextSibling(); |
|
1054 |
} |
|
1055 |
return text; |
|
1056 |
} |
|
1057 |
||
1058 |
/*! |
|
1059 |
*/ |
|
1060 |
void Tree::resolveIndex() |
|
1061 |
{ |
|
1062 |
QPair<ClassNode*,QString> pair; |
|
1063 |
||
1064 |
foreach (pair, priv->basesList) { |
|
1065 |
foreach (const QString &base, pair.second.split(",")) { |
|
1066 |
Node *baseClass = root()->findNode(base, Node::Class); |
|
1067 |
if (baseClass) { |
|
1068 |
pair.first->addBaseClass(Node::Public, |
|
1069 |
static_cast<ClassNode*>(baseClass)); |
|
1070 |
} |
|
1071 |
} |
|
1072 |
} |
|
1073 |
||
1074 |
QPair<FunctionNode*,QString> relatedPair; |
|
1075 |
||
1076 |
foreach (relatedPair, priv->relatedList) { |
|
1077 |
Node *classNode = root()->findNode(relatedPair.second, Node::Class); |
|
1078 |
if (classNode) |
|
1079 |
relatedPair.first->setRelates(static_cast<ClassNode*>(classNode)); |
|
1080 |
} |
|
1081 |
} |
|
1082 |
||
1083 |
/*! |
|
1084 |
Generate the index section with the given \a writer for the \a node |
|
1085 |
specified, returning true if an element was written; otherwise returns |
|
1086 |
false. |
|
1087 |
*/ |
|
1088 |
bool Tree::generateIndexSection(QXmlStreamWriter &writer, |
|
1089 |
const Node *node, |
|
1090 |
bool generateInternalNodes) const |
|
1091 |
{ |
|
1092 |
if (!node->url().isEmpty()) |
|
1093 |
return false; |
|
1094 |
||
1095 |
QString nodeName; |
|
1096 |
switch (node->type()) { |
|
1097 |
case Node::Namespace: |
|
1098 |
nodeName = "namespace"; |
|
1099 |
break; |
|
1100 |
case Node::Class: |
|
1101 |
nodeName = "class"; |
|
1102 |
break; |
|
1103 |
case Node::Fake: |
|
1104 |
nodeName = "page"; |
|
1105 |
break; |
|
1106 |
case Node::Enum: |
|
1107 |
nodeName = "enum"; |
|
1108 |
break; |
|
1109 |
case Node::Typedef: |
|
1110 |
nodeName = "typedef"; |
|
1111 |
break; |
|
1112 |
case Node::Property: |
|
1113 |
nodeName = "property"; |
|
1114 |
break; |
|
1115 |
case Node::Function: |
|
1116 |
nodeName = "function"; |
|
1117 |
break; |
|
1118 |
case Node::Variable: |
|
1119 |
nodeName = "variable"; |
|
1120 |
break; |
|
1121 |
case Node::Target: |
|
1122 |
nodeName = "target"; |
|
1123 |
break; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1124 |
case Node::QmlProperty: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1125 |
nodeName = "qmlproperty"; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1126 |
break; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1127 |
case Node::QmlSignal: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1128 |
nodeName = "qmlsignal"; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1129 |
break; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1130 |
case Node::QmlMethod: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1131 |
nodeName = "qmlmethod"; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1132 |
break; |
0 | 1133 |
default: |
1134 |
return false; |
|
1135 |
} |
|
1136 |
||
1137 |
QString access; |
|
1138 |
switch (node->access()) { |
|
1139 |
case Node::Public: |
|
1140 |
access = "public"; |
|
1141 |
break; |
|
1142 |
case Node::Protected: |
|
1143 |
access = "protected"; |
|
1144 |
break; |
|
1145 |
case Node::Private: |
|
1146 |
// Do not include private non-internal nodes in the index. |
|
1147 |
// (Internal public and protected nodes are marked as private |
|
1148 |
// by qdoc. We can check their internal status to determine |
|
1149 |
// whether they were really private to begin with.) |
|
1150 |
if (node->status() == Node::Internal && generateInternalNodes) |
|
1151 |
access = "internal"; |
|
1152 |
else |
|
1153 |
return false; |
|
1154 |
break; |
|
1155 |
default: |
|
1156 |
return false; |
|
1157 |
} |
|
1158 |
||
1159 |
QString objName = node->name(); |
|
1160 |
||
1161 |
// Special case: only the root node should have an empty name. |
|
1162 |
if (objName.isEmpty() && node != root()) |
|
1163 |
return false; |
|
1164 |
||
1165 |
writer.writeStartElement(nodeName); |
|
1166 |
||
1167 |
QXmlStreamAttributes attributes; |
|
1168 |
writer.writeAttribute("access", access); |
|
1169 |
||
1170 |
if (node->type() != Node::Fake) { |
|
1171 |
QString threadSafety; |
|
1172 |
switch (node->threadSafeness()) { |
|
1173 |
case Node::NonReentrant: |
|
1174 |
threadSafety = "non-reentrant"; |
|
1175 |
break; |
|
1176 |
case Node::Reentrant: |
|
1177 |
threadSafety = "reentrant"; |
|
1178 |
break; |
|
1179 |
case Node::ThreadSafe: |
|
1180 |
threadSafety = "thread safe"; |
|
1181 |
break; |
|
1182 |
case Node::UnspecifiedSafeness: |
|
1183 |
default: |
|
1184 |
threadSafety = "unspecified"; |
|
1185 |
break; |
|
1186 |
} |
|
1187 |
writer.writeAttribute("threadsafety", threadSafety); |
|
1188 |
} |
|
1189 |
||
1190 |
QString status; |
|
1191 |
switch (node->status()) { |
|
1192 |
case Node::Compat: |
|
1193 |
status = "compat"; |
|
1194 |
break; |
|
1195 |
case Node::Obsolete: |
|
1196 |
status = "obsolete"; |
|
1197 |
break; |
|
1198 |
case Node::Deprecated: |
|
1199 |
status = "deprecated"; |
|
1200 |
break; |
|
1201 |
case Node::Preliminary: |
|
1202 |
status = "preliminary"; |
|
1203 |
break; |
|
1204 |
case Node::Commendable: |
|
1205 |
status = "commendable"; |
|
1206 |
break; |
|
1207 |
case Node::Internal: |
|
1208 |
status = "internal"; |
|
1209 |
break; |
|
1210 |
case Node::Main: |
|
1211 |
default: |
|
1212 |
status = "main"; |
|
1213 |
break; |
|
1214 |
} |
|
1215 |
writer.writeAttribute("status", status); |
|
1216 |
||
1217 |
writer.writeAttribute("name", objName); |
|
1218 |
QString fullName = fullDocumentName(node); |
|
1219 |
if (fullName != objName) |
|
1220 |
writer.writeAttribute("fullname", fullName); |
|
1221 |
writer.writeAttribute("href", fullDocumentLocation(node)); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1222 |
if ((node->type() != Node::Fake) && (!node->isQmlNode())) |
0 | 1223 |
writer.writeAttribute("location", node->location().fileName()); |
1224 |
||
1225 |
switch (node->type()) { |
|
1226 |
||
1227 |
case Node::Class: |
|
1228 |
{ |
|
1229 |
// Classes contain information about their base classes. |
|
1230 |
||
1231 |
const ClassNode *classNode = static_cast<const ClassNode*>(node); |
|
1232 |
QList<RelatedClass> bases = classNode->baseClasses(); |
|
1233 |
QSet<QString> baseStrings; |
|
1234 |
foreach (const RelatedClass &related, bases) { |
|
1235 |
ClassNode *baseClassNode = related.node; |
|
1236 |
baseStrings.insert(baseClassNode->name()); |
|
1237 |
} |
|
1238 |
writer.writeAttribute("bases", QStringList(baseStrings.toList()).join(",")); |
|
1239 |
writer.writeAttribute("module", node->moduleName()); |
|
1240 |
} |
|
1241 |
break; |
|
1242 |
||
1243 |
case Node::Namespace: |
|
1244 |
writer.writeAttribute("module", node->moduleName()); |
|
1245 |
break; |
|
1246 |
||
1247 |
case Node::Fake: |
|
1248 |
{ |
|
1249 |
/* |
|
1250 |
Fake nodes (such as manual pages) contain subtypes, |
|
1251 |
titles and other attributes. |
|
1252 |
*/ |
|
1253 |
||
1254 |
const FakeNode *fakeNode = static_cast<const FakeNode*>(node); |
|
1255 |
switch (fakeNode->subType()) { |
|
1256 |
case Node::Example: |
|
1257 |
writer.writeAttribute("subtype", "example"); |
|
1258 |
break; |
|
1259 |
case Node::HeaderFile: |
|
1260 |
writer.writeAttribute("subtype", "header"); |
|
1261 |
break; |
|
1262 |
case Node::File: |
|
1263 |
writer.writeAttribute("subtype", "file"); |
|
1264 |
break; |
|
1265 |
case Node::Group: |
|
1266 |
writer.writeAttribute("subtype", "group"); |
|
1267 |
break; |
|
1268 |
case Node::Module: |
|
1269 |
writer.writeAttribute("subtype", "module"); |
|
1270 |
break; |
|
1271 |
case Node::Page: |
|
1272 |
writer.writeAttribute("subtype", "page"); |
|
1273 |
break; |
|
1274 |
case Node::ExternalPage: |
|
1275 |
writer.writeAttribute("subtype", "externalpage"); |
|
1276 |
break; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1277 |
case Node::QmlClass: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1278 |
writer.writeAttribute("subtype", "qmlclass"); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1279 |
break; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1280 |
case Node::QmlBasicType: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1281 |
writer.writeAttribute("subtype", "qmlbasictype"); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1282 |
break; |
0 | 1283 |
default: |
1284 |
break; |
|
1285 |
} |
|
1286 |
writer.writeAttribute("title", fakeNode->title()); |
|
1287 |
writer.writeAttribute("fulltitle", fakeNode->fullTitle()); |
|
1288 |
writer.writeAttribute("subtitle", fakeNode->subTitle()); |
|
1289 |
writer.writeAttribute("location", fakeNode->doc().location().fileName()); |
|
1290 |
} |
|
1291 |
break; |
|
1292 |
||
1293 |
case Node::Function: |
|
1294 |
{ |
|
1295 |
/* |
|
1296 |
Function nodes contain information about the type of |
|
1297 |
function being described. |
|
1298 |
*/ |
|
1299 |
||
1300 |
const FunctionNode *functionNode = |
|
1301 |
static_cast<const FunctionNode*>(node); |
|
1302 |
||
1303 |
switch (functionNode->virtualness()) { |
|
1304 |
case FunctionNode::NonVirtual: |
|
1305 |
writer.writeAttribute("virtual", "non"); |
|
1306 |
break; |
|
1307 |
case FunctionNode::ImpureVirtual: |
|
1308 |
writer.writeAttribute("virtual", "impure"); |
|
1309 |
break; |
|
1310 |
case FunctionNode::PureVirtual: |
|
1311 |
writer.writeAttribute("virtual", "pure"); |
|
1312 |
break; |
|
1313 |
default: |
|
1314 |
break; |
|
1315 |
} |
|
1316 |
switch (functionNode->metaness()) { |
|
1317 |
case FunctionNode::Plain: |
|
1318 |
writer.writeAttribute("meta", "plain"); |
|
1319 |
break; |
|
1320 |
case FunctionNode::Signal: |
|
1321 |
writer.writeAttribute("meta", "signal"); |
|
1322 |
break; |
|
1323 |
case FunctionNode::Slot: |
|
1324 |
writer.writeAttribute("meta", "slot"); |
|
1325 |
break; |
|
1326 |
case FunctionNode::Ctor: |
|
1327 |
writer.writeAttribute("meta", "constructor"); |
|
1328 |
break; |
|
1329 |
case FunctionNode::Dtor: |
|
1330 |
writer.writeAttribute("meta", "destructor"); |
|
1331 |
break; |
|
1332 |
case FunctionNode::MacroWithParams: |
|
1333 |
writer.writeAttribute("meta", "macrowithparams"); |
|
1334 |
break; |
|
1335 |
case FunctionNode::MacroWithoutParams: |
|
1336 |
writer.writeAttribute("meta", "macrowithoutparams"); |
|
1337 |
break; |
|
1338 |
default: |
|
1339 |
break; |
|
1340 |
} |
|
1341 |
writer.writeAttribute("const", functionNode->isConst()?"true":"false"); |
|
1342 |
writer.writeAttribute("static", functionNode->isStatic()?"true":"false"); |
|
1343 |
writer.writeAttribute("overload", functionNode->isOverload()?"true":"false"); |
|
1344 |
if (functionNode->isOverload()) |
|
1345 |
writer.writeAttribute("overload-number", QString::number(functionNode->overloadNumber())); |
|
1346 |
if (functionNode->relates()) |
|
1347 |
writer.writeAttribute("relates", functionNode->relates()->name()); |
|
1348 |
const PropertyNode *propertyNode = functionNode->associatedProperty(); |
|
1349 |
if (propertyNode) |
|
1350 |
writer.writeAttribute("associated-property", propertyNode->name()); |
|
1351 |
writer.writeAttribute("type", functionNode->returnType()); |
|
1352 |
} |
|
1353 |
break; |
|
1354 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1355 |
case Node::QmlProperty: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1356 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1357 |
const QmlPropertyNode *qpn = static_cast<const QmlPropertyNode*>(node); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1358 |
writer.writeAttribute("type", qpn->dataType()); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1359 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1360 |
break; |
0 | 1361 |
case Node::Property: |
1362 |
{ |
|
1363 |
const PropertyNode *propertyNode = static_cast<const PropertyNode*>(node); |
|
1364 |
writer.writeAttribute("type", propertyNode->dataType()); |
|
1365 |
foreach (const Node *fnNode, propertyNode->getters()) { |
|
1366 |
if (fnNode) { |
|
1367 |
const FunctionNode *functionNode = static_cast<const FunctionNode*>(fnNode); |
|
1368 |
writer.writeStartElement("getter"); |
|
1369 |
writer.writeAttribute("name", functionNode->name()); |
|
1370 |
writer.writeEndElement(); // getter |
|
1371 |
} |
|
1372 |
} |
|
1373 |
foreach (const Node *fnNode, propertyNode->setters()) { |
|
1374 |
if (fnNode) { |
|
1375 |
const FunctionNode *functionNode = static_cast<const FunctionNode*>(fnNode); |
|
1376 |
writer.writeStartElement("setter"); |
|
1377 |
writer.writeAttribute("name", functionNode->name()); |
|
1378 |
writer.writeEndElement(); // getter |
|
1379 |
} |
|
1380 |
} |
|
1381 |
foreach (const Node *fnNode, propertyNode->resetters()) { |
|
1382 |
if (fnNode) { |
|
1383 |
const FunctionNode *functionNode = static_cast<const FunctionNode*>(fnNode); |
|
1384 |
writer.writeStartElement("resetter"); |
|
1385 |
writer.writeAttribute("name", functionNode->name()); |
|
1386 |
writer.writeEndElement(); // getter |
|
1387 |
} |
|
1388 |
} |
|
1389 |
} |
|
1390 |
break; |
|
1391 |
||
1392 |
case Node::Variable: |
|
1393 |
{ |
|
1394 |
const VariableNode *variableNode = |
|
1395 |
static_cast<const VariableNode*>(node); |
|
1396 |
writer.writeAttribute("type", variableNode->dataType()); |
|
1397 |
writer.writeAttribute("static", |
|
1398 |
variableNode->isStatic() ? "true" : "false"); |
|
1399 |
} |
|
1400 |
break; |
|
1401 |
default: |
|
1402 |
break; |
|
1403 |
} |
|
1404 |
||
1405 |
// Inner nodes and function nodes contain child nodes of some sort, either |
|
1406 |
// actual child nodes or function parameters. For these, we close the |
|
1407 |
// opening tag, create child elements, then add a closing tag for the |
|
1408 |
// element. Elements for all other nodes are closed in the opening tag. |
|
1409 |
||
1410 |
if (node->isInnerNode()) { |
|
1411 |
||
1412 |
const InnerNode *inner = static_cast<const InnerNode*>(node); |
|
1413 |
||
1414 |
// For internal pages, we canonicalize the target, keyword and content |
|
1415 |
// item names so that they can be used by qdoc for other sets of |
|
1416 |
// documentation. |
|
1417 |
// The reason we do this here is that we don't want to ruin |
|
1418 |
// externally composed indexes, containing non-qdoc-style target names |
|
1419 |
// when reading in indexes. |
|
1420 |
||
1421 |
if (inner->doc().hasTargets()) { |
|
1422 |
bool external = false; |
|
1423 |
if (inner->type() == Node::Fake) { |
|
1424 |
const FakeNode *fakeNode = static_cast<const FakeNode *>(inner); |
|
1425 |
if (fakeNode->subType() == Node::ExternalPage) |
|
1426 |
external = true; |
|
1427 |
} |
|
1428 |
||
1429 |
foreach (const Atom *target, inner->doc().targets()) { |
|
1430 |
QString targetName = target->string(); |
|
1431 |
if (!external) |
|
1432 |
targetName = Doc::canonicalTitle(targetName); |
|
1433 |
||
1434 |
writer.writeStartElement("target"); |
|
1435 |
writer.writeAttribute("name", targetName); |
|
1436 |
writer.writeEndElement(); // target |
|
1437 |
} |
|
1438 |
} |
|
1439 |
if (inner->doc().hasKeywords()) { |
|
1440 |
foreach (const Atom *keyword, inner->doc().keywords()) { |
|
1441 |
writer.writeStartElement("keyword"); |
|
1442 |
writer.writeAttribute("name", |
|
1443 |
Doc::canonicalTitle(keyword->string())); |
|
1444 |
writer.writeEndElement(); // keyword |
|
1445 |
} |
|
1446 |
} |
|
1447 |
if (inner->doc().hasTableOfContents()) { |
|
1448 |
for (int i = 0; i < inner->doc().tableOfContents().size(); ++i) { |
|
1449 |
Atom *item = inner->doc().tableOfContents()[i]; |
|
1450 |
int level = inner->doc().tableOfContentsLevels()[i]; |
|
1451 |
||
1452 |
QString title = Text::sectionHeading(item).toString(); |
|
1453 |
writer.writeStartElement("contents"); |
|
1454 |
writer.writeAttribute("name", Doc::canonicalTitle(title)); |
|
1455 |
writer.writeAttribute("title", title); |
|
1456 |
writer.writeAttribute("level", QString::number(level)); |
|
1457 |
writer.writeEndElement(); // contents |
|
1458 |
} |
|
1459 |
} |
|
1460 |
||
1461 |
} |
|
1462 |
else if (node->type() == Node::Function) { |
|
1463 |
||
1464 |
const FunctionNode *functionNode = static_cast<const FunctionNode*>(node); |
|
1465 |
// Write a signature attribute for convenience. |
|
1466 |
QStringList signatureList; |
|
1467 |
QStringList resolvedParameters; |
|
1468 |
||
1469 |
foreach (const Parameter ¶meter, functionNode->parameters()) { |
|
1470 |
QString leftType = parameter.leftType(); |
|
1471 |
const Node *leftNode = |
|
1472 |
const_cast<Tree*>(this)->findNode(parameter.leftType().split("::"), |
|
1473 |
Node::Typedef, 0, SearchBaseClasses|NonFunction); |
|
1474 |
if (!leftNode) { |
|
1475 |
leftNode = const_cast<Tree *>(this)->findNode( |
|
1476 |
parameter.leftType().split("::"), Node::Typedef, |
|
1477 |
node->parent(), SearchBaseClasses|NonFunction); |
|
1478 |
} |
|
1479 |
if (leftNode) { |
|
1480 |
if (leftNode->type() == Node::Typedef) { |
|
1481 |
const TypedefNode *typedefNode = |
|
1482 |
static_cast<const TypedefNode *>(leftNode); |
|
1483 |
if (typedefNode->associatedEnum()) { |
|
1484 |
leftType = "QFlags<"+fullDocumentName(typedefNode->associatedEnum())+">"; |
|
1485 |
} |
|
1486 |
} |
|
1487 |
else |
|
1488 |
leftType = fullDocumentName(leftNode); |
|
1489 |
} |
|
1490 |
resolvedParameters.append(leftType); |
|
1491 |
signatureList.append(leftType + " " + parameter.name()); |
|
1492 |
} |
|
1493 |
||
1494 |
QString signature = functionNode->name()+"("+signatureList.join(", ")+")"; |
|
1495 |
if (functionNode->isConst()) |
|
1496 |
signature += " const"; |
|
1497 |
writer.writeAttribute("signature", signature); |
|
1498 |
||
1499 |
for (int i = 0; i < functionNode->parameters().size(); ++i) { |
|
1500 |
Parameter parameter = functionNode->parameters()[i]; |
|
1501 |
writer.writeStartElement("parameter"); |
|
1502 |
writer.writeAttribute("left", resolvedParameters[i]); |
|
1503 |
writer.writeAttribute("right", parameter.rightType()); |
|
1504 |
writer.writeAttribute("name", parameter.name()); |
|
1505 |
writer.writeAttribute("default", parameter.defaultValue()); |
|
1506 |
writer.writeEndElement(); // parameter |
|
1507 |
} |
|
1508 |
||
1509 |
} |
|
1510 |
else if (node->type() == Node::Enum) { |
|
1511 |
||
1512 |
const EnumNode *enumNode = static_cast<const EnumNode*>(node); |
|
1513 |
if (enumNode->flagsType()) { |
|
1514 |
writer.writeAttribute("typedef", |
|
1515 |
fullDocumentName(enumNode->flagsType())); |
|
1516 |
} |
|
1517 |
foreach (const EnumItem &item, enumNode->items()) { |
|
1518 |
writer.writeStartElement("value"); |
|
1519 |
writer.writeAttribute("name", item.name()); |
|
1520 |
writer.writeAttribute("value", item.value()); |
|
1521 |
writer.writeEndElement(); // value |
|
1522 |
} |
|
1523 |
||
1524 |
} |
|
1525 |
else if (node->type() == Node::Typedef) { |
|
1526 |
||
1527 |
const TypedefNode *typedefNode = static_cast<const TypedefNode*>(node); |
|
1528 |
if (typedefNode->associatedEnum()) { |
|
1529 |
writer.writeAttribute("enum", |
|
1530 |
fullDocumentName(typedefNode->associatedEnum())); |
|
1531 |
} |
|
1532 |
} |
|
1533 |
||
1534 |
return true; |
|
1535 |
} |
|
1536 |
||
1537 |
/*! |
|
1538 |
*/ |
|
1539 |
void Tree::generateIndexSections(QXmlStreamWriter &writer, |
|
1540 |
const Node *node, |
|
1541 |
bool generateInternalNodes) const |
|
1542 |
{ |
|
1543 |
if (generateIndexSection(writer, node, generateInternalNodes)) { |
|
1544 |
||
1545 |
if (node->isInnerNode()) { |
|
1546 |
const InnerNode *inner = static_cast<const InnerNode *>(node); |
|
1547 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1548 |
foreach (const Node *child, inner->childNodes()) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1549 |
/* |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1550 |
Don't generate anything for a QML property group node. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1551 |
It is just a place holder for a collection of QML property |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1552 |
nodes. Recurse to its children, which are the QML property |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1553 |
nodes. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1554 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1555 |
if (child->subType() == Node::QmlPropertyGroup) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1556 |
const InnerNode *pgn = static_cast<const InnerNode*>(child); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1557 |
foreach (const Node *c, pgn->childNodes()) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1558 |
generateIndexSections(writer, c, generateInternalNodes); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1559 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1560 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1561 |
else |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1562 |
generateIndexSections(writer, child, generateInternalNodes); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1563 |
} |
0 | 1564 |
|
1565 |
/* |
|
1566 |
foreach (const Node *child, inner->relatedNodes()) { |
|
1567 |
QDomElement childElement = generateIndexSections(document, child); |
|
1568 |
element.appendChild(childElement); |
|
1569 |
} |
|
1570 |
*/ |
|
1571 |
} |
|
1572 |
writer.writeEndElement(); |
|
1573 |
} |
|
1574 |
} |
|
1575 |
||
1576 |
/*! |
|
1577 |
Outputs an index file. |
|
1578 |
*/ |
|
1579 |
void Tree::generateIndex(const QString &fileName, |
|
1580 |
const QString &url, |
|
1581 |
const QString &title, |
|
1582 |
bool generateInternalNodes) const |
|
1583 |
{ |
|
1584 |
QFile file(fileName); |
|
1585 |
if (!file.open(QFile::WriteOnly | QFile::Text)) |
|
1586 |
return ; |
|
1587 |
||
1588 |
QXmlStreamWriter writer(&file); |
|
1589 |
writer.setAutoFormatting(true); |
|
1590 |
writer.writeStartDocument(); |
|
1591 |
writer.writeDTD("<!DOCTYPE QDOCINDEX>"); |
|
1592 |
||
1593 |
writer.writeStartElement("INDEX"); |
|
1594 |
writer.writeAttribute("url", url); |
|
1595 |
writer.writeAttribute("title", title); |
|
1596 |
writer.writeAttribute("version", version()); |
|
1597 |
||
1598 |
generateIndexSections(writer, root(), generateInternalNodes); |
|
1599 |
||
1600 |
writer.writeEndElement(); // INDEX |
|
1601 |
writer.writeEndElement(); // QDOCINDEX |
|
1602 |
writer.writeEndDocument(); |
|
1603 |
file.close(); |
|
1604 |
} |
|
1605 |
||
1606 |
/*! |
|
1607 |
Generate the tag file section with the given \a writer for the \a node |
|
1608 |
specified, returning true if an element was written; otherwise returns |
|
1609 |
false. |
|
1610 |
*/ |
|
1611 |
void Tree::generateTagFileCompounds(QXmlStreamWriter &writer, |
|
1612 |
const InnerNode *inner) const |
|
1613 |
{ |
|
1614 |
foreach (const Node *node, inner->childNodes()) { |
|
1615 |
||
1616 |
if (!node->url().isEmpty()) |
|
1617 |
continue; |
|
1618 |
||
1619 |
QString kind; |
|
1620 |
switch (node->type()) { |
|
1621 |
case Node::Namespace: |
|
1622 |
kind = "namespace"; |
|
1623 |
break; |
|
1624 |
case Node::Class: |
|
1625 |
kind = "class"; |
|
1626 |
break; |
|
1627 |
case Node::Enum: |
|
1628 |
case Node::Typedef: |
|
1629 |
case Node::Property: |
|
1630 |
case Node::Function: |
|
1631 |
case Node::Variable: |
|
1632 |
case Node::Target: |
|
1633 |
default: |
|
1634 |
continue; |
|
1635 |
} |
|
1636 |
||
1637 |
QString access; |
|
1638 |
switch (node->access()) { |
|
1639 |
case Node::Public: |
|
1640 |
access = "public"; |
|
1641 |
break; |
|
1642 |
case Node::Protected: |
|
1643 |
access = "protected"; |
|
1644 |
break; |
|
1645 |
case Node::Private: |
|
1646 |
default: |
|
1647 |
continue; |
|
1648 |
} |
|
1649 |
||
1650 |
QString objName = node->name(); |
|
1651 |
||
1652 |
// Special case: only the root node should have an empty name. |
|
1653 |
if (objName.isEmpty() && node != root()) |
|
1654 |
continue; |
|
1655 |
||
1656 |
// *** Write the starting tag for the element here. *** |
|
1657 |
writer.writeStartElement("compound"); |
|
1658 |
writer.writeAttribute("kind", kind); |
|
1659 |
||
1660 |
if (node->type() == Node::Class) { |
|
1661 |
writer.writeTextElement("name", fullDocumentName(node)); |
|
1662 |
writer.writeTextElement("filename", fullDocumentLocation(node)); |
|
1663 |
||
1664 |
// Classes contain information about their base classes. |
|
1665 |
const ClassNode *classNode = static_cast<const ClassNode*>(node); |
|
1666 |
QList<RelatedClass> bases = classNode->baseClasses(); |
|
1667 |
foreach (const RelatedClass &related, bases) { |
|
1668 |
ClassNode *baseClassNode = related.node; |
|
1669 |
writer.writeTextElement("base", baseClassNode->name()); |
|
1670 |
} |
|
1671 |
||
1672 |
// Recurse to write all members. |
|
1673 |
generateTagFileMembers(writer, static_cast<const InnerNode *>(node)); |
|
1674 |
writer.writeEndElement(); |
|
1675 |
||
1676 |
// Recurse to write all compounds. |
|
1677 |
generateTagFileCompounds(writer, static_cast<const InnerNode *>(node)); |
|
1678 |
} else { |
|
1679 |
writer.writeTextElement("name", fullDocumentName(node)); |
|
1680 |
writer.writeTextElement("filename", fullDocumentLocation(node)); |
|
1681 |
||
1682 |
// Recurse to write all members. |
|
1683 |
generateTagFileMembers(writer, static_cast<const InnerNode *>(node)); |
|
1684 |
writer.writeEndElement(); |
|
1685 |
||
1686 |
// Recurse to write all compounds. |
|
1687 |
generateTagFileCompounds(writer, static_cast<const InnerNode *>(node)); |
|
1688 |
} |
|
1689 |
} |
|
1690 |
} |
|
1691 |
||
1692 |
/*! |
|
1693 |
*/ |
|
1694 |
void Tree::generateTagFileMembers(QXmlStreamWriter &writer, |
|
1695 |
const InnerNode *inner) const |
|
1696 |
{ |
|
1697 |
foreach (const Node *node, inner->childNodes()) { |
|
1698 |
||
1699 |
if (!node->url().isEmpty()) |
|
1700 |
continue; |
|
1701 |
||
1702 |
QString nodeName; |
|
1703 |
QString kind; |
|
1704 |
switch (node->type()) { |
|
1705 |
case Node::Enum: |
|
1706 |
nodeName = "member"; |
|
1707 |
kind = "enum"; |
|
1708 |
break; |
|
1709 |
case Node::Typedef: |
|
1710 |
nodeName = "member"; |
|
1711 |
kind = "typedef"; |
|
1712 |
break; |
|
1713 |
case Node::Property: |
|
1714 |
nodeName = "member"; |
|
1715 |
kind = "property"; |
|
1716 |
break; |
|
1717 |
case Node::Function: |
|
1718 |
nodeName = "member"; |
|
1719 |
kind = "function"; |
|
1720 |
break; |
|
1721 |
case Node::Namespace: |
|
1722 |
nodeName = "namespace"; |
|
1723 |
break; |
|
1724 |
case Node::Class: |
|
1725 |
nodeName = "class"; |
|
1726 |
break; |
|
1727 |
case Node::Variable: |
|
1728 |
case Node::Target: |
|
1729 |
default: |
|
1730 |
continue; |
|
1731 |
} |
|
1732 |
||
1733 |
QString access; |
|
1734 |
switch (node->access()) { |
|
1735 |
case Node::Public: |
|
1736 |
access = "public"; |
|
1737 |
break; |
|
1738 |
case Node::Protected: |
|
1739 |
access = "protected"; |
|
1740 |
break; |
|
1741 |
case Node::Private: |
|
1742 |
default: |
|
1743 |
continue; |
|
1744 |
} |
|
1745 |
||
1746 |
QString objName = node->name(); |
|
1747 |
||
1748 |
// Special case: only the root node should have an empty name. |
|
1749 |
if (objName.isEmpty() && node != root()) |
|
1750 |
continue; |
|
1751 |
||
1752 |
// *** Write the starting tag for the element here. *** |
|
1753 |
writer.writeStartElement(nodeName); |
|
1754 |
if (!kind.isEmpty()) |
|
1755 |
writer.writeAttribute("kind", kind); |
|
1756 |
||
1757 |
switch (node->type()) { |
|
1758 |
||
1759 |
case Node::Class: |
|
1760 |
writer.writeCharacters(fullDocumentName(node)); |
|
1761 |
writer.writeEndElement(); |
|
1762 |
break; |
|
1763 |
case Node::Namespace: |
|
1764 |
writer.writeCharacters(fullDocumentName(node)); |
|
1765 |
writer.writeEndElement(); |
|
1766 |
break; |
|
1767 |
case Node::Function: |
|
1768 |
{ |
|
1769 |
/* |
|
1770 |
Function nodes contain information about |
|
1771 |
the type of function being described. |
|
1772 |
*/ |
|
1773 |
||
1774 |
const FunctionNode *functionNode = |
|
1775 |
static_cast<const FunctionNode*>(node); |
|
1776 |
writer.writeAttribute("protection", access); |
|
1777 |
||
1778 |
switch (functionNode->virtualness()) { |
|
1779 |
case FunctionNode::NonVirtual: |
|
1780 |
writer.writeAttribute("virtualness", "non"); |
|
1781 |
break; |
|
1782 |
case FunctionNode::ImpureVirtual: |
|
1783 |
writer.writeAttribute("virtualness", "virtual"); |
|
1784 |
break; |
|
1785 |
case FunctionNode::PureVirtual: |
|
1786 |
writer.writeAttribute("virtual", "pure"); |
|
1787 |
break; |
|
1788 |
default: |
|
1789 |
break; |
|
1790 |
} |
|
1791 |
writer.writeAttribute("static", |
|
1792 |
functionNode->isStatic() ? "yes" : "no"); |
|
1793 |
||
1794 |
if (functionNode->virtualness() == FunctionNode::NonVirtual) |
|
1795 |
writer.writeTextElement("type", functionNode->returnType()); |
|
1796 |
else |
|
1797 |
writer.writeTextElement("type", |
|
1798 |
"virtual " + functionNode->returnType()); |
|
1799 |
||
1800 |
writer.writeTextElement("name", objName); |
|
1801 |
QStringList pieces = fullDocumentLocation(node).split("#"); |
|
1802 |
writer.writeTextElement("anchorfile", pieces[0]); |
|
1803 |
writer.writeTextElement("anchor", pieces[1]); |
|
1804 |
||
1805 |
// Write a signature attribute for convenience. |
|
1806 |
QStringList signatureList; |
|
1807 |
||
1808 |
foreach (const Parameter ¶meter, functionNode->parameters()) { |
|
1809 |
QString leftType = parameter.leftType(); |
|
1810 |
const Node *leftNode = const_cast<Tree *>(this)->findNode(parameter.leftType().split("::"), |
|
1811 |
Node::Typedef, 0, SearchBaseClasses|NonFunction); |
|
1812 |
if (!leftNode) { |
|
1813 |
leftNode = const_cast<Tree *>(this)->findNode( |
|
1814 |
parameter.leftType().split("::"), Node::Typedef, |
|
1815 |
node->parent(), SearchBaseClasses|NonFunction); |
|
1816 |
} |
|
1817 |
if (leftNode) { |
|
1818 |
const TypedefNode *typedefNode = static_cast<const TypedefNode *>(leftNode); |
|
1819 |
if (typedefNode->associatedEnum()) { |
|
1820 |
leftType = "QFlags<"+fullDocumentName(typedefNode->associatedEnum())+">"; |
|
1821 |
} |
|
1822 |
} |
|
1823 |
signatureList.append(leftType + " " + parameter.name()); |
|
1824 |
} |
|
1825 |
||
1826 |
QString signature = "("+signatureList.join(", ")+")"; |
|
1827 |
if (functionNode->isConst()) |
|
1828 |
signature += " const"; |
|
1829 |
if (functionNode->virtualness() == FunctionNode::PureVirtual) |
|
1830 |
signature += " = 0"; |
|
1831 |
writer.writeTextElement("arglist", signature); |
|
1832 |
} |
|
1833 |
writer.writeEndElement(); // member |
|
1834 |
break; |
|
1835 |
||
1836 |
case Node::Property: |
|
1837 |
{ |
|
1838 |
const PropertyNode *propertyNode = static_cast<const PropertyNode*>(node); |
|
1839 |
writer.writeAttribute("type", propertyNode->dataType()); |
|
1840 |
writer.writeTextElement("name", objName); |
|
1841 |
QStringList pieces = fullDocumentLocation(node).split("#"); |
|
1842 |
writer.writeTextElement("anchorfile", pieces[0]); |
|
1843 |
writer.writeTextElement("anchor", pieces[1]); |
|
1844 |
writer.writeTextElement("arglist", ""); |
|
1845 |
} |
|
1846 |
writer.writeEndElement(); // member |
|
1847 |
break; |
|
1848 |
||
1849 |
case Node::Enum: |
|
1850 |
{ |
|
1851 |
const EnumNode *enumNode = static_cast<const EnumNode*>(node); |
|
1852 |
writer.writeTextElement("name", objName); |
|
1853 |
QStringList pieces = fullDocumentLocation(node).split("#"); |
|
1854 |
writer.writeTextElement("anchor", pieces[1]); |
|
1855 |
writer.writeTextElement("arglist", ""); |
|
1856 |
writer.writeEndElement(); // member |
|
1857 |
||
1858 |
for (int i = 0; i < enumNode->items().size(); ++i) { |
|
1859 |
EnumItem item = enumNode->items().value(i); |
|
1860 |
writer.writeStartElement("member"); |
|
1861 |
writer.writeAttribute("name", item.name()); |
|
1862 |
writer.writeTextElement("anchor", pieces[1]); |
|
1863 |
writer.writeTextElement("arglist", ""); |
|
1864 |
writer.writeEndElement(); // member |
|
1865 |
} |
|
1866 |
} |
|
1867 |
break; |
|
1868 |
||
1869 |
case Node::Typedef: |
|
1870 |
{ |
|
1871 |
const TypedefNode *typedefNode = static_cast<const TypedefNode*>(node); |
|
1872 |
if (typedefNode->associatedEnum()) |
|
1873 |
writer.writeAttribute("type", fullDocumentName(typedefNode->associatedEnum())); |
|
1874 |
else |
|
1875 |
writer.writeAttribute("type", ""); |
|
1876 |
writer.writeTextElement("name", objName); |
|
1877 |
QStringList pieces = fullDocumentLocation(node).split("#"); |
|
1878 |
writer.writeTextElement("anchorfile", pieces[0]); |
|
1879 |
writer.writeTextElement("anchor", pieces[1]); |
|
1880 |
writer.writeTextElement("arglist", ""); |
|
1881 |
} |
|
1882 |
writer.writeEndElement(); // member |
|
1883 |
break; |
|
1884 |
||
1885 |
case Node::Variable: |
|
1886 |
case Node::Target: |
|
1887 |
default: |
|
1888 |
break; |
|
1889 |
} |
|
1890 |
} |
|
1891 |
} |
|
1892 |
||
1893 |
/*! |
|
1894 |
*/ |
|
1895 |
void Tree::generateTagFile(const QString &fileName) const |
|
1896 |
{ |
|
1897 |
QFile file(fileName); |
|
1898 |
if (!file.open(QFile::WriteOnly | QFile::Text)) |
|
1899 |
return ; |
|
1900 |
||
1901 |
QXmlStreamWriter writer(&file); |
|
1902 |
writer.setAutoFormatting(true); |
|
1903 |
writer.writeStartDocument(); |
|
1904 |
||
1905 |
writer.writeStartElement("tagfile"); |
|
1906 |
||
1907 |
generateTagFileCompounds(writer, root()); |
|
1908 |
||
1909 |
writer.writeEndElement(); // tagfile |
|
1910 |
writer.writeEndDocument(); |
|
1911 |
file.close(); |
|
1912 |
} |
|
1913 |
||
1914 |
/*! |
|
1915 |
*/ |
|
1916 |
void Tree::addExternalLink(const QString &url, const Node *relative) |
|
1917 |
{ |
|
1918 |
FakeNode *fakeNode = new FakeNode(root(), url, Node::ExternalPage); |
|
1919 |
fakeNode->setAccess(Node::Public); |
|
1920 |
||
1921 |
// Create some content for the node. |
|
1922 |
QSet<QString> emptySet; |
|
1923 |
Location location(relative->doc().location()); |
|
1924 |
Doc doc(location, location, " ", emptySet); // placeholder |
|
1925 |
fakeNode->setDoc(doc); |
|
1926 |
} |
|
1927 |
||
1928 |
/*! |
|
1929 |
Returns the full document location for HTML-based documentation. |
|
1930 |
This should be moved into the HTML generator. |
|
1931 |
*/ |
|
1932 |
QString Tree::fullDocumentLocation(const Node *node) const |
|
1933 |
{ |
|
1934 |
if (!node) |
|
1935 |
return ""; |
|
1936 |
if (!node->url().isEmpty()) |
|
1937 |
return node->url(); |
|
1938 |
||
1939 |
QString parentName; |
|
1940 |
QString anchorRef; |
|
1941 |
||
1942 |
if (node->type() == Node::Namespace) { |
|
1943 |
||
1944 |
// The root namespace has no name - check for this before creating |
|
1945 |
// an attribute containing the location of any documentation. |
|
1946 |
||
1947 |
if (!node->fileBase().isEmpty()) |
|
1948 |
parentName = node->fileBase() + ".html"; |
|
1949 |
else |
|
1950 |
return ""; |
|
1951 |
} |
|
1952 |
else if (node->type() == Node::Fake) { |
|
1953 |
#ifdef QDOC_QML |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1954 |
if ((node->subType() == Node::QmlClass) || |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1955 |
(node->subType() == Node::QmlBasicType)) |
0 | 1956 |
return "qml-" + node->fileBase() + ".html"; |
1957 |
else |
|
1958 |
#endif |
|
1959 |
parentName = node->fileBase() + ".html"; |
|
1960 |
} |
|
1961 |
else if (node->fileBase().isEmpty()) |
|
1962 |
return ""; |
|
1963 |
||
1964 |
Node *parentNode = 0; |
|
1965 |
||
1966 |
if ((parentNode = node->relates())) |
|
1967 |
parentName = fullDocumentLocation(node->relates()); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1968 |
else if ((parentNode = node->parent())) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1969 |
if (parentNode->subType() == Node::QmlPropertyGroup) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1970 |
parentNode = parentNode->parent(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1971 |
parentName = "qml-" + parentNode->fileBase() + ".html"; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1972 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1973 |
else |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1974 |
parentName = fullDocumentLocation(node->parent()); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1975 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1976 |
#if 0 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1977 |
if (node->type() == Node::QmlProperty) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1978 |
qDebug() << "Node::QmlProperty:" << node->name() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1979 |
<< "parentName:" << parentName; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1980 |
if (parentNode) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1981 |
qDebug() << "PARENT NODE" << parentNode->type() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1982 |
<< parentNode->subType() << parentNode->name(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1983 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1984 |
#endif |
0 | 1985 |
switch (node->type()) { |
1986 |
case Node::Class: |
|
1987 |
case Node::Namespace: |
|
1988 |
if (parentNode && !parentNode->name().isEmpty()) |
|
1989 |
parentName = parentName.replace(".html", "") + "-" |
|
1990 |
+ node->fileBase().toLower() + ".html"; |
|
1991 |
else |
|
1992 |
parentName = node->fileBase() + ".html"; |
|
1993 |
break; |
|
1994 |
case Node::Function: |
|
1995 |
{ |
|
1996 |
/* |
|
1997 |
Functions can be destructors, overloaded, or |
|
1998 |
have associated properties. |
|
1999 |
*/ |
|
2000 |
const FunctionNode *functionNode = |
|
2001 |
static_cast<const FunctionNode *>(node); |
|
2002 |
||
2003 |
if (functionNode->metaness() == FunctionNode::Dtor) |
|
2004 |
anchorRef = "#dtor." + functionNode->name().mid(1); |
|
2005 |
||
2006 |
else if (functionNode->associatedProperty()) |
|
2007 |
return fullDocumentLocation(functionNode->associatedProperty()); |
|
2008 |
||
2009 |
else if (functionNode->overloadNumber() > 1) |
|
2010 |
anchorRef = "#" + functionNode->name() |
|
2011 |
+ "-" + QString::number(functionNode->overloadNumber()); |
|
2012 |
else |
|
2013 |
anchorRef = "#" + functionNode->name(); |
|
2014 |
} |
|
2015 |
||
2016 |
/* |
|
2017 |
Use node->name() instead of node->fileBase() as |
|
2018 |
the latter returns the name in lower-case. For |
|
2019 |
HTML anchors, we need to preserve the case. |
|
2020 |
*/ |
|
2021 |
break; |
|
2022 |
case Node::Enum: |
|
2023 |
anchorRef = "#" + node->name() + "-enum"; |
|
2024 |
break; |
|
2025 |
case Node::Typedef: |
|
2026 |
anchorRef = "#" + node->name() + "-typedef"; |
|
2027 |
break; |
|
2028 |
case Node::Property: |
|
2029 |
anchorRef = "#" + node->name() + "-prop"; |
|
2030 |
break; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2031 |
case Node::QmlProperty: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2032 |
anchorRef = "#" + node->name() + "-prop"; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2033 |
break; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2034 |
case Node::QmlSignal: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2035 |
anchorRef = "#" + node->name() + "-signal"; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2036 |
break; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2037 |
case Node::QmlMethod: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2038 |
anchorRef = "#" + node->name() + "-method"; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2039 |
break; |
0 | 2040 |
case Node::Variable: |
2041 |
anchorRef = "#" + node->name() + "-var"; |
|
2042 |
break; |
|
2043 |
case Node::Target: |
|
2044 |
anchorRef = "#" + Doc::canonicalTitle(node->name()); |
|
2045 |
break; |
|
2046 |
case Node::Fake: |
|
2047 |
{ |
|
2048 |
/* |
|
2049 |
Use node->fileBase() for fake nodes because they are represented |
|
2050 |
by pages whose file names are lower-case. |
|
2051 |
*/ |
|
2052 |
parentName = node->fileBase(); |
|
2053 |
parentName.replace("/", "-").replace(".", "-"); |
|
2054 |
parentName += ".html"; |
|
2055 |
} |
|
2056 |
break; |
|
2057 |
default: |
|
2058 |
break; |
|
2059 |
} |
|
2060 |
||
2061 |
// Various objects can be compat (deprecated) or obsolete. |
|
2062 |
if (node->type() != Node::Class && node->type() != Node::Namespace) { |
|
2063 |
switch (node->status()) { |
|
2064 |
case Node::Compat: |
|
2065 |
parentName.replace(".html", "-qt3.html"); |
|
2066 |
break; |
|
2067 |
case Node::Obsolete: |
|
2068 |
parentName.replace(".html", "-obsolete.html"); |
|
2069 |
break; |
|
2070 |
default: |
|
2071 |
; |
|
2072 |
} |
|
2073 |
} |
|
2074 |
||
2075 |
return parentName.toLower() + anchorRef; |
|
2076 |
} |
|
2077 |
||
2078 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2079 |
Construct the full document name for \a node and return the |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2080 |
name. |
0 | 2081 |
*/ |
2082 |
QString Tree::fullDocumentName(const Node *node) const |
|
2083 |
{ |
|
2084 |
if (!node) |
|
2085 |
return ""; |
|
2086 |
||
2087 |
QStringList pieces; |
|
2088 |
const Node *n = node; |
|
2089 |
||
2090 |
do { |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2091 |
if (!n->name().isEmpty() && |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2092 |
((n->type() != Node::Fake) || (n->subType() != Node::QmlPropertyGroup))) |
0 | 2093 |
pieces.insert(0, n->name()); |
2094 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2095 |
if ((n->type() == Node::Fake) && (n->subType() != Node::QmlPropertyGroup)) |
0 | 2096 |
break; |
2097 |
||
2098 |
// Examine the parent node if one exists. |
|
2099 |
if (n->parent()) |
|
2100 |
n = n->parent(); |
|
2101 |
else |
|
2102 |
break; |
|
2103 |
} while (true); |
|
2104 |
||
2105 |
// Create a name based on the type of the ancestor node. |
|
2106 |
if (n->type() == Node::Fake) |
|
2107 |
return pieces.join("#"); |
|
2108 |
else |
|
2109 |
return pieces.join("::"); |
|
2110 |
} |
|
2111 |
||
2112 |
QT_END_NAMESPACE |