diff options
Diffstat (limited to 'tools/assistant/lib')
-rw-r--r-- | tools/assistant/lib/fulltextsearch/fulltextsearch.pro | 2 | ||||
-rw-r--r-- | tools/assistant/lib/fulltextsearch/qanalyzer.cpp | 10 | ||||
-rw-r--r-- | tools/assistant/lib/lib.pro | 2 | ||||
-rw-r--r-- | tools/assistant/lib/qhelpsearchquerywidget.cpp | 84 | ||||
-rw-r--r-- | tools/assistant/lib/qhelpsearchquerywidget.h | 4 |
5 files changed, 78 insertions, 24 deletions
diff --git a/tools/assistant/lib/fulltextsearch/fulltextsearch.pro b/tools/assistant/lib/fulltextsearch/fulltextsearch.pro index 4d2fddb..d0e7a87 100644 --- a/tools/assistant/lib/fulltextsearch/fulltextsearch.pro +++ b/tools/assistant/lib/fulltextsearch/fulltextsearch.pro @@ -23,7 +23,7 @@ contains(QT_CONFIG, reduce_exports) { linux*-g++*:DEFINES += _GLIBCXX_EXTERN_TEMPLATE=0 } -unix:QMAKE_PKGCONFIG_REQUIRES = QtCore +unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore # impossible to disable exceptions in clucene atm CONFIG(exceptions_off) { diff --git a/tools/assistant/lib/fulltextsearch/qanalyzer.cpp b/tools/assistant/lib/fulltextsearch/qanalyzer.cpp index d6b00a0..71dd2c9 100644 --- a/tools/assistant/lib/fulltextsearch/qanalyzer.cpp +++ b/tools/assistant/lib/fulltextsearch/qanalyzer.cpp @@ -96,6 +96,11 @@ QCLuceneStandardAnalyzer::QCLuceneStandardAnalyzer(const QStringList &stopWords) tArray[stopWords.count()] = 0; d->analyzer = new lucene::analysis::standard::StandardAnalyzer(tArray); + + for (int i = 0; i < stopWords.count(); ++i) + delete [] tArray[i]; + + delete [] tArray; } @@ -147,6 +152,11 @@ QCLuceneStopAnalyzer::QCLuceneStopAnalyzer(const QStringList &stopWords) tArray[stopWords.count()] = 0; d->analyzer = new lucene::analysis::StopAnalyzer(tArray); + + for (int i = 0; i < stopWords.count(); ++i) + delete [] tArray[i]; + + delete [] tArray; } QStringList QCLuceneStopAnalyzer::englishStopWords() const diff --git a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro index 26d3456..03821b2 100644 --- a/tools/assistant/lib/lib.pro +++ b/tools/assistant/lib/lib.pro @@ -19,7 +19,7 @@ if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { win32:qclucene = $${qclucene}d } linux-lsb-g++:LIBS_PRIVATE += --lsb-shared-libs=$$qclucene -unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \ +unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \ QtSql \ QtXml LIBS_PRIVATE += -l$$qclucene diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp index c917907..e6a789a 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 8cf4b2b..e9fb61c 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(); |