src/EditRecipeTab5.cpp

Thu, 18 Aug 2022 20:34:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 20:34:15 +0200
changeset 401
583148eb6e01
parent 395
7212b980a527
child 454
2dfead81c72f
permissions
-rw-r--r--

Init est_carb field for new products.

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 qDebug() << "refreshYeasts" << recipe->yeasts.size();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
39 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
40
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
41 const QStringList labels({tr("Yeast"), tr("Laboratory"), tr("Code"), tr("Type"), tr("Use for"), tr("Min. °C"), tr("Max. °C"),
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
42 tr("Tol. %"), tr("Attn. %"), tr("Amount"), tr("Delete"), tr("Edit") });
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
43
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
44 ui->yeastsTable->setColumnCount(12);
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(0, 200); /* Yeast */
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(1, 125); /* Laboratory */
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(2, 80); /* Code */
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(3, 80); /* Type */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
49 ui->yeastsTable->setColumnWidth(4, 100); /* Usage */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
50 ui->yeastsTable->setColumnWidth(5, 60); /* Min. */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
51 ui->yeastsTable->setColumnWidth(6, 60); /* Max. */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
52 ui->yeastsTable->setColumnWidth(7, 60); /* Tolerance */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
53 ui->yeastsTable->setColumnWidth(8, 60); /* Attenuation */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
54 ui->yeastsTable->setColumnWidth(9, 90); /* Amount */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
55 ui->yeastsTable->setColumnWidth(10, 80); /* Delete */
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
56 ui->yeastsTable->setColumnWidth(11, 80); /* Edit */
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
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
91 if (recipe->yeasts.at(i).form == 0)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
92 item = new QTableWidgetItem(QString("%1 pack").arg(recipe->yeasts.at(i).amount, 1, 'f', 0, '0'));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
93 else if (recipe->yeasts.at(i).form == 1)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
94 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
95 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
96 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
97 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
98 ui->yeastsTable->setItem(i, 9, item);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
99
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
100 pWidget = new QWidget();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 pWidget->setLayout(pLayout);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
109 ui->yeastsTable->setCellWidget(i, 10, pWidget);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
110
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
111 pWidget = new QWidget();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 pWidget->setLayout(pLayout);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
120 ui->yeastsTable->setCellWidget(i, 11, pWidget);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
121 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
122 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
123
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
124
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
125 /*
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
126 * 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
127 */
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
128 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
129 {
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
130 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
131 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
132 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
133 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
134 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
135 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
136
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
137 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
138 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
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 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
141 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
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
143 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
144 if (recipe->yeasts.at(i).use == 0) { // Primary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
145 if (recipe->yeasts.at(i).form == 1) {
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
146 /*
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 * 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
148 * 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
149 */
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 ui->yeastProcedure->setCurrentIndex(2);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
151 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
152 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
153 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
154 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
155 double og = recipe->yeasts.at(i).sg_lo;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 } 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
167 /*
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
168 * 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
169 * 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
170 * 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
171 */
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 ui->yeastProcedure->setCurrentIndex(1);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
173 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
174 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
175 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
176 pitchrate = 2.0;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
177 } 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
178 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
179 } 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
180 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
181 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
182 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
183 }
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
184 if (recipe->yeasts.at(i).form == 0)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
185 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
186 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
187 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
188
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 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
190 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
191 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
192 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
193 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
194 }
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
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 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
197 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
198 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
199 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
200
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
201 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
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 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
204 }
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 }
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
206 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
207 }
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
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
210 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
211 {
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
212 Yeasts newy;
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
213
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
214 qDebug() << "Add yeast row";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
215
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
216 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
217 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
218 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
219 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
220
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
221 newy.name = "Select one";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
222 newy.laboratory = "";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
223 newy.product_id = "";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
224 newy.amount = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
225 newy.type = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
226 newy.form = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
227 newy.min_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
228 newy.max_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
229 newy.flocculation = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
230 newy.attenuation = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
231 newy.cells = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
232 newy.tolerance = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
233 newy.inventory = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
234 newy.use = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
235 newy.sta1 = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
236 newy.bacteria = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
237 newy.harvest_top = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
238 newy.harvest_time = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
239 newy.pitch_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
240 newy.pofpos = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
241 newy.zymocide = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
242 newy.gr_hl_lo = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
243 newy.sg_lo = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
244 newy.gr_hl_hi = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
245 newy.sg_hi = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
246 newy.cost = 0;
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
247
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
248 recipe->yeasts.append(newy);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
249 emit refreshAll();
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
250 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
251
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
252
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
253 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
254 {
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
255 if (recipe->locked || recipe->yeasts.size() < 1)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
256 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
257
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
258 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
259 int row = pb->objectName().toInt();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
260 qDebug() << "Delete yeast row" << row << recipe->yeasts.size();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
261
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
262 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
263 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
264 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
265 return;
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 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
268 is_changed();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
269 emit refreshAll();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
270 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
271
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
272
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
273 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
274 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
275 QTableWidgetItem *item;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
276
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
277 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
278
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
279 if (recipe->yeasts.at(recipe->yeasts_row).form == 0) {
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
280 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
281 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
282 } 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
283 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
284 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
285 } else {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
286 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
287 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
288 }
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
289 item->setTextAlignment(Qt::AlignRight|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
290 ui->yeastsTable->setItem(recipe->yeasts_row, 9, item);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
291
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
292 calcYeast();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
293 is_changed();
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
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
296
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
297 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
298 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
299 QSqlQuery query;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
300 bool instock = yinstockEdit->isChecked();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
301 QString w;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
302 QTableWidgetItem *item;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
303
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
304 if (val < 1)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
305 return;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
306
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
307 qDebug() << "yeast_select_changed()" << recipe->yeasts_row << val << instock;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
308
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 * 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
311 */
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
312 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
313 "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
314 "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
315 if (instock)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
316 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
317 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
318 query.prepare(sql);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
319 query.exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
320 query.first();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
321 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
322 query.next();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
323 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
324 qDebug() << "found" << query.value(0).toString() << query.value(2).toString();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
325
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
326 /*
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
327 * 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
328 */
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351 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
352
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
353 /*
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
354 * Update the visible fields
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
355 */
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
356 ynameEdit->setText(recipe->yeasts.at(recipe->yeasts_row).name);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
357 ylaboratoryEdit->setText(recipe->yeasts.at(recipe->yeasts_row).laboratory);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
358 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
359 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
360 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
361 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
362 yamountLabel->setText(tr("Total packs:"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
363 } 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
364 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
365 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
366 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
367 } 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
368 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
369 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
370 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
371 }
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
372
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
373 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
374 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
375 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
376
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
377 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
378 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
379 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
380
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
381 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
382 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
383 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
384
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
385 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
386 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
387 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
388
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
389 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
390 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
391 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
392
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
393 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
394 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
395 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
396
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
397 calcYeast();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
398 is_changed();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
399 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
400
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
401
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
402 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
403 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
404 QSqlQuery query;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
405
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
406 qDebug() << "yeast_instock_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
407
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
408 this->yselectEdit->setCurrentIndex(-1);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
409 this->yselectEdit->clear();
299
8021e09ab6a3 Fixed select yeasts in recipes and poducts.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
410 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
411 if (val)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
412 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
413 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
414 query.prepare(sql);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
415 query.exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
416 query.first();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
417 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
418 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
419 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
420 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
421 query.next();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
422 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
423 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
424
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
425
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
426 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
427 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
428 qDebug() << "yeast_useat_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
429
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
430 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
431 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
432 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
433 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
434 is_changed();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
435 emit refreshAll();
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
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
438
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
439 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
440 {
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
441 QSqlQuery query;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
442
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
443 if (recipe->locked)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
444 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
445
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
446 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
447 recipe->yeasts_row = pb->objectName().toInt();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
448 qDebug() << "Edit yeast row" << recipe->yeasts_row;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
449 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
450
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
451 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
452 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
453 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
454 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
455 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
456 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
457 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
458 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
459 buttonBox->setCenterButtons(true);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
460
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
461 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
462 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
463 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
464 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
465 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
466 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
467 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
468 laboratoryLabel->setText(tr("Laboratory:"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
469 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
470 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
471 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
472 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
473 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
474 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
475 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
476 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
477 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
478 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
479 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
480 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
481 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
482 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
483 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
484 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
485 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
486 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
487 yamountLabel->setObjectName(QString::fromUtf8("amountLabel"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
488 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
489 yamountLabel->setText(tr("Total packs:"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
490 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
491 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
492 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
493 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
494 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
495 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
496 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
497 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
498 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
499 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
500 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
501
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
502 ynameEdit = new QLineEdit(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
503 ynameEdit->setObjectName(QString::fromUtf8("ynameEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
504 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
505 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
506 ynameEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
507 ylaboratoryEdit = new QLineEdit(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
508 ylaboratoryEdit->setObjectName(QString::fromUtf8("ylaboratoryEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
509 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
510 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
511 ylaboratoryEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
512 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
513 yproduct_idEdit->setObjectName(QString::fromUtf8("yproduct_idEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
514 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
515 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
516 yproduct_idEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
517 yselectEdit = new QComboBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
518 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
519 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
520 yinstockEdit = new QCheckBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
521 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
522 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
523 yinstockEdit->setChecked(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
524 yamountEdit = new QDoubleSpinBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
525 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
526 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
527 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
528 yamountEdit->setAccelerated(true);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
529 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
530 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
531 yamountEdit->setSingleStep(1.0);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
532 yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).amount);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
533 } 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
534 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
535 yamountEdit->setSingleStep(0.5);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
536 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
537 } 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
538 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
539 yamountEdit->setSingleStep(0.5);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
540 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
541 }
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
542 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
543 useatEdit = new QComboBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
544 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
545 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
546 useatEdit->addItem(tr("Primary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
547 useatEdit->addItem(tr("Secondary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
548 useatEdit->addItem(tr("Tertiary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
549 useatEdit->addItem(tr("Bottle"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
550 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
551
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
552 yeast_instock_changed(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
553
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
554 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
555 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
556 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
557 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
558 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
559 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
560
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
561 dialog->setModal(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
562 dialog->exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
563 if (dialog->result() == QDialog::Rejected) {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
564 qDebug() << "reject and rollback";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
565 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
566 } else {
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
567
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
568 }
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
569
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
570 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
571 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
572 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
573 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
574 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
575
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
576 emit refreshAll();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
577 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
578
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
579
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
580 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
581 {
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
582 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
583
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
584 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
585 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
586
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
587 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
588 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
589 amount = recipe->yeasts.at(i).amount * factor;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
590 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
591 }
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
592 }
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
593 }
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
594

mercurial