7723
|
1 |
#ifndef PLAYERSLISTMODEL_H
|
|
2 |
#define PLAYERSLISTMODEL_H
|
|
3 |
|
7725
|
4 |
#include <QAbstractListModel>
|
|
5 |
#include <QHash>
|
|
6 |
#include <QIcon>
|
|
7 |
#include <QModelIndex>
|
7723
|
8 |
|
7725
|
9 |
class PlayersListModel : public QAbstractListModel
|
7723
|
10 |
{
|
|
11 |
Q_OBJECT
|
7725
|
12 |
|
7723
|
13 |
public:
|
7725
|
14 |
enum StateFlag {
|
|
15 |
Ready = Qt::UserRole,
|
|
16 |
ServerAdmin = Qt::UserRole + 1,
|
|
17 |
RoomAdmin = Qt::UserRole + 2,
|
|
18 |
Registered = Qt::UserRole + 3,
|
|
19 |
Friend = Qt::UserRole + 4,
|
|
20 |
Ignore = Qt::UserRole + 5
|
|
21 |
};
|
|
22 |
|
7728
|
23 |
enum SpecialRoles {
|
|
24 |
SortRole = Qt::UserRole + 100
|
|
25 |
};
|
|
26 |
|
7723
|
27 |
explicit PlayersListModel(QObject *parent = 0);
|
|
28 |
|
7725
|
29 |
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
30 |
|
|
31 |
QVariant data(const QModelIndex &index, int role) const;
|
|
32 |
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
|
|
33 |
|
|
34 |
bool insertRow(int row, const QModelIndex &parent = QModelIndex());
|
|
35 |
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
|
|
36 |
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
|
|
37 |
|
7723
|
38 |
public slots:
|
|
39 |
void addPlayer(const QString & nickname);
|
7725
|
40 |
void removePlayer(const QString & nickname);
|
|
41 |
void setFlag(const QString & nickname, StateFlag flagType, bool isSet);
|
|
42 |
|
|
43 |
private:
|
|
44 |
QHash<quint32, QIcon> & m_icons();
|
|
45 |
typedef QHash<int, QVariant> DataEntry;
|
|
46 |
QList<DataEntry> m_data;
|
|
47 |
void updateIcon(const QModelIndex & index);
|
7728
|
48 |
void updateSortData(const QModelIndex & index);
|
7723
|
49 |
};
|
|
50 |
|
|
51 |
#endif // PLAYERSLISTMODEL_H
|