2017-06-18 13:08:49 +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 13:08:49 +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 13:08:49 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
namespace HistoryView {
|
2018-01-17 16:21:01 +00:00
|
|
|
class ElementDelegate;
|
2018-01-11 19:33:26 +00:00
|
|
|
class Element;
|
|
|
|
} // namespace HistoryView
|
|
|
|
|
2017-06-18 13:08:49 +00:00
|
|
|
namespace AdminLog {
|
|
|
|
|
2018-01-10 13:13:33 +00:00
|
|
|
class OwnedItem;
|
2017-06-21 23:54:38 +00:00
|
|
|
class LocalIdManager;
|
2017-06-21 21:38:31 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void GenerateItems(
|
2018-01-17 16:21:01 +00:00
|
|
|
not_null<HistoryView::ElementDelegate*> delegate,
|
2018-01-11 19:33:26 +00:00
|
|
|
not_null<History*> history,
|
2018-01-22 16:42:25 +00:00
|
|
|
not_null<LocalIdManager*> idManager,
|
2018-01-11 19:33:26 +00:00
|
|
|
const MTPDchannelAdminLogEvent &event,
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(OwnedItem item)> callback);
|
2017-06-18 13:08:49 +00:00
|
|
|
|
2017-06-21 23:54:38 +00:00
|
|
|
// Smart pointer wrapper for HistoryItem* that destroys the owned item.
|
2018-01-10 13:13:33 +00:00
|
|
|
class OwnedItem {
|
2017-06-21 23:54:38 +00:00
|
|
|
public:
|
2018-10-05 16:02:33 +00:00
|
|
|
OwnedItem(std::nullptr_t = nullptr);
|
2018-01-11 19:33:26 +00:00
|
|
|
OwnedItem(
|
2018-01-17 16:21:01 +00:00
|
|
|
not_null<HistoryView::ElementDelegate*> delegate,
|
2018-01-11 19:33:26 +00:00
|
|
|
not_null<HistoryItem*> data);
|
2018-01-10 13:13:33 +00:00
|
|
|
OwnedItem(const OwnedItem &other) = delete;
|
|
|
|
OwnedItem &operator=(const OwnedItem &other) = delete;
|
|
|
|
OwnedItem(OwnedItem &&other);
|
|
|
|
OwnedItem &operator=(OwnedItem &&other);
|
|
|
|
~OwnedItem();
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *get() const {
|
2018-01-10 13:13:33 +00:00
|
|
|
return _view.get();
|
2017-06-21 21:38:31 +00:00
|
|
|
}
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *operator->() const {
|
2017-06-21 23:54:38 +00:00
|
|
|
return get();
|
|
|
|
}
|
2018-01-11 19:33:26 +00:00
|
|
|
operator HistoryView::Element*() const {
|
2017-06-21 23:54:38 +00:00
|
|
|
return get();
|
2017-06-18 13:08:49 +00:00
|
|
|
}
|
|
|
|
|
2018-03-21 22:26:19 +00:00
|
|
|
void refreshView(not_null<HistoryView::ElementDelegate*> delegate);
|
|
|
|
|
2017-06-21 23:54:38 +00:00
|
|
|
private:
|
|
|
|
HistoryItem *_data = nullptr;
|
2018-01-11 19:33:26 +00:00
|
|
|
std::unique_ptr<HistoryView::Element> _view;
|
2017-06-18 13:08:49 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AdminLog
|