src/EditProductTab3.cpp

Thu, 18 Aug 2022 19:47:28 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 19:47:28 +0200
changeset 399
4b9aaf86094e
parent 397
877420a13815
child 412
5fe775f036fa
permissions
-rw-r--r--

Prompts corrections and updated translations. Minor layout changes so the prompts will fit.

175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditProduct.cpp is part of bmsapp.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Tab 3, fermentables
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the hope that it will be useful,
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 bool EditProduct::ferment_sort_test(const Fermentables &D1, const Fermentables &D2)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
24 if (D1.added > D2.added)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 return false;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
26 if (D1.added < D2.added)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 return true;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
28 return (D1.amount >= D2.amount) && (D1.color < D2.color);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 void EditProduct::to100Fermentables(int row)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
34 if (product->fermentables.at(row).adjust_to_total_100) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 QWidget *pWidget = new QWidget();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 QLabel *label = new QLabel;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 label->setPixmap(QPixmap(":icons/silk/tick.png"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 QHBoxLayout *pLayout = new QHBoxLayout(pWidget);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 pLayout->addWidget(label);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 pLayout->setAlignment(Qt::AlignCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 pLayout->setContentsMargins(0, 0, 0, 0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 pWidget->setLayout(pLayout);
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
43 ui->fermentablesTable->setCellWidget(row, 10, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 } else {
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
45 ui->fermentablesTable->removeCellWidget(row, 10);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
50 bool EditProduct::block_fermentable(int stage, int added)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
51 {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
52 if (stage > PROD_STAGE_PACKAGE)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
53 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
54 if (stage > PROD_STAGE_TERTIARY && added < FERMENTABLE_ADDED_BOTTLE)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
55 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
56 if (stage > PROD_STAGE_PRIMARY && added < FERMENTABLE_ADDED_LAGERING)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
57 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
58 if (stage > PROD_STAGE_BREW && added < FERMENTABLE_ADDED_FERMENTATION)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
59 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
60 return false;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
61 }
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
62
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
63
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 void EditProduct::refreshFermentables()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 QWidget* pWidget;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 QHBoxLayout* pLayout;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 qDebug() << "refreshFermentables" << product->fermentables.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 std::sort(product->fermentables.begin(), product->fermentables.end(), ferment_sort_test);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 const QStringList labels({tr("Supplier"), tr("Fermentable"), tr("EBC"), tr("Type"), tr("Graintype"), tr("When"), tr("Yield"),
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
75 tr("Amount"), tr("Stock"), tr("Procent"), tr("100%"), tr("Delete"), tr("Edit") });
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
76 ui->fermentablesTable->setColumnCount(13);
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
77 ui->fermentablesTable->setColumnWidth(0, 130); /* Supplier */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
78 ui->fermentablesTable->setColumnWidth(1, 210); /* Fermentable */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
79 ui->fermentablesTable->setColumnWidth(2, 45); /* Color */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 ui->fermentablesTable->setColumnWidth(3, 75); /* Type */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 ui->fermentablesTable->setColumnWidth(4, 75); /* Graintype */
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
82 ui->fermentablesTable->setColumnWidth(5, 77); /* Added */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
83 ui->fermentablesTable->setColumnWidth(6, 55); /* Yield */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
84 ui->fermentablesTable->setColumnWidth(7, 80); /* Amount */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
85 ui->fermentablesTable->setColumnWidth(8, 80); /* Stock */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
86 ui->fermentablesTable->setColumnWidth(9, 55); /* Procent */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
87 ui->fermentablesTable->setColumnWidth(10, 50); /* 100% */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
88 ui->fermentablesTable->setColumnWidth(11, 80); /* Delete */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
89 ui->fermentablesTable->setColumnWidth(12, 80); /* Edit */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 ui->fermentablesTable->setHorizontalHeaderLabels(labels);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 ui->fermentablesTable->verticalHeader()->hide();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 ui->fermentablesTable->setRowCount(product->fermentables.size());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 for (int i = 0; i < product->fermentables.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
96 ui->fermentablesTable->setItem(i, 0, new QTableWidgetItem(product->fermentables.at(i).supplier));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
97 ui->fermentablesTable->setItem(i, 1, new QTableWidgetItem(product->fermentables.at(i).name));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
99 w = QString("%1").arg(product->fermentables.at(i).color, 1, 'f', 0, '0');
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 item = new QTableWidgetItem(w);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 ui->fermentablesTable->setItem(i, 2, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
104 item = new QTableWidgetItem(QCoreApplication::translate("FermentableType", g_fermentable_types[product->fermentables.at(i).type]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 ui->fermentablesTable->setItem(i, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
108 item = new QTableWidgetItem(QCoreApplication::translate("FermentableGraintype", g_fermentable_graintypes[product->fermentables.at(i).graintype]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 ui->fermentablesTable->setItem(i, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
112 item = new QTableWidgetItem(QCoreApplication::translate("FermentableAdded", g_fermentable_added[product->fermentables.at(i).added]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 ui->fermentablesTable->setItem(i, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
116 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(i).yield, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 ui->fermentablesTable->setItem(i, 6, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
120 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).amount, 4, 'f', 3, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 ui->fermentablesTable->setItem(i, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
124 if (block_fermentable(product->stage, product->fermentables.at(i).added)) {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
125 item = new QTableWidgetItem(QString(""));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
126 } else {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
127 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).inventory, 4, 'f', 3, '0'));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
128 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
129 if (product->fermentables.at(i).inventory < product->fermentables.at(i).amount)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
130 item->setForeground(QBrush(QColor(Qt::red)));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
131 }
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
132 ui->fermentablesTable->setItem(i, 8, item);
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
133
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
134 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
135 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(i).percentage, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 item = new QTableWidgetItem(QString("")); // Blank for bottling and kegging.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
140 ui->fermentablesTable->setItem(i, 9, item);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 to100Fermentables(i);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
144 /* Add the Delete and Edit row buttons if allowed. */
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
145 if (product->fermentables.at(i).added >= FERMENTABLE_ADDED_BOTTLE) {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
146 item = new QTableWidgetItem("");
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
147 item->setToolTip(tr("Edit this from the package tab"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
148 ui->fermentablesTable->setItem(i, 11, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
149 item = new QTableWidgetItem("");
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
150 item->setToolTip(tr("Edit this from the package tab"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
151 ui->fermentablesTable->setItem(i, 12, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
152 } else if (block_fermentable(product->stage, product->fermentables.at(i).added)) {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
153 item = new QTableWidgetItem("");
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
154 item->setToolTip(tr("Fermentable already used"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
155 ui->fermentablesTable->setItem(i, 11, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
156 item = new QTableWidgetItem("");
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
157 item->setToolTip(tr("Fermentable already used"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
158 ui->fermentablesTable->setItem(i, 12, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
159 } else {
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
160 pWidget = new QWidget();
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
161 QPushButton* btn_dele = new QPushButton();
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
162 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
163 btn_dele->setText(tr("Delete"));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
164 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteFermentRow_clicked()));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
165 pLayout = new QHBoxLayout(pWidget);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
166 pLayout->addWidget(btn_dele);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
167 pLayout->setContentsMargins(5, 0, 5, 0);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
168 pWidget->setLayout(pLayout);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
169 ui->fermentablesTable->setCellWidget(i, 11, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
171 pWidget = new QWidget();
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
172 QPushButton* btn_edit = new QPushButton();
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
173 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
174 btn_edit->setText(tr("Edit"));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
175 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editFermentRow_clicked()));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
176 pLayout = new QHBoxLayout(pWidget);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
177 pLayout->addWidget(btn_edit);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
178 pLayout->setContentsMargins(5, 0, 5, 0);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
179 pWidget->setLayout(pLayout);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
180 ui->fermentablesTable->setCellWidget(i, 12, pWidget);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
181 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 void EditProduct::calcFermentables()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 int i;
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
189 double psugar = 0, pcara = 0, d, s = 0, x, cw, color;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 double vol = 0; // Volume sugars after boil
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 double addedS = 0; // Added sugars after boil
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 double addedmass = 0; // Added mass after boil
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 double mvol = 0; // Mash volume
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 double lintner = 0; // Total product lintner
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 double sugarsf = 0; // fermentable sugars mash + boil
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 double sugarsm = 0; // fermentable sugars in mash
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 double sugardensity = 1.611; // kg/l in solution
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 double mashtime = 0; // Total mash time
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 double mashtemp = 0; // Average mash temperature
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 double mashinfuse = 0; // Mash infuse amount
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 double colort = 0; // Colors srm * vol totals
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 double colorh = 0; // Colors ebc * vol * kt
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 double colorn = 0; // Colors ebc * pt * pct
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
204 double bv = 0.925; // Beer loss efficiency
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
205 double sr = 0.95; // Mash and sparge efficiency
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 qDebug() << "calcFermentables()";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 * Get average mashtemp and mashtime from the Mash schedule.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 * It is possible that the schedule is not (yet) present.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 if (product->mashs.size() > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 for (i = 0; i < product->mashs.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 if (product->mashs.at(i).step_type == 0) // Infusion
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 mashinfuse += product->mashs.at(i).step_infuse_amount;
390
2a69be28a925 Fixed calculation of estimated fg.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
217 if (product->mashs.at(i).step_temp <= 75 && product->mashs.at(i).step_temp >= 60) { // Ignore mashout and low temperatures.
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
218 double timem = product->mashs.at(i).step_time;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
219 if (i > 0)
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
220 timem += product->mashs.at(i).ramp_time;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
221 mashtime += timem;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
222 mashtemp += timem * product->mashs.at(i).step_temp;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 mashtemp = mashtemp / mashtime;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 mvol = mashinfuse;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 qDebug() << " mash time" << mashtime << "temp" << mashtemp << "infuse" << mashinfuse;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 qDebug() << " no mash schedule";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 const QSignalBlocker blocker1(ui->est_ogEdit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 const QSignalBlocker blocker2(ui->est_og2Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 if (product->fermentables.size() < 1) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 qDebug() << " no fermentables, return.";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 product->est_og = 0.980;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 ui->est_ogEdit->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 ui->est_og2Edit->setValue(0.980);
181
14a1f7bca79b Added missing est_og3 database field load and save. Added all extra fields in update and insert product. Renamed est_og3Edit on tab 3 to est_og4Edit because est_og3Edit is reserved for the brewday tab.
Michiel Broek <mbroek@mbse.eu>
parents: 177
diff changeset
240 ui->est_og4Edit->setValue(0.980);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 ui->est_ogShow->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 product->est_color = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 ui->est_colorEdit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(0));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 ui->est_color2Edit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(0));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 ui->est_colorShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 ui->perc_mashShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 ui->perc_sugarsShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 ui->perc_caraShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 ui->lintnerShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 product->est_fg = 0.980;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 ui->est_fgEdit->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 ui->est_fg3Edit->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 ui->est_fgShow->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 ui->est_abvEdit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 ui->est_abv2Edit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 ui->est_abvShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 product->est_abv = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 ui->calEdit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 product->mashs_kg = 0;
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
262 ui->mash_kgEdit->setValue(0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 qDebug() << " adjust to 100" << product->fermentables_use100;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
267 product->fermentables_ok = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 product->mashs_kg = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
270 if (product->fermentables.at(i).type == FERMENTABLE_TYPE_SUGAR && product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
271 psugar += product->fermentables.at(i).percentage;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
272 if (product->fermentables.at(i).graintype == FERMENTABLE_GRAINTYPE_CRYSTAL && product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
273 pcara += product->fermentables.at(i).percentage;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
274 d = product->fermentables.at(i).amount * (product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
275 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH) {
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
276 if (mvol > 0) { // If mash volume is known
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
277 mvol += product->fermentables.at(i).amount * product->fermentables.at(i).moisture / 100;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 s += d;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 }
184
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
280 d = product->efficiency / 100 * d;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281 sugarsm += d;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
282 product->mashs_kg += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
284 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH || product->fermentables.at(i).added == FERMENTABLE_ADDED_BOIL)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 sugarsf += d;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
286 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_FERMENTATION || product->fermentables.at(i).added == FERMENTABLE_ADDED_LAGERING) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
287 x = (product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
288 addedS += product->fermentables.at(i).amount * x;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
289 addedmass += product->fermentables.at(i).amount;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
290 vol += (x * sugardensity + (1 - x) * 1) * product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
292 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH &&
369
09d3d8d18f97 Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents: 363
diff changeset
293 (product->fermentables.at(i).type == FERMENTABLE_TYPE_GRAIN || product->fermentables.at(i).type == FERMENTABLE_TYPE_ADJUCT)) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
294 lintner += product->fermentables.at(i).diastatic_power * product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
296 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
297 colort += product->fermentables.at(i).amount * Utils::ebc_to_srm(product->fermentables.at(i).color);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
298 colorh += product->fermentables.at(i).amount * product->fermentables.at(i).color * Utils::get_kt(product->fermentables.at(i).color);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
299 colorn += (product->fermentables.at(i).percentage / 100) * product->fermentables.at(i).color; // For 8.6 Pt wort.
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 }
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
301 /* Check supplies */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
302 if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->fermentables.at(i).added <= FERMENTABLE_ADDED_BOIL)) ||
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
303 ((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_FERMENTATION)) ||
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
304 ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_LAGERING)) ||
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
305 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE)) ||
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
306 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_KEGS))) &&
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
307 product->fermentables.at(i).inventory < product->fermentables.at(i).amount) {
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
308 product->fermentables_ok = false;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
309 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 }
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
311 qDebug() << " supplies" << product->fermentables_ok;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 qDebug() << " colort" << colort << "colorh" << colorh << "colorn" << colorn;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 qDebug() << " psugar" << psugar << "pcara" << pcara << "mvol" << mvol;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 qDebug() << " sugarsf" << sugarsf << "sugarsm" << sugarsm;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315
182
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
316 double v = s / sugardensity + mvol;
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
317 s = 1000 * s / (v * 10); //deg. Plato
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
318 product->est_mash_sg = Utils::plato_to_sg(s);
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
319 ui->brew_mashsgShow->setValue(product->est_mash_sg);
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
320
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
321 /* Estimate total recipe OG */
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
322 product->est_og = Utils::estimate_sg(sugarsf + addedS, product->batch_size);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
323 qDebug() << " OG" << ui->est_ogEdit->value() << product->est_og;
396
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
324 if (product->stage > PROD_STAGE_BREW) {
399
4b9aaf86094e Prompts corrections and updated translations. Minor layout changes so the prompts will fit.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
325 ui->est_ogLabel->setText(tr("Final OG:"));
396
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
326 ui->est_ogEdit->setValue(product->og);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
327 ui->est_ogShow->setValue(product->og);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
328 } else {
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
329 ui->est_ogEdit->setValue(product->est_og);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
330 ui->est_ogShow->setValue(product->est_og);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
331 }
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
332 ui->est_og2Edit->setValue(product->est_og);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
333 ui->est_og4Edit->setValue(product->est_og);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
335 /* Estimate SG in kettle after boil */
184
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
336 product->est_og3 = Utils::estimate_sg(sugarsf, product->batch_size);
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
337 ui->brew_aboilsgShow->setValue(product->est_og3);
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
338
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
339 /* Estimate SG in kettle before boil */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 product->preboil_sg = Utils::estimate_sg(sugarsm, product->boil_size);
184
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
341 ui->brew_preboilsgShow->setValue(product->preboil_sg);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 qDebug() << " preboil SG" << product->preboil_sg;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 /*
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
345 * Recalculate volumes
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
346 */
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
347 double aboil_volume = product->batch_size;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
348 if (product->brew_aboil_volume > 0)
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
349 aboil_volume = product->brew_aboil_volume / 1.04; // Volume @ 20 degrees.
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
350 if (product->brew_fermenter_tcloss == 0) {
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
351 product->brew_fermenter_tcloss = product->eq_trub_chiller_loss;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
352 ui->brew_trublossEdit->setValue(product->brew_fermenter_tcloss);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
353 }
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
354 product->brew_fermenter_volume = aboil_volume - product->brew_fermenter_tcloss + product->brew_fermenter_extrawater;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
355 ui->brew_tofermentEdit->setValue(product->brew_fermenter_volume);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
356 /* Calculate SG in fermenter */
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
357 double ogx = product->brew_aboil_sg;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
358 if (ogx < 1.002)
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
359 ogx = product->est_og3;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
360 double topw = product->brew_fermenter_extrawater;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
361
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
362 if (product->brew_fermenter_volume > 0) {
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
363 double sug = Utils::sg_to_plato(ogx) * product->brew_fermenter_volume * ogx / 100; //kg of sugar in
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
364 sug += addedS; //kg
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
365
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
366 if ((product->brew_fermenter_volume * ogx + addedmass) > 0) {
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
367 double pt = 100 * sug / (product->brew_fermenter_volume * ogx + addedmass + topw);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
368 product->og = product->brew_fermenter_sg = round(Utils::plato_to_sg(pt) * 10000) / 10000.0;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
369 ui->brew_fermentsgShow->setValue(product->brew_fermenter_sg);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
370 // color
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
371 if (product->color_method == 4) { // Naudts
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
372 product->brew_fermenter_color = round(((pt / 8.6) * colorn) + (product->boil_time / 60));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
373 } else if (product->color_method == 3) { // Hans Halberstadt
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
374 product->brew_fermenter_color = round((4.46 * bv * sr) / (aboil_volume + topw) * colorh);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
375 } else {
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
376 cw = colort / (aboil_volume + topw) * 8.34436;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
377 product->brew_fermenter_color = Utils::kw_to_ebc(product->color_method, cw);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
378 }
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
379 ui->brew_fermentcolorShow->setValue(product->brew_fermenter_color);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
380 ui->brew_fermentcolorShow->setStyleSheet(Utils::ebc_to_style(product->brew_fermenter_color));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
381 }
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
382 } else {
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
383 // Negative volume
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
384 product->brew_fermenter_sg = product->brew_fermenter_color = 0;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
385 ui->brew_fermentsgShow->setValue(0);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
386 ui->brew_fermentcolorShow->setStyleSheet(0);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
387 ui->brew_fermentcolorShow->setValue(0);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
388 }
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
389
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
390 /*
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 * Color of the wort
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 if (product->color_method == 4) { // Naudts
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
394 color = round(((Utils::sg_to_plato(product->est_og) / 8.6) * colorn) + (product->boil_time / 60));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 } else if (product->color_method == 3) { // Hans Halberstadt
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 color = round((4.46 * bv * sr) / product->batch_size * colorh);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 } else {
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
398 cw = colort / product->batch_size * 8.34436;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 color = Utils::kw_to_ebc(product->color_method, cw);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 //qDebug() << " oud EBC" << color << "new EBC" << Utils::kw_to_newebc(product->color_method, cw) << "SRM" << Utils::kw_to_srm(product->color_method, cw);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 qDebug() << " color" << ui->est_colorEdit->value() << color << product->est_color;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 product->est_color = color;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 ui->est_color2Edit->setValue(color);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color));
397
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
406 if (product->stage > PROD_STAGE_BREW) {
399
4b9aaf86094e Prompts corrections and updated translations. Minor layout changes so the prompts will fit.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
407 ui->est_colorLabel->setText(tr("Final EBC:"));
397
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
408 ui->est_colorEdit->setValue(product->brew_fermenter_color);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
409 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(product->brew_fermenter_color));
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
410 ui->est_colorShow->setValue(product->brew_fermenter_color);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
411 } else {
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
412 ui->est_colorEdit->setValue(color);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
413 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color));
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
414 ui->est_colorShow->setValue(color);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
415 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
416
363
313cdeb309d2 Fixed overloaded perc_mashShow when the value is above the maxiumum.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
417 if (round(product->mashs_kg / product->eq_mash_max * 100) > 120)
313cdeb309d2 Fixed overloaded perc_mashShow when the value is above the maxiumum.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
418 ui->perc_mashShow->setValue(120);
313cdeb309d2 Fixed overloaded perc_mashShow when the value is above the maxiumum.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
419 else
313cdeb309d2 Fixed overloaded perc_mashShow when the value is above the maxiumum.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
420 ui->perc_mashShow->setValue(round(product->mashs_kg / product->eq_mash_max * 100));
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
421 ui->mash_kgEdit->setValue(product->mashs_kg);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 ui->perc_sugarsShow->setValue(round(psugar));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 ui->perc_caraShow->setValue(round(pcara));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424 if (product->mashs_kg > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425 qDebug() << " lintner" << lintner << " mashkg" << product->mashs_kg << "final" << round(lintner / product->mashs_kg);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426 ui->lintnerShow->setValue(round(lintner / product->mashs_kg));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428 qDebug() << " lintner N/A";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429 ui->lintnerShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433 * Calculate the apparant attenuation.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435 double svg = 0;
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
436 double initcells = 0;
225
448e4187cada Implemented the tasting tab. On the generic tab, show the ingredients check or the read only prompt on the same place depending on the product stage. Fixed the yeasts ingredients in stock check. Reordered the tab order of all edit fields. It looks like this module is ready and needs testing.
Michiel Broek <mbroek@mbse.eu>
parents: 224
diff changeset
437 product->yeasts_ok = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 if (product->yeasts.size() > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439 for (i = 0; i < product->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
440 if (product->yeasts.at(i).use == 0) { // Used in primary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
441 if (product->yeasts.at(i).attenuation > svg)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
442 svg = product->yeasts.at(i).attenuation; // Take the highest if multiple yeasts.
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 }
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
444 if (product->yeasts.at(i).form == 0)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
445 initcells += (product->yeasts.at(i).cells / 1000000000) * product->yeasts.at(i).amount * (product->starter_viability / 100);
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
446 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
447 initcells += (product->yeasts.at(i).cells / 1000000) * product->yeasts.at(i).amount * (product->starter_viability / 100);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 // TODO: brett or others in secondary.
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
449 if ((((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->yeasts.at(i).use == 0)) || // Primary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
450 ((product->inventory_reduced <= PROD_STAGE_SECONDARY) && (product->yeasts.at(i).use == 1)) || // Secondary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
451 ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->yeasts.at(i).use == 2)) || // Tertiary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
452 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->yeasts.at(i).use == 3))) && // Bottle
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
453 (product->yeasts.at(i).inventory < product->yeasts.at(i).amount)) {
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
454 product->yeasts_ok = false;
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
455 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 }
397
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
457 qDebug() << " est SVG" << svg;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 if (svg == 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 svg = 77.0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 ui->est_svgEdit->setValue(svg);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463 if (product->mashs_kg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0)
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
464 product->est_fg = Utils::estimate_fg(psugar, pcara, mashinfuse / product->mashs_kg, mashtime, mashtemp, svg, product->est_og);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 else
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
466 product->est_fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, product->est_og);
397
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
467 qDebug() << " est FG" << ui->est_fgEdit->value() << product->est_fg;
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
468 product->est_abv = Utils::abvol(product->est_og, product->est_fg);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
469 qDebug() << " est ABV" << ui->est_abvEdit->value() << product->est_abv;
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
470
396
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
471 if (product->stage > PROD_STAGE_TERTIARY) {
399
4b9aaf86094e Prompts corrections and updated translations. Minor layout changes so the prompts will fit.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
472 ui->est_fgLabel->setText(tr("Final FG:"));
396
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
473 ui->est_fgEdit->setValue(product->fg);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
474 ui->est_fgShow->setValue(product->fg);
399
4b9aaf86094e Prompts corrections and updated translations. Minor layout changes so the prompts will fit.
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
475 ui->est_abvLabel->setText(tr("Final ABV:"));
397
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
476 double abv = Utils::abvol(product->og, product->fg);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
477 ui->est_abvEdit->setValue(abv);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
478 ui->est_abvShow->setValue(abv);
396
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
479 } else {
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
480 ui->est_fgEdit->setValue(product->est_fg);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
481 ui->est_fgShow->setValue(product->est_fg);
397
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
482 ui->est_abvEdit->setValue(product->est_abv);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
483 ui->est_abvShow->setValue(product->est_abv);
396
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
484 }
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
485 ui->est_fg3Edit->setValue(product->est_fg);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
486 ui->est_abv2Edit->setValue(product->est_abv);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489 * Calculate kilocalories/liter. Formula from brouwhulp.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490 * Take the alcohol and sugar parts and then combine.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491 */
397
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
492 double alc, sug;
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
493 if (product->stage > PROD_STAGE_TERTIARY) {
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
494 alc = 1881.22 * product->fg * (product->og - product->fg) / (1.775 - product->og);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
495 sug = 3550 * product->fg * (0.1808 * product->og + 0.8192 * product->fg - 1.0004);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
496 } else {
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
497 alc = 1881.22 * product->est_fg * (product->est_og - product->est_fg) / (1.775 - product->est_og);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
498 sug = 3550 * product->est_fg * (0.1808 * product->est_og + 0.8192 * product->est_fg - 1.0004);
877420a13815 Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.
Michiel Broek <mbroek@mbse.eu>
parents: 396
diff changeset
499 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500 ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296)));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 void EditProduct::calcFermentablesFromOG(double og)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 qDebug() << "calcFermentablesFromOG" << og;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 int i;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 double totmass = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 double tot = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 double d, amount;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 double efficiency = product->efficiency;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 double sug = Utils::sg_to_plato(og) * product->batch_size * og / 100.0; // total amount of sugars in kg.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
516 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
517 d = product->fermentables.at(i).percentage / 100.0 *
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
518 (product->fermentables.at(i).yield / 100.0) *
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
519 (1 - product->fermentables.at(i).moisture / 100.0);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
520 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521 d = efficiency / 100.0 * d;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522 tot += d;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525 if (tot)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 totmass = round((sug / tot) * 1000.0) / 1000.0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 if (totmass) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
530 amount = round(product->fermentables.at(i).percentage * 10.0 * totmass) / 1000.0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
531 product->fermentables[i].amount = amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 void EditProduct::ferment_perc_mash_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538 {
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
539 if (value < 90) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 ui->perc_mashShow->setStyleSheet(bar_green);
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
541 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
542 double s1 = 90.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
543 if (value < 100) {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
544 ui->perc_mashShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
545 "stop: 0 green, stop: %1 green, stop: %2 orange, stop: 1 orange"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
546 ");}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
547 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
548 double s2 = 100.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
549 ui->perc_mashShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
550 "stop: 0 green, stop: %1 green, stop: %2 orange, stop: %3 orange, stop: %4 red, stop: 1 red"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
551 ");}").arg(s1 - 0.00003).arg(s1 - 0.00002).arg(s2 - 0.00001).arg(s2));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
552 }
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
553 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557 void EditProduct::ferment_perc_sugars_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 if (value < 20)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 ui->perc_sugarsShow->setStyleSheet(bar_green);
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
561 else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
562 double s1 = 20.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
563 ui->perc_sugarsShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
564 "stop: 0 green, stop: %1 green, stop: %2 red, stop: 1 red);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
565 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 void EditProduct::ferment_perc_cara_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 if (value < 25)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 ui->perc_caraShow->setStyleSheet(bar_green);
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
573 else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
574 double s1 = 25.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
575 ui->perc_caraShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
576 "stop: 0 green, stop: %1 green, stop: %2 red, stop: 1 red);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
577 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
578 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 void EditProduct::ferment_lintner_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 {
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
583 /*
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
584 * Calculate the color stop positions
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
585 */
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
586 if (value < 30) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 ui->lintnerShow->setStyleSheet(bar_red);
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
588 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
589 double s1 = 30.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
590 if (value < 40) {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
591 ui->lintnerShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
592 "stop: 0 red, stop: %1 red, stop: %2 orange, stop: 1 orange);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
593 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
594 double s2 = 40.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
595 ui->lintnerShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
596 "stop: 0 red, stop: %1 red, stop: %2 orange, stop: %3 orange, stop: %4 green, stop: 1 green"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
597 ");}").arg(s1 - 0.00003).arg(s1 - 0.00002).arg(s2 - 0.00001).arg(s2));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
598 }
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
599 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 void EditProduct::addFermentRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 Fermentables newf;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 qDebug() << "Add fermentable row";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
610 if (product->fermentables.at(i).amount == 0 && product->fermentables.at(i).color == 0)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 return; // Add only one at a time.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
614 newf.name = "Select one";
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
615 newf.origin = "";
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
616 newf.supplier = "";
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
617 newf.amount = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
618 newf.cost = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
619 newf.type = FERMENTABLE_TYPE_GRAIN;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
620 newf.yield = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
621 newf.color = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
622 newf.coarse_fine_diff = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
623 newf.moisture = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
624 newf.diastatic_power = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
625 newf.protein = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
626 newf.dissolved_protein = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
627 newf.max_in_batch = 100;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
628 newf.graintype = FERMENTABLE_GRAINTYPE_BASE;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
629 newf.added = FERMENTABLE_ADDED_MASH;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
630 newf.recommend_mash = true;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
631 newf.add_after_boil = false;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
632 newf.adjust_to_total_100 = false;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
633 newf.percentage = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
634 newf.di_ph = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
635 newf.acid_to_ph_57 = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
637 product->fermentables.append(newf);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
641
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 void EditProduct::deleteFermentRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 if (product->locked)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 int row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 qDebug() << "Delete fermentable row" << row << product->fermentables.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 if (product->fermentables.size() < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
654 int rc = QMessageBox::warning(this, tr("Delete fermentable"), tr("Delete %1").arg(product->fermentables.at(row).name),
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656 if (rc == QMessageBox::No)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
658
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 product->fermentables.removeAt(row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662 * Recalculate the percentages on the rows left.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 double total = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
666 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
667 total += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
669 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
670 product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
671
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
672 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
676
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
677 void EditProduct::ferment_amount_changed(double val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
678 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
679 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
680 double total = 0, perc;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
681
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
682 if (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
684
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
685 qDebug() << "ferment_amount_changed()" << product->fermentables_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
687 product->fermentables[product->fermentables_row].amount = val;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688 item = new QTableWidgetItem(QString("%1 Kg").arg(val, 4, 'f', 3, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690 ui->fermentablesTable->setItem(product->fermentables_row, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
693 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
694 total += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 * Recalculate the percentages
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
699 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
700 perc = product->fermentables.at(i).amount / total * 100;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
701 product->fermentables[i].percentage = perc;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 item = new QTableWidgetItem(QString("%1%").arg(perc, 2, 'f', 1, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 ui->fermentablesTable->setItem(i, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 if (i == product->fermentables_row)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706 this->pctEdit->setValue(perc);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
709 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
711
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
713 void EditProduct::ferment_pct_changed(double val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
714 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
716 double total = 0, row100 = -1;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
717
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718 if (! product->fermentables_use100)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 qDebug() << "ferment_pct_changed()" << product->fermentables_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723 * Since we have arrived here, adjust_to_100 is active and
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
724 * this is not the entry to be adjusted to 100.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
725 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
726 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
727 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
728 total += product->fermentables.at(i).amount;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
729 if (product->fermentables.at(i).adjust_to_total_100)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
730 row100 = i;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
731 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
732 double oldperc = product->fermentables.at(product->fermentables_row).percentage;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 double diffp = val - oldperc;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734 double diffw = (diffp / 100) * total;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735 qDebug() << "row100" << row100 << "total" << total << "diff kg" << diffw << "diff %" << diffp;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
737 product->fermentables[product->fermentables_row].percentage += diffp;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
738 product->fermentables[product->fermentables_row].amount += diffw;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
739 product->fermentables[row100].percentage -= diffp;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
740 product->fermentables[row100].amount -= diffw;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
742 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables[product->fermentables_row].amount, 4, 'f', 3, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 ui->fermentablesTable->setItem(product->fermentables_row, 7, item);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
745 this->famountEdit->setValue(product->fermentables[product->fermentables_row].amount);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
747 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables[product->fermentables_row].percentage, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
749 ui->fermentablesTable->setItem(product->fermentables_row, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
751 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables[row100].amount, 4, 'f', 3, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753 ui->fermentablesTable->setItem(row100, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
755 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables[row100].percentage, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757 ui->fermentablesTable->setItem(row100, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763 void EditProduct::ferment_to100_changed(bool val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765 qDebug() << "ferment_to100_changed()" << product->fermentables_row << val << product->fermentables_use100;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
767 if (product->fermentables.at(product->fermentables_row).added >= FERMENTABLE_ADDED_BOTTLE) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768 const QSignalBlocker blocker1(to100Edit);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
769 product->fermentables[product->fermentables_row].adjust_to_total_100 = false;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 to100Edit->setChecked(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 * Three scenario's.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
776 * 1. There is no fermentable selected yet, just mark it.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
777 * 2. There is current one is selected, deselect it.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778 * 3. There is another one selected, deselect and select this one.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780 if (! product->fermentables_use100 && val) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781 /* Scenario 1. */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782 product->fermentables_use100 = true;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
783 product->fermentables[product->fermentables_row].adjust_to_total_100 = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
784 pctEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
785 famountEdit->setReadOnly(true);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
786 } else if (product->fermentables_use100 && product->fermentables[product->fermentables_row].adjust_to_total_100 && ! val) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
787 /* Scenario 2. */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
788 product->fermentables[product->fermentables_row].adjust_to_total_100 = false;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
789 product->fermentables_use100 = false;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
790 pctEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
791 famountEdit->setReadOnly(false);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
792 } else if (product->fermentables_use100 && ! product->fermentables[product->fermentables_row].adjust_to_total_100 && val) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
793 /* Scenario 3. */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
794 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
795 product->fermentables[i].adjust_to_total_100 = false;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
796 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
797 product->fermentables[product->fermentables_row].adjust_to_total_100 = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
798 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
799 qDebug() << "bug";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
801 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
802
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
803 for (int i = 0; i < product->fermentables.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
804 to100Fermentables(i);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
805 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
806 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
807 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
808
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
809
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
810 void EditProduct::ferment_select_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
811 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
813 bool instock = finstockEdit->isChecked();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
814 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
815 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
816
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
817 if (val < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
818 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
819
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
820 qDebug() << "ferment_select_changed()" << product->fermentables_row << val << instock;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
821
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
822 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
823 * Search the fermentable pointed by the index and instock flag.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
824 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
825 QString sql = "SELECT name,origin,supplier,cost,type,yield,color,coarse_fine_diff,moisture,diastatic_power,protein,dissolved_protein,max_in_batch,"
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
826 "graintype,recommend_mash,add_after_boil,di_ph,acid_to_ph_57,inventory FROM inventory_fermentables ";
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
827 if (instock)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
828 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
829 sql.append("ORDER BY supplier,name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
830 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
831 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
832 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
833 for (int i = 0; i < (val - 1); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
834 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
835 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
836
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
837 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
838 * Replace the fermentable record contents
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
839 */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
840 product->fermentables[product->fermentables_row].name = query.value(0).toString();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
841 product->fermentables[product->fermentables_row].origin = query.value(1).toString();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
842 product->fermentables[product->fermentables_row].supplier = query.value(2).toString();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
843 product->fermentables[product->fermentables_row].cost = query.value(3).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
844 product->fermentables[product->fermentables_row].type = query.value(4).toInt();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
845 product->fermentables[product->fermentables_row].yield = query.value(5).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
846 product->fermentables[product->fermentables_row].color = query.value(6).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
847 product->fermentables[product->fermentables_row].coarse_fine_diff = query.value(7).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
848 product->fermentables[product->fermentables_row].moisture = query.value(8).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
849 product->fermentables[product->fermentables_row].diastatic_power = query.value(9).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
850 product->fermentables[product->fermentables_row].protein = query.value(10).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
851 product->fermentables[product->fermentables_row].dissolved_protein = query.value(11).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
852 product->fermentables[product->fermentables_row].max_in_batch = query.value(12).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
853 product->fermentables[product->fermentables_row].graintype = query.value(13).toInt();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
854 product->fermentables[product->fermentables_row].recommend_mash = query.value(14).toInt() ? true:false;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
855 product->fermentables[product->fermentables_row].add_after_boil = query.value(15).toInt() ? true:false;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
856 product->fermentables[product->fermentables_row].di_ph = query.value(16).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
857 product->fermentables[product->fermentables_row].acid_to_ph_57 = query.value(17).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
858 product->fermentables[product->fermentables_row].inventory = query.value(18).toDouble();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
859
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
860 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
861 * Update the visible fields
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
862 */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
863 fnameEdit->setText(product->fermentables.at(product->fermentables_row).name);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
864 fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).supplier);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
865 fmaxEdit->setValue(product->fermentables.at(product->fermentables_row).max_in_batch);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
866
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
867 ui->fermentablesTable->setItem(product->fermentables_row, 0, new QTableWidgetItem(product->fermentables.at(product->fermentables_row).supplier));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
868 ui->fermentablesTable->setItem(product->fermentables_row, 1, new QTableWidgetItem(product->fermentables.at(product->fermentables_row).name));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
869
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
870 w = QString("%1").arg(product->fermentables.at(product->fermentables_row).color, 1, 'f', 0, '0');
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
871 item = new QTableWidgetItem(w);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
872 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
873 ui->fermentablesTable->setItem(product->fermentables_row, 2, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
874
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
875 item = new QTableWidgetItem(QCoreApplication::translate("FermentableType", g_fermentable_types[product->fermentables.at(product->fermentables_row).type]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
876 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
877 ui->fermentablesTable->setItem(product->fermentables_row, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
878
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
879 item = new QTableWidgetItem(QCoreApplication::translate("FermentableGraintype", g_fermentable_graintypes[product->fermentables.at(product->fermentables_row).graintype]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
880 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
881 ui->fermentablesTable->setItem(product->fermentables_row, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
882
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
883 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(product->fermentables_row).yield, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
884 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
885 ui->fermentablesTable->setItem(product->fermentables_row, 6, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
886
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
887 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(product->fermentables_row).inventory, 4, 'f', 3, '0'));
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
888 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
889 if (product->fermentables.at(product->fermentables_row).inventory < product->fermentables.at(product->fermentables_row).amount)
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
890 item->setForeground(QBrush(QColor(Qt::red)));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
891 ui->fermentablesTable->setItem(product->fermentables_row, 8, item);
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 187
diff changeset
892
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
893 calcFermentables();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
894 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
895 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
896
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
897
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
898 void EditProduct::ferment_instock_changed(bool val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
899 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
900 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
901
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
902 qDebug() << "ferment_instock_changed()" << product->fermentables_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
903
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
904 this->fselectEdit->setCurrentIndex(-1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
905 this->fselectEdit->clear();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
906 QString sql = "SELECT supplier,name,color,inventory FROM inventory_fermentables ";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
907 if (val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
908 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
909 sql.append("ORDER BY supplier,name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
910 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
911 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
912 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
913 this->fselectEdit->addItem(""); // Start with empty value
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
914 for (int i = 0; i < query.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
915 this->fselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+" EBC) "+
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
916 QString("%1 kg").arg(query.value(3).toDouble(), 4, 'f', 3, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
917 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
918 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
919 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
920
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
921
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
922 void EditProduct::ferment_added_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
923 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924 qDebug() << "ferment_added_changed()" << product->fermentables_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
925
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
926 product->fermentables[product->fermentables_row].added = val;
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
927 QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("FermentableAdded", g_fermentable_added[val]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
928 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
929 ui->fermentablesTable->setItem(product->fermentables_row, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
930
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
931 famountEdit->setReadOnly(product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
932 pctEdit->setReadOnly(! (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
933
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
934 double total = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
935 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
936 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
937 total += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
938 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
939 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
940 product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
941
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
942 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
943 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
944 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
946
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
947 void EditProduct::editFermentRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
948 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
949 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
950
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
951 if (product->locked)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
952 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
953
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
954 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
955 product->fermentables_row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
956 qDebug() << "Edit fermentable row" << product->fermentables_row;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
957 Fermentables backup = product->fermentables.at(product->fermentables_row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
958
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
959 QDialog* dialog = new QDialog(this);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
960 dialog->resize(738, 287);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
961 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
962 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
963 buttonBox->setGeometry(QRect(30, 240, 671, 32));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
964 buttonBox->setLayoutDirection(Qt::LeftToRight);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 buttonBox->setOrientation(Qt::Horizontal);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967 buttonBox->setCenterButtons(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968 QLabel *nameLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
969 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
970 nameLabel->setText(tr("Current ingredient:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
971 nameLabel->setGeometry(QRect(10, 10, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
972 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
973 QLabel *supplierLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
974 supplierLabel->setObjectName(QString::fromUtf8("supplierLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
975 supplierLabel->setText(tr("Supplier:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
976 supplierLabel->setGeometry(QRect(10, 40, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
977 supplierLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
978 QLabel *amountLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
979 amountLabel->setObjectName(QString::fromUtf8("amountLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
980 amountLabel->setText(tr("Amount in kg:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
981 amountLabel->setGeometry(QRect(10, 100, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
982 amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
983 QLabel *pctLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
984 pctLabel->setObjectName(QString::fromUtf8("pctLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
985 pctLabel->setText(tr("Percentage in batch:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
986 pctLabel->setGeometry(QRect(10, 130, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
987 pctLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
988 QLabel *to100Label = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
989 to100Label->setObjectName(QString::fromUtf8("to100Label"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
990 to100Label->setText(tr("Auto fill to 100%:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
991 to100Label->setGeometry(QRect(10, 160, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
992 to100Label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
993 QLabel *addedLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
994 addedLabel->setObjectName(QString::fromUtf8("addedLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
995 addedLabel->setText(tr("Use at:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
996 addedLabel->setGeometry(QRect(10, 190, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
997 addedLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
998 QLabel *selectLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
999 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1000 selectLabel->setText(tr("Select ingredient:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1001 selectLabel->setGeometry(QRect(10, 70, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1002 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1003 QLabel *instockLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1004 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1005 instockLabel->setText(tr("In stock:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1006 instockLabel->setGeometry(QRect(525, 70, 121, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1007 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1008 QLabel *maxLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1009 maxLabel->setObjectName(QString::fromUtf8("maxLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1010 maxLabel->setText(tr("Max in batch:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1011 maxLabel->setGeometry(QRect(420, 130, 121, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1012 maxLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1013
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1014 fselectEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1015 fselectEdit->setObjectName(QString::fromUtf8("fselectEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1016 fselectEdit->setGeometry(QRect(160, 70, 371, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1017
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1018 fnameEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1019 fnameEdit->setObjectName(QString::fromUtf8("fnameEdit"));
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1020 fnameEdit->setText(product->fermentables.at(product->fermentables_row).name);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1021 fnameEdit->setGeometry(QRect(160, 10, 511, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1022 fnameEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1023 fsupplierEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1024 fsupplierEdit->setObjectName(QString::fromUtf8("fsupplierEdit"));
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1025 fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).supplier);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1026 fsupplierEdit->setGeometry(QRect(160, 40, 511, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1027 fsupplierEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1028 famountEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1029 famountEdit->setObjectName(QString::fromUtf8("famountEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1030 famountEdit->setGeometry(QRect(160, 100, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1031 famountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1032 famountEdit->setAccelerated(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1033 famountEdit->setDecimals(3);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1034 famountEdit->setReadOnly(product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < 4);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1035 famountEdit->setMaximum(100000.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1036 famountEdit->setSingleStep(0.0010);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1037 famountEdit->setValue(product->fermentables.at(product->fermentables_row).amount);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1038
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1039 pctEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1040 pctEdit->setObjectName(QString::fromUtf8("pctEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1041 pctEdit->setGeometry(QRect(160, 130, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1042 pctEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1043 pctEdit->setAccelerated(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1044 pctEdit->setDecimals(1);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1045 if (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1046 if (product->fermentables.at(product->fermentables_row).adjust_to_total_100)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1047 pctEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1048 else
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1049 pctEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1050 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1051 pctEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1052 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1053 pctEdit->setMaximum(100.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1054 pctEdit->setSingleStep(0.1);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1055 pctEdit->setValue(product->fermentables.at(product->fermentables_row).percentage);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1056
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1057 faddedEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1058 faddedEdit->setObjectName(QString::fromUtf8("faddedEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1059 faddedEdit->setGeometry(QRect(160, 190, 161, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1060 faddedEdit->addItem(tr("Mash"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1061 faddedEdit->addItem(tr("Boil"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1062 faddedEdit->addItem(tr("Fermentation"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1063 faddedEdit->addItem(tr("Lagering"));
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1064 faddedEdit->setCurrentIndex(product->fermentables.at(product->fermentables_row).added);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1065
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1066 to100Edit = new QCheckBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1067 to100Edit->setObjectName(QString::fromUtf8("to100Edit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1068 to100Edit->setGeometry(QRect(160, 160, 85, 21));
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1069 to100Edit->setChecked(product->fermentables.at(product->fermentables_row).adjust_to_total_100);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1070
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1071 finstockEdit = new QCheckBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1072 finstockEdit->setObjectName(QString::fromUtf8("instockEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1073 finstockEdit->setGeometry(QRect(655, 70, 85, 21));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1074 finstockEdit->setChecked(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1075
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1076 fmaxEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1077 fmaxEdit->setObjectName(QString::fromUtf8("fmaxEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1078 fmaxEdit->setGeometry(QRect(550, 130, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1079 fmaxEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1080 fmaxEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1081 fmaxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1082 fmaxEdit->setDecimals(1);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1083 fmaxEdit->setValue(product->fermentables.at(product->fermentables_row).max_in_batch);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1084
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1085 ferment_instock_changed(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1086
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1087 connect(fselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::ferment_select_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1088 connect(famountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::ferment_amount_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1089 connect(pctEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::ferment_pct_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1090 connect(faddedEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::ferment_added_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1091 connect(to100Edit, &QCheckBox::stateChanged, this, &EditProduct::ferment_to100_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1092 connect(finstockEdit, &QCheckBox::stateChanged, this, &EditProduct::ferment_instock_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1093 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1094 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1095
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1096 dialog->setModal(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1097 dialog->exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1098 if (dialog->result() == QDialog::Rejected) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1099 qDebug() << "reject and rollback";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1100 product->fermentables[product->fermentables_row] = backup;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1101 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1102 * Recalculate the percentages
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1103 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1104 double total = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1105 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1106 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1107 total += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1108 product->fermentables_use100 = false;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1109 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1110 if (product->fermentables.at(i).adjust_to_total_100)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1111 product->fermentables_use100 = true;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1112 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1113 product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1114 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1115 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1116 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1117
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1118 disconnect(fselectEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1119 disconnect(famountEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1120 disconnect(pctEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1121 disconnect(faddedEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1122 disconnect(to100Edit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1123 disconnect(finstockEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1124 disconnect(buttonBox, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1125
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1126 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1127 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1128
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1129

mercurial