Author: mir3x
Date: Tue Nov 29 12:42:41 2016
New Revision: 34649

URL: http://svn.gna.org/viewcvs/freeciv?rev=34649&view=rev
Log:
Qt client - fixed city dialog worklist autoresize

See bug #25342

Modified:
    trunk/client/gui-qt/citydlg.cpp

Modified: trunk/client/gui-qt/citydlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/citydlg.cpp?rev=34649&r1=34648&r2=34649&view=diff
==============================================================================
--- trunk/client/gui-qt/citydlg.cpp     (original)
+++ trunk/client/gui-qt/citydlg.cpp     Tue Nov 29 12:42:41 2016
@@ -1519,6 +1519,7 @@
   prod_option_layout->addWidget(label, Qt::AlignRight);
   prod_options = new QGroupBox(this);
   prod_options->setLayout(prod_option_layout);
+  prod_options->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
 
   /* prev/next and close buttons */
   button = new QPushButton;
@@ -1628,8 +1629,9 @@
   p_table_p->setSelectionMode(QAbstractItemView::SingleSelection);
   production_combo_p->setFixedHeight(h);
   p_table_p->setMinimumWidth(200);
-  p_table_p->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
+  
p_table_p->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
   p_table_p->setContextMenuPolicy(Qt::CustomContextMenu);
+  p_table_p->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
   header = p_table_p->horizontalHeader();
   header->setStretchLastSection(true);
 
@@ -2172,14 +2174,18 @@
 ****************************************************************************/
 void city_dialog::update_sliders()
 {
-  struct cm_parameter *param;
+  struct cm_parameter param;
+  const struct cm_parameter *cparam;
   int output;
   QVariant qvar;
   QLabel *label;
 
-  param = new cm_parameter;
-  if (cma_is_city_under_agent(pcity, param) == false) {
-    return;
+  if (cma_is_city_under_agent(pcity, &param) == false) {
+    if (cma_table->currentRow() == -1 || cmafec_preset_num() == 0) {
+      return;
+    }
+    cparam = cmafec_preset_get_parameter(cma_table->currentRow());
+    cm_copy_parameter(&param, cparam);
   }
 
   for (output = O_FOOD; output < 2 * O_LAST; output++) {
@@ -2189,28 +2195,27 @@
   for (output = O_FOOD; output < O_LAST; output++) {
     qvar = slider_tab[2 * output + 1]->property("FC");
     label = reinterpret_cast<QLabel *>(qvar.value<void *>());
-    label->setText(QString::number(param->factor[output]));
-    slider_tab[2 * output + 1]->setValue(param->factor[output]);
+    label->setText(QString::number(param.factor[output]));
+    slider_tab[2 * output + 1]->setValue(param.factor[output]);
     qvar = slider_tab[2 * output]->property("FC");
     label = reinterpret_cast<QLabel *>(qvar.value<void *>());
-    label->setText(QString::number(param->minimal_surplus[output]));
-    slider_tab[2 * output]->setValue(param->minimal_surplus[output]);
+    label->setText(QString::number(param.minimal_surplus[output]));
+    slider_tab[2 * output]->setValue(param.minimal_surplus[output]);
   }
 
   slider_tab[2 * O_LAST + 1]->blockSignals(true);
   qvar = slider_tab[2 * O_LAST + 1]->property("FC");
   label = reinterpret_cast<QLabel *>(qvar.value<void *>());
-  label->setText(QString::number(param->happy_factor));
-  slider_tab[2 * O_LAST + 1]->setValue(param->happy_factor);
+  label->setText(QString::number(param.happy_factor));
+  slider_tab[2 * O_LAST + 1]->setValue(param.happy_factor);
   slider_tab[2 * O_LAST + 1]->blockSignals(false);
   cma_celeb_checkbox->blockSignals(true);
-  cma_celeb_checkbox->setChecked(param->require_happy);
+  cma_celeb_checkbox->setChecked(param.require_happy);
   cma_celeb_checkbox->blockSignals(false);
 
   for (output = O_FOOD; output < 2 * O_LAST; output++) {
     slider_tab[output]->blockSignals(false);
   }
-  delete param;
 }
 
 /****************************************************************************


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to