2016-05-31 19:27:11 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
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
|