info_polls_results_inner_widget.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "ui/rp_widget.h"
  9. #include "ui/widgets/scroll_area.h"
  10. #include "base/object_ptr.h"
  11. namespace Ui {
  12. class VerticalLayout;
  13. } // namespace Ui
  14. namespace Info {
  15. class Controller;
  16. } // namespace Info
  17. namespace Info::Polls {
  18. class Memento;
  19. class ListController;
  20. class InnerWidget final : public Ui::RpWidget {
  21. public:
  22. InnerWidget(
  23. QWidget *parent,
  24. not_null<Controller*> controller,
  25. not_null<PollData*> poll,
  26. FullMsgId contextId);
  27. [[nodiscard]] not_null<PollData*> poll() const {
  28. return _poll;
  29. }
  30. [[nodiscard]] FullMsgId contextId() const {
  31. return _contextId;
  32. }
  33. [[nodiscard]] auto scrollToRequests() const
  34. -> rpl::producer<Ui::ScrollToRequest>;
  35. [[nodiscard]] auto showPeerInfoRequests() const
  36. -> rpl::producer<not_null<PeerData*>>;
  37. [[nodiscard]] int desiredHeight() const;
  38. void saveState(not_null<Memento*> memento);
  39. void restoreState(not_null<Memento*> memento);
  40. protected:
  41. void visibleTopBottomUpdated(
  42. int visibleTop,
  43. int visibleBottom) override;
  44. private:
  45. void setupContent();
  46. not_null<Controller*> _controller;
  47. not_null<PollData*> _poll;
  48. FullMsgId _contextId;
  49. object_ptr<Ui::VerticalLayout> _content;
  50. base::flat_map<QByteArray, not_null<ListController*>> _sections;
  51. rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
  52. rpl::event_stream<not_null<PeerData*>> _showPeerInfoRequests;
  53. rpl::variable<int> _visibleTop = 0;
  54. };
  55. } // namespace Info::Polls