Merge pull request #5279 from nextcloud/bugfix/fix-full-text-search-items

Fix full-text search results not being opened in browser
This commit is contained in:
Claudio Cambra 2023-01-06 20:09:33 +01:00 committed by GitHub
commit 382b322cb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View file

@ -579,15 +579,6 @@ void UnifiedSearchResultsListModel::parseResultsForProvider(const QJsonObject &d
QVector<UnifiedSearchResult> newEntries;
const auto makeResourceUrl = [](const QString &resourceUrl, const QUrl &accountUrl) {
QUrl finalResurceUrl(resourceUrl);
if (finalResurceUrl.scheme().isEmpty() && accountUrl.scheme().isEmpty()) {
finalResurceUrl = accountUrl;
finalResurceUrl.setPath(resourceUrl);
}
return finalResurceUrl;
};
for (const auto &entry : entries) {
const auto entryMap = entry.toMap();
if (entryMap.isEmpty()) {
@ -601,10 +592,10 @@ void UnifiedSearchResultsListModel::parseResultsForProvider(const QJsonObject &d
result._title = entryMap.value(QStringLiteral("title")).toString();
result._subline = entryMap.value(QStringLiteral("subline")).toString();
const auto resourceUrl = entryMap.value(QStringLiteral("resourceUrl")).toString();
const auto resourceUrl = entryMap.value(QStringLiteral("resourceUrl")).toUrl();
const auto accountUrl = (_accountState && _accountState->account()) ? _accountState->account()->url() : QUrl();
result._resourceUrl = makeResourceUrl(resourceUrl, accountUrl);
result._resourceUrl = openableResourceUrl(resourceUrl, accountUrl);
const auto darkIconsData = iconsFromThumbnailAndFallbackIcon(entryMap.value(QStringLiteral("thumbnailUrl")).toString(),
entryMap.value(QStringLiteral("icon")).toString(), accountUrl, true);
const auto lightIconsData = iconsFromThumbnailAndFallbackIcon(entryMap.value(QStringLiteral("thumbnailUrl")).toString(),
@ -624,6 +615,17 @@ void UnifiedSearchResultsListModel::parseResultsForProvider(const QJsonObject &d
}
}
QUrl UnifiedSearchResultsListModel::openableResourceUrl(const QUrl &resourceUrl, const QUrl &accountUrl)
{
if (!resourceUrl.isRelative()) {
return resourceUrl;
}
QUrl finalResourceUrl(accountUrl);
finalResourceUrl.setPath(resourceUrl.toString());
return finalResourceUrl;
}
void UnifiedSearchResultsListModel::appendResults(QVector<UnifiedSearchResult> results, const UnifiedSearchProvider &provider)
{
if (provider._cursor > 0 && provider._isPaginated) {

View file

@ -119,6 +119,8 @@ private slots:
void slotSearchForProviderFinished(const QJsonDocument &json, int statusCode);
private:
static QUrl openableResourceUrl(const QUrl &resourceUrl, const QUrl &accountUrl);
QMap<QString, UnifiedSearchProvider> _providers;
QVector<UnifiedSearchResult> _results;