| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the tools applications of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | /*
|
|---|
| 43 | node.cpp
|
|---|
| 44 | */
|
|---|
| 45 |
|
|---|
| 46 | #include "node.h"
|
|---|
| 47 |
|
|---|
| 48 | QT_BEGIN_NAMESPACE
|
|---|
| 49 |
|
|---|
| 50 | /*!
|
|---|
| 51 | \class Node
|
|---|
| 52 | \brief A node in a Tree.
|
|---|
| 53 | */
|
|---|
| 54 |
|
|---|
| 55 | /*!
|
|---|
| 56 | */
|
|---|
| 57 | Node::~Node()
|
|---|
| 58 | {
|
|---|
| 59 | if (par)
|
|---|
| 60 | par->removeChild(this);
|
|---|
| 61 | if (rel)
|
|---|
| 62 | rel->removeRelated(this);
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | /*!
|
|---|
| 66 | */
|
|---|
| 67 | void Node::setDoc(const Doc& doc, bool replace)
|
|---|
| 68 | {
|
|---|
| 69 | if (!d.isEmpty() && !replace) {
|
|---|
| 70 | doc.location().warning(tr("Overrides a previous doc"));
|
|---|
| 71 | d.location().warning(tr("(The previous doc is here)"));
|
|---|
| 72 | }
|
|---|
| 73 | d = doc;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | /*!
|
|---|
| 77 | */
|
|---|
| 78 | Node::Node(Type type, InnerNode *parent, const QString& name)
|
|---|
| 79 | : typ(type),
|
|---|
| 80 | acc(Public),
|
|---|
| 81 | sta(Commendable),
|
|---|
| 82 | saf(UnspecifiedSafeness),
|
|---|
| 83 | par(parent),
|
|---|
| 84 | rel(0),
|
|---|
| 85 | nam(name)
|
|---|
| 86 | {
|
|---|
| 87 | if (par)
|
|---|
| 88 | par->addChild(this);
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | /*!
|
|---|
| 92 | */
|
|---|
| 93 | QString Node::url() const
|
|---|
| 94 | {
|
|---|
| 95 | return u;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | /*!
|
|---|
| 99 | */
|
|---|
| 100 | void Node::setUrl(const QString &url)
|
|---|
| 101 | {
|
|---|
| 102 | u = url;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | /*!
|
|---|
| 106 | */
|
|---|
| 107 | void Node::setRelates(InnerNode *pseudoParent)
|
|---|
| 108 | {
|
|---|
| 109 | if (rel)
|
|---|
| 110 | rel->removeRelated(this);
|
|---|
| 111 | rel = pseudoParent;
|
|---|
| 112 | pseudoParent->related.append(this);
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | /*!
|
|---|
| 116 | */
|
|---|
| 117 | void Node::setLink(LinkType linkType, const QString &link, const QString &desc)
|
|---|
| 118 | {
|
|---|
| 119 | QPair<QString,QString> linkPair;
|
|---|
| 120 | linkPair.first = link;
|
|---|
| 121 | linkPair.second = desc;
|
|---|
| 122 | linkMap[linkType] = linkPair;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | /*!
|
|---|
| 126 | */
|
|---|
| 127 | Node::Status Node::inheritedStatus() const
|
|---|
| 128 | {
|
|---|
| 129 | Status parentStatus = Commendable;
|
|---|
| 130 | if (par)
|
|---|
| 131 | parentStatus = par->inheritedStatus();
|
|---|
| 132 | return (Status)qMin((int)sta, (int)parentStatus);
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | /*!
|
|---|
| 136 | */
|
|---|
| 137 | Node::ThreadSafeness Node::threadSafeness() const
|
|---|
| 138 | {
|
|---|
| 139 | if (par && saf == par->inheritedThreadSafeness())
|
|---|
| 140 | return UnspecifiedSafeness;
|
|---|
| 141 | return saf;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | /*!
|
|---|
| 145 | */
|
|---|
| 146 | Node::ThreadSafeness Node::inheritedThreadSafeness() const
|
|---|
| 147 | {
|
|---|
| 148 | if (par && saf == UnspecifiedSafeness)
|
|---|
| 149 | return par->inheritedThreadSafeness();
|
|---|
| 150 | return saf;
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | /*!
|
|---|
| 154 | */
|
|---|
| 155 | QString Node::fileBase() const
|
|---|
| 156 | {
|
|---|
| 157 | QString base = name();
|
|---|
| 158 | if (base.endsWith(".html"))
|
|---|
| 159 | base.chop(5);
|
|---|
| 160 | base.replace(QRegExp("[^A-Za-z0-9]+"), " ");
|
|---|
| 161 | base = base.trimmed();
|
|---|
| 162 | base.replace(" ", "-");
|
|---|
| 163 | return base.toLower();
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | /*!
|
|---|
| 167 | \class InnerNode
|
|---|
| 168 | */
|
|---|
| 169 |
|
|---|
| 170 | /*!
|
|---|
| 171 | */
|
|---|
| 172 | InnerNode::~InnerNode()
|
|---|
| 173 | {
|
|---|
| 174 | deleteChildren();
|
|---|
| 175 | removeFromRelated();
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | /*!
|
|---|
| 179 | */
|
|---|
| 180 | Node *InnerNode::findNode(const QString& name)
|
|---|
| 181 | {
|
|---|
| 182 | Node *node = childMap.value(name);
|
|---|
| 183 | if (node)
|
|---|
| 184 | return node;
|
|---|
| 185 | return primaryFunctionMap.value(name);
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | /*!
|
|---|
| 189 | */
|
|---|
| 190 | Node *InnerNode::findNode(const QString& name, Type type)
|
|---|
| 191 | {
|
|---|
| 192 | if (type == Function) {
|
|---|
| 193 | return primaryFunctionMap.value(name);
|
|---|
| 194 | }
|
|---|
| 195 | else {
|
|---|
| 196 | Node *node = childMap.value(name);
|
|---|
| 197 | if (node && node->type() == type) {
|
|---|
| 198 | return node;
|
|---|
| 199 | }
|
|---|
| 200 | else {
|
|---|
| 201 | return 0;
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | /*!
|
|---|
| 207 | */
|
|---|
| 208 | FunctionNode *InnerNode::findFunctionNode(const QString& name)
|
|---|
| 209 | {
|
|---|
| 210 | return static_cast<FunctionNode *>(primaryFunctionMap.value(name));
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | /*!
|
|---|
| 214 | */
|
|---|
| 215 | FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone)
|
|---|
| 216 | {
|
|---|
| 217 | QMap<QString, Node *>::ConstIterator c =
|
|---|
| 218 | primaryFunctionMap.find(clone->name());
|
|---|
| 219 | if (c != primaryFunctionMap.end()) {
|
|---|
| 220 | if (isSameSignature(clone, (FunctionNode *) *c)) {
|
|---|
| 221 | return (FunctionNode *) *c;
|
|---|
| 222 | }
|
|---|
| 223 | else if (secondaryFunctionMap.contains(clone->name())) {
|
|---|
| 224 | const NodeList& secs = secondaryFunctionMap[clone->name()];
|
|---|
| 225 | NodeList::ConstIterator s = secs.begin();
|
|---|
| 226 | while (s != secs.end()) {
|
|---|
| 227 | if (isSameSignature(clone, (FunctionNode *) *s))
|
|---|
| 228 | return (FunctionNode *) *s;
|
|---|
| 229 | ++s;
|
|---|
| 230 | }
|
|---|
| 231 | }
|
|---|
| 232 | }
|
|---|
| 233 | return 0;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | /*!
|
|---|
| 237 | */
|
|---|
| 238 | void InnerNode::setOverload(const FunctionNode *func, bool overlode)
|
|---|
| 239 | {
|
|---|
| 240 | Node *node = (Node *) func;
|
|---|
| 241 | Node *&primary = primaryFunctionMap[func->name()];
|
|---|
| 242 |
|
|---|
| 243 | if (secondaryFunctionMap.contains(func->name())) {
|
|---|
| 244 | NodeList& secs = secondaryFunctionMap[func->name()];
|
|---|
| 245 | if (overlode) {
|
|---|
| 246 | if (primary == node) {
|
|---|
| 247 | primary = secs.first();
|
|---|
| 248 | secs.erase(secs.begin());
|
|---|
| 249 | secs.append(node);
|
|---|
| 250 | }
|
|---|
| 251 | else {
|
|---|
| 252 | secs.removeAll(node);
|
|---|
| 253 | secs.append(node);
|
|---|
| 254 | }
|
|---|
| 255 | }
|
|---|
| 256 | else {
|
|---|
| 257 | if (primary != node) {
|
|---|
| 258 | secs.removeAll(node);
|
|---|
| 259 | secs.prepend(primary);
|
|---|
| 260 | primary = node;
|
|---|
| 261 | }
|
|---|
| 262 | }
|
|---|
| 263 | }
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | /*!
|
|---|
| 267 | */
|
|---|
| 268 | void InnerNode::makeUndocumentedChildrenInternal()
|
|---|
| 269 | {
|
|---|
| 270 | foreach (Node *child, childNodes()) {
|
|---|
| 271 | if (child->doc().isEmpty()) {
|
|---|
| 272 | child->setAccess(Node::Private);
|
|---|
| 273 | child->setStatus(Node::Internal);
|
|---|
| 274 | }
|
|---|
| 275 | }
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | /*!
|
|---|
| 279 | */
|
|---|
| 280 | void InnerNode::normalizeOverloads()
|
|---|
| 281 | {
|
|---|
| 282 | QMap<QString, Node *>::Iterator p1 = primaryFunctionMap.begin();
|
|---|
| 283 | while (p1 != primaryFunctionMap.end()) {
|
|---|
| 284 | FunctionNode *primaryFunc = (FunctionNode *) *p1;
|
|---|
| 285 | if (secondaryFunctionMap.contains(primaryFunc->name()) &&
|
|---|
| 286 | (primaryFunc->status() != Commendable ||
|
|---|
| 287 | primaryFunc->access() == Private)) {
|
|---|
| 288 |
|
|---|
| 289 | NodeList& secs = secondaryFunctionMap[primaryFunc->name()];
|
|---|
| 290 | NodeList::ConstIterator s = secs.begin();
|
|---|
| 291 | while (s != secs.end()) {
|
|---|
| 292 | FunctionNode *secondaryFunc = (FunctionNode *) *s;
|
|---|
| 293 |
|
|---|
| 294 | // Any non-obsolete, non-compatibility, non-private functions
|
|---|
| 295 | // (i.e, visible functions) are preferable to the primary
|
|---|
| 296 | // function.
|
|---|
| 297 |
|
|---|
| 298 | if (secondaryFunc->status() == Commendable &&
|
|---|
| 299 | secondaryFunc->access() != Private) {
|
|---|
| 300 |
|
|---|
| 301 | *p1 = secondaryFunc;
|
|---|
| 302 | int index = secondaryFunctionMap[primaryFunc->name()].indexOf(secondaryFunc);
|
|---|
| 303 | secondaryFunctionMap[primaryFunc->name()].replace(index, primaryFunc);
|
|---|
| 304 | break;
|
|---|
| 305 | }
|
|---|
| 306 | ++s;
|
|---|
| 307 | }
|
|---|
| 308 | }
|
|---|
| 309 | ++p1;
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | QMap<QString, Node *>::ConstIterator p = primaryFunctionMap.begin();
|
|---|
| 313 | while (p != primaryFunctionMap.end()) {
|
|---|
| 314 | FunctionNode *primaryFunc = (FunctionNode *) *p;
|
|---|
| 315 | if (primaryFunc->isOverload())
|
|---|
| 316 | primaryFunc->ove = false;
|
|---|
| 317 | if (secondaryFunctionMap.contains(primaryFunc->name())) {
|
|---|
| 318 | NodeList& secs = secondaryFunctionMap[primaryFunc->name()];
|
|---|
| 319 | NodeList::ConstIterator s = secs.begin();
|
|---|
| 320 | while (s != secs.end()) {
|
|---|
| 321 | FunctionNode *secondaryFunc = (FunctionNode *) *s;
|
|---|
| 322 | if (!secondaryFunc->isOverload())
|
|---|
| 323 | secondaryFunc->ove = true;
|
|---|
| 324 | ++s;
|
|---|
| 325 | }
|
|---|
| 326 | }
|
|---|
| 327 | ++p;
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | NodeList::ConstIterator c = childNodes().begin();
|
|---|
| 331 | while (c != childNodes().end()) {
|
|---|
| 332 | if ((*c)->isInnerNode())
|
|---|
| 333 | ((InnerNode *) *c)->normalizeOverloads();
|
|---|
| 334 | ++c;
|
|---|
| 335 | }
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | /*!
|
|---|
| 339 | */
|
|---|
| 340 | void InnerNode::removeFromRelated()
|
|---|
| 341 | {
|
|---|
| 342 | while (!related.isEmpty()) {
|
|---|
| 343 | Node *p = static_cast<Node *>(related.takeFirst());
|
|---|
| 344 |
|
|---|
| 345 | if (p != 0 && p->relates() == this) p->clearRelated();
|
|---|
| 346 | }
|
|---|
| 347 | }
|
|---|
| 348 |
|
|---|
| 349 | /*!
|
|---|
| 350 | */
|
|---|
| 351 | void InnerNode::deleteChildren()
|
|---|
| 352 | {
|
|---|
| 353 | qDeleteAll(children);
|
|---|
| 354 | }
|
|---|
| 355 |
|
|---|
| 356 | /*!
|
|---|
| 357 | Returns true.
|
|---|
| 358 | */
|
|---|
| 359 | bool InnerNode::isInnerNode() const
|
|---|
| 360 | {
|
|---|
| 361 | return true;
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | /*!
|
|---|
| 365 | */
|
|---|
| 366 | const Node *InnerNode::findNode(const QString& name) const
|
|---|
| 367 | {
|
|---|
| 368 | InnerNode *that = (InnerNode *) this;
|
|---|
| 369 | return that->findNode(name);
|
|---|
| 370 | }
|
|---|
| 371 |
|
|---|
| 372 | /*!
|
|---|
| 373 | */
|
|---|
| 374 | const Node *InnerNode::findNode(const QString& name, Type type) const
|
|---|
| 375 | {
|
|---|
| 376 | InnerNode *that = (InnerNode *) this;
|
|---|
| 377 | return that->findNode(name, type);
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | /*!
|
|---|
| 381 | */
|
|---|
| 382 | const FunctionNode *InnerNode::findFunctionNode(const QString& name) const
|
|---|
| 383 | {
|
|---|
| 384 | InnerNode *that = (InnerNode *) this;
|
|---|
| 385 | return that->findFunctionNode(name);
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | /*!
|
|---|
| 389 | */
|
|---|
| 390 | const FunctionNode *InnerNode::findFunctionNode(
|
|---|
| 391 | const FunctionNode *clone) const
|
|---|
| 392 | {
|
|---|
| 393 | InnerNode *that = (InnerNode *) this;
|
|---|
| 394 | return that->findFunctionNode(clone);
|
|---|
| 395 | }
|
|---|
| 396 |
|
|---|
| 397 | /*!
|
|---|
| 398 | */
|
|---|
| 399 | const EnumNode *InnerNode::findEnumNodeForValue(const QString &enumValue) const
|
|---|
| 400 | {
|
|---|
| 401 | foreach (const Node *node, enumChildren) {
|
|---|
| 402 | const EnumNode *enume = static_cast<const EnumNode *>(node);
|
|---|
| 403 | if (enume->hasItem(enumValue))
|
|---|
| 404 | return enume;
|
|---|
| 405 | }
|
|---|
| 406 | return 0;
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | /*!
|
|---|
| 410 | */
|
|---|
| 411 | int InnerNode::overloadNumber(const FunctionNode *func) const
|
|---|
| 412 | {
|
|---|
| 413 | Node *node = (Node *) func;
|
|---|
| 414 | if (primaryFunctionMap[func->name()] == node) {
|
|---|
| 415 | return 1;
|
|---|
| 416 | }
|
|---|
| 417 | else {
|
|---|
| 418 | return secondaryFunctionMap[func->name()].indexOf(node) + 2;
|
|---|
| 419 | }
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | /*!
|
|---|
| 423 | */
|
|---|
| 424 | int InnerNode::numOverloads(const QString& funcName) const
|
|---|
| 425 | {
|
|---|
| 426 | if (primaryFunctionMap.contains(funcName)) {
|
|---|
| 427 | return secondaryFunctionMap[funcName].count() + 1;
|
|---|
| 428 | }
|
|---|
| 429 | else {
|
|---|
| 430 | return 0;
|
|---|
| 431 | }
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 | /*!
|
|---|
| 435 | */
|
|---|
| 436 | NodeList InnerNode::overloads(const QString &funcName) const
|
|---|
| 437 | {
|
|---|
| 438 | NodeList result;
|
|---|
| 439 | Node *primary = primaryFunctionMap.value(funcName);
|
|---|
| 440 | if (primary) {
|
|---|
| 441 | result << primary;
|
|---|
| 442 | result += secondaryFunctionMap[funcName];
|
|---|
| 443 | }
|
|---|
| 444 | return result;
|
|---|
| 445 | }
|
|---|
| 446 |
|
|---|
| 447 | /*!
|
|---|
| 448 | */
|
|---|
| 449 | InnerNode::InnerNode(Type type, InnerNode *parent, const QString& name)
|
|---|
| 450 | : Node(type, parent, name)
|
|---|
| 451 | {
|
|---|
| 452 | }
|
|---|
| 453 |
|
|---|
| 454 | /*!
|
|---|
| 455 | */
|
|---|
| 456 | void InnerNode::addInclude(const QString& include)
|
|---|
| 457 | {
|
|---|
| 458 | inc.append(include);
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | /*!
|
|---|
| 462 | */
|
|---|
| 463 | void InnerNode::setIncludes(const QStringList& includes)
|
|---|
| 464 | {
|
|---|
| 465 | inc = includes;
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | /*!
|
|---|
| 469 | f1 is always the clone
|
|---|
| 470 | */
|
|---|
| 471 | bool InnerNode::isSameSignature(const FunctionNode *f1, const FunctionNode *f2)
|
|---|
| 472 | {
|
|---|
| 473 | if (f1->parameters().count() != f2->parameters().count())
|
|---|
| 474 | return false;
|
|---|
| 475 | if (f1->isConst() != f2->isConst())
|
|---|
| 476 | return false;
|
|---|
| 477 |
|
|---|
| 478 | QList<Parameter>::ConstIterator p1 = f1->parameters().begin();
|
|---|
| 479 | QList<Parameter>::ConstIterator p2 = f2->parameters().begin();
|
|---|
| 480 | while (p2 != f2->parameters().end()) {
|
|---|
| 481 | if ((*p1).hasType() && (*p2).hasType()) {
|
|---|
| 482 | if ((*p1).rightType() != (*p2).rightType())
|
|---|
| 483 | return false;
|
|---|
| 484 |
|
|---|
| 485 | QString t1 = p1->leftType();
|
|---|
| 486 | QString t2 = p2->leftType();
|
|---|
| 487 |
|
|---|
| 488 | if (t1.length() < t2.length())
|
|---|
| 489 | qSwap(t1, t2);
|
|---|
| 490 |
|
|---|
| 491 | /*
|
|---|
| 492 | ### hack for C++ to handle superfluous
|
|---|
| 493 | "Foo::" prefixes gracefully
|
|---|
| 494 | */
|
|---|
| 495 | if (t1 != t2 && t1 != (f2->parent()->name() + "::" + t2))
|
|---|
| 496 | return false;
|
|---|
| 497 | }
|
|---|
| 498 | ++p1;
|
|---|
| 499 | ++p2;
|
|---|
| 500 | }
|
|---|
| 501 | return true;
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | /*!
|
|---|
| 505 | */
|
|---|
| 506 | void InnerNode::addChild(Node *child)
|
|---|
| 507 | {
|
|---|
| 508 | children.append(child);
|
|---|
| 509 | if (child->type() == Function) {
|
|---|
| 510 | FunctionNode *func = (FunctionNode *) child;
|
|---|
| 511 | if (!primaryFunctionMap.contains(func->name())) {
|
|---|
| 512 | primaryFunctionMap.insert(func->name(), func);
|
|---|
| 513 | }
|
|---|
| 514 | else {
|
|---|
| 515 | NodeList &secs = secondaryFunctionMap[func->name()];
|
|---|
| 516 | secs.append(func);
|
|---|
| 517 | }
|
|---|
| 518 | }
|
|---|
| 519 | else {
|
|---|
| 520 | if (child->type() == Enum)
|
|---|
| 521 | enumChildren.append(child);
|
|---|
| 522 | childMap.insert(child->name(), child);
|
|---|
| 523 | }
|
|---|
| 524 | }
|
|---|
| 525 |
|
|---|
| 526 | /*!
|
|---|
| 527 | */
|
|---|
| 528 | void InnerNode::removeChild(Node *child)
|
|---|
| 529 | {
|
|---|
| 530 | children.removeAll(child);
|
|---|
| 531 | enumChildren.removeAll(child);
|
|---|
| 532 | if (child->type() == Function) {
|
|---|
| 533 | QMap<QString, Node *>::Iterator prim =
|
|---|
| 534 | primaryFunctionMap.find(child->name());
|
|---|
| 535 | NodeList& secs = secondaryFunctionMap[child->name()];
|
|---|
| 536 | if (*prim == child) {
|
|---|
| 537 | if (secs.isEmpty()) {
|
|---|
| 538 | primaryFunctionMap.remove(child->name());
|
|---|
| 539 | }
|
|---|
| 540 | else {
|
|---|
| 541 | primaryFunctionMap.insert(child->name(), secs.takeFirst());
|
|---|
| 542 | }
|
|---|
| 543 | }
|
|---|
| 544 | else {
|
|---|
| 545 | secs.removeAll(child);
|
|---|
| 546 | }
|
|---|
| 547 | QMap<QString, Node *>::Iterator ent = childMap.find( child->name() );
|
|---|
| 548 | if ( *ent == child )
|
|---|
| 549 | childMap.erase( ent );
|
|---|
| 550 | }
|
|---|
| 551 | else {
|
|---|
| 552 | QMap<QString, Node *>::Iterator ent = childMap.find(child->name());
|
|---|
| 553 | if (*ent == child)
|
|---|
| 554 | childMap.erase(ent);
|
|---|
| 555 | }
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | /*!
|
|---|
| 559 | Find the module (QtCore, QtGui, etc.) to which the class belongs.
|
|---|
| 560 | We do this by obtaining the full path to the header file's location
|
|---|
| 561 | and examine everything between "src/" and the filename. This is
|
|---|
| 562 | semi-dirty because we are assuming a particular directory structure.
|
|---|
| 563 |
|
|---|
| 564 | This function is only really useful if the class's module has not
|
|---|
| 565 | been defined in the header file with a QT_MODULE macro or with an
|
|---|
| 566 | \inmodule command in the documentation.
|
|---|
| 567 | */
|
|---|
| 568 | QString Node::moduleName() const
|
|---|
| 569 | {
|
|---|
| 570 | if (!mod.isEmpty())
|
|---|
| 571 | return mod;
|
|---|
| 572 |
|
|---|
| 573 | QString path = location().filePath();
|
|---|
| 574 | QString pattern = QString("src") + QDir::separator();
|
|---|
| 575 | int start = path.lastIndexOf(pattern);
|
|---|
| 576 |
|
|---|
| 577 | if (start == -1)
|
|---|
| 578 | return "";
|
|---|
| 579 |
|
|---|
| 580 | QString moduleDir = path.mid(start + pattern.size());
|
|---|
| 581 | int finish = moduleDir.indexOf(QDir::separator());
|
|---|
| 582 |
|
|---|
| 583 | if (finish == -1)
|
|---|
| 584 | return "";
|
|---|
| 585 |
|
|---|
| 586 | QString moduleName = moduleDir.left(finish);
|
|---|
| 587 |
|
|---|
| 588 | if (moduleName == "corelib")
|
|---|
| 589 | return "QtCore";
|
|---|
| 590 | else if (moduleName == "uitools")
|
|---|
| 591 | return "QtUiTools";
|
|---|
| 592 | else if (moduleName == "gui")
|
|---|
| 593 | return "QtGui";
|
|---|
| 594 | else if (moduleName == "network")
|
|---|
| 595 | return "QtNetwork";
|
|---|
| 596 | else if (moduleName == "opengl")
|
|---|
| 597 | return "QtOpenGL";
|
|---|
| 598 | else if (moduleName == "qt3support")
|
|---|
| 599 | return "Qt3Support";
|
|---|
| 600 | else if (moduleName == "svg")
|
|---|
| 601 | return "QtSvg";
|
|---|
| 602 | else if (moduleName == "sql")
|
|---|
| 603 | return "QtSql";
|
|---|
| 604 | else if (moduleName == "qtestlib")
|
|---|
| 605 | return "QtTest";
|
|---|
| 606 | else if (moduleDir.contains("webkit"))
|
|---|
| 607 | return "QtWebKit";
|
|---|
| 608 | else if (moduleName == "xml")
|
|---|
| 609 | return "QtXml";
|
|---|
| 610 | else
|
|---|
| 611 | return "";
|
|---|
| 612 | }
|
|---|
| 613 |
|
|---|
| 614 | /*!
|
|---|
| 615 | */
|
|---|
| 616 | void InnerNode::removeRelated(Node *pseudoChild)
|
|---|
| 617 | {
|
|---|
| 618 | related.removeAll(pseudoChild);
|
|---|
| 619 | }
|
|---|
| 620 |
|
|---|
| 621 | /*!
|
|---|
| 622 | \class LeafNode
|
|---|
| 623 | */
|
|---|
| 624 |
|
|---|
| 625 | /*!
|
|---|
| 626 | Returns false because this is an InnerNode.
|
|---|
| 627 | */
|
|---|
| 628 | bool LeafNode::isInnerNode() const
|
|---|
| 629 | {
|
|---|
| 630 | return false;
|
|---|
| 631 | }
|
|---|
| 632 |
|
|---|
| 633 | /*!
|
|---|
| 634 | */
|
|---|
| 635 | LeafNode::LeafNode(Type type, InnerNode *parent, const QString& name)
|
|---|
| 636 | : Node(type, parent, name)
|
|---|
| 637 | {
|
|---|
| 638 | }
|
|---|
| 639 |
|
|---|
| 640 | /*!
|
|---|
| 641 | \class NamespaceNode
|
|---|
| 642 | */
|
|---|
| 643 |
|
|---|
| 644 | /*!
|
|---|
| 645 | */
|
|---|
| 646 | NamespaceNode::NamespaceNode(InnerNode *parent, const QString& name)
|
|---|
| 647 | : InnerNode(Namespace, parent, name)
|
|---|
| 648 | {
|
|---|
| 649 | }
|
|---|
| 650 |
|
|---|
| 651 | /*!
|
|---|
| 652 | \class ClassNode
|
|---|
| 653 | */
|
|---|
| 654 |
|
|---|
| 655 | /*!
|
|---|
| 656 | */
|
|---|
| 657 | ClassNode::ClassNode(InnerNode *parent, const QString& name)
|
|---|
| 658 | : InnerNode(Class, parent, name)
|
|---|
| 659 | {
|
|---|
| 660 | hidden = false;
|
|---|
| 661 | }
|
|---|
| 662 |
|
|---|
| 663 | /*!
|
|---|
| 664 | */
|
|---|
| 665 | void ClassNode::addBaseClass(Access access,
|
|---|
| 666 | ClassNode *node,
|
|---|
| 667 | const QString &dataTypeWithTemplateArgs)
|
|---|
| 668 | {
|
|---|
| 669 | bas.append(RelatedClass(access, node, dataTypeWithTemplateArgs));
|
|---|
| 670 | node->der.append(RelatedClass(access, this));
|
|---|
| 671 | }
|
|---|
| 672 |
|
|---|
| 673 | /*!
|
|---|
| 674 | */
|
|---|
| 675 | void ClassNode::fixBaseClasses()
|
|---|
| 676 | {
|
|---|
| 677 | int i;
|
|---|
| 678 |
|
|---|
| 679 | i = 0;
|
|---|
| 680 | while (i < bas.size()) {
|
|---|
| 681 | ClassNode *baseClass = bas.at(i).node;
|
|---|
| 682 | if (baseClass->access() == Node::Private) {
|
|---|
| 683 | bas.removeAt(i);
|
|---|
| 684 |
|
|---|
| 685 | const QList<RelatedClass> &basesBases = baseClass->baseClasses();
|
|---|
| 686 | for (int j = basesBases.size() - 1; j >= 0; --j)
|
|---|
| 687 | bas.insert(i, basesBases.at(j));
|
|---|
| 688 | }
|
|---|
| 689 | else {
|
|---|
| 690 | ++i;
|
|---|
| 691 | }
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | i = 0;
|
|---|
| 695 | while (i < der.size()) {
|
|---|
| 696 | ClassNode *derivedClass = der.at(i).node;
|
|---|
| 697 | if (derivedClass->access() == Node::Private) {
|
|---|
| 698 | der.removeAt(i);
|
|---|
| 699 |
|
|---|
| 700 | const QList<RelatedClass> &dersDers =
|
|---|
| 701 | derivedClass->derivedClasses();
|
|---|
| 702 | for (int j = dersDers.size() - 1; j >= 0; --j)
|
|---|
| 703 | der.insert(i, dersDers.at(j));
|
|---|
| 704 | }
|
|---|
| 705 | else {
|
|---|
| 706 | ++i;
|
|---|
| 707 | }
|
|---|
| 708 | }
|
|---|
| 709 | }
|
|---|
| 710 |
|
|---|
| 711 | /*!
|
|---|
| 712 | \class FakeNode
|
|---|
| 713 | */
|
|---|
| 714 |
|
|---|
| 715 | /*!
|
|---|
| 716 | */
|
|---|
| 717 | FakeNode::FakeNode(InnerNode *parent, const QString& name, SubType subType)
|
|---|
| 718 | : InnerNode(Fake, parent, name), sub(subType)
|
|---|
| 719 | {
|
|---|
| 720 | }
|
|---|
| 721 |
|
|---|
| 722 | /*!
|
|---|
| 723 | */
|
|---|
| 724 | QString FakeNode::fullTitle() const
|
|---|
| 725 | {
|
|---|
| 726 | if (sub == File) {
|
|---|
| 727 | if (title().isEmpty())
|
|---|
| 728 | return name().mid(name().lastIndexOf('/') + 1) + " Example File";
|
|---|
| 729 | else
|
|---|
| 730 | return title();
|
|---|
| 731 | }
|
|---|
| 732 | else if (sub == HeaderFile) {
|
|---|
| 733 | if (title().isEmpty())
|
|---|
| 734 | return name();
|
|---|
| 735 | else
|
|---|
| 736 | return name() + " - " + title();
|
|---|
| 737 | }
|
|---|
| 738 | else {
|
|---|
| 739 | return title();
|
|---|
| 740 | }
|
|---|
| 741 | }
|
|---|
| 742 |
|
|---|
| 743 | /*!
|
|---|
| 744 | */
|
|---|
| 745 | QString FakeNode::subTitle() const
|
|---|
| 746 | {
|
|---|
| 747 | if (!stle.isEmpty())
|
|---|
| 748 | return stle;
|
|---|
| 749 |
|
|---|
| 750 | if (sub == File) {
|
|---|
| 751 | if (title().isEmpty() && name().contains("/"))
|
|---|
| 752 | return name();
|
|---|
| 753 | }
|
|---|
| 754 | return QString();
|
|---|
| 755 | }
|
|---|
| 756 |
|
|---|
| 757 | /*!
|
|---|
| 758 | \class EnumNode
|
|---|
| 759 | */
|
|---|
| 760 |
|
|---|
| 761 | /*!
|
|---|
| 762 | */
|
|---|
| 763 | EnumNode::EnumNode(InnerNode *parent, const QString& name)
|
|---|
| 764 | : LeafNode(Enum, parent, name), ft(0)
|
|---|
| 765 | {
|
|---|
| 766 | }
|
|---|
| 767 |
|
|---|
| 768 | /*!
|
|---|
| 769 | */
|
|---|
| 770 | void EnumNode::addItem(const EnumItem& item)
|
|---|
| 771 | {
|
|---|
| 772 | itms.append(item);
|
|---|
| 773 | names.insert(item.name());
|
|---|
| 774 | }
|
|---|
| 775 |
|
|---|
| 776 | /*!
|
|---|
| 777 | */
|
|---|
| 778 | Node::Access EnumNode::itemAccess(const QString &name) const
|
|---|
| 779 | {
|
|---|
| 780 | if (doc().omitEnumItemNames().contains(name)) {
|
|---|
| 781 | return Private;
|
|---|
| 782 | }
|
|---|
| 783 | else {
|
|---|
| 784 | return Public;
|
|---|
| 785 | }
|
|---|
| 786 | }
|
|---|
| 787 |
|
|---|
| 788 | /*!
|
|---|
| 789 | Returns the enum value associated with the enum \a name.
|
|---|
| 790 | */
|
|---|
| 791 | QString EnumNode::itemValue(const QString &name) const
|
|---|
| 792 | {
|
|---|
| 793 | foreach (const EnumItem &item, itms) {
|
|---|
| 794 | if (item.name() == name)
|
|---|
| 795 | return item.value();
|
|---|
| 796 | }
|
|---|
| 797 | return QString();
|
|---|
| 798 | }
|
|---|
| 799 |
|
|---|
| 800 | /*!
|
|---|
| 801 | \class TypedefNode
|
|---|
| 802 | */
|
|---|
| 803 |
|
|---|
| 804 | /*!
|
|---|
| 805 | */
|
|---|
| 806 | TypedefNode::TypedefNode(InnerNode *parent, const QString& name)
|
|---|
| 807 | : LeafNode(Typedef, parent, name), ae(0)
|
|---|
| 808 | {
|
|---|
| 809 | }
|
|---|
| 810 |
|
|---|
| 811 | /*!
|
|---|
| 812 | */
|
|---|
| 813 | void TypedefNode::setAssociatedEnum(const EnumNode *enume)
|
|---|
| 814 | {
|
|---|
| 815 | ae = enume;
|
|---|
| 816 | }
|
|---|
| 817 |
|
|---|
| 818 | /*!
|
|---|
| 819 | \class Parameter
|
|---|
| 820 | */
|
|---|
| 821 |
|
|---|
| 822 | /*!
|
|---|
| 823 | */
|
|---|
| 824 | Parameter::Parameter(const QString& leftType,
|
|---|
| 825 | const QString& rightType,
|
|---|
| 826 | const QString& name,
|
|---|
| 827 | const QString& defaultValue)
|
|---|
| 828 | : lef(leftType), rig(rightType), nam(name), def(defaultValue)
|
|---|
| 829 | {
|
|---|
| 830 | }
|
|---|
| 831 |
|
|---|
| 832 | /*!
|
|---|
| 833 | */
|
|---|
| 834 | Parameter::Parameter(const Parameter& p)
|
|---|
| 835 | : lef(p.lef), rig(p.rig), nam(p.nam), def(p.def)
|
|---|
| 836 | {
|
|---|
| 837 | }
|
|---|
| 838 |
|
|---|
| 839 | /*!
|
|---|
| 840 | */
|
|---|
| 841 | Parameter& Parameter::operator=(const Parameter& p)
|
|---|
| 842 | {
|
|---|
| 843 | lef = p.lef;
|
|---|
| 844 | rig = p.rig;
|
|---|
| 845 | nam = p.nam;
|
|---|
| 846 | def = p.def;
|
|---|
| 847 | return *this;
|
|---|
| 848 | }
|
|---|
| 849 |
|
|---|
| 850 | /*!
|
|---|
| 851 | \class FunctionNode
|
|---|
| 852 | */
|
|---|
| 853 |
|
|---|
| 854 | /*!
|
|---|
| 855 | */
|
|---|
| 856 | FunctionNode::FunctionNode(InnerNode *parent, const QString& name)
|
|---|
| 857 | : LeafNode(Function, parent, name), met(Plain), vir(NonVirtual),
|
|---|
| 858 | con(false), sta(false), ove(false), rf(0), ap(0)
|
|---|
| 859 | {
|
|---|
| 860 | }
|
|---|
| 861 |
|
|---|
| 862 | /*!
|
|---|
| 863 | */
|
|---|
| 864 | void FunctionNode::setOverload(bool overlode)
|
|---|
| 865 | {
|
|---|
| 866 | parent()->setOverload(this, overlode);
|
|---|
| 867 | ove = overlode;
|
|---|
| 868 | }
|
|---|
| 869 |
|
|---|
| 870 | /*!
|
|---|
| 871 | */
|
|---|
| 872 | void FunctionNode::addParameter(const Parameter& parameter)
|
|---|
| 873 | {
|
|---|
| 874 | params.append(parameter);
|
|---|
| 875 | }
|
|---|
| 876 |
|
|---|
| 877 | /*!
|
|---|
| 878 | */
|
|---|
| 879 | void FunctionNode::borrowParameterNames(const FunctionNode *source)
|
|---|
| 880 | {
|
|---|
| 881 | QList<Parameter>::Iterator t = params.begin();
|
|---|
| 882 | QList<Parameter>::ConstIterator s = source->params.begin();
|
|---|
| 883 | while (s != source->params.end() && t != params.end()) {
|
|---|
| 884 | if (!(*s).name().isEmpty())
|
|---|
| 885 | (*t).setName((*s).name());
|
|---|
| 886 | ++s;
|
|---|
| 887 | ++t;
|
|---|
| 888 | }
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 | /*!
|
|---|
| 892 | */
|
|---|
| 893 | void FunctionNode::setReimplementedFrom(FunctionNode *from)
|
|---|
| 894 | {
|
|---|
| 895 | rf = from;
|
|---|
| 896 | from->rb.append(this);
|
|---|
| 897 | }
|
|---|
| 898 |
|
|---|
| 899 | /*!
|
|---|
| 900 | */
|
|---|
| 901 | void FunctionNode::setAssociatedProperty(PropertyNode *property)
|
|---|
| 902 | {
|
|---|
| 903 | ap = property;
|
|---|
| 904 | }
|
|---|
| 905 |
|
|---|
| 906 | /*!
|
|---|
| 907 | */
|
|---|
| 908 | int FunctionNode::overloadNumber() const
|
|---|
| 909 | {
|
|---|
| 910 | return parent()->overloadNumber(this);
|
|---|
| 911 | }
|
|---|
| 912 |
|
|---|
| 913 | /*!
|
|---|
| 914 | */
|
|---|
| 915 | int FunctionNode::numOverloads() const
|
|---|
| 916 | {
|
|---|
| 917 | return parent()->numOverloads(name());
|
|---|
| 918 | }
|
|---|
| 919 |
|
|---|
| 920 | /*!
|
|---|
| 921 | */
|
|---|
| 922 | QStringList FunctionNode::parameterNames() const
|
|---|
| 923 | {
|
|---|
| 924 | QStringList names;
|
|---|
| 925 | QList<Parameter>::ConstIterator p = parameters().begin();
|
|---|
| 926 | while (p != parameters().end()) {
|
|---|
| 927 | names << (*p).name();
|
|---|
| 928 | ++p;
|
|---|
| 929 | }
|
|---|
| 930 | return names;
|
|---|
| 931 | }
|
|---|
| 932 |
|
|---|
| 933 | /*!
|
|---|
| 934 | \class PropertyNode
|
|---|
| 935 | */
|
|---|
| 936 |
|
|---|
| 937 | /*!
|
|---|
| 938 | */
|
|---|
| 939 | PropertyNode::PropertyNode(InnerNode *parent, const QString& name)
|
|---|
| 940 | : LeafNode(Property, parent, name),
|
|---|
| 941 | sto(Trool_Default),
|
|---|
| 942 | des(Trool_Default),
|
|---|
| 943 | overrides(0)
|
|---|
| 944 | {
|
|---|
| 945 | }
|
|---|
| 946 |
|
|---|
| 947 | /*!
|
|---|
| 948 | */
|
|---|
| 949 | void PropertyNode::setOverriddenFrom(const PropertyNode *baseProperty)
|
|---|
| 950 | {
|
|---|
| 951 | for (int i = 0; i < NumFunctionRoles; ++i) {
|
|---|
| 952 | if (funcs[i].isEmpty())
|
|---|
| 953 | funcs[i] = baseProperty->funcs[i];
|
|---|
| 954 | }
|
|---|
| 955 | if (sto == Trool_Default)
|
|---|
| 956 | sto = baseProperty->sto;
|
|---|
| 957 | if (des == Trool_Default)
|
|---|
| 958 | des = baseProperty->des;
|
|---|
| 959 | overrides = baseProperty;
|
|---|
| 960 | }
|
|---|
| 961 |
|
|---|
| 962 | /*!
|
|---|
| 963 | */
|
|---|
| 964 | QString PropertyNode::qualifiedDataType() const
|
|---|
| 965 | {
|
|---|
| 966 | if (setters().isEmpty() && resetters().isEmpty()) {
|
|---|
| 967 | if (dt.contains("*") || dt.contains("&")) {
|
|---|
| 968 | // 'QWidget *' becomes 'QWidget *' const
|
|---|
| 969 | return dt + " const";
|
|---|
| 970 | }
|
|---|
| 971 | else {
|
|---|
| 972 | /*
|
|---|
| 973 | 'int' becomes 'const int' ('int const' is
|
|---|
| 974 | correct C++, but looks wrong)
|
|---|
| 975 | */
|
|---|
| 976 | return "const " + dt;
|
|---|
| 977 | }
|
|---|
| 978 | }
|
|---|
| 979 | else {
|
|---|
| 980 | return dt;
|
|---|
| 981 | }
|
|---|
| 982 | }
|
|---|
| 983 |
|
|---|
| 984 | /*!
|
|---|
| 985 | */
|
|---|
| 986 | PropertyNode::Trool PropertyNode::toTrool(bool boolean)
|
|---|
| 987 | {
|
|---|
| 988 | return boolean ? Trool_True : Trool_False;
|
|---|
| 989 | }
|
|---|
| 990 |
|
|---|
| 991 | /*!
|
|---|
| 992 | */
|
|---|
| 993 | bool PropertyNode::fromTrool(Trool troolean, bool defaultValue)
|
|---|
| 994 | {
|
|---|
| 995 | switch (troolean) {
|
|---|
| 996 | case Trool_True:
|
|---|
| 997 | return true;
|
|---|
| 998 | case Trool_False:
|
|---|
| 999 | return false;
|
|---|
| 1000 | default:
|
|---|
| 1001 | return defaultValue;
|
|---|
| 1002 | }
|
|---|
| 1003 | }
|
|---|
| 1004 |
|
|---|
| 1005 | /*!
|
|---|
| 1006 | \class TargetNode
|
|---|
| 1007 | */
|
|---|
| 1008 |
|
|---|
| 1009 | /*!
|
|---|
| 1010 | */
|
|---|
| 1011 | TargetNode::TargetNode(InnerNode *parent, const QString& name)
|
|---|
| 1012 | : LeafNode(Target, parent, name)
|
|---|
| 1013 | {
|
|---|
| 1014 | }
|
|---|
| 1015 |
|
|---|
| 1016 | /*!
|
|---|
| 1017 | Returns false because this is a TargetNode.
|
|---|
| 1018 | */
|
|---|
| 1019 | bool TargetNode::isInnerNode() const
|
|---|
| 1020 | {
|
|---|
| 1021 | return false;
|
|---|
| 1022 | }
|
|---|
| 1023 |
|
|---|
| 1024 | QT_END_NAMESPACE
|
|---|