author | Dmitry Marakasov <amdmi3@amdmi3.ru> |
Wed, 25 Dec 2013 23:25:25 +0400 | |
changeset 9801 | 8fb7737fbd31 |
parent 9744 | 1ee4842a9c86 |
child 9998 | 736015b847e3 |
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 |
9080 | 3 |
* Copyright (c) 2004-2013 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 |
|
8385
9e8924ff9813
Convert feedback page to dialog (+some fixes from unC0Rr)
dag10
parents:
8377
diff
changeset
|
24 |
#include <QSettings> |
9e8924ff9813
Convert feedback page to dialog (+some fixes from unC0Rr)
dag10
parents:
8377
diff
changeset
|
25 |
|
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
26 |
#include "physfs.h" |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
27 |
#include "MapModel.h" |
8385
9e8924ff9813
Convert feedback page to dialog (+some fixes from unC0Rr)
dag10
parents:
8377
diff
changeset
|
28 |
#include "HWApplication.h" |
8464 | 29 |
#include "hwconsts.h" |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
30 |
|
9736
d2b01d350035
add missing initializers for 'dlc' variables for the 3 default generated map types (fixes 3 clang warnings)
sheepluva
parents:
9080
diff
changeset
|
31 |
MapModel::MapInfo MapModel::MapInfoRandom = {MapModel::GeneratedMap, "+rnd+", "", 0, "", "", "", false}; |
d2b01d350035
add missing initializers for 'dlc' variables for the 3 default generated map types (fixes 3 clang warnings)
sheepluva
parents:
9080
diff
changeset
|
32 |
MapModel::MapInfo MapModel::MapInfoMaze = {MapModel::GeneratedMaze, "+maze+", "", 0, "", "", "", false}; |
d2b01d350035
add missing initializers for 'dlc' variables for the 3 default generated map types (fixes 3 clang warnings)
sheepluva
parents:
9080
diff
changeset
|
33 |
MapModel::MapInfo MapModel::MapInfoDrawn = {MapModel::HandDrawnMap, "+drawn+", "", 0, "", "", "", false}; |
8377 | 34 |
|
9744 | 35 |
|
36 |
MapModel::MapModel(MapType maptype, QObject *parent) : QStandardItemModel(parent) |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
37 |
{ |
9744 | 38 |
m_maptype = maptype; |
39 |
m_loaded = false; |
|
40 |
} |
|
41 |
||
42 |
bool MapModel::loadMaps() |
|
43 |
{ |
|
44 |
if(m_loaded) |
|
45 |
return false; |
|
46 |
||
47 |
m_loaded = true; |
|
48 |
||
49 |
qDebug("[LAZINESS] MapModel::loadMaps()"); |
|
50 |
||
6943 | 51 |
// 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
|
52 |
beginResetModel(); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
53 |
|
6943 | 54 |
// 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
|
55 |
DataManager & datamgr = DataManager::instance(); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
56 |
|
6943 | 57 |
// fetch list of available maps |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
58 |
QStringList maps = |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
59 |
datamgr.entryList("Maps", QDir::AllDirs | QDir::NoDotAndDotDot); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
60 |
|
6943 | 61 |
// 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
|
62 |
QStandardItemModel::clear(); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
63 |
|
8377 | 64 |
//QList<QStandardItem *> staticMaps; |
65 |
//QList<QStandardItem *> missionMaps; |
|
66 |
QList<QStandardItem *> mapList; |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
67 |
|
6943 | 68 |
// add mission/static maps to lists |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
69 |
foreach (QString map, maps) |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
70 |
{ |
8386 | 71 |
// only 2 map relate files are relevant: |
72 |
// - the cfg file that contains the settings/info of the map |
|
73 |
// - the lua file - if it exists it's a mission, otherwise it isn't |
|
74 |
QFile mapLuaFile(QString("physfs://Maps/%1/map.lua").arg(map)); |
|
75 |
QFile mapCfgFile(QString("physfs://Maps/%1/map.cfg").arg(map)); |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
76 |
|
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
77 |
if (mapCfgFile.open(QFile::ReadOnly)) |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
78 |
{ |
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
|
79 |
QString caption; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
80 |
QString theme; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
81 |
quint32 limit = 0; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
82 |
QString scheme; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
83 |
QString weapons; |
8377 | 84 |
QString desc; |
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
85 |
bool dlc; |
8377 | 86 |
|
6943 | 87 |
// 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
|
88 |
bool isMission = mapLuaFile.exists(); |
8377 | 89 |
MapType type = isMission ? MissionMap : StaticMap; |
90 |
||
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
91 |
// if we're supposed to ignore this type, continue |
9744 | 92 |
if (type != m_maptype) continue; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
93 |
|
6943 | 94 |
// load map info from file |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
95 |
QTextStream input(&mapCfgFile); |
8377 | 96 |
theme = input.readLine(); |
97 |
limit = input.readLine().toInt(); |
|
6943 | 98 |
if (isMission) { // scheme and weapons are only relevant for missions |
8377 | 99 |
scheme = input.readLine(); |
100 |
weapons = input.readLine(); |
|
6943 | 101 |
} |
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
|
102 |
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
|
103 |
|
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
104 |
// load description (if applicable) |
8377 | 105 |
if (isMission) |
106 |
{ |
|
107 |
QString locale = HWApplication::keyboardInputLocale().name(); |
|
8386 | 108 |
|
109 |
QSettings descSettings(QString("physfs://Maps/%1/desc.txt").arg(map), QSettings::IniFormat); |
|
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8386
diff
changeset
|
110 |
desc = descSettings.value(locale, QString()).toString().replace("|", "\n").replace("\\,", ","); |
8377 | 111 |
} |
112 |
||
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
113 |
// detect if map is dlc |
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
114 |
QString mapDir = PHYSFS_getRealDir(QString("Maps/%1/map.cfg").arg(map).toLocal8Bit().data()); |
8464 | 115 |
dlc = !mapDir.startsWith(datadir->absolutePath()); |
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
116 |
|
6943 | 117 |
// 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
|
118 |
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
|
119 |
limit = 18; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
120 |
|
6943 | 121 |
// the default scheme/weaponset for missions. |
122 |
// if empty we assume the map sets these internally -> locked |
|
123 |
if (isMission) |
|
124 |
{ |
|
125 |
if (scheme.isEmpty()) |
|
126 |
scheme = "locked"; |
|
127 |
else |
|
128 |
scheme.replace("_", " "); |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
129 |
|
6943 | 130 |
if (weapons.isEmpty()) |
131 |
weapons = "locked"; |
|
132 |
else |
|
133 |
weapons.replace("_", " "); |
|
134 |
} |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
135 |
|
8377 | 136 |
// caption |
137 |
caption = map; |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
138 |
|
6943 | 139 |
// we know everything there is about the map, let's get am item for it |
8377 | 140 |
QStandardItem * item = MapModel::infoToItem( |
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
141 |
QIcon(), caption, type, map, theme, limit, scheme, weapons, desc, dlc); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
142 |
|
6943 | 143 |
// append item to the list |
8377 | 144 |
mapList.append(item); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
145 |
} |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
146 |
|
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 |
// Create column-index lookup table |
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
150 |
|
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
151 |
m_mapIndexes.clear(); |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
152 |
|
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
153 |
|
8377 | 154 |
int count = mapList.size(); |
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
155 |
for (int i = 0; i < count; i++) |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
156 |
{ |
8377 | 157 |
QStandardItem * si = mapList.at(i); |
6983
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
158 |
QVariant v = si->data(Qt::UserRole + 1); |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
159 |
if (v.canConvert<MapInfo>()) |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
160 |
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
|
161 |
} |
ede55af89e78
roomslistmodel: prettier names for map +rnd+ etc.; point out unavailable maps
sheepluva
parents:
6952
diff
changeset
|
162 |
|
8377 | 163 |
QStandardItemModel::appendColumn(mapList); |
6943 | 164 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
165 |
endResetModel(); |
9744 | 166 |
|
167 |
return true; |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
168 |
} |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
169 |
|
9744 | 170 |
bool MapModel::mapExists(const QString & map) |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
171 |
{ |
8377 | 172 |
return findMap(map) >= 0; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
diff
changeset
|
173 |
} |
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
|
174 |
|
9744 | 175 |
int MapModel::findMap(const QString & map) |
8377 | 176 |
{ |
9744 | 177 |
loadMaps(); |
178 |
||
8377 | 179 |
return m_mapIndexes.value(map, -1); |
180 |
} |
|
181 |
||
182 |
QStandardItem * MapModel::getMap(const QString & map) |
|
183 |
{ |
|
184 |
int loc = findMap(map); |
|
185 |
if (loc < 0) return NULL; |
|
186 |
return item(loc); |
|
187 |
} |
|
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 |
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
|
190 |
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
|
191 |
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
|
192 |
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
|
193 |
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
|
194 |
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
|
195 |
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
|
196 |
QString scheme, |
8377 | 197 |
QString weapons, |
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
198 |
QString desc, |
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
199 |
bool dlc) |
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
|
200 |
{ |
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
201 |
QStandardItem * item = new QStandardItem(icon, (dlc ? "*" : "") + caption); |
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
|
202 |
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
|
203 |
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
|
204 |
|
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
|
205 |
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
|
206 |
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
|
207 |
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
|
208 |
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
|
209 |
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
|
210 |
mapInfo.weapons = weapons; |
8377 | 211 |
mapInfo.desc = desc.isEmpty() ? tr("No description available.") : desc; |
8419
d99f46b676b5
Prepends an asterisk on maps, styles, and themes that are DLC. (Resolves issue 515)
dag10
parents:
8393
diff
changeset
|
212 |
mapInfo.dlc = dlc; |
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
|
213 |
|
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
|
214 |
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
|
215 |
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
|
216 |
|
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
|
217 |
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
|
218 |
} |