diff options
Diffstat (limited to 'tools/assistant/lib/qhelpsearchquerywidget.cpp')
-rw-r--r-- | tools/assistant/lib/qhelpsearchquerywidget.cpp | 84 |
1 files changed, 62 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) |