@@ -324,29 +324,48 @@ bool UnifiedSearchResultsListModel::isSearchInProgress() const
324324 return !_searchJobConnections.isEmpty ();
325325}
326326
327- void UnifiedSearchResultsListModel::resultClicked (const QString &providerId, const QUrl &resourceUrl) const
327+ void UnifiedSearchResultsListModel::resultClicked (
328+ const QString &providerId, const QUrl &resourceUrl, const QString &subline, const QString &title
329+ ) const
328330{
329- const QUrlQuery urlQuery{resourceUrl};
330- const auto dir = urlQuery.queryItemValue (QStringLiteral (" dir" ), QUrl::ComponentFormattingOption::FullyDecoded);
331- const auto fileName =
332- urlQuery.queryItemValue (QStringLiteral (" scrollto" ), QUrl::ComponentFormattingOption::FullyDecoded);
333-
334- if (providerId.contains (QStringLiteral (" file" ), Qt::CaseInsensitive) && !dir.isEmpty () && !fileName.isEmpty ()) {
335- if (!_accountState || !_accountState->account ()) {
336- return ;
331+ if (_accountState == nullptr || _accountState->account () == nullptr || !providerId.contains (QStringLiteral (" file" ), Qt::CaseInsensitive)) {
332+ qCInfo (lcUnifiedSearch) << " immediately returning from resultClicked" ;
333+ return ;
334+ }
335+
336+ const QUrlQuery urlQuery{resourceUrl};
337+ QString dir = urlQuery.queryItemValue (QStringLiteral (" dir" ), QUrl::ComponentFormattingOption::FullyDecoded);
338+ QString fileName = urlQuery.queryItemValue (QStringLiteral (" scrollto" ), QUrl::ComponentFormattingOption::FullyDecoded);
339+
340+ QString relativePath;
341+ // server version above 20
342+ if (dir.isEmpty () && fileName.isEmpty () && !title.isEmpty ()) {
343+ if (!subline.isEmpty ()) {
344+ dir = subline;
345+ dir.remove (0 ,3 );
346+ fileName = QLatin1Char (' /' ) + title;
337347 }
348+ else {
349+ dir = title;
350+ }
351+ relativePath = dir + fileName;
352+ }
353+ // server version 20
354+ else {
355+ relativePath = dir + QLatin1Char (' /' ) + fileName;
356+ }
338357
339- const QString relativePath = dir + QLatin1Char (' /' ) + fileName;
340- const auto localFiles =
341- FolderMan::instance ()->findFileInLocalFolders (QFileInfo (relativePath).path (), _accountState->account ());
358+ qCInfo (lcUnifiedSearch) << " relativePath: " << relativePath;
359+ const QStringList localFiles = FolderMan::instance ()->findFileInLocalFolders (relativePath, _accountState->account ());
342360
343- if (!localFiles.isEmpty ()) {
344- qCInfo (lcUnifiedSearch) << " Opening file:" << localFiles.constFirst ();
345- QDesktopServices::openUrl (QUrl::fromLocalFile (localFiles.constFirst ()));
346- return ;
347- }
361+ if (!localFiles.isEmpty ()) {
362+ qCInfo (lcUnifiedSearch) << " Opening requested file or folder locally:" << localFiles.constFirst ();
363+ QDesktopServices::openUrl (QUrl::fromLocalFile (localFiles.constFirst ()));
364+ }
365+ else {
366+ qCInfo (lcUnifiedSearch) << " Opening requested file or folder in webbrowser: " << localFiles.constFirst ();
367+ Utility::openBrowser (resourceUrl);
348368 }
349- Utility::openBrowser (resourceUrl);
350369}
351370
352371void UnifiedSearchResultsListModel::fetchMoreTriggerClicked (const QString &providerId)
0 commit comments