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
|
|
|
|
|
2018-01-05 18:57:18 +03:00
|
|
|
#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"
|
2020-03-25 17:28:59 +04:00
|
|
|
#include "base/weak_ptr.h"
|
2018-01-05 18:57:18 +03:00
|
|
|
|
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 {
|
|
|
|
|
2018-01-23 19:51:12 +03:00
|
|
|
class Session;
|
2018-01-29 16:52:09 +03:00
|
|
|
|
2022-10-08 15:14:38 +04:00
|
|
|
class Folder final : public Dialogs::Entry {
|
2018-01-04 12:40:58 +03:00
|
|
|
public:
|
2018-01-23 19:51:12 +03:00
|
|
|
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
|
|
|
|
2022-09-20 22:12:30 +04:00
|
|
|
[[nodiscard]] FolderId id() const;
|
2019-04-16 12:50:59 +04:00
|
|
|
void registerOne(not_null<History*> history);
|
|
|
|
void unregisterOne(not_null<History*> history);
|
2019-04-22 19:09:03 +04:00
|
|
|
void oneListMessageChanged(HistoryItem *from, HistoryItem *to);
|
2018-01-04 12:40:58 +03:00
|
|
|
|
2023-03-09 12:38:40 +04:00
|
|
|
void clearChatsList();
|
2022-09-20 22:12:30 +04:00
|
|
|
[[nodiscard]] not_null<Dialogs::MainList*> chatsList();
|
2018-01-05 18:57:18 +03:00
|
|
|
|
2019-04-16 12:50:59 +04:00
|
|
|
void applyDialog(const MTPDdialogFolder &data);
|
2019-04-19 12:47:49 +04:00
|
|
|
void applyPinnedUpdate(const MTPDupdateDialogPinned &data);
|
|
|
|
|
2019-04-18 13:00:38 +04:00
|
|
|
TimeId adjustedChatListTimeId() const override;
|
2018-01-31 20:10:29 +03:00
|
|
|
|
2019-04-18 15:31:30 +04:00
|
|
|
int fixedOnTopIndex() const override;
|
2018-01-23 19:51:12 +03:00
|
|
|
bool shouldBeInChatList() const override;
|
2019-04-22 18:22:39 +04:00
|
|
|
Dialogs::UnreadState chatListUnreadState() const override;
|
2022-10-20 12:57:12 +04:00
|
|
|
Dialogs::BadgesState chatListBadgesState() const override;
|
2019-01-15 15:57:45 +04:00
|
|
|
HistoryItem *chatListMessage() const override;
|
|
|
|
bool chatListMessageKnown() const override;
|
|
|
|
const QString &chatListName() const override;
|
2021-02-19 15:54:27 +04:00
|
|
|
const QString &chatListNameSortKey() const override;
|
2023-12-27 01:09:20 +00:00
|
|
|
int chatListNameVersion() const override;
|
2019-01-15 15:57:45 +04:00
|
|
|
const base::flat_set<QString> &chatListNameWords() const override;
|
|
|
|
const base::flat_set<QChar> &chatListFirstLetters() const override;
|
2018-01-22 12:33:09 +03:00
|
|
|
|
2023-02-09 09:56:47 +04:00
|
|
|
void chatListPreloadData() override;
|
2018-01-05 18:57:18 +03:00
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
2022-12-05 16:18:10 +04:00
|
|
|
Ui::PeerUserpicView &view,
|
2022-09-29 14:33:17 +04:00
|
|
|
const Dialogs::Ui::PaintContext &context) const override;
|
|
|
|
void paintUserpic(Painter &p, int x, int y, int size) const;
|
2019-05-16 11:39:45 +03:00
|
|
|
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;
|
2019-05-16 11:39:45 +03:00
|
|
|
|
2019-05-08 11:50:39 +03:00
|
|
|
const std::vector<not_null<History*>> &lastHistories() const;
|
2022-11-13 23:38:18 +04:00
|
|
|
void validateListEntryCache();
|
|
|
|
[[nodiscard]] const Ui::Text::String &listEntryCache() const {
|
|
|
|
return _listEntryCache;
|
|
|
|
}
|
2018-01-29 16:52:09 +03:00
|
|
|
|
2023-07-18 12:15:19 +04:00
|
|
|
void updateStoriesCount(int count, int unread);
|
|
|
|
[[nodiscard]] int storiesCount() const;
|
|
|
|
[[nodiscard]] int storiesUnreadCount() const;
|
|
|
|
|
2018-01-04 12:40:58 +03:00
|
|
|
private:
|
2018-01-22 12:33:09 +03:00
|
|
|
void indexNameParts();
|
2018-12-04 14:32:06 +04:00
|
|
|
|
2019-05-08 11:50:39 +03:00
|
|
|
void reorderLastHistories();
|
2019-04-23 16:29:23 +04:00
|
|
|
|
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;
|
|
|
|
|
2022-09-20 22:12:30 +04:00
|
|
|
const FolderId _id = 0;
|
2019-04-22 18:22:39 +04:00
|
|
|
Dialogs::MainList _chatsList;
|
2018-01-05 18:57:18 +03:00
|
|
|
|
2018-01-22 12:33:09 +03:00
|
|
|
QString _name;
|
|
|
|
base::flat_set<QString> _nameWords;
|
|
|
|
base::flat_set<QChar> _nameFirstLetters;
|
2018-01-05 18:57:18 +03:00
|
|
|
|
2019-05-08 11:50:39 +03:00
|
|
|
std::vector<not_null<History*>> _lastHistories;
|
2022-11-13 23:38:18 +04:00
|
|
|
|
|
|
|
Ui::Text::String _listEntryCache;
|
|
|
|
int _listEntryCacheVersion = 0;
|
|
|
|
int _chatListViewVersion = 0;
|
2019-04-17 17:22:37 +04:00
|
|
|
//rpl::variable<MessagePosition> _unreadPosition;
|
2018-01-04 12:40:58 +03:00
|
|
|
|
2023-07-18 12:15:19 +04:00
|
|
|
uint16_t _storiesCount = 0;
|
|
|
|
uint16_t _storiesUnreadCount = 0;
|
|
|
|
|
2019-04-23 17:28:44 +04:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
2018-01-04 12:40:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|