Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
UserListWidget Class Reference

#include <user_list_widget.h>

Inheritance diagram for UserListWidget:
[legend]
Collaboration diagram for UserListWidget:
[legend]

Public Types

enum  UserListType { AllUsersList , RoomList , BuddyList , IgnoreList }
enum class  Section { Buddy , Online , Ignore }

Signals

void openMessageDialog (const QString &userName, bool focus)
void addBuddy (const QString &userName)
void removeBuddy (const QString &userName)
void addIgnore (const QString &userName)
void removeIgnore (const QString &userName)
void joinGameRequested (int gameId, int roomId, bool asSpectator)
void sectionExpanded (Section section, bool expanded)
void userActivated (const QString &userName)
void currentUserChanged (const QString &userName)
void userListChanged ()

Public Member Functions

 UserListWidget (TabSupervisor *_tabSupervisor, AbstractClient *_client, UserListType _type, QWidget *parent=nullptr, bool hasUserInfoPopup=true)
 ~UserListWidget () override
void bind (UserListManager *mgr)
void applyDisplayMode ()
void beginBulkLoad ()
void endBulkLoad ()
bool eventFilter (QObject *obj, QEvent *event) override
void retranslateUi ()
void rebuild ()
void processUserInfo (const ServerInfo_User &user, bool online)
bool deleteUser (const QString &userName)
void setUserOnline (const QString &userName, bool online)
void setFilterText (const QString &text)
void setShowTitle (bool showTitle)
void setSectioned (const QList< Section > &ids)
void setSectionExpanded (Section section, bool expanded)
void setUserFilter (std::function< bool(const QString &userName, bool online)> filter)
int visibleUserRowCount () const
bool getHasUserInfoPopup () const
const QList< Section > & getSectionIds () const
const QMap< QString, UserListTWI * > & getUsers () const
void showContextMenu (const QPoint &pos, const QModelIndex &index)
void sortItems ()
void setGameInviteLinkProvider (std::function< QList< GameInviteOption >()> provider)

Protected Member Functions

void hideEvent (QHideEvent *e) override
void showEvent (QShowEvent *e) override

Private Slots

void userClicked (QTreeWidgetItem *item, int column)
void refreshVisibleUserHeader (const QString &name)

Private Member Functions

void showPopupForUser (UserListTWI *item)
void hidePopup (bool immediate=false)
void positionPopup (UserListTWI *item)
void connectPopupSignals ()
bool isPressInsideListUi (const QWidget *widget) const
void clearSelectionAndClosePopup ()
bool isItemNearViewport (const UserListTWI *item) const
void requestVisibleItemResources ()
void createSectionItems ()
QTreeWidgetItem * createSectionItem (Section section)
QString sectionTitle (Section section) const
void updateSectionDivider (Section section)
void handleSectionExpansion (QTreeWidgetItem *item, bool expanded)
void setExpandedProgrammatically (QTreeWidgetItem *item, bool expanded)
void handleOnlineChange (const ServerInfo_User &user)
void handleOnlineChangeLeft (const QString &userName)
void handleListAdd (Section section, const ServerInfo_User &user)
void handleListRemove (Section section, const QString &userName)
UserListTWIensureSectionMembership (Section section, const ServerInfo_User &user, bool online)
bool dropSectionMembership (Section section, const QString &userName)
void finishSectionedMutation ()
void updateCardArtParams (const ServerInfo_User &user, const QString &userName)
void processUserInfo (Section section, const ServerInfo_User &user, bool online)
void updateCount ()
void applyFilter ()
void refreshPopupButtons (const QString &userName)

Private Attributes

UserListManagermanager = nullptr
UserAvatarProvideravatarProvider = nullptr
UserCardArtProvidercardArtProvider = nullptr
QMap< QString, CardArtParamscardArtParamsMap
UserInfoPopupuserInfoPopup = nullptr
QTimer * showPopupTimer = nullptr
QTimer * hidePopupTimer = nullptr
QString hoveredUser
bool popupPinned = false
bool bulkLoading = false
bool hasUserInfoPopup = true
std::function< bool(const QString &userName, bool online)> userFilter
bool sectioned = false
QList< SectionsectionIds
QMap< Section, QTreeWidgetItem * > sectionItems
QMap< Section, QMap< QString, UserListTWI * > > sectionUsers
QSet< SectionexpandedSections
QMap< QString, UserListTWI * > users
TabSupervisortabSupervisor
AbstractClientclient
UserListType type
QTreeWidget * userTree = nullptr
UserListItemDelegateitemDelegate
UserContextMenuuserContextMenu
int onlineCount
QString titleStr
QString filterText
bool showTitle = true

Member Enumeration Documentation

◆ Section

enum class UserListWidget::Section
strong
Enumerator
Buddy 
Online 
Ignore 

◆ UserListType

Enumerator
AllUsersList 
RoomList 
BuddyList 
IgnoreList 

Constructor & Destructor Documentation

◆ UserListWidget()

UserListWidget::UserListWidget ( TabSupervisor * _tabSupervisor,
AbstractClient * _client,
UserListType _type,
QWidget * parent = nullptr,
bool hasUserInfoPopup = true )
Here is the call graph for this function:

◆ ~UserListWidget()

UserListWidget::~UserListWidget ( )
override

Member Function Documentation

◆ addBuddy

void UserListWidget::addBuddy ( const QString & userName)
signal

◆ addIgnore

void UserListWidget::addIgnore ( const QString & userName)
signal

◆ applyDisplayMode()

void UserListWidget::applyDisplayMode ( )
Here is the call graph for this function:

◆ applyFilter()

void UserListWidget::applyFilter ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ beginBulkLoad()

void UserListWidget::beginBulkLoad ( )
Here is the caller graph for this function:

◆ bind()

void UserListWidget::bind ( UserListManager * mgr)
Here is the call graph for this function:

◆ clearSelectionAndClosePopup()

void UserListWidget::clearSelectionAndClosePopup ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connectPopupSignals()

void UserListWidget::connectPopupSignals ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createSectionItem()

QTreeWidgetItem * UserListWidget::createSectionItem ( Section section)
private
Here is the caller graph for this function:

◆ createSectionItems()

void UserListWidget::createSectionItems ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentUserChanged

void UserListWidget::currentUserChanged ( const QString & userName)
signal

Dialog mode: the current row changed; empty string means no user row.

Here is the caller graph for this function:

◆ deleteUser()

bool UserListWidget::deleteUser ( const QString & userName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dropSectionMembership()

bool UserListWidget::dropSectionMembership ( Section section,
const QString & userName )
private

Removes and deletes the row for userName in section.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endBulkLoad()

void UserListWidget::endBulkLoad ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureSectionMembership()

UserListTWI * UserListWidget::ensureSectionMembership ( Section section,
const ServerInfo_User & user,
bool online )
private

Creates or updates the row for user in section.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventFilter()

bool UserListWidget::eventFilter ( QObject * obj,
QEvent * event )
override
Here is the call graph for this function:

◆ finishSectionedMutation()

void UserListWidget::finishSectionedMutation ( )
private

Sorts, refilters and repaints after a sectioned mode mutation.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHasUserInfoPopup()

bool UserListWidget::getHasUserInfoPopup ( ) const
inlinenodiscard

◆ getSectionIds()

const QList< Section > & UserListWidget::getSectionIds ( ) const
inlinenodiscard

◆ getUsers()

const QMap< QString, UserListTWI * > & UserListWidget::getUsers ( ) const
inlinenodiscard

◆ handleListAdd()

void UserListWidget::handleListAdd ( Section section,
const ServerInfo_User & user )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleListRemove()

void UserListWidget::handleListRemove ( Section section,
const QString & userName )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleOnlineChange()

void UserListWidget::handleOnlineChange ( const ServerInfo_User & user)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleOnlineChangeLeft()

void UserListWidget::handleOnlineChangeLeft ( const QString & userName)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleSectionExpansion()

void UserListWidget::handleSectionExpansion ( QTreeWidgetItem * item,
bool expanded )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hideEvent()

void UserListWidget::hideEvent ( QHideEvent * e)
overrideprotected
Here is the call graph for this function:

◆ hidePopup()

void UserListWidget::hidePopup ( bool immediate = false)
private
Here is the caller graph for this function:

◆ isItemNearViewport()

bool UserListWidget::isItemNearViewport ( const UserListTWI * item) const
private
Here is the caller graph for this function:

◆ isPressInsideListUi()

bool UserListWidget::isPressInsideListUi ( const QWidget * widget) const
private

True when widget is the tree, the popup or an open menu.

Here is the caller graph for this function:

◆ joinGameRequested

void UserListWidget::joinGameRequested ( int gameId,
int roomId,
bool asSpectator )
signal
Here is the caller graph for this function:

◆ openMessageDialog

void UserListWidget::openMessageDialog ( const QString & userName,
bool focus )
signal
Here is the caller graph for this function:

◆ positionPopup()

void UserListWidget::positionPopup ( UserListTWI * item)
private
Here is the caller graph for this function:

◆ processUserInfo() [1/2]

void UserListWidget::processUserInfo ( const ServerInfo_User & user,
bool online )
Here is the call graph for this function:

◆ processUserInfo() [2/2]

void UserListWidget::processUserInfo ( Section section,
const ServerInfo_User & user,
bool online )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rebuild()

void UserListWidget::rebuild ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ refreshPopupButtons()

void UserListWidget::refreshPopupButtons ( const QString & userName)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ refreshVisibleUserHeader

void UserListWidget::refreshVisibleUserHeader ( const QString & name)
privateslot

◆ removeBuddy

void UserListWidget::removeBuddy ( const QString & userName)
signal

◆ removeIgnore

void UserListWidget::removeIgnore ( const QString & userName)
signal

◆ requestVisibleItemResources()

void UserListWidget::requestVisibleItemResources ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ retranslateUi()

void UserListWidget::retranslateUi ( )
Here is the call graph for this function:

◆ sectionExpanded

void UserListWidget::sectionExpanded ( Section section,
bool expanded )
signal
Here is the caller graph for this function:

◆ sectionTitle()

QString UserListWidget::sectionTitle ( Section section) const
nodiscardprivate
Here is the caller graph for this function:

◆ setExpandedProgrammatically()

void UserListWidget::setExpandedProgrammatically ( QTreeWidgetItem * item,
bool expanded )
private
Here is the caller graph for this function:

◆ setFilterText()

void UserListWidget::setFilterText ( const QString & text)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGameInviteLinkProvider()

void UserListWidget::setGameInviteLinkProvider ( std::function< QList< GameInviteOption >()> provider)

◆ setSectioned()

void UserListWidget::setSectioned ( const QList< Section > & ids)
Here is the call graph for this function:

◆ setSectionExpanded()

void UserListWidget::setSectionExpanded ( Section section,
bool expanded )
Here is the call graph for this function:

◆ setShowTitle()

void UserListWidget::setShowTitle ( bool showTitle)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUserFilter()

void UserListWidget::setUserFilter ( std::function< bool(const QString &userName, bool online)> filter)
inline

Dialog mode: rows that fail the predicate are never shown.

◆ setUserOnline()

void UserListWidget::setUserOnline ( const QString & userName,
bool online )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ showContextMenu()

void UserListWidget::showContextMenu ( const QPoint & pos,
const QModelIndex & index )
Here is the caller graph for this function:

◆ showEvent()

void UserListWidget::showEvent ( QShowEvent * e)
overrideprotected
Here is the call graph for this function:

◆ showPopupForUser()

void UserListWidget::showPopupForUser ( UserListTWI * item)
private

Popup functions are anchored on the row, not the user name. In sectioned mode a user can own several rows (online + buddy), and the popup must follow the hovered/selected row rather than a lookup by name.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sortItems()

void UserListWidget::sortItems ( )
Here is the caller graph for this function:

◆ updateCardArtParams()

void UserListWidget::updateCardArtParams ( const ServerInfo_User & user,
const QString & userName )
private
Here is the caller graph for this function:

◆ updateCount()

void UserListWidget::updateCount ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateSectionDivider()

void UserListWidget::updateSectionDivider ( Section section)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ userActivated

void UserListWidget::userActivated ( const QString & userName)
signal

Dialog mode: the user activated (Enter/double-click) the given row.

Here is the caller graph for this function:

◆ userClicked

void UserListWidget::userClicked ( QTreeWidgetItem * item,
int column )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ userListChanged

void UserListWidget::userListChanged ( )
signal

The set of visible rows changed (filter, search or a live mutation).

Here is the caller graph for this function:

◆ visibleUserRowCount()

int UserListWidget::visibleUserRowCount ( ) const
nodiscard

Member Data Documentation

◆ avatarProvider

UserAvatarProvider* UserListWidget::avatarProvider = nullptr
private

◆ bulkLoading

bool UserListWidget::bulkLoading = false
private

◆ cardArtParamsMap

QMap<QString, CardArtParams> UserListWidget::cardArtParamsMap
private

◆ cardArtProvider

UserCardArtProvider* UserListWidget::cardArtProvider = nullptr
private

◆ client

AbstractClient* UserListWidget::client
private

◆ expandedSections

QSet<Section> UserListWidget::expandedSections
private

◆ filterText

QString UserListWidget::filterText
private

◆ hasUserInfoPopup

bool UserListWidget::hasUserInfoPopup = true
private

◆ hidePopupTimer

QTimer* UserListWidget::hidePopupTimer = nullptr
private

◆ hoveredUser

QString UserListWidget::hoveredUser
private

◆ itemDelegate

UserListItemDelegate* UserListWidget::itemDelegate
private

◆ manager

UserListManager* UserListWidget::manager = nullptr
private

◆ onlineCount

int UserListWidget::onlineCount
private

◆ popupPinned

bool UserListWidget::popupPinned = false
private

◆ sectioned

bool UserListWidget::sectioned = false
private

◆ sectionIds

QList<Section> UserListWidget::sectionIds
private

◆ sectionItems

QMap<Section, QTreeWidgetItem *> UserListWidget::sectionItems
private

◆ sectionUsers

QMap<Section, QMap<QString, UserListTWI *> > UserListWidget::sectionUsers
private

◆ showPopupTimer

QTimer* UserListWidget::showPopupTimer = nullptr
private

◆ showTitle

bool UserListWidget::showTitle = true
private

◆ tabSupervisor

TabSupervisor* UserListWidget::tabSupervisor
private

◆ titleStr

QString UserListWidget::titleStr
private

◆ type

UserListType UserListWidget::type
private

◆ userContextMenu

UserContextMenu* UserListWidget::userContextMenu
private

◆ userFilter

std::function<bool(const QString &userName, bool online)> UserListWidget::userFilter
private

◆ userInfoPopup

UserInfoPopup* UserListWidget::userInfoPopup = nullptr
private

◆ users

QMap<QString, UserListTWI *> UserListWidget::users
private

◆ userTree

QTreeWidget* UserListWidget::userTree = nullptr
private

The documentation for this class was generated from the following files: