src/database/db_recipe.cpp

changeset 283
242a68fa7186
parent 282
d1d208a857b0
child 284
33bb98c33e6a
--- a/src/database/db_recipe.cpp	Mon Jun 13 15:47:16 2022 +0200
+++ b/src/database/db_recipe.cpp	Mon Jun 13 16:47:52 2022 +0200
@@ -138,43 +138,43 @@
 	    for (int i = 0; i < fermentables.array().size(); i++) {
 		QJsonObject obj = fermentables.array().at(i).toObject();
 		Fermentables f;
-		f.f_name = obj["f_name"].toString();
-		f.f_origin = obj["f_origin"].toString();
-		f.f_supplier = obj["f_supplier"].toString();
-		f.f_amount = obj["f_amount"].toDouble();
-		f.f_cost = obj["f_cost"].toDouble();
-		f.f_type = obj["f_type"].toInt();
-		f.f_yield = obj["f_yield"].toDouble();
-		f.f_color = obj["f_color"].toDouble();
-		f.f_coarse_fine_diff = obj["f_coarse_fine_diff"].toDouble();
-		f.f_moisture = obj["f_moisture"].toDouble();
-		f.f_diastatic_power = obj["f_diastatic_power"].toDouble();
-		f.f_protein = obj["f_protein"].toDouble();
-		f.f_dissolved_protein = obj["f_dissolved_protein"].toDouble();
-		f.f_max_in_batch = obj["f_max_in_batch"].toDouble();
-		f.f_graintype = obj["f_graintype"].toInt();
-		f.f_added = obj["f_added"].toInt();
-		f.f_recommend_mash = obj["f_recommend_mash"].toInt() ? true:false;
-		f.f_add_after_boil = obj["f_add_after_boil"].toInt() ? true:false;
-		f.f_adjust_to_total_100 = obj["f_adjust_to_total_100"].toInt() ? true:false;
-		f.f_percentage = obj["f_percentage"].toDouble();
-		f.f_di_ph = obj["f_di_ph"].toDouble();
-		f.f_acid_to_ph_57 = obj["f_acid_to_ph_57"].toDouble();
-		if (f.f_adjust_to_total_100)
+		f.name = obj["f_name"].toString();
+		f.origin = obj["f_origin"].toString();
+		f.supplier = obj["f_supplier"].toString();
+		f.amount = obj["f_amount"].toDouble();
+		f.cost = obj["f_cost"].toDouble();
+		f.type = obj["f_type"].toInt();
+		f.yield = obj["f_yield"].toDouble();
+		f.color = obj["f_color"].toDouble();
+		f.coarse_fine_diff = obj["f_coarse_fine_diff"].toDouble();
+		f.moisture = obj["f_moisture"].toDouble();
+		f.diastatic_power = obj["f_diastatic_power"].toDouble();
+		f.protein = obj["f_protein"].toDouble();
+		f.dissolved_protein = obj["f_dissolved_protein"].toDouble();
+		f.max_in_batch = obj["f_max_in_batch"].toDouble();
+		f.graintype = obj["f_graintype"].toInt();
+		f.added = obj["f_added"].toInt();
+		f.recommend_mash = obj["f_recommend_mash"].toInt() ? true:false;
+		f.add_after_boil = obj["f_add_after_boil"].toInt() ? true:false;
+		f.adjust_to_total_100 = obj["f_adjust_to_total_100"].toInt() ? true:false;
+		f.percentage = obj["f_percentage"].toDouble();
+		f.di_ph = obj["f_di_ph"].toDouble();
+		f.acid_to_ph_57 = obj["f_acid_to_ph_57"].toDouble();
+		if (f.adjust_to_total_100)
 		    reci->fermentables_use100 = true;
-		percentcheck += f.f_percentage;
+		percentcheck += f.percentage;
 		reci->fermentables.append(f);
 	    }
 	    if (percentcheck == 0) {
 		/* Missing percentages, fix it. */
 		double total = 0;
 		for (int i = 0; i < reci->fermentables.size(); i++) {
-			if (reci->fermentables.at(i).f_added < 4)
-			    total += reci->fermentables.at(i).f_amount;
+			if (reci->fermentables.at(i).added < 4)
+			    total += reci->fermentables.at(i).amount;
 		}
 		for (int i = 0; i < reci->fermentables.size(); i++) {
-			if (reci->fermentables.at(i).f_added < 4)
-			    reci->fermentables[i].f_percentage = round((reci->fermentables.at(i).f_amount / total) * 10000.0) / 100.0;
+			if (reci->fermentables.at(i).added < 4)
+			    reci->fermentables[i].percentage = round((reci->fermentables.at(i).amount / total) * 10000.0) / 100.0;
 		}
 		qInfo() << "fixed missing percentages";
 	    }
@@ -485,28 +485,28 @@
 	QJsonArray array;
 	for (int i = 0; i < reci->fermentables.size(); i++) {
 		QJsonObject obj;
-		obj.insert("f_name", reci->fermentables.at(i).f_name);
-		obj.insert("f_origin", reci->fermentables.at(i).f_origin);
-		obj.insert("f_supplier", reci->fermentables.at(i).f_supplier);
-		obj.insert("f_amount", round(reci->fermentables.at(i).f_amount * 10000) / 10000);
-		obj.insert("f_cost", round(reci->fermentables.at(i).f_cost * 1000) / 1000);
-		obj.insert("f_type", reci->fermentables.at(i).f_type);
-		obj.insert("f_yield", round(reci->fermentables.at(i).f_yield * 10) / 10);
-		obj.insert("f_color", round(reci->fermentables.at(i).f_color * 10) / 10);
-		obj.insert("f_coarse_fine_diff", round(reci->fermentables.at(i).f_coarse_fine_diff * 10) / 10);
-		obj.insert("f_moisture", round(reci->fermentables.at(i).f_moisture * 10) / 10);
-		obj.insert("f_diastatic_power", round(reci->fermentables.at(i).f_diastatic_power * 100000) / 100000);
-		obj.insert("f_protein", round(reci->fermentables.at(i).f_protein * 10) / 10);
-		obj.insert("f_dissolved_protein", round(reci->fermentables.at(i).f_dissolved_protein * 10) / 10);
-		obj.insert("f_max_in_batch", reci->fermentables.at(i).f_max_in_batch);
-		obj.insert("f_graintype", reci->fermentables.at(i).f_graintype);
-		obj.insert("f_added", reci->fermentables.at(i).f_added);
-		obj.insert("f_recommend_mash", reci->fermentables.at(i).f_recommend_mash ? 1:0);
-		obj.insert("f_add_after_boil", reci->fermentables.at(i).f_add_after_boil ? 1:0);
-		obj.insert("f_adjust_to_total_100", reci->fermentables.at(i).f_adjust_to_total_100 ? 1:0);
-		obj.insert("f_percentage", round(reci->fermentables.at(i).f_percentage * 10) / 10);
-		obj.insert("f_di_ph", round(reci->fermentables.at(i).f_di_ph * 100000) / 100000);
-		obj.insert("f_acid_to_ph_57", round(reci->fermentables.at(i).f_acid_to_ph_57 * 100000) / 100000);
+		obj.insert("f_name", reci->fermentables.at(i).name);
+		obj.insert("f_origin", reci->fermentables.at(i).origin);
+		obj.insert("f_supplier", reci->fermentables.at(i).supplier);
+		obj.insert("f_amount", round(reci->fermentables.at(i).amount * 10000) / 10000);
+		obj.insert("f_cost", round(reci->fermentables.at(i).cost * 1000) / 1000);
+		obj.insert("f_type", reci->fermentables.at(i).type);
+		obj.insert("f_yield", round(reci->fermentables.at(i).yield * 10) / 10);
+		obj.insert("f_color", round(reci->fermentables.at(i).color * 10) / 10);
+		obj.insert("f_coarse_fine_diff", round(reci->fermentables.at(i).coarse_fine_diff * 10) / 10);
+		obj.insert("f_moisture", round(reci->fermentables.at(i).moisture * 10) / 10);
+		obj.insert("f_diastatic_power", round(reci->fermentables.at(i).diastatic_power * 100000) / 100000);
+		obj.insert("f_protein", round(reci->fermentables.at(i).protein * 10) / 10);
+		obj.insert("f_dissolved_protein", round(reci->fermentables.at(i).dissolved_protein * 10) / 10);
+		obj.insert("f_max_in_batch", reci->fermentables.at(i).max_in_batch);
+		obj.insert("f_graintype", reci->fermentables.at(i).graintype);
+		obj.insert("f_added", reci->fermentables.at(i).added);
+		obj.insert("f_recommend_mash", reci->fermentables.at(i).recommend_mash ? 1:0);
+		obj.insert("f_add_after_boil", reci->fermentables.at(i).add_after_boil ? 1:0);
+		obj.insert("f_adjust_to_total_100", reci->fermentables.at(i).adjust_to_total_100 ? 1:0);
+		obj.insert("f_percentage", round(reci->fermentables.at(i).percentage * 10) / 10);
+		obj.insert("f_di_ph", round(reci->fermentables.at(i).di_ph * 100000) / 100000);
+		obj.insert("f_acid_to_ph_57", round(reci->fermentables.at(i).acid_to_ph_57 * 100000) / 100000);
 		array.append(obj);      /* Append this object */
 	}
 	QJsonDocument doc;

mercurial