2016-09-27 14:20:49 +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.
|
2016-09-27 14:20:49 +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
|
2016-09-27 14:20:49 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "base/runtime_composer.h"
|
2017-08-31 16:28:58 +00:00
|
|
|
#include "base/flags.h"
|
2017-12-13 18:10:48 +00:00
|
|
|
#include "base/value_ordering.h"
|
2019-03-29 14:17:46 +00:00
|
|
|
#include "data/data_media_types.h"
|
2016-09-29 11:37:16 +00:00
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
enum class UnreadMentionType;
|
2017-12-18 15:44:50 +00:00
|
|
|
struct HistoryMessageReplyMarkup;
|
|
|
|
class ReplyKeyboard;
|
|
|
|
class HistoryMessage;
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
namespace base {
|
|
|
|
template <typename Enum>
|
|
|
|
class enum_mask;
|
|
|
|
} // namespace base
|
|
|
|
|
|
|
|
namespace Storage {
|
2018-03-09 20:48:47 +00:00
|
|
|
enum class SharedMediaType : signed char;
|
2017-09-04 11:40:02 +00:00
|
|
|
using SharedMediaTypesMask = base::enum_mask<SharedMediaType>;
|
|
|
|
} // namespace Storage
|
|
|
|
|
2016-11-16 16:04:25 +00:00
|
|
|
namespace Ui {
|
|
|
|
class RippleAnimation;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2016-11-16 10:44:06 +00:00
|
|
|
namespace style {
|
|
|
|
struct BotKeyboardButton;
|
2016-11-16 16:04:25 +00:00
|
|
|
struct RippleAnimation;
|
2016-11-16 10:44:06 +00:00
|
|
|
} // namespace style
|
|
|
|
|
2018-01-09 17:08:31 +00:00
|
|
|
namespace Data {
|
|
|
|
struct MessagePosition;
|
2018-01-14 16:02:25 +00:00
|
|
|
class Media;
|
2018-01-09 17:08:31 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2018-01-11 19:33:26 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
|
|
|
namespace HistoryView {
|
2018-01-27 13:59:24 +00:00
|
|
|
struct TextState;
|
|
|
|
struct StateRequest;
|
|
|
|
enum class CursorState : char;
|
|
|
|
enum class PointState : char;
|
2018-01-11 19:33:26 +00:00
|
|
|
enum class Context : char;
|
2018-01-17 16:21:01 +00:00
|
|
|
class ElementDelegate;
|
2018-01-11 19:33:26 +00:00
|
|
|
} // namespace HistoryView
|
|
|
|
|
2019-03-15 15:15:56 +00:00
|
|
|
struct HiddenSenderInfo;
|
2019-09-13 06:06:02 +00:00
|
|
|
class History;
|
2019-03-15 15:15:56 +00:00
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
class HistoryItem : public RuntimeComposer<HistoryItem> {
|
2016-09-27 14:20:49 +00:00
|
|
|
public:
|
2018-01-14 16:02:25 +00:00
|
|
|
static not_null<HistoryItem*> Create(
|
|
|
|
not_null<History*> history,
|
2019-08-09 19:19:23 +00:00
|
|
|
const MTPMessage &message,
|
|
|
|
MTPDmessage_ClientFlags clientFlags);
|
2018-01-14 16:02:25 +00:00
|
|
|
|
2018-02-05 20:19:51 +00:00
|
|
|
struct Destroyer {
|
|
|
|
void operator()(HistoryItem *value);
|
|
|
|
};
|
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
virtual void dependencyItemRemoved(HistoryItem *dependency) {
|
|
|
|
}
|
|
|
|
virtual bool updateDependencyItem() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
virtual MsgId dependencyMsgId() const {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] virtual bool notificationReady() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] PeerData *specialNotificationPeer() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] UserData *viaBot() const;
|
|
|
|
[[nodiscard]] UserData *getMessageBot() const;
|
|
|
|
[[nodiscard]] bool isHistoryEntry() const;
|
2019-09-06 09:20:12 +00:00
|
|
|
[[nodiscard]] bool isAdminLogEntry() const;
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] bool isFromScheduled() const;
|
|
|
|
[[nodiscard]] bool isScheduled() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
void addLogEntryOriginal(
|
|
|
|
WebPageId localId,
|
|
|
|
const QString &label,
|
|
|
|
const TextWithEntities &content);
|
2017-06-18 13:08:49 +00:00
|
|
|
|
2017-08-25 15:17:46 +00:00
|
|
|
not_null<History*> history() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _history;
|
|
|
|
}
|
2018-01-13 12:45:11 +00:00
|
|
|
not_null<PeerData*> from() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _from;
|
|
|
|
}
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *mainView() const {
|
2018-01-10 13:13:33 +00:00
|
|
|
return _mainView;
|
|
|
|
}
|
2018-03-10 12:47:19 +00:00
|
|
|
void setMainView(not_null<HistoryView::Element*> view) {
|
2018-01-11 13:07:29 +00:00
|
|
|
_mainView = view;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2018-01-18 13:59:22 +00:00
|
|
|
void refreshMainView();
|
2018-01-11 13:07:29 +00:00
|
|
|
void clearMainView();
|
|
|
|
void removeMainView();
|
2017-05-12 14:05:06 +00:00
|
|
|
|
2018-01-11 13:07:29 +00:00
|
|
|
void destroy();
|
2019-04-30 09:48:48 +00:00
|
|
|
[[nodiscard]] bool out() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _flags & MTPDmessage::Flag::f_out;
|
|
|
|
}
|
2020-10-09 12:56:33 +00:00
|
|
|
[[nodiscard]] bool isPinned() const {
|
|
|
|
return _flags & MTPDmessage::Flag::f_pinned;
|
|
|
|
}
|
2019-04-30 09:48:48 +00:00
|
|
|
[[nodiscard]] bool unread() const;
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] bool showNotification() const;
|
2019-04-30 09:48:48 +00:00
|
|
|
void markClientSideAsRead();
|
2019-05-28 14:53:36 +00:00
|
|
|
[[nodiscard]] bool mentionsMe() const;
|
2019-04-30 09:48:48 +00:00
|
|
|
[[nodiscard]] bool isUnreadMention() const;
|
|
|
|
[[nodiscard]] bool isUnreadMedia() const;
|
|
|
|
[[nodiscard]] bool hasUnreadMediaFlag() const;
|
2017-08-25 12:48:10 +00:00
|
|
|
void markMediaRead();
|
2020-10-09 12:56:33 +00:00
|
|
|
void setIsPinned(bool isPinned);
|
2017-07-17 20:09:55 +00:00
|
|
|
|
2019-03-29 14:17:46 +00:00
|
|
|
// For edit media in history_message.
|
|
|
|
virtual void returnSavedMedia() {};
|
2019-03-31 20:45:55 +00:00
|
|
|
void savePreviousMedia() {
|
2020-05-30 14:41:39 +00:00
|
|
|
_savedLocalEditMediaData = {
|
|
|
|
originalText(),
|
|
|
|
_media->clone(this),
|
|
|
|
};
|
2019-03-31 20:45:55 +00:00
|
|
|
}
|
2019-04-30 09:48:48 +00:00
|
|
|
[[nodiscard]] bool isEditingMedia() const {
|
2020-05-30 14:41:39 +00:00
|
|
|
return _savedLocalEditMediaData.media != nullptr;
|
2019-04-04 10:22:59 +00:00
|
|
|
}
|
2019-03-30 08:13:16 +00:00
|
|
|
void clearSavedMedia() {
|
2020-05-30 14:41:39 +00:00
|
|
|
_savedLocalEditMediaData = {};
|
2019-03-30 08:13:16 +00:00
|
|
|
}
|
2019-03-29 14:17:46 +00:00
|
|
|
|
2017-07-17 20:09:55 +00:00
|
|
|
// Zero result means this message is not self-destructing right now.
|
2019-02-19 06:57:53 +00:00
|
|
|
virtual crl::time getSelfDestructIn(crl::time now) {
|
2017-07-17 20:09:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool definesReplyKeyboard() const;
|
|
|
|
[[nodiscard]] MTPDreplyKeyboardMarkup::Flags replyKeyboardFlags() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool hasSwitchInlineButton() const {
|
2019-08-09 19:19:23 +00:00
|
|
|
return _clientFlags & MTPDmessage_ClientFlag::f_has_switch_inline_button;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool hasTextLinks() const {
|
2019-08-09 19:19:23 +00:00
|
|
|
return _clientFlags & MTPDmessage_ClientFlag::f_has_text_links;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isGroupEssential() const {
|
2019-08-09 19:19:23 +00:00
|
|
|
return _clientFlags & MTPDmessage_ClientFlag::f_is_group_essential;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isLocalUpdateMedia() const {
|
2019-08-09 19:19:23 +00:00
|
|
|
return _clientFlags & MTPDmessage_ClientFlag::f_is_local_update_media;
|
2019-04-04 10:22:59 +00:00
|
|
|
}
|
|
|
|
void setIsLocalUpdateMedia(bool flag) {
|
|
|
|
if (flag) {
|
2019-08-09 19:19:23 +00:00
|
|
|
_clientFlags |= MTPDmessage_ClientFlag::f_is_local_update_media;
|
2019-04-04 10:22:59 +00:00
|
|
|
} else {
|
2019-08-09 19:19:23 +00:00
|
|
|
_clientFlags &= ~MTPDmessage_ClientFlag::f_is_local_update_media;
|
2019-04-04 10:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isGroupMigrate() const {
|
2019-01-22 07:50:21 +00:00
|
|
|
return isGroupEssential() && isEmpty();
|
|
|
|
}
|
2019-08-02 18:19:14 +00:00
|
|
|
[[nodiscard]] bool isIsolatedEmoji() const {
|
2019-08-09 19:19:23 +00:00
|
|
|
return _clientFlags & MTPDmessage_ClientFlag::f_isolated_emoji;
|
2019-08-01 21:14:19 +00:00
|
|
|
}
|
|
|
|
[[nodiscard]] bool hasViews() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _flags & MTPDmessage::Flag::f_views;
|
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isPost() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _flags & MTPDmessage::Flag::f_post;
|
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isSilent() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _flags & MTPDmessage::Flag::f_silent;
|
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isSending() const {
|
2019-08-09 19:19:23 +00:00
|
|
|
return _clientFlags & MTPDmessage_ClientFlag::f_sending;
|
2019-07-17 14:34:39 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool hasFailed() const {
|
2019-08-09 19:19:23 +00:00
|
|
|
return _clientFlags & MTPDmessage_ClientFlag::f_failed;
|
2019-07-17 14:34:39 +00:00
|
|
|
}
|
|
|
|
void sendFailed();
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual int viewsCount() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return hasViews() ? 1 : -1;
|
|
|
|
}
|
2020-09-01 06:44:18 +00:00
|
|
|
[[nodiscard]] virtual int repliesCount() const {
|
|
|
|
return 0;
|
|
|
|
}
|
2020-09-03 07:19:02 +00:00
|
|
|
[[nodiscard]] virtual bool repliesAreComments() const {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-11 17:55:10 +00:00
|
|
|
[[nodiscard]] virtual bool externalReply() const {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-22 11:01:49 +00:00
|
|
|
|
|
|
|
[[nodiscard]] virtual MsgId repliesInboxReadTill() const {
|
|
|
|
return MsgId(0);
|
2020-09-03 08:21:31 +00:00
|
|
|
}
|
2020-09-22 11:01:49 +00:00
|
|
|
virtual void setRepliesInboxReadTill(MsgId readTillId) {
|
2020-09-03 08:21:31 +00:00
|
|
|
}
|
2020-09-22 11:01:49 +00:00
|
|
|
[[nodiscard]] virtual MsgId computeRepliesInboxReadTillFull() const {
|
2020-09-15 08:39:39 +00:00
|
|
|
return MsgId(0);
|
|
|
|
}
|
2020-09-22 11:01:49 +00:00
|
|
|
[[nodiscard]] virtual MsgId repliesOutboxReadTill() const {
|
|
|
|
return MsgId(0);
|
2020-09-15 08:39:39 +00:00
|
|
|
}
|
2020-09-22 11:01:49 +00:00
|
|
|
virtual void setRepliesOutboxReadTill(MsgId readTillId) {
|
2020-09-15 08:39:39 +00:00
|
|
|
}
|
2020-09-22 11:01:49 +00:00
|
|
|
[[nodiscard]] virtual MsgId computeRepliesOutboxReadTillFull() const {
|
2020-09-18 11:52:44 +00:00
|
|
|
return MsgId(0);
|
|
|
|
}
|
2020-09-22 11:01:49 +00:00
|
|
|
virtual void setRepliesMaxId(MsgId maxId) {
|
|
|
|
}
|
|
|
|
virtual void setRepliesPossibleMaxId(MsgId possibleMaxId) {
|
|
|
|
}
|
|
|
|
[[nodiscard]] virtual bool areRepliesUnread() const {
|
2020-09-15 08:39:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2020-09-22 11:01:49 +00:00
|
|
|
[[nodiscard]] virtual FullMsgId commentsItemId() const {
|
|
|
|
return FullMsgId();
|
|
|
|
}
|
|
|
|
virtual void setCommentsItemId(FullMsgId id) {
|
|
|
|
}
|
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual bool needCheck() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual bool serviceMsg() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
virtual void applyEdition(const MTPDmessage &message) {
|
|
|
|
}
|
|
|
|
virtual void applyEdition(const MTPDmessageService &message) {
|
|
|
|
}
|
2019-04-08 09:16:45 +00:00
|
|
|
void applyEditionToHistoryCleared();
|
2019-08-07 14:38:26 +00:00
|
|
|
virtual void updateSentContent(
|
|
|
|
const TextWithEntities &textWithEntities,
|
|
|
|
const MTPMessageMedia *media) {
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2016-10-20 15:26:55 +00:00
|
|
|
virtual void updateReplyMarkup(const MTPReplyMarkup *markup) {
|
|
|
|
}
|
2019-03-15 15:15:56 +00:00
|
|
|
virtual void updateForwardedInfo(const MTPMessageFwdHeader *fwd) {
|
|
|
|
}
|
2019-08-20 09:42:13 +00:00
|
|
|
virtual void contributeToSlowmode(TimeId realDate = 0) {
|
|
|
|
}
|
2017-09-04 11:40:02 +00:00
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
virtual void addToUnreadMentions(UnreadMentionType type);
|
2020-09-01 06:44:18 +00:00
|
|
|
virtual void destroyHistoryEntry() {
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual Storage::SharedMediaTypesMask sharedMediaTypes() const = 0;
|
2016-11-18 16:27:47 +00:00
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
void indexAsNewItem();
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual QString notificationHeader() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return QString();
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual QString notificationText() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2017-09-05 17:21:56 +00:00
|
|
|
enum class DrawInDialog {
|
|
|
|
Normal,
|
|
|
|
WithoutSender,
|
|
|
|
};
|
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
// Returns text with link-start and link-end commands for service-color highlighting.
|
|
|
|
// Example: "[link1-start]You:[link1-end] [link1-start]Photo,[link1-end] caption text"
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual QString inDialogsText(DrawInDialog way) const;
|
|
|
|
[[nodiscard]] virtual QString inReplyText() const {
|
2018-05-31 11:13:11 +00:00
|
|
|
return inDialogsText(DrawInDialog::WithoutSender);
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual Ui::Text::IsolatedEmoji isolatedEmoji() const;
|
|
|
|
[[nodiscard]] virtual TextWithEntities originalText() const {
|
2019-04-08 15:10:06 +00:00
|
|
|
return TextWithEntities();
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual TextForMimeData clipboardText() const {
|
2019-04-08 15:10:06 +00:00
|
|
|
return TextForMimeData();
|
2018-01-26 15:40:11 +00:00
|
|
|
}
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2020-09-01 06:44:18 +00:00
|
|
|
virtual void setViewsCount(int count) {
|
|
|
|
}
|
|
|
|
virtual void setForwardsCount(int count) {
|
|
|
|
}
|
2020-09-03 07:19:02 +00:00
|
|
|
virtual void setReplies(const MTPMessageReplies &data) {
|
|
|
|
}
|
2020-10-01 08:34:59 +00:00
|
|
|
virtual void clearReplies() {
|
|
|
|
}
|
2020-09-03 11:53:54 +00:00
|
|
|
virtual void changeRepliesCount(int delta, PeerId replier) {
|
2020-09-01 06:44:18 +00:00
|
|
|
}
|
|
|
|
virtual void setReplyToTop(MsgId replyToTop) {
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2020-10-06 07:23:58 +00:00
|
|
|
virtual void setPostAuthor(const QString &author) {
|
|
|
|
}
|
2018-01-13 12:45:11 +00:00
|
|
|
virtual void setRealId(MsgId newId);
|
2020-09-01 06:44:18 +00:00
|
|
|
virtual void incrementReplyToTopCounter() {
|
|
|
|
}
|
2017-09-05 17:21:56 +00:00
|
|
|
|
|
|
|
void drawInDialog(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &r,
|
|
|
|
bool active,
|
|
|
|
bool selected,
|
|
|
|
DrawInDialog way,
|
|
|
|
const HistoryItem *&cacheFor,
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String &cache) const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool emptyText() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _text.isEmpty();
|
|
|
|
}
|
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool canPin() const;
|
|
|
|
[[nodiscard]] bool canStopPoll() const;
|
|
|
|
[[nodiscard]] virtual bool allowsSendNow() const;
|
|
|
|
[[nodiscard]] virtual bool allowsForward() const;
|
|
|
|
[[nodiscard]] virtual bool allowsEdit(TimeId now) const;
|
|
|
|
[[nodiscard]] bool canDelete() const;
|
|
|
|
[[nodiscard]] bool canDeleteForEveryone(TimeId now) const;
|
|
|
|
[[nodiscard]] bool suggestReport() const;
|
|
|
|
[[nodiscard]] bool suggestBanReport() const;
|
|
|
|
[[nodiscard]] bool suggestDeleteAllReport() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool hasDirectLink() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] ChannelId channelId() const;
|
|
|
|
[[nodiscard]] FullMsgId fullId() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return FullMsgId(channelId(), id);
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] Data::MessagePosition position() const;
|
|
|
|
[[nodiscard]] TimeId date() const;
|
|
|
|
|
|
|
|
[[nodiscard]] static TimeId NewMessageDate(TimeId scheduled);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] Data::Media *media() const {
|
2017-03-05 13:39:10 +00:00
|
|
|
return _media.get();
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
|
|
|
virtual void setText(const TextWithEntities &textWithEntities) {
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual bool textHasLinks() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual HistoryMessage *toHistoryMessage() { // dynamic_cast optimize
|
2016-09-27 14:20:49 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual const HistoryMessage *toHistoryMessage() const { // dynamic_cast optimize
|
2016-09-27 14:20:49 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] MsgId replyToId() const;
|
2020-09-01 06:44:18 +00:00
|
|
|
[[nodiscard]] MsgId replyToTop() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] not_null<PeerData*> author() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] TimeId dateOriginal() const;
|
|
|
|
[[nodiscard]] PeerData *senderOriginal() const;
|
|
|
|
[[nodiscard]] const HiddenSenderInfo *hiddenForwardedInfo() const;
|
|
|
|
[[nodiscard]] not_null<PeerData*> fromOriginal() const;
|
|
|
|
[[nodiscard]] QString authorOriginal() const;
|
|
|
|
[[nodiscard]] MsgId idOriginal() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool isEmpty() const;
|
2017-12-13 18:10:48 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] MessageGroupId groupId() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] const HistoryMessageReplyMarkup *inlineReplyMarkup() const {
|
2019-05-25 14:42:01 +00:00
|
|
|
return const_cast<HistoryItem*>(this)->inlineReplyMarkup();
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] const ReplyKeyboard *inlineReplyKeyboard() const {
|
2019-05-25 14:42:01 +00:00
|
|
|
return const_cast<HistoryItem*>(this)->inlineReplyKeyboard();
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] HistoryMessageReplyMarkup *inlineReplyMarkup();
|
|
|
|
[[nodiscard]] ReplyKeyboard *inlineReplyKeyboard();
|
2019-05-25 14:42:01 +00:00
|
|
|
|
2019-05-25 15:05:57 +00:00
|
|
|
[[nodiscard]] ChannelData *discussionPostOriginalSender() const;
|
|
|
|
[[nodiscard]] bool isDiscussionPost() const;
|
2020-09-15 08:39:39 +00:00
|
|
|
[[nodiscard]] HistoryItem *lookupDiscussionPostOriginal() const;
|
2019-05-25 15:05:57 +00:00
|
|
|
[[nodiscard]] PeerData *displayFrom() const;
|
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] virtual std::unique_ptr<HistoryView::Element> createView(
|
2020-06-16 16:53:44 +00:00
|
|
|
not_null<HistoryView::ElementDelegate*> delegate,
|
|
|
|
HistoryView::Element *replacing = nullptr) = 0;
|
2018-01-11 19:33:26 +00:00
|
|
|
|
2020-05-09 20:34:57 +00:00
|
|
|
void updateDate(TimeId newDate);
|
|
|
|
[[nodiscard]] bool canUpdateDate() const;
|
|
|
|
|
2020-06-04 10:29:16 +00:00
|
|
|
[[nodiscard]] bool canBeEditedFromHistory() const;
|
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
virtual ~HistoryItem();
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
MsgId id;
|
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
protected:
|
2017-08-25 15:17:46 +00:00
|
|
|
HistoryItem(
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
MTPDmessage::Flags flags,
|
2019-08-09 19:19:23 +00:00
|
|
|
MTPDmessage_ClientFlags clientFlags,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2017-07-17 20:09:55 +00:00
|
|
|
virtual void markMediaAsReadHook() {
|
|
|
|
}
|
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
void finishEdition(int oldKeyboardTop);
|
|
|
|
void finishEditionToEmpty();
|
|
|
|
|
2017-08-25 15:17:46 +00:00
|
|
|
const not_null<History*> _history;
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<PeerData*> _from;
|
2017-06-21 08:53:14 +00:00
|
|
|
MTPDmessage::Flags _flags = 0;
|
2019-08-09 19:19:23 +00:00
|
|
|
MTPDmessage_ClientFlags _clientFlags = 0;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-01-15 11:57:45 +00:00
|
|
|
void invalidateChatListEntry();
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
void setGroupId(MessageGroupId groupId);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _text = { st::msgMinWidth };
|
2016-09-27 14:20:49 +00:00
|
|
|
int _textWidth = -1;
|
|
|
|
int _textHeight = 0;
|
|
|
|
|
2020-05-30 14:41:39 +00:00
|
|
|
struct SavedMediaData {
|
|
|
|
TextWithEntities text;
|
|
|
|
std::unique_ptr<Data::Media> media;
|
|
|
|
};
|
|
|
|
|
|
|
|
SavedMediaData _savedLocalEditMediaData;
|
2018-01-14 16:02:25 +00:00
|
|
|
std::unique_ptr<Data::Media> _media;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2017-05-12 13:53:08 +00:00
|
|
|
private:
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId _date = 0;
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *_mainView = nullptr;
|
2018-01-13 12:45:11 +00:00
|
|
|
friend class HistoryView::Element;
|
2017-05-12 13:53:08 +00:00
|
|
|
|
2019-05-31 21:51:57 +00:00
|
|
|
MessageGroupId _groupId = MessageGroupId();
|
2018-01-14 16:02:25 +00:00
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
};
|
|
|
|
|
2018-02-03 19:52:35 +00:00
|
|
|
QDateTime ItemDateTime(not_null<const HistoryItem*> item);
|
2020-01-14 22:23:16 +00:00
|
|
|
QString ItemDateText(not_null<const HistoryItem*> item, bool isUntilOnline);
|
|
|
|
bool IsItemScheduledUntilOnline(not_null<const HistoryItem*> item);
|
2018-02-03 19:52:35 +00:00
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
ClickHandlerPtr goToMessageClickHandler(
|
|
|
|
not_null<PeerData*> peer,
|
2018-01-26 15:40:11 +00:00
|
|
|
MsgId msgId,
|
|
|
|
FullMsgId returnToId = FullMsgId());
|
|
|
|
ClickHandlerPtr goToMessageClickHandler(
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
FullMsgId returnToId = FullMsgId());
|