- const int maxWidth = metrics.averageCharWidth() * 15;
- const QString fileName = metrics.elidedText(url.fileName(), Qt::ElideMiddle, maxWidth);
- m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", fileName));
+ const int maxWidth = metrics.height() * 8;
+
+ QString location = url.fileName();
+ if (location.isEmpty()) {
+ if (url.isLocalFile()) {
+ location = QLatin1String("/");
+ } else {
+ location = url.protocol() + QLatin1String(" - ") + url.host();
+ }
+ }
+
+ const QString elidedLocation = metrics.elidedText(location, Qt::ElideMiddle, maxWidth);
+ m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", elidedLocation));
+
+ const bool showSearchFromButtons = url.isLocalFile();
+ m_separator->setVisible(showSearchFromButtons);
+ m_fromHereButton->setVisible(showSearchFromButtons);
+ m_everywhereButton->setVisible(showSearchFromButtons);
+
+ bool hasFacetsSupport = false;
+#ifdef HAVE_BALOO
+ const Baloo::IndexerConfig searchInfo;
+ hasFacetsSupport = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
+#endif
+ m_facetsWidget->setEnabled(hasFacetsSupport);