2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Load maps using mtproto instead of google.

This commit is contained in:
John Preston
2018-10-08 21:14:05 +03:00
parent be6e329e94
commit 9f90d3a7fc
9 changed files with 219 additions and 231 deletions

View File

@@ -392,6 +392,9 @@ StorageImages storageImages;
using WebFileImages = QMap<StorageKey, WebFileImage*>;
WebFileImages webFileImages;
using GeoPointImages = QMap<StorageKey, GeoPointImage*>;
GeoPointImages geoPointImages;
int64 globalAcquiredSize = 0;
uint64 PixKey(int width, int height, Images::Options options) {
@@ -947,6 +950,9 @@ void clearStorageImages() {
for (auto image : base::take(webFileImages)) {
delete image;
}
for (auto image : base::take(geoPointImages)) {
delete image;
}
}
void clearAllImages() {
@@ -1229,6 +1235,40 @@ FileLoader *WebFileImage::createLoader(
Data::kImageCacheTag);
}
GeoPointImage::GeoPointImage(const GeoPointLocation &location)
: _location(location) {
}
std::optional<Storage::Cache::Key> GeoPointImage::cacheKey() const {
return Data::GeoPointCacheKey(_location);
}
int GeoPointImage::countWidth() const {
return _location.width;
}
int GeoPointImage::countHeight() const {
return _location.height;
}
void GeoPointImage::setInformation(int size, int width, int height) {
_size = size;
_location.width = width;
_location.height = height;
}
FileLoader *GeoPointImage::createLoader(
Data::FileOrigin origin,
LoadFromCloudSetting fromCloud,
bool autoLoading) {
return new mtpFileLoader(
&_location,
_size,
fromCloud,
autoLoading,
Data::kImageCacheTag);
}
DelayedStorageImage::DelayedStorageImage() : StorageImage(StorageImageLocation())
, _loadRequested(false)
, _loadCancelled(false)
@@ -1571,6 +1611,17 @@ WebFileImage *getImage(
return i.value();
}
GeoPointImage *getImage(const GeoPointLocation &location) {
auto key = storageKey(location);
auto i = geoPointImages.constFind(key);
if (i == geoPointImages.cend()) {
i = geoPointImages.insert(
key,
new GeoPointImage(location));
}
return i.value();
}
} // namespace internal
ReadAccessEnabler::ReadAccessEnabler(const PsFileBookmark *bookmark)