Thu, 05 May 2022 20:01:30 +0200
Internal product record stores the starter steps in array format.
src/EditProduct.cpp | file | annotate | diff | comparison | revisions | |
src/EditProductTab6.cpp | file | annotate | diff | comparison | revisions | |
src/global.h | file | annotate | diff | comparison | revisions |
--- a/src/EditProduct.cpp Thu May 05 17:20:06 2022 +0200 +++ b/src/EditProduct.cpp Thu May 05 20:01:30 2022 +0200 @@ -333,14 +333,14 @@ product->starter_viability = query.value("starter_viability").toInt(); product->yeast_prod_date = query.value("yeast_prod_date").toDate(); product->yeast_pitchrate = query.value("yeast_pitchrate").toDouble(); - product->prop1_type = query.value("prop1_type").toInt(); - product->prop1_volume = query.value("prop1_volume").toDouble(); - product->prop2_type = query.value("prop2_type").toInt(); - product->prop2_volume = query.value("prop2_volume").toDouble(); - product->prop3_type = query.value("prop3_type").toInt(); - product->prop3_volume = query.value("prop3_volume").toDouble(); - product->prop4_type = query.value("prop4_type").toInt(); - product->prop4_volume = query.value("prop4_volume").toDouble(); + product->prop_type[0] = query.value("prop1_type").toInt(); + product->prop_volume[0] = query.value("prop1_volume").toDouble(); + product->prop_type[1] = query.value("prop2_type").toInt(); + product->prop_volume[1] = query.value("prop2_volume").toDouble(); + product->prop_type[2] = query.value("prop3_type").toInt(); + product->prop_volume[2] = query.value("prop3_volume").toDouble(); + product->prop_type[3] = query.value("prop4_type").toInt(); + product->prop_volume[3] = query.value("prop4_volume").toDouble(); product->divide_type = query.value("divide_type").toInt(); product->divide_size = query.value("divide_size").toDouble(); @@ -729,11 +729,11 @@ product->wa_acid_perc = 80; product->wa_base_name = 0; product->starter_enable = false; - product->starter_type = product->prop1_type = product->prop2_type = product->prop3_type = product->prop4_type = 0; + product->starter_type = product->prop_type[0] = product->prop_type[1] = product->prop_type[2] = product->prop_type[3] = 0; product->starter_viability = 100; product->starter_sg = 1.037; product->yeast_prod_date = QDate(); - product->yeast_pitchrate = product->prop1_volume = product->prop2_volume = product->prop3_volume = product->prop4_volume = 0; + product->yeast_pitchrate = product->prop_volume[0] = product->prop_volume[1] = product->prop_volume[2] = product->prop_volume[3] = 0; product->divide_type = product->divide_parts = product->divide_part = 0; product->divide_size = product->divide_factor = 0; } @@ -1503,14 +1503,14 @@ query.bindValue(":starter_viability", product->starter_viability); query.bindValue(":yeast_prod_date", product->yeast_prod_date); query.bindValue(":yeast_pitchrate", round(product->yeast_pitchrate * 1000) / 1000); - query.bindValue(":prop1_type", product->prop1_type); - query.bindValue(":prop1_volume", round(product->prop1_volume * 1000) / 1000); - query.bindValue(":prop2_type", product->prop2_type); - query.bindValue(":prop2_volume", round(product->prop2_volume * 1000) / 1000); - query.bindValue(":prop3_type", product->prop3_type); - query.bindValue(":prop3_volume", round(product->prop3_volume * 1000) / 1000); - query.bindValue(":prop4_type", product->prop4_type); - query.bindValue(":prop4_volume", round(product->prop4_volume * 1000) / 1000); + query.bindValue(":prop1_type", product->prop_type[0]); + query.bindValue(":prop1_volume", round(product->prop_volume[0] * 1000) / 1000); + query.bindValue(":prop2_type", product->prop_type[1]); + query.bindValue(":prop2_volume", round(product->prop_volume[1] * 1000) / 1000); + query.bindValue(":prop3_type", product->prop_type[2]); + query.bindValue(":prop3_volume", round(product->prop_volume[2] * 1000) / 1000); + query.bindValue(":prop4_type", product->prop_type[3]); + query.bindValue(":prop4_volume", round(product->prop_volume[3] * 1000) / 1000); query.bindValue(":divide_type", product->divide_type); query.bindValue(":divide_size", round(product->divide_size * 10) / 10); query.bindValue(":divide_factor", round(product->divide_factor * 100) / 100);
--- a/src/EditProductTab6.cpp Thu May 05 17:20:06 2022 +0200 +++ b/src/EditProductTab6.cpp Thu May 05 20:01:30 2022 +0200 @@ -350,7 +350,7 @@ iconT.addFile(QString::fromUtf8(":/icons/silk/pencil.png"), QSize(), QIcon::Normal, QIcon::Off); - if ((product->prop1_volume + product->prop2_volume + product->prop3_volume + product->prop4_volume) == 0) { + if ((product->prop_volume[0] + product->prop_volume[1] + product->prop_volume[2] + product->prop_volume[3]) == 0) { /* * Auto calculate the starter. */ @@ -413,19 +413,8 @@ pWidget->setLayout(pLayout); ui->starterTable->setCellWidget(step -1, 6, pWidget); - if (step == 1) { - product->prop1_type = product->starter_type; - product->prop1_volume = result.svol / 1000.0; - } else if (step == 2) { - product->prop2_type = product->starter_type; - product->prop2_volume = result.svol / 1000.0; - } else if (step == 3) { - product->prop3_type = product->starter_type; - product->prop3_volume = result.svol / 1000.0; - } else if (step == 4) { - product->prop4_type = product->starter_type; - product->prop4_volume = result.svol / 1000.0; - } + product->prop_type[step -1] = product->starter_type; + product->prop_volume[step -1] = result.svol / 1000.0; tcells = result.totcells; if (result.totcells > needed) // Hit the target @@ -438,10 +427,10 @@ */ qDebug() << " calcSteps() recalculate"; - if (product->prop1_volume > 0) { - result = calcStep(product->prop1_volume * 1000, product->prop1_type, tcells); + if (product->prop_volume[0] > 0) { + result = calcStep(product->prop_volume[0] * 1000, product->prop_type[0], tcells); ui->starterTable->setRowCount(1); - item = new QTableWidgetItem(starters[product->prop1_type]); + item = new QTableWidgetItem(starters[product->prop_type[0]]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->starterTable->setItem(0, 0, item); @@ -478,18 +467,18 @@ tcells = result.totcells; if (result.totcells > needed) { // Hit the target - product->prop2_volume = product->prop3_volume = product->prop4_volume = 0; - product->prop2_type = product->prop3_type = product->prop4_type = 0; + product->prop_volume[1] = product->prop_volume[2] = product->prop_volume[3] = 0; + product->prop_type[1] = product->prop_type[2] = product->prop_type[3] = 0; return; - } else if (product->prop2_volume == 0) { // Extra step needed, start with the same size. - product->prop2_volume = product->prop1_volume; - product->prop2_type = product->prop1_type; + } else if (product->prop_volume[1] == 0) { // Extra step needed, start with the same size. + product->prop_volume[1] = product->prop_volume[0]; + product->prop_type[1] = product->prop_type[0]; } } - if (product->prop2_volume > 0) { - result = calcStep(product->prop2_volume * 1000, product->prop2_type, tcells); + if (product->prop_volume[1] > 0) { + result = calcStep(product->prop_volume[1] * 1000, product->prop_type[1], tcells); ui->starterTable->setRowCount(2); - item = new QTableWidgetItem(starters[product->prop2_type]); + item = new QTableWidgetItem(starters[product->prop_type[1]]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->starterTable->setItem(1, 0, item); @@ -526,18 +515,18 @@ tcells = result.totcells; if (result.totcells > needed) { // Hit the target - product->prop3_volume = product->prop4_volume = 0; - product->prop3_type = product->prop4_type = 0; + product->prop_volume[2] = product->prop_volume[3] = 0; + product->prop_type[2] = product->prop_type[3] = 0; return; - } else if (product->prop3_volume == 0) { // Extra step needed, start with the same size. - product->prop3_volume = product->prop2_volume; - product->prop3_type = product->prop2_type; + } else if (product->prop_volume[2] == 0) { // Extra step needed, start with the same size. + product->prop_volume[2] = product->prop_volume[1]; + product->prop_type[2] = product->prop_type[1]; } } - if (product->prop3_volume > 0) { - result = calcStep(product->prop3_volume * 1000, product->prop3_type, tcells); + if (product->prop_volume[2] > 0) { + result = calcStep(product->prop_volume[2] * 1000, product->prop_type[2], tcells); ui->starterTable->setRowCount(3); - item = new QTableWidgetItem(starters[product->prop3_type]); + item = new QTableWidgetItem(starters[product->prop_type[2]]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->starterTable->setItem(2, 0, item); @@ -574,18 +563,18 @@ tcells = result.totcells; if (result.totcells > needed) { // Hit the target - product->prop4_volume = 0; - product->prop4_type = 0; + product->prop_volume[3] = 0; + product->prop_type[3] = 0; return; - } else if (product->prop4_volume == 0) { // Extra step needed, start with the same size. - product->prop4_volume = product->prop3_volume; - product->prop4_type = product->prop3_type; + } else if (product->prop_volume[3] == 0) { // Extra step needed, start with the same size. + product->prop_volume[3] = product->prop_volume[2]; + product->prop_type[3] = product->prop_type[2]; } } - if (product->prop4_volume > 0) { - result = calcStep(product->prop4_volume * 1000, product->prop4_type, tcells); + if (product->prop_volume[3] > 0) { + result = calcStep(product->prop_volume[3] * 1000, product->prop_type[3], tcells); ui->starterTable->setRowCount(4); - item = new QTableWidgetItem(starters[product->prop4_type]); + item = new QTableWidgetItem(starters[product->prop_type[3]]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->starterTable->setItem(3, 0, item); @@ -654,9 +643,15 @@ void EditProduct::yeast_starter_edit_clicked() { + int stype; + double svol; + QToolButton *pb = qobject_cast<QToolButton *>(QObject::sender()); int row = pb->objectName().toInt(); qDebug() << "yeast_starter_edit_clicked" << row; + + stype = product->prop_type[row]; + svol = product->prop_volume[row]; }
--- a/src/global.h Thu May 05 17:20:06 2022 +0200 +++ b/src/global.h Thu May 05 20:01:30 2022 +0200 @@ -496,14 +496,8 @@ int starter_viability; QDate yeast_prod_date; double yeast_pitchrate; - int prop1_type; - double prop1_volume; - int prop2_type; - double prop2_volume; - int prop3_type; - double prop3_volume; - int prop4_type; - double prop4_volume; + int prop_type[4]; + double prop_volume[4]; int divide_type; double divide_size;