diff options
Diffstat (limited to 'src/tools/qdoc/ditaxmlgenerator.cpp')
| -rw-r--r-- | src/tools/qdoc/ditaxmlgenerator.cpp | 147 |
1 files changed, 44 insertions, 103 deletions
diff --git a/src/tools/qdoc/ditaxmlgenerator.cpp b/src/tools/qdoc/ditaxmlgenerator.cpp index c2a5cdb8b8f..83d89d01873 100644 --- a/src/tools/qdoc/ditaxmlgenerator.cpp +++ b/src/tools/qdoc/ditaxmlgenerator.cpp @@ -3444,7 +3444,7 @@ void DitaXmlGenerator::writeText(const QString& markedCode, const Node* relative text.clear(); } par1 = QStringRef(); - n = qdb_->resolveFunctionTarget(arg.toString(), relative); + n = qdb_->findFunctionNode(arg.toString(), relative, Node::DontCare); addLink(linkForNode(n, relative), arg); break; case 1: @@ -3455,7 +3455,7 @@ void DitaXmlGenerator::writeText(const QString& markedCode, const Node* relative text.clear(); } par1 = QStringRef(); - n = qdb_->resolveType(arg.toString(), relative); + n = qdb_->findTypeNode(arg.toString(), relative); if (n && n->isQmlBasicType()) { if (relative && relative->isQmlType()) addLink(linkForNode(n, relative), arg); @@ -3733,65 +3733,50 @@ QString DitaXmlGenerator::fileName(const Node* node) */ QString DitaXmlGenerator::getLink(const Atom *atom, const Node *relative, const Node** node) { - if (atom->string().contains(QLatin1Char(':')) && (atom->string().startsWith("file:") || - atom->string().startsWith("http:") || - atom->string().startsWith("https:") || - atom->string().startsWith("ftp:") || - atom->string().startsWith("mailto:"))) { - return atom->string(); // It's some kind of protocol. + const QString& t = atom->string(); + if (t.at(0) == QChar('h')) { + if (t.startsWith("http:") || t.startsWith("https:")) + return t; + } + else if (t.at(0) == QChar('f')) { + if (t.startsWith("file:") || t.startsWith("ftp:")) + return t; + } + else if (t.at(0) == QChar('m')) { + if (t.startsWith("mailto:")) + return t; } QString ref; - QString link; - QStringList path = atom->string().split("#"); - QString first = path.first().trimmed(); - *node = 0; - if (first.isEmpty()) - *node = relative; // search for a target on the current page. - else { - if (first.endsWith(".html")) { // The target is an html file. - *node = qdb_->findNodeByNameAndType(QStringList(first), Node::Document); - } - else if (first.endsWith("()")) { // The target is a C++ function or QML method. - *node = qdb_->resolveFunctionTarget(first, relative); - } - else { - *node = qdb_->resolveTarget(first, relative); - if (!(*node)) - *node = qdb_->findDocNodeByTitle(first); - if (!(*node)) { - *node = qdb_->findUnambiguousTarget(first, ref); - if (*node && !(*node)->url().isEmpty() && !ref.isEmpty()) { - QString final = (*node)->url() + "#" + ref; - return final; - } - } - } - } + *node = qdb_->findNodeForAtom(atom, relative, ref); if (!(*node)) - return link; // empty - - if (!(*node)->url().isEmpty()) - return (*node)->url(); + return QString(); - if (!path.isEmpty()) { - ref = qdb_->findTarget(path.first(), *node); + QString url = (*node)->url(); + if (!url.isEmpty()) { if (ref.isEmpty()) - return link; // empty + return url; + int hashtag = url.lastIndexOf(QChar('#')); + if (hashtag != -1) + url.truncate(hashtag); + return url + "#" + ref; } - /* Given that *node is not null, we now cconstruct a link to the page that *node represents, and then if we found a target on that page, we connect the target to the link with '#'. */ - link = linkForNode(*node, relative); + QString link = linkForNode(*node, relative); if (*node && (*node)->subType() == Node::Image) link = "images/used-in-examples/" + link; - if (!ref.isEmpty()) + if (!ref.isEmpty()) { + int hashtag = link.lastIndexOf(QChar('#')); + if (hashtag != -1) + link.truncate(hashtag); link += QLatin1Char('#') + ref; + } return link; } @@ -3810,31 +3795,20 @@ QString DitaXmlGenerator::getAutoLink(const Atom *atom, const Node *relative, co { QString ref; QString link; - QString target = atom->string().trimmed(); - *node = 0; - - if (target.endsWith("()")) { // The target is a C++ function or QML method. - *node = qdb_->resolveFunctionTarget(target, relative); - } - else { - *node = qdb_->resolveTarget(target, relative); - if (!(*node)) { - *node = qdb_->findDocNodeByTitle(target); - } - if (!(*node)) { - *node = qdb_->findUnambiguousTarget(target, ref); - if (*node && !(*node)->url().isEmpty() && !ref.isEmpty()) { - QString final = (*node)->url() + "#" + ref; - return final; - } - } - } + *node = qdb_->findNodeForAtom(atom, relative, ref); if (!(*node)) - return link; // empty + return QString(); - if (!(*node)->url().isEmpty()) - return (*node)->url(); + QString url = (*node)->url(); + if (!url.isEmpty()) { + if (ref.isEmpty()) + return url; + int hashtag = url.lastIndexOf(QChar('#')); + if (hashtag != -1) + url.truncate(hashtag); + return url + "#" + ref; + } link = linkForNode(*node, relative); if (!ref.isEmpty()) @@ -3963,40 +3937,7 @@ void DitaXmlGenerator::generateStatus(const Node* node, CodeMarker* marker) Generator::generateStatus(node, marker); break; case Node::Compat: - if (node->isInnerNode()) { - text << Atom::ParaLeft - << Atom(Atom::FormattingLeft,ATOM_FORMATTING_BOLD) - << "This " - << typeString(node) - << " is part of the Qt 3 support library." - << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) - << " It is provided to keep old source code working. " - << "We strongly advise against " - << "using it in new code. See "; - - const DocNode *docNode = qdb_->findDocNodeByTitle("Porting To Qt 4"); - QString ref; - if (docNode && node->type() == Node::Class) { - QString oldName(node->name()); - oldName.remove(QLatin1Char('3')); - ref = qdb_->findTarget(oldName,docNode); - } - - if (!ref.isEmpty()) { - QString fn = fileName(docNode); - QString guid = lookupGuid(fn, ref); - text << Atom(Atom::GuidLink, fn + QLatin1Char('#') + guid); - } - else - text << Atom(Atom::Link, "Porting to Qt 4"); - - text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) - << Atom(Atom::String, "Porting to Qt 4") - << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK) - << " for more information." - << Atom::ParaRight; - } - generateText(text, node, marker); + // Porting to Qt 4 no longer supported break; default: Generator::generateStatus(node, marker); @@ -4652,7 +4593,7 @@ void DitaXmlGenerator::replaceTypesWithLinks(const Node* n, const InnerNode* par } i += 2; if (parseArg(src, typeTag, &i, srcSize, &arg, &par1)) { - const Node* tn = qdb_->resolveType(arg.toString(), parent); + const Node* tn = qdb_->findTypeNode(arg.toString(), parent); if (tn) { //Do not generate a link from a C++ function to a QML Basic Type (such as int) if (n->isFunction() && tn->isQmlBasicType()) @@ -6159,7 +6100,7 @@ void DitaXmlGenerator::generateCollisionPages() int count = 0; for (int i=0; i<collisions.size(); ++i) { InnerNode* n = static_cast<InnerNode*>(collisions.at(i)); - if (n->findChildNode(t.key())) { + if (n->findChildNode(t.key(), Node::DontCare)) { ++count; if (count > 1) { targets.append(t.key()); @@ -6181,7 +6122,7 @@ void DitaXmlGenerator::generateCollisionPages() writeStartTag(DT_ul); for (int i=0; i<collisions.size(); ++i) { InnerNode* n = static_cast<InnerNode*>(collisions.at(i)); - Node* p = n->findChildNode(*t); + Node* p = n->findChildNode(*t, Node::DontCare); if (p) { QString link = linkForNode(p,0); QString label; |
