diff -r aa8d421bfc24 -r 35ce719998e1 src/EditProductTab5.cpp --- a/src/EditProductTab5.cpp Tue Jun 21 16:16:43 2022 +0200 +++ b/src/EditProductTab5.cpp Thu Jun 23 16:50:23 2022 +0200 @@ -32,6 +32,20 @@ } +bool EditProduct::block_misc(int stage, int use_use) +{ + if (stage > PROD_STAGE_TERTIARY && use_use < MISC_USES_BOTTLING) + return true; + if (stage > PROD_STAGE_PRIMARY && use_use < MISC_USES_SECONDARY) + return true; + if (stage > PROD_STAGE_BREW && use_use < MISC_USES_PRIMARY) + return true; + if (stage > PROD_STAGE_WAIT && use_use < MISC_USES_MASH) + return true; + return false; +} + + void EditProduct::refreshMiscs() { QString w; @@ -96,18 +110,23 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->miscsTable->setItem(i, 4, item); - if (product->miscs.at(i).amount_is_weight) - item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0')); - else - item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0')); - item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - if (product->miscs.at(i).inventory < product->miscs.at(i).amount) - item->setForeground(QBrush(QColor(Qt::red))); + if (block_misc(product->stage, product->miscs.at(i).use_use)) { + item = new QTableWidgetItem(QString("")); + } else { + if (product->miscs.at(i).amount_is_weight) + item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0')); + else + item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if (product->miscs.at(i).inventory < product->miscs.at(i).amount) + item->setForeground(QBrush(QColor(Qt::red))); + } ui->miscsTable->setItem(i, 5, item); /* * Add the Delete and Edit row buttons. * Not for water agents, these are set on the water tab. + * And also not if the ingredient has been used. */ if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT) { ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */ @@ -118,6 +137,15 @@ item = new QTableWidgetItem(""); item->setToolTip(tr("Edit this from the water tab")); ui->miscsTable->setItem(i, 7, item); + } else if (block_misc(product->stage, product->miscs.at(i).use_use)) { + ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */ + item = new QTableWidgetItem(""); + item->setToolTip(tr("Misc already used")); + ui->miscsTable->setItem(i, 6, item); + ui->miscsTable->removeCellWidget(i, 7); + item = new QTableWidgetItem(""); + item->setToolTip(tr("Misc already used")); + ui->miscsTable->setItem(i, 7, item); } else { if (ui->miscsTable->item(i, 6)) { ui->miscsTable->takeItem(i, 6); /* to remove the old tooltip */