author | nemo |
Fri, 05 Feb 2010 13:30:47 +0000 | |
changeset 2759 | 03988f64e146 |
parent 2726 | a84fc5113d01 |
child 2762 | 2fbc8d35eb52 |
permissions | -rw-r--r-- |
1881 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2009 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 |
||
1885 | 19 |
#include <QDebug> |
1881 | 20 |
#include <QModelIndex> |
1897 | 21 |
|
1881 | 22 |
#include "ammoSchemeModel.h" |
1897 | 23 |
#include "hwconsts.h" |
1881 | 24 |
|
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
25 |
QList<QVariant> defaultScheme = QList<QVariant>() |
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
26 |
<< QVariant("Default") // name 0 |
1899
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
27 |
<< QVariant(false) // fortsmode 1 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
28 |
<< QVariant(false) // team divide 2 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
29 |
<< QVariant(false) // solid land 3 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
30 |
<< QVariant(false) // border 4 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
31 |
<< QVariant(false) // low gravity 5 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
32 |
<< QVariant(false) // laser sight 6 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
33 |
<< QVariant(false) // invulnerable 7 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
34 |
<< QVariant(true) // add mines 8 |
2017 | 35 |
<< QVariant(false) // vampiric 9 |
36 |
<< QVariant(false) // karma 10 |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
37 |
<< QVariant(false) // artillery 11 |
2703 | 38 |
<< QVariant(true) // random order 12 |
2726 | 39 |
<< QVariant(false) // king 13 |
40 |
<< QVariant(100) // damage modfier 14 |
|
41 |
<< QVariant(45) // turn time 15 |
|
42 |
<< QVariant(100) // init health 16 |
|
43 |
<< QVariant(15) // sudden death 17 |
|
44 |
<< QVariant(5) // case prob 18 |
|
45 |
<< QVariant(3) // mines time 19 |
|
46 |
<< QVariant(4) // landadds 20 |
|
1899
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
47 |
; |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
48 |
|
1897 | 49 |
AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) : |
50 |
QAbstractTableModel(parent), |
|
1974 | 51 |
numberOfDefaultSchemes(4), |
1940 | 52 |
fileConfig(fileName, QSettings::IniFormat) |
1881 | 53 |
{ |
1899
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
54 |
QStringList predefSchemesNames; |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
55 |
predefSchemesNames |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
56 |
<< "Default" |
1968 | 57 |
<< "Pro mode" |
1974 | 58 |
<< "Shoppa" |
2093
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
59 |
<< "Basketball" |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
60 |
<< "Minefield"; |
2377 | 61 |
|
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
62 |
spNames = QStringList() |
1897 | 63 |
<< "name" // 0 |
64 |
<< "fortsmode" // 1 |
|
65 |
<< "divteams" // 2 |
|
66 |
<< "solidland" // 3 |
|
67 |
<< "border" // 4 |
|
68 |
<< "lowgrav" // 5 |
|
69 |
<< "laser" // 6 |
|
70 |
<< "invulnerability" // 7 |
|
71 |
<< "mines" // 8 |
|
2017 | 72 |
<< "vampiric" // 9 |
73 |
<< "karma" // 10 |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
74 |
<< "artillery" // 11 |
2703 | 75 |
<< "randomorder" // 12 |
2726 | 76 |
<< "king" // 13 |
77 |
<< "damagefactor" // 14 |
|
78 |
<< "turntime" // 15 |
|
79 |
<< "health" // 16 |
|
80 |
<< "suddendeath" // 17 |
|
81 |
<< "caseprobability" // 18 |
|
82 |
<< "minestime" // 19 |
|
83 |
<< "landadds" // 20 |
|
1897 | 84 |
; |
85 |
||
86 |
QList<QVariant> proMode; |
|
87 |
proMode |
|
1968 | 88 |
<< predefSchemesNames[1] // name 0 |
1897 | 89 |
<< QVariant(false) // fortsmode 1 |
90 |
<< QVariant(false) // team divide 2 |
|
91 |
<< QVariant(false) // solid land 3 |
|
92 |
<< QVariant(false) // border 4 |
|
93 |
<< QVariant(false) // low gravity 5 |
|
94 |
<< QVariant(false) // laser sight 6 |
|
95 |
<< QVariant(false) // invulnerable 7 |
|
96 |
<< QVariant(false) // add mines 8 |
|
2017 | 97 |
<< QVariant(false) // vampiric 9 |
98 |
<< QVariant(false) // karma 10 |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
99 |
<< QVariant(false) // artillery 11 |
2703 | 100 |
<< QVariant(true) // random order 12 |
2726 | 101 |
<< QVariant(false) // king 13 |
102 |
<< QVariant(100) // damage modfier 14 |
|
103 |
<< QVariant(15) // turn time 15 |
|
104 |
<< QVariant(100) // init health 16 |
|
105 |
<< QVariant(15) // sudden death 17 |
|
106 |
<< QVariant(0) // case prob 18 |
|
107 |
<< QVariant(3) // mines time 19 |
|
108 |
<< QVariant(4) // landadds 20 |
|
1897 | 109 |
; |
110 |
||
1968 | 111 |
QList<QVariant> shoppa; |
112 |
shoppa |
|
113 |
<< predefSchemesNames[2] // name 0 |
|
114 |
<< QVariant(false) // fortsmode 1 |
|
115 |
<< QVariant(false) // team divide 2 |
|
116 |
<< QVariant(true) // solid land 3 |
|
117 |
<< QVariant(true) // border 4 |
|
118 |
<< QVariant(false) // low gravity 5 |
|
119 |
<< QVariant(false) // laser sight 6 |
|
120 |
<< QVariant(false) // invulnerable 7 |
|
121 |
<< QVariant(false) // add mines 8 |
|
2017 | 122 |
<< QVariant(false) // vampiric 9 |
123 |
<< QVariant(false) // karma 10 |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
124 |
<< QVariant(false) // artillery 11 |
2703 | 125 |
<< QVariant(true) // random order 12 |
2726 | 126 |
<< QVariant(false) // king 13 |
127 |
<< QVariant(100) // damage modfier 14 |
|
128 |
<< QVariant(30) // turn time 15 |
|
129 |
<< QVariant(100) // init health 16 |
|
130 |
<< QVariant(50) // sudden death 17 |
|
131 |
<< QVariant(1) // case prob 18 |
|
132 |
<< QVariant(3) // mines time 19 |
|
133 |
<< QVariant(4) // landadds 20 |
|
1974 | 134 |
; |
135 |
||
136 |
QList<QVariant> basketball; |
|
137 |
basketball |
|
138 |
<< predefSchemesNames[3] // name 0 |
|
139 |
<< QVariant(false) // fortsmode 1 |
|
140 |
<< QVariant(false) // team divide 2 |
|
141 |
<< QVariant(true) // solid land 3 |
|
142 |
<< QVariant(true) // border 4 |
|
143 |
<< QVariant(true) // low gravity 5 |
|
144 |
<< QVariant(false) // laser sight 6 |
|
145 |
<< QVariant(true) // invulnerable 7 |
|
146 |
<< QVariant(false) // add mines 8 |
|
2017 | 147 |
<< QVariant(false) // vampiric 9 |
148 |
<< QVariant(false) // karma 10 |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
149 |
<< QVariant(false) // artillery 11 |
2703 | 150 |
<< QVariant(true) // random order 12 |
2726 | 151 |
<< QVariant(false) // king 13 |
152 |
<< QVariant(100) // damage modfier 14 |
|
153 |
<< QVariant(30) // turn time 15 |
|
154 |
<< QVariant(100) // init health 16 |
|
155 |
<< QVariant(15) // sudden death 17 |
|
156 |
<< QVariant(0) // case prob 18 |
|
157 |
<< QVariant(3) // mines time 19 |
|
158 |
<< QVariant(4) // landadds 20 |
|
1968 | 159 |
; |
160 |
||
2093
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
161 |
QList<QVariant> minefield; |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
162 |
minefield |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
163 |
<< predefSchemesNames[4] // name 0 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
164 |
<< QVariant(false) // fortsmode 1 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
165 |
<< QVariant(false) // team divide 2 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
166 |
<< QVariant(false) // solid land 3 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
167 |
<< QVariant(false) // border 4 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
168 |
<< QVariant(false) // low gravity 5 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
169 |
<< QVariant(false) // laser sight 6 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
170 |
<< QVariant(false) // invulnerable 7 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
171 |
<< QVariant(true) // add mines 8 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
172 |
<< QVariant(false) // vampiric 9 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
173 |
<< QVariant(false) // karma 10 |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
174 |
<< QVariant(false) // artillery 11 |
2703 | 175 |
<< QVariant(true) // random order 12 |
2726 | 176 |
<< QVariant(false) // king 13 |
177 |
<< QVariant(150) // damage modfier 14 |
|
178 |
<< QVariant(30) // turn time 15 |
|
179 |
<< QVariant(50) // init health 16 |
|
180 |
<< QVariant(15) // sudden death 17 |
|
181 |
<< QVariant(0) // case prob 18 |
|
182 |
<< QVariant(0) // mines time 19 |
|
183 |
<< QVariant(50) // landadds 20 |
|
2093
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
184 |
; |
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
185 |
|
1884 | 186 |
schemes.append(defaultScheme); |
1897 | 187 |
schemes.append(proMode); |
1968 | 188 |
schemes.append(shoppa); |
1974 | 189 |
schemes.append(basketball); |
2093
485e084cedc4
Portugese (european) translation, Tiy's "minefield" scheme/wepset, disable vampirism, update translations
nemo
parents:
2031
diff
changeset
|
190 |
schemes.append(minefield); |
1897 | 191 |
|
192 |
||
193 |
int size = fileConfig.beginReadArray("schemes"); |
|
194 |
for (int i = 0; i < size; ++i) { |
|
195 |
fileConfig.setArrayIndex(i); |
|
196 |
||
197 |
if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString())) |
|
198 |
{ |
|
199 |
QList<QVariant> scheme; |
|
200 |
||
201 |
for (int k = 0; k < spNames.size(); ++k) |
|
202 |
scheme << fileConfig.value(spNames[k], defaultScheme[k]); |
|
203 |
||
204 |
schemes.append(scheme); |
|
205 |
} |
|
206 |
} |
|
207 |
fileConfig.endArray(); |
|
1881 | 208 |
} |
209 |
||
210 |
QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const |
|
211 |
{ |
|
212 |
return QVariant(); |
|
213 |
} |
|
214 |
||
215 |
int AmmoSchemeModel::rowCount(const QModelIndex &parent) const |
|
216 |
{ |
|
217 |
if (parent.isValid()) |
|
218 |
return 0; |
|
219 |
else |
|
220 |
return schemes.size(); |
|
221 |
} |
|
222 |
||
223 |
int AmmoSchemeModel::columnCount(const QModelIndex & parent) const |
|
224 |
{ |
|
225 |
if (parent.isValid()) |
|
226 |
return 0; |
|
227 |
else |
|
1884 | 228 |
return defaultScheme.size(); |
1881 | 229 |
} |
230 |
||
231 |
Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const |
|
232 |
{ |
|
233 |
return |
|
234 |
Qt::ItemIsEnabled |
|
235 |
| Qt::ItemIsSelectable |
|
236 |
| Qt::ItemIsEditable; |
|
237 |
} |
|
238 |
||
239 |
bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role) |
|
240 |
{ |
|
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
241 |
if (!index.isValid() || index.row() < numberOfDefaultSchemes |
1884 | 242 |
|| index.row() >= schemes.size() |
243 |
|| index.column() >= defaultScheme.size() |
|
1885 | 244 |
|| role != Qt::EditRole) |
1884 | 245 |
return false; |
246 |
||
1890 | 247 |
schemes[index.row()][index.column()] = value; |
1885 | 248 |
|
1881 | 249 |
emit dataChanged(index, index); |
1884 | 250 |
return true; |
1881 | 251 |
} |
1884 | 252 |
|
253 |
bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent) |
|
254 |
{ |
|
255 |
beginInsertRows(parent, row, row); |
|
256 |
||
1890 | 257 |
QList<QVariant> newScheme = defaultScheme; |
258 |
newScheme[0] = QVariant(tr("new")); |
|
2377 | 259 |
|
1889 | 260 |
schemes.insert(row, newScheme); |
1884 | 261 |
|
262 |
endInsertRows(); |
|
2377 | 263 |
|
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
264 |
return true; |
1884 | 265 |
} |
266 |
||
267 |
bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent) |
|
268 |
{ |
|
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
269 |
if(count != 1 |
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
270 |
|| row < numberOfDefaultSchemes |
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
271 |
|| row >= schemes.size()) |
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
272 |
return false; |
2377 | 273 |
|
1884 | 274 |
beginRemoveRows(parent, row, row); |
275 |
||
276 |
schemes.removeAt(row); |
|
277 |
||
278 |
endRemoveRows(); |
|
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
279 |
|
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
280 |
return true; |
1884 | 281 |
} |
282 |
||
283 |
QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const |
|
284 |
{ |
|
285 |
if (!index.isValid() || index.row() < 0 |
|
286 |
|| index.row() >= schemes.size() |
|
287 |
|| index.column() >= defaultScheme.size() |
|
1889 | 288 |
|| (role != Qt::EditRole && role != Qt::DisplayRole) |
289 |
) |
|
1884 | 290 |
return QVariant(); |
291 |
||
1890 | 292 |
return schemes[index.row()][index.column()]; |
1884 | 293 |
} |
1897 | 294 |
|
295 |
void AmmoSchemeModel::Save() |
|
296 |
{ |
|
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
297 |
fileConfig.beginWriteArray("schemes", schemes.size()); |
2377 | 298 |
|
1897 | 299 |
for (int i = 0; i < schemes.size(); ++i) { |
300 |
fileConfig.setArrayIndex(i); |
|
301 |
||
302 |
QList<QVariant> scheme = schemes[i]; |
|
2377 | 303 |
|
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
304 |
for (int k = 0; k < scheme.size(); ++k) |
1897 | 305 |
fileConfig.setValue(spNames[k], scheme[k]); |
306 |
} |
|
307 |
fileConfig.endArray(); |
|
308 |
} |
|
1899
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
309 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
310 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
311 |
NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) : |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
312 |
QAbstractTableModel(parent) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
313 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
314 |
netScheme = defaultScheme; |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
315 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
316 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
317 |
QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
318 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
319 |
return QVariant(); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
320 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
321 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
322 |
int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
323 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
324 |
if (parent.isValid()) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
325 |
return 0; |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
326 |
else |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
327 |
return 1; |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
328 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
329 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
330 |
int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
331 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
332 |
if (parent.isValid()) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
333 |
return 0; |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
334 |
else |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
335 |
return defaultScheme.size(); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
336 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
337 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
338 |
QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
339 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
340 |
if (!index.isValid() || index.row() < 0 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
341 |
|| index.row() > 1 |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
342 |
|| index.column() >= defaultScheme.size() |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
343 |
|| (role != Qt::EditRole && role != Qt::DisplayRole) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
344 |
) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
345 |
return QVariant(); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
346 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
347 |
return netScheme[index.column()]; |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
348 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
349 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
350 |
void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
351 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
352 |
if(cfg.size() != netScheme.size()) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
353 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
354 |
qWarning("Incorrect scheme cfg size"); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
355 |
return; |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
356 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
357 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
358 |
for(int i = 0; i < cfg.size(); ++i) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
359 |
netScheme[i] = QVariant(cfg[i]); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
360 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
361 |
reset(); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1897
diff
changeset
|
362 |
} |