src/EditProductTab4.cpp

changeset 375
c21567bfd703
parent 373
b02aca4e926c
child 380
8f5c03ed4321
--- a/src/EditProductTab4.cpp	Fri Jul 29 13:20:24 2022 +0200
+++ b/src/EditProductTab4.cpp	Fri Jul 29 16:21:20 2022 +0200
@@ -325,6 +325,8 @@
     newh.myrcene = 0;
     newh.total_oil = 0;
     newh.inventory = 0;
+    newh.utilisation = 20;
+    newh.bu_factor = 1;
 
     product->hops.append(newh);
     emit refreshAll();
@@ -430,7 +432,7 @@
     /*
      * Search the hop pointed by the index and instock flag.
      */
-    QString sql = "SELECT name,origin,alpha,beta,humulene,caryophyllene,cohumulone,myrcene,hsi,total_oil,type,form,cost,inventory FROM inventory_hops ";
+    QString sql = "SELECT * FROM inventory_hops ";
     if (instock)
         sql.append("WHERE inventory > 0 ");
     sql.append("ORDER BY origin,name");
@@ -444,20 +446,22 @@
     /*
      * Replace the hop record contents
      */
-    product->hops[product->hops_row].name = query.value(0).toString();
-    product->hops[product->hops_row].origin = query.value(1).toString();
-    product->hops[product->hops_row].alpha = query.value(2).toDouble();
-    product->hops[product->hops_row].beta = query.value(3).toDouble();
-    product->hops[product->hops_row].humulene = query.value(4).toDouble();
-    product->hops[product->hops_row].caryophyllene = query.value(5).toDouble();
-    product->hops[product->hops_row].cohumulone = query.value(6).toDouble();
-    product->hops[product->hops_row].myrcene = query.value(7).toDouble();
-    product->hops[product->hops_row].hsi = query.value(8).toDouble();
-    product->hops[product->hops_row].total_oil = query.value(9).toDouble();
-    product->hops[product->hops_row].type = query.value(10).toInt();
-    product->hops[product->hops_row].form = query.value(11).toInt();
-    product->hops[product->hops_row].cost = query.value(12).toDouble();
-    product->hops[product->hops_row].inventory = query.value(13).toDouble();
+    product->hops[product->hops_row].name = query.value("name").toString();
+    product->hops[product->hops_row].origin = query.value("origin").toString();
+    product->hops[product->hops_row].alpha = query.value("alpha").toDouble();
+    product->hops[product->hops_row].beta = query.value("beta").toDouble();
+    product->hops[product->hops_row].humulene = query.value("humulene").toDouble();
+    product->hops[product->hops_row].caryophyllene = query.value("caryophyllene").toDouble();
+    product->hops[product->hops_row].cohumulone = query.value("cohumulone").toDouble();
+    product->hops[product->hops_row].myrcene = query.value("myrcene").toDouble();
+    product->hops[product->hops_row].hsi = query.value("hsi").toDouble();
+    product->hops[product->hops_row].total_oil = query.value("total_oil").toDouble();
+    product->hops[product->hops_row].type = query.value("type").toInt();
+    product->hops[product->hops_row].form = query.value("form").toInt();
+    product->hops[product->hops_row].cost = query.value("cost").toDouble();
+    product->hops[product->hops_row].inventory = query.value("inventory").toDouble();
+    product->hops[product->hops_row].utilisation = query.value("utilisation").toDouble();
+    product->hops[product->hops_row].bu_factor = query.value("bu_factor").toDouble();
 
     /*
      * Update the visible fields

mercurial