+void DolphinSearchBox::updateFromQuery(const DolphinQuery &query)
+{
+ // Block all signals to avoid unnecessary "searchRequest" signals
+ // while we adjust the search text and the facet widget.
+ blockSignals(true);
+
+ const QString customDir = query.includeFolder();
+ if (!customDir.isEmpty()) {
+ setSearchPath(QUrl::fromLocalFile(customDir));
+ } else {
+ setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
+ }
+
+ // If the input box has focus, do not update to avoid messing with user typing
+ if (!m_searchInput->hasFocus()) {
+ setText(query.text());
+ }
+
+ if (query.hasContentSearch()) {
+ m_contentButton->setChecked(true);
+ } else if (query.hasFileName()) {
+ m_fileNameButton->setChecked(true);
+ }
+
+ m_facetsWidget->resetSearchTerms();
+ m_facetsWidget->setFacetType(query.type());
+ const QStringList searchTerms = query.searchTerms();
+ for (const QString &searchTerm : searchTerms) {
+ m_facetsWidget->setSearchTerm(searchTerm);
+ }
+
+ m_startSearchTimer->stop();
+ blockSignals(false);
+}
+
+void DolphinSearchBox::updateFacetsVisible()
+{
+ const bool indexingEnabled = isIndexingEnabled();
+ m_facetsWidget->setEnabled(indexingEnabled);
+ m_facetsWidget->setVisible(indexingEnabled);
+}
+
+bool DolphinSearchBox::isIndexingEnabled() const
+{
+#if HAVE_BALOO
+ const Baloo::IndexerConfig searchInfo;
+ return searchInfo.fileIndexingEnabled() && !searchPath().isEmpty() && searchInfo.shouldBeIndexed(searchPath().toLocalFile());
+#else
+ return false;
+#endif
+}