2017-12-13 18:10:48 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-12-13 18:10:48 +00:00
|
|
|
|
2018-01-03 10:23:14 +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(
|
2018-01-14 16:02:25 +00:00
|
|
|
not_null<Element*> parent,
|
2018-01-17 16:21:01 +00:00
|
|
|
const std::vector<not_null<HistoryItem*>> &items);
|
2017-12-13 18:10:48 +00:00
|
|
|
|
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeGrouped;
|
|
|
|
}
|
|
|
|
|
2018-01-17 16:21:01 +00:00
|
|
|
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;
|
2018-01-27 13:59:24 +00:00
|
|
|
PointState pointState(QPoint point) const override;
|
|
|
|
TextState textState(
|
2017-12-13 18:10:48 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
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-15 19:05:10 +00:00
|
|
|
|
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;
|
|
|
|
|
2017-12-16 15:25:21 +00:00
|
|
|
TextWithEntities getCaption() const override;
|
2017-12-13 18:10:48 +00:00
|
|
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
2017-12-16 15:25:21 +00:00
|
|
|
|
2017-12-16 16:32:10 +00:00
|
|
|
bool overrideEditedDate() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-16 17:05:58 +00:00
|
|
|
HistoryMessageEdited *displayedEditBadge() const override;
|
2017-12-16 16:32:10 +00:00
|
|
|
|
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:
|
2018-01-14 16:02:25 +00:00
|
|
|
struct Part {
|
2018-01-17 16:21:01 +00:00
|
|
|
Part(not_null<HistoryItem*> item);
|
2017-12-13 18:10:48 +00:00
|
|
|
|
2018-01-17 16:21:01 +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;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-01-30 16:37:24 +00:00
|
|
|
bool applyGroup(const std::vector<not_null<HistoryItem*>> &items);
|
2018-01-13 12:45:11 +00:00
|
|
|
QSize countOptimalSize() override;
|
|
|
|
QSize countCurrentSize(int newWidth) override;
|
|
|
|
|
2018-01-11 13:07:29 +00:00
|
|
|
bool needInfoDisplay() const;
|
2017-12-13 18:10:48 +00:00
|
|
|
bool computeNeedBubble() const;
|
|
|
|
not_null<HistoryMedia*> main() const;
|
2018-01-14 16:02:25 +00:00
|
|
|
bool validateGroupParts(
|
2018-01-17 16:21:01 +00:00
|
|
|
const std::vector<not_null<HistoryItem*>> &items) const;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getPartState(
|
2017-12-16 07:20:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const;
|
2017-12-13 18:10:48 +00:00
|
|
|
|
|
|
|
Text _caption;
|
2018-01-14 16:02:25 +00:00
|
|
|
std::vector<Part> _parts;
|
2017-12-13 18:10:48 +00:00
|
|
|
bool _needBubble = false;
|
|
|
|
|
|
|
|
};
|