+QString DolphinViewContainer::captionWindowTitle() const
+{
+ if (GeneralSettings::showFullPathInTitlebar() && !isSearchModeEnabled()) {
+ if (!url().isLocalFile()) {
+ return url().adjusted(QUrl::StripTrailingSlash).toString();
+ }
+ return url().adjusted(QUrl::StripTrailingSlash).path();
+ } else {
+ return DolphinViewContainer::caption();
+ }
+}
+
+QString DolphinViewContainer::caption() const
+{
+ if (isSearchModeEnabled()) {
+ if (currentSearchText().isEmpty()){
+ return i18n("Search");
+ } else {
+ return i18n("Search for %1", currentSearchText());
+ }
+ }
+
+ KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
+ const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, QUrl(url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?")), 1, Qt::MatchRegExp);
+
+ if (!matchedPlaces.isEmpty()) {
+ return placesModel->text(matchedPlaces.first());
+ }
+
+
+ if (!url().isLocalFile()) {
+ QUrl adjustedUrl = url().adjusted(QUrl::StripTrailingSlash);
+ QString caption;
+ if (!adjustedUrl.fileName().isEmpty()) {
+ caption = adjustedUrl.fileName();
+ } else if (!adjustedUrl.path().isEmpty() && adjustedUrl.path() != "/") {
+ caption = adjustedUrl.path();
+ } else if (!adjustedUrl.host().isEmpty()) {
+ caption = adjustedUrl.host();
+ } else {
+ caption = adjustedUrl.toString();
+ }
+ return caption;
+ }
+
+ QString fileName = url().adjusted(QUrl::StripTrailingSlash).fileName();
+ if (fileName.isEmpty()) {
+ fileName = '/';
+ }
+
+ return fileName;
+}
+