+ if (m_searchLocations == SearchLocations::FromHere) {
+ QString prettySearchLocation;
+ KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
+ QModelIndex url_index = placesModel->closestItem(m_searchPath);
+ if (url_index.isValid() && placesModel->url(url_index).matches(m_searchPath, QUrl::StripTrailingSlash)) {
+ prettySearchLocation = placesModel->text(url_index);
+ } else {
+ prettySearchLocation = m_searchPath.fileName();
+ }
+ if (prettySearchLocation.isEmpty()) {
+ if (m_searchPath.isLocalFile()) {
+ prettySearchLocation = KShell::tildeCollapse(m_searchPath.adjusted(QUrl::StripTrailingSlash).toLocalFile());
+ } else {
+ prettySearchLocation = m_searchPath.toString(QUrl::RemoveAuthority | QUrl::StripTrailingSlash);
+ }
+ }
+
+ // A great title clearly identifies a search results page among many tabs, windows, or links in the Places panel.
+ // Using the search term is phenomenal for this because the user has typed this very specific string with a clear intention, so we definitely want to
+ // reuse the search term in the title if possible.
+ if (!m_searchTerm.isEmpty()) {
+ if (m_searchThrough == SearchThrough::FileNames) {
+ return i18nc("@title of a search results page. %1 is the search term a user entered, %2 is a folder name",
+ "Search results for “%1” in %2",
+ m_searchTerm,
+ prettySearchLocation);
+ }
+ Q_ASSERT(m_searchThrough == SearchThrough::FileContents);
+ return i18nc("@title of a search results page. %1 is the search term a user entered, %2 is a folder name",
+ "Files containing “%1” in %2",
+ m_searchTerm,
+ prettySearchLocation);
+ }
+ if (!m_requiredTags.isEmpty()) {
+ if (m_requiredTags.count() == 1) {
+ return i18nc("@title of a search results page. %1 is a tag e.g. 'important'. %2 is a folder name",
+ "Search items tagged “%1” in %2",
+ m_requiredTags.constFirst(),
+ prettySearchLocation);
+ }
+ return i18nc("@title of a search results page. %1 and %2 are tags e.g. 'important'. %3 is a folder name",
+ "Search items tagged “%1” and “%2” in %3",
+ m_requiredTags.constFirst(),
+ m_requiredTags.constLast(),
+ prettySearchLocation);
+ }
+ if (m_fileType != KFileMetaData::Type::Empty) {
+ return i18nc("@title of a search results page for items of a specified type. %1 is a file type e.g. 'Document', 'Folder'. %2 is a folder name",
+ "%1 search results in %2",
+ KFileMetaData::TypeInfo{m_fileType}.displayName(),
+ prettySearchLocation);
+ }
+ // Everything else failed so we use a very generic title.
+ return i18nc("@title of a search results page with items matching pre-defined conditions. %1 is a folder name",
+ "Search results in %1",
+ prettySearchLocation);
+ }
+
+ Q_ASSERT(m_searchLocations == SearchLocations::Everywhere);
+ // A great title clearly identifies a search results page among many tabs, windows, or links in the Places panel.
+ // Using the search term is phenomenal for this because the user has typed this very specific string with a clear intention, so we definitely want to reuse
+ // the search term in the title if possible.
+ if (!m_searchTerm.isEmpty()) {
+ if (m_searchThrough == SearchThrough::FileNames) {
+ return i18nc("@title of a search results page. %1 is the search term a user entered", "Search results for “%1”", m_searchTerm);
+ }
+ Q_ASSERT(m_searchThrough == SearchThrough::FileContents);
+ return i18nc("@title of a search results page. %1 is the search term a user entered", "Files containing “%1”", m_searchTerm);
+ }
+ if (!m_requiredTags.isEmpty()) {
+ if (m_requiredTags.count() == 1) {
+ return i18nc("@title of a search results page. %1 is a tag e.g. 'important'", "Search items tagged “%1”", m_requiredTags.constFirst());
+ }
+ return i18nc("@title of a search results page. %1 and %2 are tags e.g. 'important'",
+ "Search items tagged “%1” and “%2”",
+ m_requiredTags.constFirst(),
+ m_requiredTags.constLast());
+ }
+ if (m_fileType != KFileMetaData::Type::Empty) {
+ // i18n: Results page for items of a specified type. %1 is a file type e.g. 'Audio', 'Document', 'Folder', 'Archive'. 'Presentation'.
+ // If putting such a file type at the start does not work in your language in this context, you might want to translate this liberally with
+ // something along the lines of 'Search items of type “%1”'.
+ return i18nc("@title of a search. %1 is file type", "%1 search results", KFileMetaData::TypeInfo{m_fileType}.displayName());
+ }
+ // Everything else failed so we use a very generic title.
+ return i18nc("@title of a search results page with items matching pre-defined conditions", "Search results");