QTfrontend/model/playerslistmodel.h
changeset 7725 4ad05a478c6c
parent 7723 ca05b576ec74
child 7728 664738870325
--- a/QTfrontend/model/playerslistmodel.h	Sat Oct 06 23:36:43 2012 +0400
+++ b/QTfrontend/model/playerslistmodel.h	Sun Oct 07 00:12:46 2012 +0400
@@ -1,19 +1,46 @@
 #ifndef PLAYERSLISTMODEL_H
 #define PLAYERSLISTMODEL_H
 
-#include <QStringListModel>
+#include <QAbstractListModel>
+#include <QHash>
+#include <QIcon>
+#include <QModelIndex>
 
-class PlayersListModel : public QStringListModel
+class PlayersListModel : public QAbstractListModel
 {
     Q_OBJECT
+
 public:
+    enum StateFlag {
+        Ready       = Qt::UserRole,
+        ServerAdmin = Qt::UserRole + 1,
+        RoomAdmin   = Qt::UserRole + 2,
+        Registered  = Qt::UserRole + 3,
+        Friend      = Qt::UserRole + 4,
+        Ignore      = Qt::UserRole + 5
+    };
+
     explicit PlayersListModel(QObject *parent = 0);
 
-signals:
-    
+    int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+    QVariant data(const QModelIndex &index, int role) const;
+    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
+
+    bool insertRow(int row, const QModelIndex &parent = QModelIndex());
+    bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+    bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+
 public slots:
     void addPlayer(const QString & nickname);
-    
+    void removePlayer(const QString & nickname);
+    void setFlag(const QString & nickname, StateFlag flagType, bool isSet);
+
+private:
+    QHash<quint32, QIcon> & m_icons();
+    typedef QHash<int, QVariant> DataEntry;
+    QList<DataEntry> m_data;
+    void updateIcon(const QModelIndex & index);
 };
 
 #endif // PLAYERSLISTMODEL_H