QTfrontend/model/MapModel.cpp
branchqmlfrontend
changeset 12855 1b2b84315d27
parent 12686 d5e09024d722
child 13274 e381f5260b45
--- a/QTfrontend/model/MapModel.cpp	Thu Aug 11 23:05:14 2016 +0300
+++ b/QTfrontend/model/MapModel.cpp	Sun Dec 17 00:09:24 2017 +0100
@@ -80,6 +80,14 @@
     //QList<QStandardItem *> missionMaps;
     QList<QStandardItem *> mapList;
 
+
+    QIcon dlcIcon;
+    dlcIcon.addFile(":/res/dlcMarker.png", QSize(), QIcon::Normal, QIcon::On);
+    dlcIcon.addFile(":/res/dlcMarkerSelected.png", QSize(), QIcon::Selected, QIcon::On);
+    QPixmap emptySpace = QPixmap(7, 15);
+    emptySpace.fill(QColor(0, 0, 0, 0));
+    QIcon notDlcIcon = QIcon(emptySpace);
+
     // add mission/static maps to lists
     foreach (QString map, maps)
     {
@@ -119,10 +127,22 @@
             // load description (if applicable)
             if (isMission)
             {
-                QString locale = HWApplication::keyboardInputLocale().name();
+                // get locale
+                QSettings settings(datamgr.settingsFileName(), QSettings::IniFormat);
+                QString locale = settings.value("misc/locale", "").toString();
+                if (locale.isEmpty())
+                    locale = QLocale::system().name();
 
                 QSettings descSettings(QString("physfs://Maps/%1/desc.txt").arg(map), QSettings::IniFormat);
-                desc = descSettings.value(locale, QString()).toString().replace("|", "\n").replace("\\,", ",");
+                descSettings.setIniCodec("UTF-8");
+                desc = descSettings.value(locale, QString()).toString();
+                // If not found, try with lanague-only code
+                if (desc.isEmpty())
+                {
+                    QString localeSimple = locale.remove(QRegExp("_.*$"));
+                    desc = descSettings.value(localeSimple, QString()).toString();
+                }
+                desc = desc.replace("_n", "\n").replace("_c", ",").replace("__", "_");
             }
 
             // detect if map is dlc
@@ -151,9 +171,15 @@
             // caption
             caption = map;
 
+            QIcon icon;
+            if (dlc)
+                icon = dlcIcon;
+            else
+                icon = notDlcIcon;
+
             // we know everything there is about the map, let's get am item for it
             QStandardItem * item = MapModel::infoToItem(
-                QIcon(), caption, type, map, theme, limit, scheme, weapons, desc, dlc);
+                icon, caption, type, map, theme, limit, scheme, weapons, desc, dlc);
 
             // append item to the list
             mapList.append(item);
@@ -213,7 +239,7 @@
     QString desc,
     bool dlc)
 {
-    QStandardItem * item = new QStandardItem(icon, (dlc ? "*" : "") + caption);
+    QStandardItem * item = new QStandardItem(icon, caption);
     MapInfo mapInfo;
     QVariant qvar(QVariant::UserType);