diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2022-07-19 17:56:19 +0300 |
---|---|---|
committer | Hannah von Reth <hannah.vonreth@owncloud.com> | 2022-07-22 12:13:57 +0300 |
commit | 66e4f2d21200bcb922fed9989f27ac87f570783a (patch) | |
tree | b87486fc2a2bf881517826354203cb5979731149 | |
parent | 4ee1193be5a2646862f43fb606d5f4ce325a66cb (diff) |
Use absolute image urlwork/space_image
-rw-r--r-- | src/gui/spaces/spacesmodel.cpp | 14 | ||||
-rw-r--r-- | src/gui/spaces/spacesmodel.h | 2 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/gui/spaces/spacesmodel.cpp b/src/gui/spaces/spacesmodel.cpp index 97fa78eac..b402c427c 100644 --- a/src/gui/spaces/spacesmodel.cpp +++ b/src/gui/spaces/spacesmodel.cpp @@ -13,6 +13,7 @@ */ #include "spacesmodel.h" +#include "common/utility.h" #include "networkjobs.h" #include <QPixmap> @@ -103,19 +104,16 @@ QVariant SpacesModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: switch (column) { case Columns::Image: { - auto it = _images.constFind(item.getId()); - if (it != _images.cend()) { - return QVariant::fromValue(*it); + if (auto it = Utility::optionalFind(_images, item.getId())) { + return QVariant::fromValue(it->value()); } - const auto imgUrl = data(index, Qt::DisplayRole); - if (!imgUrl.isValid()) { + const auto imgUrl = data(index, Qt::DisplayRole).toUrl(); + if (imgUrl.isEmpty()) { return {}; } // TODO: placeholder _images[item.getId()] = QPixmap(); - auto davUrl = QUrl(item.getRoot().getWebDavUrl()); - auto path = imgUrl.toString().remove(item.getRoot().getWebDavUrl()); - auto job = new OCC::SimpleNetworkJob(_acc, davUrl, path, "GET", {}, {}, nullptr); + auto job = new OCC::SimpleNetworkJob(_acc, imgUrl, {}, "GET", {}, {}, nullptr); connect(job, &OCC::SimpleNetworkJob::finishedSignal, this, [job, id = item.getId(), index, this] { QPixmap img; qDebug() << img.loadFromData(job->reply()->readAll()); diff --git a/src/gui/spaces/spacesmodel.h b/src/gui/spaces/spacesmodel.h index 8f40cd9e7..0d0f454bf 100644 --- a/src/gui/spaces/spacesmodel.h +++ b/src/gui/spaces/spacesmodel.h @@ -49,7 +49,7 @@ public: private: QList<OpenAPI::OAIDrive> _data; - mutable QMap<QString, QPixmap> _images; + mutable QHash<QString, QPixmap> _images; OCC::AccountPtr _acc; }; }
\ No newline at end of file |