# HG changeset patch # User Michiel Broek # Date 1652300775 -7200 # Node ID b8232133a12d7d6a19e1c8ba65fe98b54c81e826 # Parent bbab7d37d12f0d4fd01ab14096415becc77b49c7 Fixes for select another yeast. diff -r bbab7d37d12f -r b8232133a12d src/EditProductTab6.cpp --- a/src/EditProductTab6.cpp Wed May 11 21:04:08 2022 +0200 +++ b/src/EditProductTab6.cpp Wed May 11 22:26:15 2022 +0200 @@ -756,6 +756,7 @@ bool instock = yinstockEdit->isChecked(); QString w; QTableWidgetItem *item; + int oldform = product->yeasts.at(product->yeasts_row).y_form; if (val < 1) return; @@ -767,7 +768,7 @@ */ QString sql = "SELECT name,laboratory,product_id,type,form,min_temperature,max_temperature,flocculation,attenuation," "cells,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide," - "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost FROM inventory_yeasts "; + "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost,inventory FROM inventory_yeasts "; if (instock) sql.append("WHERE inventory > 0 "); sql.append("ORDER BY laboratory,product_id,name"); @@ -805,22 +806,33 @@ product->yeasts[product->yeasts_row].y_gr_hl_hi = query.value(20).toInt(); product->yeasts[product->yeasts_row].y_sg_hi = query.value(21).toDouble(); product->yeasts[product->yeasts_row].y_cost = query.value(22).toDouble(); + product->yeasts[product->yeasts_row].y_inventory = query.value(23).toDouble(); /* * Update the visible fields */ + const QSignalBlocker blocker1(yamountEdit); ynameEdit->setText(product->yeasts.at(product->yeasts_row).y_name); ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).y_laboratory); yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).y_product_id); if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { + if (oldform != YEAST_FORMS_LIQUID) + product->yeasts[product->yeasts_row].y_amount = 1; + yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount); yamountEdit->setDecimals(0); yamountEdit->setSingleStep(1.0); yamountLabel->setText(tr("Total packs:")); } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) { + if (oldform == YEAST_FORMS_LIQUID) + product->yeasts[product->yeasts_row].y_amount = 0.01; + yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount * 1000.0); yamountEdit->setDecimals(1); yamountEdit->setSingleStep(0.5); yamountLabel->setText(tr("Amount in gr:")); } else { + if (oldform == YEAST_FORMS_LIQUID) + product->yeasts[product->yeasts_row].y_amount = 0.01; + yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount * 1000.0); yamountEdit->setDecimals(1); yamountEdit->setSingleStep(0.5); yamountLabel->setText(tr("Amount in ml:")); @@ -850,8 +862,18 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->yeastsTable->setItem(product->yeasts_row, 8, item); - calcYeast(); + if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) + item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(product->yeasts_row).y_amount, 1, 'f', 0, '0')); + else if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY || product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED) + item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(product->yeasts_row).y_amount * 1000.0, 3, 'f', 2, '0')); + else + item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(product->yeasts_row).y_amount * 1000.0, 3, 'f', 2, '0')); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + ui->yeastsTable->setItem(product->yeasts_row, 9, item); + + //calcYeast(); is_changed(); + emit refreshAll(); } @@ -982,6 +1004,7 @@ yamountEdit->setGeometry(QRect(160, 130, 121, 24)); yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); yamountEdit->setAccelerated(true); + yamountEdit->setMaximum(10000.0); if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { yamountEdit->setDecimals(0); yamountEdit->setSingleStep(1.0);