aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/playerlistwidget.h
blob: 217c9f92528f1666d6aac5253cd1f89b4abfe260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include "datatypes.h"

#include <QList>
#include <QListWidget>
#include <QMap>

class AOApplication;

class PlayerListWidget : public QListWidget
{
public:
  explicit PlayerListWidget(AOApplication *ao_app, QWidget *parent = nullptr);
  virtual ~PlayerListWidget();

  void registerPlayer(const PlayerRegister &update);
  void updatePlayer(const PlayerUpdate &update);

  void setAuthenticated(bool f_state);

private:
  AOApplication *ao_app;
  QMap<int, PlayerData> m_player_map;
  QMap<int, QListWidgetItem *> m_item_map;
  bool m_is_authenticated = false;

  void addPlayer(int playerId);
  void removePlayer(int playerId);
  void updatePlayer(int playerId, bool updateIcon);

  QString formatLabel(const PlayerData &data);

  void filterPlayerList();

private Q_SLOTS:
  void onCustomContextMenuRequested(const QPoint &pos);
};