[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 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 | **
|
---|
[561] | 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.
|
---|
[2] | 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 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | /*
|
---|
| 43 | node.h
|
---|
| 44 | */
|
---|
| 45 |
|
---|
| 46 | #ifndef NODE_H
|
---|
| 47 | #define NODE_H
|
---|
| 48 |
|
---|
| 49 | #include <qdir.h>
|
---|
| 50 | #include <qmap.h>
|
---|
| 51 | #include <qpair.h>
|
---|
| 52 | #include <qstringlist.h>
|
---|
| 53 |
|
---|
| 54 | #include "codechunk.h"
|
---|
| 55 | #include "doc.h"
|
---|
| 56 | #include "location.h"
|
---|
| 57 | #include "text.h"
|
---|
[846] | 58 | #include <QUuid>
|
---|
[2] | 59 |
|
---|
| 60 | QT_BEGIN_NAMESPACE
|
---|
| 61 |
|
---|
| 62 | class InnerNode;
|
---|
| 63 |
|
---|
| 64 | class Node
|
---|
| 65 | {
|
---|
| 66 | public:
|
---|
| 67 | enum Type {
|
---|
| 68 | Namespace,
|
---|
| 69 | Class,
|
---|
| 70 | Fake,
|
---|
| 71 | Enum,
|
---|
| 72 | Typedef,
|
---|
| 73 | Function,
|
---|
| 74 | Property,
|
---|
| 75 | Variable,
|
---|
[561] | 76 | #ifdef QDOC_QML
|
---|
| 77 | Target,
|
---|
| 78 | QmlProperty,
|
---|
| 79 | QmlSignal,
|
---|
| 80 | QmlMethod,
|
---|
| 81 | LastType
|
---|
| 82 | #else
|
---|
| 83 | Target,
|
---|
| 84 | LastType
|
---|
| 85 | #endif
|
---|
[2] | 86 | };
|
---|
[561] | 87 |
|
---|
| 88 | enum SubType {
|
---|
| 89 | NoSubType,
|
---|
| 90 | Example,
|
---|
| 91 | HeaderFile,
|
---|
| 92 | File,
|
---|
| 93 | Image,
|
---|
| 94 | Group,
|
---|
| 95 | Module,
|
---|
| 96 | Page,
|
---|
| 97 | #ifdef QDOC_QML
|
---|
| 98 | ExternalPage,
|
---|
| 99 | QmlClass,
|
---|
[846] | 100 | QmlPropertyGroup,
|
---|
| 101 | QmlBasicType
|
---|
[561] | 102 | #else
|
---|
| 103 | ExternalPage
|
---|
| 104 | #endif
|
---|
| 105 | };
|
---|
[2] | 106 |
|
---|
| 107 | enum Access { Public, Protected, Private };
|
---|
| 108 |
|
---|
| 109 | enum Status {
|
---|
| 110 | Compat,
|
---|
| 111 | Obsolete,
|
---|
| 112 | Deprecated,
|
---|
| 113 | Preliminary,
|
---|
| 114 | Commendable,
|
---|
| 115 | Main,
|
---|
| 116 | Internal
|
---|
| 117 | }; // don't reorder thisw enum
|
---|
| 118 |
|
---|
| 119 | enum ThreadSafeness {
|
---|
| 120 | UnspecifiedSafeness,
|
---|
| 121 | NonReentrant,
|
---|
| 122 | Reentrant,
|
---|
| 123 | ThreadSafe
|
---|
| 124 | };
|
---|
| 125 |
|
---|
| 126 | enum LinkType {
|
---|
| 127 | StartLink,
|
---|
| 128 | NextLink,
|
---|
| 129 | PreviousLink,
|
---|
| 130 | ContentsLink,
|
---|
[561] | 131 | IndexLink,
|
---|
| 132 | InheritsLink /*,
|
---|
[2] | 133 | GlossaryLink,
|
---|
| 134 | CopyrightLink,
|
---|
| 135 | ChapterLink,
|
---|
| 136 | SectionLink,
|
---|
| 137 | SubsectionLink,
|
---|
| 138 | AppendixLink */
|
---|
| 139 | };
|
---|
| 140 |
|
---|
[846] | 141 | enum PageType {
|
---|
| 142 | NoPageType,
|
---|
| 143 | ApiPage,
|
---|
| 144 | ArticlePage,
|
---|
| 145 | ExamplePage
|
---|
| 146 | };
|
---|
| 147 |
|
---|
[2] | 148 | virtual ~Node();
|
---|
| 149 |
|
---|
| 150 | void setAccess(Access access) { acc = access; }
|
---|
| 151 | void setLocation(const Location& location) { loc = location; }
|
---|
| 152 | void setDoc(const Doc& doc, bool replace = false);
|
---|
| 153 | void setStatus(Status status) { sta = status; }
|
---|
| 154 | void setThreadSafeness(ThreadSafeness safeness) { saf = safeness; }
|
---|
| 155 | void setSince(const QString &since) { sinc = since; }
|
---|
[846] | 156 | void setRelates(InnerNode* pseudoParent);
|
---|
[2] | 157 | void setModuleName(const QString &module) { mod = module; }
|
---|
| 158 | void setLink(LinkType linkType, const QString &link, const QString &desc);
|
---|
| 159 | void setUrl(const QString &url);
|
---|
| 160 | void setTemplateStuff(const QString &templateStuff) { tpl = templateStuff; }
|
---|
[846] | 161 | void setPageType(PageType t) { pageTyp = t; }
|
---|
| 162 | void setPageType(const QString& t);
|
---|
[2] | 163 |
|
---|
| 164 | virtual bool isInnerNode() const = 0;
|
---|
[561] | 165 | virtual bool isReimp() const { return false; }
|
---|
| 166 | virtual bool isFunction() const { return false; }
|
---|
[846] | 167 | virtual bool isQmlNode() const { return false; }
|
---|
[2] | 168 | Type type() const { return typ; }
|
---|
[561] | 169 | virtual SubType subType() const { return NoSubType; }
|
---|
[846] | 170 | InnerNode* parent() const { return par; }
|
---|
| 171 | InnerNode* relates() const { return rel; }
|
---|
[2] | 172 | const QString& name() const { return nam; }
|
---|
| 173 | QMap<LinkType, QPair<QString,QString> > links() const { return linkMap; }
|
---|
| 174 | QString moduleName() const;
|
---|
| 175 | QString url() const;
|
---|
[561] | 176 | virtual QString nameForLists() const { return nam; }
|
---|
[2] | 177 |
|
---|
| 178 | Access access() const { return acc; }
|
---|
[846] | 179 | QString accessString() const;
|
---|
[2] | 180 | const Location& location() const { return loc; }
|
---|
| 181 | const Doc& doc() const { return d; }
|
---|
| 182 | Status status() const { return sta; }
|
---|
| 183 | Status inheritedStatus() const;
|
---|
| 184 | ThreadSafeness threadSafeness() const;
|
---|
| 185 | ThreadSafeness inheritedThreadSafeness() const;
|
---|
| 186 | QString since() const { return sinc; }
|
---|
| 187 | QString templateStuff() const { return tpl; }
|
---|
[846] | 188 | PageType pageType() const { return pageTyp; }
|
---|
| 189 | virtual void addPageKeywords(const QString& ) { }
|
---|
[2] | 190 |
|
---|
| 191 | void clearRelated() { rel = 0; }
|
---|
| 192 |
|
---|
[561] | 193 | virtual QString fileBase() const;
|
---|
[846] | 194 | QUuid guid() const;
|
---|
| 195 | QString ditaXmlHref();
|
---|
| 196 | QString extractClassName(const QString &string) const;
|
---|
[2] | 197 |
|
---|
| 198 | protected:
|
---|
[846] | 199 | Node(Type type, InnerNode* parent, const QString& name);
|
---|
[2] | 200 |
|
---|
| 201 | private:
|
---|
[561] | 202 |
|
---|
[2] | 203 | #ifdef Q_WS_WIN
|
---|
| 204 | Type typ;
|
---|
| 205 | Access acc;
|
---|
[846] | 206 | ThreadSafeness saf;
|
---|
| 207 | PageType pageTyp;
|
---|
[2] | 208 | Status sta;
|
---|
| 209 | #else
|
---|
| 210 | Type typ : 4;
|
---|
| 211 | Access acc : 2;
|
---|
[846] | 212 | ThreadSafeness saf : 2;
|
---|
| 213 | PageType pageTyp : 4;
|
---|
[2] | 214 | Status sta : 3;
|
---|
| 215 | #endif
|
---|
[846] | 216 | InnerNode* par;
|
---|
| 217 | InnerNode* rel;
|
---|
[2] | 218 | QString nam;
|
---|
| 219 | Location loc;
|
---|
| 220 | Doc d;
|
---|
| 221 | QMap<LinkType, QPair<QString, QString> > linkMap;
|
---|
| 222 | QString mod;
|
---|
| 223 | QString u;
|
---|
| 224 | QString sinc;
|
---|
| 225 | QString tpl;
|
---|
[846] | 226 | mutable QUuid uuid;
|
---|
[2] | 227 | };
|
---|
| 228 |
|
---|
| 229 | class FunctionNode;
|
---|
| 230 | class EnumNode;
|
---|
| 231 |
|
---|
[846] | 232 | typedef QList<Node*> NodeList;
|
---|
[2] | 233 |
|
---|
| 234 | class InnerNode : public Node
|
---|
| 235 | {
|
---|
| 236 | public:
|
---|
[561] | 237 | virtual ~InnerNode();
|
---|
[2] | 238 |
|
---|
[846] | 239 | Node* findNode(const QString& name);
|
---|
| 240 | Node* findNode(const QString& name, Type type);
|
---|
| 241 | FunctionNode* findFunctionNode(const QString& name);
|
---|
| 242 | FunctionNode* findFunctionNode(const FunctionNode* clone);
|
---|
[2] | 243 | void addInclude(const QString &include);
|
---|
| 244 | void setIncludes(const QStringList &includes);
|
---|
[846] | 245 | void setOverload(const FunctionNode* func, bool overlode);
|
---|
[2] | 246 | void normalizeOverloads();
|
---|
| 247 | void makeUndocumentedChildrenInternal();
|
---|
| 248 | void deleteChildren();
|
---|
| 249 | void removeFromRelated();
|
---|
| 250 |
|
---|
| 251 | virtual bool isInnerNode() const;
|
---|
[846] | 252 | const Node* findNode(const QString& name) const;
|
---|
| 253 | const Node* findNode(const QString& name, Type type) const;
|
---|
| 254 | const FunctionNode* findFunctionNode(const QString& name) const;
|
---|
| 255 | const FunctionNode* findFunctionNode(const FunctionNode* clone) const;
|
---|
| 256 | const EnumNode* findEnumNodeForValue(const QString &enumValue) const;
|
---|
[2] | 257 | const NodeList & childNodes() const { return children; }
|
---|
| 258 | const NodeList & relatedNodes() const { return related; }
|
---|
[561] | 259 | int count() const { return children.size(); }
|
---|
[846] | 260 | int overloadNumber(const FunctionNode* func) const;
|
---|
[2] | 261 | int numOverloads(const QString& funcName) const;
|
---|
| 262 | NodeList overloads(const QString &funcName) const;
|
---|
| 263 | const QStringList& includes() const { return inc; }
|
---|
| 264 |
|
---|
[561] | 265 | QStringList primaryKeys();
|
---|
| 266 | QStringList secondaryKeys();
|
---|
[846] | 267 | const QStringList& pageKeywords() const { return pageKeywds; }
|
---|
| 268 | virtual void addPageKeywords(const QString& t) { pageKeywds << t; }
|
---|
| 269 | virtual bool isAbstract() const { return false; }
|
---|
| 270 | virtual void setAbstract(bool ) { }
|
---|
[561] | 271 |
|
---|
[2] | 272 | protected:
|
---|
[846] | 273 | InnerNode(Type type, InnerNode* parent, const QString& name);
|
---|
[2] | 274 |
|
---|
| 275 | private:
|
---|
| 276 | friend class Node;
|
---|
| 277 |
|
---|
[846] | 278 | static bool isSameSignature(const FunctionNode* f1, const FunctionNode* f2);
|
---|
| 279 | void addChild(Node* child);
|
---|
| 280 | void removeChild(Node* child);
|
---|
| 281 | void removeRelated(Node* pseudoChild);
|
---|
[2] | 282 |
|
---|
[846] | 283 | QStringList pageKeywds;
|
---|
[2] | 284 | QStringList inc;
|
---|
| 285 | NodeList children;
|
---|
| 286 | NodeList enumChildren;
|
---|
| 287 | NodeList related;
|
---|
[846] | 288 | QMap<QString, Node*> childMap;
|
---|
| 289 | QMap<QString, Node*> primaryFunctionMap;
|
---|
[2] | 290 | QMap<QString, NodeList> secondaryFunctionMap;
|
---|
| 291 | };
|
---|
| 292 |
|
---|
| 293 | class LeafNode : public Node
|
---|
| 294 | {
|
---|
| 295 | public:
|
---|
| 296 | LeafNode();
|
---|
[561] | 297 | virtual ~LeafNode() { }
|
---|
[2] | 298 |
|
---|
| 299 | virtual bool isInnerNode() const;
|
---|
| 300 |
|
---|
| 301 | protected:
|
---|
[561] | 302 | LeafNode(Type type, InnerNode* parent, const QString& name);
|
---|
[2] | 303 | };
|
---|
| 304 |
|
---|
| 305 | class NamespaceNode : public InnerNode
|
---|
| 306 | {
|
---|
| 307 | public:
|
---|
[846] | 308 | NamespaceNode(InnerNode* parent, const QString& name);
|
---|
[561] | 309 | virtual ~NamespaceNode() { }
|
---|
[2] | 310 | };
|
---|
| 311 |
|
---|
| 312 | class ClassNode;
|
---|
| 313 |
|
---|
| 314 | struct RelatedClass
|
---|
| 315 | {
|
---|
| 316 | RelatedClass() { }
|
---|
| 317 | RelatedClass(Node::Access access0,
|
---|
| 318 | ClassNode* node0,
|
---|
| 319 | const QString& dataTypeWithTemplateArgs0 = "")
|
---|
| 320 | : access(access0),
|
---|
| 321 | node(node0),
|
---|
| 322 | dataTypeWithTemplateArgs(dataTypeWithTemplateArgs0) { }
|
---|
[846] | 323 | QString accessString() const;
|
---|
[2] | 324 |
|
---|
| 325 | Node::Access access;
|
---|
| 326 | ClassNode* node;
|
---|
| 327 | QString dataTypeWithTemplateArgs;
|
---|
| 328 | };
|
---|
| 329 |
|
---|
[846] | 330 | class PropertyNode;
|
---|
| 331 |
|
---|
[2] | 332 | class ClassNode : public InnerNode
|
---|
| 333 | {
|
---|
| 334 | public:
|
---|
[846] | 335 | ClassNode(InnerNode* parent, const QString& name);
|
---|
[561] | 336 | virtual ~ClassNode() { }
|
---|
[2] | 337 |
|
---|
| 338 | void addBaseClass(Access access,
|
---|
[846] | 339 | ClassNode* node,
|
---|
[2] | 340 | const QString &dataTypeWithTemplateArgs = "");
|
---|
| 341 | void fixBaseClasses();
|
---|
| 342 |
|
---|
[846] | 343 | const QList<RelatedClass> &baseClasses() const { return bases; }
|
---|
| 344 | const QList<RelatedClass> &derivedClasses() const { return derived; }
|
---|
| 345 | const QList<RelatedClass> &ignoredBaseClasses() const { return ignoredBases; }
|
---|
[2] | 346 |
|
---|
| 347 | bool hideFromMainList() const { return hidden; }
|
---|
| 348 | void setHideFromMainList(bool value) { hidden = value; }
|
---|
| 349 |
|
---|
| 350 | QString serviceName() const { return sname; }
|
---|
| 351 | void setServiceName(const QString& value) { sname = value; }
|
---|
[561] | 352 | QString qmlElement() const { return qmlelement; }
|
---|
| 353 | void setQmlElement(const QString& value) { qmlelement = value; }
|
---|
[846] | 354 | virtual bool isAbstract() const { return abstract; }
|
---|
| 355 | virtual void setAbstract(bool b) { abstract = b; }
|
---|
| 356 | const PropertyNode* findPropertyNode(const QString& name) const;
|
---|
[2] | 357 |
|
---|
| 358 | private:
|
---|
[846] | 359 | QList<RelatedClass> bases;
|
---|
| 360 | QList<RelatedClass> derived;
|
---|
| 361 | QList<RelatedClass> ignoredBases;
|
---|
[2] | 362 | bool hidden;
|
---|
[846] | 363 | bool abstract;
|
---|
[2] | 364 | QString sname;
|
---|
[561] | 365 | QString qmlelement;
|
---|
[2] | 366 | };
|
---|
| 367 |
|
---|
| 368 | class FakeNode : public InnerNode
|
---|
| 369 | {
|
---|
| 370 | public:
|
---|
| 371 |
|
---|
[846] | 372 | FakeNode(InnerNode* parent, const QString& name, SubType subType);
|
---|
[561] | 373 | virtual ~FakeNode() { }
|
---|
[2] | 374 |
|
---|
| 375 | void setTitle(const QString &title) { tle = title; }
|
---|
| 376 | void setSubTitle(const QString &subTitle) { stle = subTitle; }
|
---|
[846] | 377 | void addGroupMember(Node* node) { gr.append(node); }
|
---|
[2] | 378 |
|
---|
| 379 | SubType subType() const { return sub; }
|
---|
[846] | 380 | virtual QString title() const;
|
---|
| 381 | virtual QString fullTitle() const;
|
---|
| 382 | virtual QString subTitle() const;
|
---|
[2] | 383 | const NodeList &groupMembers() const { return gr; }
|
---|
[561] | 384 | virtual QString nameForLists() const { return title(); }
|
---|
[2] | 385 |
|
---|
| 386 | private:
|
---|
| 387 | SubType sub;
|
---|
| 388 | QString tle;
|
---|
| 389 | QString stle;
|
---|
| 390 | NodeList gr;
|
---|
| 391 | };
|
---|
| 392 |
|
---|
[561] | 393 | #ifdef QDOC_QML
|
---|
| 394 | class QmlClassNode : public FakeNode
|
---|
[2] | 395 | {
|
---|
| 396 | public:
|
---|
[846] | 397 | QmlClassNode(InnerNode* parent,
|
---|
[561] | 398 | const QString& name,
|
---|
| 399 | const ClassNode* cn);
|
---|
[846] | 400 | virtual ~QmlClassNode();
|
---|
| 401 | virtual bool isQmlNode() const { return true; }
|
---|
[2] | 402 |
|
---|
| 403 | const ClassNode* classNode() const { return cnode; }
|
---|
[561] | 404 | virtual QString fileBase() const;
|
---|
[846] | 405 | static void addInheritedBy(const QString& base, Node* sub);
|
---|
| 406 | static void subclasses(const QString& base, NodeList& subs);
|
---|
| 407 | static void clear();
|
---|
[2] | 408 |
|
---|
[846] | 409 | public:
|
---|
[561] | 410 | static bool qmlOnly;
|
---|
[846] | 411 | static QMultiMap<QString,Node*> inheritedBy;
|
---|
[561] | 412 |
|
---|
[2] | 413 | private:
|
---|
[846] | 414 | const ClassNode* cnode;
|
---|
[2] | 415 | };
|
---|
| 416 |
|
---|
[846] | 417 | class QmlBasicTypeNode : public FakeNode
|
---|
| 418 | {
|
---|
| 419 | public:
|
---|
| 420 | QmlBasicTypeNode(InnerNode* parent,
|
---|
| 421 | const QString& name);
|
---|
| 422 | virtual ~QmlBasicTypeNode() { }
|
---|
| 423 | virtual bool isQmlNode() const { return true; }
|
---|
| 424 | };
|
---|
| 425 |
|
---|
[561] | 426 | class QmlPropGroupNode : public FakeNode
|
---|
| 427 | {
|
---|
| 428 | public:
|
---|
| 429 | QmlPropGroupNode(QmlClassNode* parent,
|
---|
| 430 | const QString& name,
|
---|
| 431 | bool attached);
|
---|
| 432 | virtual ~QmlPropGroupNode() { }
|
---|
[846] | 433 | virtual bool isQmlNode() const { return true; }
|
---|
[561] | 434 |
|
---|
| 435 | const QString& element() const { return parent()->name(); }
|
---|
| 436 | void setDefault() { isdefault = true; }
|
---|
| 437 | bool isDefault() const { return isdefault; }
|
---|
| 438 | bool isAttached() const { return att; }
|
---|
| 439 |
|
---|
| 440 | private:
|
---|
| 441 | bool isdefault;
|
---|
| 442 | bool att;
|
---|
| 443 | };
|
---|
| 444 |
|
---|
[846] | 445 | class Tree;
|
---|
| 446 |
|
---|
[561] | 447 | class QmlPropertyNode : public LeafNode
|
---|
| 448 | {
|
---|
| 449 | public:
|
---|
| 450 | QmlPropertyNode(QmlPropGroupNode* parent,
|
---|
| 451 | const QString& name,
|
---|
| 452 | const QString& type,
|
---|
| 453 | bool attached);
|
---|
| 454 | virtual ~QmlPropertyNode() { }
|
---|
| 455 |
|
---|
| 456 | void setDataType(const QString& dataType) { dt = dataType; }
|
---|
| 457 | void setStored(bool stored) { sto = toTrool(stored); }
|
---|
| 458 | void setDesignable(bool designable) { des = toTrool(designable); }
|
---|
| 459 | void setWritable(bool writable) { wri = toTrool(writable); }
|
---|
| 460 |
|
---|
| 461 | const QString &dataType() const { return dt; }
|
---|
| 462 | QString qualifiedDataType() const { return dt; }
|
---|
| 463 | bool isStored() const { return fromTrool(sto,true); }
|
---|
| 464 | bool isDesignable() const { return fromTrool(des,false); }
|
---|
[846] | 465 | bool isWritable(const Tree* tree) const;
|
---|
[561] | 466 | bool isAttached() const { return att; }
|
---|
[846] | 467 | virtual bool isQmlNode() const { return true; }
|
---|
[561] | 468 |
|
---|
| 469 | const QString& element() const { return static_cast<QmlPropGroupNode*>(parent())->element(); }
|
---|
| 470 |
|
---|
| 471 | private:
|
---|
| 472 | enum Trool { Trool_True, Trool_False, Trool_Default };
|
---|
| 473 |
|
---|
| 474 | static Trool toTrool(bool boolean);
|
---|
| 475 | static bool fromTrool(Trool troolean, bool defaultValue);
|
---|
| 476 |
|
---|
| 477 | QString dt;
|
---|
| 478 | Trool sto;
|
---|
| 479 | Trool des;
|
---|
| 480 | Trool wri;
|
---|
| 481 | bool att;
|
---|
| 482 | };
|
---|
| 483 | #endif
|
---|
| 484 |
|
---|
[2] | 485 | class EnumItem
|
---|
| 486 | {
|
---|
| 487 | public:
|
---|
| 488 | EnumItem() { }
|
---|
| 489 | EnumItem(const QString& name, const QString& value)
|
---|
| 490 | : nam(name), val(value) { }
|
---|
| 491 | EnumItem(const QString& name, const QString& value, const Text &txt)
|
---|
| 492 | : nam(name), val(value), txt(txt) { }
|
---|
| 493 |
|
---|
| 494 | const QString& name() const { return nam; }
|
---|
| 495 | const QString& value() const { return val; }
|
---|
| 496 | const Text &text() const { return txt; }
|
---|
| 497 |
|
---|
| 498 | private:
|
---|
| 499 | QString nam;
|
---|
| 500 | QString val;
|
---|
| 501 | Text txt;
|
---|
| 502 | };
|
---|
| 503 |
|
---|
| 504 | class TypedefNode;
|
---|
| 505 |
|
---|
| 506 | class EnumNode : public LeafNode
|
---|
| 507 | {
|
---|
| 508 | public:
|
---|
[846] | 509 | EnumNode(InnerNode* parent, const QString& name);
|
---|
[561] | 510 | virtual ~EnumNode() { }
|
---|
[2] | 511 |
|
---|
| 512 | void addItem(const EnumItem& item);
|
---|
[846] | 513 | void setFlagsType(TypedefNode* typedeff);
|
---|
[2] | 514 | bool hasItem(const QString &name) const { return names.contains(name); }
|
---|
| 515 |
|
---|
| 516 | const QList<EnumItem>& items() const { return itms; }
|
---|
| 517 | Access itemAccess(const QString& name) const;
|
---|
[846] | 518 | const TypedefNode* flagsType() const { return ft; }
|
---|
[2] | 519 | QString itemValue(const QString &name) const;
|
---|
| 520 |
|
---|
| 521 | private:
|
---|
| 522 | QList<EnumItem> itms;
|
---|
| 523 | QSet<QString> names;
|
---|
[846] | 524 | const TypedefNode* ft;
|
---|
[2] | 525 | };
|
---|
| 526 |
|
---|
| 527 | class TypedefNode : public LeafNode
|
---|
| 528 | {
|
---|
| 529 | public:
|
---|
[846] | 530 | TypedefNode(InnerNode* parent, const QString& name);
|
---|
[561] | 531 | virtual ~TypedefNode() { }
|
---|
[2] | 532 |
|
---|
[846] | 533 | const EnumNode* associatedEnum() const { return ae; }
|
---|
[2] | 534 |
|
---|
| 535 | private:
|
---|
[846] | 536 | void setAssociatedEnum(const EnumNode* enume);
|
---|
[2] | 537 |
|
---|
| 538 | friend class EnumNode;
|
---|
| 539 |
|
---|
[846] | 540 | const EnumNode* ae;
|
---|
[2] | 541 | };
|
---|
| 542 |
|
---|
[846] | 543 | inline void EnumNode::setFlagsType(TypedefNode* typedeff)
|
---|
[2] | 544 | {
|
---|
| 545 | ft = typedeff;
|
---|
| 546 | typedeff->setAssociatedEnum(this);
|
---|
| 547 | }
|
---|
| 548 |
|
---|
| 549 |
|
---|
| 550 | class Parameter
|
---|
| 551 | {
|
---|
| 552 | public:
|
---|
| 553 | Parameter() {}
|
---|
[561] | 554 | Parameter(const QString& leftType,
|
---|
| 555 | const QString& rightType = "",
|
---|
| 556 | const QString& name = "",
|
---|
| 557 | const QString& defaultValue = "");
|
---|
[2] | 558 | Parameter(const Parameter& p);
|
---|
| 559 |
|
---|
| 560 | Parameter& operator=(const Parameter& p);
|
---|
| 561 |
|
---|
| 562 | void setName(const QString& name) { nam = name; }
|
---|
| 563 |
|
---|
| 564 | bool hasType() const { return lef.length() + rig.length() > 0; }
|
---|
| 565 | const QString& leftType() const { return lef; }
|
---|
| 566 | const QString& rightType() const { return rig; }
|
---|
| 567 | const QString& name() const { return nam; }
|
---|
| 568 | const QString& defaultValue() const { return def; }
|
---|
| 569 |
|
---|
[561] | 570 | QString reconstruct(bool value = false) const;
|
---|
| 571 |
|
---|
[2] | 572 | private:
|
---|
| 573 | QString lef;
|
---|
| 574 | QString rig;
|
---|
| 575 | QString nam;
|
---|
| 576 | QString def;
|
---|
| 577 | };
|
---|
| 578 |
|
---|
| 579 | class PropertyNode;
|
---|
| 580 |
|
---|
| 581 | class FunctionNode : public LeafNode
|
---|
| 582 | {
|
---|
| 583 | public:
|
---|
| 584 | enum Metaness {
|
---|
| 585 | Plain,
|
---|
| 586 | Signal,
|
---|
| 587 | Slot,
|
---|
| 588 | Ctor,
|
---|
| 589 | Dtor,
|
---|
| 590 | MacroWithParams,
|
---|
| 591 | MacroWithoutParams,
|
---|
| 592 | Native };
|
---|
| 593 | enum Virtualness { NonVirtual, ImpureVirtual, PureVirtual };
|
---|
| 594 |
|
---|
[846] | 595 | FunctionNode(InnerNode* parent, const QString &name);
|
---|
| 596 | FunctionNode(Type type, InnerNode* parent, const QString &name, bool attached);
|
---|
[561] | 597 | virtual ~FunctionNode() { }
|
---|
[2] | 598 |
|
---|
| 599 | void setReturnType(const QString& returnType) { rt = returnType; }
|
---|
[561] | 600 | void setParentPath(const QStringList& parentPath) { pp = parentPath; }
|
---|
[2] | 601 | void setMetaness(Metaness metaness) { met = metaness; }
|
---|
[846] | 602 | void setVirtualness(Virtualness virtualness);
|
---|
[2] | 603 | void setConst(bool conste) { con = conste; }
|
---|
| 604 | void setStatic(bool statique) { sta = statique; }
|
---|
| 605 | void setOverload(bool overlode);
|
---|
[561] | 606 | void setReimp(bool r);
|
---|
[2] | 607 | void addParameter(const Parameter& parameter);
|
---|
| 608 | inline void setParameters(const QList<Parameter>& parameters);
|
---|
[846] | 609 | void borrowParameterNames(const FunctionNode* source);
|
---|
| 610 | void setReimplementedFrom(FunctionNode* from);
|
---|
[2] | 611 |
|
---|
| 612 | const QString& returnType() const { return rt; }
|
---|
| 613 | Metaness metaness() const { return met; }
|
---|
| 614 | bool isMacro() const {
|
---|
| 615 | return met == MacroWithParams || met == MacroWithoutParams;
|
---|
| 616 | }
|
---|
| 617 | Virtualness virtualness() const { return vir; }
|
---|
| 618 | bool isConst() const { return con; }
|
---|
| 619 | bool isStatic() const { return sta; }
|
---|
| 620 | bool isOverload() const { return ove; }
|
---|
[561] | 621 | bool isReimp() const { return reimp; }
|
---|
| 622 | bool isFunction() const { return true; }
|
---|
[2] | 623 | int overloadNumber() const;
|
---|
| 624 | int numOverloads() const;
|
---|
| 625 | const QList<Parameter>& parameters() const { return params; }
|
---|
| 626 | QStringList parameterNames() const;
|
---|
[846] | 627 | QString rawParameters(bool names = false, bool values = false) const;
|
---|
| 628 | const FunctionNode* reimplementedFrom() const { return rf; }
|
---|
| 629 | const QList<FunctionNode*> &reimplementedBy() const { return rb; }
|
---|
| 630 | const PropertyNode* associatedProperty() const { return ap; }
|
---|
[561] | 631 | const QStringList& parentPath() const { return pp; }
|
---|
[2] | 632 |
|
---|
[561] | 633 | QStringList reconstructParams(bool values = false) const;
|
---|
| 634 | QString signature(bool values = false) const;
|
---|
| 635 | const QString& element() const { return parent()->name(); }
|
---|
| 636 | bool isAttached() const { return att; }
|
---|
[846] | 637 | virtual bool isQmlNode() const {
|
---|
| 638 | return ((type() == QmlSignal) || (type() == QmlMethod));
|
---|
| 639 | }
|
---|
[561] | 640 |
|
---|
| 641 | void debug() const;
|
---|
| 642 |
|
---|
[2] | 643 | private:
|
---|
[846] | 644 | void setAssociatedProperty(PropertyNode* property);
|
---|
[2] | 645 |
|
---|
| 646 | friend class InnerNode;
|
---|
| 647 | friend class PropertyNode;
|
---|
| 648 |
|
---|
[561] | 649 | QString rt;
|
---|
| 650 | QStringList pp;
|
---|
[2] | 651 | #ifdef Q_WS_WIN
|
---|
[561] | 652 | Metaness met;
|
---|
[2] | 653 | Virtualness vir;
|
---|
| 654 | #else
|
---|
| 655 | Metaness met : 4;
|
---|
| 656 | Virtualness vir : 2;
|
---|
| 657 | #endif
|
---|
| 658 | bool con : 1;
|
---|
| 659 | bool sta : 1;
|
---|
| 660 | bool ove : 1;
|
---|
[561] | 661 | bool reimp: 1;
|
---|
| 662 | bool att: 1;
|
---|
[2] | 663 | QList<Parameter> params;
|
---|
[846] | 664 | const FunctionNode* rf;
|
---|
| 665 | const PropertyNode* ap;
|
---|
| 666 | QList<FunctionNode*> rb;
|
---|
[2] | 667 | };
|
---|
| 668 |
|
---|
| 669 | class PropertyNode : public LeafNode
|
---|
| 670 | {
|
---|
| 671 | public:
|
---|
[561] | 672 | enum FunctionRole { Getter, Setter, Resetter, Notifier };
|
---|
| 673 | enum { NumFunctionRoles = Notifier + 1 };
|
---|
[2] | 674 |
|
---|
[846] | 675 | PropertyNode(InnerNode* parent, const QString& name);
|
---|
[561] | 676 | virtual ~PropertyNode() { }
|
---|
[2] | 677 |
|
---|
| 678 | void setDataType(const QString& dataType) { dt = dataType; }
|
---|
[846] | 679 | void addFunction(FunctionNode* function, FunctionRole role);
|
---|
| 680 | void addSignal(FunctionNode* function, FunctionRole role);
|
---|
[2] | 681 | void setStored(bool stored) { sto = toTrool(stored); }
|
---|
| 682 | void setDesignable(bool designable) { des = toTrool(designable); }
|
---|
[846] | 683 | void setScriptable(bool scriptable) { scr = toTrool(scriptable); }
|
---|
[561] | 684 | void setWritable(bool writable) { wri = toTrool(writable); }
|
---|
[846] | 685 | void setUser(bool user) { usr = toTrool(user); }
|
---|
| 686 | void setOverriddenFrom(const PropertyNode* baseProperty);
|
---|
| 687 | void setRuntimeDesFunc(const QString& rdf) { runtimeDesFunc = rdf; }
|
---|
| 688 | void setRuntimeScrFunc(const QString& scrf) { runtimeScrFunc = scrf; }
|
---|
| 689 | void setConstant() { cst = true; }
|
---|
| 690 | void setFinal() { fnl = true; }
|
---|
[2] | 691 |
|
---|
| 692 | const QString &dataType() const { return dt; }
|
---|
| 693 | QString qualifiedDataType() const;
|
---|
| 694 | NodeList functions() const;
|
---|
| 695 | NodeList functions(FunctionRole role) const { return funcs[(int)role]; }
|
---|
| 696 | NodeList getters() const { return functions(Getter); }
|
---|
| 697 | NodeList setters() const { return functions(Setter); }
|
---|
| 698 | NodeList resetters() const { return functions(Resetter); }
|
---|
[561] | 699 | NodeList notifiers() const { return functions(Notifier); }
|
---|
[2] | 700 | bool isStored() const { return fromTrool(sto, storedDefault()); }
|
---|
| 701 | bool isDesignable() const { return fromTrool(des, designableDefault()); }
|
---|
[846] | 702 | bool isScriptable() const { return fromTrool(scr, scriptableDefault()); }
|
---|
| 703 | const QString& runtimeDesignabilityFunction() const { return runtimeDesFunc; }
|
---|
| 704 | const QString& runtimeScriptabilityFunction() const { return runtimeScrFunc; }
|
---|
[561] | 705 | bool isWritable() const { return fromTrool(wri, writableDefault()); }
|
---|
[846] | 706 | bool isUser() const { return fromTrool(usr, userDefault()); }
|
---|
| 707 | bool isConstant() const { return cst; }
|
---|
| 708 | bool isFinal() const { return fnl; }
|
---|
| 709 | const PropertyNode* overriddenFrom() const { return overrides; }
|
---|
[2] | 710 |
|
---|
[846] | 711 | bool storedDefault() const { return true; }
|
---|
| 712 | bool userDefault() const { return false; }
|
---|
| 713 | bool designableDefault() const { return !setters().isEmpty(); }
|
---|
| 714 | bool scriptableDefault() const { return true; }
|
---|
| 715 | bool writableDefault() const { return !setters().isEmpty(); }
|
---|
| 716 |
|
---|
[2] | 717 | private:
|
---|
| 718 | enum Trool { Trool_True, Trool_False, Trool_Default };
|
---|
| 719 |
|
---|
| 720 | static Trool toTrool(bool boolean);
|
---|
| 721 | static bool fromTrool(Trool troolean, bool defaultValue);
|
---|
| 722 |
|
---|
| 723 | QString dt;
|
---|
[846] | 724 | QString runtimeDesFunc;
|
---|
| 725 | QString runtimeScrFunc;
|
---|
[2] | 726 | NodeList funcs[NumFunctionRoles];
|
---|
| 727 | Trool sto;
|
---|
| 728 | Trool des;
|
---|
[846] | 729 | Trool scr;
|
---|
[561] | 730 | Trool wri;
|
---|
[846] | 731 | Trool usr;
|
---|
| 732 | bool cst;
|
---|
| 733 | bool fnl;
|
---|
| 734 | const PropertyNode* overrides;
|
---|
[2] | 735 | };
|
---|
| 736 |
|
---|
| 737 | inline void FunctionNode::setParameters(const QList<Parameter> ¶meters)
|
---|
| 738 | {
|
---|
| 739 | params = parameters;
|
---|
| 740 | }
|
---|
| 741 |
|
---|
[846] | 742 | inline void PropertyNode::addFunction(FunctionNode* function, FunctionRole role)
|
---|
[2] | 743 | {
|
---|
| 744 | funcs[(int)role].append(function);
|
---|
| 745 | function->setAssociatedProperty(this);
|
---|
| 746 | }
|
---|
| 747 |
|
---|
[846] | 748 | inline void PropertyNode::addSignal(FunctionNode* function, FunctionRole role)
|
---|
[561] | 749 | {
|
---|
| 750 | funcs[(int)role].append(function);
|
---|
| 751 | }
|
---|
| 752 |
|
---|
[2] | 753 | inline NodeList PropertyNode::functions() const
|
---|
| 754 | {
|
---|
| 755 | NodeList list;
|
---|
| 756 | for (int i = 0; i < NumFunctionRoles; ++i)
|
---|
| 757 | list += funcs[i];
|
---|
| 758 | return list;
|
---|
| 759 | }
|
---|
| 760 |
|
---|
| 761 | class VariableNode : public LeafNode
|
---|
| 762 | {
|
---|
| 763 | public:
|
---|
[846] | 764 | VariableNode(InnerNode* parent, const QString &name);
|
---|
[561] | 765 | virtual ~VariableNode() { }
|
---|
[2] | 766 |
|
---|
| 767 | void setLeftType(const QString &leftType) { lt = leftType; }
|
---|
| 768 | void setRightType(const QString &rightType) { rt = rightType; }
|
---|
| 769 | void setStatic(bool statique) { sta = statique; }
|
---|
| 770 |
|
---|
| 771 | const QString &leftType() const { return lt; }
|
---|
| 772 | const QString &rightType() const { return rt; }
|
---|
| 773 | QString dataType() const { return lt + rt; }
|
---|
| 774 | bool isStatic() const { return sta; }
|
---|
| 775 |
|
---|
| 776 | private:
|
---|
| 777 | QString lt;
|
---|
| 778 | QString rt;
|
---|
| 779 | bool sta;
|
---|
| 780 | };
|
---|
| 781 |
|
---|
[846] | 782 | inline VariableNode::VariableNode(InnerNode* parent, const QString &name)
|
---|
[2] | 783 | : LeafNode(Variable, parent, name), sta(false)
|
---|
| 784 | {
|
---|
[846] | 785 | // nothing.
|
---|
[2] | 786 | }
|
---|
| 787 |
|
---|
| 788 | class TargetNode : public LeafNode
|
---|
| 789 | {
|
---|
| 790 | public:
|
---|
[846] | 791 | TargetNode(InnerNode* parent, const QString& name);
|
---|
[561] | 792 | virtual ~TargetNode() { }
|
---|
[2] | 793 |
|
---|
| 794 | virtual bool isInnerNode() const;
|
---|
| 795 | };
|
---|
| 796 |
|
---|
| 797 | QT_END_NAMESPACE
|
---|
| 798 |
|
---|
| 799 | #endif
|
---|