# HG changeset patch # User Michiel Broek # Date 1652261609 -7200 # Node ID 59b0bdbb2f9f9bbfda1c6e27c4c0f9fb941159ba # Parent 904591820c3dfd98f054ffea34c9ea5f0b7119e5 Added field to show the needed cells. Colors in the starter table for good and error results. diff -r 904591820c3d -r 59b0bdbb2f9f src/EditProductTab6.cpp --- a/src/EditProductTab6.cpp Sat May 07 13:55:36 2022 +0200 +++ b/src/EditProductTab6.cpp Wed May 11 11:33:29 2022 +0200 @@ -243,6 +243,7 @@ initcells = (product->yeasts.at(i).y_cells / 1000000000) * product->yeasts.at(i).y_amount * (product->starter_viability / 100.0); needed = round(product->yeast_pitchrate * volume * plato * 10.0) / 10.0; + ui->neededShow->setValue(needed); if (needed > initcells) { maybe_starter = true; } @@ -390,6 +391,8 @@ item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if ((result.irate < 25) || (result.irate > 100)) + item->setForeground(QBrush(QColor(Qt::red))); ui->starterTable->setItem(step -1, 2, item); item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); @@ -398,10 +401,15 @@ item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + item->setForeground(QBrush(QColor((result.totcells > needed) ? Qt::green:Qt::red))); ui->starterTable->setItem(step -1, 4, item); item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if (result.growf < 1) + item->setForeground(QBrush(QColor(Qt::red))); + if ((stype > 0) && (result.growf > 3)) + item->setForeground(QBrush(QColor(Qt::red))); ui->starterTable->setItem(step -1, 5, item); pWidget = new QWidget(); @@ -429,188 +437,65 @@ */ qDebug() << " calcSteps() recalculate"; - 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->prop_type[0]]); - item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->starterTable->setItem(0, 0, item); + for (step = 0; step < 4; step++) { + if (product->prop_volume[step] > 0) { + result = calcStep(product->prop_volume[step] * 1000, product->prop_type[step], tcells); + ui->starterTable->setRowCount(step + 1); + item = new QTableWidgetItem(starters[product->prop_type[step]]); + item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); + ui->starterTable->setItem(step, 0, item); - item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 1, item); + item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + ui->starterTable->setItem(step, 1, item); - item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 2, item); + item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if ((result.irate < 25) || (result.irate > 100)) + item->setForeground(QBrush(QColor(Qt::red))); + ui->starterTable->setItem(step, 2, item); - item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 3, item); + item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + ui->starterTable->setItem(step, 3, item); - item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 4, item); + item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + item->setForeground(QBrush(QColor((result.totcells > needed) ? Qt::green:Qt::red))); + ui->starterTable->setItem(step, 4, item); - item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(0, 5, item); + item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if (result.growf < 1) + item->setForeground(QBrush(QColor(Qt::red))); + if ((stype > 0) && (result.growf > 3)) + item->setForeground(QBrush(QColor(Qt::red))); + ui->starterTable->setItem(step, 5, item); - pWidget = new QWidget(); - QToolButton* btn_edit = new QToolButton(); - btn_edit->setObjectName(QString("0")); /* Send row with the button */ - btn_edit->setIcon(iconT); - connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); - pLayout = new QHBoxLayout(pWidget); - pLayout->addWidget(btn_edit); - pLayout->setContentsMargins(5, 0, 5, 0); - pWidget->setLayout(pLayout); - ui->starterTable->setCellWidget(0, 6, pWidget); + pWidget = new QWidget(); + QToolButton* btn_edit = new QToolButton(); + btn_edit->setObjectName(QString("%1").arg(step)); /* Send row with the button */ + btn_edit->setIcon(iconT); + connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); + pLayout = new QHBoxLayout(pWidget); + pLayout->addWidget(btn_edit); + pLayout->setContentsMargins(5, 0, 5, 0); + pWidget->setLayout(pLayout); + ui->starterTable->setCellWidget(step, 6, pWidget); - tcells = result.totcells; - if (result.totcells > needed) { // Hit the target - 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->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]; + tcells = result.totcells; + if (result.totcells > needed) { // Hit the target + for (int i = step + 1; i < 4; i++) { + product->prop_volume[i] = 0; + product->prop_type[i] = 0; + } + return; + } else if ((step < 3) && (product->prop_volume[step + 1] == 0)) { // Extra step needed, start with the same size. + product->prop_volume[step + 1] = product->prop_volume[step]; + product->prop_type[step + 1] = product->prop_type[step]; + } } } - 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->prop_type[1]]); - item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->starterTable->setItem(1, 0, item); - - item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 1, item); - - item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 2, item); - - item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 3, item); - - item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 4, item); - - item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(1, 5, item); - - pWidget = new QWidget(); - QToolButton* btn_edit = new QToolButton(); - btn_edit->setObjectName(QString("1")); /* Send row with the button */ - btn_edit->setIcon(iconT); - connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); - pLayout = new QHBoxLayout(pWidget); - pLayout->addWidget(btn_edit); - pLayout->setContentsMargins(5, 0, 5, 0); - pWidget->setLayout(pLayout); - ui->starterTable->setCellWidget(1, 6, pWidget); - - tcells = result.totcells; - if (result.totcells > needed) { // Hit the target - product->prop_volume[2] = product->prop_volume[3] = 0; - product->prop_type[2] = product->prop_type[3] = 0; - return; - } 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->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->prop_type[2]]); - item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->starterTable->setItem(2, 0, item); - - item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 1, item); - - item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 2, item); - - item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 3, item); - - item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 4, item); - - item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(2, 5, item); - - pWidget = new QWidget(); - QToolButton* btn_edit = new QToolButton(); - btn_edit->setObjectName(QString("2")); /* Send row with the button */ - btn_edit->setIcon(iconT); - connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); - pLayout = new QHBoxLayout(pWidget); - pLayout->addWidget(btn_edit); - pLayout->setContentsMargins(5, 0, 5, 0); - pWidget->setLayout(pLayout); - ui->starterTable->setCellWidget(2, 6, pWidget); - - tcells = result.totcells; - if (result.totcells > needed) { // Hit the target - product->prop_volume[3] = 0; - product->prop_type[3] = 0; - return; - } 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->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->prop_type[3]]); - item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); - ui->starterTable->setItem(3, 0, item); - - item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 1, item); - - item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 2, item); - - item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 3, item); - - item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 4, item); - - item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->starterTable->setItem(3, 5, item); - - pWidget = new QWidget(); - QToolButton* btn_edit = new QToolButton(); - btn_edit->setObjectName(QString("3")); /* Send row with the button */ - btn_edit->setIcon(iconT); - connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); - pLayout = new QHBoxLayout(pWidget); - pLayout->addWidget(btn_edit); - pLayout->setContentsMargins(5, 0, 5, 0); - pWidget->setLayout(pLayout); - ui->starterTable->setCellWidget(3, 6, pWidget); - } } } diff -r 904591820c3d -r 59b0bdbb2f9f ui/EditProduct.ui --- a/ui/EditProduct.ui Sat May 07 13:55:36 2022 +0200 +++ b/ui/EditProduct.ui Wed May 11 11:33:29 2022 +0200 @@ -3103,6 +3103,53 @@ + + + + 360 + 40 + 181 + 20 + + + + Need million cells: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 550 + 40 + 91 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + false + + + 1 + + + 100000.000000000000000 + + + 0.000000000000000 + +