dialogs_pinned_list.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. class History;
  9. namespace Data {
  10. class SavedMessages;
  11. class Session;
  12. class Forum;
  13. } // namespace Data
  14. namespace Dialogs {
  15. class Key;
  16. class PinnedList final {
  17. public:
  18. PinnedList(FilterId filterId, int limit);
  19. void setLimit(int limit);
  20. // Places on the last place in the list otherwise.
  21. // Does nothing if already pinned.
  22. void addPinned(Key key);
  23. // if (pinned) places on the first place in the list.
  24. void setPinned(Key key, bool pinned);
  25. void clear();
  26. void applyList(
  27. not_null<Data::Session*> owner,
  28. const QVector<MTPDialogPeer> &list);
  29. void applyList(
  30. not_null<Data::SavedMessages*> sublistsOwner,
  31. const QVector<MTPDialogPeer> &list);
  32. void applyList(
  33. not_null<Data::Forum*> forum,
  34. const QVector<MTPint> &list);
  35. void applyList(const std::vector<not_null<History*>> &list);
  36. void reorder(Key key1, Key key2);
  37. const std::vector<Key> &order() const {
  38. return _data;
  39. }
  40. private:
  41. int addPinnedGetPosition(Key key);
  42. void applyLimit(int limit);
  43. FilterId _filterId = 0;
  44. int _limit = 0;
  45. std::vector<Key> _data;
  46. };
  47. } // namespace Dialogs