author | unc0rr |
Mon, 06 Aug 2012 23:30:58 +0400 | |
changeset 7511 | 1841d5cf899f |
parent 7260 | c3584a3ab730 |
child 7681 | 26978d581070 |
permissions | -rw-r--r-- |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
1 |
/* |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
6952 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
4 |
* |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
8 |
* |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
13 |
* |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
17 |
*/ |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
18 |
|
6168 | 19 |
/** |
6170 | 20 |
* @file |
6930 | 21 |
* @brief DataManager class implementation |
6168 | 22 |
*/ |
23 |
||
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
24 |
#include <QMap> |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
25 |
#include <QStringList> |
7258 | 26 |
#include <QStandardItemModel> |
6199
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
27 |
#include <QFileInfo> |
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
28 |
|
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
29 |
#include "hwconsts.h" |
7260 | 30 |
#include "HWApplication.h" |
31 |
#include "sdlkeys.h" |
|
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
32 |
|
6930 | 33 |
#include "DataManager.h" |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
34 |
|
7258 | 35 |
#include "GameStyleModel.h" |
36 |
#include "HatModel.h" |
|
37 |
#include "MapModel.h" |
|
38 |
#include "ThemeModel.h" |
|
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
39 |
|
6930 | 40 |
DataManager::DataManager() |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
41 |
{ |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
42 |
m_userData = new QDir(cfgdir->absolutePath()); |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
43 |
if (!m_userData->cd("Data")) |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
44 |
m_userData = NULL; |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
45 |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
46 |
m_defaultData = new QDir(datadir->absolutePath()); |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
47 |
|
6953
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
48 |
m_hatModel = NULL; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
49 |
m_mapModel = NULL; |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
50 |
m_themeModel = NULL; |
7258 | 51 |
m_colorsModel = NULL; |
7260 | 52 |
m_bindsModel = NULL; |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
53 |
} |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
54 |
|
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
55 |
|
6930 | 56 |
DataManager & DataManager::instance() |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
57 |
{ |
6930 | 58 |
static DataManager instance; |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
59 |
return instance; |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
60 |
} |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
61 |
|
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
62 |
|
6930 | 63 |
QStringList DataManager::entryList( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6199
diff
changeset
|
64 |
const QString & subDirectory, |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6199
diff
changeset
|
65 |
QDir::Filters filters, |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6199
diff
changeset
|
66 |
const QStringList & nameFilters |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6199
diff
changeset
|
67 |
) const |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
68 |
{ |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
69 |
QStringList result; |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
70 |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
71 |
if (m_userData != NULL) |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
72 |
{ |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
73 |
QDir tmpDir(*m_userData); |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
74 |
if (tmpDir.cd(subDirectory)) |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
75 |
result.append(tmpDir.entryList(nameFilters, filters)); |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
76 |
} |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
77 |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
78 |
QDir tmpDir(*m_defaultData); |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
79 |
if (tmpDir.cd(subDirectory)) |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
80 |
result.append(tmpDir.entryList(nameFilters, filters)); |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
81 |
|
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
82 |
result.removeDuplicates(); |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
83 |
|
6160
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
84 |
// sort case-insensitive |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
85 |
QMap<QString, QString> sortedFileNames; |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
86 |
foreach ( QString fn, result) |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
87 |
{ |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
88 |
sortedFileNames.insert(fn.toLower(), fn); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
89 |
} |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
90 |
result = sortedFileNames.values(); |
863d3edf5690
cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents:
6159
diff
changeset
|
91 |
|
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
92 |
return result; |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
93 |
} |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
94 |
|
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
95 |
|
6930 | 96 |
QString DataManager::findFileForRead( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6199
diff
changeset
|
97 |
const QString & relativeDataFilePath) const |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
98 |
{ |
6196 | 99 |
QString path; |
6167 | 100 |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
101 |
if (m_userData != NULL) |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
102 |
path = m_userData->absolutePath()+"/"+relativeDataFilePath; |
6196 | 103 |
|
104 |
if ((!path.isEmpty()) && (!QFile::exists(path))) |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
105 |
path = m_defaultData->absolutePath()+"/"+relativeDataFilePath; |
6167 | 106 |
|
107 |
return path; |
|
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
108 |
} |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
109 |
|
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
110 |
|
6930 | 111 |
QString DataManager::findFileForWrite( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6199
diff
changeset
|
112 |
const QString & relativeDataFilePath) const |
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
113 |
{ |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
114 |
if (m_userData != NULL) |
6199
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
115 |
{ |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
116 |
QString path = m_userData->absolutePath()+"/"+relativeDataFilePath; |
6199
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
117 |
|
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
118 |
// create folders if needed |
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
119 |
QDir tmp; |
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
120 |
tmp.mkpath(QFileInfo(path).absolutePath()); |
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
121 |
|
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
122 |
return path; |
582e85254110
on file save: create parent directories if needed
sheepluva
parents:
6196
diff
changeset
|
123 |
} |
6196 | 124 |
|
125 |
||
126 |
return ""; |
|
6159
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
127 |
} |
c780b8cf4d75
introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents:
diff
changeset
|
128 |
|
6958 | 129 |
GameStyleModel * DataManager::gameStyleModel() |
130 |
{ |
|
131 |
if (m_gameStyleModel == NULL) { |
|
132 |
m_gameStyleModel = new GameStyleModel(); |
|
133 |
m_gameStyleModel->loadGameStyles(); |
|
134 |
} |
|
135 |
return m_gameStyleModel; |
|
136 |
} |
|
137 |
||
6953
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
138 |
HatModel * DataManager::hatModel() |
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
139 |
{ |
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
140 |
if (m_hatModel == NULL) { |
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
141 |
m_hatModel = new HatModel(); |
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
142 |
m_hatModel->loadHats(); |
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
143 |
} |
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
144 |
return m_hatModel; |
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
145 |
} |
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
146 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
147 |
MapModel * DataManager::mapModel() |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
148 |
{ |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
149 |
if (m_mapModel == NULL) { |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
150 |
m_mapModel = new MapModel(); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
151 |
m_mapModel->loadMaps(); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
152 |
} |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
153 |
return m_mapModel; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
154 |
} |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
155 |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
156 |
ThemeModel * DataManager::themeModel() |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
157 |
{ |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
158 |
if (m_themeModel == NULL) { |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
159 |
m_themeModel = new ThemeModel(); |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
160 |
m_themeModel->loadThemes(); |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
161 |
} |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
162 |
return m_themeModel; |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
163 |
} |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
164 |
|
7258 | 165 |
QStandardItemModel * DataManager::colorsModel() |
166 |
{ |
|
167 |
if(m_colorsModel == NULL) |
|
168 |
{ |
|
169 |
m_colorsModel = new QStandardItemModel(); |
|
170 |
||
171 |
int i = 0; |
|
172 |
while(colors[i]) |
|
173 |
{ |
|
174 |
QStandardItem * item = new QStandardItem(); |
|
175 |
item->setData(QColor(colors[i])); |
|
176 |
m_colorsModel->appendRow(item); |
|
177 |
++i; |
|
178 |
} |
|
179 |
} |
|
180 |
||
181 |
return m_colorsModel; |
|
182 |
} |
|
183 |
||
7260 | 184 |
QStandardItemModel * DataManager::bindsModel() |
185 |
{ |
|
186 |
if(m_bindsModel == NULL) |
|
187 |
{ |
|
188 |
m_bindsModel = new QStandardItemModel(); |
|
189 |
||
190 |
for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) |
|
191 |
{ |
|
192 |
QStandardItem * item = new QStandardItem(); |
|
193 |
item->setData(HWApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? HWApplication::translate("binds (keys)", sdlkeys[j][1]) : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + HWApplication::translate("binds (keys)", sdlkeys[j][1]), Qt::DisplayRole); |
|
194 |
item->setData(sdlkeys[j][0], Qt::UserRole + 1); |
|
195 |
m_bindsModel->appendRow(item); |
|
196 |
} |
|
197 |
} |
|
198 |
||
199 |
return m_bindsModel; |
|
200 |
} |
|
201 |
||
6931
86c951cd0f3f
make DataManager a QObject with reload() slot that emits signal updated()
sheepluva
parents:
6930
diff
changeset
|
202 |
void DataManager::reload() |
86c951cd0f3f
make DataManager a QObject with reload() slot that emits signal updated()
sheepluva
parents:
6930
diff
changeset
|
203 |
{ |
6959 | 204 |
m_gameStyleModel->loadGameStyles(); |
6953
4c2dd25630a7
* make HatModel update automatically (also renamed class and files)
sheepluva
parents:
6952
diff
changeset
|
205 |
m_hatModel->loadHats(); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
206 |
m_mapModel->loadMaps(); |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6931
diff
changeset
|
207 |
m_themeModel->loadThemes(); |
6931
86c951cd0f3f
make DataManager a QObject with reload() slot that emits signal updated()
sheepluva
parents:
6930
diff
changeset
|
208 |
emit updated(); |
86c951cd0f3f
make DataManager a QObject with reload() slot that emits signal updated()
sheepluva
parents:
6930
diff
changeset
|
209 |
} |