2016-05-31 19:27:11 +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.
|
2016-05-31 19:27:11 +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
|
2016-05-31 19:27:11 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
#include "profile/profile_block_peer_list.h"
|
2016-05-31 19:27:11 +00:00
|
|
|
|
2016-06-02 13:02:55 +00:00
|
|
|
namespace Ui {
|
2016-11-16 10:44:06 +00:00
|
|
|
class FlatLabel;
|
2016-06-02 13:02:55 +00:00
|
|
|
class LeftOutlineButton;
|
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Notify {
|
|
|
|
struct PeerUpdate;
|
|
|
|
} // namespace Notify
|
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
namespace Profile {
|
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
class GroupMembersWidget : public PeerListWidget {
|
2016-06-03 07:20:24 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
public:
|
2016-06-17 18:18:01 +00:00
|
|
|
enum class TitleVisibility {
|
|
|
|
Visible,
|
|
|
|
Hidden,
|
|
|
|
};
|
2017-09-26 17:57:01 +00:00
|
|
|
GroupMembersWidget(QWidget *parent, PeerData *peer, TitleVisibility titleVisibility = TitleVisibility::Visible, const style::PeerListItem &st = st::profileMemberItem);
|
2016-05-31 19:27:11 +00:00
|
|
|
|
2016-06-03 07:20:24 +00:00
|
|
|
int onlineCount() const {
|
|
|
|
return _onlineCount;
|
|
|
|
}
|
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
~GroupMembersWidget();
|
2016-06-03 07:20:24 +00:00
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
protected:
|
|
|
|
// Resizes content and counts natural widget height for the desired width.
|
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
|
2016-06-03 07:20:24 +00:00
|
|
|
void paintContents(Painter &p) override;
|
|
|
|
|
2017-01-11 05:30:51 +00:00
|
|
|
Ui::PopupMenu *fillPeerMenu(PeerData *peer) override;
|
|
|
|
|
2016-06-03 07:20:24 +00:00
|
|
|
signals:
|
|
|
|
void onlineCountUpdated(int onlineCount);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onUpdateOnlineDisplay();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Observed notifications.
|
|
|
|
void notifyPeerUpdated(const Notify::PeerUpdate &update);
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
void editAdmin(not_null<UserData*> user);
|
|
|
|
void restrictUser(not_null<UserData*> user);
|
2017-01-11 05:30:51 +00:00
|
|
|
void removePeer(PeerData *selectedPeer);
|
2016-06-03 07:20:24 +00:00
|
|
|
void refreshMembers();
|
|
|
|
void fillChatMembers(ChatData *chat);
|
|
|
|
void fillMegagroupMembers(ChannelData *megagroup);
|
|
|
|
void sortMembers();
|
|
|
|
void updateOnlineCount();
|
|
|
|
void checkSelfAdmin(ChatData *chat);
|
2016-06-03 21:46:45 +00:00
|
|
|
void refreshLimitReached();
|
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
void preloadMore();
|
|
|
|
|
2016-06-03 21:46:45 +00:00
|
|
|
bool limitReachedHook(const ClickHandlerPtr &handler, Qt::MouseButton button);
|
2016-06-03 07:20:24 +00:00
|
|
|
|
|
|
|
void refreshUserOnline(UserData *user);
|
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
int getListTop() const override;
|
2016-06-03 07:20:24 +00:00
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
struct Member : public Item {
|
|
|
|
explicit Member(UserData *user) : Item(user) {
|
|
|
|
}
|
|
|
|
UserData *user() const {
|
|
|
|
return static_cast<UserData*>(peer);
|
2016-06-03 07:20:24 +00:00
|
|
|
}
|
|
|
|
TimeId onlineTextTill = 0;
|
|
|
|
TimeId onlineTill = 0;
|
|
|
|
TimeId onlineForSort = 0;
|
|
|
|
};
|
2016-10-23 21:03:10 +00:00
|
|
|
Member *getMember(Item *item) {
|
|
|
|
return static_cast<Member*>(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateItemStatusText(Item *item);
|
|
|
|
Member *computeMember(UserData *user);
|
2016-06-03 07:20:24 +00:00
|
|
|
Member *addUser(ChatData *chat, UserData *user);
|
|
|
|
Member *addUser(ChannelData *megagroup, UserData *user);
|
2016-10-23 21:03:10 +00:00
|
|
|
void setItemFlags(Item *item, ChatData *chat);
|
|
|
|
void setItemFlags(Item *item, ChannelData *megagroup);
|
2016-06-03 07:20:24 +00:00
|
|
|
bool addUsersToEnd(ChannelData *megagroup);
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _limitReachedInfo = { nullptr };
|
2016-06-03 07:20:24 +00:00
|
|
|
|
|
|
|
QMap<UserData*, Member*> _membersByUser;
|
|
|
|
bool _sortByOnline = false;
|
|
|
|
TimeId _now = 0;
|
|
|
|
|
|
|
|
int _onlineCount = 0;
|
|
|
|
TimeId _updateOnlineAt = 0;
|
|
|
|
QTimer _updateOnlineTimer;
|
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Profile
|