]> git.sesse.net Git - pkanalytics/blob - players.h
f7886f35f007571487b82b550519a2a0847e3699
[pkanalytics] / players.h
1 #ifndef _PLAYERS_H
2 #define _PLAYERS_H 1
3
4 #include <sqlite3.h>
5 #include <QAbstractTableModel>
6 #include <string>
7 #include <vector>
8
9 class PlayersModel : public QAbstractTableModel
10 {
11 public:
12         PlayersModel(sqlite3 *db);
13
14         int rowCount(const QModelIndex &parent) const override
15         {
16                 return players.size();
17         }
18         int columnCount(const QModelIndex &column) const override
19         {
20                 return 2;
21         }
22         QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
23         QVariant data(const QModelIndex &index, int role) const override;
24
25 //      Player get_player(int player_id) const;
26
27 private:
28         struct Player {
29                 int player_id;
30                 std::string number;
31                 std::string name;
32         };
33         std::vector<Player> players;
34
35         sqlite3 *db;
36
37         void load_data();
38 };
39
40 #endif  // !defined(_PLAYERS_H)