QTfrontend/ui/widget/gamecfgwidget.cpp
changeset 6960 822f8269e13f
parent 6958 8230a516ba93
child 6983 ede55af89e78
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Sun Apr 29 17:23:05 2012 +0200
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Sun Apr 29 20:52:10 2012 +0200
@@ -112,6 +112,8 @@
     connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int)));
     connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap()));
     connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &)));
+
+    connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews()));
 }
 
 void GameCFGWidget::jumpToSchemes()
@@ -491,10 +493,13 @@
 
 void GameCFGWidget::scriptChanged(int index)
 {
+    const QString & name = Scripts->itemText(index);
+    m_curScript = name;
+
     if(isEnabled() && index > 0)
     {
-        QString scheme = Scripts->itemData(Scripts->currentIndex(), GameStyleModel::SchemeRole).toString();
-        QString weapons = Scripts->itemData(Scripts->currentIndex(), GameStyleModel::WeaponsRole).toString();
+        QString scheme = Scripts->itemData(index, GameStyleModel::SchemeRole).toString();
+        QString weapons = Scripts->itemData(index, GameStyleModel::WeaponsRole).toString();
 
         if (scheme == "locked")
         {
@@ -537,7 +542,7 @@
         WeaponsName->setEnabled(true);
         bindEntries->setEnabled(true);
     }
-    emit paramChanged("SCRIPT", QStringList(Scripts->itemText(index)));
+    emit paramChanged("SCRIPT", QStringList(name));
 }
 
 void GameCFGWidget::mapgenChanged(MapGenerator m)
@@ -559,3 +564,17 @@
 {
     emit paramChanged("DRAWNMAP", QStringList(qCompress(data, 9).toBase64()));
 }
+
+
+void GameCFGWidget::updateModelViews()
+{
+    // restore game-style selection
+    if (!m_curScript.isEmpty())
+    {
+        int idx = Scripts->findText(m_curScript);
+        if (idx >= 0)
+            Scripts->setCurrentIndex(idx);
+        else
+            Scripts->setCurrentIndex(0);
+    }
+}