QTfrontend/model/ThemeModel.cpp
branchwebgl
changeset 8833 c13ebed437cb
parent 8475 f605bc59c603
child 9080 9b42757d7e71
--- a/QTfrontend/model/ThemeModel.cpp	Wed Feb 20 02:21:58 2013 +0100
+++ b/QTfrontend/model/ThemeModel.cpp	Tue Apr 02 21:00:57 2013 +0200
@@ -23,6 +23,7 @@
 
 #include "physfs.h"
 #include "ThemeModel.h"
+#include "hwconsts.h"
 
 ThemeModel::ThemeModel(QObject *parent) :
     QAbstractListModel(parent)
@@ -50,8 +51,6 @@
 
 void ThemeModel::loadThemes()
 {
-    const QString appDir = QString(PHYSFS_getBaseDir());
-
     beginResetModel();
 
     DataManager & datamgr = DataManager::instance();
@@ -77,24 +76,21 @@
 
         // detect if theme is dlc
         QString themeDir = PHYSFS_getRealDir(QString("Themes/%1/icon.png").arg(theme).toLocal8Bit().data());
-        dataset.insert(Qt::UserRole + 2, !themeDir.startsWith(appDir));
+        bool isDLC = !themeDir.startsWith(datadir->absolutePath());
+        dataset.insert(IsDlcRole, isDLC);
 
         // set icon path
-        dataset.insert(Qt::UserRole + 1, iconpath);
+        dataset.insert(IconPathRole, iconpath);
 
         // set name
-        dataset.insert(Qt::DisplayRole, theme);
+        dataset.insert(ActualNameRole, theme);
 
-        // load and set icon
-        QIcon icon;
-        icon.addPixmap(QPixmap(iconpath), QIcon::Normal);
-        icon.addPixmap(QPixmap(iconpath), QIcon::Disabled);
-
-        dataset.insert(Qt::DecorationRole, icon);
+        // set displayed name
+        dataset.insert(Qt::DisplayRole, (isDLC ? "*" : "") + theme);
 
         // load and set preview icon
         QIcon preview(QString("physfs://Themes/%1/icon@2x.png").arg(theme));
-        dataset.insert(Qt::UserRole, preview);
+        dataset.insert(Qt::DecorationRole, preview);
 
         m_data.append(dataset);
     }