|
1 /** |
|
2 * EditRecipe.cpp is part of bmsapp. |
|
3 * |
|
4 * Tab 1, generic settings. |
|
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 void EditRecipe::name_changed(QString name) |
|
23 { |
|
24 recipe->name = name; |
|
25 is_changed(); |
|
26 } |
|
27 |
|
28 |
|
29 void EditRecipe::notes_changed() |
|
30 { |
|
31 /* The text cannot be passed in a simple way :) */ |
|
32 recipe->notes = ui->notesEdit->toPlainText(); |
|
33 is_changed(); |
|
34 } |
|
35 |
|
36 |
|
37 /* |
|
38 * New beerstyle is selected. |
|
39 */ |
|
40 void EditRecipe::style_changed() |
|
41 { |
|
42 QSqlQuery query; |
|
43 |
|
44 if (ui->beerstyleEdit->currentIndex() < 1) |
|
45 return; |
|
46 |
|
47 query.prepare("SELECT * FROM profile_styles ORDER BY style_guide,style_letter,name"); |
|
48 query.exec(); |
|
49 query.first(); |
|
50 // Skip to the record index. |
|
51 for (int i = 0; i < (ui->beerstyleEdit->currentIndex() - 1); i++) { |
|
52 query.next(); |
|
53 } |
|
54 // Set relevant fields and update ranges. |
|
55 recipe->st_name = query.value(1).toString(); |
|
56 recipe->st_category = query.value(2).toString(); |
|
57 recipe->st_category_number = query.value(3).toInt(); |
|
58 recipe->st_letter = query.value(4).toString(); |
|
59 recipe->st_guide = query.value(5).toString(); |
|
60 recipe->st_type = query.value(6).toInt(); |
|
61 recipe->st_og_min = query.value(7).toDouble(); |
|
62 recipe->st_og_max = query.value(8).toDouble(); |
|
63 recipe->st_fg_min = query.value(9).toDouble(); |
|
64 recipe->st_fg_max = query.value(10).toDouble(); |
|
65 recipe->st_ibu_min = query.value(11).toDouble(); |
|
66 recipe->st_ibu_max = query.value(12).toDouble(); |
|
67 recipe->st_color_min = query.value(13).toDouble(); |
|
68 recipe->st_color_max = query.value(14).toDouble(); |
|
69 recipe->st_carb_min = query.value(15).toDouble(); |
|
70 recipe->st_carb_max = query.value(16).toDouble(); |
|
71 recipe->st_abv_min = query.value(17).toDouble(); |
|
72 recipe->st_abv_max = query.value(18).toDouble(); |
|
73 |
|
74 ui->st_nameEdit->setText(recipe->st_name); |
|
75 ui->st_groupEdit->setText(recipe->st_letter); |
|
76 ui->st_guideEdit->setText(recipe->st_guide); |
|
77 ui->st_catEdit->setText(recipe->st_category); |
|
78 ui->st_catnrEdit->setText(QString("%1").arg(recipe->st_category_number)); |
|
79 ui->st_typeEdit->setText(s_types[recipe->st_type]); |
|
80 |
|
81 ui->est_ogShow->setRange(query.value(7).toDouble(), query.value(8).toDouble()); |
|
82 ui->est_fgShow->setRange(query.value(9).toDouble(), query.value(10).toDouble()); |
|
83 ui->est_ibuShow->setRange(query.value(11).toDouble(), query.value(12).toDouble()); |
|
84 ui->est_colorShow->setRange(query.value(13).toDouble(), query.value(14).toDouble()); |
|
85 ui->est_carbShow->setRange(query.value(15).toDouble(), query.value(16).toDouble()); |
|
86 ui->est_abvShow->setRange(query.value(17).toDouble(), query.value(18).toDouble()); |
|
87 |
|
88 is_changed(); |
|
89 } |
|
90 |
|
91 |
|
92 void EditRecipe::colormethod_changed() |
|
93 { |
|
94 calcFermentables(); |
|
95 is_changed(); |
|
96 } |
|
97 |
|
98 |