mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Extract makeResourceUrl lambda into separate static openableUrl method
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
37830c4bc4
commit
481298997c
2 changed files with 14 additions and 11 deletions
|
@ -579,16 +579,6 @@ void UnifiedSearchResultsListModel::parseResultsForProvider(const QJsonObject &d
|
||||||
|
|
||||||
QVector<UnifiedSearchResult> newEntries;
|
QVector<UnifiedSearchResult> newEntries;
|
||||||
|
|
||||||
const auto makeResourceUrl = [](const QUrl &resourceUrl, const QUrl &accountUrl) {
|
|
||||||
if (!resourceUrl.isRelative()) {
|
|
||||||
return resourceUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUrl finalResourceUrl(accountUrl);
|
|
||||||
finalResourceUrl.setPath(resourceUrl.toString());
|
|
||||||
return finalResourceUrl;
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto &entry : entries) {
|
for (const auto &entry : entries) {
|
||||||
const auto entryMap = entry.toMap();
|
const auto entryMap = entry.toMap();
|
||||||
if (entryMap.isEmpty()) {
|
if (entryMap.isEmpty()) {
|
||||||
|
@ -605,7 +595,7 @@ void UnifiedSearchResultsListModel::parseResultsForProvider(const QJsonObject &d
|
||||||
const auto resourceUrl = entryMap.value(QStringLiteral("resourceUrl")).toUrl();
|
const auto resourceUrl = entryMap.value(QStringLiteral("resourceUrl")).toUrl();
|
||||||
const auto accountUrl = (_accountState && _accountState->account()) ? _accountState->account()->url() : QUrl();
|
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(),
|
const auto darkIconsData = iconsFromThumbnailAndFallbackIcon(entryMap.value(QStringLiteral("thumbnailUrl")).toString(),
|
||||||
entryMap.value(QStringLiteral("icon")).toString(), accountUrl, true);
|
entryMap.value(QStringLiteral("icon")).toString(), accountUrl, true);
|
||||||
const auto lightIconsData = iconsFromThumbnailAndFallbackIcon(entryMap.value(QStringLiteral("thumbnailUrl")).toString(),
|
const auto lightIconsData = iconsFromThumbnailAndFallbackIcon(entryMap.value(QStringLiteral("thumbnailUrl")).toString(),
|
||||||
|
@ -625,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)
|
void UnifiedSearchResultsListModel::appendResults(QVector<UnifiedSearchResult> results, const UnifiedSearchProvider &provider)
|
||||||
{
|
{
|
||||||
if (provider._cursor > 0 && provider._isPaginated) {
|
if (provider._cursor > 0 && provider._isPaginated) {
|
||||||
|
|
|
@ -119,6 +119,8 @@ private slots:
|
||||||
void slotSearchForProviderFinished(const QJsonDocument &json, int statusCode);
|
void slotSearchForProviderFinished(const QJsonDocument &json, int statusCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static QUrl openableResourceUrl(const QUrl &resourceUrl, const QUrl &accountUrl);
|
||||||
|
|
||||||
QMap<QString, UnifiedSearchProvider> _providers;
|
QMap<QString, UnifiedSearchProvider> _providers;
|
||||||
QVector<UnifiedSearchResult> _results;
|
QVector<UnifiedSearchResult> _results;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue