21 * @brief DataManager class implementation |
21 * @brief DataManager class implementation |
22 */ |
22 */ |
23 |
23 |
24 #include <QMap> |
24 #include <QMap> |
25 #include <QStringList> |
25 #include <QStringList> |
26 |
26 #include <QStandardItemModel> |
27 #include <QFileInfo> |
27 #include <QFileInfo> |
28 |
28 |
29 #include "hwconsts.h" |
29 #include "hwconsts.h" |
|
30 #include "HWApplication.h" |
|
31 #include "sdlkeys.h" |
30 |
32 |
31 #include "DataManager.h" |
33 #include "DataManager.h" |
32 |
34 |
|
35 #include "GameStyleModel.h" |
|
36 #include "HatModel.h" |
|
37 #include "MapModel.h" |
|
38 #include "ThemeModel.h" |
33 |
39 |
34 DataManager::DataManager() |
40 DataManager::DataManager() |
35 { |
41 { |
36 m_userData = new QDir(cfgdir->absolutePath()); |
42 m_userData = new QDir(cfgdir->absolutePath()); |
37 if (!m_userData->cd("Data")) |
43 if (!m_userData->cd("Data")) |
152 m_themeModel->loadThemes(); |
160 m_themeModel->loadThemes(); |
153 } |
161 } |
154 return m_themeModel; |
162 return m_themeModel; |
155 } |
163 } |
156 |
164 |
|
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 |
|
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 |
157 void DataManager::reload() |
202 void DataManager::reload() |
158 { |
203 { |
159 m_gameStyleModel->loadGameStyles(); |
204 m_gameStyleModel->loadGameStyles(); |
160 m_hatModel->loadHats(); |
205 m_hatModel->loadHats(); |
161 m_mapModel->loadMaps(); |
206 m_mapModel->loadMaps(); |