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;
|
|
|
|
} // 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(const Key &key);
|
|
|
|
|
|
|
|
// if (pinned) places on the first place in the list.
|
|
|
|
void setPinned(const Key &key, bool pinned);
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void applyList(
|
|
|
|
not_null<Data::Session*> owner,
|
|
|
|
const QVector<MTPDialogPeer> &list);
|
2020-03-17 13:04:30 +00:00
|
|
|
void applyList(const std::vector<not_null<History*>> &list);
|
2019-04-19 08:47:49 +00:00
|
|
|
void reorder(const Key &key1, const Key &key2);
|
|
|
|
|
|
|
|
const std::vector<Key> &order() const {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int addPinnedGetPosition(const Key &key);
|
|
|
|
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
|