src/EditProductTab6.cpp

changeset 284
33bb98c33e6a
parent 202
49ec4fdee5a6
child 299
8021e09ab6a3
equal deleted inserted replaced
283:242a68fa7186 284:33bb98c33e6a
18 */ 18 */
19 19
20 20
21 bool EditProduct::yeast_sort_test(const Yeasts &D1, const Yeasts &D2) 21 bool EditProduct::yeast_sort_test(const Yeasts &D1, const Yeasts &D2)
22 { 22 {
23 if (D1.y_use > D2.y_use) 23 if (D1.use > D2.use)
24 return false; 24 return false;
25 if (D1.y_use < D2.y_use) 25 if (D1.use < D2.use)
26 return true; 26 return true;
27 return (D1.y_amount > D2.y_amount); 27 return (D1.amount > D2.amount);
28 } 28 }
29 29
30 30
31 void EditProduct::refreshYeasts() 31 void EditProduct::refreshYeasts()
32 { 32 {
59 ui->yeastsTable->verticalHeader()->hide(); 59 ui->yeastsTable->verticalHeader()->hide();
60 ui->yeastsTable->setRowCount(product->yeasts.size()); 60 ui->yeastsTable->setRowCount(product->yeasts.size());
61 61
62 for (int i = 0; i < product->yeasts.size(); i++) { 62 for (int i = 0; i < product->yeasts.size(); i++) {
63 63
64 ui->yeastsTable->setItem(i, 0, new QTableWidgetItem(product->yeasts.at(i).y_name)); 64 ui->yeastsTable->setItem(i, 0, new QTableWidgetItem(product->yeasts.at(i).name));
65 ui->yeastsTable->setItem(i, 1, new QTableWidgetItem(product->yeasts.at(i).y_laboratory)); 65 ui->yeastsTable->setItem(i, 1, new QTableWidgetItem(product->yeasts.at(i).laboratory));
66 ui->yeastsTable->setItem(i, 2, new QTableWidgetItem(product->yeasts.at(i).y_product_id)); 66 ui->yeastsTable->setItem(i, 2, new QTableWidgetItem(product->yeasts.at(i).product_id));
67 67
68 item = new QTableWidgetItem(yeast_forms[product->yeasts.at(i).y_form]); 68 item = new QTableWidgetItem(yeast_forms[product->yeasts.at(i).form]);
69 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); 69 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
70 ui->yeastsTable->setItem(i, 3, item); 70 ui->yeastsTable->setItem(i, 3, item);
71 71
72 item = new QTableWidgetItem(yeast_use[product->yeasts.at(i).y_use]); 72 item = new QTableWidgetItem(yeast_use[product->yeasts.at(i).use]);
73 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); 73 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
74 ui->yeastsTable->setItem(i, 4, item); 74 ui->yeastsTable->setItem(i, 4, item);
75 75
76 item = new QTableWidgetItem(QString("%1°C").arg(product->yeasts.at(i).y_min_temperature, 2, 'f', 1, '0')); 76 item = new QTableWidgetItem(QString("%1°C").arg(product->yeasts.at(i).min_temperature, 2, 'f', 1, '0'));
77 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 77 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
78 ui->yeastsTable->setItem(i, 5, item); 78 ui->yeastsTable->setItem(i, 5, item);
79 79
80 item = new QTableWidgetItem(QString("%1°C").arg(product->yeasts.at(i).y_max_temperature, 2, 'f', 1, '0')); 80 item = new QTableWidgetItem(QString("%1°C").arg(product->yeasts.at(i).max_temperature, 2, 'f', 1, '0'));
81 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 81 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
82 ui->yeastsTable->setItem(i, 6, item); 82 ui->yeastsTable->setItem(i, 6, item);
83 83
84 item = new QTableWidgetItem(QString("%1%").arg(product->yeasts.at(i).y_tolerance, 2, 'f', 1, '0')); 84 item = new QTableWidgetItem(QString("%1%").arg(product->yeasts.at(i).tolerance, 2, 'f', 1, '0'));
85 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 85 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
86 ui->yeastsTable->setItem(i, 7, item); 86 ui->yeastsTable->setItem(i, 7, item);
87 87
88 item = new QTableWidgetItem(QString("%1%").arg(product->yeasts.at(i).y_attenuation, 2, 'f', 1, '0')); 88 item = new QTableWidgetItem(QString("%1%").arg(product->yeasts.at(i).attenuation, 2, 'f', 1, '0'));
89 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 89 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
90 ui->yeastsTable->setItem(i, 8, item); 90 ui->yeastsTable->setItem(i, 8, item);
91 91
92 if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) 92 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
93 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(i).y_amount, 1, 'f', 0, '0')); 93 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(i).amount, 1, 'f', 0, '0'));
94 else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRY || product->yeasts.at(i).y_form == YEAST_FORMS_DRIED) 94 else if (product->yeasts.at(i).form == YEAST_FORMS_DRY || product->yeasts.at(i).form == YEAST_FORMS_DRIED)
95 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(i).y_amount * 1000.0, 3, 'f', 2, '0')); 95 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0'));
96 else 96 else
97 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(i).y_amount * 1000.0, 3, 'f', 2, '0')); 97 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0'));
98 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 98 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
99 ui->yeastsTable->setItem(i, 9, item); 99 ui->yeastsTable->setItem(i, 9, item);
100 100
101 if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) 101 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
102 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(i).y_inventory, 1, 'f', 0, '0')); 102 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(i).inventory, 1, 'f', 0, '0'));
103 else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRY || product->yeasts.at(i).y_form == YEAST_FORMS_DRIED) 103 else if (product->yeasts.at(i).form == YEAST_FORMS_DRY || product->yeasts.at(i).form == YEAST_FORMS_DRIED)
104 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(i).y_inventory * 1000.0, 3, 'f', 2, '0')); 104 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(i).inventory * 1000.0, 3, 'f', 2, '0'));
105 else 105 else
106 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(i).y_inventory * 1000.0, 3, 'f', 2, '0')); 106 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(i).inventory * 1000.0, 3, 'f', 2, '0'));
107 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 107 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
108 if (product->yeasts.at(i).y_inventory < product->yeasts.at(i).y_amount) 108 if (product->yeasts.at(i).inventory < product->yeasts.at(i).amount)
109 item->setForeground(QBrush(QColor(Qt::red))); 109 item->setForeground(QBrush(QColor(Qt::red)));
110 ui->yeastsTable->setItem(i, 10, item); 110 ui->yeastsTable->setItem(i, 10, item);
111 111
112 pWidget = new QWidget(); 112 pWidget = new QWidget();
113 QPushButton* btn_dele = new QPushButton(); 113 QPushButton* btn_dele = new QPushButton();
185 return; // No yeast in product. 185 return; // No yeast in product.
186 186
187 calcViability(); 187 calcViability();
188 188
189 for (int i = 0; i < product->yeasts.size(); i++) { 189 for (int i = 0; i < product->yeasts.size(); i++) {
190 if (product->yeasts.at(i).y_use == YEAST_USE_PRIMARY) { // Primary 190 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY) { // Primary
191 if (product->yeasts.at(i).y_form == YEAST_FORMS_DRY) { 191 if (product->yeasts.at(i).form == YEAST_FORMS_DRY) {
192 /* 192 /*
193 * Dry yeast, build the formule with the yeast parameters. 193 * Dry yeast, build the formule with the yeast parameters.
194 * Based on https://www.lallemandbrewing.com/en/canada/brewers-corner/brewing-tools/pitching-rate-calculator/ 194 * Based on https://www.lallemandbrewing.com/en/canada/brewers-corner/brewing-tools/pitching-rate-calculator/
195 */ 195 */
196 ui->yeastProcedure->setCurrentIndex(2); 196 ui->yeastProcedure->setCurrentIndex(2);
197 ui->lo_gr_hlEdit->setValue(product->yeasts.at(i).y_gr_hl_lo); 197 ui->lo_gr_hlEdit->setValue(product->yeasts.at(i).gr_hl_lo);
198 ui->hi_gr_hlEdit->setValue(product->yeasts.at(i).y_gr_hl_hi); 198 ui->hi_gr_hlEdit->setValue(product->yeasts.at(i).gr_hl_hi);
199 ui->lo_sgEdit->setValue(product->yeasts.at(i).y_sg_lo); 199 ui->lo_sgEdit->setValue(product->yeasts.at(i).sg_lo);
200 ui->hi_sgEdit->setValue(product->yeasts.at(i).y_sg_hi); 200 ui->hi_sgEdit->setValue(product->yeasts.at(i).sg_hi);
201 double og = product->yeasts.at(i).y_sg_lo; 201 double og = product->yeasts.at(i).sg_lo;
202 double f1 = product->yeasts.at(i).y_gr_hl_lo / 100.0; 202 double f1 = product->yeasts.at(i).gr_hl_lo / 100.0;
203 double f2 = round(f1 / 5 * 1000000.0) / 1000000.0; 203 double f2 = round(f1 / 5 * 1000000.0) / 1000000.0;
204 double multiplier = (sg <= og) ? f1 : (f1 + f2 * (sg - og) / 0.008); 204 double multiplier = (sg <= og) ? f1 : (f1 + f2 * (sg - og) / 0.008);
205 qDebug() << " sg:" << sg << "og:" << og << "f1:" << f1 << "f2:" << f2 << "multiplier:" << multiplier; 205 qDebug() << " sg:" << sg << "og:" << og << "f1:" << f1 << "f2:" << f2 << "multiplier:" << multiplier;
206 double yeast_grams = round(volume * multiplier * 100.0) / product->starter_viability; 206 double yeast_grams = round(volume * multiplier * 100.0) / product->starter_viability;
207 double yeast_gr_hl = round((yeast_grams / (volume * 0.01)) * 100.0) / 100.0; 207 double yeast_gr_hl = round((yeast_grams / (volume * 0.01)) * 100.0) / 100.0;
208 double pitch_gr_hl = round(((product->yeasts.at(i).y_amount * 1000.0) / (volume * 0.01)) * 100.0) / 100.0; 208 double pitch_gr_hl = round(((product->yeasts.at(i).amount * 1000.0) / (volume * 0.01)) * 100.0) / 100.0;
209 ui->dry_needShow->setValue(yeast_grams); 209 ui->dry_needShow->setValue(yeast_grams);
210 ui->dry_pitchrateShow->setValue(yeast_gr_hl); 210 ui->dry_pitchrateShow->setValue(yeast_gr_hl);
211 ui->pitch_grShow->setValue(pitch_gr_hl); 211 ui->pitch_grShow->setValue(pitch_gr_hl);
212 ui->pitch_grShow->setStyleSheet((pitch_gr_hl < yeast_gr_hl) ? "background-color: red":""); 212 ui->pitch_grShow->setStyleSheet((pitch_gr_hl < yeast_gr_hl) ? "background-color: red":"");
213 213
222 ui->yeastProcedure->setCurrentIndex(1); 222 ui->yeastProcedure->setCurrentIndex(1);
223 if (product->yeast_pitchrate == 0) { 223 if (product->yeast_pitchrate == 0) {
224 /* 224 /*
225 * No pitchrate yet, do a educated guess .. 225 * No pitchrate yet, do a educated guess ..
226 */ 226 */
227 if (product->yeasts.at(i).y_type == YEAST_TYPES_LAGER) { 227 if (product->yeasts.at(i).type == YEAST_TYPES_LAGER) {
228 product->yeast_pitchrate = 1.5; 228 product->yeast_pitchrate = 1.5;
229 if (sg > 1.060) 229 if (sg > 1.060)
230 product->yeast_pitchrate = 2.0; 230 product->yeast_pitchrate = 2.0;
231 } else if (product->yeasts.at(i).y_type == YEAST_TYPES_KVEIK) { // Real Kveik 231 } else if (product->yeasts.at(i).type == YEAST_TYPES_KVEIK) { // Real Kveik
232 product->yeast_pitchrate = 0.075; 232 product->yeast_pitchrate = 0.075;
233 } else { 233 } else {
234 product->yeast_pitchrate = 0.75; 234 product->yeast_pitchrate = 0.75;
235 if (sg > 1.060) 235 if (sg > 1.060)
236 product->yeast_pitchrate = 1.0; 236 product->yeast_pitchrate = 1.0;
237 } 237 }
238 is_changed(); 238 is_changed();
239 ui->pitchrateEdit->setValue(product->yeast_pitchrate); 239 ui->pitchrateEdit->setValue(product->yeast_pitchrate);
240 } 240 }
241 241
242 initcells = (product->yeasts.at(i).y_cells / 1000000) * product->yeasts.at(i).y_amount * (product->starter_viability / 100.0); 242 initcells = (product->yeasts.at(i).cells / 1000000) * product->yeasts.at(i).amount * (product->starter_viability / 100.0);
243 if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) 243 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
244 initcells = (product->yeasts.at(i).y_cells / 1000000000) * product->yeasts.at(i).y_amount * (product->starter_viability / 100.0); 244 initcells = (product->yeasts.at(i).cells / 1000000000) * product->yeasts.at(i).amount * (product->starter_viability / 100.0);
245 245
246 needed = round(product->yeast_pitchrate * volume * plato * 10.0) / 10.0; 246 needed = round(product->yeast_pitchrate * volume * plato * 10.0) / 10.0;
247 ui->neededShow->setValue(needed); 247 ui->neededShow->setValue(needed);
248 if (needed > initcells) { 248 if (needed > initcells) {
249 maybe_starter = true; 249 maybe_starter = true;
505 { 505 {
506 double vpm = 1.00; 506 double vpm = 1.00;
507 double max = 100; 507 double max = 100;
508 508
509 for (int i = 0; i < product->yeasts.size(); i++) { 509 for (int i = 0; i < product->yeasts.size(); i++) {
510 if (product->yeasts.at(i).y_use == YEAST_USE_PRIMARY) { 510 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY) {
511 if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) { 511 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID) {
512 vpm = 0.80; 512 vpm = 0.80;
513 max = 97; 513 max = 97;
514 if (product->yeasts.at(i).y_laboratory == "White Labs") { // PurePitch 514 if (product->yeasts.at(i).laboratory == "White Labs") { // PurePitch
515 vpm = 0.95; 515 vpm = 0.95;
516 max = 100; 516 max = 100;
517 } 517 }
518 } else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRY) { 518 } else if (product->yeasts.at(i).form == YEAST_FORMS_DRY) {
519 vpm = 0.998; 519 vpm = 0.998;
520 max = 100; 520 max = 100;
521 } else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRIED) { // dried kveik 521 } else if (product->yeasts.at(i).form == YEAST_FORMS_DRIED) { // dried kveik
522 vpm = 0.92; 522 vpm = 0.92;
523 max = 100; 523 max = 100;
524 } else { // Slant, Culture, Frozen, Bottle 524 } else { // Slant, Culture, Frozen, Bottle
525 vpm = 0.99; 525 vpm = 0.99;
526 max = 97; 526 max = 97;
668 Yeasts newy; 668 Yeasts newy;
669 669
670 qDebug() << "Add yeast row"; 670 qDebug() << "Add yeast row";
671 671
672 for (int i = 0; i < product->yeasts.size(); i++) { 672 for (int i = 0; i < product->yeasts.size(); i++) {
673 if (product->yeasts.at(i).y_amount == 0) 673 if (product->yeasts.at(i).amount == 0)
674 return; // Add only one at a time. 674 return; // Add only one at a time.
675 } 675 }
676 676
677 newy.y_name = "Select one"; 677 newy.name = "Select one";
678 newy.y_laboratory = ""; 678 newy.laboratory = "";
679 newy.y_product_id = ""; 679 newy.product_id = "";
680 newy.y_amount = 0; 680 newy.amount = 0;
681 newy.y_type = YEAST_TYPES_ALE; 681 newy.type = YEAST_TYPES_ALE;
682 newy.y_form = YEAST_FORMS_LIQUID; 682 newy.form = YEAST_FORMS_LIQUID;
683 newy.y_min_temperature = 0; 683 newy.min_temperature = 0;
684 newy.y_max_temperature = 0; 684 newy.max_temperature = 0;
685 newy.y_flocculation = 0; 685 newy.flocculation = 0;
686 newy.y_attenuation = 0; 686 newy.attenuation = 0;
687 newy.y_cells = 0; 687 newy.cells = 0;
688 newy.y_tolerance = 0; 688 newy.tolerance = 0;
689 newy.y_inventory = 0; 689 newy.inventory = 0;
690 newy.y_use = YEAST_USE_PRIMARY; 690 newy.use = YEAST_USE_PRIMARY;
691 newy.y_sta1 = false; 691 newy.sta1 = false;
692 newy.y_bacteria = false; 692 newy.bacteria = false;
693 newy.y_harvest_top = false; 693 newy.harvest_top = false;
694 newy.y_harvest_time = 0; 694 newy.harvest_time = 0;
695 newy.y_pitch_temperature = 0; 695 newy.pitch_temperature = 0;
696 newy.y_pofpos = false; 696 newy.pofpos = false;
697 newy.y_zymocide = 0; 697 newy.zymocide = 0;
698 newy.y_gr_hl_lo = 0; 698 newy.gr_hl_lo = 0;
699 newy.y_sg_lo = 0; 699 newy.sg_lo = 0;
700 newy.y_gr_hl_hi = 0; 700 newy.gr_hl_hi = 0;
701 newy.y_sg_hi = 0; 701 newy.sg_hi = 0;
702 newy.y_cost = 0; 702 newy.cost = 0;
703 703
704 product->yeasts.append(newy); 704 product->yeasts.append(newy);
705 emit refreshAll(); 705 emit refreshAll();
706 } 706 }
707 707
713 713
714 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); 714 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
715 int row = pb->objectName().toInt(); 715 int row = pb->objectName().toInt();
716 qDebug() << "Delete yeast row" << row << product->yeasts.size(); 716 qDebug() << "Delete yeast row" << row << product->yeasts.size();
717 717
718 int rc = QMessageBox::warning(this, tr("Delete yeast"), tr("Delete %1").arg(product->yeasts.at(row).y_name), 718 int rc = QMessageBox::warning(this, tr("Delete yeast"), tr("Delete %1").arg(product->yeasts.at(row).name),
719 QMessageBox::Yes | QMessageBox::No, QMessageBox::No); 719 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
720 if (rc == QMessageBox::No) 720 if (rc == QMessageBox::No)
721 return; 721 return;
722 722
723 product->yeasts.removeAt(row); 723 product->yeasts.removeAt(row);
730 { 730 {
731 QTableWidgetItem *item; 731 QTableWidgetItem *item;
732 732
733 qDebug() << "yeast_amount_changed()" << product->yeasts_row << val; 733 qDebug() << "yeast_amount_changed()" << product->yeasts_row << val;
734 734
735 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { 735 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID) {
736 product->yeasts[product->yeasts_row].y_amount = val; 736 product->yeasts[product->yeasts_row].amount = val;
737 item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '0')); 737 item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '0'));
738 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || 738 } else if ((product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY) ||
739 (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) { 739 (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED)) {
740 product->yeasts[product->yeasts_row].y_amount = val / 1000.0; 740 product->yeasts[product->yeasts_row].amount = val / 1000.0;
741 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0')); 741 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0'));
742 } else { 742 } else {
743 product->yeasts[product->yeasts_row].y_amount = val / 1000.0; 743 product->yeasts[product->yeasts_row].amount = val / 1000.0;
744 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0')); 744 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0'));
745 } 745 }
746 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 746 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
747 ui->yeastsTable->setItem(product->yeasts_row, 9, item); 747 ui->yeastsTable->setItem(product->yeasts_row, 9, item);
748 748
755 { 755 {
756 QSqlQuery query; 756 QSqlQuery query;
757 bool instock = yinstockEdit->isChecked(); 757 bool instock = yinstockEdit->isChecked();
758 QString w; 758 QString w;
759 QTableWidgetItem *item; 759 QTableWidgetItem *item;
760 int oldform = product->yeasts.at(product->yeasts_row).y_form; 760 int oldform = product->yeasts.at(product->yeasts_row).form;
761 761
762 if (val < 1) 762 if (val < 1)
763 return; 763 return;
764 764
765 qDebug() << "yeast_select_changed()" << product->yeasts_row << val << instock; 765 qDebug() << "yeast_select_changed()" << product->yeasts_row << val << instock;
767 /* 767 /*
768 * Search the yeast pointed by the index and instock flag. 768 * Search the yeast pointed by the index and instock flag.
769 */ 769 */
770 QString sql = "SELECT name,laboratory,product_id,type,form,min_temperature,max_temperature,flocculation,attenuation," 770 QString sql = "SELECT name,laboratory,product_id,type,form,min_temperature,max_temperature,flocculation,attenuation,"
771 "cells,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide," 771 "cells,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide,"
772 "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost,inventory FROM inventory_yeasts "; 772 "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost,inventory FROM inventoryeasts ";
773 if (instock) 773 if (instock)
774 sql.append("WHERE inventory > 0 "); 774 sql.append("WHERE inventory > 0 ");
775 sql.append("ORDER BY laboratory,product_id,name"); 775 sql.append("ORDER BY laboratory,product_id,name");
776 query.prepare(sql); 776 query.prepare(sql);
777 query.exec(); 777 query.exec();
782 qDebug() << "found" << query.value(0).toString() << query.value(2).toString(); 782 qDebug() << "found" << query.value(0).toString() << query.value(2).toString();
783 783
784 /* 784 /*
785 * Replace the yeast record contents 785 * Replace the yeast record contents
786 */ 786 */
787 product->yeasts[product->yeasts_row].y_name = query.value(0).toString(); 787 product->yeasts[product->yeasts_row].name = query.value(0).toString();
788 product->yeasts[product->yeasts_row].y_laboratory = query.value(1).toString(); 788 product->yeasts[product->yeasts_row].laboratory = query.value(1).toString();
789 product->yeasts[product->yeasts_row].y_product_id = query.value(2).toString(); 789 product->yeasts[product->yeasts_row].product_id = query.value(2).toString();
790 product->yeasts[product->yeasts_row].y_type = query.value(3).toInt(); 790 product->yeasts[product->yeasts_row].type = query.value(3).toInt();
791 product->yeasts[product->yeasts_row].y_form = query.value(4).toInt(); 791 product->yeasts[product->yeasts_row].form = query.value(4).toInt();
792 product->yeasts[product->yeasts_row].y_min_temperature = query.value(5).toDouble(); 792 product->yeasts[product->yeasts_row].min_temperature = query.value(5).toDouble();
793 product->yeasts[product->yeasts_row].y_max_temperature = query.value(6).toDouble(); 793 product->yeasts[product->yeasts_row].max_temperature = query.value(6).toDouble();
794 product->yeasts[product->yeasts_row].y_flocculation = query.value(7).toInt(); 794 product->yeasts[product->yeasts_row].flocculation = query.value(7).toInt();
795 product->yeasts[product->yeasts_row].y_attenuation = query.value(8).toDouble(); 795 product->yeasts[product->yeasts_row].attenuation = query.value(8).toDouble();
796 product->yeasts[product->yeasts_row].y_cells = query.value(9).toDouble(); 796 product->yeasts[product->yeasts_row].cells = query.value(9).toDouble();
797 product->yeasts[product->yeasts_row].y_tolerance = query.value(10).toDouble(); 797 product->yeasts[product->yeasts_row].tolerance = query.value(10).toDouble();
798 product->yeasts[product->yeasts_row].y_sta1 = query.value(11).toInt() ? true:false; 798 product->yeasts[product->yeasts_row].sta1 = query.value(11).toInt() ? true:false;
799 product->yeasts[product->yeasts_row].y_bacteria = query.value(12).toInt() ? true:false; 799 product->yeasts[product->yeasts_row].bacteria = query.value(12).toInt() ? true:false;
800 product->yeasts[product->yeasts_row].y_harvest_top = query.value(13).toInt() ? true:false; 800 product->yeasts[product->yeasts_row].harvest_top = query.value(13).toInt() ? true:false;
801 product->yeasts[product->yeasts_row].y_harvest_time = query.value(14).toInt(); 801 product->yeasts[product->yeasts_row].harvest_time = query.value(14).toInt();
802 product->yeasts[product->yeasts_row].y_pitch_temperature = query.value(15).toDouble(); 802 product->yeasts[product->yeasts_row].pitch_temperature = query.value(15).toDouble();
803 product->yeasts[product->yeasts_row].y_pofpos = query.value(16).toInt() ? true:false; 803 product->yeasts[product->yeasts_row].pofpos = query.value(16).toInt() ? true:false;
804 product->yeasts[product->yeasts_row].y_zymocide = query.value(17).toInt(); 804 product->yeasts[product->yeasts_row].zymocide = query.value(17).toInt();
805 product->yeasts[product->yeasts_row].y_gr_hl_lo = query.value(18).toInt(); 805 product->yeasts[product->yeasts_row].gr_hl_lo = query.value(18).toInt();
806 product->yeasts[product->yeasts_row].y_sg_lo = query.value(19).toDouble(); 806 product->yeasts[product->yeasts_row].sg_lo = query.value(19).toDouble();
807 product->yeasts[product->yeasts_row].y_gr_hl_hi = query.value(20).toInt(); 807 product->yeasts[product->yeasts_row].gr_hl_hi = query.value(20).toInt();
808 product->yeasts[product->yeasts_row].y_sg_hi = query.value(21).toDouble(); 808 product->yeasts[product->yeasts_row].sg_hi = query.value(21).toDouble();
809 product->yeasts[product->yeasts_row].y_cost = query.value(22).toDouble(); 809 product->yeasts[product->yeasts_row].cost = query.value(22).toDouble();
810 product->yeasts[product->yeasts_row].y_inventory = query.value(23).toDouble(); 810 product->yeasts[product->yeasts_row].inventory = query.value(23).toDouble();
811 811
812 /* 812 /*
813 * Update the visible fields 813 * Update the visible fields
814 */ 814 */
815 const QSignalBlocker blocker1(yamountEdit); 815 const QSignalBlocker blocker1(yamountEdit);
816 ynameEdit->setText(product->yeasts.at(product->yeasts_row).y_name); 816 ynameEdit->setText(product->yeasts.at(product->yeasts_row).name);
817 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).y_laboratory); 817 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).laboratory);
818 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).y_product_id); 818 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).product_id);
819 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { 819 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID) {
820 if (oldform != YEAST_FORMS_LIQUID) 820 if (oldform != YEAST_FORMS_LIQUID)
821 product->yeasts[product->yeasts_row].y_amount = 1; 821 product->yeasts[product->yeasts_row].amount = 1;
822 yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount); 822 yamountEdit->setValue(product->yeasts[product->yeasts_row].amount);
823 yamountEdit->setDecimals(0); 823 yamountEdit->setDecimals(0);
824 yamountEdit->setSingleStep(1.0); 824 yamountEdit->setSingleStep(1.0);
825 yamountLabel->setText(tr("Total packs:")); 825 yamountLabel->setText(tr("Total packs:"));
826 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) { 826 } else if ((product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED)) {
827 if (oldform == YEAST_FORMS_LIQUID) 827 if (oldform == YEAST_FORMS_LIQUID)
828 product->yeasts[product->yeasts_row].y_amount = 0.01; 828 product->yeasts[product->yeasts_row].amount = 0.01;
829 yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount * 1000.0); 829 yamountEdit->setValue(product->yeasts[product->yeasts_row].amount * 1000.0);
830 yamountEdit->setDecimals(1); 830 yamountEdit->setDecimals(1);
831 yamountEdit->setSingleStep(0.5); 831 yamountEdit->setSingleStep(0.5);
832 yamountLabel->setText(tr("Amount in gr:")); 832 yamountLabel->setText(tr("Amount in gr:"));
833 } else { 833 } else {
834 if (oldform == YEAST_FORMS_LIQUID) 834 if (oldform == YEAST_FORMS_LIQUID)
835 product->yeasts[product->yeasts_row].y_amount = 0.01; 835 product->yeasts[product->yeasts_row].amount = 0.01;
836 yamountEdit->setValue(product->yeasts[product->yeasts_row].y_amount * 1000.0); 836 yamountEdit->setValue(product->yeasts[product->yeasts_row].amount * 1000.0);
837 yamountEdit->setDecimals(1); 837 yamountEdit->setDecimals(1);
838 yamountEdit->setSingleStep(0.5); 838 yamountEdit->setSingleStep(0.5);
839 yamountLabel->setText(tr("Amount in ml:")); 839 yamountLabel->setText(tr("Amount in ml:"));
840 } 840 }
841 841
842 ui->yeastsTable->setItem(product->yeasts_row, 0, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).y_name)); 842 ui->yeastsTable->setItem(product->yeasts_row, 0, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).name));
843 ui->yeastsTable->setItem(product->yeasts_row, 1, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).y_laboratory)); 843 ui->yeastsTable->setItem(product->yeasts_row, 1, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).laboratory));
844 ui->yeastsTable->setItem(product->yeasts_row, 2, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).y_product_id)); 844 ui->yeastsTable->setItem(product->yeasts_row, 2, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).product_id));
845 845
846 item = new QTableWidgetItem(yeast_forms[product->yeasts.at(product->yeasts_row).y_form]); 846 item = new QTableWidgetItem(yeast_forms[product->yeasts.at(product->yeasts_row).form]);
847 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); 847 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
848 ui->yeastsTable->setItem(product->yeasts_row, 3, item); 848 ui->yeastsTable->setItem(product->yeasts_row, 3, item);
849 849
850 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).y_min_temperature, 2, 'f', 1, '0')); 850 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).min_temperature, 2, 'f', 1, '0'));
851 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 851 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
852 ui->yeastsTable->setItem(product->yeasts_row, 5, item); 852 ui->yeastsTable->setItem(product->yeasts_row, 5, item);
853 853
854 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).y_max_temperature, 2, 'f', 1, '0')); 854 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).max_temperature, 2, 'f', 1, '0'));
855 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 855 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
856 ui->yeastsTable->setItem(product->yeasts_row, 6, item); 856 ui->yeastsTable->setItem(product->yeasts_row, 6, item);
857 857
858 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).y_tolerance, 2, 'f', 1, '0')); 858 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).tolerance, 2, 'f', 1, '0'));
859 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 859 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
860 ui->yeastsTable->setItem(product->yeasts_row, 7, item); 860 ui->yeastsTable->setItem(product->yeasts_row, 7, item);
861 861
862 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).y_attenuation, 2, 'f', 1, '0')); 862 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).attenuation, 2, 'f', 1, '0'));
863 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 863 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
864 ui->yeastsTable->setItem(product->yeasts_row, 8, item); 864 ui->yeastsTable->setItem(product->yeasts_row, 8, item);
865 865
866 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) 866 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID)
867 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(product->yeasts_row).y_amount, 1, 'f', 0, '0')); 867 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(product->yeasts_row).amount, 1, 'f', 0, '0'));
868 else if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY || product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED) 868 else if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY || product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED)
869 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(product->yeasts_row).y_amount * 1000.0, 3, 'f', 2, '0')); 869 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(product->yeasts_row).amount * 1000.0, 3, 'f', 2, '0'));
870 else 870 else
871 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(product->yeasts_row).y_amount * 1000.0, 3, 'f', 2, '0')); 871 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(product->yeasts_row).amount * 1000.0, 3, 'f', 2, '0'));
872 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 872 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
873 ui->yeastsTable->setItem(product->yeasts_row, 9, item); 873 ui->yeastsTable->setItem(product->yeasts_row, 9, item);
874 874
875 //calcYeast(); 875 //calcYeast();
876 is_changed(); 876 is_changed();
884 884
885 qDebug() << "yeast_instock_changed()" << product->yeasts_row << val; 885 qDebug() << "yeast_instock_changed()" << product->yeasts_row << val;
886 886
887 this->yselectEdit->setCurrentIndex(-1); 887 this->yselectEdit->setCurrentIndex(-1);
888 this->yselectEdit->clear(); 888 this->yselectEdit->clear();
889 QString sql = "SELECT name,laboratory,product_id,inventory FROM inventory_yeasts "; 889 QString sql = "SELECT name,laboratory,product_id,inventory FROM inventoryeasts ";
890 if (val) 890 if (val)
891 sql.append("WHERE inventory > 0 "); 891 sql.append("WHERE inventory > 0 ");
892 sql.append("ORDER BY laboratory,product_id,name"); 892 sql.append("ORDER BY laboratory,product_id,name");
893 query.prepare(sql); 893 query.prepare(sql);
894 query.exec(); 894 query.exec();
904 904
905 void EditProduct::yeast_useat_changed(int val) 905 void EditProduct::yeast_useat_changed(int val)
906 { 906 {
907 qDebug() << "yeast_useat_changed()" << product->yeasts_row << val; 907 qDebug() << "yeast_useat_changed()" << product->yeasts_row << val;
908 908
909 product->yeasts[product->yeasts_row].y_use = val; 909 product->yeasts[product->yeasts_row].use = val;
910 QTableWidgetItem *item = new QTableWidgetItem(yeast_use[val]); 910 QTableWidgetItem *item = new QTableWidgetItem(yeast_use[val]);
911 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); 911 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
912 ui->yeastsTable->setItem(product->yeasts_row, 5, item); 912 ui->yeastsTable->setItem(product->yeasts_row, 5, item);
913 is_changed(); 913 is_changed();
914 emit refreshAll(); 914 emit refreshAll();
962 instockLabel->setText(tr("In stock:")); 962 instockLabel->setText(tr("In stock:"));
963 instockLabel->setGeometry(QRect(525,100, 121, 20)); 963 instockLabel->setGeometry(QRect(525,100, 121, 20));
964 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 964 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
965 yamountLabel = new QLabel(dialog); 965 yamountLabel = new QLabel(dialog);
966 yamountLabel->setObjectName(QString::fromUtf8("amountLabel")); 966 yamountLabel->setObjectName(QString::fromUtf8("amountLabel"));
967 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) 967 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID)
968 yamountLabel->setText(tr("Total packs:")); 968 yamountLabel->setText(tr("Total packs:"));
969 else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) 969 else if ((product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED))
970 yamountLabel->setText(tr("Amount in gr:")); 970 yamountLabel->setText(tr("Amount in gr:"));
971 else 971 else
972 yamountLabel->setText(tr("Amount in ml:")); 972 yamountLabel->setText(tr("Amount in ml:"));
973 yamountLabel->setGeometry(QRect(10, 130, 141, 20)); 973 yamountLabel->setGeometry(QRect(10, 130, 141, 20));
974 yamountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 974 yamountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
978 useatLabel->setGeometry(QRect(10, 160, 141, 20)); 978 useatLabel->setGeometry(QRect(10, 160, 141, 20));
979 useatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 979 useatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
980 980
981 ynameEdit = new QLineEdit(dialog); 981 ynameEdit = new QLineEdit(dialog);
982 ynameEdit->setObjectName(QString::fromUtf8("ynameEdit")); 982 ynameEdit->setObjectName(QString::fromUtf8("ynameEdit"));
983 ynameEdit->setText(product->yeasts.at(product->yeasts_row).y_name); 983 ynameEdit->setText(product->yeasts.at(product->yeasts_row).name);
984 ynameEdit->setGeometry(QRect(160, 10, 511, 23)); 984 ynameEdit->setGeometry(QRect(160, 10, 511, 23));
985 ynameEdit->setReadOnly(true); 985 ynameEdit->setReadOnly(true);
986 ylaboratoryEdit = new QLineEdit(dialog); 986 ylaboratoryEdit = new QLineEdit(dialog);
987 ylaboratoryEdit->setObjectName(QString::fromUtf8("ylaboratoryEdit")); 987 ylaboratoryEdit->setObjectName(QString::fromUtf8("ylaboratoryEdit"));
988 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).y_laboratory); 988 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).laboratory);
989 ylaboratoryEdit->setGeometry(QRect(160, 40, 511, 23)); 989 ylaboratoryEdit->setGeometry(QRect(160, 40, 511, 23));
990 ylaboratoryEdit->setReadOnly(true); 990 ylaboratoryEdit->setReadOnly(true);
991 yproduct_idEdit = new QLineEdit(dialog); 991 yproduct_idEdit = new QLineEdit(dialog);
992 yproduct_idEdit->setObjectName(QString::fromUtf8("yproduct_idEdit")); 992 yproduct_idEdit->setObjectName(QString::fromUtf8("yproduct_idEdit"));
993 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).y_product_id); 993 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).product_id);
994 yproduct_idEdit->setGeometry(QRect(160, 70, 511, 23)); 994 yproduct_idEdit->setGeometry(QRect(160, 70, 511, 23));
995 yproduct_idEdit->setReadOnly(true); 995 yproduct_idEdit->setReadOnly(true);
996 yselectEdit = new QComboBox(dialog); 996 yselectEdit = new QComboBox(dialog);
997 yselectEdit->setObjectName(QString::fromUtf8("selectEdit")); 997 yselectEdit->setObjectName(QString::fromUtf8("selectEdit"));
998 yselectEdit->setGeometry(QRect(160,100, 371, 23)); 998 yselectEdit->setGeometry(QRect(160,100, 371, 23));
1004 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit")); 1004 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit"));
1005 yamountEdit->setGeometry(QRect(160, 130, 121, 24)); 1005 yamountEdit->setGeometry(QRect(160, 130, 121, 24));
1006 yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 1006 yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
1007 yamountEdit->setAccelerated(true); 1007 yamountEdit->setAccelerated(true);
1008 yamountEdit->setMaximum(10000.0); 1008 yamountEdit->setMaximum(10000.0);
1009 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) { 1009 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID) {
1010 yamountEdit->setDecimals(0); 1010 yamountEdit->setDecimals(0);
1011 yamountEdit->setSingleStep(1.0); 1011 yamountEdit->setSingleStep(1.0);
1012 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount); 1012 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).amount);
1013 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) { 1013 } else if ((product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED)) {
1014 yamountEdit->setDecimals(1); 1014 yamountEdit->setDecimals(1);
1015 yamountEdit->setSingleStep(0.5); 1015 yamountEdit->setSingleStep(0.5);
1016 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount * 1000.0); 1016 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).amount * 1000.0);
1017 } else { 1017 } else {
1018 yamountEdit->setDecimals(1); 1018 yamountEdit->setDecimals(1);
1019 yamountEdit->setSingleStep(0.5); 1019 yamountEdit->setSingleStep(0.5);
1020 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount * 1000.0); 1020 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).amount * 1000.0);
1021 } 1021 }
1022 yamountEdit->setMaximum(1000000000.0); 1022 yamountEdit->setMaximum(1000000000.0);
1023 useatEdit = new QComboBox(dialog); 1023 useatEdit = new QComboBox(dialog);
1024 useatEdit->setObjectName(QString::fromUtf8("useatEdit")); 1024 useatEdit->setObjectName(QString::fromUtf8("useatEdit"));
1025 useatEdit->setGeometry(QRect(160, 160, 161, 23)); 1025 useatEdit->setGeometry(QRect(160, 160, 161, 23));
1026 useatEdit->addItem(tr("Primary")); 1026 useatEdit->addItem(tr("Primary"));
1027 useatEdit->addItem(tr("Secondary")); 1027 useatEdit->addItem(tr("Secondary"));
1028 useatEdit->addItem(tr("Tertiary")); 1028 useatEdit->addItem(tr("Tertiary"));
1029 useatEdit->addItem(tr("Bottle")); 1029 useatEdit->addItem(tr("Bottle"));
1030 useatEdit->setCurrentIndex(product->yeasts.at(product->yeasts_row).y_use); 1030 useatEdit->setCurrentIndex(product->yeasts.at(product->yeasts_row).use);
1031 1031
1032 yeast_instock_changed(true); 1032 yeast_instock_changed(true);
1033 1033
1034 connect(yselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_select_changed); 1034 connect(yselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_select_changed);
1035 connect(yamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::yeast_amount_changed); 1035 connect(yamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::yeast_amount_changed);
1063 1063
1064 if (product->yeasts.size() == 0) 1064 if (product->yeasts.size() == 0)
1065 return; 1065 return;
1066 1066
1067 for (int i = 0; i < product->yeasts.size(); i++) { 1067 for (int i = 0; i < product->yeasts.size(); i++) {
1068 if (product->yeasts.at(i).y_form == YEAST_FORMS_DRY) { // Only adjust dry yeast 1068 if (product->yeasts.at(i).form == YEAST_FORMS_DRY) { // Only adjust dry yeast
1069 amount = product->yeasts.at(i).y_amount * factor; 1069 amount = product->yeasts.at(i).amount * factor;
1070 product->yeasts[i].y_amount = amount; 1070 product->yeasts[i].amount = amount;
1071 } 1071 }
1072 } 1072 }
1073 } 1073 }
1074 1074

mercurial