mirror of https://github.com/procxx/kepka.git
Remove HistoryItemInstantiated.
This commit is contained in:
parent
950126865e
commit
d326c7e3fa
|
@ -334,7 +334,7 @@ void GenerateItems(
|
||||||
auto addSimpleServiceMessage = [&](const QString &text, PhotoData *photo = nullptr) {
|
auto addSimpleServiceMessage = [&](const QString &text, PhotoData *photo = nullptr) {
|
||||||
auto message = HistoryService::PreparedText { text };
|
auto message = HistoryService::PreparedText { text };
|
||||||
message.links.push_back(fromLink);
|
message.links.push_back(fromLink);
|
||||||
addPart(HistoryService::create(history, idManager.next(), ::date(date), message, 0, peerToUser(from->id), photo));
|
addPart(new HistoryService(history, idManager.next(), ::date(date), message, 0, peerToUser(from->id), photo));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto createChangeTitle = [&](const MTPDchannelAdminLogEventActionChangeTitle &action) {
|
auto createChangeTitle = [&](const MTPDchannelAdminLogEventActionChangeTitle &action) {
|
||||||
|
@ -355,7 +355,7 @@ void GenerateItems(
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto newDescription = PrepareText(newValue, QString());
|
auto newDescription = PrepareText(newValue, QString());
|
||||||
auto body = HistoryMessage::create(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), newDescription);
|
auto body = new HistoryMessage(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), newDescription);
|
||||||
if (!oldValue.isEmpty()) {
|
if (!oldValue.isEmpty()) {
|
||||||
auto oldDescription = PrepareText(oldValue, QString());
|
auto oldDescription = PrepareText(oldValue, QString());
|
||||||
body->addLogEntryOriginal(id, lang(lng_admin_log_previous_description), oldDescription);
|
body->addLogEntryOriginal(id, lang(lng_admin_log_previous_description), oldDescription);
|
||||||
|
@ -376,7 +376,7 @@ void GenerateItems(
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto newLink = newValue.isEmpty() ? TextWithEntities() : PrepareText(Messenger::Instance().createInternalLinkFull(newValue), QString());
|
auto newLink = newValue.isEmpty() ? TextWithEntities() : PrepareText(Messenger::Instance().createInternalLinkFull(newValue), QString());
|
||||||
auto body = HistoryMessage::create(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), newLink);
|
auto body = new HistoryMessage(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), newLink);
|
||||||
if (!oldValue.isEmpty()) {
|
if (!oldValue.isEmpty()) {
|
||||||
auto oldLink = PrepareText(Messenger::Instance().createInternalLinkFull(oldValue), QString());
|
auto oldLink = PrepareText(Messenger::Instance().createInternalLinkFull(oldValue), QString());
|
||||||
body->addLogEntryOriginal(id, lang(lng_admin_log_previous_link), oldLink);
|
body->addLogEntryOriginal(id, lang(lng_admin_log_previous_link), oldLink);
|
||||||
|
@ -486,7 +486,7 @@ void GenerateItems(
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto bodyText = GenerateParticipantChangeText(channel, action.vparticipant);
|
auto bodyText = GenerateParticipantChangeText(channel, action.vparticipant);
|
||||||
addPart(HistoryMessage::create(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), bodyText));
|
addPart(new HistoryMessage(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), bodyText));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto createParticipantToggleBan = [&](const MTPDchannelAdminLogEventActionParticipantToggleBan &action) {
|
auto createParticipantToggleBan = [&](const MTPDchannelAdminLogEventActionParticipantToggleBan &action) {
|
||||||
|
@ -494,7 +494,7 @@ void GenerateItems(
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant, &action.vprev_participant);
|
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant, &action.vprev_participant);
|
||||||
addPart(HistoryMessage::create(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), bodyText));
|
addPart(new HistoryMessage(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), bodyText));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto createParticipantToggleAdmin = [&](const MTPDchannelAdminLogEventActionParticipantToggleAdmin &action) {
|
auto createParticipantToggleAdmin = [&](const MTPDchannelAdminLogEventActionParticipantToggleAdmin &action) {
|
||||||
|
@ -502,7 +502,7 @@ void GenerateItems(
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant, &action.vprev_participant);
|
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant, &action.vprev_participant);
|
||||||
addPart(HistoryMessage::create(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), bodyText));
|
addPart(new HistoryMessage(history, idManager.next(), bodyFlags, bodyReplyTo, bodyViaBotId, ::date(date), peerToUser(from->id), QString(), bodyText));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto createChangeStickerSet = [&](const MTPDchannelAdminLogEventActionChangeStickerSet &action) {
|
auto createChangeStickerSet = [&](const MTPDchannelAdminLogEventActionChangeStickerSet &action) {
|
||||||
|
@ -523,7 +523,7 @@ void GenerateItems(
|
||||||
auto message = HistoryService::PreparedText { text };
|
auto message = HistoryService::PreparedText { text };
|
||||||
message.links.push_back(fromLink);
|
message.links.push_back(fromLink);
|
||||||
message.links.push_back(setLink);
|
message.links.push_back(setLink);
|
||||||
addPart(HistoryService::create(history, idManager.next(), ::date(date), message, 0, peerToUser(from->id)));
|
addPart(new HistoryService(history, idManager.next(), ::date(date), message, 0, peerToUser(from->id)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -437,7 +437,7 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
|
||||||
auto inviteDate = peer->asChannel()->inviteDate;
|
auto inviteDate = peer->asChannel()->inviteDate;
|
||||||
if (unread) _maxReadMessageDate = inviteDate;
|
if (unread) _maxReadMessageDate = inviteDate;
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
_joinedMessage = HistoryJoined::create(this, inviteDate, inviter, flags);
|
_joinedMessage = new HistoryJoined(this, inviteDate, inviter, flags);
|
||||||
addNewItem(_joinedMessage, unread);
|
addNewItem(_joinedMessage, unread);
|
||||||
return _joinedMessage;
|
return _joinedMessage;
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
|
||||||
}
|
}
|
||||||
if (item->date <= inviteDate) {
|
if (item->date <= inviteDate) {
|
||||||
++itemIndex;
|
++itemIndex;
|
||||||
_joinedMessage = HistoryJoined::create(
|
_joinedMessage = new HistoryJoined(
|
||||||
this,
|
this,
|
||||||
inviteDate,
|
inviteDate,
|
||||||
inviter,
|
inviter,
|
||||||
|
@ -476,7 +476,7 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
|
||||||
|
|
||||||
startBuildingFrontBlock();
|
startBuildingFrontBlock();
|
||||||
|
|
||||||
_joinedMessage = HistoryJoined::create(this, inviteDate, inviter, flags);
|
_joinedMessage = new HistoryJoined(this, inviteDate, inviter, flags);
|
||||||
addItemToBlock(_joinedMessage);
|
addItemToBlock(_joinedMessage);
|
||||||
|
|
||||||
finishBuildingFrontBlock();
|
finishBuildingFrontBlock();
|
||||||
|
@ -766,7 +766,7 @@ not_null<HistoryItem*> History::createItemForwarded(
|
||||||
UserId from,
|
UserId from,
|
||||||
const QString &postAuthor,
|
const QString &postAuthor,
|
||||||
HistoryMessage *original) {
|
HistoryMessage *original) {
|
||||||
return HistoryMessage::create(
|
return new HistoryMessage(
|
||||||
this,
|
this,
|
||||||
id,
|
id,
|
||||||
flags,
|
flags,
|
||||||
|
@ -787,7 +787,7 @@ not_null<HistoryItem*> History::createItemDocument(
|
||||||
DocumentData *document,
|
DocumentData *document,
|
||||||
const TextWithEntities &caption,
|
const TextWithEntities &caption,
|
||||||
const MTPReplyMarkup &markup) {
|
const MTPReplyMarkup &markup) {
|
||||||
return HistoryMessage::create(
|
return new HistoryMessage(
|
||||||
this,
|
this,
|
||||||
id,
|
id,
|
||||||
flags,
|
flags,
|
||||||
|
@ -812,7 +812,7 @@ not_null<HistoryItem*> History::createItemPhoto(
|
||||||
PhotoData *photo,
|
PhotoData *photo,
|
||||||
const TextWithEntities &caption,
|
const TextWithEntities &caption,
|
||||||
const MTPReplyMarkup &markup) {
|
const MTPReplyMarkup &markup) {
|
||||||
return HistoryMessage::create(
|
return new HistoryMessage(
|
||||||
this,
|
this,
|
||||||
id,
|
id,
|
||||||
flags,
|
flags,
|
||||||
|
@ -836,7 +836,7 @@ not_null<HistoryItem*> History::createItemGame(
|
||||||
const QString &postAuthor,
|
const QString &postAuthor,
|
||||||
GameData *game,
|
GameData *game,
|
||||||
const MTPReplyMarkup &markup) {
|
const MTPReplyMarkup &markup) {
|
||||||
return HistoryMessage::create(
|
return new HistoryMessage(
|
||||||
this,
|
this,
|
||||||
id,
|
id,
|
||||||
flags,
|
flags,
|
||||||
|
@ -857,7 +857,7 @@ not_null<HistoryItem*> History::addNewService(
|
||||||
bool unread) {
|
bool unread) {
|
||||||
auto message = HistoryService::PreparedText { text };
|
auto message = HistoryService::PreparedText { text };
|
||||||
return addNewItem(
|
return addNewItem(
|
||||||
HistoryService::create(this, msgId, date, message, flags),
|
new HistoryService(this, msgId, date, message, flags),
|
||||||
unread);
|
unread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ not_null<HistoryItem*> CreateUnsupportedMessage(
|
||||||
text.entities.push_front(
|
text.entities.push_front(
|
||||||
EntityInText(EntityInTextItalic, 0, text.text.size()));
|
EntityInText(EntityInTextItalic, 0, text.text.size()));
|
||||||
flags &= ~MTPDmessage::Flag::f_post_author;
|
flags &= ~MTPDmessage::Flag::f_post_author;
|
||||||
return HistoryMessage::create(
|
return new HistoryMessage(
|
||||||
history,
|
history,
|
||||||
msgId,
|
msgId,
|
||||||
flags,
|
flags,
|
||||||
|
@ -81,9 +81,6 @@ HistoryItem::HistoryItem(
|
||||||
, _history(history)
|
, _history(history)
|
||||||
, _from(from ? App::user(from) : history->peer)
|
, _from(from ? App::user(from) : history->peer)
|
||||||
, _flags(flags) {
|
, _flags(flags) {
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryItem::finishCreate() {
|
|
||||||
App::historyRegItem(this);
|
App::historyRegItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +780,7 @@ not_null<HistoryItem*> HistoryItem::Create(
|
||||||
const auto text = HistoryService::PreparedText {
|
const auto text = HistoryService::PreparedText {
|
||||||
lang(lng_message_empty)
|
lang(lng_message_empty)
|
||||||
};
|
};
|
||||||
return HistoryService::create(history, data.vid.v, ::date(), text);
|
return new HistoryService(history, data.vid.v, ::date(), text);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_message: {
|
case mtpc_message: {
|
||||||
|
@ -881,7 +878,7 @@ not_null<HistoryItem*> HistoryItem::Create(
|
||||||
const auto text = HistoryService::PreparedText {
|
const auto text = HistoryService::PreparedText {
|
||||||
lang(lng_message_empty)
|
lang(lng_message_empty)
|
||||||
};
|
};
|
||||||
return HistoryService::create(
|
return new HistoryService(
|
||||||
history,
|
history,
|
||||||
data.vid.v,
|
data.vid.v,
|
||||||
::date(data.vdate),
|
::date(data.vdate),
|
||||||
|
@ -889,17 +886,17 @@ not_null<HistoryItem*> HistoryItem::Create(
|
||||||
data.vflags.v,
|
data.vflags.v,
|
||||||
data.has_from_id() ? data.vfrom_id.v : UserId(0));
|
data.has_from_id() ? data.vfrom_id.v : UserId(0));
|
||||||
} else if (badMedia == MediaCheckResult::HasTimeToLive) {
|
} else if (badMedia == MediaCheckResult::HasTimeToLive) {
|
||||||
return HistoryService::create(history, data);
|
return new HistoryService(history, data);
|
||||||
}
|
}
|
||||||
return HistoryMessage::create(history, data);
|
return new HistoryMessage(history, data);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_messageService: {
|
case mtpc_messageService: {
|
||||||
auto &data = message.c_messageService();
|
auto &data = message.c_messageService();
|
||||||
if (data.vaction.type() == mtpc_messageActionPhoneCall) {
|
if (data.vaction.type() == mtpc_messageActionPhoneCall) {
|
||||||
return HistoryMessage::create(history, data);
|
return new HistoryMessage(history, data);
|
||||||
}
|
}
|
||||||
return HistoryService::create(history, data);
|
return new HistoryService(history, data);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,10 +287,6 @@ protected:
|
||||||
QDateTime date,
|
QDateTime date,
|
||||||
UserId from);
|
UserId from);
|
||||||
|
|
||||||
// To completely create history item we need to call
|
|
||||||
// a virtual method, it can not be done from constructor.
|
|
||||||
virtual void finishCreate();
|
|
||||||
|
|
||||||
virtual void markMediaAsReadHook() {
|
virtual void markMediaAsReadHook() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,22 +323,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// make all the constructors in HistoryItem children protected
|
|
||||||
// and wrapped with a static create() call with the same args
|
|
||||||
// so that history item can not be created directly, without
|
|
||||||
// calling a virtual finishCreate() method
|
|
||||||
template <typename T>
|
|
||||||
class HistoryItemInstantiated {
|
|
||||||
public:
|
|
||||||
template <typename ...Args>
|
|
||||||
static not_null<T*> _create(Args &&... args) {
|
|
||||||
auto result = new T(std::forward<Args>(args)...);
|
|
||||||
result->finishCreate();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ClickHandlerPtr goToMessageClickHandler(
|
ClickHandlerPtr goToMessageClickHandler(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
MsgId msgId);
|
MsgId msgId);
|
||||||
|
|
|
@ -25,182 +25,8 @@ void FastShareMessage(not_null<HistoryItem*> item);
|
||||||
QString FormatViewsCount(int views);
|
QString FormatViewsCount(int views);
|
||||||
|
|
||||||
class HistoryMessage
|
class HistoryMessage
|
||||||
: public HistoryItem
|
: public HistoryItem {
|
||||||
, private HistoryItemInstantiated<HistoryMessage> {
|
|
||||||
public:
|
public:
|
||||||
static not_null<HistoryMessage*> create(
|
|
||||||
not_null<History*> history,
|
|
||||||
const MTPDmessage &msg) {
|
|
||||||
return _create(history, msg);
|
|
||||||
}
|
|
||||||
static not_null<HistoryMessage*> create(
|
|
||||||
not_null<History*> history,
|
|
||||||
const MTPDmessageService &msg) {
|
|
||||||
return _create(history, msg);
|
|
||||||
}
|
|
||||||
static not_null<HistoryMessage*> create(
|
|
||||||
not_null<History*> history,
|
|
||||||
MsgId msgId,
|
|
||||||
MTPDmessage::Flags flags,
|
|
||||||
QDateTime date,
|
|
||||||
UserId from,
|
|
||||||
const QString &postAuthor,
|
|
||||||
not_null<HistoryMessage*> fwd) {
|
|
||||||
return _create(history, msgId, flags, date, from, postAuthor, fwd);
|
|
||||||
}
|
|
||||||
static not_null<HistoryMessage*> create(
|
|
||||||
not_null<History*> history,
|
|
||||||
MsgId msgId,
|
|
||||||
MTPDmessage::Flags flags,
|
|
||||||
MsgId replyTo,
|
|
||||||
UserId viaBotId,
|
|
||||||
QDateTime date,
|
|
||||||
UserId from,
|
|
||||||
const QString &postAuthor,
|
|
||||||
const TextWithEntities &textWithEntities) {
|
|
||||||
return _create(
|
|
||||||
history,
|
|
||||||
msgId,
|
|
||||||
flags,
|
|
||||||
replyTo,
|
|
||||||
viaBotId,
|
|
||||||
date,
|
|
||||||
from,
|
|
||||||
postAuthor,
|
|
||||||
textWithEntities);
|
|
||||||
}
|
|
||||||
static not_null<HistoryMessage*> create(
|
|
||||||
not_null<History*> history,
|
|
||||||
MsgId msgId,
|
|
||||||
MTPDmessage::Flags flags,
|
|
||||||
MsgId replyTo,
|
|
||||||
UserId viaBotId,
|
|
||||||
QDateTime date,
|
|
||||||
UserId from,
|
|
||||||
const QString &postAuthor,
|
|
||||||
not_null<DocumentData*> document,
|
|
||||||
const TextWithEntities &caption,
|
|
||||||
const MTPReplyMarkup &markup) {
|
|
||||||
return _create(
|
|
||||||
history,
|
|
||||||
msgId,
|
|
||||||
flags,
|
|
||||||
replyTo,
|
|
||||||
viaBotId,
|
|
||||||
date,
|
|
||||||
from,
|
|
||||||
postAuthor,
|
|
||||||
document,
|
|
||||||
caption,
|
|
||||||
markup);
|
|
||||||
}
|
|
||||||
static not_null<HistoryMessage*> create(
|
|
||||||
not_null<History*> history,
|
|
||||||
MsgId msgId,
|
|
||||||
MTPDmessage::Flags flags,
|
|
||||||
MsgId replyTo,
|
|
||||||
UserId viaBotId,
|
|
||||||
QDateTime date,
|
|
||||||
UserId from,
|
|
||||||
const QString &postAuthor,
|
|
||||||
not_null<PhotoData*> photo,
|
|
||||||
const TextWithEntities &caption,
|
|
||||||
const MTPReplyMarkup &markup) {
|
|
||||||
return _create(
|
|
||||||
history,
|
|
||||||
msgId,
|
|
||||||
flags,
|
|
||||||
replyTo,
|
|
||||||
viaBotId,
|
|
||||||
date,
|
|
||||||
from,
|
|
||||||
postAuthor,
|
|
||||||
photo,
|
|
||||||
caption,
|
|
||||||
markup);
|
|
||||||
}
|
|
||||||
static not_null<HistoryMessage*> create(
|
|
||||||
not_null<History*> history,
|
|
||||||
MsgId msgId,
|
|
||||||
MTPDmessage::Flags flags,
|
|
||||||
MsgId replyTo,
|
|
||||||
UserId viaBotId,
|
|
||||||
QDateTime date,
|
|
||||||
UserId from,
|
|
||||||
const QString &postAuthor,
|
|
||||||
not_null<GameData*> game,
|
|
||||||
const MTPReplyMarkup &markup) {
|
|
||||||
return _create(
|
|
||||||
history,
|
|
||||||
msgId,
|
|
||||||
flags,
|
|
||||||
replyTo,
|
|
||||||
viaBotId,
|
|
||||||
date,
|
|
||||||
from,
|
|
||||||
postAuthor,
|
|
||||||
game,
|
|
||||||
markup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void refreshMedia(const MTPMessageMedia *media);
|
|
||||||
void refreshSentMedia(const MTPMessageMedia *media);
|
|
||||||
void setMedia(const MTPMessageMedia &media);
|
|
||||||
static std::unique_ptr<Data::Media> CreateMedia(
|
|
||||||
not_null<HistoryMessage*> item,
|
|
||||||
const MTPMessageMedia &media);
|
|
||||||
|
|
||||||
int32 plainMaxWidth() const;
|
|
||||||
|
|
||||||
bool allowsForward() const override;
|
|
||||||
bool allowsEdit(const QDateTime &now) const override;
|
|
||||||
bool uploading() const;
|
|
||||||
|
|
||||||
void applyGroupAdminChanges(
|
|
||||||
const base::flat_map<UserId, bool> &changes) override;
|
|
||||||
|
|
||||||
void setViewsCount(int32 count) override;
|
|
||||||
void setRealId(MsgId newId) override;
|
|
||||||
|
|
||||||
void dependencyItemRemoved(HistoryItem *dependency) override;
|
|
||||||
|
|
||||||
QString notificationHeader() const override;
|
|
||||||
|
|
||||||
void applyEdition(const MTPDmessage &message) override;
|
|
||||||
void applyEdition(const MTPDmessageService &message) override;
|
|
||||||
void updateSentMedia(const MTPMessageMedia *media) override;
|
|
||||||
void updateReplyMarkup(const MTPReplyMarkup *markup) override {
|
|
||||||
setReplyMarkup(markup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void addToUnreadMentions(UnreadMentionType type) override;
|
|
||||||
void eraseFromUnreadMentions() override;
|
|
||||||
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
|
||||||
|
|
||||||
void setText(const TextWithEntities &textWithEntities) override;
|
|
||||||
TextWithEntities originalText() const override;
|
|
||||||
bool textHasLinks() const override;
|
|
||||||
|
|
||||||
int viewsCount() const override;
|
|
||||||
not_null<PeerData*> displayFrom() const;
|
|
||||||
bool updateDependencyItem() override;
|
|
||||||
MsgId dependencyMsgId() const override {
|
|
||||||
return replyToId();
|
|
||||||
}
|
|
||||||
|
|
||||||
HistoryMessage *toHistoryMessage() override { // dynamic_cast optimize
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
const HistoryMessage *toHistoryMessage() const override { // dynamic_cast optimize
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<HistoryView::Element> createView(
|
|
||||||
not_null<HistoryView::ElementDelegate*> delegate) override;
|
|
||||||
|
|
||||||
~HistoryMessage();
|
|
||||||
|
|
||||||
private:
|
|
||||||
HistoryMessage(
|
HistoryMessage(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
const MTPDmessage &msg);
|
const MTPDmessage &msg);
|
||||||
|
@ -260,8 +86,65 @@ private:
|
||||||
const QString &postAuthor,
|
const QString &postAuthor,
|
||||||
not_null<GameData*> game,
|
not_null<GameData*> game,
|
||||||
const MTPReplyMarkup &markup); // local game
|
const MTPReplyMarkup &markup); // local game
|
||||||
friend class HistoryItemInstantiated<HistoryMessage>;
|
|
||||||
|
|
||||||
|
void refreshMedia(const MTPMessageMedia *media);
|
||||||
|
void refreshSentMedia(const MTPMessageMedia *media);
|
||||||
|
void setMedia(const MTPMessageMedia &media);
|
||||||
|
static std::unique_ptr<Data::Media> CreateMedia(
|
||||||
|
not_null<HistoryMessage*> item,
|
||||||
|
const MTPMessageMedia &media);
|
||||||
|
|
||||||
|
int32 plainMaxWidth() const;
|
||||||
|
|
||||||
|
bool allowsForward() const override;
|
||||||
|
bool allowsEdit(const QDateTime &now) const override;
|
||||||
|
bool uploading() const;
|
||||||
|
|
||||||
|
void applyGroupAdminChanges(
|
||||||
|
const base::flat_map<UserId, bool> &changes) override;
|
||||||
|
|
||||||
|
void setViewsCount(int32 count) override;
|
||||||
|
void setRealId(MsgId newId) override;
|
||||||
|
|
||||||
|
void dependencyItemRemoved(HistoryItem *dependency) override;
|
||||||
|
|
||||||
|
QString notificationHeader() const override;
|
||||||
|
|
||||||
|
void applyEdition(const MTPDmessage &message) override;
|
||||||
|
void applyEdition(const MTPDmessageService &message) override;
|
||||||
|
void updateSentMedia(const MTPMessageMedia *media) override;
|
||||||
|
void updateReplyMarkup(const MTPReplyMarkup *markup) override {
|
||||||
|
setReplyMarkup(markup);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addToUnreadMentions(UnreadMentionType type) override;
|
||||||
|
void eraseFromUnreadMentions() override;
|
||||||
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
||||||
|
|
||||||
|
void setText(const TextWithEntities &textWithEntities) override;
|
||||||
|
TextWithEntities originalText() const override;
|
||||||
|
bool textHasLinks() const override;
|
||||||
|
|
||||||
|
int viewsCount() const override;
|
||||||
|
not_null<PeerData*> displayFrom() const;
|
||||||
|
bool updateDependencyItem() override;
|
||||||
|
MsgId dependencyMsgId() const override {
|
||||||
|
return replyToId();
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryMessage *toHistoryMessage() override { // dynamic_cast optimize
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
const HistoryMessage *toHistoryMessage() const override { // dynamic_cast optimize
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<HistoryView::Element> createView(
|
||||||
|
not_null<HistoryView::ElementDelegate*> delegate) override;
|
||||||
|
|
||||||
|
~HistoryMessage();
|
||||||
|
|
||||||
|
private:
|
||||||
void setEmptyText();
|
void setEmptyText();
|
||||||
bool hasAdminBadge() const {
|
bool hasAdminBadge() const {
|
||||||
return _flags & MTPDmessage_ClientFlag::f_has_admin_badge;
|
return _flags & MTPDmessage_ClientFlag::f_has_admin_badge;
|
||||||
|
|
|
@ -51,22 +51,25 @@ namespace HistoryView {
|
||||||
class ServiceMessagePainter;
|
class ServiceMessagePainter;
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
||||||
class HistoryService : public HistoryItem, private HistoryItemInstantiated<HistoryService> {
|
class HistoryService : public HistoryItem {
|
||||||
public:
|
public:
|
||||||
struct PreparedText {
|
struct PreparedText {
|
||||||
QString text;
|
QString text;
|
||||||
QList<ClickHandlerPtr> links;
|
QList<ClickHandlerPtr> links;
|
||||||
};
|
};
|
||||||
|
|
||||||
static not_null<HistoryService*> create(not_null<History*> history, const MTPDmessage &message) {
|
HistoryService(not_null<History*> history, const MTPDmessage &message);
|
||||||
return _create(history, message);
|
HistoryService(
|
||||||
}
|
not_null<History*> history,
|
||||||
static not_null<HistoryService*> create(not_null<History*> history, const MTPDmessageService &message) {
|
const MTPDmessageService &message);
|
||||||
return _create(history, message);
|
HistoryService(
|
||||||
}
|
not_null<History*> history,
|
||||||
static not_null<HistoryService*> create(not_null<History*> history, MsgId msgId, QDateTime date, const PreparedText &message, MTPDmessage::Flags flags = 0, UserId from = 0, PhotoData *photo = nullptr) {
|
MsgId msgId,
|
||||||
return _create(history, msgId, date, message, flags, from, photo);
|
QDateTime date,
|
||||||
}
|
const PreparedText &message,
|
||||||
|
MTPDmessage::Flags flags = 0,
|
||||||
|
UserId from = 0,
|
||||||
|
PhotoData *photo = nullptr);
|
||||||
|
|
||||||
bool updateDependencyItem() override;
|
bool updateDependencyItem() override;
|
||||||
MsgId dependencyMsgId() const override {
|
MsgId dependencyMsgId() const override {
|
||||||
|
@ -104,11 +107,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
friend class HistoryView::ServiceMessagePainter;
|
friend class HistoryView::ServiceMessagePainter;
|
||||||
|
|
||||||
HistoryService(not_null<History*> history, const MTPDmessage &message);
|
|
||||||
HistoryService(not_null<History*> history, const MTPDmessageService &message);
|
|
||||||
HistoryService(not_null<History*> history, MsgId msgId, QDateTime date, const PreparedText &message, MTPDmessage::Flags flags = 0, UserId from = 0, PhotoData *photo = 0);
|
|
||||||
friend class HistoryItemInstantiated<HistoryService>;
|
|
||||||
|
|
||||||
void markMediaAsReadHook() override;
|
void markMediaAsReadHook() override;
|
||||||
|
|
||||||
void setServiceText(const PreparedText &prepared);
|
void setServiceText(const PreparedText &prepared);
|
||||||
|
@ -153,18 +151,17 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class HistoryJoined : public HistoryService, private HistoryItemInstantiated<HistoryJoined> {
|
class HistoryJoined : public HistoryService {
|
||||||
public:
|
public:
|
||||||
static not_null<HistoryJoined*> create(not_null<History*> history, const QDateTime &inviteDate, not_null<UserData*> inviter, MTPDmessage::Flags flags) {
|
HistoryJoined(
|
||||||
return _create(history, inviteDate, inviter, flags);
|
not_null<History*> history,
|
||||||
}
|
const QDateTime &inviteDate,
|
||||||
|
not_null<UserData*> inviter,
|
||||||
protected:
|
MTPDmessage::Flags flags);
|
||||||
HistoryJoined(not_null<History*> history, const QDateTime &inviteDate, not_null<UserData*> inviter, MTPDmessage::Flags flags);
|
|
||||||
using HistoryItemInstantiated<HistoryJoined>::_create;
|
|
||||||
friend class HistoryItemInstantiated<HistoryJoined>;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static PreparedText GenerateText(not_null<History*> history, not_null<UserData*> inviter);
|
static PreparedText GenerateText(
|
||||||
|
not_null<History*> history,
|
||||||
|
not_null<UserData*> inviter);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue