|
1 /* |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2004-2015 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
17 */ |
|
18 |
|
19 #ifndef _GAME_SCHEME_MODEL_INCLUDED |
|
20 #define _GAME_SCHEME_MODEL_INCLUDED |
|
21 |
|
22 #include <QAbstractTableModel> |
|
23 #include <QStringList> |
|
24 #include <QList> |
|
25 #include <QSettings> |
|
26 |
|
27 class GameSchemeModel : public QAbstractTableModel |
|
28 { |
|
29 Q_OBJECT |
|
30 |
|
31 public: |
|
32 GameSchemeModel(QObject * parent, const QString & fileName); |
|
33 |
|
34 QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
|
35 int rowCount(const QModelIndex & parent) const; |
|
36 int columnCount(const QModelIndex & parent) const; |
|
37 bool hasScheme(QString name); |
|
38 Qt::ItemFlags flags(const QModelIndex & index) const; |
|
39 bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); |
|
40 bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()); |
|
41 bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); |
|
42 QVariant data(const QModelIndex &index, int role) const; |
|
43 |
|
44 int numberOfDefaultSchemes; |
|
45 QStringList predefSchemesNames; |
|
46 QStringList spNames; |
|
47 |
|
48 public slots: |
|
49 void Save(); |
|
50 |
|
51 // signals: |
|
52 // void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); |
|
53 |
|
54 protected: |
|
55 QList< QList<QVariant> > schemes; |
|
56 |
|
57 private: |
|
58 QSettings fileConfig; |
|
59 }; |
|
60 |
|
61 class NetGameSchemeModel : public QAbstractTableModel |
|
62 { |
|
63 Q_OBJECT |
|
64 |
|
65 public: |
|
66 NetGameSchemeModel(QObject * parent); |
|
67 |
|
68 QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
|
69 int rowCount(const QModelIndex & parent) const; |
|
70 int columnCount(const QModelIndex & parent) const; |
|
71 QVariant data(const QModelIndex &index, int role) const; |
|
72 |
|
73 public slots: |
|
74 void setNetSchemeConfig(QStringList cfg); |
|
75 |
|
76 private: |
|
77 QList<QVariant> netScheme; |
|
78 }; |
|
79 |
|
80 #endif // _GAME_SCHEME_MODEL_INCLUDED |