tdesktop/Telegram/SourceFiles/history/history_media_grouped.h

119 lines
3.0 KiB
C
Raw Normal View History

2017-12-13 18:10:48 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2017-12-13 18:10:48 +00:00
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
2017-12-13 18:10:48 +00:00
*/
#pragma once
#include "history/history_media.h"
#include "data/data_document.h"
#include "data/data_photo.h"
class HistoryGroupedMedia : public HistoryMedia {
public:
HistoryGroupedMedia(
not_null<Element*> parent,
const std::vector<not_null<HistoryItem*>> &items);
2017-12-13 18:10:48 +00:00
HistoryMediaType type() const override {
return MediaTypeGrouped;
}
void refreshParentId(not_null<HistoryItem*> realParent) override;
2017-12-13 18:10:48 +00:00
void draw(
Painter &p,
const QRect &clip,
TextSelection selection,
TimeMs ms) const override;
HistoryTextState getState(
QPoint point,
HistoryStateRequest request) const override;
bool toggleSelectionByHandlerClick(
const ClickHandlerPtr &p) const override;
bool dragItemByHandler(const ClickHandlerPtr &p) const override;
[[nodiscard]] TextSelection adjustSelection(
TextSelection selection,
TextSelectType type) const override;
uint16 fullSelectionLength() const override {
return _caption.length();
}
bool hasTextForCopy() const override {
return !_caption.isEmpty();
}
2017-12-19 16:57:42 +00:00
PhotoData *getPhoto() const override;
DocumentData *getDocument() const override;
2017-12-13 18:10:48 +00:00
TextWithEntities selectedText(TextSelection selection) const override;
void clickHandlerActiveChanged(
const ClickHandlerPtr &p,
bool active) override;
void clickHandlerPressedChanged(
const ClickHandlerPtr &p,
bool pressed) override;
std::unique_ptr<HistoryMedia> takeLastFromGroup() override;
bool applyGroup(
const std::vector<not_null<HistoryItem*>> &items) override;
2017-12-13 18:10:48 +00:00
bool hasReplyPreview() const override;
ImagePtr replyPreview() override;
TextWithEntities getCaption() const override;
2017-12-13 18:10:48 +00:00
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
bool overrideEditedDate() const override {
return true;
}
HistoryMessageEdited *displayedEditBadge() const override;
2017-12-13 18:10:48 +00:00
bool skipBubbleTail() const override {
return isBubbleBottom() && _caption.isEmpty();
}
void updateNeedBubbleState() override;
bool needsBubble() const override;
bool customInfoLayout() const override {
return _caption.isEmpty();
}
bool allowsFastShare() const override {
return true;
}
private:
struct Part {
Part(not_null<HistoryItem*> item);
2017-12-13 18:10:48 +00:00
not_null<HistoryItem*> item;
2017-12-13 18:10:48 +00:00
std::unique_ptr<HistoryMedia> content;
RectParts sides = RectPart::None;
QRect initialGeometry;
QRect geometry;
mutable uint64 cacheKey = 0;
mutable QPixmap cache;
};
QSize countOptimalSize() override;
QSize countCurrentSize(int newWidth) override;
bool needInfoDisplay() const;
2017-12-13 18:10:48 +00:00
bool computeNeedBubble() const;
not_null<HistoryMedia*> main() const;
bool validateGroupParts(
const std::vector<not_null<HistoryItem*>> &items) const;
HistoryTextState getPartState(
2017-12-16 07:20:04 +00:00
QPoint point,
HistoryStateRequest request) const;
2017-12-13 18:10:48 +00:00
Text _caption;
std::vector<Part> _parts;
2017-12-13 18:10:48 +00:00
bool _needBubble = false;
};