2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_types.h"
|
|
|
|
#include "data/data_peer.h"
|
2016-12-01 19:20:33 +00:00
|
|
|
#include "dialogs/dialogs_common.h"
|
|
|
|
#include "ui/effects/send_action_animations.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "base/observer.h"
|
2017-07-17 20:09:55 +00:00
|
|
|
#include "base/timer.h"
|
2017-08-11 07:16:07 +00:00
|
|
|
#include "base/variant.h"
|
|
|
|
#include "base/flat_set.h"
|
2017-08-31 16:28:58 +00:00
|
|
|
#include "base/flags.h"
|
2016-12-01 19:20:33 +00:00
|
|
|
|
2017-06-22 15:11:41 +00:00
|
|
|
void HistoryInit();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
class HistoryItem;
|
2017-08-17 08:31:24 +00:00
|
|
|
using SelectedItemSet = QMap<int, not_null<HistoryItem*>>;
|
2014-12-22 23:11:37 +00:00
|
|
|
|
2015-09-20 08:55:41 +00:00
|
|
|
enum NewMessageType {
|
|
|
|
NewMessageUnread,
|
|
|
|
NewMessageLast,
|
|
|
|
NewMessageExisting,
|
|
|
|
};
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
class History;
|
2015-12-08 12:33:37 +00:00
|
|
|
class Histories {
|
2015-09-19 09:13:21 +00:00
|
|
|
public:
|
2016-12-05 08:45:56 +00:00
|
|
|
using Map = QHash<PeerId, History*>;
|
2015-09-19 09:13:21 +00:00
|
|
|
Map map;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-01-07 11:55:05 +00:00
|
|
|
Histories() : _a_typings(animation(this, &Histories::step_typings)) {
|
2017-07-17 20:09:55 +00:00
|
|
|
_selfDestructTimer.setCallback([this] { checkSelfDestructItems(); });
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-06-22 18:41:13 +00:00
|
|
|
void regSendAction(History *history, UserData *user, const MTPSendMessageAction &action, TimeId when);
|
2016-12-01 19:20:33 +00:00
|
|
|
void step_typings(TimeMs ms, bool timer);
|
2014-12-12 16:27:03 +00:00
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
History *find(const PeerId &peerId);
|
2017-08-31 17:53:03 +00:00
|
|
|
not_null<History*> findOrInsert(const PeerId &peerId);
|
|
|
|
not_null<History*> findOrInsert(const PeerId &peerId, int32 unreadCount, int32 maxInboxRead, int32 maxOutboxRead);
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void clear();
|
2014-12-18 18:40:49 +00:00
|
|
|
void remove(const PeerId &peer);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
HistoryItem *addNewMessage(const MTPMessage &msg, NewMessageType type);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
typedef QMap<History*, TimeMs> TypingHistories; // when typing in this history started
|
2014-05-30 08:53:19 +00:00
|
|
|
TypingHistories typing;
|
2016-12-07 13:32:25 +00:00
|
|
|
BasicAnimation _a_typings;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
int unreadBadge() const;
|
|
|
|
int unreadMutedCount() const {
|
2016-04-11 10:59:01 +00:00
|
|
|
return _unreadMuted;
|
|
|
|
}
|
2016-08-27 04:49:18 +00:00
|
|
|
bool unreadOnlyMuted() const;
|
2016-02-28 11:58:30 +00:00
|
|
|
void unreadIncrement(int32 count, bool muted) {
|
|
|
|
_unreadFull += count;
|
|
|
|
if (muted) {
|
|
|
|
_unreadMuted += count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void unreadMuteChanged(int32 count, bool muted) {
|
|
|
|
if (muted) {
|
|
|
|
_unreadMuted += count;
|
|
|
|
} else {
|
|
|
|
_unreadMuted -= count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-13 07:59:57 +00:00
|
|
|
void setIsPinned(History *history, bool isPinned);
|
|
|
|
void clearPinned();
|
2017-01-02 17:11:49 +00:00
|
|
|
int pinnedCount() const;
|
2017-01-30 15:27:13 +00:00
|
|
|
QList<History*> getPinnedOrder() const;
|
2017-02-16 16:47:50 +00:00
|
|
|
void savePinnedToServer() const;
|
2016-12-13 07:59:57 +00:00
|
|
|
|
2016-12-05 08:45:56 +00:00
|
|
|
struct SendActionAnimationUpdate {
|
2016-10-23 21:03:10 +00:00
|
|
|
History *history;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
bool textUpdated;
|
2016-12-05 08:45:56 +00:00
|
|
|
};
|
|
|
|
base::Observable<SendActionAnimationUpdate> &sendActionAnimationUpdated() {
|
|
|
|
return _sendActionAnimationUpdated;
|
|
|
|
}
|
2017-08-17 08:31:24 +00:00
|
|
|
void selfDestructIn(not_null<HistoryItem*> item, TimeMs delay);
|
2016-12-05 08:45:56 +00:00
|
|
|
|
2016-02-28 11:58:30 +00:00
|
|
|
private:
|
2017-07-17 20:09:55 +00:00
|
|
|
void checkSelfDestructItems();
|
|
|
|
|
2016-12-13 07:59:57 +00:00
|
|
|
int _unreadFull = 0;
|
|
|
|
int _unreadMuted = 0;
|
2016-12-05 08:45:56 +00:00
|
|
|
base::Observable<SendActionAnimationUpdate> _sendActionAnimationUpdated;
|
2016-12-13 07:59:57 +00:00
|
|
|
OrderedSet<History*> _pinnedDialogs;
|
2016-02-28 11:58:30 +00:00
|
|
|
|
2017-07-17 20:09:55 +00:00
|
|
|
base::Timer _selfDestructTimer;
|
|
|
|
std::vector<FullMsgId> _selfDestructItems;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
class HistoryBlock;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-08-15 11:19:32 +00:00
|
|
|
enum HistoryMediaType {
|
|
|
|
MediaTypePhoto,
|
|
|
|
MediaTypeVideo,
|
|
|
|
MediaTypeContact,
|
2017-04-27 21:17:00 +00:00
|
|
|
MediaTypeCall,
|
2016-02-12 16:35:06 +00:00
|
|
|
MediaTypeFile,
|
2015-12-08 19:07:50 +00:00
|
|
|
MediaTypeGif,
|
2014-12-22 23:11:37 +00:00
|
|
|
MediaTypeSticker,
|
2016-02-28 13:54:04 +00:00
|
|
|
MediaTypeLocation,
|
2015-04-04 20:01:34 +00:00
|
|
|
MediaTypeWebPage,
|
2016-02-12 16:35:06 +00:00
|
|
|
MediaTypeMusicFile,
|
|
|
|
MediaTypeVoiceFile,
|
2016-09-27 13:37:18 +00:00
|
|
|
MediaTypeGame,
|
2017-03-05 13:39:10 +00:00
|
|
|
MediaTypeInvoice,
|
2014-08-15 11:19:32 +00:00
|
|
|
|
|
|
|
MediaTypeCount
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MediaOverviewType {
|
2017-05-18 12:37:06 +00:00
|
|
|
OverviewPhotos = 0,
|
|
|
|
OverviewVideos = 1,
|
|
|
|
OverviewMusicFiles = 2,
|
|
|
|
OverviewFiles = 3,
|
|
|
|
OverviewVoiceFiles = 4,
|
|
|
|
OverviewLinks = 5,
|
|
|
|
OverviewChatPhotos = 6,
|
|
|
|
OverviewRoundVoiceFiles = 7,
|
|
|
|
OverviewGIFs = 8,
|
2014-08-15 11:19:32 +00:00
|
|
|
|
|
|
|
OverviewCount
|
|
|
|
};
|
|
|
|
|
2016-11-15 11:56:49 +00:00
|
|
|
struct TextWithTags {
|
|
|
|
struct Tag {
|
|
|
|
int offset, length;
|
|
|
|
QString id;
|
|
|
|
};
|
|
|
|
using Tags = QVector<Tag>;
|
|
|
|
|
|
|
|
QString text;
|
|
|
|
Tags tags;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline bool operator==(const TextWithTags::Tag &a, const TextWithTags::Tag &b) {
|
|
|
|
return (a.offset == b.offset) && (a.length == b.length) && (a.id == b.id);
|
|
|
|
}
|
|
|
|
inline bool operator!=(const TextWithTags::Tag &a, const TextWithTags::Tag &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator==(const TextWithTags &a, const TextWithTags &b) {
|
|
|
|
return (a.text == b.text) && (a.tags == b.tags);
|
|
|
|
}
|
|
|
|
inline bool operator!=(const TextWithTags &a, const TextWithTags &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
2016-06-03 18:24:27 +00:00
|
|
|
|
2016-06-09 14:31:10 +00:00
|
|
|
namespace Data {
|
|
|
|
struct Draft;
|
|
|
|
} // namespace Data
|
2016-02-25 10:32:31 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
class HistoryMedia;
|
|
|
|
class HistoryMessage;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2016-01-03 01:43:42 +00:00
|
|
|
enum AddToOverviewMethod {
|
|
|
|
AddToOverviewNew, // when new message is added to history
|
|
|
|
AddToOverviewFront, // when old messages slice was received
|
|
|
|
AddToOverviewBack, // when new messages slice was received and it is the last one, we index all media
|
|
|
|
};
|
|
|
|
|
2016-04-09 18:45:55 +00:00
|
|
|
namespace Dialogs {
|
|
|
|
class Row;
|
|
|
|
class IndexedList;
|
|
|
|
} // namespace Dialogs
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
class ChannelHistory;
|
|
|
|
class History {
|
|
|
|
public:
|
2014-05-30 08:53:19 +00:00
|
|
|
History(const PeerId &peerId);
|
2016-03-22 09:51:20 +00:00
|
|
|
History(const History &) = delete;
|
|
|
|
History &operator=(const History &) = delete;
|
|
|
|
|
2015-09-03 10:48:40 +00:00
|
|
|
ChannelId channelId() const {
|
|
|
|
return peerToChannel(peer->id);
|
|
|
|
}
|
2015-09-19 09:13:21 +00:00
|
|
|
bool isChannel() const {
|
|
|
|
return peerIsChannel(peer->id);
|
|
|
|
}
|
2015-11-02 22:33:57 +00:00
|
|
|
bool isMegagroup() const {
|
|
|
|
return peer->isMegagroup();
|
|
|
|
}
|
2015-09-19 09:13:21 +00:00
|
|
|
ChannelHistory *asChannelHistory();
|
|
|
|
const ChannelHistory *asChannelHistory() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-08-31 17:53:03 +00:00
|
|
|
not_null<History*> migrateToOrMe() const;
|
|
|
|
History *migrateFrom() const;
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
bool isEmpty() const {
|
2017-09-27 18:45:26 +00:00
|
|
|
return blocks.empty();
|
2015-09-19 09:13:21 +00:00
|
|
|
}
|
2016-06-03 12:45:33 +00:00
|
|
|
bool isDisplayedEmpty() const;
|
|
|
|
|
2014-07-04 11:12:54 +00:00
|
|
|
void clear(bool leaveItems = false);
|
2017-11-20 19:54:05 +00:00
|
|
|
void clearUpTill(MsgId availableMinId);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-02-25 10:32:31 +00:00
|
|
|
virtual ~History();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-29 17:17:00 +00:00
|
|
|
HistoryItem *addNewService(MsgId msgId, QDateTime date, const QString &text, MTPDmessage::Flags flags = 0, bool newMsg = true);
|
2015-09-21 20:57:42 +00:00
|
|
|
HistoryItem *addNewMessage(const MTPMessage &msg, NewMessageType type);
|
|
|
|
HistoryItem *addToHistory(const MTPMessage &msg);
|
2017-07-12 19:14:20 +00:00
|
|
|
HistoryItem *addNewForwarded(MsgId id, MTPDmessage::Flags flags, QDateTime date, UserId from, const QString &postAuthor, HistoryMessage *item);
|
|
|
|
HistoryItem *addNewDocument(MsgId id, MTPDmessage::Flags flags, UserId viaBotId, MsgId replyTo, QDateTime date, UserId from, const QString &postAuthor, DocumentData *doc, const QString &caption, const MTPReplyMarkup &markup);
|
|
|
|
HistoryItem *addNewPhoto(MsgId id, MTPDmessage::Flags flags, UserId viaBotId, MsgId replyTo, QDateTime date, UserId from, const QString &postAuthor, PhotoData *photo, const QString &caption, const MTPReplyMarkup &markup);
|
|
|
|
HistoryItem *addNewGame(MsgId id, MTPDmessage::Flags flags, UserId viaBotId, MsgId replyTo, QDateTime date, UserId from, const QString &postAuthor, GameData *game, const MTPReplyMarkup &markup);
|
2015-01-02 14:55:24 +00:00
|
|
|
|
2017-06-18 13:08:49 +00:00
|
|
|
// Used only internally and for channel admin log.
|
|
|
|
HistoryItem *createItem(const MTPMessage &msg, bool applyServiceAction, bool detachExistingItem);
|
|
|
|
|
2016-05-27 16:47:46 +00:00
|
|
|
void addOlderSlice(const QVector<MTPMessage> &slice);
|
|
|
|
void addNewerSlice(const QVector<MTPMessage> &slice);
|
2016-01-03 01:43:42 +00:00
|
|
|
bool addToOverview(MediaOverviewType type, MsgId msgId, AddToOverviewMethod method);
|
|
|
|
void eraseFromOverview(MediaOverviewType type, MsgId msgId);
|
2014-07-04 11:12:54 +00:00
|
|
|
|
|
|
|
void newItemAdded(HistoryItem *item);
|
|
|
|
|
2016-03-22 15:23:34 +00:00
|
|
|
int countUnread(MsgId upTo);
|
2015-09-19 09:13:21 +00:00
|
|
|
void updateShowFrom();
|
2015-09-06 10:17:09 +00:00
|
|
|
MsgId inboxRead(MsgId upTo);
|
|
|
|
MsgId inboxRead(HistoryItem *wasRead);
|
|
|
|
MsgId outboxRead(MsgId upTo);
|
|
|
|
MsgId outboxRead(HistoryItem *wasRead);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-02-10 14:16:50 +00:00
|
|
|
HistoryItem *lastAvailableMessage() const;
|
2015-09-20 08:55:41 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
int unreadCount() const {
|
|
|
|
return _unreadCount;
|
|
|
|
}
|
2016-04-14 19:24:42 +00:00
|
|
|
void setUnreadCount(int newUnreadCount);
|
2016-04-11 10:59:01 +00:00
|
|
|
bool mute() const {
|
|
|
|
return _mute;
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
void setMute(bool newMute);
|
2016-03-22 15:23:34 +00:00
|
|
|
void getNextShowFrom(HistoryBlock *block, int i);
|
2014-05-30 08:53:19 +00:00
|
|
|
void addUnreadBar();
|
2016-03-18 19:05:08 +00:00
|
|
|
void destroyUnreadBar();
|
2014-07-04 11:12:54 +00:00
|
|
|
void clearNotifications();
|
|
|
|
|
|
|
|
bool loadedAtBottom() const; // last message is in the list
|
2015-09-13 08:41:27 +00:00
|
|
|
void setNotLoadedAtBottom();
|
2014-07-04 11:12:54 +00:00
|
|
|
bool loadedAtTop() const; // nothing was added after loading history back
|
2016-05-27 16:47:46 +00:00
|
|
|
bool isReadyFor(MsgId msgId); // has messages for showing history at msgId
|
|
|
|
void getReadyFor(MsgId msgId);
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void setLastMessage(HistoryItem *msg);
|
2014-07-04 11:12:54 +00:00
|
|
|
void fixLastMessage(bool wasAtBottom);
|
|
|
|
|
2016-06-03 18:24:27 +00:00
|
|
|
bool needUpdateInChatList() const;
|
|
|
|
void updateChatListSortPosition();
|
2016-02-28 11:58:30 +00:00
|
|
|
void setChatsListDate(const QDateTime &date);
|
|
|
|
uint64 sortKeyInChatList() const {
|
|
|
|
return _sortKeyInChatList;
|
|
|
|
}
|
2016-04-11 11:14:54 +00:00
|
|
|
struct PositionInChatListChange {
|
|
|
|
int movedFrom;
|
|
|
|
int movedTo;
|
|
|
|
};
|
|
|
|
PositionInChatListChange adjustByPosInChatList(Dialogs::Mode list, Dialogs::IndexedList *indexed);
|
2016-04-11 10:59:01 +00:00
|
|
|
bool inChatList(Dialogs::Mode list) const {
|
2017-10-24 17:11:35 +00:00
|
|
|
return !chatListLinks(list).empty();
|
2016-02-28 11:58:30 +00:00
|
|
|
}
|
2016-04-11 10:59:01 +00:00
|
|
|
int posInChatList(Dialogs::Mode list) const;
|
|
|
|
Dialogs::Row *addToChatList(Dialogs::Mode list, Dialogs::IndexedList *indexed);
|
|
|
|
void removeFromChatList(Dialogs::Mode list, Dialogs::IndexedList *indexed);
|
|
|
|
void removeChatListEntryByLetter(Dialogs::Mode list, QChar letter);
|
|
|
|
void addChatListEntryByLetter(Dialogs::Mode list, QChar letter, Dialogs::Row *row);
|
2016-02-28 11:58:30 +00:00
|
|
|
void updateChatListEntry() const;
|
|
|
|
|
2016-12-13 07:59:57 +00:00
|
|
|
bool isPinnedDialog() const {
|
|
|
|
return (_pinnedIndex > 0);
|
|
|
|
}
|
|
|
|
void setPinnedDialog(bool isPinned);
|
2017-01-30 15:27:13 +00:00
|
|
|
void setPinnedIndex(int newPinnedIndex);
|
2016-12-13 07:59:57 +00:00
|
|
|
int getPinnedIndex() const {
|
|
|
|
return _pinnedIndex;
|
|
|
|
}
|
|
|
|
|
2014-07-04 11:12:54 +00:00
|
|
|
MsgId minMsgId() const;
|
|
|
|
MsgId maxMsgId() const;
|
2015-09-06 10:17:09 +00:00
|
|
|
MsgId msgIdForRead() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-21 18:40:00 +00:00
|
|
|
int resizeGetHeight(int newWidth);
|
2014-07-04 11:12:54 +00:00
|
|
|
|
|
|
|
void removeNotification(HistoryItem *item) {
|
|
|
|
if (!notifies.isEmpty()) {
|
2016-03-15 10:37:56 +00:00
|
|
|
for (auto i = notifies.begin(), e = notifies.end(); i != e; ++i) {
|
2014-07-04 11:12:54 +00:00
|
|
|
if ((*i) == item) {
|
|
|
|
notifies.erase(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HistoryItem *currentNotification() {
|
|
|
|
return notifies.isEmpty() ? 0 : notifies.front();
|
|
|
|
}
|
2015-04-23 15:50:11 +00:00
|
|
|
bool hasNotification() const {
|
|
|
|
return !notifies.isEmpty();
|
|
|
|
}
|
2014-07-04 11:12:54 +00:00
|
|
|
void skipNotification() {
|
|
|
|
if (!notifies.isEmpty()) {
|
|
|
|
notifies.pop_front();
|
|
|
|
}
|
|
|
|
}
|
2015-03-19 09:18:19 +00:00
|
|
|
void popNotification(HistoryItem *item) {
|
|
|
|
if (!notifies.isEmpty() && notifies.back() == item) notifies.pop_back();
|
|
|
|
}
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2016-03-19 16:55:15 +00:00
|
|
|
bool hasPendingResizedItems() const {
|
|
|
|
return _flags & Flag::f_has_pending_resized_items;
|
|
|
|
}
|
|
|
|
void setHasPendingResizedItems();
|
|
|
|
void setPendingResize() {
|
|
|
|
_flags |= Flag::f_pending_resize;
|
|
|
|
setHasPendingResizedItems();
|
|
|
|
}
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
void paintDialog(Painter &p, int32 w, bool sel) const;
|
2016-12-01 19:20:33 +00:00
|
|
|
bool updateSendActionNeedsAnimating(TimeMs ms, bool force = false);
|
|
|
|
void unregSendAction(UserData *from);
|
|
|
|
bool updateSendActionNeedsAnimating(UserData *user, const MTPSendMessageAction &action);
|
|
|
|
bool mySendActionUpdated(SendAction::Type type, bool doing);
|
2016-12-23 13:21:01 +00:00
|
|
|
bool paintSendAction(Painter &p, int x, int y, int availableWidth, int outerWidth, style::color color, TimeMs ms);
|
2016-12-01 19:20:33 +00:00
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
void clearLastKeyboard();
|
|
|
|
|
2016-03-23 11:47:32 +00:00
|
|
|
// optimization for userpics displayed on the left
|
|
|
|
// if this returns false there is no need to even try to handle them
|
|
|
|
bool canHaveFromPhotos() const;
|
|
|
|
|
2017-08-11 07:16:07 +00:00
|
|
|
int getUnreadMentionsLoadedCount() const {
|
|
|
|
return _unreadMentions.size();
|
|
|
|
}
|
|
|
|
MsgId getMinLoadedUnreadMention() const {
|
|
|
|
return _unreadMentions.empty() ? 0 : _unreadMentions.front();
|
|
|
|
}
|
|
|
|
MsgId getMaxLoadedUnreadMention() const {
|
|
|
|
return _unreadMentions.empty() ? 0 : _unreadMentions.back();
|
|
|
|
}
|
|
|
|
int getUnreadMentionsCount(int notLoadedValue = -1) const {
|
2017-08-14 10:38:23 +00:00
|
|
|
return _unreadMentionsCount ? *_unreadMentionsCount : notLoadedValue;
|
2017-08-11 07:16:07 +00:00
|
|
|
}
|
|
|
|
bool hasUnreadMentions() const {
|
|
|
|
return (getUnreadMentionsCount() > 0);
|
|
|
|
}
|
|
|
|
void setUnreadMentionsCount(int count);
|
|
|
|
bool addToUnreadMentions(MsgId msgId, AddToOverviewMethod method);
|
|
|
|
void eraseFromUnreadMentions(MsgId msgId);
|
|
|
|
void addUnreadMentionsSlice(const MTPmessages_Messages &result);
|
|
|
|
|
2017-09-27 18:45:26 +00:00
|
|
|
using Blocks = std::deque<HistoryBlock*>;
|
2015-09-19 09:13:21 +00:00
|
|
|
Blocks blocks;
|
|
|
|
|
2016-04-08 14:16:52 +00:00
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
int32 msgCount = 0;
|
|
|
|
MsgId inboxReadBefore = 1;
|
|
|
|
MsgId outboxReadBefore = 1;
|
|
|
|
HistoryItem *showFrom = nullptr;
|
|
|
|
HistoryItem *unreadBar = nullptr;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
|
|
|
PeerData *peer;
|
2016-04-08 14:16:52 +00:00
|
|
|
bool oldLoaded = false;
|
|
|
|
bool newLoaded = true;
|
|
|
|
HistoryItem *lastMsg = nullptr;
|
2016-04-23 11:40:42 +00:00
|
|
|
HistoryItem *lastSentMsg = nullptr;
|
2015-09-19 09:13:21 +00:00
|
|
|
QDateTime lastMsgDate;
|
|
|
|
|
|
|
|
typedef QList<HistoryItem*> NotifyQueue;
|
|
|
|
NotifyQueue notifies;
|
|
|
|
|
2016-06-09 14:31:10 +00:00
|
|
|
Data::Draft *localDraft() {
|
2016-06-03 18:24:27 +00:00
|
|
|
return _localDraft.get();
|
|
|
|
}
|
2016-06-09 14:31:10 +00:00
|
|
|
Data::Draft *cloudDraft() {
|
2016-06-03 18:24:27 +00:00
|
|
|
return _cloudDraft.get();
|
2016-04-08 14:16:52 +00:00
|
|
|
}
|
2016-06-09 14:31:10 +00:00
|
|
|
Data::Draft *editDraft() {
|
2016-04-10 19:20:48 +00:00
|
|
|
return _editDraft.get();
|
2016-04-08 14:16:52 +00:00
|
|
|
}
|
2017-02-21 13:45:56 +00:00
|
|
|
void setLocalDraft(std::unique_ptr<Data::Draft> &&draft);
|
2016-06-09 14:31:10 +00:00
|
|
|
void takeLocalDraft(History *from);
|
2016-06-03 18:24:27 +00:00
|
|
|
void createLocalDraftFromCloud();
|
2017-02-21 13:45:56 +00:00
|
|
|
void setCloudDraft(std::unique_ptr<Data::Draft> &&draft);
|
2016-06-09 14:31:10 +00:00
|
|
|
Data::Draft *createCloudDraft(Data::Draft *fromDraft);
|
2017-02-21 13:45:56 +00:00
|
|
|
void setEditDraft(std::unique_ptr<Data::Draft> &&draft);
|
2016-06-09 14:31:10 +00:00
|
|
|
void clearLocalDraft();
|
2016-06-03 18:24:27 +00:00
|
|
|
void clearCloudDraft();
|
2016-06-09 14:31:10 +00:00
|
|
|
void clearEditDraft();
|
|
|
|
void draftSavedToCloud();
|
|
|
|
Data::Draft *draft() {
|
2016-06-03 18:24:27 +00:00
|
|
|
return _editDraft ? editDraft() : localDraft();
|
2016-02-25 10:32:31 +00:00
|
|
|
}
|
|
|
|
|
2017-06-16 20:33:35 +00:00
|
|
|
QVector<FullMsgId> forwardDraft() const {
|
|
|
|
return _forwardDraft;
|
|
|
|
}
|
|
|
|
SelectedItemSet validateForwardDraft();
|
|
|
|
void setForwardDraft(const SelectedItemSet &items);
|
|
|
|
|
2016-03-21 18:40:00 +00:00
|
|
|
// some fields below are a property of a currently displayed instance of this
|
|
|
|
// conversation history not a property of the conversation history itself
|
|
|
|
public:
|
|
|
|
// we save the last showAtMsgId to restore the state when switching
|
|
|
|
// between different conversation histories
|
2016-04-08 14:16:52 +00:00
|
|
|
MsgId showAtMsgId = ShowAtUnreadMsgId;
|
2016-03-21 18:40:00 +00:00
|
|
|
|
|
|
|
// we save a pointer of the history item at the top of the displayed window
|
|
|
|
// together with an offset from the window top to the top of this message
|
|
|
|
// resulting scrollTop = top(scrollTopItem) + scrollTopOffset
|
2016-04-08 14:16:52 +00:00
|
|
|
HistoryItem *scrollTopItem = nullptr;
|
|
|
|
int scrollTopOffset = 0;
|
2016-03-21 18:40:00 +00:00
|
|
|
void forgetScrollState() {
|
|
|
|
scrollTopItem = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find the correct scrollTopItem and scrollTopOffset using given top
|
|
|
|
// of the displayed window relative to the history start coord
|
|
|
|
void countScrollState(int top);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// when this item is destroyed scrollTopItem just points to the next one
|
|
|
|
// and scrollTopOffset remains the same
|
|
|
|
// if we are at the bottom of the window scrollTopItem == nullptr and
|
|
|
|
// scrollTopOffset is undefined
|
|
|
|
void getNextScrollTopItem(HistoryBlock *block, int32 i);
|
|
|
|
|
|
|
|
// helper method for countScrollState(int top)
|
|
|
|
void countScrollTopItem(int top);
|
|
|
|
|
|
|
|
public:
|
2016-04-08 14:16:52 +00:00
|
|
|
bool lastKeyboardInited = false;
|
|
|
|
bool lastKeyboardUsed = false;
|
|
|
|
MsgId lastKeyboardId = 0;
|
|
|
|
MsgId lastKeyboardHiddenId = 0;
|
|
|
|
PeerId lastKeyboardFrom = 0;
|
2015-06-15 17:19:24 +00:00
|
|
|
|
2016-04-08 14:16:52 +00:00
|
|
|
mtpRequestId sendRequestId = 0;
|
2014-11-05 17:43:32 +00:00
|
|
|
|
2016-04-08 14:16:52 +00:00
|
|
|
mutable const HistoryItem *textCachedFor = nullptr; // cache
|
2016-06-07 19:59:39 +00:00
|
|
|
mutable Text lastItemTextCache;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-11-18 13:11:56 +00:00
|
|
|
bool overviewCountLoaded(int32 overviewIndex) const {
|
2017-08-11 07:16:07 +00:00
|
|
|
return _overviewCountData[overviewIndex] >= 0;
|
2015-11-16 16:04:37 +00:00
|
|
|
}
|
2015-11-18 13:11:56 +00:00
|
|
|
bool overviewLoaded(int32 overviewIndex) const {
|
2017-08-11 07:16:07 +00:00
|
|
|
return overviewCount(overviewIndex) == _overview[overviewIndex].size();
|
2015-11-18 13:11:56 +00:00
|
|
|
}
|
2017-08-11 07:16:07 +00:00
|
|
|
int overviewCount(int32 overviewIndex, int32 defaultValue = -1) const {
|
|
|
|
auto result = _overviewCountData[overviewIndex];
|
|
|
|
auto loaded = _overview[overviewIndex].size();
|
2015-11-18 13:11:56 +00:00
|
|
|
if (result < 0) return defaultValue;
|
|
|
|
if (result < loaded) {
|
|
|
|
if (result > 0) {
|
2017-08-11 07:16:07 +00:00
|
|
|
const_cast<History*>(this)->_overviewCountData[overviewIndex] = 0;
|
2015-11-18 13:11:56 +00:00
|
|
|
}
|
|
|
|
return loaded;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2017-08-11 07:16:07 +00:00
|
|
|
const OrderedSet<MsgId> &overview(int32 overviewIndex) const {
|
|
|
|
return _overview[overviewIndex];
|
|
|
|
}
|
2015-11-18 13:11:56 +00:00
|
|
|
MsgId overviewMinId(int32 overviewIndex) const {
|
2017-08-11 07:16:07 +00:00
|
|
|
return _overview[overviewIndex].empty() ? 0 : *_overview[overviewIndex].begin();
|
2015-11-18 13:11:56 +00:00
|
|
|
}
|
2017-09-04 11:40:02 +00:00
|
|
|
void overviewSliceDone(
|
|
|
|
int32 overviewIndex,
|
|
|
|
MsgId startMessageId,
|
|
|
|
const MTPmessages_Messages &result,
|
|
|
|
bool onlyCounts = false);
|
2015-11-18 13:11:56 +00:00
|
|
|
bool overviewHasMsgId(int32 overviewIndex, MsgId msgId) const {
|
2017-08-11 07:16:07 +00:00
|
|
|
return _overview[overviewIndex].contains(msgId);
|
2015-11-16 16:04:37 +00:00
|
|
|
}
|
|
|
|
|
2015-11-18 13:11:56 +00:00
|
|
|
void changeMsgId(MsgId oldId, MsgId newId);
|
|
|
|
|
2016-06-07 19:59:39 +00:00
|
|
|
Text cloudDraftTextCache;
|
2016-06-03 18:24:27 +00:00
|
|
|
|
2016-03-15 10:37:56 +00:00
|
|
|
protected:
|
|
|
|
void clearOnDestroy();
|
2016-03-19 18:32:17 +00:00
|
|
|
HistoryItem *addNewToLastBlock(const MTPMessage &msg, NewMessageType type);
|
2016-03-15 10:37:56 +00:00
|
|
|
|
2016-03-31 10:37:58 +00:00
|
|
|
friend class HistoryBlock;
|
|
|
|
|
|
|
|
// this method just removes a block from the blocks list
|
|
|
|
// when the last item from this block was detached and
|
|
|
|
// calls the required previousItemChanged()
|
|
|
|
void removeBlock(HistoryBlock *block);
|
|
|
|
|
|
|
|
void clearBlocks(bool leaveItems);
|
|
|
|
|
2017-07-12 19:14:20 +00:00
|
|
|
HistoryItem *createItemForwarded(MsgId id, MTPDmessage::Flags flags, QDateTime date, UserId from, const QString &postAuthor, HistoryMessage *msg);
|
|
|
|
HistoryItem *createItemDocument(MsgId id, MTPDmessage::Flags flags, UserId viaBotId, MsgId replyTo, QDateTime date, UserId from, const QString &postAuthor, DocumentData *doc, const QString &caption, const MTPReplyMarkup &markup);
|
|
|
|
HistoryItem *createItemPhoto(MsgId id, MTPDmessage::Flags flags, UserId viaBotId, MsgId replyTo, QDateTime date, UserId from, const QString &postAuthor, PhotoData *photo, const QString &caption, const MTPReplyMarkup &markup);
|
|
|
|
HistoryItem *createItemGame(MsgId id, MTPDmessage::Flags flags, UserId viaBotId, MsgId replyTo, QDateTime date, UserId from, const QString &postAuthor, GameData *game, const MTPReplyMarkup &markup);
|
2016-03-31 10:37:58 +00:00
|
|
|
|
|
|
|
HistoryItem *addNewItem(HistoryItem *adding, bool newMsg);
|
|
|
|
HistoryItem *addNewInTheMiddle(HistoryItem *newItem, int32 blockIndex, int32 itemIndex);
|
|
|
|
|
|
|
|
// All this methods add a new item to the first or last block
|
|
|
|
// depending on if we are in isBuildingFronBlock() state.
|
|
|
|
// The last block is created on the go if it is needed.
|
|
|
|
|
|
|
|
// Adds the item to the back or front block, depending on
|
|
|
|
// isBuildingFrontBlock(), creating the block if necessary.
|
|
|
|
void addItemToBlock(HistoryItem *item);
|
|
|
|
|
|
|
|
// Usually all new items are added to the last block.
|
|
|
|
// Only when we scroll up and add a new slice to the
|
|
|
|
// front we want to create a new front block.
|
|
|
|
void startBuildingFrontBlock(int expectedItemsCount = 1);
|
|
|
|
HistoryBlock *finishBuildingFrontBlock(); // Returns the built block or nullptr if nothing was added.
|
|
|
|
bool isBuildingFrontBlock() const {
|
2016-04-10 19:20:48 +00:00
|
|
|
return _buildingFrontBlock != nullptr;
|
2016-03-31 10:37:58 +00:00
|
|
|
}
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
private:
|
2016-04-11 07:43:40 +00:00
|
|
|
// After adding a new history slice check the lastMsg and newLoaded.
|
|
|
|
void checkLastMsg();
|
|
|
|
|
2016-08-14 19:15:45 +00:00
|
|
|
// Add all items to the media overview if we were not loaded at bottom and now are.
|
|
|
|
void checkAddAllToOverview();
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
template <int kSharedMediaTypeCount>
|
|
|
|
void addToSharedMedia(std::vector<MsgId> (&medias)[kSharedMediaTypeCount], bool force);
|
|
|
|
void addBlockToSharedMedia(HistoryBlock *block);
|
|
|
|
|
2016-03-31 10:37:58 +00:00
|
|
|
enum class Flag {
|
2016-03-19 16:55:15 +00:00
|
|
|
f_has_pending_resized_items = (1 << 0),
|
2016-03-31 10:37:58 +00:00
|
|
|
f_pending_resize = (1 << 1),
|
2016-03-19 16:55:15 +00:00
|
|
|
};
|
2017-08-31 16:28:58 +00:00
|
|
|
using Flags = base::flags<Flag>;
|
|
|
|
friend inline constexpr auto is_flag_type(Flag) { return true; };
|
|
|
|
|
|
|
|
Flags _flags = 0;
|
2017-08-11 07:16:07 +00:00
|
|
|
bool _mute = false;
|
|
|
|
int _unreadCount = 0;
|
|
|
|
|
2017-08-14 10:38:23 +00:00
|
|
|
base::optional<int> _unreadMentionsCount;
|
2017-08-11 07:16:07 +00:00
|
|
|
base::flat_set<MsgId> _unreadMentions;
|
2016-03-19 16:55:15 +00:00
|
|
|
|
2016-04-11 10:59:01 +00:00
|
|
|
Dialogs::RowsByLetter _chatListLinks[2];
|
|
|
|
Dialogs::RowsByLetter &chatListLinks(Dialogs::Mode list) {
|
|
|
|
return _chatListLinks[static_cast<int>(list)];
|
|
|
|
}
|
|
|
|
const Dialogs::RowsByLetter &chatListLinks(Dialogs::Mode list) const {
|
|
|
|
return _chatListLinks[static_cast<int>(list)];
|
|
|
|
}
|
|
|
|
Dialogs::Row *mainChatListLink(Dialogs::Mode list) const {
|
2017-10-24 17:11:35 +00:00
|
|
|
auto it = chatListLinks(list).find(0);
|
2017-08-17 09:06:26 +00:00
|
|
|
Assert(it != chatListLinks(list).cend());
|
2017-10-24 17:11:35 +00:00
|
|
|
return it->second;
|
2016-03-24 13:27:34 +00:00
|
|
|
}
|
2016-04-08 14:16:52 +00:00
|
|
|
uint64 _sortKeyInChatList = 0; // like ((unixtime) << 32) | (incremented counter)
|
2016-02-28 11:58:30 +00:00
|
|
|
|
2017-08-11 07:16:07 +00:00
|
|
|
OrderedSet<MsgId> _overview[OverviewCount];
|
|
|
|
int32 _overviewCountData[OverviewCount]; // -1 - not loaded, 0 - all loaded, > 0 - count, but not all loaded
|
2015-11-18 13:11:56 +00:00
|
|
|
|
2016-03-31 10:37:58 +00:00
|
|
|
// A pointer to the block that is currently being built.
|
|
|
|
// We hold this pointer so we can destroy it while building
|
|
|
|
// and then create a new one if it is necessary.
|
|
|
|
struct BuildingBlock {
|
|
|
|
int expectedItemsCount = 0; // optimization for block->items.reserve() call
|
|
|
|
HistoryBlock *block = nullptr;
|
|
|
|
};
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<BuildingBlock> _buildingFrontBlock;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2016-03-31 10:37:58 +00:00
|
|
|
// Creates if necessary a new block for adding item.
|
|
|
|
// Depending on isBuildingFrontBlock() gets front or back block.
|
|
|
|
HistoryBlock *prepareBlockForAddingItem();
|
2016-03-22 09:51:20 +00:00
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<Data::Draft> _localDraft, _cloudDraft;
|
|
|
|
std::unique_ptr<Data::Draft> _editDraft;
|
2017-06-16 20:33:35 +00:00
|
|
|
QVector<FullMsgId> _forwardDraft;
|
2016-04-08 14:16:52 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
using TypingUsers = QMap<UserData*, TimeMs>;
|
|
|
|
TypingUsers _typing;
|
|
|
|
using SendActionUsers = QMap<UserData*, SendAction>;
|
|
|
|
SendActionUsers _sendActions;
|
|
|
|
QString _sendActionString;
|
|
|
|
Text _sendActionText;
|
|
|
|
Ui::SendActionAnimation _sendActionAnimation;
|
|
|
|
QMap<SendAction::Type, TimeMs> _mySendActions;
|
|
|
|
|
2016-12-13 07:59:57 +00:00
|
|
|
int _pinnedIndex = 0; // > 0 for pinned dialogs
|
2016-12-01 19:20:33 +00:00
|
|
|
|
2016-03-22 09:51:20 +00:00
|
|
|
};
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
class HistoryJoined;
|
2015-09-19 09:13:21 +00:00
|
|
|
class ChannelHistory : public History {
|
|
|
|
public:
|
2017-02-10 14:16:50 +00:00
|
|
|
using History::History;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
|
|
|
void messageDetached(HistoryItem *msg);
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void getRangeDifference();
|
|
|
|
void getRangeDifferenceNext(int32 pts);
|
|
|
|
|
|
|
|
HistoryJoined *insertJoinedMessage(bool unread);
|
2015-09-25 07:47:32 +00:00
|
|
|
void checkJoinedMessage(bool createUnread = false);
|
2015-09-21 20:57:42 +00:00
|
|
|
const QDateTime &maxReadMessageDate();
|
|
|
|
|
2016-03-15 10:37:56 +00:00
|
|
|
~ChannelHistory();
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
private:
|
2015-09-20 08:55:41 +00:00
|
|
|
friend class History;
|
|
|
|
HistoryItem* addNewChannelMessage(const MTPMessage &msg, NewMessageType type);
|
|
|
|
HistoryItem *addNewToBlocks(const MTPMessage &msg, NewMessageType type);
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void checkMaxReadMessageDate();
|
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
void cleared(bool leaveItems);
|
2015-09-21 20:57:42 +00:00
|
|
|
|
|
|
|
QDateTime _maxReadMessageDate;
|
|
|
|
|
2017-02-10 14:16:50 +00:00
|
|
|
HistoryJoined *_joinedMessage = nullptr;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
MsgId _rangeDifferenceFromId, _rangeDifferenceToId;
|
|
|
|
int32 _rangeDifferencePts;
|
|
|
|
mtpRequestId _rangeDifferenceRequestId;
|
2015-07-03 08:47:16 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
class HistoryBlock {
|
|
|
|
public:
|
2017-08-17 08:31:24 +00:00
|
|
|
HistoryBlock(not_null<History*> history) : _history(history) {
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
HistoryBlock(const HistoryBlock &) = delete;
|
|
|
|
HistoryBlock &operator=(const HistoryBlock &) = delete;
|
|
|
|
|
2017-09-27 18:45:26 +00:00
|
|
|
std::vector<HistoryItem*> items;
|
2015-09-19 09:13:21 +00:00
|
|
|
|
2014-07-04 11:12:54 +00:00
|
|
|
void clear(bool leaveItems = false);
|
2014-05-30 08:53:19 +00:00
|
|
|
~HistoryBlock() {
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
void removeItem(HistoryItem *item);
|
|
|
|
|
2016-03-21 18:40:00 +00:00
|
|
|
int resizeGetHeight(int newWidth, bool resizeAllItems);
|
2017-05-12 13:53:08 +00:00
|
|
|
int y() const {
|
|
|
|
return _y;
|
|
|
|
}
|
|
|
|
void setY(int y) {
|
|
|
|
_y = y;
|
|
|
|
}
|
|
|
|
int height() const {
|
|
|
|
return _height;
|
|
|
|
}
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<History*> history() const {
|
2017-05-12 13:53:08 +00:00
|
|
|
return _history;
|
|
|
|
}
|
2016-03-15 10:37:56 +00:00
|
|
|
|
2016-06-13 18:42:25 +00:00
|
|
|
HistoryBlock *previousBlock() const {
|
2017-05-12 13:53:08 +00:00
|
|
|
Expects(_indexInHistory >= 0);
|
2016-03-21 18:40:00 +00:00
|
|
|
|
2017-05-12 13:53:08 +00:00
|
|
|
return (_indexInHistory > 0) ? _history->blocks.at(_indexInHistory - 1) : nullptr;
|
2016-03-18 19:05:08 +00:00
|
|
|
}
|
2016-06-13 18:42:25 +00:00
|
|
|
HistoryBlock *nextBlock() const {
|
2017-05-12 13:53:08 +00:00
|
|
|
Expects(_indexInHistory >= 0);
|
2016-06-13 18:42:25 +00:00
|
|
|
|
2017-05-12 13:53:08 +00:00
|
|
|
return (_indexInHistory + 1 < _history->blocks.size()) ? _history->blocks.at(_indexInHistory + 1) : nullptr;
|
2016-06-13 18:42:25 +00:00
|
|
|
}
|
2016-03-19 18:32:17 +00:00
|
|
|
void setIndexInHistory(int index) {
|
|
|
|
_indexInHistory = index;
|
|
|
|
}
|
2016-03-21 18:40:00 +00:00
|
|
|
int indexInHistory() const {
|
2017-05-12 13:53:08 +00:00
|
|
|
Expects(_indexInHistory >= 0);
|
|
|
|
Expects(_indexInHistory < _history->blocks.size());
|
|
|
|
Expects(_history->blocks[_indexInHistory] == this);
|
2016-03-21 18:40:00 +00:00
|
|
|
|
|
|
|
return _indexInHistory;
|
|
|
|
}
|
2016-03-18 19:05:08 +00:00
|
|
|
|
|
|
|
protected:
|
2017-08-17 08:31:24 +00:00
|
|
|
const not_null<History*> _history;
|
2017-05-12 13:53:08 +00:00
|
|
|
|
|
|
|
int _y = 0;
|
|
|
|
int _height = 0;
|
|
|
|
int _indexInHistory = -1;
|
2016-03-18 19:05:08 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|