tdesktop/Telegram/SourceFiles/history/history_media_grouped.h

131 lines
3.2 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"
namespace Data {
class Media;
} // namespace Data
2017-12-13 18:10:48 +00:00
class HistoryGroupedMedia : public HistoryMedia {
public:
static constexpr auto kMaxSize = 10;
HistoryGroupedMedia(
not_null<Element*> parent,
const std::vector<std::unique_ptr<Data::Media>> &medias);
2017-12-13 18:10:48 +00:00
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;
PointState pointState(QPoint point) const override;
TextState textState(
2017-12-13 18:10:48 +00:00
QPoint point,
StateRequest request) const override;
2017-12-13 18:10:48 +00:00
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;
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;
}
void parentTextUpdated() override;
2017-12-13 18:10:48 +00:00
private:
struct Part {
Part(
not_null<HistoryView::Element*> parent,
not_null<Data::Media*> media);
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;
};
template <typename DataMediaRange>
bool applyGroup(const DataMediaRange &medias);
template <typename DataMediaRange>
bool validateGroupParts(const DataMediaRange &medias) const;
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;
TextState getPartState(
2017-12-16 07:20:04 +00:00
QPoint point,
StateRequest 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;
};