Thu, 21 Apr 2022 17:22:01 +0200
New recipe, calculate the boil_size. Lot's of ignoreChanges removeals and where needed QSignalBlocker is used. Bottle priming calculation added. In fermentables editor block and release to100 settings only in mash to fermentation steps, bottle and kegging are ignored. Update the IBU slider after hop changes. Set the mash name when another mash profile is selected. Don't backup initial infuse amount if there was no mash table. A small cosmetic layout change on the mash tab.
128 | 1 | /** |
2 | * EditRecipe.cpp is part of bmsapp. | |
3 | * | |
4 | * tab 5, yeasts. | |
5 | * | |
6 | * bmsapp is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License, or | |
9 | * (at your option) any later version. | |
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 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
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 | 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 | 28 | } |
29 | ||
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 | /* |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
42 | * During filling the table turn off the cellChanged signal because every cell that is filled |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
43 | * triggers the cellChanged signal. The QTableWidget has no better signal to use. |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
44 | */ |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
45 | this->ignoreChanges = true; |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
46 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
47 | 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
|
48 | 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
|
49 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
50 | 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
|
51 | 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
|
52 | 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
|
53 | 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
|
54 | 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
|
55 | 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
|
56 | 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
|
57 | 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
|
58 | 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
|
59 | 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
|
60 | 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
|
61 | 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
|
62 | 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
|
63 | 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
|
64 | 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
|
65 | 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
|
66 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
67 | 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
|
68 | |
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, 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
|
70 | 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
|
71 | 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
|
72 | |
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
|
73 | item = new QTableWidgetItem(y_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
|
74 | 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
|
75 | 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
|
76 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
77 | item = new QTableWidgetItem(y_use[recipe->yeasts.at(i).y_use]); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
78 | 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
|
79 | 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
|
80 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
81 | 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
|
82 | 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
|
83 | 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
|
84 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
85 | 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
|
86 | 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
|
87 | 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
|
88 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
89 | 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
|
90 | 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
|
91 | 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
|
92 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | |
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
|
97 | 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
|
98 | 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
|
99 | 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
|
100 | 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
|
101 | else |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
106 | pWidget = new QWidget(); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | 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
|
111 | 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
|
112 | 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
|
113 | 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
|
114 | pWidget->setLayout(pLayout); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
115 | 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
|
116 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
117 | pWidget = new QWidget(); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
118 | 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
|
119 | 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
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | 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
|
124 | 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
|
125 | pWidget->setLayout(pLayout); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
126 | 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
|
127 | } |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
128 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
129 | this->ignoreChanges = false; |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
130 | } |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
131 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
132 | |
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
|
133 | /* |
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 | * 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
|
135 | */ |
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 | 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
|
137 | { |
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 | 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
|
139 | 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
|
140 | 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
|
141 | 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
|
142 | 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
|
143 | 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
|
144 | |
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 | 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
|
146 | 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
|
147 | |
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 | 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
|
149 | 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
|
150 | |
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
141
diff
changeset
|
151 | 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
|
152 | 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
|
153 | 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
|
154 | /* |
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 | * 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
|
156 | * 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
|
157 | */ |
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 | 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
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | 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
|
163 | 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
|
164 | 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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | 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
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | 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
|
173 | 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
|
174 | } 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
|
175 | /* |
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 | * 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
|
177 | * 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
|
178 | * 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
|
179 | */ |
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 | 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
|
181 | 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
|
182 | 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
|
183 | 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
|
184 | 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
|
185 | } 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
|
186 | 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
|
187 | } 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
|
188 | 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
|
189 | if (sg > 1.060) |
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
141
diff
changeset
|
190 | pitchrate = 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
|
191 | } |
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 | 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
|
193 | 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
|
194 | 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
|
195 | 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
|
196 | |
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 | 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
|
198 | 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
|
199 | 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
|
200 | 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
|
201 | 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
|
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 | |
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 | 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
|
205 | 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
|
206 | 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
|
207 | 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
|
208 | |
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
141
diff
changeset
|
209 | 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
|
210 | } |
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
141
diff
changeset
|
211 | 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
|
212 | } |
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
141
diff
changeset
|
213 | } |
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
141
diff
changeset
|
214 | } |
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
141
diff
changeset
|
215 | |
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
141
diff
changeset
|
216 | |
141
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
217 | 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
|
218 | { |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
219 | Yeasts newy; |
141
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
220 | |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
221 | qDebug() << "Add yeast row"; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
222 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
223 | 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
|
224 | 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
|
225 | 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
|
226 | } |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
227 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
228 | 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
|
229 | newy.y_laboratory = ""; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
230 | newy.y_product_id = ""; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
231 | newy.y_amount = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
232 | newy.y_type = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
233 | newy.y_form = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
234 | 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
|
235 | 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
|
236 | newy.y_flocculation = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
237 | newy.y_attenuation = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
238 | newy.y_cells = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
239 | newy.y_tolerance = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
240 | newy.y_inventory = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
241 | newy.y_use = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
242 | newy.y_sta1 = false; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
243 | newy.y_bacteria = false; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
244 | 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
|
245 | 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
|
246 | 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
|
247 | newy.y_pofpos = false; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
248 | newy.y_zymocide = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
249 | 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
|
250 | 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
|
251 | 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
|
252 | 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
|
253 | newy.y_cost = 0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
254 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
255 | recipe->yeasts.append(newy); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
256 | emit refreshAll(); |
141
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 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
259 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
260 | 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
|
261 | { |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
262 | 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
|
263 | 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
|
264 | 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
|
265 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
266 | 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
|
267 | return; |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
268 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
269 | 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
|
270 | 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
|
271 | 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
|
272 | return; |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
273 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
274 | this->ignoreChanges = true; |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
275 | 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
|
276 | this->ignoreChanges = false; |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
277 | is_changed(); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
278 | emit refreshAll(); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
279 | } |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
280 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
281 | |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
282 | 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
|
283 | { |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
284 | QTableWidgetItem *item; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
285 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
286 | 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
|
287 | this->ignoreChanges = true; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
288 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
289 | recipe->yeasts[recipe->yeasts_row].y_amount = val / 1000.0; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
290 | item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0')); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
291 | 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
|
292 | 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
|
293 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
294 | this->ignoreChanges = false; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
295 | calcYeast(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
296 | is_changed(); |
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 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
299 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
300 | 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
|
301 | { |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
302 | QSqlQuery query; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
303 | bool instock = yinstockEdit->isChecked(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
304 | QString w; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
305 | QTableWidgetItem *item; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
306 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
307 | if (val < 1) |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
308 | return; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
309 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
310 | 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
|
311 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
312 | /* |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
313 | * 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
|
314 | */ |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
315 | 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
|
316 | "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
|
317 | "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
|
318 | if (instock) |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
319 | 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
|
320 | 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
|
321 | query.prepare(sql); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
322 | query.exec(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
323 | query.first(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
324 | 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
|
325 | query.next(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
326 | } |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
327 | 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
|
328 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
329 | /* |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
330 | * 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
|
331 | */ |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
332 | this->ignoreChanges = true; |
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_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
|
334 | 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
|
335 | 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
|
336 | 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
|
337 | 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
|
338 | 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
|
339 | 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
|
340 | 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
|
341 | 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
|
342 | 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
|
343 | 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
|
344 | 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
|
345 | 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
|
346 | 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
|
347 | 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
|
348 | 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
|
349 | 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
|
350 | 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
|
351 | 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
|
352 | 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
|
353 | 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
|
354 | 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
|
355 | 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
|
356 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
357 | /* |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
358 | * Update the visible fields |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
359 | */ |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
360 | 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
|
361 | 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
|
362 | 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
|
363 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
364 | 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
|
365 | 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
|
366 | 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
|
367 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
368 | item = new QTableWidgetItem(y_forms[recipe->yeasts.at(recipe->yeasts_row).y_form]); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
369 | 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
|
370 | 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
|
371 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
372 | 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
|
373 | 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
|
374 | 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
|
375 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
376 | 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
|
377 | 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
|
378 | 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
|
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_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
|
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, 7, 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_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
|
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, 8, 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 | this->ignoreChanges = false; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
389 | calcYeast(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
390 | is_changed(); |
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 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
393 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
394 | 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
|
395 | { |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
396 | QSqlQuery query; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
397 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
398 | 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
|
399 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
400 | this->yselectEdit->setCurrentIndex(-1); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
401 | this->yselectEdit->clear(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
402 | 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
|
403 | if (val) |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
404 | 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
|
405 | 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
|
406 | query.prepare(sql); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
407 | query.exec(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
408 | query.first(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
409 | 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
|
410 | 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
|
411 | 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
|
412 | 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
|
413 | query.next(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
414 | } |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
415 | } |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
416 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
417 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
418 | 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
|
419 | { |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
420 | 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
|
421 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
422 | this->ignoreChanges = true; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
423 | recipe->yeasts[recipe->yeasts_row].y_use = val; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
424 | QTableWidgetItem *item = new QTableWidgetItem(y_use[val]); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
425 | 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
|
426 | 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
|
427 | this->ignoreChanges = false; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
428 | is_changed(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
429 | emit refreshAll(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
430 | } |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
431 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
432 | |
141
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
433 | 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
|
434 | { |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
435 | QSqlQuery query; |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
436 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
437 | 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
|
438 | 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
|
439 | 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
|
440 | 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
|
441 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
442 | 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
|
443 | 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
|
444 | 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
|
445 | 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
|
446 | 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
|
447 | 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
|
448 | 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
|
449 | 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
|
450 | buttonBox->setCenterButtons(true); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
451 | |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
452 | 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
|
453 | 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
|
454 | 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
|
455 | 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
|
456 | 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
|
457 | 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
|
458 | 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
|
459 | laboratoryLabel->setText(tr("Laboratory:")); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
460 | 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
|
461 | 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
|
462 | 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
|
463 | 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
|
464 | 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
|
465 | 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
|
466 | 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
|
467 | 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
|
468 | 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
|
469 | 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
|
470 | 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
|
471 | 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
|
472 | 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
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | instockLabel->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 *amountLabel = new QLabel(dialog); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
478 | amountLabel->setObjectName(QString::fromUtf8("amountLabel")); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
479 | amountLabel->setText(tr("Amount in gr:")); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
480 | amountLabel->setGeometry(QRect(10, 130, 141, 20)); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
481 | amountLabel->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
|
482 | 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
|
483 | 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
|
484 | 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
|
485 | 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
|
486 | 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
|
487 | |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
488 | ynameEdit = new QLineEdit(dialog); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
489 | 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
|
490 | 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
|
491 | 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
|
492 | ynameEdit->setReadOnly(true); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
493 | ylaboratoryEdit = new QLineEdit(dialog); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
494 | 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
|
495 | 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
|
496 | 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
|
497 | ylaboratoryEdit->setReadOnly(true); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
498 | 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
|
499 | 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
|
500 | 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
|
501 | 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
|
502 | yproduct_idEdit->setReadOnly(true); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
503 | yselectEdit = new QComboBox(dialog); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
504 | 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
|
505 | 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
|
506 | yinstockEdit = new QCheckBox(dialog); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
507 | 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
|
508 | 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
|
509 | yinstockEdit->setChecked(true); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
510 | yamountEdit = new QDoubleSpinBox(dialog); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
511 | 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
|
512 | 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
|
513 | 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
|
514 | yamountEdit->setAccelerated(true); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
515 | yamountEdit->setDecimals(1); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
516 | yamountEdit->setMaximum(1000000.0); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
517 | yamountEdit->setSingleStep(0.5); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
518 | yamountEdit->setValue(recipe->yeasts.at(recipe->yeasts_row).y_amount * 1000.0); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
519 | useatEdit = new QComboBox(dialog); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
520 | 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
|
521 | 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
|
522 | useatEdit->addItem(tr("Primary")); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
523 | useatEdit->addItem(tr("Secondary")); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
524 | useatEdit->addItem(tr("Tertiary")); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
525 | useatEdit->addItem(tr("Bottle")); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
526 | 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
|
527 | |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
528 | yeast_instock_changed(true); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
529 | |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
530 | 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
|
531 | 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
|
532 | 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
|
533 | 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
|
534 | 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
|
535 | 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
|
536 | |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
537 | dialog->setModal(true); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
538 | dialog->exec(); |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
539 | 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
|
540 | qDebug() << "reject and rollback"; |
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
541 | 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
|
542 | } else { |
141
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
543 | |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
544 | } |
141
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
545 | |
143
8414844c9f8b
Added all yeast edit functions and the popup editor window.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
546 | 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
|
547 | 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
|
548 | 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
|
549 | 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
|
550 | 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
|
551 | |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
552 | emit refreshAll(); |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
553 | } |
eea8a9e7e1f6
Upgrade yeasts fields if needed during recipe startup. Added yeast table.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
554 | |
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
|
555 | |
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
|
556 | 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
|
557 | { |
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
|
558 | 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
|
559 | |
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
|
560 | 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
|
561 | 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
|
562 | |
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
|
563 | 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
|
564 | 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
|
565 | 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
|
566 | 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
|
567 | } |
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
|
568 | } |
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
|
569 | } |
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
|
570 |