author | dag10 |
Mon, 14 Jan 2013 11:19:59 +0100 | |
changeset 8377 | 869f80966a77 |
parent 8049 | 133e22b5c410 |
child 8385 | 9e8924ff9813 |
permissions | -rw-r--r-- |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
1 |
/* |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
6952 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
4 |
* |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
8 |
* |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
12 |
* GNU General Public License for more details. |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
13 |
* |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
17 |
*/ |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
18 |
|
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
19 |
/** |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
20 |
* @file |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
21 |
* @brief MapModel class implementation |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
22 |
*/ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
23 |
|
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
24 |
#include "MapModel.h" |
8377 | 25 |
#include "hwapplication.h" |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
26 |
|
8377 | 27 |
#include <QSettings> |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
28 |
|
8377 | 29 |
MapModel::MapInfo MapModel::MapInfoRandom = {MapModel::GeneratedMap, "+rnd+", "", 0, "", "", ""}; |
30 |
MapModel::MapInfo MapModel::MapInfoMaze = {MapModel::GeneratedMaze, "+maze+", "", 0, "", "", ""}; |
|
31 |
MapModel::MapInfo MapModel::MapInfoDrawn = {MapModel::HandDrawnMap, "+drawn+", "", 0, "", "", ""}; |
|
32 |
||
33 |
void MapModel::loadMaps(MapType maptype) |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
34 |
{ |
6943 | 35 |
// this method resets the contents of this model (important to know for views). |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
36 |
beginResetModel(); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
37 |
|
6943 | 38 |
// we'll need the DataManager a few times, so let's get a reference to it |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
39 |
DataManager & datamgr = DataManager::instance(); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
40 |
|
6943 | 41 |
// fetch list of available maps |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
42 |
QStringList maps = |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
43 |
datamgr.entryList("Maps", QDir::AllDirs | QDir::NoDotAndDotDot); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
44 |
|
6943 | 45 |
// empty list, so that we can (re)fill it |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
46 |
QStandardItemModel::clear(); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
47 |
|
8377 | 48 |
//QList<QStandardItem *> staticMaps; |
49 |
//QList<QStandardItem *> missionMaps; |
|
50 |
QList<QStandardItem *> mapList; |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
51 |
|
6943 | 52 |
// only 2 map relate files are relevant: |
53 |
// - the cfg file that contains the settings/info of the map |
|
54 |
// - the lua file - if it exists it's a mission, otherwise it isn't |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
55 |
QFile mapLuaFile; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
56 |
QFile mapCfgFile; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
57 |
|
6943 | 58 |
// add mission/static maps to lists |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
59 |
foreach (QString map, maps) |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
60 |
{ |
8049 | 61 |
mapCfgFile.setFileName(QString("physfs://Maps/%1/map.cfg").arg(map)); |
62 |
mapLuaFile.setFileName(QString("physfs://Maps/%1/map.lua").arg(map)); |
|
8377 | 63 |
QSettings descSettings(QString("physfs://Maps/%1/desc.txt").arg(map), QSettings::IniFormat); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
64 |
|
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
65 |
if (mapCfgFile.open(QFile::ReadOnly)) |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
66 |
{ |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
67 |
QString caption; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
68 |
QString theme; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
69 |
quint32 limit = 0; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
70 |
QString scheme; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
71 |
QString weapons; |
8377 | 72 |
QString desc; |
73 |
||
6943 | 74 |
// if there is a lua file for this map, then it's a mission |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
75 |
bool isMission = mapLuaFile.exists(); |
8377 | 76 |
MapType type = isMission ? MissionMap : StaticMap; |
77 |
||
78 |
// If we're supposed to ignore this type, continue |
|
79 |
if (type != maptype) continue; |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
80 |
|
6943 | 81 |
// load map info from file |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
82 |
QTextStream input(&mapCfgFile); |
8377 | 83 |
theme = input.readLine(); |
84 |
limit = input.readLine().toInt(); |
|
6943 | 85 |
if (isMission) { // scheme and weapons are only relevant for missions |
8377 | 86 |
scheme = input.readLine(); |
87 |
weapons = input.readLine(); |
|
6943 | 88 |
} |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
89 |
mapCfgFile.close(); |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
90 |
|
8377 | 91 |
// Load description (if applicable) |
92 |
if (isMission) |
|
93 |
{ |
|
94 |
QString locale = HWApplication::keyboardInputLocale().name(); |
|
95 |
desc = descSettings.value(locale, QString()).toString().replace("|", "\n"); |
|
96 |
} |
|
97 |
||
6943 | 98 |
// let's use some semi-sane hedgehog limit, rather than none |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
99 |
if (limit == 0) |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
100 |
limit = 18; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
101 |
|
6943 | 102 |
// the default scheme/weaponset for missions. |
103 |
// if empty we assume the map sets these internally -> locked |
|
104 |
if (isMission) |
|
105 |
{ |
|
106 |
if (scheme.isEmpty()) |
|
107 |
scheme = "locked"; |
|
108 |
else |
|
109 |
scheme.replace("_", " "); |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
110 |
|
6943 | 111 |
if (weapons.isEmpty()) |
112 |
weapons = "locked"; |
|
113 |
else |
|
114 |
weapons.replace("_", " "); |
|
115 |
} |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
116 |
|
8377 | 117 |
// caption |
118 |
caption = map; |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
119 |
|
6943 | 120 |
// we know everything there is about the map, let's get am item for it |
8377 | 121 |
QStandardItem * item = MapModel::infoToItem( |
122 |
QIcon(), caption, type, map, theme, limit, scheme, weapons, desc); |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
123 |
|
6943 | 124 |
// append item to the list |
8377 | 125 |
mapList.append(item); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
126 |
} |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
127 |
|
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
128 |
} |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
129 |
|
8377 | 130 |
// Create column-index lookup table |
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
131 |
|
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
132 |
m_mapIndexes.clear(); |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
133 |
|
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
134 |
|
8377 | 135 |
int count = mapList.size(); |
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
136 |
for (int i = 0; i < count; i++) |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
137 |
{ |
8377 | 138 |
QStandardItem * si = mapList.at(i); |
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
139 |
QVariant v = si->data(Qt::UserRole + 1); |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
140 |
if (v.canConvert<MapInfo>()) |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
141 |
m_mapIndexes.insert(v.value<MapInfo>().name, i); |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
142 |
} |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
143 |
|
8377 | 144 |
QStandardItemModel::appendColumn(mapList); |
6943 | 145 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
146 |
endResetModel(); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
147 |
} |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
148 |
|
8377 | 149 |
bool MapModel::mapExists(const QString & map) const |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
150 |
{ |
8377 | 151 |
return findMap(map) >= 0; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
152 |
} |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
153 |
|
8377 | 154 |
int MapModel::findMap(const QString & map) const |
155 |
{ |
|
156 |
return m_mapIndexes.value(map, -1); |
|
157 |
} |
|
158 |
||
159 |
QStandardItem * MapModel::getMap(const QString & map) |
|
160 |
{ |
|
161 |
int loc = findMap(map); |
|
162 |
if (loc < 0) return NULL; |
|
163 |
return item(loc); |
|
164 |
} |
|
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
165 |
|
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
166 |
QStandardItem * MapModel::infoToItem( |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
167 |
const QIcon & icon, |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
168 |
const QString caption, |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
169 |
MapType type, |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
170 |
QString name, |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
171 |
QString theme, |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
172 |
quint32 limit, |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
173 |
QString scheme, |
8377 | 174 |
QString weapons, |
175 |
QString desc) |
|
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
176 |
{ |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
177 |
QStandardItem * item = new QStandardItem(icon, caption); |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
178 |
MapInfo mapInfo; |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
179 |
QVariant qvar(QVariant::UserType); |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
180 |
|
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
181 |
mapInfo.type = type; |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
182 |
mapInfo.name = name; |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
183 |
mapInfo.theme = theme; |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
184 |
mapInfo.limit = limit; |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
185 |
mapInfo.scheme = scheme; |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
186 |
mapInfo.weapons = weapons; |
8377 | 187 |
mapInfo.desc = desc.isEmpty() ? tr("No description available.") : desc; |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
188 |
|
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
189 |
qvar.setValue(mapInfo); |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
190 |
item->setData(qvar, Qt::UserRole + 1); |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
191 |
|
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
192 |
return item; |
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
193 |
} |