src/EditRecipeTab5.cpp

Sat, 23 Apr 2022 13:18:47 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 23 Apr 2022 13:18:47 +0200
changeset 154
1af9f7b7f317
parent 152
58e4ce7dd217
child 171
6cd2d808d863
permissions
-rw-r--r--

Moved QStringList arrays to global.

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 {
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
23 if (D1.y_use > D2.y_use)
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
24 return false;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
25 if (D1.y_use < D2.y_use)
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
26 return true;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
27 return (D1.y_amount > D2.y_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
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
63 ui->yeastsTable->setItem(i, 0, new QTableWidgetItem(recipe->yeasts.at(i).y_name));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
64 ui->yeastsTable->setItem(i, 1, new QTableWidgetItem(recipe->yeasts.at(i).y_laboratory));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
65 ui->yeastsTable->setItem(i, 2, new QTableWidgetItem(recipe->yeasts.at(i).y_product_id));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
66
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
67 item = new QTableWidgetItem(yeast_forms[recipe->yeasts.at(i).y_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
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
71 item = new QTableWidgetItem(yeast_use[recipe->yeasts.at(i).y_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
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
75 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).y_min_temperature, 2, 'f', 1, '0'));
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
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
79 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).y_max_temperature, 2, 'f', 1, '0'));
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
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
83 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).y_tolerance, 2, 'f', 1, '0'));
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
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
87 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).y_attenuation, 2, 'f', 1, '0'));
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
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
91 if (recipe->yeasts.at(i).y_form == 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
92 item = new QTableWidgetItem(QString("%1 pack").arg(recipe->yeasts.at(i).y_amount, 1, 'f', 0, '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
93 else if (recipe->yeasts.at(i).y_form == 1)
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
94 item = new QTableWidgetItem(QString("%1 gr").arg(recipe->yeasts.at(i).y_amount * 1000.0, 3, 'f', 2, '0'));
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
95 else
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
96 item = new QTableWidgetItem(QString("%1 ml").arg(recipe->yeasts.at(i).y_amount * 1000.0, 3, 'f', 2, '0'));
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++) {
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
144 if (recipe->yeasts.at(i).y_use == 0) { // Primary
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
145 if (recipe->yeasts.at(i).y_form == 1) {
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);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
151 ui->lo_gr_hlEdit->setValue(recipe->yeasts.at(i).y_gr_hl_lo);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
152 ui->hi_gr_hlEdit->setValue(recipe->yeasts.at(i).y_gr_hl_hi);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
153 ui->lo_sgEdit->setValue(recipe->yeasts.at(i).y_sg_lo);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
154 ui->hi_sgEdit->setValue(recipe->yeasts.at(i).y_sg_hi);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
155 double og = recipe->yeasts.at(i).y_sg_lo;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
156 double f1 = recipe->yeasts.at(i).y_gr_hl_lo / 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
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);
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
173 if (recipe->yeasts.at(i).y_type == 0) { // Lager yeast
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;
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
177 } else if (recipe->yeasts.at(i).y_type == 6) { // Real Kveik
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 }
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
184 if (recipe->yeasts.at(i).y_form == 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
185 initcells = (recipe->yeasts.at(i).y_cells / 1000000000) * recipe->yeasts.at(i).y_amount * 0.97; // 97% viability assumed.
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
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
187 initcells = (recipe->yeasts.at(i).y_cells / 1000000) * recipe->yeasts.at(i).y_amount * 0.97;
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 }
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
206 }
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
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
209 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
210 {
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
211 Yeasts newy;
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
212
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
213 qDebug() << "Add yeast row";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
214
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
215 for (int i = 0; i < recipe->yeasts.size(); i++) {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
216 if (recipe->yeasts.at(i).y_amount == 0)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
217 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
218 }
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 newy.y_name = "Select one";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
221 newy.y_laboratory = "";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
222 newy.y_product_id = "";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
223 newy.y_amount = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
224 newy.y_type = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
225 newy.y_form = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
226 newy.y_min_temperature = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
227 newy.y_max_temperature = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
228 newy.y_flocculation = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
229 newy.y_attenuation = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
230 newy.y_cells = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
231 newy.y_tolerance = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
232 newy.y_inventory = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
233 newy.y_use = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
234 newy.y_sta1 = false;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
235 newy.y_bacteria = false;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
236 newy.y_harvest_top = false;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
237 newy.y_harvest_time = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
238 newy.y_pitch_temperature = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
239 newy.y_pofpos = false;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
240 newy.y_zymocide = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
241 newy.y_gr_hl_lo = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
242 newy.y_sg_lo = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
243 newy.y_gr_hl_hi = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
244 newy.y_sg_hi = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
245 newy.y_cost = 0;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
246
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
247 recipe->yeasts.append(newy);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
248 emit refreshAll();
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
249 }
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 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
253 {
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
254 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
255 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
256 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
257
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
258 if (recipe->yeasts.size() < 1)
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
259 return;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
260
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
261 int rc = QMessageBox::warning(this, tr("Delete yeast"), tr("Delete %1").arg(recipe->yeasts.at(row).y_name),
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
262 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
263 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
264 return;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
265
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
266 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
267 is_changed();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
268 emit refreshAll();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
269 }
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
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
272 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
273 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
274 QTableWidgetItem *item;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
275
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
276 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
277
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
278 if (recipe->yeasts.at(recipe->yeasts_row).y_form == 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
279 recipe->yeasts[recipe->yeasts_row].y_amount = val;
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
280 item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '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
281 } else if (recipe->yeasts.at(recipe->yeasts_row).y_form == 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
282 recipe->yeasts[recipe->yeasts_row].y_amount = val / 1000.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
283 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
284 } 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
285 recipe->yeasts[recipe->yeasts_row].y_amount = val / 1000.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
286 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
287 }
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
288 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
289 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
290
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
291 calcYeast();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
292 is_changed();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
293 }
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 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
297 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
298 QSqlQuery query;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
299 bool instock = yinstockEdit->isChecked();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
300 QString w;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
301 QTableWidgetItem *item;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
302
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
303 if (val < 1)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
304 return;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
305
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
306 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
307
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 * 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
310 */
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
311 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
312 "cells,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide,"
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
313 "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost FROM inventory_yeasts ";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
314 if (instock)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
315 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
316 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
317 query.prepare(sql);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
318 query.exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
319 query.first();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
320 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
321 query.next();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
322 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
323 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
324
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 * 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
327 */
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
328 recipe->yeasts[recipe->yeasts_row].y_name = query.value(0).toString();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
329 recipe->yeasts[recipe->yeasts_row].y_laboratory = query.value(1).toString();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
330 recipe->yeasts[recipe->yeasts_row].y_product_id = query.value(2).toString();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
331 recipe->yeasts[recipe->yeasts_row].y_type = query.value(3).toInt();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
332 recipe->yeasts[recipe->yeasts_row].y_form = query.value(4).toInt();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
333 recipe->yeasts[recipe->yeasts_row].y_min_temperature = query.value(5).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
334 recipe->yeasts[recipe->yeasts_row].y_max_temperature = query.value(6).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
335 recipe->yeasts[recipe->yeasts_row].y_flocculation = query.value(7).toInt();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
336 recipe->yeasts[recipe->yeasts_row].y_attenuation = query.value(8).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
337 recipe->yeasts[recipe->yeasts_row].y_cells = query.value(9).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
338 recipe->yeasts[recipe->yeasts_row].y_tolerance = query.value(10).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
339 recipe->yeasts[recipe->yeasts_row].y_sta1 = query.value(11).toInt() ? true:false;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
340 recipe->yeasts[recipe->yeasts_row].y_bacteria = query.value(12).toInt() ? true:false;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
341 recipe->yeasts[recipe->yeasts_row].y_harvest_top = query.value(13).toInt() ? true:false;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
342 recipe->yeasts[recipe->yeasts_row].y_harvest_time = query.value(14).toInt();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
343 recipe->yeasts[recipe->yeasts_row].y_pitch_temperature = query.value(15).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
344 recipe->yeasts[recipe->yeasts_row].y_pofpos = query.value(16).toInt() ? true:false;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
345 recipe->yeasts[recipe->yeasts_row].y_zymocide = query.value(17).toInt();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
346 recipe->yeasts[recipe->yeasts_row].y_gr_hl_lo = query.value(18).toInt();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
347 recipe->yeasts[recipe->yeasts_row].y_sg_lo = query.value(19).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
348 recipe->yeasts[recipe->yeasts_row].y_gr_hl_hi = query.value(20).toInt();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
349 recipe->yeasts[recipe->yeasts_row].y_sg_hi = query.value(21).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
350 recipe->yeasts[recipe->yeasts_row].y_cost = query.value(22).toDouble();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
351
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 * Update the visible fields
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
354 */
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
355 ynameEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_name);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
356 ylaboratoryEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_laboratory);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
357 yproduct_idEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_product_id);
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
358 if (recipe->yeasts.at(recipe->yeasts_row).y_form == 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
359 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
360 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
361 yamountLabel->setText(tr("Total packs:"));
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 } else if (recipe->yeasts.at(recipe->yeasts_row).y_form == 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
363 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
364 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
365 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
366 } 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
367 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
368 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
369 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
370 }
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
371
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
372 ui->yeastsTable->setItem(recipe->yeasts_row, 0, new QTableWidgetItem(recipe->yeasts.at(recipe->yeasts_row).y_name));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
373 ui->yeastsTable->setItem(recipe->yeasts_row, 1, new QTableWidgetItem(recipe->yeasts.at(recipe->yeasts_row).y_laboratory));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
374 ui->yeastsTable->setItem(recipe->yeasts_row, 2, new QTableWidgetItem(recipe->yeasts.at(recipe->yeasts_row).y_product_id));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
375
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
376 item = new QTableWidgetItem(yeast_forms[recipe->yeasts.at(recipe->yeasts_row).y_form]);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
377 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
378 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
379
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
380 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).y_min_temperature, 2, 'f', 1, '0'));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
381 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
382 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
383
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
384 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).y_max_temperature, 2, 'f', 1, '0'));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
385 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
386 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
387
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
388 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).y_tolerance, 2, 'f', 1, '0'));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
389 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
390 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
391
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
392 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).y_attenuation, 2, 'f', 1, '0'));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
393 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
394 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
395
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
396 calcYeast();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
397 is_changed();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
398 }
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 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
402 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
403 QSqlQuery query;
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
404
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
405 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
406
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
407 this->yselectEdit->setCurrentIndex(-1);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
408 this->yselectEdit->clear();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
409 QString sql = "SELECT name,laboratory,product_id,inventory FROM inventory_yeasts ";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
410 if (val)
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
411 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
412 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
413 query.prepare(sql);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
414 query.exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
415 query.first();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
416 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
417 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
418 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
419 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
420 query.next();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
421 }
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 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
426 {
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
427 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
428
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
429 recipe->yeasts[recipe->yeasts_row].y_use = val;
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
430 QTableWidgetItem *item = new QTableWidgetItem(yeast_use[val]);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
431 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
432 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
433 is_changed();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
434 emit refreshAll();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
435 }
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
436
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
437
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
438 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
439 {
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
440 QSqlQuery query;
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
441
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
442 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
443 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
444 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
445 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
446
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
447 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
448 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
449 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
450 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
451 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
452 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
453 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
454 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
455 buttonBox->setCenterButtons(true);
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
456
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
457 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
458 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
459 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
460 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
461 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
462 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
463 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
464 laboratoryLabel->setText(tr("Laboratory:"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
465 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
466 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
467 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
468 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
469 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
470 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
471 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
472 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
473 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
474 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
475 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
476 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
477 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
478 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
479 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
480 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
481 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
482 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
483 yamountLabel->setObjectName(QString::fromUtf8("amountLabel"));
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
484 if (recipe->yeasts.at(recipe->yeasts_row).y_form == 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
485 yamountLabel->setText(tr("Total packs:"));
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 else if (recipe->yeasts.at(recipe->yeasts_row).y_form == 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
487 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
488 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
489 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
490 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
491 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
492 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
493 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
494 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
495 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
496 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
497
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
498 ynameEdit = new QLineEdit(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
499 ynameEdit->setObjectName(QString::fromUtf8("ynameEdit"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
500 ynameEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_name);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
501 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
502 ynameEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
503 ylaboratoryEdit = new QLineEdit(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
504 ylaboratoryEdit->setObjectName(QString::fromUtf8("ylaboratoryEdit"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
505 ylaboratoryEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_laboratory);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
506 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
507 ylaboratoryEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
508 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
509 yproduct_idEdit->setObjectName(QString::fromUtf8("yproduct_idEdit"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
510 yproduct_idEdit->setText(recipe->yeasts.at(recipe->yeasts_row).y_product_id);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
511 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
512 yproduct_idEdit->setReadOnly(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
513 yselectEdit = new QComboBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
514 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
515 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
516 yinstockEdit = new QCheckBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
517 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
518 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
519 yinstockEdit->setChecked(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
520 yamountEdit = new QDoubleSpinBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
521 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
522 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
523 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
524 yamountEdit->setAccelerated(true);
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
525 if (recipe->yeasts.at(recipe->yeasts_row).y_form == 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
526 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
527 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
528 yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).y_amount);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
529 } else if (recipe->yeasts.at(recipe->yeasts_row).y_form == 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
530 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
531 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
532 yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).y_amount * 1000.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
533 } 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
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);
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
536 yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).y_amount * 1000.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
537 }
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->setMaximum(1000000000.0);
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
539 useatEdit = new QComboBox(dialog);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
540 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
541 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
542 useatEdit->addItem(tr("Primary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
543 useatEdit->addItem(tr("Secondary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
544 useatEdit->addItem(tr("Tertiary"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
545 useatEdit->addItem(tr("Bottle"));
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
546 useatEdit->setCurrentIndex(recipe->yeasts.at(recipe->yeasts_row).y_use);
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
547
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
548 yeast_instock_changed(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
549
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
550 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
551 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
552 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
553 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
554 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
555 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
556
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
557 dialog->setModal(true);
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
558 dialog->exec();
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
559 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
560 qDebug() << "reject and rollback";
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
561 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
562 } else {
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
563
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
564 }
141
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
565
143
8414844c9f8b Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
566 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
567 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
568 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
569 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
570 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
571
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
572 emit refreshAll();
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
573 }
eea8a9e7e1f6 Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
574
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
575
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
576 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
577 {
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
578 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
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 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
581 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
582
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 for (int i = 0; i < recipe->yeasts.size(); i++) {
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.at(i).y_form == 1) { // Only adjust dry yeast
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 amount = recipe->yeasts.at(i).y_amount * 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
586 recipe->yeasts[i].y_amount = 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
587 }
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
588 }
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
589 }
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
590

mercurial