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
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
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
|
|
|
} // namespace Ui
|
|
|
|
|
2020-06-12 12:12:34 +00:00
|
|
|
namespace Data {
|
2016-06-02 13:02:55 +00:00
|
|
|
struct PeerUpdate;
|
2020-06-12 12:12:34 +00:00
|
|
|
} // namespace Data
|
2016-06-02 13:02:55 +00:00
|
|
|
|
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:
|
2020-06-12 12:12:34 +00:00
|
|
|
GroupMembersWidget(
|
2020-07-01 09:03:29 +00:00
|
|
|
QWidget *parent,
|
|
|
|
not_null<PeerData*> peer,
|
2020-06-12 12:12:34 +00:00
|
|
|
const style::PeerListItem &st);
|
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
|
|
|
|
|
|
|
signals:
|
|
|
|
void onlineCountUpdated(int onlineCount);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onUpdateOnlineDisplay();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Observed notifications.
|
2020-06-12 12:12:34 +00:00
|
|
|
void notifyPeerUpdated(const Data::PeerUpdate &update);
|
2016-06-03 07:20:24 +00:00
|
|
|
|
2017-01-11 05:30:51 +00:00
|
|
|
void removePeer(PeerData *selectedPeer);
|
2016-06-03 07:20:24 +00:00
|
|
|
void refreshMembers();
|
2019-01-13 08:03:34 +00:00
|
|
|
void fillChatMembers(not_null<ChatData*> chat);
|
|
|
|
void fillMegagroupMembers(not_null<ChannelData*> megagroup);
|
2016-06-03 07:20:24 +00:00
|
|
|
void sortMembers();
|
|
|
|
void updateOnlineCount();
|
2019-01-13 08:03:34 +00:00
|
|
|
void checkSelfAdmin(not_null<ChatData*> chat);
|
2016-10-23 21:03:10 +00:00
|
|
|
void preloadMore();
|
|
|
|
|
2016-06-03 07:20:24 +00:00
|
|
|
void refreshUserOnline(UserData *user);
|
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
struct Member : public Item {
|
2020-05-28 14:32:10 +00:00
|
|
|
explicit Member(not_null<UserData*> user);
|
|
|
|
not_null<UserData*> user() const;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
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);
|
2019-01-13 08:03:34 +00:00
|
|
|
not_null<Member*> computeMember(not_null<UserData*> user);
|
|
|
|
not_null<Member*> addUser(not_null<ChatData*> chat, not_null<UserData*> user);
|
|
|
|
not_null<Member*> addUser(not_null<ChannelData*> megagroup, not_null<UserData*> user);
|
|
|
|
void setItemFlags(not_null<Item*> item, not_null<ChatData*> chat);
|
|
|
|
void setItemFlags(
|
|
|
|
not_null<Item*> item,
|
|
|
|
not_null<ChannelData*> megagroup);
|
|
|
|
bool addUsersToEnd(not_null<ChannelData*> megagroup);
|
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
|