2017-06-18 11:08:14 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-06-18 11:08:14 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-06-18 11:08:14 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "window/section_widget.h"
|
|
|
|
#include "window/section_memento.h"
|
2018-01-09 17:08:31 +00:00
|
|
|
#include "history/admin_log/history_admin_log_item.h"
|
2017-07-04 13:31:18 +00:00
|
|
|
#include "mtproto/sender.h"
|
2017-06-18 11:08:14 +00:00
|
|
|
|
|
|
|
namespace Notify {
|
|
|
|
struct PeerUpdate;
|
|
|
|
} // namespace Notify
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ScrollArea;
|
|
|
|
class PlainShadow;
|
|
|
|
class FlatButton;
|
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Profile {
|
|
|
|
class BackButton;
|
|
|
|
} // namespace Profile
|
|
|
|
|
|
|
|
namespace AdminLog {
|
|
|
|
|
|
|
|
class FixedBar;
|
|
|
|
class InnerWidget;
|
|
|
|
class SectionMemento;
|
|
|
|
|
2017-07-04 13:31:18 +00:00
|
|
|
struct FilterValue {
|
|
|
|
// Empty "flags" means all events.
|
|
|
|
MTPDchannelAdminLogEventsFilter::Flags flags = 0;
|
2017-08-17 08:31:24 +00:00
|
|
|
std::vector<not_null<UserData*>> admins;
|
2017-07-04 13:31:18 +00:00
|
|
|
bool allUsers = true;
|
|
|
|
};
|
|
|
|
|
2017-07-05 13:11:08 +00:00
|
|
|
inline bool operator==(const FilterValue &a, const FilterValue &b) {
|
|
|
|
return (a.flags == b.flags && a.admins == b.admins && a.allUsers == b.allUsers);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const FilterValue &a, const FilterValue &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
2017-07-05 18:11:31 +00:00
|
|
|
class Widget final : public Window::SectionWidget {
|
2017-06-18 11:08:14 +00:00
|
|
|
public:
|
2019-06-06 10:21:40 +00:00
|
|
|
Widget(QWidget *parent, not_null<Window::SessionController*> controller, not_null<ChannelData*> channel);
|
2017-06-18 11:08:14 +00:00
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<ChannelData*> channel() const;
|
2018-01-22 16:42:25 +00:00
|
|
|
Dialogs::RowDescriptor activeChat() const override;
|
2017-06-18 11:08:14 +00:00
|
|
|
|
|
|
|
bool hasTopBarShadow() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap grabForShowAnimation(const Window::SectionSlideParams ¶ms) override;
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
bool showInternal(
|
|
|
|
not_null<Window::SectionMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms) override;
|
2017-06-24 17:05:32 +00:00
|
|
|
std::unique_ptr<Window::SectionMemento> createMemento() override;
|
2017-06-18 11:08:14 +00:00
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
void setInternalState(const QRect &geometry, not_null<SectionMemento*> memento);
|
2017-06-18 11:08:14 +00:00
|
|
|
|
|
|
|
// Float player interface.
|
2017-09-16 16:53:41 +00:00
|
|
|
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
|
|
|
QRect rectForFloatPlayer() const override;
|
2017-06-18 11:08:14 +00:00
|
|
|
|
2017-07-04 13:31:18 +00:00
|
|
|
void applyFilter(FilterValue &&value);
|
2017-06-18 11:08:14 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
2017-10-03 17:41:44 +00:00
|
|
|
void showAnimatedHook(
|
|
|
|
const Window::SectionSlideParams ¶ms) override;
|
2017-06-18 11:08:14 +00:00
|
|
|
void showFinishedHook() override;
|
|
|
|
void doSetInnerFocus() override;
|
|
|
|
|
|
|
|
private:
|
2017-07-04 13:31:18 +00:00
|
|
|
void showFilter();
|
2017-06-18 11:08:14 +00:00
|
|
|
void onScroll();
|
|
|
|
void updateAdaptiveLayout();
|
2017-08-17 08:31:24 +00:00
|
|
|
void saveState(not_null<SectionMemento*> memento);
|
|
|
|
void restoreState(not_null<SectionMemento*> memento);
|
2018-11-16 12:15:14 +00:00
|
|
|
void setupShortcuts();
|
2017-06-18 11:08:14 +00:00
|
|
|
|
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
QPointer<InnerWidget> _inner;
|
|
|
|
object_ptr<FixedBar> _fixedBar;
|
|
|
|
object_ptr<Ui::PlainShadow> _fixedBarShadow;
|
|
|
|
object_ptr<Ui::FlatButton> _whatIsThis;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class SectionMemento : public Window::SectionMemento {
|
|
|
|
public:
|
2018-01-11 19:33:26 +00:00
|
|
|
using Element = HistoryView::Element;
|
2018-01-10 13:13:33 +00:00
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
SectionMemento(not_null<ChannelData*> channel) : _channel(channel) {
|
2017-06-18 11:08:14 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
object_ptr<Window::SectionWidget> createWidget(
|
|
|
|
QWidget *parent,
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2017-09-16 16:53:41 +00:00
|
|
|
Window::Column column,
|
|
|
|
const QRect &geometry) override;
|
2017-06-18 11:08:14 +00:00
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<ChannelData*> getChannel() const {
|
2017-06-18 11:08:14 +00:00
|
|
|
return _channel;
|
|
|
|
}
|
|
|
|
void setScrollTop(int scrollTop) {
|
|
|
|
_scrollTop = scrollTop;
|
|
|
|
}
|
|
|
|
int getScrollTop() const {
|
|
|
|
return _scrollTop;
|
|
|
|
}
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
void setAdmins(std::vector<not_null<UserData*>> admins) {
|
2017-07-04 13:31:18 +00:00
|
|
|
_admins = std::move(admins);
|
|
|
|
}
|
2017-08-17 08:31:24 +00:00
|
|
|
void setAdminsCanEdit(std::vector<not_null<UserData*>> admins) {
|
2017-07-05 18:11:31 +00:00
|
|
|
_adminsCanEdit = std::move(admins);
|
|
|
|
}
|
2017-08-17 08:31:24 +00:00
|
|
|
std::vector<not_null<UserData*>> takeAdmins() {
|
2017-07-04 13:31:18 +00:00
|
|
|
return std::move(_admins);
|
|
|
|
}
|
2017-08-17 08:31:24 +00:00
|
|
|
std::vector<not_null<UserData*>> takeAdminsCanEdit() {
|
2017-07-05 18:11:31 +00:00
|
|
|
return std::move(_adminsCanEdit);
|
|
|
|
}
|
2017-07-04 13:31:18 +00:00
|
|
|
|
2018-01-10 13:13:33 +00:00
|
|
|
void setItems(
|
|
|
|
std::vector<OwnedItem> &&items,
|
2019-01-13 11:47:00 +00:00
|
|
|
std::set<uint64> &&eventIds,
|
2018-01-10 13:13:33 +00:00
|
|
|
bool upLoaded,
|
|
|
|
bool downLoaded) {
|
2017-06-24 17:05:32 +00:00
|
|
|
_items = std::move(items);
|
2019-01-13 11:47:00 +00:00
|
|
|
_eventIds = std::move(eventIds);
|
2017-06-24 17:05:32 +00:00
|
|
|
_upLoaded = upLoaded;
|
|
|
|
_downLoaded = downLoaded;
|
|
|
|
}
|
2017-07-04 13:31:18 +00:00
|
|
|
void setFilter(FilterValue &&filter) {
|
|
|
|
_filter = std::move(filter);
|
|
|
|
}
|
2017-07-05 13:11:08 +00:00
|
|
|
void setSearchQuery(QString &&query) {
|
|
|
|
_searchQuery = std::move(query);
|
|
|
|
}
|
2018-01-10 13:13:33 +00:00
|
|
|
std::vector<OwnedItem> takeItems() {
|
2017-06-24 17:05:32 +00:00
|
|
|
return std::move(_items);
|
|
|
|
}
|
2019-01-13 11:47:00 +00:00
|
|
|
std::set<uint64> takeEventIds() {
|
|
|
|
return std::move(_eventIds);
|
2017-06-24 17:05:32 +00:00
|
|
|
}
|
|
|
|
bool upLoaded() const {
|
|
|
|
return _upLoaded;
|
|
|
|
}
|
|
|
|
bool downLoaded() const {
|
|
|
|
return _downLoaded;
|
|
|
|
}
|
2017-07-04 13:31:18 +00:00
|
|
|
FilterValue takeFilter() {
|
|
|
|
return std::move(_filter);
|
|
|
|
}
|
2017-07-05 13:11:08 +00:00
|
|
|
QString takeSearchQuery() {
|
|
|
|
return std::move(_searchQuery);
|
|
|
|
}
|
2017-06-24 17:05:32 +00:00
|
|
|
|
2017-06-18 11:08:14 +00:00
|
|
|
private:
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<ChannelData*> _channel;
|
2017-06-18 11:08:14 +00:00
|
|
|
int _scrollTop = 0;
|
2017-08-17 08:31:24 +00:00
|
|
|
std::vector<not_null<UserData*>> _admins;
|
|
|
|
std::vector<not_null<UserData*>> _adminsCanEdit;
|
2018-01-10 13:13:33 +00:00
|
|
|
std::vector<OwnedItem> _items;
|
2019-01-13 11:47:00 +00:00
|
|
|
std::set<uint64> _eventIds;
|
2017-06-24 17:05:32 +00:00
|
|
|
bool _upLoaded = false;
|
|
|
|
bool _downLoaded = true;
|
2017-07-04 13:31:18 +00:00
|
|
|
FilterValue _filter;
|
2017-07-05 13:11:08 +00:00
|
|
|
QString _searchQuery;
|
2017-06-18 11:08:14 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AdminLog
|