diff options
author | Leandro Melo <leandro.melo@nokia.com> | 2010-07-21 17:25:58 +0200 |
---|---|---|
committer | Leandro Melo <leandro.melo@nokia.com> | 2010-07-22 12:03:51 +0200 |
commit | 5a1983f9240e52be6df4cd3260d13eb4e9338dcd (patch) | |
tree | 09bb5b760bb06d37eca820fd4e13ca26cff496f6 /src/plugins/cppeditor/cpphoverhandler.cpp | |
parent | aae95a24a253d57374da62e7176df7155ee30ec6 (diff) | |
download | qt-creator-5a1983f9240e52be6df4cd3260d13eb4e9338dcd.tar.gz |
C++ tooltip: Integration with qdocs now only with 4.7 html marks.
Diffstat (limited to 'src/plugins/cppeditor/cpphoverhandler.cpp')
-rw-r--r-- | src/plugins/cppeditor/cpphoverhandler.cpp | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index ecb2cecc95..a8848e8752 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -63,14 +63,6 @@ using namespace CPlusPlus; using namespace Core; namespace { - QString removeQualificationIfAny(const QString &name) { - int index = name.lastIndexOf(QLatin1Char(':')); - if (index == -1) - return name; - else - return name.right(name.length() - index - 1); - } - void moveCursorToEndOfName(QTextCursor *tc) { QTextDocument *doc = tc->document(); if (!doc) @@ -334,33 +326,43 @@ void CppHoverHandler::handleLookupItemMatch(const LookupItem &lookupItem, } } - HelpCandidate::Category helpCategory; + HelpCandidate::Category helpCategory = HelpCandidate::Unknown; if (matchingDeclaration->isNamespace() || matchingDeclaration->isClass() || matchingDeclaration->isForwardClassDeclaration()) { helpCategory = HelpCandidate::ClassOrNamespace; - } else if (matchingDeclaration->isEnum()) { + } else if (matchingDeclaration->isEnum() || + matchingDeclaration->enclosingSymbol()->isEnum()) { helpCategory = HelpCandidate::Enum; } else if (matchingDeclaration->isTypedef()) { helpCategory = HelpCandidate::Typedef; - } else if (matchingDeclaration->isStatic() && - !matchingDeclaration->type()->isFunctionType()) { - helpCategory = HelpCandidate::Var; - } else { + } else if (matchingDeclaration->isFunction() || + (matchingType.isValid() && matchingType->isFunctionType())){ helpCategory = HelpCandidate::Function; } - // Help identifiers are simply the name with no signature, arguments or return type. - // They might or might not include a qualification. This is why two candidates are created. - overview.setShowArgumentNames(false); - overview.setShowReturnTypes(false); - overview.setShowFunctionSignatures(false); - const QString &simpleName = overview.prettyName(matchingDeclaration->name()); - overview.setShowFunctionSignatures(true); - const QString &specifierId = overview.prettyType(matchingType, simpleName); - - m_helpCandidates.append(HelpCandidate(simpleName, specifierId, helpCategory)); - m_helpCandidates.append(HelpCandidate(qualifiedName, specifierId, helpCategory)); + if (helpCategory != HelpCandidate::Unknown) { + // Help identifiers are simply the name with no signature, arguments or return type. + // They might or might not include a qualification. So two candidates are created. + overview.setShowArgumentNames(false); + overview.setShowReturnTypes(false); + overview.setShowFunctionSignatures(false); + const QString &simpleName = overview.prettyName(matchingDeclaration->name()); + + QString mark; + if (matchingType.isValid() && matchingType->isFunctionType()) { + overview.setShowFunctionSignatures(true); + mark = overview.prettyType(matchingType, simpleName); + } else if (matchingDeclaration->enclosingSymbol()->isEnum()) { + Symbol *enumSymbol = matchingDeclaration->enclosingSymbol()->asEnum(); + mark = overview.prettyName(enumSymbol->name()); + } else { + mark = simpleName; + } + + m_helpCandidates.append(HelpCandidate(simpleName, mark, helpCategory)); + m_helpCandidates.append(HelpCandidate(qualifiedName, mark, helpCategory)); + } } } @@ -395,30 +397,25 @@ QString CppHoverHandler::getDocContents(const HelpCandidate &help) const QMap<QString, QUrl> helpLinks = Core::HelpManager::instance()->linksForIdentifier(help.m_helpId); foreach (const QUrl &url, helpLinks) { - // The help id might or might not be qualified. But anchors and marks are not qualified. - const QString &name = removeQualificationIfAny(help.m_helpId); const QByteArray &html = Core::HelpManager::instance()->fileData(url); switch (help.m_category) { case HelpCandidate::Brief: - contents = m_htmlDocExtractor.getClassOrNamespaceBrief(html, name); + contents = m_htmlDocExtractor.getClassOrNamespaceBrief(html, help.m_docMark); break; case HelpCandidate::ClassOrNamespace: - contents = m_htmlDocExtractor.getClassOrNamespaceDescription(html, name); + contents = m_htmlDocExtractor.getClassOrNamespaceDescription(html, help.m_docMark); break; case HelpCandidate::Function: - contents = m_htmlDocExtractor.getFunctionDescription(html, help.m_markId, name); + contents = m_htmlDocExtractor.getFunctionDescription(html, help.m_docMark); break; case HelpCandidate::Enum: - contents = m_htmlDocExtractor.getEnumDescription(html, name); + contents = m_htmlDocExtractor.getEnumDescription(html, help.m_docMark); break; case HelpCandidate::Typedef: - contents = m_htmlDocExtractor.getTypedefDescription(html, name); - break; - case HelpCandidate::Var: - contents = m_htmlDocExtractor.getVarDescription(html, name); + contents = m_htmlDocExtractor.getTypedefDescription(html, help.m_docMark); break; case HelpCandidate::Macro: - contents = m_htmlDocExtractor.getMacroDescription(html, help.m_markId, name); + contents = m_htmlDocExtractor.getMacroDescription(html, help.m_docMark); break; default: break; |