diff options
author | kh1 <qt-info@nokia.com> | 2010-09-24 14:44:59 (GMT) |
---|---|---|
committer | kh1 <qt-info@nokia.com> | 2010-09-27 10:07:23 (GMT) |
commit | 7aec069a0edee1593e8bdb60995609edc18b2574 (patch) | |
tree | 48a2cfd0a2e142e660ec898d03ef39328393813d /tools/assistant/lib | |
parent | bcb4dbebe2f6216842ce443bfc6d126943020a35 (diff) | |
download | Qt-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/lib')
-rw-r--r-- | tools/assistant/lib/qhelpsearchquerywidget.cpp | 84 | ||||
-rw-r--r-- | tools/assistant/lib/qhelpsearchquerywidget.h | 4 |
2 files changed, 66 insertions, 22 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(); |