mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Remove Image::toDelayedStorageImage downcaster.
This commit is contained in:
parent
113f665295
commit
5a50248055
@ -129,9 +129,9 @@ ImagePtr PhotoData::makeReplyPreview(Data::FileOrigin origin) {
|
||||
: image->pix(origin, st::msgReplyBarSize.height())),
|
||||
"PNG");
|
||||
};
|
||||
if (thumb->toDelayedStorageImage()
|
||||
if (thumb->isDelayedStorageImage()
|
||||
&& !full->isNull()
|
||||
&& !full->toDelayedStorageImage()) {
|
||||
&& !full->isDelayedStorageImage()) {
|
||||
replyPreview = previewFromImage(full);
|
||||
} else {
|
||||
replyPreview = previewFromImage(thumb);
|
||||
|
@ -57,10 +57,10 @@ void UpdateImage(ImagePtr &old, ImagePtr now) {
|
||||
}
|
||||
if (old->isNull()) {
|
||||
old = now;
|
||||
} else if (const auto delayed = old->toDelayedStorageImage()) {
|
||||
} else if (old->isDelayedStorageImage()) {
|
||||
const auto location = now->location();
|
||||
if (!location.isNull()) {
|
||||
delayed->setStorageLocation(Data::FileOrigin(), location);
|
||||
old->setDelayedStorageLocation(Data::FileOrigin(), location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -460,8 +460,7 @@ void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, Tim
|
||||
p.setOpacity(radialOpacity);
|
||||
auto icon = ([radial, this, selected]() -> const style::icon* {
|
||||
if (radial || _data->loading()) {
|
||||
auto delayed = _data->full->toDelayedStorageImage();
|
||||
if (!delayed || !delayed->location().isNull()) {
|
||||
if (!_data->full->location().isNull()) {
|
||||
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
|
||||
}
|
||||
return nullptr;
|
||||
@ -529,8 +528,7 @@ TextState HistoryPhoto::textState(QPoint point, StateRequest request) const {
|
||||
} else if (_data->loaded()) {
|
||||
result.link = _openl;
|
||||
} else if (_data->loading()) {
|
||||
auto delayed = _data->full->toDelayedStorageImage();
|
||||
if (!delayed || !delayed->location().isNull()) {
|
||||
if (!_data->full->location().isNull()) {
|
||||
result.link = _cancell;
|
||||
}
|
||||
} else {
|
||||
@ -631,8 +629,7 @@ void HistoryPhoto::drawGrouped(
|
||||
if (_data->waitingForAlbum()) {
|
||||
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting);
|
||||
} else if (radial || _data->loading()) {
|
||||
auto delayed = _data->full->toDelayedStorageImage();
|
||||
if (!delayed || !delayed->location().isNull()) {
|
||||
if (!_data->full->location().isNull()) {
|
||||
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
|
||||
}
|
||||
return nullptr;
|
||||
@ -661,15 +658,14 @@ TextState HistoryPhoto::getStateGrouped(
|
||||
if (!geometry.contains(point)) {
|
||||
return {};
|
||||
}
|
||||
const auto delayed = _data->full->toDelayedStorageImage();
|
||||
return TextState(_parent, _data->uploading()
|
||||
? _cancell
|
||||
: _data->loaded()
|
||||
? _openl
|
||||
: _data->loading()
|
||||
? ((!delayed || !delayed->location().isNull())
|
||||
? _cancell
|
||||
: ClickHandlerPtr())
|
||||
? (_data->full->location().isNull()
|
||||
? ClickHandlerPtr()
|
||||
: _cancell)
|
||||
: _savel);
|
||||
}
|
||||
|
||||
|
@ -898,7 +898,8 @@ FileLoader *GeoPointImage::createLoader(
|
||||
Data::kImageCacheTag);
|
||||
}
|
||||
|
||||
DelayedStorageImage::DelayedStorageImage() : StorageImage(StorageImageLocation())
|
||||
DelayedStorageImage::DelayedStorageImage()
|
||||
: StorageImage(StorageImageLocation())
|
||||
, _loadRequested(false)
|
||||
, _loadCancelled(false)
|
||||
, _loadFromCloud(false) {
|
||||
@ -918,7 +919,7 @@ DelayedStorageImage::DelayedStorageImage(int32 w, int32 h)
|
||||
//, _loadFromCloud(false) {
|
||||
//}
|
||||
|
||||
void DelayedStorageImage::setStorageLocation(
|
||||
void DelayedStorageImage::setDelayedStorageLocation(
|
||||
Data::FileOrigin origin,
|
||||
const StorageImageLocation location) {
|
||||
_location = location;
|
||||
|
@ -15,7 +15,6 @@ void CheckCacheSize();
|
||||
|
||||
} // namespace Images
|
||||
|
||||
class DelayedStorageImage;
|
||||
class HistoryItem;
|
||||
|
||||
class Image {
|
||||
@ -157,11 +156,12 @@ public:
|
||||
return _saved;
|
||||
}
|
||||
|
||||
virtual DelayedStorageImage *toDelayedStorageImage() {
|
||||
return 0;
|
||||
}
|
||||
virtual const DelayedStorageImage *toDelayedStorageImage() const {
|
||||
return 0;
|
||||
virtual void setDelayedStorageLocation(
|
||||
Data::FileOrigin origin,
|
||||
const StorageImageLocation location) {
|
||||
};
|
||||
virtual bool isDelayedStorageImage() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual ~Image();
|
||||
@ -340,15 +340,11 @@ public:
|
||||
DelayedStorageImage(int32 w, int32 h);
|
||||
//DelayedStorageImage(QByteArray &bytes);
|
||||
|
||||
void setStorageLocation(
|
||||
void setDelayedStorageLocation(
|
||||
Data::FileOrigin origin,
|
||||
const StorageImageLocation location);
|
||||
|
||||
virtual DelayedStorageImage *toDelayedStorageImage() override {
|
||||
return this;
|
||||
}
|
||||
virtual const DelayedStorageImage *toDelayedStorageImage() const override {
|
||||
return this;
|
||||
const StorageImageLocation location) override;
|
||||
bool isDelayedStorageImage() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
void automaticLoad(
|
||||
|
Loading…
Reference in New Issue
Block a user