tdesktop/Telegram/SourceFiles/data/data_folder.h

132 lines
3.4 KiB
C
Raw Normal View History

2018-01-04 12:40:58 +03:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "dialogs/dialogs_entry.h"
2019-04-22 18:22:39 +04:00
#include "dialogs/dialogs_main_list.h"
2018-01-09 20:08:31 +03:00
#include "data/data_messages.h"
2018-01-04 12:40:58 +03:00
class ChannelData;
2019-07-24 13:45:24 +02:00
namespace Main {
class Session;
} // namespace Main
2018-01-04 12:40:58 +03:00
namespace Data {
class Session;
2019-04-15 15:54:03 +04:00
class Folder;
2018-03-06 20:07:42 +03:00
//MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); // #feed
class Folder final : public Dialogs::Entry {
2018-01-04 12:40:58 +03:00
public:
static constexpr auto kId = 1;
2019-04-15 15:54:03 +04:00
Folder(not_null<Data::Session*> owner, FolderId id);
Folder(const Folder &) = delete;
Folder &operator=(const Folder &) = delete;
2019-01-15 15:57:45 +04:00
2019-04-15 15:54:03 +04:00
FolderId id() const;
void registerOne(not_null<History*> history);
void unregisterOne(not_null<History*> history);
void oneListMessageChanged(HistoryItem *from, HistoryItem *to);
2018-01-04 12:40:58 +03:00
2019-04-22 18:22:39 +04:00
not_null<Dialogs::MainList*> chatsList();
void applyDialog(const MTPDdialogFolder &data);
2019-04-19 12:47:49 +04:00
void applyPinnedUpdate(const MTPDupdateDialogPinned &data);
//MessagePosition unreadPosition() const; // #feed
//rpl::producer<MessagePosition> unreadPositionChanges() const; // #feed
2019-04-22 18:22:39 +04:00
void updateCloudUnread(const MTPDdialogFolder &data);
void unreadStateChanged(
const Dialogs::Key &key,
2019-04-22 18:22:39 +04:00
const Dialogs::UnreadState &wasState,
const Dialogs::UnreadState &nowState);
void unreadEntryChanged(
const Dialogs::Key &key,
const Dialogs::UnreadState &state,
bool added);
2019-04-19 12:47:49 +04:00
TimeId adjustedChatListTimeId() const override;
2019-04-18 15:31:30 +04:00
int fixedOnTopIndex() const override;
bool toImportant() const override;
bool shouldBeInChatList() const override;
int chatListUnreadCount() const override;
2018-06-26 19:03:45 +01:00
bool chatListUnreadMark() const override;
bool chatListMutedBadge() const override;
2019-04-22 18:22:39 +04:00
Dialogs::UnreadState chatListUnreadState() const override;
2019-01-15 15:57:45 +04:00
HistoryItem *chatListMessage() const override;
bool chatListMessageKnown() const override;
void requestChatListMessage() override;
const QString &chatListName() const override;
const base::flat_set<QString> &chatListNameWords() const override;
const base::flat_set<QChar> &chatListFirstLetters() const override;
void loadUserpic() override;
void paintUserpic(
Painter &p,
int x,
int y,
int size) const override;
void paintUserpic(
Painter &p,
int x,
int y,
int size,
2019-06-17 15:26:08 +02:00
const style::color &overrideBg,
const style::color &overrideFg) const;
bool chatsListLoaded() const;
2019-04-22 18:22:39 +04:00
void setChatsListLoaded(bool loaded = true);
void setCloudChatsListSize(int size);
int chatsListSize() const;
2019-05-08 11:50:39 +03:00
const std::vector<not_null<History*>> &lastHistories() const;
uint32 chatListViewVersion() const;
2018-01-04 12:40:58 +03:00
private:
void indexNameParts();
bool applyChatListMessage(HistoryItem *item);
void computeChatListMessage();
2018-12-04 14:32:06 +04:00
2019-05-08 11:50:39 +03:00
void reorderLastHistories();
void finalizeCloudUnread();
2019-06-17 15:26:08 +02:00
void paintUserpic(
Painter &p,
int x,
int y,
int size,
const style::color *overrideBg,
const style::color *overrideFg) const;
2019-04-15 15:54:03 +04:00
FolderId _id = 0;
2019-04-22 18:22:39 +04:00
Dialogs::MainList _chatsList;
QString _name;
base::flat_set<QString> _nameWords;
base::flat_set<QChar> _nameFirstLetters;
2019-04-22 18:22:39 +04:00
Dialogs::UnreadState _cloudUnread;
int _cloudChatsListSize = 0;
2019-05-08 11:50:39 +03:00
std::vector<not_null<History*>> _lastHistories;
HistoryItem *_chatListMessage = nullptr;
uint32 _chatListViewVersion = 0;
//rpl::variable<MessagePosition> _unreadPosition;
2018-01-04 12:40:58 +03:00
rpl::lifetime _lifetime;
2018-01-04 12:40:58 +03:00
};
} // namespace Data