calls_box_controller.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include "boxes/peer_list_box.h"
  9. #include "ui/layers/generic_box.h"
  10. #include "mtproto/sender.h"
  11. namespace Window {
  12. class SessionController;
  13. } // namespace Window
  14. namespace Calls {
  15. namespace GroupCalls {
  16. class ListController : public PeerListController {
  17. public:
  18. explicit ListController(not_null<Window::SessionController*> window);
  19. [[nodiscard]] rpl::producer<bool> shownValue() const;
  20. Main::Session &session() const override;
  21. void prepare() override;
  22. void rowClicked(not_null<PeerListRow*> row) override;
  23. void rowRightActionClicked(not_null<PeerListRow*> row) override;
  24. private:
  25. const not_null<Window::SessionController*> _window;
  26. base::flat_map<PeerId, not_null<PeerListRow*>> _groupCalls;
  27. rpl::variable<int> _fullCount;
  28. };
  29. } // namespace GroupCalls
  30. class BoxController : public PeerListController {
  31. public:
  32. explicit BoxController(not_null<Window::SessionController*> window);
  33. Main::Session &session() const override;
  34. void prepare() override;
  35. void rowClicked(not_null<PeerListRow*> row) override;
  36. void rowRightActionClicked(not_null<PeerListRow*> row) override;
  37. void loadMoreRows() override;
  38. base::unique_qptr<Ui::PopupMenu> rowContextMenu(
  39. QWidget *parent,
  40. not_null<PeerListRow*> row) override;
  41. private:
  42. void receivedCalls(const QVector<MTPMessage> &result);
  43. void refreshAbout();
  44. class GroupCallRow;
  45. class Row;
  46. Row *rowForItem(not_null<const HistoryItem*> item);
  47. enum class InsertWay {
  48. Append,
  49. Prepend,
  50. };
  51. bool insertRow(not_null<HistoryItem*> item, InsertWay way);
  52. std::unique_ptr<PeerListRow> createRow(
  53. not_null<HistoryItem*> item) const;
  54. const not_null<Window::SessionController*> _window;
  55. MTP::Sender _api;
  56. MsgId _offsetId = 0;
  57. int _loadRequestId = 0; // Not a real mtpRequestId.
  58. bool _allLoaded = false;
  59. };
  60. void ClearCallsBox(
  61. not_null<Ui::GenericBox*> box,
  62. not_null<Window::SessionController*> window);
  63. } // namespace Calls