Changeset 846 for trunk/tools/qdoc3/helpprojectwriter.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/qdoc3/helpprojectwriter.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 40 40 ****************************************************************************/ 41 41 42 #include <QtXml>43 42 #include <QHash> 44 43 #include <QMap> 44 45 45 46 46 #include "atom.h" … … 50 50 #include "node.h" 51 51 #include "tree.h" 52 52 53 53 54 QT_BEGIN_NAMESPACE … … 92 93 subproject.indexTitle = config.getString(subprefix + "indexTitle"); 93 94 subproject.sortPages = config.getBool(subprefix + "sortPages"); 95 94 96 readSelectors(subproject, config.getStringList(subprefix + "selectors")); 95 97 project.subprojects[name] = subproject; … … 118 120 typeHash["variable"] = Node::Variable; 119 121 typeHash["target"] = Node::Target; 122 123 124 125 126 120 127 121 128 QHash<QString, Node::SubType> subTypeHash; … … 129 136 #ifdef QDOC_QML 130 137 subTypeHash["qmlclass"] = Node::QmlClass; 138 139 131 140 #endif 132 141 … … 178 187 QStringList details; 179 188 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()) { 181 196 // "name" 182 197 if (node->type() == Node::Enum || node->type() == Node::Typedef) … … 186 201 // "id" 187 202 details << node->parent()->name()+"::"+node->name(); 188 } else if (node->type() == Node::Fake) { 203 } 204 else if (node->type() == Node::Fake) { 189 205 const FakeNode *fake = static_cast<const FakeNode *>(node); 190 #ifdef QDOC_QML191 206 if (fake->subType() == Node::QmlClass) { 192 207 details << (QmlClassNode::qmlOnly ? fake->name() : fake->fullTitle()); 193 208 details << "QML." + fake->name(); 194 } else 195 #endif 196 { 209 } 210 else { 197 211 details << fake->fullTitle(); 198 212 details << fake->fullTitle(); 199 213 } 200 } else { 214 } 215 else { 201 216 details << node->name(); 202 217 details << node->name(); 203 218 } 204 219 details << tree->fullDocumentLocation(node); 205 206 220 return details; 207 221 } 208 222 209 223 bool HelpProjectWriter::generateSection(HelpProject &project, 210 QXmlStreamWriter & /* writer */, const Node *node) 224 QXmlStreamWriter & /* writer */, 225 const Node *node) 211 226 { 212 227 if (!node->url().isEmpty()) … … 227 242 const FakeNode *fake = static_cast<const FakeNode *>(node); 228 243 objName = fake->fullTitle(); 229 } else 244 } 245 else 230 246 objName = tree->fullDocumentName(node); 231 247 232 248 // Only add nodes to the set for each subproject if they match a selector. 233 249 // Those that match will be listed in the table of contents. … … 236 252 SubProject subproject = project.subprojects[name]; 237 253 // No selectors: accept all nodes. 238 if (subproject.selectors.isEmpty()) 254 if (subproject.selectors.isEmpty()) 239 255 project.subprojects[name].nodes[objName] = node; 256 240 257 else if (subproject.selectors.contains(node->type())) { 241 258 // Accept only the node types in the selectors hash. … … 248 265 if (subproject.selectors[node->type()].contains(fakeNode->subType()) && 249 266 fakeNode->subType() != Node::ExternalPage && 250 !fakeNode->fullTitle().isEmpty()) 267 !fakeNode->fullTitle().isEmpty()) 251 268 252 269 project.subprojects[name].nodes[objName] = node; 270 253 271 } 254 272 } … … 291 309 292 310 case Node::Property: 311 312 313 293 314 project.keywords.append(keywordDetails(node)); 294 315 break; … … 401 422 if (!generateSection(project, writer, node)) 402 423 return; 403 424 404 425 if (node->isInnerNode()) { 405 426 const InnerNode *inner = static_cast<const InnerNode *>(node); … … 410 431 if (node->access() == Node::Private) 411 432 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 } 414 450 else { 415 451 if (node->type() == Node::Function) { … … 495 531 writer.writeAttribute("ref", href); 496 532 writer.writeAttribute("title", fakeNode->fullTitle()); 497 // qDebug() << "Title:" << fakeNode->fullTitle();498 533 499 if (fakeNode->subType() == Node::HeaderFile) { 500 534 if ((fakeNode->subType() == Node::HeaderFile) || (fakeNode->subType() == Node::QmlClass)) { 501 535 // Write subsections for all members, obsolete members and Qt 3 502 536 // members. 503 if (!project.memberStatus[node].isEmpty() ) {537 if (!project.memberStatus[node].isEmpty()) { 504 538 QString membersPath = href.left(href.size()-5) + "-members.html"; 505 539 writer.writeStartElement("section"); … … 594 628 SubProject subproject = project.subprojects[name]; 595 629 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 608 682 } 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; 626 717 } 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 } 634 724 } 635 725
Note:
See TracChangeset
for help on using the changeset viewer.