Sat, 09 Jul 2022 23:05:25 +0200
Increased some labels sizes.
127 | 1 | /** |
2 | * EditRecipe.cpp is part of bmsapp. | |
3 | * | |
4 | * Tab 3, hops | |
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 | * | |
11 | * bmsapp is distributed in the hope that it will be useful, | |
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 | ||
21 | ||
22 | bool EditRecipe::hop_sort_test(const Hops &D1, const Hops &D2) | |
23 | { | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
24 | if (D1.useat > D2.useat) |
127 | 25 | return false; |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
26 | if (D1.useat < D2.useat) |
127 | 27 | return true; |
28 | /* Same useat moments, test time. */ | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
29 | if (D1.time < D2.time) |
127 | 30 | return false; |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
31 | if (D1.time > D2.time) |
127 | 32 | return true; |
33 | /* Finally consider the amounts */ | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
34 | return (D1.amount > D2.amount); |
127 | 35 | } |
36 | ||
37 | ||
38 | void EditRecipe::refreshHops() | |
39 | { | |
40 | QString w; | |
41 | QWidget* pWidget; | |
42 | QHBoxLayout* pLayout; | |
43 | QTableWidgetItem *item; | |
44 | ||
45 | qDebug() << "refreshHops" << recipe->hops.size(); | |
46 | std::sort(recipe->hops.begin(), recipe->hops.end(), hop_sort_test); | |
47 | ||
48 | const QStringList labels({tr("Origin"), tr("Hop"), tr("Type"), tr("Form"), tr("Alpha"), tr("Use at"), tr("Time"), | |
49 | tr("IBU"), tr("Amount"), tr("Delete"), tr("Edit") }); | |
50 | ||
51 | ui->hopsTable->setColumnCount(11); | |
52 | ui->hopsTable->setColumnWidth(0, 150); /* Origin */ | |
53 | ui->hopsTable->setColumnWidth(1, 225); /* Hop */ | |
131
0115b97e8c39
Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents:
129
diff
changeset
|
54 | ui->hopsTable->setColumnWidth(2, 84); /* Type */ |
0115b97e8c39
Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents:
129
diff
changeset
|
55 | ui->hopsTable->setColumnWidth(3, 84); /* Form */ |
127 | 56 | ui->hopsTable->setColumnWidth(4, 75); /* Alpha% */ |
57 | ui->hopsTable->setColumnWidth(5, 75); /* Added */ | |
58 | ui->hopsTable->setColumnWidth(6, 75); /* Time */ | |
59 | ui->hopsTable->setColumnWidth(7, 60); /* IBU */ | |
131
0115b97e8c39
Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents:
129
diff
changeset
|
60 | ui->hopsTable->setColumnWidth(8, 90); /* Amount */ |
127 | 61 | ui->hopsTable->setColumnWidth(9, 80); /* Delete */ |
62 | ui->hopsTable->setColumnWidth(10, 80); /* Edit */ | |
63 | ui->hopsTable->setHorizontalHeaderLabels(labels); | |
64 | ui->hopsTable->verticalHeader()->hide(); | |
65 | ui->hopsTable->setRowCount(recipe->hops.size()); | |
66 | ||
67 | for (int i = 0; i < recipe->hops.size(); i++) { | |
68 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
69 | ui->hopsTable->setItem(i, 0, new QTableWidgetItem(recipe->hops.at(i).origin)); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
70 | ui->hopsTable->setItem(i, 1, new QTableWidgetItem(recipe->hops.at(i).name)); |
127 | 71 | |
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
72 | item = new QTableWidgetItem(QCoreApplication::translate("HopTypes", g_hop_types[recipe->hops.at(i).type])); |
127 | 73 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
74 | ui->hopsTable->setItem(i, 2, item); | |
75 | ||
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
76 | item = new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[recipe->hops.at(i).form])); |
127 | 77 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
78 | ui->hopsTable->setItem(i, 3, item); | |
79 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
80 | item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(i).alpha, 2, 'f', 1, '0')); |
127 | 81 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
82 | ui->hopsTable->setItem(i, 4, item); | |
83 | ||
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
84 | item = new QTableWidgetItem(QCoreApplication::translate("HopUse", g_hop_useat[recipe->hops.at(i).useat])); |
127 | 85 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
86 | ui->hopsTable->setItem(i, 5, item); | |
87 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
88 | if (recipe->hops.at(i).useat == 2 || recipe->hops.at(i).useat == 4) { // Boil or whirlpool |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
89 | item = new QTableWidgetItem(QString("%1 min.").arg(recipe->hops.at(i).time, 1, 'f', 0, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
90 | } else if (recipe->hops.at(i).useat == 5) { // Dry-hop |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
91 | item = new QTableWidgetItem(QString("%1 days.").arg(recipe->hops.at(i).time / 1440, 1, 'f', 0, '0')); |
127 | 92 | } else { |
93 | item = new QTableWidgetItem(QString("")); | |
94 | } | |
95 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
96 | ui->hopsTable->setItem(i, 6, item); | |
97 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
98 | double ibu = Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).amount, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
99 | recipe->hops.at(i).time, recipe->hops.at(i).alpha, recipe->ibu_method, 0, recipe->hops.at(i).time, |
340
b9af88bfe972
Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
100 | 0, recipe->boil_time, 0, 0, 0); |
127 | 101 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
102 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
103 | ui->hopsTable->setItem(i, 7, item); | |
104 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
105 | if (recipe->hops.at(i).amount < 1.0) { |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
106 | item = new QTableWidgetItem(QString("%1 gr").arg(recipe->hops.at(i).amount * 1000.0, 2, 'f', 1, '0')); |
127 | 107 | } else { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
108 | item = new QTableWidgetItem(QString("%1 kg").arg(recipe->hops.at(i).amount, 4, 'f', 3, '0')); |
127 | 109 | } |
110 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
111 | ui->hopsTable->setItem(i, 8, item); | |
112 | ||
113 | /* Add the Delete row button */ | |
114 | pWidget = new QWidget(); | |
115 | QPushButton* btn_dele = new QPushButton(); | |
116 | btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ | |
117 | btn_dele->setText(tr("Delete")); | |
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
118 | connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_clicked())); |
127 | 119 | pLayout = new QHBoxLayout(pWidget); |
120 | pLayout->addWidget(btn_dele); | |
121 | pLayout->setContentsMargins(5, 0, 5, 0); | |
122 | pWidget->setLayout(pLayout); | |
123 | ui->hopsTable->setCellWidget(i, 9, pWidget); | |
124 | ||
125 | pWidget = new QWidget(); | |
126 | QPushButton* btn_edit = new QPushButton(); | |
127 | btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ | |
128 | btn_edit->setText(tr("Edit")); | |
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
129 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_clicked())); |
127 | 130 | pLayout = new QHBoxLayout(pWidget); |
131 | pLayout->addWidget(btn_edit); | |
132 | pLayout->setContentsMargins(5, 0, 5, 0); | |
133 | pWidget->setLayout(pLayout); | |
134 | ui->hopsTable->setCellWidget(i, 10, pWidget); | |
135 | } | |
136 | } | |
137 | ||
138 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
139 | void EditRecipe::hop_Flavour_valueChanged(int value) |
127 | 140 | { |
141 | if (value < 20) { | |
142 | ui->hop_tasteShow->setStyleSheet(bar_20); | |
230
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
143 | ui->hop_tasteShow->setFormat(tr("Very low")); |
127 | 144 | } else { |
230
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
145 | double s1 = 20.0 / value; |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
146 | if (value < 40) { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
147 | ui->hop_tasteShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
148 | "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #008C00, stop: 1 #008C00);}").arg(s1).arg(s1)); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
149 | ui->hop_tasteShow->setFormat(tr("Low")); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
150 | } else { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
151 | double s2 = 40.0 / value; |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
152 | if (value < 60) { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
153 | ui->hop_tasteShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
154 | "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: 1 #008C00" |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
155 | ");}").arg(s1).arg(s1).arg(s2).arg(s2)); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
156 | ui->hop_tasteShow->setFormat(tr("Moderate")); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
157 | } else { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
158 | double s3 = 60.0 / value; |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
159 | if (value < 80) { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
160 | ui->hop_tasteShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
161 | "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: %5 #008C00, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
162 | "stop: %6 #00AC00, stop: 1 #00AC00" |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
163 | ");}").arg(s1).arg(s1).arg(s2).arg(s2).arg(s3).arg(s3)); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
164 | ui->hop_tasteShow->setFormat(tr("High")); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
165 | } else { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
166 | double s4 = 80.0 / value; |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
167 | ui->hop_tasteShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
168 | "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: %5 #008C00, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
169 | "stop: %6 #00AC00, stop: %7 #00AC00, stop: %8 #00CC00, stop: 1 #00CC00" |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
170 | ");}").arg(s1).arg(s1).arg(s2).arg(s2).arg(s3).arg(s3).arg(s4).arg(s4)); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
171 | ui->hop_tasteShow->setFormat(tr("Very high")); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
172 | } |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
173 | } |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
174 | } |
127 | 175 | } |
176 | } | |
177 | ||
178 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
179 | void EditRecipe::hop_Aroma_valueChanged(int value) |
127 | 180 | { |
181 | if (value < 20) { | |
182 | ui->hop_aromaShow->setStyleSheet(bar_20); | |
183 | ui->hop_aromaShow->setFormat(tr("Very low")); | |
184 | } else { | |
230
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
185 | double s1 = 20.0 / value; |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
186 | if (value < 40) { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
187 | ui->hop_aromaShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
188 | "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #008C00, stop: 1 #008C00);}").arg(s1).arg(s1)); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
189 | ui->hop_aromaShow->setFormat(tr("Low")); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
190 | } else { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
191 | double s2 = 40.0 / value; |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
192 | if (value < 60) { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
193 | ui->hop_aromaShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
194 | "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: 1 #008C00" |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
195 | ");}").arg(s1).arg(s1).arg(s2).arg(s2)); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
196 | ui->hop_aromaShow->setFormat(tr("Moderate")); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
197 | } else { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
198 | double s3 = 60.0 / value; |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
199 | if (value < 80) { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
200 | ui->hop_aromaShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
201 | "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: %5 #008C00, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
202 | "stop: %6 #00AC00, stop: 1 #00AC00" |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
203 | ");}").arg(s1).arg(s1).arg(s2).arg(s2).arg(s3).arg(s3)); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
204 | ui->hop_aromaShow->setFormat(tr("High")); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
205 | } else { |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
206 | double s4 = 80.0 / value; |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
207 | ui->hop_aromaShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
208 | "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: %5 #008C00, " |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
209 | "stop: %6 #00AC00, stop: %7 #00AC00, stop: %8 #00CC00, stop: 1 #00CC00" |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
210 | ");}").arg(s1).arg(s1).arg(s2).arg(s2).arg(s3).arg(s3).arg(s4).arg(s4)); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
211 | ui->hop_aromaShow->setFormat(tr("Very high")); |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
212 | } |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
213 | } |
b68c0c61d261
Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents:
208
diff
changeset
|
214 | } |
127 | 215 | } |
216 | } | |
217 | ||
218 | ||
219 | void EditRecipe::calcIBUs() | |
220 | { | |
221 | double hop_flavour = 0, hop_aroma = 0, ibus = 0; | |
222 | ||
223 | for (int i = 0; i < recipe->hops.size(); i++) { | |
224 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
225 | ibus += Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).amount, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
226 | recipe->hops.at(i).time, recipe->hops.at(i).alpha, recipe->ibu_method, 0, recipe->hops.at(i).time, |
340
b9af88bfe972
Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
227 | 0, recipe->boil_time, 0, 0, 0); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
228 | hop_flavour += Utils::hopFlavourContribution(recipe->hops.at(i).time, recipe->batch_size, recipe->hops.at(i).useat, recipe->hops.at(i).amount); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
229 | hop_aroma += Utils::hopAromaContribution(recipe->hops.at(i).time, recipe->batch_size, recipe->hops.at(i).useat, recipe->hops.at(i).amount); |
127 | 230 | } |
231 | ||
232 | hop_flavour = round(hop_flavour * 1000.0 / 5.0) / 10; | |
233 | hop_aroma = round(hop_aroma * 1000.0 / 6.0) / 10; | |
234 | if (hop_flavour > 100) | |
235 | hop_flavour = 100; | |
236 | if (hop_aroma > 100) | |
237 | hop_aroma = 100; | |
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:
139
diff
changeset
|
238 | qDebug() << "ibu" << recipe->est_ibu << ibus << "flavour" << hop_flavour << "aroma" << hop_aroma << "method" << recipe->ibu_method; |
127 | 239 | |
240 | recipe->est_ibu = ibus; | |
241 | ui->est_ibuEdit->setValue(recipe->est_ibu); | |
242 | ui->est_ibu2Edit->setValue(recipe->est_ibu); | |
151
b5b2483f3a3f
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.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
243 | ui->est_ibuShow->setValue(recipe->est_ibu); |
127 | 244 | ui->hop_tasteShow->setValue(hop_flavour); |
245 | ui->hop_aromaShow->setValue(hop_aroma); | |
246 | } | |
247 | ||
248 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
249 | void EditRecipe::addHopRow_clicked() |
127 | 250 | { |
251 | Hops newh; | |
252 | ||
253 | qDebug() << "Add hop row"; | |
254 | ||
255 | for (int i = 0; i < recipe->hops.size(); i++) { | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
256 | if (recipe->hops.at(i).amount == 0 && recipe->hops.at(i).alpha == 0) |
127 | 257 | return; // Add only one at a time. |
258 | } | |
259 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
260 | newh.name = "Select one"; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
261 | newh.origin = ""; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
262 | newh.amount = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
263 | newh.cost = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
264 | newh.type = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
265 | newh.form = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
266 | newh.useat = 2; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
267 | newh.time = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
268 | newh.alpha = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
269 | newh.beta = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
270 | newh.hsi = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
271 | newh.humulene = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
272 | newh.caryophyllene = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
273 | newh.cohumulone = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
274 | newh.myrcene = 0; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
275 | newh.total_oil = 0; |
129
a9c19eaab018
Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
276 | |
a9c19eaab018
Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
277 | recipe->hops.append(newh); |
127 | 278 | emit refreshAll(); |
279 | } | |
280 | ||
281 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
282 | void EditRecipe::deleteHopRow_clicked() |
127 | 283 | { |
171
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
284 | if (recipe->locked || recipe->hops.size() < 1) |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
285 | return; |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
286 | |
127 | 287 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
288 | int row = pb->objectName().toInt(); | |
289 | qDebug() << "Delete hop row" << row << recipe->hops.size(); | |
290 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
291 | int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(recipe->hops.at(row).name), |
127 | 292 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
293 | if (rc == QMessageBox::No) | |
294 | return; | |
295 | ||
129
a9c19eaab018
Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
296 | recipe->hops.removeAt(row); |
a9c19eaab018
Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
297 | is_changed(); |
a9c19eaab018
Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
298 | emit refreshAll(); |
127 | 299 | } |
300 | ||
301 | ||
302 | void EditRecipe::hop_amount_changed(double val) | |
303 | { | |
304 | QTableWidgetItem *item; | |
305 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
306 | recipe->hops[recipe->hops_row].amount = val / 1000.0; |
127 | 307 | item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0')); |
308 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
309 | ui->hopsTable->setItem(recipe->hops_row, 8, item); | |
310 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
311 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
312 | recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
313 | recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, |
340
b9af88bfe972
Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
314 | 0, recipe->boil_time, 0, 0, 0); |
127 | 315 | |
316 | ibuEdit->setValue(ibu); | |
317 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); | |
318 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
319 | ui->hopsTable->setItem(recipe->hops_row, 7, item); | |
320 | ||
321 | calcIBUs(); | |
322 | is_changed(); | |
323 | } | |
324 | ||
325 | ||
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
326 | void EditRecipe::hop_alpha_changed(double val) |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
327 | { |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
328 | QTableWidgetItem *item; |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
329 | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
330 | recipe->hops[recipe->hops_row].alpha = val; |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
331 | item = new QTableWidgetItem(QString("%1%").arg(val, 2, 'f', 1, '0')); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
332 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
333 | ui->hopsTable->setItem(recipe->hops_row, 4, item); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
334 | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
335 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
336 | recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
337 | recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, |
340
b9af88bfe972
Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
338 | 0, recipe->boil_time, 0, 0, 0); |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
339 | |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
340 | ibuEdit->setValue(ibu); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
341 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
342 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
343 | ui->hopsTable->setItem(recipe->hops_row, 7, item); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
344 | |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
345 | calcIBUs(); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
346 | is_changed(); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
347 | } |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
348 | |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
349 | |
127 | 350 | void EditRecipe::hop_time_changed(int val) |
351 | { | |
352 | QTableWidgetItem *item; | |
353 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
354 | if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) { // Boil or whirlpool |
127 | 355 | item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
356 | recipe->hops[recipe->hops_row].time = val; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
357 | } else if (recipe->hops.at(recipe->hops_row).useat == 5) { // Dry-hop |
164 | 358 | item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
359 | recipe->hops[recipe->hops_row].time = val * 1440; |
127 | 360 | } else { |
361 | item = new QTableWidgetItem(QString("")); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
362 | recipe->hops[recipe->hops_row].time = val; |
127 | 363 | } |
364 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
365 | ui->hopsTable->setItem(recipe->hops_row, 6, item); | |
366 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
367 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
368 | recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
369 | recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, |
340
b9af88bfe972
Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
370 | 0, recipe->boil_time, 0, 0, 0); |
127 | 371 | |
372 | ibuEdit->setValue(ibu); | |
373 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); | |
374 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
375 | ui->hopsTable->setItem(recipe->hops_row, 7, item); | |
376 | ||
377 | calcIBUs(); | |
378 | is_changed(); | |
379 | } | |
380 | ||
381 | ||
382 | void EditRecipe::hop_select_changed(int val) | |
383 | { | |
384 | QSqlQuery query; | |
385 | bool instock = hinstockEdit->isChecked(); | |
386 | QString w; | |
387 | QTableWidgetItem *item; | |
388 | ||
389 | if (val < 1) | |
390 | return; | |
391 | ||
392 | /* | |
393 | * Search the hop pointed by the index and instock flag. | |
394 | */ | |
395 | QString sql = "SELECT name,origin,alpha,beta,humulene,caryophyllene,cohumulone,myrcene,hsi,total_oil,type,form,cost FROM inventory_hops "; | |
396 | if (instock) | |
397 | sql.append("WHERE inventory > 0 "); | |
398 | sql.append("ORDER BY origin,name"); | |
399 | query.prepare(sql); | |
400 | query.exec(); | |
401 | query.first(); | |
402 | for (int i = 0; i < (val - 1); i++) { | |
403 | query.next(); | |
404 | } | |
405 | ||
406 | /* | |
407 | * Replace the hop record contents | |
408 | */ | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
409 | recipe->hops[recipe->hops_row].name = query.value(0).toString(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
410 | recipe->hops[recipe->hops_row].origin = query.value(1).toString(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
411 | recipe->hops[recipe->hops_row].alpha = query.value(2).toDouble(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
412 | recipe->hops[recipe->hops_row].beta = query.value(3).toDouble(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
413 | recipe->hops[recipe->hops_row].humulene = query.value(4).toDouble(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
414 | recipe->hops[recipe->hops_row].caryophyllene = query.value(5).toDouble(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
415 | recipe->hops[recipe->hops_row].cohumulone = query.value(6).toDouble(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
416 | recipe->hops[recipe->hops_row].myrcene = query.value(7).toDouble(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
417 | recipe->hops[recipe->hops_row].hsi = query.value(8).toDouble(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
418 | recipe->hops[recipe->hops_row].total_oil = query.value(9).toDouble(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
419 | recipe->hops[recipe->hops_row].type = query.value(10).toInt(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
420 | recipe->hops[recipe->hops_row].form = query.value(11).toInt(); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
421 | recipe->hops[recipe->hops_row].cost = query.value(12).toDouble(); |
127 | 422 | |
423 | /* | |
424 | * Update the visible fields | |
425 | */ | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
426 | hnameEdit->setText(recipe->hops.at(recipe->hops_row).name); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
427 | horiginEdit->setText(recipe->hops.at(recipe->hops_row).origin); |
127 | 428 | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
429 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
430 | recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
431 | recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, |
340
b9af88bfe972
Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
432 | 0, recipe->boil_time, 0, 0, 0); |
127 | 433 | ibuEdit->setValue(ibu); |
434 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
435 | ui->hopsTable->setItem(recipe->hops_row, 0, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).origin)); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
436 | ui->hopsTable->setItem(recipe->hops_row, 1, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).name)); |
127 | 437 | |
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
438 | QString hoptype = QCoreApplication::translate("HopTypes", g_hop_types[recipe->hops.at(recipe->hops_row).type]); |
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
439 | item = new QTableWidgetItem(hoptype); |
127 | 440 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
441 | ui->hopsTable->setItem(recipe->hops_row, 2, item); | |
442 | ||
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
443 | item = new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[recipe->hops.at(recipe->hops_row).form])); |
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
444 | //item = new QTableWidgetItem(hop_forms[recipe->hops.at(recipe->hops_row).form]); |
127 | 445 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
446 | ui->hopsTable->setItem(recipe->hops_row, 3, item); | |
447 | ||
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
448 | item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(recipe->hops_row).alpha, 2, 'f', 1, '0')); |
127 | 449 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
450 | ui->hopsTable->setItem(recipe->hops_row, 4, item); | |
451 | ||
452 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); | |
453 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
454 | ui->hopsTable->setItem(recipe->hops_row, 7, item); | |
455 | ||
456 | calcIBUs(); | |
457 | is_changed(); | |
458 | } | |
459 | ||
460 | ||
461 | void EditRecipe::hop_instock_changed(bool val) | |
462 | { | |
463 | QSqlQuery query; | |
464 | ||
465 | this->hselectEdit->setCurrentIndex(-1); | |
466 | this->hselectEdit->clear(); | |
467 | QString sql = "SELECT origin,name,alpha,inventory FROM inventory_hops "; | |
468 | if (val) | |
469 | sql.append("WHERE inventory > 0 "); | |
470 | sql.append("ORDER BY origin,name"); | |
471 | query.prepare(sql); | |
472 | query.exec(); | |
473 | query.first(); | |
474 | this->hselectEdit->addItem(""); // Start with empty value | |
475 | for (int i = 0; i < query.size(); i++) { | |
476 | this->hselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+"%) "+ | |
477 | QString("%1 gr").arg(query.value(3).toDouble() * 1000.0, 2, 'f', 1, '0')); | |
478 | query.next(); | |
479 | } | |
480 | } | |
481 | ||
482 | ||
483 | void EditRecipe::hop_useat_changed(int val) | |
484 | { | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
485 | recipe->hops[recipe->hops_row].useat = val; |
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
486 | QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("HopUse", g_hop_useat[val])); |
127 | 487 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
488 | ui->hopsTable->setItem(recipe->hops_row, 5, item); | |
489 | ||
490 | if (val == 2 || val == 4) { // Boil or whirlpool | |
491 | htimeLabel->setText(tr("Time in minutes:")); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
492 | htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time); |
127 | 493 | htimeEdit->setReadOnly(false); |
494 | } else if (val == 5) { // Dry-hop | |
495 | htimeLabel->setText(tr("Time in days:")); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
496 | htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time / 1440); |
127 | 497 | htimeEdit->setReadOnly(false); |
498 | } else { | |
499 | htimeLabel->setText(""); | |
500 | htimeEdit->setValue(0); | |
501 | htimeEdit->setReadOnly(true); | |
502 | } | |
503 | ||
504 | is_changed(); | |
505 | emit refreshAll(); | |
506 | } | |
507 | ||
508 | ||
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
509 | void EditRecipe::hop_form_changed(int val) |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
510 | { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
511 | recipe->hops[recipe->hops_row].form = val; |
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
300
diff
changeset
|
512 | QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[val])); |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
513 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
514 | ui->hopsTable->setItem(recipe->hops_row, 3, item); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
515 | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
516 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
517 | recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
518 | recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, |
340
b9af88bfe972
Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
519 | 0, recipe->boil_time, 0, 0, 0); |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
520 | |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
521 | ibuEdit->setValue(ibu); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
522 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
523 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
524 | ui->hopsTable->setItem(recipe->hops_row, 7, item); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
525 | |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
526 | is_changed(); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
527 | emit refreshAll(); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
528 | } |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
529 | |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
530 | |
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
531 | void EditRecipe::editHopRow_clicked() |
127 | 532 | { |
533 | QSqlQuery query; | |
534 | ||
171
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
535 | if (recipe->locked) |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
536 | return; |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
537 | |
127 | 538 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
539 | recipe->hops_row = pb->objectName().toInt(); | |
540 | qDebug() << "Edit hop row" << recipe->hops_row; | |
541 | Hops backup = recipe->hops.at(recipe->hops_row); | |
542 | ||
543 | QDialog* dialog = new QDialog(this); | |
544 | dialog->resize(738, 260); | |
545 | QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); | |
546 | buttonBox->setObjectName(QString::fromUtf8("buttonBox")); | |
547 | buttonBox->setGeometry(QRect(30, 210, 671, 32)); | |
548 | buttonBox->setLayoutDirection(Qt::LeftToRight); | |
549 | buttonBox->setOrientation(Qt::Horizontal); | |
550 | buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); | |
551 | buttonBox->setCenterButtons(true); | |
552 | QLabel *nameLabel = new QLabel(dialog); | |
553 | nameLabel->setObjectName(QString::fromUtf8("nameLabel")); | |
554 | nameLabel->setText(tr("Current hop:")); | |
555 | nameLabel->setGeometry(QRect(10, 10, 141, 20)); | |
556 | nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
557 | QLabel *originLabel = new QLabel(dialog); | |
558 | originLabel->setObjectName(QString::fromUtf8("originLabel")); | |
559 | originLabel->setText(tr("Origin:")); | |
560 | originLabel->setGeometry(QRect(10, 40, 141, 20)); | |
561 | originLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
562 | QLabel *amountLabel = new QLabel(dialog); | |
563 | amountLabel->setObjectName(QString::fromUtf8("amountLabel")); | |
564 | amountLabel->setText(tr("Amount in gr:")); | |
565 | amountLabel->setGeometry(QRect(10, 100, 141, 20)); | |
566 | amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
567 | QLabel *alphaLabel = new QLabel(dialog); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
568 | alphaLabel->setObjectName(QString::fromUtf8("alphaLabel")); |
263
14d79ec33db4
Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents:
258
diff
changeset
|
569 | alphaLabel->setText(tr("Alpha percent:")); |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
570 | alphaLabel->setGeometry(QRect(420, 100, 121, 20)); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
571 | alphaLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
127 | 572 | htimeLabel = new QLabel(dialog); |
573 | htimeLabel->setObjectName(QString::fromUtf8("htimeLabel")); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
574 | if (recipe->hops.at(recipe->hops_row).useat == 5) // Dry-hop |
127 | 575 | htimeLabel->setText(tr("Time in days:")); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
576 | else if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) // Boil or whirlpool |
127 | 577 | htimeLabel->setText(tr("Time in minutes:")); |
578 | else | |
579 | htimeLabel->setText(""); | |
580 | ||
581 | htimeLabel->setGeometry(QRect(10, 130, 141, 20)); | |
582 | htimeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
583 | QLabel *useatLabel = new QLabel(dialog); | |
584 | useatLabel->setObjectName(QString::fromUtf8("useatLabel")); | |
585 | useatLabel->setText(tr("Use at:")); | |
586 | useatLabel->setGeometry(QRect(10, 160, 141, 20)); | |
587 | useatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
588 | QLabel *formLabel = new QLabel(dialog); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
589 | formLabel->setObjectName(QString::fromUtf8("formLabel")); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
590 | formLabel->setText(tr("Hop form:")); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
591 | formLabel->setGeometry(QRect(380, 160, 121, 20)); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
592 | formLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
127 | 593 | QLabel *selectLabel = new QLabel(dialog); |
594 | selectLabel->setObjectName(QString::fromUtf8("selectLabel")); | |
595 | selectLabel->setText(tr("Select hop:")); | |
596 | selectLabel->setGeometry(QRect(10, 70, 141, 20)); | |
597 | selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
598 | QLabel *instockLabel = new QLabel(dialog); | |
599 | instockLabel->setObjectName(QString::fromUtf8("instockLabel")); | |
600 | instockLabel->setText(tr("In stock:")); | |
601 | instockLabel->setGeometry(QRect(525, 70, 121, 20)); | |
602 | instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
603 | QLabel *ibuLabel = new QLabel(dialog); | |
604 | ibuLabel->setObjectName(QString::fromUtf8("maxLabel")); | |
605 | ibuLabel->setText(tr("Bitterness IBU:")); | |
606 | ibuLabel->setGeometry(QRect(420, 130, 121, 20)); | |
607 | ibuLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
608 | ||
609 | hselectEdit = new QComboBox(dialog); | |
610 | hselectEdit->setObjectName(QString::fromUtf8("selectEdit")); | |
611 | hselectEdit->setGeometry(QRect(160, 70, 371, 23)); | |
612 | ||
613 | hnameEdit = new QLineEdit(dialog); | |
614 | hnameEdit->setObjectName(QString::fromUtf8("hnameEdit")); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
615 | hnameEdit->setText(recipe->hops.at(recipe->hops_row).name); |
127 | 616 | hnameEdit->setGeometry(QRect(160, 10, 511, 23)); |
617 | hnameEdit->setReadOnly(true); | |
618 | horiginEdit = new QLineEdit(dialog); | |
619 | horiginEdit->setObjectName(QString::fromUtf8("horiginEdit")); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
620 | horiginEdit->setText(recipe->hops.at(recipe->hops_row).origin); |
127 | 621 | horiginEdit->setGeometry(QRect(160, 40, 511, 23)); |
622 | horiginEdit->setReadOnly(true); | |
623 | hamountEdit = new QDoubleSpinBox(dialog); | |
624 | hamountEdit->setObjectName(QString::fromUtf8("hamountEdit")); | |
625 | hamountEdit->setGeometry(QRect(160, 100, 121, 24)); | |
626 | hamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
627 | hamountEdit->setAccelerated(true); | |
628 | hamountEdit->setDecimals(1); | |
629 | hamountEdit->setMaximum(1000000.0); | |
630 | hamountEdit->setSingleStep(0.5); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
631 | hamountEdit->setValue(recipe->hops.at(recipe->hops_row).amount * 1000.0); |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
632 | halphaEdit = new QDoubleSpinBox(dialog); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
633 | halphaEdit->setObjectName(QString::fromUtf8("halphaEdit")); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
634 | halphaEdit->setGeometry(QRect(550, 100, 121, 24)); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
635 | halphaEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
636 | halphaEdit->setAccelerated(true); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
637 | halphaEdit->setDecimals(1); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
638 | halphaEdit->setMaximum(100.0); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
639 | halphaEdit->setSingleStep(0.1); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
640 | halphaEdit->setValue(recipe->hops.at(recipe->hops_row).alpha); |
127 | 641 | htimeEdit = new QSpinBox(dialog); |
642 | htimeEdit->setObjectName(QString::fromUtf8("htimeEdit")); | |
643 | htimeEdit->setGeometry(QRect(160, 130, 121, 24)); | |
644 | htimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
645 | htimeEdit->setAccelerated(true); | |
646 | htimeEdit->setMaximum(10000.0); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
647 | if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) { // Boil or whirlpool |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
648 | htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time); |
127 | 649 | htimeEdit->setReadOnly(false); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
650 | } else if (recipe->hops.at(recipe->hops_row).useat == 5){ // Dry-hop |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
651 | htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time / 1440); |
127 | 652 | htimeEdit->setReadOnly(false); |
653 | } else { | |
654 | htimeEdit->setReadOnly(true); | |
655 | } | |
656 | useatEdit = new QComboBox(dialog); | |
657 | useatEdit->setObjectName(QString::fromUtf8("useatEdit")); | |
658 | useatEdit->setGeometry(QRect(160, 160, 161, 23)); | |
659 | useatEdit->addItem(tr("Mash")); | |
660 | useatEdit->addItem(tr("First wort")); | |
661 | useatEdit->addItem(tr("Boil")); | |
662 | useatEdit->addItem(tr("Aroma")); | |
663 | useatEdit->addItem(tr("Whirlpool")); | |
664 | useatEdit->addItem(tr("Dry hop")); | |
300
2a97905cb637
Added hop co2 extract form. Added hop add at bottling needed for iso and tetra hop.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
665 | useatEdit->addItem(tr("Bottling")); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
666 | useatEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).useat); |
127 | 667 | |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
668 | hformEdit = new QComboBox(dialog); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
669 | hformEdit->setObjectName(QString::fromUtf8("formEdit")); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
670 | hformEdit->setGeometry(QRect(510, 160, 161, 23)); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
671 | hformEdit->addItem(tr("Pellet")); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
672 | hformEdit->addItem(tr("Plug")); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
673 | hformEdit->addItem(tr("Leaf")); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
674 | hformEdit->addItem(tr("Wet leaf")); |
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
675 | hformEdit->addItem(tr("Cryo")); |
300
2a97905cb637
Added hop co2 extract form. Added hop add at bottling needed for iso and tetra hop.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
676 | hformEdit->addItem(tr("Extract")); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
677 | hformEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).form); |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
678 | |
127 | 679 | hinstockEdit = new QCheckBox(dialog); |
680 | hinstockEdit->setObjectName(QString::fromUtf8("hinstockEdit")); | |
681 | hinstockEdit->setGeometry(QRect(655, 70, 85, 21)); | |
682 | hinstockEdit->setChecked(true); | |
683 | ||
684 | ibuEdit = new QDoubleSpinBox(dialog); | |
685 | ibuEdit->setObjectName(QString::fromUtf8("ibuEdit")); | |
686 | ibuEdit->setGeometry(QRect(550, 130, 121, 24)); | |
687 | ibuEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
688 | ibuEdit->setReadOnly(true); | |
689 | ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); | |
690 | ibuEdit->setDecimals(1); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
691 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
692 | recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
693 | recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, |
340
b9af88bfe972
Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
694 | 0, recipe->boil_time, 0, 0, 0); |
127 | 695 | ibuEdit->setValue(ibu); |
696 | ||
697 | hop_instock_changed(true); | |
698 | ||
699 | connect(hselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_select_changed); | |
700 | connect(hamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::hop_amount_changed); | |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
701 | connect(halphaEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::hop_alpha_changed); |
127 | 702 | connect(htimeEdit, QOverload<int>::of(&QSpinBox::valueChanged), this, &EditRecipe::hop_time_changed); |
703 | connect(useatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_useat_changed); | |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
704 | connect(hformEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_form_changed); |
127 | 705 | connect(hinstockEdit, &QCheckBox::stateChanged, this, &EditRecipe::hop_instock_changed); |
706 | connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); | |
707 | connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); | |
708 | ||
709 | dialog->setModal(true); | |
710 | dialog->exec(); | |
711 | if (dialog->result() == QDialog::Rejected) { | |
712 | qDebug() << "reject and rollback"; | |
713 | recipe->hops[recipe->hops_row] = backup; | |
714 | } else { | |
715 | /* Clear time if hop is not used for boil, whirlpool or dry-hop. */ | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
716 | if (! (recipe->hops.at(recipe->hops_row).useat == 2 || |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
717 | recipe->hops.at(recipe->hops_row).useat == 4 || |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
718 | recipe->hops.at(recipe->hops_row).useat == 5)) { |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
719 | if (recipe->hops.at(recipe->hops_row).time) { |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
720 | recipe->hops[recipe->hops_row].time = 0; |
127 | 721 | is_changed(); |
722 | } | |
723 | } | |
724 | } | |
725 | ||
726 | disconnect(hselectEdit, nullptr, nullptr, nullptr); | |
727 | disconnect(hamountEdit, nullptr, nullptr, nullptr); | |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
728 | disconnect(halphaEdit, nullptr, nullptr, nullptr); |
127 | 729 | disconnect(htimeEdit, nullptr, nullptr, nullptr); |
730 | disconnect(useatEdit, nullptr, nullptr, nullptr); | |
258
70bb9c3ee60f
In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
731 | disconnect(hformEdit, nullptr, nullptr, nullptr); |
127 | 732 | disconnect(hinstockEdit, nullptr, nullptr, nullptr); |
733 | disconnect(buttonBox, nullptr, nullptr, nullptr); | |
734 | ||
735 | emit refreshAll(); | |
736 | } | |
737 | ||
738 | ||
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:
139
diff
changeset
|
739 | void EditRecipe::adjustHops(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:
139
diff
changeset
|
740 | { |
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:
139
diff
changeset
|
741 | 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:
139
diff
changeset
|
742 | |
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:
139
diff
changeset
|
743 | if (recipe->hops.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:
139
diff
changeset
|
744 | 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:
139
diff
changeset
|
745 | |
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:
139
diff
changeset
|
746 | for (int i = 0; i < recipe->hops.size(); i++) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
747 | amount = recipe->hops.at(i).amount * factor; |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
263
diff
changeset
|
748 | recipe->hops[i].amount = amount; |
150
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
749 | } |
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:
139
diff
changeset
|
750 | } |
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:
139
diff
changeset
|
751 | |
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:
139
diff
changeset
|
752 |