author | Xeli |
Wed, 23 May 2012 19:54:53 +0200 | |
changeset 7115 | aef10d849f9b |
parent 6993 | 47830cf50574 |
child 8377 | 869f80966a77 |
permissions | -rw-r--r-- |
6966 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
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 |
||
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6973
diff
changeset
|
30 |
#include "DataManager.h" |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6973
diff
changeset
|
31 |
|
6732 | 32 |
class RoomsListModel : public QAbstractTableModel |
33 |
{ |
|
34 |
Q_OBJECT |
|
35 |
public: |
|
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
|
36 |
// if you add a column here, also incr. c_nColumns in constructor |
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
|
37 |
// also adjust header in constructor to changes |
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
|
38 |
enum Column { |
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
|
39 |
StateColumn, |
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
|
40 |
NameColumn, |
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
|
41 |
PlayerCountColumn, |
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
|
42 |
TeamCountColumn, |
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
|
43 |
OwnerColumn, |
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
|
44 |
MapColumn, |
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
|
45 |
SchemeColumn, |
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
|
46 |
WeaponsColumn |
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 |
}; |
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
|
48 |
|
6732 | 49 |
explicit RoomsListModel(QObject *parent = 0); |
50 |
||
51 |
QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
|
52 |
int rowCount(const QModelIndex & parent) const; |
|
53 |
int columnCount(const QModelIndex & parent) const; |
|
54 |
QVariant data(const QModelIndex &index, int role) const; |
|
55 |
||
6733 | 56 |
public slots: |
57 |
void setRoomsList(const QStringList & rooms); |
|
58 |
void addRoom(const QStringList & info); |
|
59 |
void removeRoom(const QString & name); |
|
60 |
void updateRoom(const QString & name, const QStringList & info); |
|
6973 | 61 |
int rowOfRoom(const QString & name); |
6733 | 62 |
|
6732 | 63 |
private: |
6973 | 64 |
const int c_nColumns; |
6732 | 65 |
QList<QStringList> m_data; |
66 |
QStringList m_headerData; |
|
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6973
diff
changeset
|
67 |
MapModel * m_mapModel; |
6733 | 68 |
|
69 |
QStringList roomInfo2RoomRecord(const QStringList & info); |
|
6732 | 70 |
}; |
71 |
||
6966 | 72 |
#endif // HEDGEWARS_ROOMSLISTMODEL_H |