tdesktop/Telegram/SourceFiles/data/data_folder.h

111 lines
2.8 KiB
C
Raw Normal View History

2018-01-04 09:40:58 +00: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 14:22:39 +00:00
#include "dialogs/dialogs_main_list.h"
2018-01-09 17:08:31 +00:00
#include "data/data_messages.h"
#include "base/weak_ptr.h"
2018-01-04 09:40:58 +00:00
class ChannelData;
2019-07-24 11:45:24 +00:00
namespace Main {
class Session;
} // namespace Main
2018-01-04 09:40:58 +00:00
namespace Data {
class Session;
class Folder final : public Dialogs::Entry {
2018-01-04 09:40:58 +00:00
public:
static constexpr auto kId = 1;
2019-04-15 11:54:03 +00:00
Folder(not_null<Data::Session*> owner, FolderId id);
Folder(const Folder &) = delete;
Folder &operator=(const Folder &) = delete;
2019-01-15 11:57:45 +00:00
2022-09-20 18:12:30 +00:00
[[nodiscard]] FolderId id() const;
void registerOne(not_null<History*> history);
void unregisterOne(not_null<History*> history);
void oneListMessageChanged(HistoryItem *from, HistoryItem *to);
2018-01-04 09:40:58 +00:00
2022-09-20 18:12:30 +00:00
[[nodiscard]] not_null<Dialogs::MainList*> chatsList();
void applyDialog(const MTPDdialogFolder &data);
2019-04-19 08:47:49 +00:00
void applyPinnedUpdate(const MTPDupdateDialogPinned &data);
TimeId adjustedChatListTimeId() const override;
2019-04-18 11:31:30 +00:00
int fixedOnTopIndex() const override;
bool shouldBeInChatList() const override;
2019-04-22 14:22:39 +00:00
Dialogs::UnreadState chatListUnreadState() const override;
Dialogs::BadgesState chatListBadgesState() const override;
2019-01-15 11:57:45 +00:00
HistoryItem *chatListMessage() const override;
bool chatListMessageKnown() const override;
void requestChatListMessage() override;
const QString &chatListName() const override;
const QString &chatListNameSortKey() const override;
2019-01-15 11:57:45 +00:00
const base::flat_set<QString> &chatListNameWords() const override;
const base::flat_set<QChar> &chatListFirstLetters() const override;
void chatListPreloadData() override;
void paintUserpic(
Painter &p,
Ui::PeerUserpicView &view,
const Dialogs::Ui::PaintContext &context) const override;
void paintUserpic(Painter &p, int x, int y, int size) const;
void paintUserpic(
Painter &p,
int x,
int y,
int size,
2019-06-17 13:26:08 +00:00
const style::color &overrideBg,
const style::color &overrideFg) const;
2019-05-08 08:50:39 +00:00
const std::vector<not_null<History*>> &lastHistories() const;
void validateListEntryCache();
[[nodiscard]] const Ui::Text::String &listEntryCache() const {
return _listEntryCache;
}
2018-01-04 09:40:58 +00:00
private:
void indexNameParts();
2018-12-04 10:32:06 +00:00
2022-08-09 11:12:19 +00:00
int chatListNameVersion() const override;
2019-05-08 08:50:39 +00:00
void reorderLastHistories();
2019-06-17 13:26:08 +00:00
void paintUserpic(
Painter &p,
int x,
int y,
int size,
const style::color *overrideBg,
const style::color *overrideFg) const;
2022-09-20 18:12:30 +00:00
const FolderId _id = 0;
2019-04-22 14:22:39 +00:00
Dialogs::MainList _chatsList;
QString _name;
base::flat_set<QString> _nameWords;
base::flat_set<QChar> _nameFirstLetters;
2019-05-08 08:50:39 +00:00
std::vector<not_null<History*>> _lastHistories;
Ui::Text::String _listEntryCache;
int _listEntryCacheVersion = 0;
int _chatListViewVersion = 0;
//rpl::variable<MessagePosition> _unreadPosition;
2018-01-04 09:40:58 +00:00
rpl::lifetime _lifetime;
2018-01-04 09:40:58 +00:00
};
} // namespace Data