summaryrefslogtreecommitdiff
path: root/src/plugins/help/searchwidget.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2014-10-31 14:20:03 +0100
committerEike Ziller <eike.ziller@theqtcompany.com>2014-11-04 07:57:08 +0100
commitcd5e00034d7cc9bd11d26f4cbde91e2db2c12383 (patch)
tree56dfa1d2719f9afbb28af01d44d836cbe4c9ebf7 /src/plugins/help/searchwidget.cpp
parentd6a7287fb40121951d3d93296eed011c2b598832 (diff)
downloadqt-creator-cd5e00034d7cc9bd11d26f4cbde91e2db2c12383.tar.gz
Help: Fix highlighting of search terms.
It was using the wrong search help engine to get the search terms. Instead let the search widget itself figure out the search terms, and pass it directly on to the help widget when activating links. Change-Id: Ib72220eafca69e92894fe7584b1e4dfd9a42cc7e Task-number: QTCREATORBUG-13239 Reviewed-by: Robert Loehning <robert.loehning@digia.com> Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/plugins/help/searchwidget.cpp')
-rw-r--r--src/plugins/help/searchwidget.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/plugins/help/searchwidget.cpp b/src/plugins/help/searchwidget.cpp
index 706d113848..a0e428e0aa 100644
--- a/src/plugins/help/searchwidget.cpp
+++ b/src/plugins/help/searchwidget.cpp
@@ -137,7 +137,7 @@ void SearchWidget::showEvent(QShowEvent *event)
connect(queryWidget, SIGNAL(search()), this, SLOT(search()));
connect(resultWidget, &QHelpSearchResultWidget::requestShowLink, this,
[this](const QUrl &url) {
- emit linkActivated(url, false/*newPage*/);
+ emit linkActivated(url, currentSearchTerms(), false/*newPage*/);
});
connect(searchEngine, SIGNAL(searchingStarted()), this,
@@ -232,7 +232,7 @@ bool SearchWidget::eventFilter(QObject *o, QEvent *e)
bool controlPressed = me->modifiers() & Qt::ControlModifier;
if ((me->button() == Qt::LeftButton && controlPressed)
|| (me->button() == Qt::MidButton)) {
- emit linkActivated(link, true/*newPage*/);
+ emit linkActivated(link, currentSearchTerms(), true/*newPage*/);
}
}
}
@@ -269,20 +269,43 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
QAction *usedAction = menu.exec(mapToGlobal(contextMenuEvent->pos()));
if (usedAction == openLink)
- emit linkActivated(link, false/*newPage*/);
+ emit linkActivated(link, currentSearchTerms(), false/*newPage*/);
else if (usedAction == openLinkInNewTab)
- emit linkActivated(link, true/*newPage*/);
+ emit linkActivated(link, currentSearchTerms(), true/*newPage*/);
else if (usedAction == copyAnchorAction)
QApplication::clipboard()->setText(link.toString());
}
+QStringList SearchWidget::currentSearchTerms() const
+{
+ QList<QHelpSearchQuery> queryList = searchEngine->query();
+
+ QStringList terms;
+ foreach (const QHelpSearchQuery &query, queryList) {
+ switch (query.fieldName) {
+ case QHelpSearchQuery::ALL:
+ case QHelpSearchQuery::PHRASE:
+ case QHelpSearchQuery::DEFAULT:
+ case QHelpSearchQuery::ATLEAST: {
+ foreach (QString term, query.wordList)
+ terms.append(term.remove(QLatin1Char('"')));
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return terms;
+}
+
// #pragma mark -- SearchSideBarItem
SearchSideBarItem::SearchSideBarItem()
: SideBarItem(new SearchWidget, QLatin1String(Constants::HELP_SEARCH))
{
widget()->setWindowTitle(tr(Constants::SB_SEARCH));
- connect(widget(), SIGNAL(linkActivated(QUrl,bool)), this, SIGNAL(linkActivated(QUrl,bool)));
+ connect(widget(), SIGNAL(linkActivated(QUrl,QStringList,bool)),
+ this, SIGNAL(linkActivated(QUrl,QStringList,bool)));
}
QList<QToolButton *> SearchSideBarItem::createToolBarWidgets()