Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/qdoc3/helpprojectwriter.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    4040****************************************************************************/
    4141
    42 #include <QtXml>
    4342#include <QHash>
    4443#include <QMap>
     44
    4545
    4646#include "atom.h"
     
    5050#include "node.h"
    5151#include "tree.h"
     52
    5253
    5354QT_BEGIN_NAMESPACE
     
    9293            subproject.indexTitle = config.getString(subprefix + "indexTitle");
    9394            subproject.sortPages = config.getBool(subprefix + "sortPages");
     95
    9496            readSelectors(subproject, config.getStringList(subprefix + "selectors"));
    9597            project.subprojects[name] = subproject;
     
    118120    typeHash["variable"] = Node::Variable;
    119121    typeHash["target"] = Node::Target;
     122
     123
     124
     125
     126
    120127
    121128    QHash<QString, Node::SubType> subTypeHash;
     
    129136#ifdef QDOC_QML
    130137    subTypeHash["qmlclass"] = Node::QmlClass;
     138
     139
    131140#endif
    132141
     
    178187    QStringList details;
    179188
    180     if (node->parent() && !node->parent()->name().isEmpty()) {
     189    if (node->type() == Node::QmlProperty) {
     190        // "name"
     191        details << node->name();
     192        // "id"
     193        details << node->parent()->parent()->name()+"::"+node->name();
     194    }
     195    else if (node->parent() && !node->parent()->name().isEmpty()) {
    181196        // "name"
    182197        if (node->type() == Node::Enum || node->type() == Node::Typedef)
     
    186201        // "id"
    187202        details << node->parent()->name()+"::"+node->name();
    188     } else if (node->type() == Node::Fake) {
     203    }
     204    else if (node->type() == Node::Fake) {
    189205        const FakeNode *fake = static_cast<const FakeNode *>(node);
    190 #ifdef QDOC_QML
    191206        if (fake->subType() == Node::QmlClass) {
    192207            details << (QmlClassNode::qmlOnly ? fake->name() : fake->fullTitle());
    193208            details << "QML." + fake->name();
    194         } else
    195 #endif
    196         {
     209        }
     210        else {
    197211            details << fake->fullTitle();
    198212            details << fake->fullTitle();
    199213        }
    200     } else {
     214    }
     215    else {
    201216        details << node->name();
    202217        details << node->name();
    203218    }
    204219    details << tree->fullDocumentLocation(node);
    205 
    206220    return details;
    207221}
    208222
    209223bool HelpProjectWriter::generateSection(HelpProject &project,
    210                         QXmlStreamWriter & /* writer */, const Node *node)
     224                                        QXmlStreamWriter & /* writer */,
     225                                        const Node *node)
    211226{
    212227    if (!node->url().isEmpty())
     
    227242        const FakeNode *fake = static_cast<const FakeNode *>(node);
    228243        objName = fake->fullTitle();
    229     } else
     244    }
     245    else
    230246        objName = tree->fullDocumentName(node);
    231 
     247   
    232248    // Only add nodes to the set for each subproject if they match a selector.
    233249    // Those that match will be listed in the table of contents.
     
    236252        SubProject subproject = project.subprojects[name];
    237253        // No selectors: accept all nodes.
    238         if (subproject.selectors.isEmpty())
     254        if (subproject.selectors.isEmpty())
    239255            project.subprojects[name].nodes[objName] = node;
     256
    240257        else if (subproject.selectors.contains(node->type())) {
    241258            // Accept only the node types in the selectors hash.
     
    248265                if (subproject.selectors[node->type()].contains(fakeNode->subType()) &&
    249266                    fakeNode->subType() != Node::ExternalPage &&
    250                     !fakeNode->fullTitle().isEmpty())
     267                    !fakeNode->fullTitle().isEmpty())
    251268
    252269                    project.subprojects[name].nodes[objName] = node;
     270
    253271            }
    254272        }
     
    291309
    292310        case Node::Property:
     311
     312
     313
    293314            project.keywords.append(keywordDetails(node));
    294315            break;
     
    401422    if (!generateSection(project, writer, node))
    402423        return;
    403 
     424   
    404425    if (node->isInnerNode()) {
    405426        const InnerNode *inner = static_cast<const InnerNode *>(node);
     
    410431            if (node->access() == Node::Private)
    411432                continue;
    412             if (node->type() == Node::Fake)
    413                 childMap[static_cast<const FakeNode *>(node)->fullTitle()] = node;
     433            if (node->type() == Node::Fake) {
     434                /*
     435                  Don't visit QML property group nodes,
     436                  but visit their children, which are all
     437                  QML property nodes.
     438                 */
     439                if (node->subType() == Node::QmlPropertyGroup) {
     440                    const InnerNode* inner = static_cast<const InnerNode*>(node);
     441                    foreach (const Node* n, inner->childNodes()) {
     442                        if (n->access() == Node::Private)
     443                            continue;
     444                        childMap[tree->fullDocumentName(n)] = n;
     445                    }
     446                }
     447                else
     448                    childMap[static_cast<const FakeNode *>(node)->fullTitle()] = node;
     449            }
    414450            else {
    415451                if (node->type() == Node::Function) {
     
    495531            writer.writeAttribute("ref", href);
    496532            writer.writeAttribute("title", fakeNode->fullTitle());
    497             //            qDebug() << "Title:" << fakeNode->fullTitle();
    498533           
    499             if (fakeNode->subType() == Node::HeaderFile) {
    500 
     534            if ((fakeNode->subType() == Node::HeaderFile) || (fakeNode->subType() == Node::QmlClass)) {
    501535                // Write subsections for all members, obsolete members and Qt 3
    502536                // members.
    503                 if (!project.memberStatus[node].isEmpty()) {
     537                if (!project.memberStatus[node].isEmpty()) {
    504538                    QString membersPath = href.left(href.size()-5) + "-members.html";
    505539                    writer.writeStartElement("section");
     
    594628        SubProject subproject = project.subprojects[name];
    595629
    596         if (!name.isEmpty()) {
    597             writer.writeStartElement("section");
    598             QString indexPath = tree->fullDocumentLocation(tree->findFakeNodeByTitle(subproject.indexTitle));
    599             writer.writeAttribute("ref", HtmlGenerator::cleanRef(indexPath));
    600             writer.writeAttribute("title", subproject.title);
    601             project.files.insert(indexPath);
    602         }
    603         if (subproject.sortPages) {
    604             QStringList titles = subproject.nodes.keys();
    605             titles.sort();
    606             foreach (const QString &title, titles)
    607                 writeNode(project, writer, subproject.nodes[title]);
     630        if (subproject.type == QLatin1String("manual")) {
     631
     632            const FakeNode *indexPage = tree->findFakeNodeByTitle(subproject.indexTitle);
     633            if (indexPage) {
     634                Text indexBody = indexPage->doc().body();
     635                const Atom *atom = indexBody.firstAtom();
     636                QStack<int> sectionStack;
     637                bool inItem = false;
     638
     639                while (atom) {
     640                    switch (atom->type()) {
     641                    case Atom::ListLeft:
     642                        sectionStack.push(0);
     643                        break;
     644                    case Atom::ListRight:
     645                        if (sectionStack.pop() > 0)
     646                            writer.writeEndElement(); // section
     647                        break;
     648                    case Atom::ListItemLeft:
     649                        inItem = true;
     650                        break;
     651                    case Atom::ListItemRight:
     652                        inItem = false;
     653                        break;
     654                    case Atom::Link:
     655                        if (inItem) {
     656                            if (sectionStack.top() > 0)
     657                                writer.writeEndElement(); // section
     658
     659                            const FakeNode *page = tree->findFakeNodeByTitle(atom->string());
     660                            writer.writeStartElement("section");
     661                            QString indexPath = tree->fullDocumentLocation(page);
     662                            writer.writeAttribute("ref", HtmlGenerator::cleanRef(indexPath));
     663                            writer.writeAttribute("title", atom->string());
     664                            project.files.insert(indexPath);
     665
     666                            sectionStack.top() += 1;
     667                        }
     668                        break;
     669                    default:
     670                        ;
     671                    }
     672
     673                    if (atom == indexBody.lastAtom())
     674                        break;
     675                    atom = atom->next();
     676                }
     677            } else
     678                rootNode->doc().location().warning(
     679                    tr("Failed to find index: %1").arg(subproject.indexTitle)
     680                    );
     681
    608682        } else {
    609             // Find a contents node and navigate from there, using the NextLink values.
    610             foreach (const Node *node, subproject.nodes) {
    611                 QString nextTitle = node->links().value(Node::NextLink).first;
    612                 if (!nextTitle.isEmpty() &&
    613                     node->links().value(Node::ContentsLink).first.isEmpty()) {
    614 
    615                     FakeNode *nextPage = const_cast<FakeNode *>(tree->findFakeNodeByTitle(nextTitle));
    616 
    617                     // Write the contents node.
    618                     writeNode(project, writer, node);
    619 
    620                     while (nextPage) {
    621                         writeNode(project, writer, nextPage);
    622                         nextTitle = nextPage->links().value(Node::NextLink).first;
    623                         if(nextTitle.isEmpty())
    624                             break;
    625                         nextPage = const_cast<FakeNode *>(tree->findFakeNodeByTitle(nextTitle));
     683
     684            if (!name.isEmpty()) {
     685                writer.writeStartElement("section");
     686                QString indexPath = tree->fullDocumentLocation(tree->findFakeNodeByTitle(subproject.indexTitle));
     687                writer.writeAttribute("ref", HtmlGenerator::cleanRef(indexPath));
     688                writer.writeAttribute("title", subproject.title);
     689                project.files.insert(indexPath);
     690            }
     691            if (subproject.sortPages) {
     692                QStringList titles = subproject.nodes.keys();
     693                titles.sort();
     694                foreach (const QString &title, titles) {
     695                    writeNode(project, writer, subproject.nodes[title]);
     696                }
     697            } else {
     698                // Find a contents node and navigate from there, using the NextLink values.
     699                foreach (const Node *node, subproject.nodes) {
     700                    QString nextTitle = node->links().value(Node::NextLink).first;
     701                    if (!nextTitle.isEmpty() &&
     702                        node->links().value(Node::ContentsLink).first.isEmpty()) {
     703
     704                        FakeNode *nextPage = const_cast<FakeNode *>(tree->findFakeNodeByTitle(nextTitle));
     705
     706                        // Write the contents node.
     707                        writeNode(project, writer, node);
     708
     709                        while (nextPage) {
     710                            writeNode(project, writer, nextPage);
     711                            nextTitle = nextPage->links().value(Node::NextLink).first;
     712                            if(nextTitle.isEmpty())
     713                                break;
     714                            nextPage = const_cast<FakeNode *>(tree->findFakeNodeByTitle(nextTitle));
     715                        }
     716                        break;
    626717                    }
    627                     break;
    628                 }
    629             }
    630         }
    631 
    632         if (!name.isEmpty())
    633             writer.writeEndElement(); // section
     718                }
     719            }
     720
     721            if (!name.isEmpty())
     722                writer.writeEndElement(); // section
     723        }
    634724    }
    635725
Note: See TracChangeset for help on using the changeset viewer.