From 997e2e53481de4d4bda9cfa9d01335d1a1201747 Mon Sep 17 00:00:00 2001
From: kh1 <qt-info@nokia.com>
Date: Thu, 30 Sep 2010 14:41:47 +0200
Subject: [PATCH] Some properties are not being highlighted in context
 sensitive help.

This happens because the may have a different name (like it's frament)
which we now look for while parsing the html for the function name.

Task-number: QTCREATORBUG-2217
Reviewed-by: ck
---
 src/plugins/help/helpplugin.cpp | 36 ++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index 2be35d46004..043e3ed2d44 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -843,9 +843,12 @@ void HelpPlugin::activateContext()
             int version = 0;
             const QRegExp exp("(\\d+)");
             QUrl source = *links.begin();
+            const QLatin1String qtRefDoc = QLatin1String("com.trolltech.qt");
+
+            // workaround to show the latest qt version
             foreach (const QUrl &tmp, links) {
                 const QString &authority = tmp.authority();
-                if (authority.startsWith(QLatin1String("com.trolltech.qt"))) {
+                if (authority.startsWith(qtRefDoc)) {
                     if (exp.indexIn(authority) >= 0) {
                         const int tmpVersion = exp.cap(1).toInt();
                         if (tmpVersion > version) {
@@ -855,18 +858,31 @@ void HelpPlugin::activateContext()
                     }
                 }
             }
+
             const QUrl &oldSource = viewer->source();
             if (source != oldSource) {
 #if !defined(QT_NO_WEBKIT)
                 viewer->stop();
 #endif
+                const QString &fragment = source.fragment();
+                const bool isQtRefDoc = source.authority().startsWith(qtRefDoc);
+                if (isQtRefDoc) {
+                    // workaround for qt properties
+                    m_idFromContext = fragment;
+
+                    if (!m_idFromContext.isEmpty()) {
+                        connect(viewer, SIGNAL(loadFinished(bool)), this,
+                            SLOT(highlightSearchTerms()));
+                    }
+                }
+
                 viewer->setSource(source);
-                connect(viewer, SIGNAL(loadFinished(bool)), this,
-                    SLOT(highlightSearchTerms()));
 
-                if (source.toString().remove(source.fragment())
-                    == oldSource.toString().remove(oldSource.fragment())) {
+                if (isQtRefDoc && !m_idFromContext.isEmpty()) {
+                    if (source.toString().remove(fragment)
+                        == oldSource.toString().remove(oldSource.fragment())) {
                         highlightSearchTerms();
+                    }
                 }
             } else {
 #if !defined(QT_NO_WEBKIT)
@@ -1026,11 +1042,6 @@ void HelpPlugin::highlightSearchTerms()
             SLOT(highlightSearchTerms()));
 
 #if !defined(QT_NO_WEBKIT)
-        const QString &attrValue = m_idFromContext.mid(m_idFromContext
-            .lastIndexOf(QChar(':')) + 1);
-        if (attrValue.isEmpty())
-            return;
-
         const QWebElement &document = viewer->page()->mainFrame()->documentElement();
         const QWebElementCollection &collection = document.findAll(QLatin1String("h3.fn a"));
 
@@ -1046,14 +1057,15 @@ void HelpPlugin::highlightSearchTerms()
                 parent.setStyleProperty(property, m_styleProperty);
             }
 
-            if (attrValue == name || name.startsWith(attrValue + QLatin1Char('-'))) {
+            if (m_idFromContext == name
+                || name.startsWith(m_idFromContext + QLatin1Char('-'))) {
                 QWebElement parent = element.parent();
                 m_styleProperty = parent.styleProperty(property,
                     QWebElement::ComputedStyle);
                 parent.setStyleProperty(property, QLatin1String("yellow"));
             }
         }
-        m_oldAttrValue = attrValue;
+        m_oldAttrValue = m_idFromContext;
 #endif
     }
 }
-- 
GitLab