Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/qdoc3/node.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the tools applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4444*/
    4545
     46#include <QtCore>
    4647#include "node.h"
    4748
     
    5051/*!
    5152  \class Node
    52   \brief A node in a Tree.
    53  */
    54 
    55 /*!
     53  \brief The Node class is a node in the Tree.
     54
     55  A Node represents a class or function or something else
     56  from the source code..
     57 */
     58
     59/*!
     60  When this Node is destroyed, if it has a parent Node, it
     61  removes itself from the parent node's child list.
    5662 */
    5763Node::~Node()
     
    6470
    6571/*!
     72  Sets this Node's Doc to \a doc. If \a replace is false and
     73  this Node already has a Doc, a warning is reported that the
     74  Doc is being overridden, and it reports where the previous
     75  Doc was found. If \a replace is true, the Doc is replaced
     76  silently.
    6677 */
    6778void Node::setDoc(const Doc& doc, bool replace)
     
    114125
    115126/*!
     127  This function creates a pair that describes a link.
     128  The pair is composed from \a link and \a desc. The
     129  \a linkType is the map index the pair is filed under.
    116130 */
    117131void Node::setLink(LinkType linkType, const QString &link, const QString &desc)
     
    205219
    206220/*!
     221  Find the function node in this node for the function named \a name.
    207222 */
    208223FunctionNode *InnerNode::findFunctionNode(const QString& name)
     
    212227
    213228/*!
     229  Find the function node in this node that has the same name as \a clone.
    214230 */
    215231FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone)
     
    232248    }
    233249    return 0;
     250}
     251
     252/*!
     253  Returns the list of keys from the primary function map.
     254 */
     255QStringList InnerNode::primaryKeys()
     256{
     257    QStringList t;
     258    QMap<QString, Node*>::iterator i = primaryFunctionMap.begin();
     259    while (i != primaryFunctionMap.end()) {
     260        t.append(i.key());
     261        ++i;
     262    }
     263    return t;
     264}
     265
     266/*!
     267  Returns the list of keys from the secondary function map.
     268 */
     269QStringList InnerNode::secondaryKeys()
     270{
     271    QStringList t;
     272    QMap<QString, NodeList>::iterator i = secondaryFunctionMap.begin();
     273    while (i != secondaryFunctionMap.end()) {
     274        t.append(i.key());
     275        ++i;
     276    }
     277    return t;
    234278}
    235279
     
    379423
    380424/*!
     425  Find the function node in this node that has the given \a name.
    381426 */
    382427const FunctionNode *InnerNode::findFunctionNode(const QString& name) const
     
    387432
    388433/*!
    389  */
    390 const FunctionNode *InnerNode::findFunctionNode(
    391         const FunctionNode *clone) const
     434  Find the function node in this node that has the same name as \a clone.
     435 */
     436const FunctionNode *InnerNode::findFunctionNode(const FunctionNode *clone) const
    392437{
    393438    InnerNode *that = (InnerNode *) this;
     
    507552{
    508553    children.append(child);
    509     if (child->type() == Function) {
     554    if ((child->type() == Function) || (child->type() == QmlMethod)) {
    510555        FunctionNode *func = (FunctionNode *) child;
    511556        if (!primaryFunctionMap.contains(func->name())) {
     
    624669
    625670/*!
    626   Returns false because this is an InnerNode.
     671  Returns false because this is a LeafNode.
    627672 */
    628673bool LeafNode::isInnerNode() const
     
    714759
    715760/*!
    716  */
    717 FakeNode::FakeNode(InnerNode *parent, const QString& name, SubType subType)
    718     : InnerNode(Fake, parent, name), sub(subType)
    719 {
    720 }
    721 
    722 /*!
     761  The type of a FakeNode is Fake, and it has a \a subtype,
     762  which specifies the type of FakeNode.
     763 */
     764FakeNode::FakeNode(InnerNode *parent, const QString& name, SubType subtype)
     765    : InnerNode(Fake, parent, name), sub(subtype)
     766{
     767}
     768
     769/*!
     770  Returns the fake node's full title, which is usually
     771  just title(), but for some SubType values is different
     772  from title()
    723773 */
    724774QString FakeNode::fullTitle() const
     
    730780            return title();
    731781    }
     782    else if (sub == Image) {
     783        if (title().isEmpty())
     784            return name().mid(name().lastIndexOf('/') + 1) + " Image File";
     785        else
     786            return title();
     787    }
    732788    else if (sub == HeaderFile) {
    733789        if (title().isEmpty())
     
    742798
    743799/*!
     800  Returns the subtitle.
    744801 */
    745802QString FakeNode::subTitle() const
     
    748805        return stle;
    749806
    750     if (sub == File) {
     807    if ((sub == File) || (sub == Image)) {
    751808        if (title().isEmpty() && name().contains("/"))
    752809            return name();
     
    818875/*!
    819876  \class Parameter
    820  */
    821 
    822 /*!
     877  \brief The class Parameter contains one parameter.
     878
     879  A parameter can be a function parameter or a macro
     880  parameter.
     881 */
     882
     883/*!
     884  Constructs this parameter from the left and right types
     885  \a leftType and rightType, the parameter \a name, and the
     886  \a defaultValue. In practice, \a rightType is not used,
     887  and I don't know what is was meant for.
    823888 */
    824889Parameter::Parameter(const QString& leftType,
     
    831896
    832897/*!
     898  The standard copy constructor copies the strings from \a p.
    833899 */
    834900Parameter::Parameter(const Parameter& p)
     
    838904
    839905/*!
     906  Assigning Parameter \a p to this Parameter copies the
     907  strings across.
    840908 */
    841909Parameter& Parameter::operator=(const Parameter& p)
     
    849917
    850918/*!
     919  Reconstructs the text describing the parameter and
     920  returns it. If \a value is true, the default value
     921  will be included, if there is one.
     922 */
     923QString Parameter::reconstruct(bool value) const
     924{
     925    QString p = lef + rig;
     926    if (!p.endsWith(QChar('*')) && !p.endsWith(QChar('&')) && !p.endsWith(QChar(' ')))
     927        p += " ";
     928    p += nam;
     929    if (value)
     930        p += def;
     931    return p;
     932}
     933
     934
     935/*!
    851936  \class FunctionNode
    852937 */
    853938
    854939/*!
     940  Construct a function node for a C++ function. It's parent
     941  is \a parent, and it's name is \a name.
    855942 */
    856943FunctionNode::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 {
     944    : LeafNode(Function, parent, name),
     945      met(Plain),
     946      vir(NonVirtual),
     947      con(false),
     948      sta(false),
     949      ove(false),
     950      att(false),
     951      rf(0),
     952      ap(0)
     953{
     954    // nothing.
     955}
     956
     957/*!
     958  Construct a function node for a QML method or signal, specified
     959  by \a type. It's parent is \a parent, and it's name is \a name.
     960  If \a attached is true, it is an attached method or signal.
     961 */
     962FunctionNode::FunctionNode(Type type, InnerNode *parent, const QString& name, bool attached)
     963    : LeafNode(type, parent, name),
     964      met(Plain),
     965      vir(NonVirtual),
     966      con(false),
     967      sta(false),
     968      ove(false),
     969      att(attached),
     970      rf(0),
     971      ap(0)
     972{
     973    // nothing.
    860974}
    861975
     
    866980    parent()->setOverload(this, overlode);
    867981    ove = overlode;
     982}
     983
     984/*!
     985  Sets the function node's reimplementation flag to \a r.
     986  When \a r is true, it is supposed to mean that this function
     987  is a reimplementation of a virtual function in a base class,
     988  but it really just means the \e reimp command was seen in the
     989  qdoc comment.
     990 */
     991void FunctionNode::setReimp(bool r)
     992{
     993    reimp = r;
    868994}
    869995
     
    8901016
    8911017/*!
     1018  If this function is a reimplementation, \a from points
     1019  to the FunctionNode of the function being reimplemented.
    8921020 */
    8931021void FunctionNode::setReimplementedFrom(FunctionNode *from)
     
    8981026
    8991027/*!
     1028  Sets the "associated" property to \a property. The function
     1029  might be the setter or getter for a property, for example.
    9001030 */
    9011031void FunctionNode::setAssociatedProperty(PropertyNode *property)
     
    9051035
    9061036/*!
     1037  Returns the overload number for this function obtained
     1038  from the parent.
    9071039 */
    9081040int FunctionNode::overloadNumber() const
     
    9121044
    9131045/*!
     1046  Returns the number of times this function name has been
     1047  overloaded, obtained from the parent.
    9141048 */
    9151049int FunctionNode::numOverloads() const
     
    9191053
    9201054/*!
     1055  Returns the list of parameter names.
    9211056 */
    9221057QStringList FunctionNode::parameterNames() const
     
    9291064    }
    9301065    return names;
     1066}
     1067
     1068/*!
     1069  Returns the list of reconstructed parameters. If \a values
     1070  is true, the default values are included, if any are present.
     1071 */
     1072QStringList FunctionNode::reconstructParams(bool values) const
     1073{
     1074    QStringList params;
     1075    QList<Parameter>::ConstIterator p = parameters().begin();
     1076    while (p != parameters().end()) {
     1077        params << (*p).reconstruct(values);
     1078        ++p;
     1079    }
     1080    return params;
     1081}
     1082
     1083/*!
     1084  Reconstructs and returns the function's signature. If \a values
     1085  is true, the default values of the parameters are included, if
     1086  present.
     1087 */
     1088QString FunctionNode::signature(bool values) const
     1089{
     1090    QString s;
     1091    if (!returnType().isEmpty())
     1092        s = returnType() + " ";
     1093    s += name() + "(";
     1094    QStringList params = reconstructParams(values);
     1095    int p = params.size();
     1096    if (p > 0) {
     1097        for (int i=0; i<p; i++) {
     1098            s += params[i];
     1099            if (i < (p-1))
     1100                s += ", ";
     1101        }
     1102    }
     1103    s += ")";
     1104    return s;
     1105}
     1106
     1107/*!
     1108  Print some debugging stuff.
     1109 */
     1110void FunctionNode::debug() const
     1111{
     1112    qDebug() << "QML METHOD" << name() << "rt" << rt << "pp" << pp;
    9311113}
    9321114
     
    10221204}
    10231205
     1206#ifdef QDOC_QML
     1207bool QmlClassNode::qmlOnly = false;
     1208
     1209/*!
     1210  Constructor for the Qml class node.
     1211 */
     1212QmlClassNode::QmlClassNode(InnerNode *parent,
     1213                           const QString& name,
     1214                           const ClassNode* cn)
     1215    : FakeNode(parent, name, QmlClass), cnode(cn)
     1216{
     1217    setTitle((qmlOnly ? "" : "QML ") + name + " Element Reference");
     1218}
     1219
     1220/*!
     1221  The base file name for this kind of node has "qml_"
     1222  prepended to it.
     1223
     1224  But not yet. Still testing.
     1225 */
     1226QString QmlClassNode::fileBase() const
     1227{
     1228#if 0   
     1229    if (Node::fileBase() == "item")
     1230        qDebug() << "FILEBASE: qmlitem" << name();
     1231    return "qml_" + Node::fileBase();
     1232#endif
     1233    return Node::fileBase();
     1234}
     1235
     1236/*!
     1237  Constructor for the Qml property group node. \a parent is
     1238  always a QmlClassNode.
     1239 */
     1240QmlPropGroupNode::QmlPropGroupNode(QmlClassNode* parent,
     1241                                   const QString& name,
     1242                                   bool attached)
     1243    : FakeNode(parent, name, QmlPropertyGroup),
     1244      isdefault(false),
     1245      att(attached)
     1246{
     1247    // nothing.
     1248}
     1249
     1250/*!
     1251  Constructor for the QML property node.
     1252 */
     1253QmlPropertyNode::QmlPropertyNode(QmlPropGroupNode *parent,
     1254                                 const QString& name,
     1255                                 const QString& type,
     1256                                 bool attached)
     1257    : LeafNode(QmlProperty, parent, name),
     1258      dt(type),
     1259      sto(Trool_Default),
     1260      des(Trool_Default),
     1261      att(attached)
     1262{
     1263    // nothing.
     1264}
     1265
     1266/*!
     1267  I don't know what this is.
     1268 */
     1269QmlPropertyNode::Trool QmlPropertyNode::toTrool(bool boolean)
     1270{
     1271    return boolean ? Trool_True : Trool_False;
     1272}
     1273
     1274/*!
     1275  I don't know what this is either.
     1276 */
     1277bool QmlPropertyNode::fromTrool(Trool troolean, bool defaultValue)
     1278{
     1279    switch (troolean) {
     1280    case Trool_True:
     1281        return true;
     1282    case Trool_False:
     1283        return false;
     1284    default:
     1285        return defaultValue;
     1286    }
     1287}
     1288#endif
     1289
    10241290QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.