tdesktop/Telegram/SourceFiles/dialogs/dialogs_pinned_list.h

60 lines
1.2 KiB
C
Raw Normal View History

2019-04-19 08:47:49 +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
2020-03-17 13:04:30 +00:00
class History;
2019-04-19 08:47:49 +00:00
namespace Data {
class Session;
2022-11-08 13:57:54 +00:00
class Forum;
2019-04-19 08:47:49 +00:00
} // namespace Data
namespace Dialogs {
class Key;
2019-04-22 14:22:39 +00:00
class PinnedList final {
2019-04-19 08:47:49 +00:00
public:
2020-03-17 13:04:30 +00:00
PinnedList(FilterId filterId, int limit);
2019-04-19 08:47:49 +00:00
void setLimit(int limit);
// Places on the last place in the list otherwise.
// Does nothing if already pinned.
void addPinned(Key key);
2019-04-19 08:47:49 +00:00
// if (pinned) places on the first place in the list.
void setPinned(Key key, bool pinned);
2019-04-19 08:47:49 +00:00
void clear();
void applyList(
not_null<Data::Session*> owner,
const QVector<MTPDialogPeer> &list);
2022-11-08 13:57:54 +00:00
void applyList(
not_null<Data::Forum*> forum,
const QVector<MTPint> &list);
2020-03-17 13:04:30 +00:00
void applyList(const std::vector<not_null<History*>> &list);
void reorder(Key key1, Key key2);
2019-04-19 08:47:49 +00:00
const std::vector<Key> &order() const {
return _data;
}
private:
int addPinnedGetPosition(Key key);
2019-04-19 08:47:49 +00:00
void applyLimit(int limit);
2020-03-17 13:04:30 +00:00
FilterId _filterId = 0;
2019-04-19 08:47:49 +00:00
int _limit = 0;
std::vector<Key> _data;
};
} // namespace Dialogs