21 * @brief ThemeModel class implementation |
21 * @brief ThemeModel class implementation |
22 */ |
22 */ |
23 |
23 |
24 #include "physfs.h" |
24 #include "physfs.h" |
25 #include "ThemeModel.h" |
25 #include "ThemeModel.h" |
|
26 #include "hwconsts.h" |
26 |
27 |
27 ThemeModel::ThemeModel(QObject *parent) : |
28 ThemeModel::ThemeModel(QObject *parent) : |
28 QAbstractListModel(parent) |
29 QAbstractListModel(parent) |
29 { |
30 { |
30 m_data = QList<QMap<int, QVariant> >(); |
31 m_data = QList<QMap<int, QVariant> >(); |
75 |
74 |
76 QMap<int, QVariant> dataset; |
75 QMap<int, QVariant> dataset; |
77 |
76 |
78 // detect if theme is dlc |
77 // detect if theme is dlc |
79 QString themeDir = PHYSFS_getRealDir(QString("Themes/%1/icon.png").arg(theme).toLocal8Bit().data()); |
78 QString themeDir = PHYSFS_getRealDir(QString("Themes/%1/icon.png").arg(theme).toLocal8Bit().data()); |
80 dataset.insert(Qt::UserRole + 2, !themeDir.startsWith(appDir)); |
79 bool isDLC = !themeDir.startsWith(datadir->absolutePath()); |
|
80 dataset.insert(IsDlcRole, isDLC); |
81 |
81 |
82 // set icon path |
82 // set icon path |
83 dataset.insert(Qt::UserRole + 1, iconpath); |
83 dataset.insert(IconPathRole, iconpath); |
84 |
84 |
85 // set name |
85 // set name |
86 dataset.insert(Qt::DisplayRole, theme); |
86 dataset.insert(ActualNameRole, theme); |
87 |
87 |
88 // load and set icon |
88 // set displayed name |
89 QIcon icon; |
89 dataset.insert(Qt::DisplayRole, (isDLC ? "*" : "") + theme); |
90 icon.addPixmap(QPixmap(iconpath), QIcon::Normal); |
|
91 icon.addPixmap(QPixmap(iconpath), QIcon::Disabled); |
|
92 |
|
93 dataset.insert(Qt::DecorationRole, icon); |
|
94 |
90 |
95 // load and set preview icon |
91 // load and set preview icon |
96 QIcon preview(QString("physfs://Themes/%1/icon@2x.png").arg(theme)); |
92 QIcon preview(QString("physfs://Themes/%1/icon@2x.png").arg(theme)); |
97 dataset.insert(Qt::UserRole, preview); |
93 dataset.insert(Qt::DecorationRole, preview); |
98 |
94 |
99 m_data.append(dataset); |
95 m_data.append(dataset); |
100 } |
96 } |
101 |
97 |
102 |
98 |