author | alfadur <mail@none> |
Sat, 08 Apr 2023 16:45:55 +0300 | |
changeset 15949 | 668c88b31dd6 |
parent 15047 | 773beead236f |
permissions | -rw-r--r-- |
6966 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
6966 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6966 | 17 |
*/ |
18 |
||
19 |
/** |
|
20 |
* @file |
|
21 |
* @brief RoomsListModel class definition |
|
22 |
*/ |
|
23 |
||
24 |
#ifndef HEDGEWARS_ROOMSLISTMODEL_H |
|
25 |
#define HEDGEWARS_ROOMSLISTMODEL_H |
|
6732 | 26 |
|
27 |
#include <QAbstractTableModel> |
|
28 |
#include <QStringList> |
|
29 |
||
15047
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
30 |
class RoomsListModel : public QAbstractTableModel { |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
31 |
Q_OBJECT |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
32 |
public: |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
33 |
// if you add a column here, also incr. c_nColumns in constructor |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
34 |
// also adjust header in constructor to changes |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
35 |
enum Column { |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
36 |
StateColumn, |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
37 |
NameColumn, |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
38 |
PlayerCountColumn, |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
39 |
TeamCountColumn, |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
40 |
OwnerColumn, |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
41 |
MapColumn, |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
42 |
SchemeColumn, |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
43 |
WeaponsColumn |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
44 |
}; |
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6973
diff
changeset
|
45 |
|
15047
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
46 |
explicit RoomsListModel(QObject *parent = 0); |
6993
47830cf50574
room list: replace magic table column indexes with enum. makes future changes to the room list format way easier.
sheepluva
parents:
6983
diff
changeset
|
47 |
|
15047
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
48 |
QVariant headerData(int section, Qt::Orientation orientation, |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
49 |
int role) const override; |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
50 |
int rowCount(const QModelIndex &parent) const override; |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
51 |
int columnCount(const QModelIndex &parent) const override; |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
52 |
QVariant data(const QModelIndex &index, int role) const override; |
6732 | 53 |
|
15047
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
54 |
public slots: |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
55 |
void setRoomsList(const QStringList &rooms); |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
56 |
void addRoom(const QStringList &info); |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
57 |
void removeRoom(const QString &name); |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
58 |
void updateRoom(const QString &name, const QStringList &info); |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
59 |
int rowOfRoom(const QString &name); |
6733 | 60 |
|
15047
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
61 |
private: |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
62 |
const int c_nColumns; |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
63 |
QList<QStringList> m_data; |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
64 |
QStringList m_headerData; |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
65 |
// MapModel * m_staticMapModel; |
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
66 |
// MapModel * m_missionMapModel; |
6732 | 67 |
}; |
68 |
||
15047
773beead236f
Add handling of some messages, reuse models from the old frontend
unc0rr
parents:
11046
diff
changeset
|
69 |
#endif // HEDGEWARS_ROOMSLISTMODEL_H |