Commit 997e2e53 authored by kh1's avatar kh1
Browse files

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
parent ac80d924
...@@ -843,9 +843,12 @@ void HelpPlugin::activateContext() ...@@ -843,9 +843,12 @@ void HelpPlugin::activateContext()
int version = 0; int version = 0;
const QRegExp exp("(\\d+)"); const QRegExp exp("(\\d+)");
QUrl source = *links.begin(); QUrl source = *links.begin();
const QLatin1String qtRefDoc = QLatin1String("com.trolltech.qt");
// workaround to show the latest qt version
foreach (const QUrl &tmp, links) { foreach (const QUrl &tmp, links) {
const QString &authority = tmp.authority(); const QString &authority = tmp.authority();
if (authority.startsWith(QLatin1String("com.trolltech.qt"))) { if (authority.startsWith(qtRefDoc)) {
if (exp.indexIn(authority) >= 0) { if (exp.indexIn(authority) >= 0) {
const int tmpVersion = exp.cap(1).toInt(); const int tmpVersion = exp.cap(1).toInt();
if (tmpVersion > version) { if (tmpVersion > version) {
...@@ -855,19 +858,32 @@ void HelpPlugin::activateContext() ...@@ -855,19 +858,32 @@ void HelpPlugin::activateContext()
} }
} }
} }
const QUrl &oldSource = viewer->source(); const QUrl &oldSource = viewer->source();
if (source != oldSource) { if (source != oldSource) {
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
viewer->stop(); viewer->stop();
#endif #endif
viewer->setSource(source); 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, connect(viewer, SIGNAL(loadFinished(bool)), this,
SLOT(highlightSearchTerms())); SLOT(highlightSearchTerms()));
}
}
if (source.toString().remove(source.fragment()) viewer->setSource(source);
if (isQtRefDoc && !m_idFromContext.isEmpty()) {
if (source.toString().remove(fragment)
== oldSource.toString().remove(oldSource.fragment())) { == oldSource.toString().remove(oldSource.fragment())) {
highlightSearchTerms(); highlightSearchTerms();
} }
}
} else { } else {
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
viewer->page()->mainFrame()->scrollToAnchor(source.fragment()); viewer->page()->mainFrame()->scrollToAnchor(source.fragment());
...@@ -1026,11 +1042,6 @@ void HelpPlugin::highlightSearchTerms() ...@@ -1026,11 +1042,6 @@ void HelpPlugin::highlightSearchTerms()
SLOT(highlightSearchTerms())); SLOT(highlightSearchTerms()));
#if !defined(QT_NO_WEBKIT) #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 QWebElement &document = viewer->page()->mainFrame()->documentElement();
const QWebElementCollection &collection = document.findAll(QLatin1String("h3.fn a")); const QWebElementCollection &collection = document.findAll(QLatin1String("h3.fn a"));
...@@ -1046,14 +1057,15 @@ void HelpPlugin::highlightSearchTerms() ...@@ -1046,14 +1057,15 @@ void HelpPlugin::highlightSearchTerms()
parent.setStyleProperty(property, m_styleProperty); 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(); QWebElement parent = element.parent();
m_styleProperty = parent.styleProperty(property, m_styleProperty = parent.styleProperty(property,
QWebElement::ComputedStyle); QWebElement::ComputedStyle);
parent.setStyleProperty(property, QLatin1String("yellow")); parent.setStyleProperty(property, QLatin1String("yellow"));
} }
} }
m_oldAttrValue = attrValue; m_oldAttrValue = m_idFromContext;
#endif #endif
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment