summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2010-09-24 14:44:59 (GMT)
committerkh1 <qt-info@nokia.com>2010-09-27 10:07:23 (GMT)
commit7aec069a0edee1593e8bdb60995609edc18b2574 (patch)
tree48a2cfd0a2e142e660ec898d03ef39328393813d /tools/assistant
parentbcb4dbebe2f6216842ce443bfc6d126943020a35 (diff)
downloadQt-7aec069a0edee1593e8bdb60995609edc18b2574.zip
Qt-7aec069a0edee1593e8bdb60995609edc18b2574.tar.gz
Qt-7aec069a0edee1593e8bdb60995609edc18b2574.tar.bz2
Allow fallback to fulltext search when keyword has not been found (remote).
Task-number: QTBUG-12963 Reviewed-by: ck
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/lib/qhelpsearchquerywidget.cpp84
-rw-r--r--tools/assistant/lib/qhelpsearchquerywidget.h4
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp9
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.h2
-rw-r--r--tools/assistant/tools/assistant/remotecontrol.cpp22
-rw-r--r--tools/assistant/tools/qcollectiongenerator/main.cpp11
-rw-r--r--tools/assistant/tools/shared/collectionconfiguration.cpp14
-rw-r--r--tools/assistant/tools/shared/collectionconfiguration.h4
8 files changed, 126 insertions, 24 deletions
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp
index 1634a0d..8e8b278 100644
--- a/tools/assistant/lib/qhelpsearchquerywidget.cpp
+++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp
@@ -215,37 +215,36 @@ private:
queryHist->curQuery += addend;
const QList<QHelpSearchQuery> &query =
- queryHist->queries.at(queryHist->curQuery);
+ queryHist->queries.at(queryHist->curQuery);
foreach (const QHelpSearchQuery &queryPart, query) {
- QLineEdit *lineEdit = 0;
- switch (queryPart.fieldName) {
+ if (QLineEdit *lineEdit = lineEditFor(queryPart.fieldName))
+ lineEdit->setText(queryPart.wordList.join(" "));
+ }
+
+ if (queryHist->curQuery == maxOrMinIndex)
+ thisButton->setEnabled(false);
+ otherButton->setEnabled(true);
+ }
+
+ QLineEdit* lineEditFor(const QHelpSearchQuery::FieldName &fieldName) const
+ {
+ switch (fieldName) {
case QHelpSearchQuery::DEFAULT:
- lineEdit = defaultQuery;
- break;
+ return defaultQuery;
case QHelpSearchQuery::ALL:
- lineEdit = allQuery;
- break;
+ return allQuery;
case QHelpSearchQuery::ATLEAST:
- lineEdit = atLeastQuery;
- break;
+ return atLeastQuery;
case QHelpSearchQuery::FUZZY:
- lineEdit = similarQuery;
- break;
+ return similarQuery;
case QHelpSearchQuery::WITHOUT:
- lineEdit = withoutQuery;
- break;
+ return withoutQuery;
case QHelpSearchQuery::PHRASE:
- lineEdit = exactQuery;
- break;
+ return exactQuery;
default:
Q_ASSERT(0);
- }
- lineEdit->setText(queryPart.wordList.join(" "));
}
-
- if (queryHist->curQuery == maxOrMinIndex)
- thisButton->setEnabled(false);
- otherButton->setEnabled(true);
+ return 0;
}
void enableOrDisableToolButtons()
@@ -512,8 +511,27 @@ QHelpSearchQueryWidget::~QHelpSearchQueryWidget()
}
/*!
+ Expands the search query widget so that the extended search fields are shown.
+*/
+void QHelpSearchQueryWidget::expandExtendedSearch()
+{
+ if (d->simpleSearch)
+ d->showHideAdvancedSearch();
+}
+
+/*!
+ Collapses the search query widget so that only the default search field is
+ shown.
+*/
+void QHelpSearchQueryWidget::collapseExtendedSearch()
+{
+ if (!d->simpleSearch)
+ d->showHideAdvancedSearch();
+}
+
+/*!
Returns a list of queries to use in combination with the search engines
- search(QList<QHelpSearchQuery> &query) function.
+ search(QList<QHelpSearchQuery> &queryList) function.
*/
QList<QHelpSearchQuery> QHelpSearchQueryWidget::query() const
{
@@ -524,6 +542,28 @@ QList<QHelpSearchQuery> QHelpSearchQueryWidget::query() const
}
/*!
+ Sets the QHelpSearchQueryWidget input fields to the values specified by
+ \a queryList search field name. Please note that one has to call the search
+ engine's search(QList<QHelpSearchQuery> &queryList) function to perform the
+ actual search.
+*/
+void QHelpSearchQueryWidget::setQuery(const QList<QHelpSearchQuery> &queryList)
+{
+ QList<QLineEdit *> lineEdits;
+ lineEdits << d->defaultQuery << d->allQuery << d->atLeastQuery
+ << d->similarQuery << d->withoutQuery << d->exactQuery;
+ foreach (QLineEdit *lineEdit, lineEdits)
+ lineEdit->clear();
+
+ const QLatin1String space(" ");
+ foreach (const QHelpSearchQuery &q, queryList) {
+ if (QLineEdit *lineEdit = d->lineEditFor(q.fieldName))
+ lineEdit->setText(lineEdit->text() + q.wordList.join(space) + space);
+ }
+ d->searchRequested();
+}
+
+/*!
\reimp
*/
void QHelpSearchQueryWidget::focusInEvent(QFocusEvent *focusEvent)
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.h b/tools/assistant/lib/qhelpsearchquerywidget.h
index 2afc4b4..f3c290f 100644
--- a/tools/assistant/lib/qhelpsearchquerywidget.h
+++ b/tools/assistant/lib/qhelpsearchquerywidget.h
@@ -68,7 +68,11 @@ public:
QHelpSearchQueryWidget(QWidget *parent = 0);
~QHelpSearchQueryWidget();
+ void expandExtendedSearch();
+ void collapseExtendedSearch();
+
QList<QHelpSearchQuery> query() const;
+ void setQuery(const QList<QHelpSearchQuery> &queryList);
Q_SIGNALS:
void search();
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
index 8a5bb9c..ba54dd6 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.cpp
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -693,6 +693,7 @@ void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem sys
void HelpEngineWrapper::handleCurrentFilterChanged(const QString &filter)
{
+ TRACE_OBJ
const QString &filterToReport
= filter == Unfiltered ? TrUnfiltered : filter;
emit currentFilterChanged(filterToReport);
@@ -700,14 +701,22 @@ void HelpEngineWrapper::handleCurrentFilterChanged(const QString &filter)
bool HelpEngineWrapper::showTabs() const
{
+ TRACE_OBJ
return d->m_helpEngine->customValue(ShowTabsKey, false).toBool();
}
void HelpEngineWrapper::setShowTabs(bool show)
{
+ TRACE_OBJ
d->m_helpEngine->setCustomValue(ShowTabsKey, show);
}
+bool HelpEngineWrapper::fullTextSearchFallbackEnabled() const
+{
+ TRACE_OBJ
+ return CollectionConfiguration::fullTextSearchFallbackEnabled(*d->m_helpEngine);
+}
+
// -- TimeoutForwarder
TimeoutForwarder::TimeoutForwarder(const QString &fileName)
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h
index 7349015..38bde9b 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.h
+++ b/tools/assistant/tools/assistant/helpenginewrapper.h
@@ -189,6 +189,8 @@ public:
static const QString TrUnfiltered;
+ bool fullTextSearchFallbackEnabled() const;
+
signals:
// For asynchronous doc updates triggered by external actions.
diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp
index 06e5602..51bc733 100644
--- a/tools/assistant/tools/assistant/remotecontrol.cpp
+++ b/tools/assistant/tools/assistant/remotecontrol.cpp
@@ -58,6 +58,7 @@
#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpIndexWidget>
+#include <QtHelp/QHelpSearchQueryWidget>
#ifdef Q_OS_WIN
# include "remotecontrol_win.h"
@@ -260,8 +261,25 @@ void RemoteControl::handleActivateKeywordCommand(const QString &arg)
m_activateKeyword = arg;
} else {
m_mainWindow->setIndexString(arg);
- if (!arg.isEmpty())
- helpEngine.indexWidget()->activateCurrentItem();
+ if (!arg.isEmpty()) {
+ if (!helpEngine.indexWidget()->currentIndex().isValid()
+ && helpEngine.fullTextSearchFallbackEnabled()) {
+ if (QHelpSearchEngine *se = helpEngine.searchEngine()) {
+ m_mainWindow->setSearchVisible(true);
+ if (QHelpSearchQueryWidget *w = se->queryWidget()) {
+ w->collapseExtendedSearch();
+ QList<QHelpSearchQuery> queryList;
+ queryList << QHelpSearchQuery(QHelpSearchQuery::DEFAULT,
+ QStringList(arg));
+ w->setQuery(queryList);
+ se->search(queryList);
+ }
+ }
+ } else {
+ m_mainWindow->setIndexVisible(true);
+ helpEngine.indexWidget()->activateCurrentItem();
+ }
+ }
}
}
diff --git a/tools/assistant/tools/qcollectiongenerator/main.cpp b/tools/assistant/tools/qcollectiongenerator/main.cpp
index 46e301c..1046e56 100644
--- a/tools/assistant/tools/qcollectiongenerator/main.cpp
+++ b/tools/assistant/tools/qcollectiongenerator/main.cpp
@@ -97,6 +97,10 @@ public:
QString cacheDirectory() const { return m_cacheDirectory; }
bool cacheDirRelativeToCollection() const { return m_cacheDirRelativeToCollection; }
+ bool fullTextSearchFallbackEnabled() const {
+ return m_enableFullTextSearchFallback;
+ }
+
private:
void raiseErrorWithLine();
void readConfig();
@@ -125,6 +129,7 @@ private:
QStringList m_filesToRegister;
QString m_cacheDirectory;
bool m_cacheDirRelativeToCollection;
+ bool m_enableFullTextSearchFallback;
};
void CollectionConfigReader::raiseErrorWithLine()
@@ -139,6 +144,7 @@ void CollectionConfigReader::readData(const QByteArray &contents)
m_enableAddressBar = true;
m_hideAddressBar = true;
m_enableDocumentationManager = true;
+ m_enableFullTextSearchFallback = false;
addData(contents);
while (!atEnd()) {
@@ -212,6 +218,9 @@ void CollectionConfigReader::readAssistantSettings()
attributes().value(QLatin1String("base"))
== QLatin1String("collection");
m_cacheDirectory = readElementText();
+ } else if (name() == QLatin1String("enableFullTextSearchFallback")) {
+ if (readElementText() == QLatin1String("true"))
+ m_enableFullTextSearchFallback = true;
} else {
raiseErrorWithLine();
}
@@ -511,6 +520,8 @@ int main(int argc, char *argv[])
!config.hideAddressBar());
CollectionConfiguration::setCreationTime(helpEngine,
QDateTime::currentDateTime().toTime_t());
+ CollectionConfiguration::setFullTextSearchFallbackEnabled(helpEngine,
+ config.fullTextSearchFallbackEnabled());
if (!config.applicationIcon().isEmpty()) {
QFile icon(absoluteFileName(basePath, config.applicationIcon()));
diff --git a/tools/assistant/tools/shared/collectionconfiguration.cpp b/tools/assistant/tools/shared/collectionconfiguration.cpp
index e3944b6..2272c64 100644
--- a/tools/assistant/tools/shared/collectionconfiguration.cpp
+++ b/tools/assistant/tools/shared/collectionconfiguration.cpp
@@ -71,6 +71,7 @@ namespace {
#endif
));
const QString WindowTitleKey(QLatin1String("WindowTitle"));
+ const QString FullTextSearchFallbackKey(QLatin1String("FullTextSearchFallback"));
} // anonymous namespace
const QString CollectionConfiguration::DefaultZoomFactor(QLatin1String("0.0"));
@@ -308,6 +309,19 @@ void CollectionConfiguration::copyConfiguration(const QHelpEngineCore &source,
setAboutTexts(target, aboutTexts(source));
setAboutImages(target, aboutImages(source));
setDefaultHomePage(target, defaultHomePage(source));
+ setFullTextSearchFallbackEnabled(target, fullTextSearchFallbackEnabled(source));
+}
+
+bool CollectionConfiguration:: fullTextSearchFallbackEnabled(
+ const QHelpEngineCore &helpEngine)
+{
+ return helpEngine.customValue(FullTextSearchFallbackKey, false).toBool();
+}
+
+void CollectionConfiguration::setFullTextSearchFallbackEnabled(
+ QHelpEngineCore &helpEngine, bool on)
+{
+ helpEngine.setCustomValue(FullTextSearchFallbackKey, on);
}
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/shared/collectionconfiguration.h b/tools/assistant/tools/shared/collectionconfiguration.h
index b7bf247..aeb636f 100644
--- a/tools/assistant/tools/shared/collectionconfiguration.h
+++ b/tools/assistant/tools/shared/collectionconfiguration.h
@@ -136,6 +136,10 @@ public:
static const QDateTime lastRegisterTime(const QHelpEngineCore &helpEngine);
static void updateLastRegisterTime(QHelpEngineCore &helpEngine);
+ static bool fullTextSearchFallbackEnabled(const QHelpEngineCore &helpEngine);
+ static void setFullTextSearchFallbackEnabled(QHelpEngineCore &helpEngine,
+ bool on);
+
static const QString DefaultZoomFactor;
static const QString ListSeparator;
};