diff -r 9887278c4fbe -r f7954f2d4451 src/EditProductTab6.cpp --- 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(QObject::sender()); int row = pb->objectName().toInt(); qDebug() << "yeast_starter_edit_clicked" << row; + + stype = product->prop_type[row]; + svol = product->prop_volume[row]; }