+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()));
+ }
+
+ 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);
+
+ // The m_facetsWidget might have changed visibility. We smoothly animate towards the updated height.
+ if (isVisible() && isEnabled()) {
+ setVisible(true, WithAnimation);
+ }
+}
+
+bool DolphinSearchBox::isIndexingEnabled() const
+{
+#if HAVE_BALOO
+ const Baloo::IndexerConfig searchInfo;
+ return searchInfo.fileIndexingEnabled() && !searchPath().isEmpty() && searchInfo.shouldBeIndexed(searchPath().toLocalFile());
+#else
+ return false;
+#endif
+}
+
+int DolphinSearchBox::preferredHeight() const
+{
+ return m_initialized ? m_topLayout->sizeHint().height() : 0;
+}
+
+#include "moc_dolphinsearchbox.cpp"