Themes list now works
authorunc0rr
Fri, 15 Aug 2008 07:22:55 +0000
changeset 1215 0c1c294c0f7e
parent 1214 090f94cd663e
child 1216 df1b19976e28
Themes list now works
QTfrontend/main.cpp
QTfrontend/mapContainer.cpp
QTfrontend/mapContainer.h
--- a/QTfrontend/main.cpp	Fri Aug 15 06:33:50 2008 +0000
+++ b/QTfrontend/main.cpp	Fri Aug 15 07:22:55 2008 +0000
@@ -50,6 +50,7 @@
 	QDateTime now = QDateTime::currentDateTime();
 	QDateTime zero;
 	srand(now.secsTo(zero));
+	rand();
 
 	Q_INIT_RESOURCE(hedgewars);
 
--- a/QTfrontend/mapContainer.cpp	Fri Aug 15 06:33:50 2008 +0000
+++ b/QTfrontend/mapContainer.cpp	Fri Aug 15 07:22:55 2008 +0000
@@ -49,7 +49,6 @@
   imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum);
   mainLayout.addWidget(imageButt, 0, 0, 1, 2);
   connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed()));
-  setRandomSeed();
 
   chooseMap = new QComboBox(this);
   chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -76,11 +75,14 @@
 		lwi->setTextAlignment(Qt::AlignHCenter);
 		lwThemes->addItem(lwi);
 	}
+	connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int)));
 	
 	gbTLayout->addWidget(lwThemes);
 	lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
 	
   mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
+
+  setRandomSeed();
 }
 
 void HWMapContainer::setImage(const QImage newImage)
@@ -141,10 +143,15 @@
 
 	if(!Themes->size()) return;
 	quint32 themeNum = rand() % Themes->size();
-	theme = Themes->at(themeNum);
 	lwThemes->setCurrentRow(themeNum);
 }
 
+void HWMapContainer::themeSelected(int currentRow)
+{
+	theme = Themes->at(currentRow);
+	emit themeChanged(theme);
+}
+
 QString HWMapContainer::getCurrentSeed() const
 {
   return m_seed;
@@ -183,7 +190,10 @@
 
 void HWMapContainer::setTheme(const QString & theme)
 {
-	this->theme = theme;
+	QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly);
+	if(items.size())
+		lwThemes->setCurrentItem(items.at(0));
+	//this->theme = theme;
 }
 
 void HWMapContainer::setRandomSeed()
@@ -191,5 +201,4 @@
   m_seed = QUuid::createUuid().toString();
   emit seedChanged(m_seed);
   changeImage();
-  emit themeChanged(theme);
 }
--- a/QTfrontend/mapContainer.h	Fri Aug 15 06:33:50 2008 +0000
+++ b/QTfrontend/mapContainer.h	Fri Aug 15 07:22:55 2008 +0000
@@ -59,6 +59,7 @@
   void setImage(const QImage newImage);
   void mapChanged(int index);
   void setRandomSeed();
+  void themeSelected(int currentRow);
 
  protected:
   virtual void resizeEvent ( QResizeEvent * event );