src/EditRecipeTab5.cpp

Sat, 28 Jan 2023 10:36:59 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 28 Jan 2023 10:36:59 +0100
changeset 478
a3653722b0d6
parent 454
2dfead81c72f
child 496
9db6080a4783
permissions
-rw-r--r--

Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.

128
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditRecipe.cpp is part of bmsapp.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * tab 5, yeasts.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
11 * bmsapp is distributed in the yeaste that it will be useful,
128
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
21 bool EditRecipe::yeast_sort_test(const Yeasts &D1, const Yeasts &D2)
128
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
23 if (D1.use > D2.use)
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
24 return false;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
25 if (D1.use < D2.use)
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
26 return true;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
27 return (D1.amount > D2.amount);
128
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 }
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
31 void EditRecipe::refreshYeasts()
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
32 {
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
33 QString w;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
34 QWidget* pWidget;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
35 QHBoxLayout* pLayout;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
36 QTableWidgetItem *item;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
37
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
38 std::sort(recipe->yeasts.begin(), recipe->yeasts.end(), yeast_sort_test);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
39
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
40 const QStringList labels({tr("Yeast"), tr("Laboratory"), tr("Code"), tr("Type"), tr("Use for"), tr("Min. °C"), tr("Max. °C"),
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
41 tr("Tol. %"), tr("Attn. %"), tr("STA"), tr("Amount"), tr("Delete"), tr("Edit") });
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
42
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
43 ui->yeastsTable->setColumnCount(13);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
44 ui->yeastsTable->setColumnWidth(0, 200); /* Yeast */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
45 ui->yeastsTable->setColumnWidth(1, 125); /* Laboratory */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
46 ui->yeastsTable->setColumnWidth(2, 80); /* Code */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
47 ui->yeastsTable->setColumnWidth(3, 80); /* Type */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
48 ui->yeastsTable->setColumnWidth(4, 100); /* Usage */
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
49 ui->yeastsTable->setColumnWidth(5, 50); /* Min. */
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
50 ui->yeastsTable->setColumnWidth(6, 50); /* Max. */
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
51 ui->yeastsTable->setColumnWidth(7, 50); /* Tolerance */
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
52 ui->yeastsTable->setColumnWidth(8, 50); /* Attenuation */
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
53 ui->yeastsTable->setColumnWidth(9, 40); /* STA1 gen */
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
54 ui->yeastsTable->setColumnWidth(10, 90); /* Amount */
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
55 ui->yeastsTable->setColumnWidth(11, 80); /* Delete */
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
56 ui->yeastsTable->setColumnWidth(12, 80); /* Edit */
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
57 ui->yeastsTable->setHorizontalHeaderLabels(labels);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
58 ui->yeastsTable->verticalHeader()->hide();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
59 ui->yeastsTable->setRowCount(recipe->yeasts.size());
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
60
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
61 for (int i = 0; i < recipe->yeasts.size(); i++) {
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
62
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
63 ui->yeastsTable->setItem(i, 0, new QTableWidgetItem(recipe->yeasts.at(i).name));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
64 ui->yeastsTable->setItem(i, 1, new QTableWidgetItem(recipe->yeasts.at(i).laboratory));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
65 ui->yeastsTable->setItem(i, 2, new QTableWidgetItem(recipe->yeasts.at(i).product_id));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
66
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
67 item = new QTableWidgetItem(QCoreApplication::translate("YeastForm", g_yeast_forms[recipe->yeasts.at(i).form]));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
68 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
69 ui->yeastsTable->setItem(i, 3, item);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
70
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
71 item = new QTableWidgetItem(QCoreApplication::translate("YeastUse", g_yeast_use[recipe->yeasts.at(i).use]));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
72 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
73 ui->yeastsTable->setItem(i, 4, item);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
74
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
75 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).min_temperature, 2, 'f', 1, '0'));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
76 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
77 ui->yeastsTable->setItem(i, 5, item);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
78
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
79 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).max_temperature, 2, 'f', 1, '0'));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
80 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
81 ui->yeastsTable->setItem(i, 6, item);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
82
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
83 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).tolerance, 2, 'f', 1, '0'));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
84 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
85 ui->yeastsTable->setItem(i, 7, item);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
86
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
87 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).attenuation, 2, 'f', 1, '0'));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
88 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
89 ui->yeastsTable->setItem(i, 8, item);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
90
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
91 if (recipe->yeasts.at(i).use != YEAST_USE_BOTTLE && recipe->yeasts.at(i).sta1) {
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
92 QWidget *pWidget = new QWidget();
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
93 QLabel *label = new QLabel;
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
94 label->setPixmap(QPixmap(":icons/silk/tick.png"));
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
95 QHBoxLayout *pLayout = new QHBoxLayout(pWidget);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
96 pLayout->addWidget(label);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
97 pLayout->setAlignment(Qt::AlignCenter);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
98 pLayout->setContentsMargins(0, 0, 0, 0);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
99 pWidget->setLayout(pLayout);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
100 ui->yeastsTable->setCellWidget(i, 9, pWidget);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
101 } else {
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
102 ui->yeastsTable->removeCellWidget(i, 9);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
103 }
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
104
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
105 if (recipe->yeasts.at(i).form == YEAST_FORMS_LIQUID)
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
106 item = new QTableWidgetItem(QString("%1 pack").arg(recipe->yeasts.at(i).amount, 1, 'f', 0, '0'));
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
107 else if (recipe->yeasts.at(i).form == YEAST_FORMS_DRY || recipe->yeasts.at(i).form == YEAST_FORMS_DRIED)
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
108 item = new QTableWidgetItem(QString("%1 gr").arg(recipe->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0'));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
109 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
110 item = new QTableWidgetItem(QString("%1 ml").arg(recipe->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0'));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
111 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
112 ui->yeastsTable->setItem(i, 10, item);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
113
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
114 pWidget = new QWidget();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
115 QPushButton* btn_dele = new QPushButton();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
116 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
117 btn_dele->setText(tr("Delete"));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
118 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteYeastRow_clicked()));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
119 pLayout = new QHBoxLayout(pWidget);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
120 pLayout->addWidget(btn_dele);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
121 pLayout->setContentsMargins(5, 0, 5, 0);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
122 pWidget->setLayout(pLayout);
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
123 ui->yeastsTable->setCellWidget(i, 11, pWidget);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
124
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
125 pWidget = new QWidget();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
126 QPushButton* btn_edit = new QPushButton();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
127 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
128 btn_edit->setText(tr("Edit"));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
129 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editYeastRow_clicked()));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
130 pLayout = new QHBoxLayout(pWidget);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
131 pLayout->addWidget(btn_edit);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
132 pLayout->setContentsMargins(5, 0, 5, 0);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
133 pWidget->setLayout(pLayout);
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
134 ui->yeastsTable->setCellWidget(i, 12, pWidget);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
135 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
136 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
137
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
138
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
139 /*
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
140 * The results are not stored line in EditProduct. This is just a hint.
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
141 */
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
142 void EditRecipe::calcYeast()
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
143 {
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
144 double sg = recipe->est_og;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
145 double plato = Utils::sg_to_plato(sg);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
146 double volume = recipe->batch_size * 0.9; // Volume min trub chiller loss.
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
147 bool maybe_starter = false;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
148 double pitchrate = 0.75;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
149 double initcells = 0;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
150
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
151 qDebug() << "calcYeast()";
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
152 ui->yeastProcedure->setCurrentIndex(0);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
153
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
154 if (recipe->yeasts.size() == 0)
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
155 return; // No yeast in recipe.
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
156
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
157 for (int i = 0; i < recipe->yeasts.size(); i++) {
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
158 if (recipe->yeasts.at(i).use == YEAST_USE_PRIMARY) { // Primary
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
159 if (recipe->yeasts.at(i).form == YEAST_FORMS_DRY) {
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
160 /*
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
161 * Dry yeast, build the formule with the yeast parameters.
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
162 * Based on https://www.lallemandbrewing.com/en/canada/brewers-corner/brewing-tools/pitching-rate-calculator/
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
163 */
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
164 ui->yeastProcedure->setCurrentIndex(2);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
165 ui->lo_gr_hlEdit->setValue(recipe->yeasts.at(i).gr_hl_lo);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
166 ui->hi_gr_hlEdit->setValue(recipe->yeasts.at(i).gr_hl_hi);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
167 ui->lo_sgEdit->setValue(recipe->yeasts.at(i).sg_lo);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
168 ui->hi_sgEdit->setValue(recipe->yeasts.at(i).sg_hi);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
169 double og = recipe->yeasts.at(i).sg_lo;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
170 double f1 = recipe->yeasts.at(i).gr_hl_lo / 100.0;
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
171 double f2 = round(f1 / 5 * 1000000.0) / 1000000.0;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
172 double multiplier = (sg <= og) ? f1 : (f1 + f2 * (sg - og) / 0.008);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
173 qDebug() << " sg:" << sg << "og:" << og << "f1:" << f1 << "f2:" << f2 << "multiplier:" << multiplier;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
174 double yeast_grams = round(volume * multiplier * 100.0) / 100.0; // * (100 / dataRecord.starter_viability), 2);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
175 double yeast_gr_hl = round((yeast_grams / (volume * 0.01)) * 100.0) / 100.0;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
176 ui->need_grEdit->setValue(yeast_grams);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
177 ui->pitch_grEdit->setValue(yeast_gr_hl);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
178 qDebug() << " need" << yeast_grams << "grams, gr/hl:" << yeast_gr_hl;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
179 return;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
180 } else {
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
181 /*
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
182 * Liquid, slant, culture etc.
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
183 * pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
184 * and http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
185 */
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
186 ui->yeastProcedure->setCurrentIndex(1);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
187 if (recipe->yeasts.at(i).type == 0) { // Lager yeast
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
188 pitchrate = 1.5;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
189 if (sg > 1.060)
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
190 pitchrate = 2.0;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
191 } else if (recipe->yeasts.at(i).type == 6) { // Real Kveik
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
192 pitchrate = 0.075;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
193 } else {
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
194 pitchrate = 0.75;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
195 if (sg > 1.060)
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
196 pitchrate = 1.0;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
197 }
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
198 if (recipe->yeasts.at(i).form == 0)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
199 initcells = (recipe->yeasts.at(i).cells / 1000000000) * recipe->yeasts.at(i).amount * 0.97; // 97% viability assumed.
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
200 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
201 initcells = (recipe->yeasts.at(i).cells / 1000000) * recipe->yeasts.at(i).amount * 0.97;
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
202
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
203 double needed = round(pitchrate * volume * plato * 10.0) / 10.0;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
204 double starter = 0;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
205 if (needed > initcells) {
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
206 maybe_starter = true;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
207 starter = round(needed / 2.0) / 100.0; // A very rough starter size estimate.
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
208 }
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
209
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
210 ui->pitchrateEdit->setValue(pitchrate);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
211 ui->initcellsEdit->setValue(initcells);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
212 ui->targetcellsEdit->setValue(needed);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
213 ui->starterEdit->setValue(starter);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
214
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
215 qDebug() << " pitchrate:" << pitchrate << "needed:" << needed << "initcells:" << initcells << "starter" << maybe_starter << "size" << starter;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
216 }
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
217 break;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
218 }
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
219 }
395
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
220 calcBU();
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
221 }
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
222
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
223
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
224 void EditRecipe::addYeastRow_clicked()
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
225 {
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
226 Yeasts newy;
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
227
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
228 #ifdef DEBUG_YEAST
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
229 qDebug() << "Add yeast row";
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
230 #endif
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
231
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
232 for (int i = 0; i < recipe->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
233 if (recipe->yeasts.at(i).amount == 0)
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
234 return; // Add only one at a time.
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
235 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
236
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
237 newy.name = "Select one";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
238 newy.laboratory = "";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
239 newy.product_id = "";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
240 newy.amount = 0;
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
241 newy.type = YEAST_TYPES_ALE;
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
242 newy.form = YEAST_FORMS_LIQUID;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
243 newy.min_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
244 newy.max_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
245 newy.flocculation = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
246 newy.attenuation = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
247 newy.cells = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
248 newy.tolerance = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
249 newy.inventory = 0;
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
250 newy.use = YEAST_USE_PRIMARY;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
251 newy.sta1 = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
252 newy.bacteria = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
253 newy.harvest_top = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
254 newy.harvest_time = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
255 newy.pitch_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
256 newy.pofpos = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
257 newy.zymocide = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
258 newy.gr_hl_lo = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
259 newy.sg_lo = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
260 newy.gr_hl_hi = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
261 newy.sg_hi = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
262 newy.cost = 0;
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
263
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
264 recipe->yeasts.append(newy);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
265 emit refreshAll();
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
266 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
267
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
268
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
269 void EditRecipe::deleteYeastRow_clicked()
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
270 {
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
271 if (recipe->locked || recipe->yeasts.size() < 1)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
272 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
273
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
274 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
275 int row = pb->objectName().toInt();
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
276 #ifdef DEBUG_YEAST
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
277 qDebug() << "Delete yeast row" << row << recipe->yeasts.size();
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
278 #endif
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
279
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
280 int rc = QMessageBox::warning(this, tr("Delete yeast"), tr("Delete %1").arg(recipe->yeasts.at(row).name),
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
281 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
282 if (rc == QMessageBox::No)
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
283 return;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
284
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
285 recipe->yeasts.removeAt(row);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
286 is_changed();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
287 emit refreshAll();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
288 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
289
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
290
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
291 void EditRecipe::yeast_amount_changed(double val)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
292 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
293 QTableWidgetItem *item;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
294
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
295 qDebug() << "yeast_amount_changed()" << recipe->yeasts_row << val;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
296
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
297 if (recipe->yeasts.at(recipe->yeasts_row).form == 0) {
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
298 recipe->yeasts[recipe->yeasts_row].amount = val;
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
299 item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '0'));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
300 } else if (recipe->yeasts.at(recipe->yeasts_row).form == 1) {
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
301 recipe->yeasts[recipe->yeasts_row].amount = val / 1000.0;
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
302 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0'));
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
303 } else {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
304 recipe->yeasts[recipe->yeasts_row].amount = val / 1000.0;
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
305 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0'));
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
306 }
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
307 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
308 ui->yeastsTable->setItem(recipe->yeasts_row, 10, item);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
309
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
310 calcYeast();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
311 is_changed();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
312 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
313
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
314
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
315 void EditRecipe::yeast_select_changed(int val)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
316 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
317 QSqlQuery query;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
318 bool instock = yinstockEdit->isChecked();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
319 QString w;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
320 QTableWidgetItem *item;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
321
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
322 if (val < 1)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
323 return;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
324
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
325 #ifdef DEBUG_YEAST
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
326 qDebug() << "yeast_select_changed()" << recipe->yeasts_row << val << instock;
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
327 #endif
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
328
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
329 /*
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
330 * Search the yeast pointed by the index and instock flag.
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
331 */
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
332 QString sql = "SELECT name,laboratory,product_id,type,form,min_temperature,max_temperature,flocculation,attenuation,"
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
333 "cells,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide,"
299
8021e09ab6a3 Fixed select yeasts in recipes and poducts.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
334 "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost FROM inventory_yeasts ";
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
335 if (instock)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
336 sql.append("WHERE inventory > 0 ");
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
337 sql.append("ORDER BY laboratory,product_id,name");
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
338 query.prepare(sql);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
339 query.exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
340 query.first();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
341 for (int i = 0; i < (val - 1); i++) {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
342 query.next();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
343 }
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
344 #ifdef DEBUG_YEAST
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
345 qDebug() << "found" << query.value(0).toString() << query.value(2).toString();
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
346 #endif
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
347
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
348 /*
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
349 * Replace the yeast record contents
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
350 */
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
351 recipe->yeasts[recipe->yeasts_row].name = query.value(0).toString();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
352 recipe->yeasts[recipe->yeasts_row].laboratory = query.value(1).toString();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
353 recipe->yeasts[recipe->yeasts_row].product_id = query.value(2).toString();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
354 recipe->yeasts[recipe->yeasts_row].type = query.value(3).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
355 recipe->yeasts[recipe->yeasts_row].form = query.value(4).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
356 recipe->yeasts[recipe->yeasts_row].min_temperature = query.value(5).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
357 recipe->yeasts[recipe->yeasts_row].max_temperature = query.value(6).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
358 recipe->yeasts[recipe->yeasts_row].flocculation = query.value(7).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
359 recipe->yeasts[recipe->yeasts_row].attenuation = query.value(8).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
360 recipe->yeasts[recipe->yeasts_row].cells = query.value(9).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
361 recipe->yeasts[recipe->yeasts_row].tolerance = query.value(10).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
362 recipe->yeasts[recipe->yeasts_row].sta1 = query.value(11).toInt() ? true:false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
363 recipe->yeasts[recipe->yeasts_row].bacteria = query.value(12).toInt() ? true:false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
364 recipe->yeasts[recipe->yeasts_row].harvest_top = query.value(13).toInt() ? true:false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
365 recipe->yeasts[recipe->yeasts_row].harvest_time = query.value(14).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
366 recipe->yeasts[recipe->yeasts_row].pitch_temperature = query.value(15).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
367 recipe->yeasts[recipe->yeasts_row].pofpos = query.value(16).toInt() ? true:false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
368 recipe->yeasts[recipe->yeasts_row].zymocide = query.value(17).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
369 recipe->yeasts[recipe->yeasts_row].gr_hl_lo = query.value(18).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
370 recipe->yeasts[recipe->yeasts_row].sg_lo = query.value(19).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
371 recipe->yeasts[recipe->yeasts_row].gr_hl_hi = query.value(20).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
372 recipe->yeasts[recipe->yeasts_row].sg_hi = query.value(21).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
373 recipe->yeasts[recipe->yeasts_row].cost = query.value(22).toDouble();
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
374
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
375 /*
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
376 * Update the visible fields
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
377 */
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
378 ynameEdit->setText(recipe->yeasts.at(recipe->yeasts_row).name);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
379 ylaboratoryEdit->setText(recipe->yeasts.at(recipe->yeasts_row).laboratory);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
380 yproduct_idEdit->setText(recipe->yeasts.at(recipe->yeasts_row).product_id);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
381 if (recipe->yeasts.at(recipe->yeasts_row).form == 0) {
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
382 yamountEdit->setDecimals(0);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
383 yamountEdit->setSingleStep(1.0);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
384 yamountLabel->setText(tr("Total packs:"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
385 } else if (recipe->yeasts.at(recipe->yeasts_row).form == 1) {
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
386 yamountEdit->setDecimals(1);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
387 yamountEdit->setSingleStep(0.5);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
388 yamountLabel->setText(tr("Amount in gr:"));
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
389 } else {
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
390 yamountEdit->setDecimals(1);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
391 yamountEdit->setSingleStep(0.5);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
392 yamountLabel->setText(tr("Amount in ml:"));
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
393 }
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
394
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
395 ui->yeastsTable->setItem(recipe->yeasts_row, 0, new QTableWidgetItem(recipe->yeasts.at(recipe->yeasts_row).name));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
396 ui->yeastsTable->setItem(recipe->yeasts_row, 1, new QTableWidgetItem(recipe->yeasts.at(recipe->yeasts_row).laboratory));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
397 ui->yeastsTable->setItem(recipe->yeasts_row, 2, new QTableWidgetItem(recipe->yeasts.at(recipe->yeasts_row).product_id));
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
398
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
399 item = new QTableWidgetItem(QCoreApplication::translate("YeastForm", g_yeast_forms[recipe->yeasts.at(recipe->yeasts_row).form]));
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
400 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
401 ui->yeastsTable->setItem(recipe->yeasts_row, 3, item);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
402
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
403 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).min_temperature, 2, 'f', 1, '0'));
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
404 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
405 ui->yeastsTable->setItem(recipe->yeasts_row, 5, item);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
406
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
407 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).max_temperature, 2, 'f', 1, '0'));
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
408 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
409 ui->yeastsTable->setItem(recipe->yeasts_row, 6, item);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
410
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
411 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).tolerance, 2, 'f', 1, '0'));
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
412 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
413 ui->yeastsTable->setItem(recipe->yeasts_row, 7, item);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
414
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
415 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).attenuation, 2, 'f', 1, '0'));
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
416 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
417 ui->yeastsTable->setItem(recipe->yeasts_row, 8, item);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
418
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
419 if (recipe->yeasts.at(product->yeasts_row).use != YEAST_USE_BOTTLE && recipe->yeasts.at(product->yeasts_row).sta1) {
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
420 QWidget *pWidget = new QWidget();
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
421 QLabel *label = new QLabel;
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
422 label->setPixmap(QPixmap(":icons/silk/tick.png"));
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
423 QHBoxLayout *pLayout = new QHBoxLayout(pWidget);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
424 pLayout->addWidget(label);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
425 pLayout->setAlignment(Qt::AlignCenter);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
426 pLayout->setContentsMargins(0, 0, 0, 0);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
427 pWidget->setLayout(pLayout);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
428 ui->yeastsTable->setCellWidget(product->yeasts_row, 9, pWidget);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
429 } else {
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
430 ui->yeastsTable->removeCellWidget(product->yeasts_row, 9);
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
431 }
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
432
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
433 is_changed();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
434 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
435
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
436
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
437 void EditRecipe::yeast_instock_changed(bool val)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
438 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
439 QSqlQuery query;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
440
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
441 #ifdef DEBUG_YEAST
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
442 qDebug() << "yeast_instock_changed()" << recipe->yeasts_row << val;
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
443 #endif
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
444
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
445 this->yselectEdit->setCurrentIndex(-1);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
446 this->yselectEdit->clear();
299
8021e09ab6a3 Fixed select yeasts in recipes and poducts.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
447 QString sql = "SELECT name,laboratory,product_id,inventory FROM inventory_yeasts ";
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
448 if (val)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
449 sql.append("WHERE inventory > 0 ");
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
450 sql.append("ORDER BY laboratory,product_id,name");
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
451 query.prepare(sql);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
452 query.exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
453 query.first();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
454 this->yselectEdit->addItem(""); // Start with empty value
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
455 for (int i = 0; i < query.size(); i++) {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
456 this->yselectEdit->addItem(query.value(1).toString()+" - "+query.value(2).toString()+" "+query.value(0).toString() +
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
457 QString(" (%1 gr)").arg(query.value(3).toDouble() * 1000.0, 2, 'f', 1, '0'));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
458 query.next();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
459 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
460 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
461
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
462
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
463 void EditRecipe::yeast_useat_changed(int val)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
464 {
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
465 #ifdef DEBUG_YEAST
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
466 qDebug() << "yeast_useat_changed()" << recipe->yeasts_row << val;
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
467 #endif
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
468
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
469 recipe->yeasts[recipe->yeasts_row].use = val;
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
470 QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("YeastUse", g_yeast_use[val]));
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
471 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
472 ui->yeastsTable->setItem(recipe->yeasts_row, 5, item);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
473 is_changed();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
474 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
475
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
476
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
477 void EditRecipe::editYeastRow_clicked()
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
478 {
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
479 QSqlQuery query;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
480
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
481 if (recipe->locked)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
482 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
483
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
484 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
485 recipe->yeasts_row = pb->objectName().toInt();
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
486 #ifdef DEBUG_YEAST
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
487 qDebug() << "Edit yeast row" << recipe->yeasts_row;
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
488 #endif
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
489 Yeasts backup = recipe->yeasts.at(recipe->yeasts_row);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
490
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
491 QDialog* dialog = new QDialog(this);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
492 dialog->resize(738, 260);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
493 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
494 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
495 buttonBox->setGeometry(QRect(30, 210, 671, 32));
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
496 buttonBox->setLayoutDirection(Qt::LeftToRight);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
497 buttonBox->setOrientation(Qt::Horizontal);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
498 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
499 buttonBox->setCenterButtons(true);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
500
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
501 QLabel *nameLabel = new QLabel(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
502 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
503 nameLabel->setText(tr("Yeast name:"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
504 nameLabel->setGeometry(QRect(10, 10, 141, 20));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
505 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
506 QLabel *laboratoryLabel = new QLabel(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
507 laboratoryLabel->setObjectName(QString::fromUtf8("laboratoryLabel"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
508 laboratoryLabel->setText(tr("Laboratory:"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
509 laboratoryLabel->setGeometry(QRect(10, 40, 141, 20));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
510 laboratoryLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
511 QLabel *product_idLabel = new QLabel(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
512 product_idLabel->setObjectName(QString::fromUtf8("product_idLabel"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
513 product_idLabel->setText(tr("Laboratory:"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
514 product_idLabel->setGeometry(QRect(10, 70, 141, 20));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
515 product_idLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
516 QLabel *selectLabel = new QLabel(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
517 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
518 selectLabel->setText(tr("Select yeast:"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
519 selectLabel->setGeometry(QRect(10,100, 141, 20));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
520 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
521 QLabel *instockLabel = new QLabel(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
522 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
523 instockLabel->setText(tr("In stock:"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
524 instockLabel->setGeometry(QRect(525,100, 121, 20));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
525 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
526 yamountLabel = new QLabel(dialog);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
527 yamountLabel->setObjectName(QString::fromUtf8("amountLabel"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
528 if (recipe->yeasts.at(recipe->yeasts_row).form == 0)
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
529 yamountLabel->setText(tr("Total packs:"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
530 else if (recipe->yeasts.at(recipe->yeasts_row).form == 1)
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
531 yamountLabel->setText(tr("Amount in gr:"));
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
532 else
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
533 yamountLabel->setText(tr("Amount in ml:"));
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
534 yamountLabel->setGeometry(QRect(10, 130, 141, 20));
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
535 yamountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
536 QLabel *useatLabel = new QLabel(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
537 useatLabel->setObjectName(QString::fromUtf8("useatLabel"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
538 useatLabel->setText(tr("Use at:"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
539 useatLabel->setGeometry(QRect(10, 160, 141, 20));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
540 useatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
541
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
542 ynameEdit = new QLineEdit(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
543 ynameEdit->setObjectName(QString::fromUtf8("ynameEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
544 ynameEdit->setText(recipe->yeasts.at(recipe->yeasts_row).name);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
545 ynameEdit->setGeometry(QRect(160, 10, 511, 23));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
546 ynameEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
547 ylaboratoryEdit = new QLineEdit(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
548 ylaboratoryEdit->setObjectName(QString::fromUtf8("ylaboratoryEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
549 ylaboratoryEdit->setText(recipe->yeasts.at(recipe->yeasts_row).laboratory);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
550 ylaboratoryEdit->setGeometry(QRect(160, 40, 511, 23));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
551 ylaboratoryEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
552 yproduct_idEdit = new QLineEdit(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
553 yproduct_idEdit->setObjectName(QString::fromUtf8("yproduct_idEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
554 yproduct_idEdit->setText(recipe->yeasts.at(recipe->yeasts_row).product_id);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
555 yproduct_idEdit->setGeometry(QRect(160, 70, 511, 23));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
556 yproduct_idEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
557 yselectEdit = new QComboBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
558 yselectEdit->setObjectName(QString::fromUtf8("selectEdit"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
559 yselectEdit->setGeometry(QRect(160,100, 371, 23));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
560 yinstockEdit = new QCheckBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
561 yinstockEdit->setObjectName(QString::fromUtf8("yinstockEdit"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
562 yinstockEdit->setGeometry(QRect(655,100, 85, 21));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
563 yinstockEdit->setChecked(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
564 yamountEdit = new QDoubleSpinBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
565 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
566 yamountEdit->setGeometry(QRect(160, 130, 121, 24));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
567 yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
568 yamountEdit->setAccelerated(true);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
569 if (recipe->yeasts.at(recipe->yeasts_row).form == 0) {
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
570 yamountEdit->setDecimals(0);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
571 yamountEdit->setSingleStep(1.0);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
572 yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).amount);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
573 } else if (recipe->yeasts.at(recipe->yeasts_row).form == 1) {
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
574 yamountEdit->setDecimals(1);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
575 yamountEdit->setSingleStep(0.5);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
576 yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).amount * 1000.0);
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
577 } else {
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
578 yamountEdit->setDecimals(1);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
579 yamountEdit->setSingleStep(0.5);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
580 yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).amount * 1000.0);
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
581 }
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
582 yamountEdit->setMaximum(1000000000.0);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
583 useatEdit = new QComboBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
584 useatEdit->setObjectName(QString::fromUtf8("useatEdit"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
585 useatEdit->setGeometry(QRect(160, 160, 161, 23));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
586 useatEdit->addItem(tr("Primary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
587 useatEdit->addItem(tr("Secondary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
588 useatEdit->addItem(tr("Tertiary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
589 useatEdit->addItem(tr("Bottle"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
590 useatEdit->setCurrentIndex(recipe->yeasts.at(recipe->yeasts_row).use);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
591
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
592 yeast_instock_changed(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
593
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
594 connect(yselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::yeast_select_changed);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
595 connect(yamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::yeast_amount_changed);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
596 connect(useatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::yeast_useat_changed);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
597 connect(yinstockEdit, &QCheckBox::stateChanged, this, &EditRecipe::yeast_instock_changed);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
598 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
599 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
600
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
601 dialog->setModal(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
602 dialog->exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
603 if (dialog->result() == QDialog::Rejected) {
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
604 #ifdef DEBUG_YEAST
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
605 qDebug() << "reject and rollback";
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
606 #endif
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
607 recipe->yeasts[recipe->yeasts_row] = backup;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
608 } else {
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
609
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
610 }
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
611
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
612 disconnect(yselectEdit, nullptr, nullptr, nullptr);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
613 disconnect(yamountEdit, nullptr, nullptr, nullptr);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
614 disconnect(useatEdit, nullptr, nullptr, nullptr);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
615 disconnect(yinstockEdit, nullptr, nullptr, nullptr);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
616 disconnect(buttonBox, nullptr, nullptr, nullptr);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
617
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
618 emit refreshAll();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
619 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
620
150
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
621
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
622 void EditRecipe::adjustYeasts(double factor)
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
623 {
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
624 double amount;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
625
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
626 if (recipe->yeasts.size() == 0)
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
627 return;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
628
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
629 for (int i = 0; i < recipe->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
630 if (recipe->yeasts.at(i).form == 1) { // Only adjust dry yeast
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
631 amount = recipe->yeasts.at(i).amount * factor;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
632 recipe->yeasts[i].amount = amount;
150
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
633 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
634 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
635 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
636

mercurial