diff --git a/src/search/dolphinfacetswidget.h b/src/search/dolphinfacetswidget.h --- a/src/search/dolphinfacetswidget.h +++ b/src/search/dolphinfacetswidget.h @@ -58,6 +58,8 @@ void setFacetType(const QString& type); + void resetOptions(); + signals: void facetChanged(); diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp --- a/src/search/dolphinfacetswidget.cpp +++ b/src/search/dolphinfacetswidget.cpp @@ -115,6 +115,13 @@ { } +void DolphinFacetsWidget::resetOptions() +{ + m_anyType->setChecked(true); + m_anytime->setChecked(true); + m_anyRating->setChecked(true); +} + QString DolphinFacetsWidget::ratingTerm() const { QStringList terms; @@ -211,7 +218,9 @@ void DolphinFacetsWidget::setFacetType(const QString& type) { - if (type == QLatin1String("Document")) { + if (type == QLatin1String("Folder")) { + m_folders->setChecked(true); + } else if (type == QLatin1String("Document")) { m_documents->setChecked(true); } else if (type == QLatin1String("Image")) { m_images->setChecked(true); diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -81,6 +81,10 @@ void DolphinSearchBox::setSearchPath(const QUrl& url) { + if (url == m_searchPath) { + return; + } + m_searchPath = url; QFontMetrics metrics(m_fromHereButton->font()); @@ -108,6 +112,9 @@ const Baloo::IndexerConfig searchInfo; hasFacetsSupport = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile()); #endif + if (!hasFacetsSupport) { + m_facetsWidget->resetOptions(); + } m_facetsWidget->setEnabled(hasFacetsSupport); } @@ -530,22 +537,39 @@ setSearchPath(QUrl::fromLocalFile(QDir::homePath())); } - setText(query.searchString()); + m_facetsWidget->resetOptions(); QStringList types = query.types(); if (!types.isEmpty()) { m_facetsWidget->setFacetType(types.first()); } + QStringList searchTextItems; const QStringList subTerms = query.searchString().split(' ', QString::SkipEmptyParts); - foreach (const QString& subTerm, subTerms) { + for (const QString& subTerm : subTerms) { + QString value; if (subTerm.startsWith(QLatin1String("filename:"))) { - const QString value = subTerm.mid(9); - setText(value); + value = subTerm.mid(9); } else if (m_facetsWidget->isRatingTerm(subTerm)) { m_facetsWidget->setRatingTerm(subTerm); + continue; + } else if (subTerm == QStringLiteral("AND") && subTerm != subTerms.at(0) && subTerm != subTerms.back()) { + continue; + } else { + value = subTerm; + } + + if (!value.isEmpty()) { + if (value.at(0) == QLatin1Char('"')) { + value = value.mid(1); + } + if (value.back() == QLatin1Char('"')) { + value = value.mid(0, value.size()-1); + } + searchTextItems << value; } } + setText(searchTextItems.join(" ")); m_startSearchTimer->stop(); blockSignals(false);