src/EditRecipe.h

changeset 108
ecfcbee4a9b2
parent 107
bb4607e23065
child 109
1ce50e72a6b1
equal deleted inserted replaced
107:bb4607e23065 108:ecfcbee4a9b2
2 #define _EDITRECIPE_H 2 #define _EDITRECIPE_H
3 3
4 #include <QDialog> 4 #include <QDialog>
5 #include <QStringList> 5 #include <QStringList>
6 #include <QJsonDocument> 6 #include <QJsonDocument>
7 7 #include <QJsonObject>
8 8 #include <QDoubleSpinBox>
9 typedef struct f_edit { 9 #include <QCheckBox>
10 int f_row; ///< Row to edit, -1 for insert. 10 #include <QComboBox>
11 QString f_name; ///< Fermentable name 11 #include <QLineEdit>
12 QString f_supplier; ///< Fermentable supplier 12 #include <QDialogButtonBox>
13 double f_max_in_batch; ///< Max percentage in batch 13 #include <QList>
14 double f_percentage; ///< Current percentage in batch 14
15 double f_amount; ///< Amount in kg 15
16 bool f_adjust_to_total_100; ///< Adjust amount/percentage to 100% 16 /*
17 int f_added; ///< When to add fermentable 17 * Fermentables, Hops, Miscs, Yeasts and Mashs are stored in the
18 } fedit; 18 * database in json arrays. These are the QList structures.
19 */
20 struct Fermentables
21 {
22 QString f_name;
23 QString f_origin;
24 QString f_supplier;
25 double f_amount;
26 double f_cost;
27 int f_type;
28 double f_yield;
29 double f_color;
30 double f_coarse_fine_diff;
31 double f_moisture;
32 double f_diastatic_power;
33 double f_protein;
34 double f_dissolved_protein;
35 double f_max_in_batch;
36 int f_graintype;
37 int f_added;
38 bool f_recommend_mash;
39 bool f_add_after_boil;
40 bool f_adjust_to_total_100;
41 double f_percentage;
42 double f_di_ph;
43 double f_acid_to_ph_57;
44 };
45
46
47 struct Hops
48 {
49 QString h_name;
50 QString h_origin;
51 double h_amount;
52 double h_cost;
53 int h_type;
54 int h_form;
55 int h_useat;
56 double h_time;
57 double h_alpha;
58 double h_beta;
59 double h_hsi;
60 double h_humulene;
61 double h_caryophyllene;
62 double h_cohumulone;
63 double h_myrcene;
64 double h_total_oil;
65 };
66
67
68 struct Miscs
69 {
70 QString m_name;
71 double m_amount;
72 int m_type;
73 int m_use_use;
74 int m_time;
75 bool m_amount_is_weight;
76 double m_cost;
77 };
78
79
80 struct Yeasts
81 {
82 QString y_name;
83 QString y_laboratory;
84 QString y_product_id;
85 double y_amount;
86 int y_type;
87 int y_form;
88 double y_min_temperature;
89 double y_max_temperature;
90 int y_flocculation;
91 double y_attenuation;
92 double y_cells;
93 double y_tolerance;
94 double y_inventory;
95 int y_use;
96 bool y_sta1;
97 bool y_bacteria;
98 bool y_harvest_top;
99 double y_harvest_time;
100 double y_pitch_temperature;
101 bool y_pofpos;
102 int y_zymocide;
103 double y_gr_hl_lo;
104 double y_sg_lo;
105 double y_gr_hl_hi;
106 double y_sg_hi;
107 double y_cost;
108 };
109
110
111 struct Mashs
112 {
113 QString step_name;
114 int step_type;
115 double step_volume; // May not be present
116 double step_infuse_amount; // May not be present
117 double step_infuse_temp; // May not be present
118 double step_temp;
119 double step_time;
120 double ramp_time;
121 double end_time;
122 double step_wg_ratio; // May not be present
123 };
124
125
126 /*
127 * The main recipe record stored in the database.
128 */
129 struct Recipe
130 {
131 int record;
132 QString uuid;
133 bool locked;
134 QString st_name;
135 QString st_letter;
136 QString st_guide;
137 QString st_category;
138 int st_category_number;
139 int st_type;
140 double st_og_min;
141 double st_og_max;
142 double st_fg_min;
143 double st_fg_max;
144 double st_ibu_min;
145 double st_ibu_max;
146 double st_color_min;
147 double st_color_max;
148 double st_carb_min;
149 double st_carb_max;
150 double st_abv_min;
151 double st_abv_max;
152
153 QString name;
154 QString notes;
155 int type;
156 double batch_size;
157 double boil_size;
158 double boil_time;
159 double efficiency;
160 double est_og;
161 double est_fg;
162 double est_abv;
163 double est_color;
164 int color_method;
165 double est_ibu;
166 int ibu_method;
167 double est_carb;
168
169 double sparge_temp;
170 double sparge_ph;
171 double sparge_volume;
172 int sparge_source;
173 int sparge_acid_type;
174 double sparge_acid_perc;
175 double sparge_acid_amount;
176 double mash_ph;
177 double mash_name;
178 bool calc_acid;
179
180 QString w1_name; ///< Water source 1
181 double w1_amount;
182 double w1_calcium;
183 double w1_sulfate;
184 double w1_chloride;
185 double w1_sodium;
186 double w1_magnesium;
187 double w1_total_alkalinity;
188 double w1_ph;
189 double w1_cost;
190 QString w2_name; ///< Water source 2
191 double w2_amount;
192 double w2_calcium;
193 double w2_sulfate;
194 double w2_chloride;
195 double w2_sodium;
196 double w2_magnesium;
197 double w2_total_alkalinity;
198 double w2_ph;
199 double w2_cost;
200 double wg_amount; ///< Mixed water
201 double wg_calcium;
202 double wg_sulfate;
203 double wg_chloride;
204 double wg_sodium;
205 double wg_magnesium;
206 double wg_total_alkalinity;
207 double wg_ph;
208 double wb_calcium; ///< Treated water
209 double wb_sulfate;
210 double wb_chloride;
211 double wb_sodium;
212 double wb_magnesium;
213 double wb_total_alkalinity;
214 double wb_ph;
215 double wa_acid_name;
216 double wa_acid_perc;
217 double wa_base_name;
218
219 QList<Fermentables> fermentables;
220 QList<Hops> hops;
221 QList<Miscs> miscs;
222 QList<Yeasts> yeasts;
223 QList<Mashs> mashs;
224 };
19 225
20 226
21 namespace Ui { 227 namespace Ui {
22 class EditRecipe; 228 class EditRecipe;
23 } 229 }
45 void refreshMiscs(); 251 void refreshMiscs();
46 void refreshYeasts(); 252 void refreshYeasts();
47 void refreshMashs(); 253 void refreshMashs();
48 void refreshAll(); 254 void refreshAll();
49 void cell_Fermentable_changed(int nRow, int nCol); 255 void cell_Fermentable_changed(int nRow, int nCol);
256 void ferment_amount_changed(double val);
257 void ferment_pct_changed(double val);
50 void on_deleteFermentRow_clicked(); 258 void on_deleteFermentRow_clicked();
51 void on_editFermentRow_clicked(); 259 void on_editFermentRow_clicked();
52 260
53 void on_perc_mash_valueChanged(int value); 261 void on_perc_mash_valueChanged(int value);
54 void on_perc_sugars_valueChanged(int value); 262 void on_perc_sugars_valueChanged(int value);
62 QStringList f_graintypes = { tr("Base"), tr("Roast"), tr("Crystal"), tr("Kilned"), tr("Sour Malt"), tr("Special"), tr("No malt")}; 270 QStringList f_graintypes = { tr("Base"), tr("Roast"), tr("Crystal"), tr("Kilned"), tr("Sour Malt"), tr("Special"), tr("No malt")};
63 QStringList f_added = { tr("Mash"), tr("Boil"), tr("Fermentation"), tr("Lagering"), tr("Bottle"), tr("Kegs") }; 271 QStringList f_added = { tr("Mash"), tr("Boil"), tr("Fermentation"), tr("Lagering"), tr("Bottle"), tr("Kegs") };
64 QString bar_red = "QProgressBar::chunk {background: #FF0000;}"; 272 QString bar_red = "QProgressBar::chunk {background: #FF0000;}";
65 QString bar_orange = "QProgressBar::chunk {background: #EB7331;}"; 273 QString bar_orange = "QProgressBar::chunk {background: #EB7331;}";
66 QString bar_green = "QProgressBar::chunk {background: #008C00;}"; 274 QString bar_green = "QProgressBar::chunk {background: #008C00;}";
67 int recno, st_type = 0; 275 int recno, editrow;
68 bool textIsChanged = false; 276 bool textIsChanged = false;
69 bool ignoreChanges = false; 277 bool ignoreChanges = false;
278 bool use_to100 = false;
279 Recipe *recipe;
280 /*
281 * Variables for popup ingredients editing.
282 */
70 QJsonDocument fermentables, hops, miscs, yeasts, mashs; 283 QJsonDocument fermentables, hops, miscs, yeasts, mashs;
71 fedit fermentrow, fermentbackup; 284 QJsonObject work, backup;
285 QComboBox *selectEdit, *addedEdit;
286 QLineEdit *nameEdit, *supplierEdit;
287 QDoubleSpinBox *amountEdit, *pctEdit, *maxEdit;
288 QCheckBox *to100Edit, *instockEdit;
72 289
73 void WindowTitle(); 290 void WindowTitle();
74 void fermentable_Json(); 291 void fermentable_Json();
75 void calcFermentables(); 292 void calcFermentables();
76 }; 293 };

mercurial