Using names for profile_setup query

Mon, 27 Jun 2022 11:50:18 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 27 Jun 2022 11:50:18 +0200
changeset 309
8678a0731737
parent 308
79f100a84f65
child 310
bdaac24b86ed

Using names for profile_setup query

src/Setup.cpp file | annotate | diff | comparison | revisions
ui/MainWindow.ui file | annotate | diff | comparison | revisions
--- a/src/Setup.cpp	Fri Jun 24 16:50:22 2022 +0200
+++ b/src/Setup.cpp	Mon Jun 27 11:50:18 2022 +0200
@@ -295,15 +295,15 @@
     query.exec();
     query.next();
 
-    breweryEdit->setText(query.value(1).toString()); // max 128
+    breweryEdit->setText(query.value("brewery_name").toString()); // max 128
     connect(breweryEdit, &QLineEdit::textChanged, this, &Setup::is_changed);
 
-    fwhEdit->setValue(query.value(4).toInt());
-    mashhopEdit->setValue(query.value(3).toInt());
-    pelletEdit->setValue(query.value(5).toInt());
-    hopplugEdit->setValue(query.value(6).toInt());
-    wethopEdit->setValue(query.value(7).toInt());
-    cryohopEdit->setValue(query.value(8).toInt());
+    fwhEdit->setValue(query.value("factor_fwh").toInt());
+    mashhopEdit->setValue(query.value("factor_mashhop").toInt());
+    pelletEdit->setValue(query.value("factor_pellet").toInt());
+    hopplugEdit->setValue(query.value("factor_plug").toInt());
+    wethopEdit->setValue(query.value("factor_wethop").toInt());
+    cryohopEdit->setValue(query.value("factor_cryohop").toInt());
     connect(fwhEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
     connect(mashhopEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
     connect(pelletEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
@@ -311,8 +311,8 @@
     connect(wethopEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
     connect(cryohopEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
 
-    grainEdit->setValue(query.value(12).toDouble());
-    brixEdit->setValue(query.value(11).toDouble());
+    grainEdit->setValue(query.value("grain_absorbtion").toDouble());
+    brixEdit->setValue(query.value("brix_correction").toDouble());
     connect(grainEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed);
     connect(brixEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed);
 
@@ -322,14 +322,14 @@
     colorEdit->addItem("Halberstadt");
     colorEdit->addItem("Naudts");
     colorEdit->setEditable(true);
-    colorEdit->setCurrentIndex(query.value(10).toInt());
+    colorEdit->setCurrentIndex(query.value("color_method").toInt());
     connect(colorEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
 
     ibuEdit->addItem("Tinseth");
     ibuEdit->addItem("Rager");
     ibuEdit->addItem("Daniels");
     ibuEdit->setEditable(true);
-    ibuEdit->setCurrentIndex(query.value(9).toInt());
+    ibuEdit->setCurrentIndex(query.value("ibu_method").toInt());
     connect(ibuEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
 
     QSqlQuery query2("SELECT record,name FROM inventory_waters");
@@ -339,7 +339,7 @@
     waterEdit->setPlaceholderText(tr("Choose default water"));
     for (int i = 0 ; i < query2.size() ; i++ ) {
 	waterEdit->addItem(query2.value(1).toString());
-	if (query2.value(0).toInt() == query.value(13).toInt()) {
+	if (query2.value(0).toInt() == query.value("default_water").toInt()) {
 	    pos = i;
 	}
 	query2.next();
@@ -355,7 +355,7 @@
     yeastEdit->setPlaceholderText(tr("Choose laboratory"));
     for (int i = 0 ; i < query3.size() ; i++ ) {
 	yeastEdit->addItem(query3.value(0).toString());
-	if (QString::compare(query.value(14).toString(), query3.value(0).toString(), Qt::CaseSensitive) == 0)
+	if (QString::compare(query.value("my_yeastlab").toString(), query3.value(0).toString(), Qt::CaseSensitive) == 0)
 	    pos = i;
 	query3.next();
     }
@@ -364,7 +364,7 @@
     connect(yeastEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
 
     /* logo */
-    logoByteArray = query.value(2).toByteArray();
+    logoByteArray = query.value("brewery_logo").toByteArray();
     QPixmap outPixmap = QPixmap();
     outPixmap.loadFromData(logoByteArray);
     logoLabel->setPixmap(outPixmap);
--- a/ui/MainWindow.ui	Fri Jun 24 16:50:22 2022 +0200
+++ b/ui/MainWindow.ui	Mon Jun 27 11:50:18 2022 +0200
@@ -87,11 +87,47 @@
     <property name="title">
      <string>Monitor</string>
     </property>
-    <addaction name="actionSystems"/>
+    <widget class="QMenu" name="menuSystems">
+     <property name="title">
+      <string>Systems</string>
+     </property>
+     <property name="icon">
+      <iconset resource="../resources/icons.qrc">
+       <normaloff>:/icons/silk/computer.png</normaloff>:/icons/silk/computer.png</iconset>
+     </property>
+    </widget>
+    <widget class="QMenu" name="menuFermenters">
+     <property name="title">
+      <string>Fermenters</string>
+     </property>
+     <property name="icon">
+      <iconset resource="../resources/icons.qrc">
+       <normaloff>:/icons/bms/fridge.png</normaloff>:/icons/bms/fridge.png</iconset>
+     </property>
+    </widget>
+    <widget class="QMenu" name="menuCO2_Meters">
+     <property name="title">
+      <string>CO2 Meters</string>
+     </property>
+     <property name="icon">
+      <iconset resource="../resources/icons.qrc">
+       <normaloff>:/icons/bms/beerbottle.png</normaloff>:/icons/bms/beerbottle.png</iconset>
+     </property>
+    </widget>
+    <widget class="QMenu" name="menuiSpindels">
+     <property name="title">
+      <string>iSpindels</string>
+     </property>
+     <property name="icon">
+      <iconset resource="../resources/icons.qrc">
+       <normaloff>:/icons/bms/fermenter.png</normaloff>:/icons/bms/fermenter.png</iconset>
+     </property>
+    </widget>
+    <addaction name="menuSystems"/>
     <addaction name="separator"/>
-    <addaction name="actionFermenters"/>
-    <addaction name="actionCO2_Meters"/>
-    <addaction name="actioniSpindels"/>
+    <addaction name="menuFermenters"/>
+    <addaction name="menuCO2_Meters"/>
+    <addaction name="menuiSpindels"/>
    </widget>
    <widget class="QMenu" name="menuProducts">
     <property name="title">
@@ -150,42 +186,6 @@
     <string>About</string>
    </property>
   </action>
-  <action name="actionSystems">
-   <property name="icon">
-    <iconset>
-     <normaloff>:icons/silk/server.png</normaloff>:icons/silk/server.png</iconset>
-   </property>
-   <property name="text">
-    <string>Systems</string>
-   </property>
-  </action>
-  <action name="actionFermenters">
-   <property name="icon">
-    <iconset>
-     <normaloff>:icons/bms/fridge.png</normaloff>:icons/bms/fridge.png</iconset>
-   </property>
-   <property name="text">
-    <string>Fermenters</string>
-   </property>
-  </action>
-  <action name="actionCO2_Meters">
-   <property name="icon">
-    <iconset>
-     <normaloff>:icons/bms/beerbottle.png</normaloff>:icons/bms/beerbottle.png</iconset>
-   </property>
-   <property name="text">
-    <string>CO2 Meters</string>
-   </property>
-  </action>
-  <action name="actioniSpindels">
-   <property name="icon">
-    <iconset>
-     <normaloff>:icons/bms/fermenter.png</normaloff>:icons/bms/fermenter.png</iconset>
-   </property>
-   <property name="text">
-    <string>iSpindels</string>
-   </property>
-  </action>
   <action name="actionSuppliers">
    <property name="icon">
     <iconset>
@@ -429,6 +429,26 @@
     <string>Import beerXML</string>
    </property>
   </action>
+  <action name="actiondummy">
+   <property name="text">
+    <string>dummy</string>
+   </property>
+  </action>
+  <action name="actionhh">
+   <property name="text">
+    <string>hh</string>
+   </property>
+  </action>
+  <action name="actionhj">
+   <property name="text">
+    <string>hj</string>
+   </property>
+  </action>
+  <action name="actionll">
+   <property name="text">
+    <string>ll</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources>

mercurial