author | Wuzzy <Wuzzy2@mail.ru> |
Sun, 13 Jan 2019 17:49:29 +0100 | |
changeset 14588 | 5de4d470dafe |
parent 13267 | 48b23e6f26d9 |
child 14849 | 8ed0c3761640 |
permissions | -rw-r--r-- |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
1 |
/* |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
4 |
* |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
8 |
* |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
12 |
* GNU General Public License for more details. |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
13 |
* |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
17 |
*/ |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
18 |
|
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
19 |
/** |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
20 |
* @file |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
21 |
* @brief ThemeModel class definition |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
22 |
*/ |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
23 |
|
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
24 |
#ifndef HEDGEWARS_THEMEMODEL_H |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
25 |
#define HEDGEWARS_THEMEMODEL_H |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
26 |
|
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
27 |
#include <QAbstractListModel> |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
28 |
#include <QStringList> |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
29 |
#include <QMap> |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
30 |
#include <QIcon> |
13267
48b23e6f26d9
Add icons to background themes; allow to hide themes explicitly by adding “hidden” key to theme.cfg
Wuzzy <Wuzzy2@mail.ru>
parents:
13248
diff
changeset
|
31 |
#include <QTextStream> |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
32 |
|
13247
4df9d8cedf7f
ThemeModel: Filter themes based on IsDlcRole rather than string-based
Wuzzy <Wuzzy2@mail.ru>
parents:
11757
diff
changeset
|
33 |
#include "ThemeFilterProxyModel.h" |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
34 |
#include "DataManager.h" |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
35 |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
36 |
/** |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
37 |
* @brief A model listing available themes |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
38 |
*/ |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
39 |
class ThemeModel : public QAbstractListModel |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
40 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6061
diff
changeset
|
41 |
Q_OBJECT |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
42 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6061
diff
changeset
|
43 |
public: |
13248
b0022324fb4e
Add IsHiddenRole to ThemeModel for hidden themes
Wuzzy <Wuzzy2@mail.ru>
parents:
13247
diff
changeset
|
44 |
enum Roles { ActualNameRole = Qt::UserRole, IsDlcRole, IconPathRole, IsHiddenRole }; |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
45 |
explicit ThemeModel(QObject *parent = 0); |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
46 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6061
diff
changeset
|
47 |
int rowCount(const QModelIndex &parent = QModelIndex()) const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6061
diff
changeset
|
48 |
QVariant data(const QModelIndex &index, int role) const; |
13247
4df9d8cedf7f
ThemeModel: Filter themes based on IsDlcRole rather than string-based
Wuzzy <Wuzzy2@mail.ru>
parents:
11757
diff
changeset
|
49 |
ThemeFilterProxyModel * withoutDLC(); |
13248
b0022324fb4e
Add IsHiddenRole to ThemeModel for hidden themes
Wuzzy <Wuzzy2@mail.ru>
parents:
13247
diff
changeset
|
50 |
ThemeFilterProxyModel * withoutHidden(); |
b0022324fb4e
Add IsHiddenRole to ThemeModel for hidden themes
Wuzzy <Wuzzy2@mail.ru>
parents:
13247
diff
changeset
|
51 |
ThemeFilterProxyModel * withoutDLCOrHidden(); |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
52 |
|
9745 | 53 |
private: |
54 |
mutable QList<QMap<int, QVariant> > m_data; |
|
55 |
mutable bool m_themesLoaded; |
|
13247
4df9d8cedf7f
ThemeModel: Filter themes based on IsDlcRole rather than string-based
Wuzzy <Wuzzy2@mail.ru>
parents:
11757
diff
changeset
|
56 |
mutable ThemeFilterProxyModel * m_filteredNoDLC; |
13248
b0022324fb4e
Add IsHiddenRole to ThemeModel for hidden themes
Wuzzy <Wuzzy2@mail.ru>
parents:
13247
diff
changeset
|
57 |
mutable ThemeFilterProxyModel * m_filteredNoHidden; |
b0022324fb4e
Add IsHiddenRole to ThemeModel for hidden themes
Wuzzy <Wuzzy2@mail.ru>
parents:
13247
diff
changeset
|
58 |
mutable ThemeFilterProxyModel * m_filteredNoDLCOrHidden; |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
59 |
|
9745 | 60 |
void loadThemes() const; |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
61 |
}; |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
diff
changeset
|
62 |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6616
diff
changeset
|
63 |
#endif // HEDGEWARS_THEMEMODEL_H |