src/EditRecipeTab2.cpp

Tue, 07 Jun 2022 09:48:35 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 07 Jun 2022 09:48:35 +0200
changeset 264
67b5c00dd23c
parent 229
815ee118ad49
child 283
242a68fa7186
permissions
-rw-r--r--

Added slots for sparge water volume and temperature.

127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditRecipe.cpp is part of bmsapp.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
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
4 * Tab 2, fermentables
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the hope that it will be useful,
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 bool EditRecipe::ferment_sort_test(const Fermentables &D1, const Fermentables &D2)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 {
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
24 if (D1.f_added > D2.f_added)
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
25 return false;
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
26 if (D1.f_added < D2.f_added)
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
27 return true;
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
28 return (D1.f_amount >= D2.f_amount) && (D1.f_color < D2.f_color);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 void EditRecipe::to100Fermentables(int row)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 if (recipe->fermentables.at(row).f_adjust_to_total_100) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 QWidget *pWidget = new QWidget();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 QLabel *label = new QLabel;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 label->setPixmap(QPixmap(":icons/silk/tick.png"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 QHBoxLayout *pLayout = new QHBoxLayout(pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 pLayout->addWidget(label);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 pLayout->setAlignment(Qt::AlignCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 pLayout->setContentsMargins(0, 0, 0, 0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 pWidget->setLayout(pLayout);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 ui->fermentablesTable->setCellWidget(row, 9, pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 ui->fermentablesTable->removeCellWidget(row, 9);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 void EditRecipe::refreshFermentables()
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 QString w;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 QWidget* pWidget;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 QHBoxLayout* pLayout;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 QTableWidgetItem *item;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 qDebug() << "refreshFermentables" << recipe->fermentables.size();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 std::sort(recipe->fermentables.begin(), recipe->fermentables.end(), ferment_sort_test);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 const QStringList labels({tr("Supplier"), tr("Fermentable"), tr("EBC"), tr("Type"), tr("Graintype"), tr("When"), tr("Yield"),
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 tr("Amount"), tr("Procent"), tr("100%"), tr("Delete"), tr("Edit") });
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 ui->fermentablesTable->setColumnCount(12);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 ui->fermentablesTable->setColumnWidth(0, 150); /* Supplier */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 ui->fermentablesTable->setColumnWidth(1, 225); /* Fermentable */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 ui->fermentablesTable->setColumnWidth(2, 50); /* Color */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 ui->fermentablesTable->setColumnWidth(3, 75); /* Type */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 ui->fermentablesTable->setColumnWidth(4, 75); /* Graintype */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 ui->fermentablesTable->setColumnWidth(5, 82); /* Added */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 ui->fermentablesTable->setColumnWidth(6, 60); /* Yield */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 ui->fermentablesTable->setColumnWidth(7, 90); /* Amount */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 ui->fermentablesTable->setColumnWidth(8, 60); /* Procent */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 ui->fermentablesTable->setColumnWidth(9, 50); /* 100% */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 ui->fermentablesTable->setColumnWidth(10, 80); /* Delete */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 ui->fermentablesTable->setColumnWidth(11, 80); /* Edit */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 ui->fermentablesTable->setHorizontalHeaderLabels(labels);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 ui->fermentablesTable->verticalHeader()->hide();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 ui->fermentablesTable->setRowCount(recipe->fermentables.size());
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 for (int i = 0; i < recipe->fermentables.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 ui->fermentablesTable->setItem(i, 0, new QTableWidgetItem(recipe->fermentables.at(i).f_supplier));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 ui->fermentablesTable->setItem(i, 1, new QTableWidgetItem(recipe->fermentables.at(i).f_name));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 w = QString("%1").arg(recipe->fermentables.at(i).f_color, 1, 'f', 0, '0');
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 item = new QTableWidgetItem(w);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 ui->fermentablesTable->setItem(i, 2, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
89 item = new QTableWidgetItem(fermentable_types[recipe->fermentables.at(i).f_type]);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 ui->fermentablesTable->setItem(i, 3, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
93 item = new QTableWidgetItem(fermentable_graintypes[recipe->fermentables.at(i).f_graintype]);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 ui->fermentablesTable->setItem(i, 4, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
97 item = new QTableWidgetItem(fermentable_added[recipe->fermentables.at(i).f_added]);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 ui->fermentablesTable->setItem(i, 5, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables.at(i).f_yield, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 ui->fermentablesTable->setItem(i, 6, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 item = new QTableWidgetItem(QString("%1 Kg").arg(recipe->fermentables.at(i).f_amount, 4, 'f', 3, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 ui->fermentablesTable->setItem(i, 7, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 if (recipe->fermentables.at(i).f_added < 4) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables.at(i).f_percentage, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 item = new QTableWidgetItem(QString("")); // Blank for bottling and kegging.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 ui->fermentablesTable->setItem(i, 8, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 to100Fermentables(i);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 /* Add the Delete row button */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 pWidget = new QWidget();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 QPushButton* btn_dele = new QPushButton();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 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: 132
diff changeset
124 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteFermentRow_clicked()));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 pLayout = new QHBoxLayout(pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 pLayout->addWidget(btn_dele);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 pLayout->setContentsMargins(5, 0, 5, 0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 pWidget->setLayout(pLayout);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 ui->fermentablesTable->setCellWidget(i, 10, pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 pWidget = new QWidget();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 QPushButton* btn_edit = new QPushButton();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 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: 132
diff changeset
135 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editFermentRow_clicked()));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 pLayout = new QHBoxLayout(pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 pLayout->addWidget(btn_edit);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 pLayout->setContentsMargins(5, 0, 5, 0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 pWidget->setLayout(pLayout);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 ui->fermentablesTable->setCellWidget(i, 11, pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 void EditRecipe::calcFermentables()
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 int i;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 double psugar = 0, pcara = 0, d, s = 0, x, color;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 double vol = 0; // Volume sugars after boil
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 double addedS = 0; // Added sugars after boil
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 double addedmass = 0; // Added mass after boil
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 double mvol = 0; // Mash volume
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 double lintner = 0; // Total recipe lintner
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 double sugarsf = 0; // fermentable sugars mash + boil
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 double sugarsm = 0; // fermentable sugars in mash
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 double sugardensity = 1.611; // kg/l in solution
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 double mashtime = 0; // Total mash time
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 double mashtemp = 0; // Average mash temperature
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 double mashinfuse = 0; // Mash infuse amount
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 double colort = 0; // Colors srm * vol totals
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 double colorh = 0; // Colors ebc * vol * kt
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 double colorn = 0; // Colors ebc * pt * pct
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 qDebug() << "calcFermentables()";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 * Get average mashtemp and mashtime from the Mash schedule.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 * It is possible that the schedule is not (yet) present.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 if (recipe->mashs.size() > 0) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 for (i = 0; i < recipe->mashs.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 if (recipe->mashs.at(i).step_type == 0) // Infusion
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 mashinfuse += recipe->mashs.at(i).step_infuse_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 if (recipe->mashs.at(i).step_temp < 75) { // Ignore mashout
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 mashtime += recipe->mashs.at(i).step_time;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 mashtemp += recipe->mashs.at(i).step_time * recipe->mashs.at(i).step_temp;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 mashtemp = mashtemp / mashtime;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 mvol = mashinfuse;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 qDebug() << " mash time" << mashtime << "temp" << mashtemp << "infuse" << mashinfuse;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 qDebug() << " no mash schedule";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185
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
186 const QSignalBlocker blocker1(ui->est_ogEdit);
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
187 const QSignalBlocker blocker2(ui->est_og2Edit);
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
188
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 if (recipe->fermentables.size() < 1) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 qDebug() << " no fermentables, return.";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 recipe->est_og = 0.980;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 ui->est_ogEdit->setValue(0.980);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 ui->est_og2Edit->setValue(0.980);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 ui->est_og3Edit->setValue(0.980);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 ui->est_ogShow->setValue(0.980);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 recipe->est_color = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 ui->est_colorEdit->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(0));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 ui->est_color2Edit->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(0));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 ui->est_colorShow->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 ui->perc_mashShow->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 ui->perc_sugarsShow->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 ui->perc_caraShow->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 ui->lintnerShow->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 recipe->est_fg = 0.980;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 ui->est_fgEdit->setValue(0.980);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 ui->est_fg3Edit->setValue(0.980);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 ui->est_fgShow->setValue(0.980);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 ui->est_abvEdit->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 ui->est_abv2Edit->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 ui->est_abvShow->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 recipe->est_abv = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 ui->calEdit->setValue(0);
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
215 recipe->mashs_kg = 0;
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 qDebug() << " adjust to 100" << recipe->fermentables_use100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
220 recipe->mashs_kg = 0;
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 for (i = 0; i < recipe->fermentables.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 if (recipe->fermentables.at(i).f_type == 1 && recipe->fermentables.at(i).f_added < 4) // Sugars
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 psugar += recipe->fermentables.at(i).f_percentage;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 if (recipe->fermentables.at(i).f_graintype == 2 && recipe->fermentables.at(i).f_added < 4) // Crystal/Cara
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 pcara += recipe->fermentables.at(i).f_percentage;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 d = recipe->fermentables.at(i).f_amount * (recipe->fermentables.at(i).f_yield / 100) * (1 - recipe->fermentables.at(i).f_moisture / 100);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 if (recipe->fermentables.at(i).f_added == 0) { // Mash
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 if (mvol > 0) { // If mash volume is known
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 mvol += recipe->fermentables.at(i).f_amount * recipe->fermentables.at(i).f_moisture / 100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 s += d;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 d = ui->efficiencyEdit->value() / 100 * d;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 sugarsm += d;
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
234 recipe->mashs_kg += recipe->fermentables.at(i).f_amount;
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 if (recipe->fermentables.at(i).f_added == 0 || recipe->fermentables.at(i).f_added == 1) // Mash or boil
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 sugarsf += d;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 if (recipe->fermentables.at(i).f_added == 2 || recipe->fermentables.at(i).f_added == 3) { // Fermentation or lagering
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 x = (recipe->fermentables.at(i).f_yield / 100) * (1 - recipe->fermentables.at(i).f_moisture / 100);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 addedS += recipe->fermentables.at(i).f_amount * x;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 addedmass += recipe->fermentables.at(i).f_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 vol += (x * sugardensity + (1 - x) * 1) * recipe->fermentables.at(i).f_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 if (recipe->fermentables.at(i).f_added == 0 &&
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 (recipe->fermentables.at(i).f_type == 0 || recipe->fermentables.at(i).f_type == 4) &&
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 recipe->fermentables.at(i).f_color < 50) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 lintner += recipe->fermentables.at(i).f_diastatic_power * recipe->fermentables.at(i).f_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 if (recipe->fermentables.at(i).f_added < 4) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 colort += recipe->fermentables.at(i).f_amount * Utils::ebc_to_srm(recipe->fermentables.at(i).f_color);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 colorh += recipe->fermentables.at(i).f_amount * recipe->fermentables.at(i).f_color * Utils::get_kt(recipe->fermentables.at(i).f_color);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 colorn += (recipe->fermentables.at(i).f_percentage / 100) * recipe->fermentables.at(i).f_color; // For 8.6 Pt wort.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 qDebug() << " colort" << colort << "colorh" << colorh << "colorn" << colorn;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 qDebug() << " psugar" << psugar << "pcara" << pcara << "mvol" << mvol;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 qDebug() << " sugarsf" << sugarsf << "sugarsm" << sugarsm;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258
167
5093db5665c6 Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
259 double og = Utils::estimate_sg(sugarsf + addedS, recipe->batch_size);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 qDebug() << " OG" << ui->est_ogEdit->value() << og;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 recipe->est_og = og;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 ui->est_ogEdit->setValue(og);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 ui->est_og2Edit->setValue(og);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 ui->est_og3Edit->setValue(og);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 ui->est_ogShow->setValue(og);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266
167
5093db5665c6 Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
267 recipe->preboil_sg = Utils::estimate_sg(sugarsm, recipe->boil_size);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 qDebug() << " preboil SG" << recipe->preboil_sg;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 * Color of the wort
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 */
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: 148
diff changeset
273 if (recipe->color_method == 4) { // Naudts
167
5093db5665c6 Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
274 color = round(((Utils::sg_to_plato(og) / 8.6) * colorn) + (recipe->boil_time / 60));
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: 148
diff changeset
275 } else if (recipe->color_method == 3) { // Hans Halberstadt
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 double bv = 0.925; // Beer loss efficiency
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 double sr = 0.95; // Mash and sparge efficiency
167
5093db5665c6 Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
278 color = round((4.46 * bv * sr) / recipe->batch_size * colorh);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 } else {
167
5093db5665c6 Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
280 double cw = colort / recipe->batch_size * 8.34436;
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: 148
diff changeset
281 color = Utils::kw_to_ebc(recipe->color_method, cw);
168
4bc92122d001 Added kw_to_newebc function to debug EBC differences.
Michiel Broek <mbroek@mbse.eu>
parents: 167
diff changeset
282 //qDebug() << " oud EBC" << color << "new EBC" << Utils::kw_to_newebc(recipe->color_method, cw) << "SRM" << Utils::kw_to_srm(recipe->color_method, cw);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 qDebug() << " color" << ui->est_colorEdit->value() << color << recipe->est_color;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 recipe->est_color = color;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 ui->est_colorEdit->setValue(color);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 ui->est_color2Edit->setValue(color);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 ui->est_colorShow->setValue(color);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 * We don't have a equipment profile in recipes,
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 * so we assume a certain guessed mashtun size.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 */
167
5093db5665c6 Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
296 ui->perc_mashShow->setValue(round(recipe->mashs_kg / (recipe->boil_size / 3) * 100));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 ui->perc_sugarsShow->setValue(round(psugar));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 ui->perc_caraShow->setValue(round(pcara));
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
299 if (recipe->mashs_kg > 0) {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
300 qDebug() << " lintner" << lintner << " mashkg" << recipe->mashs_kg << "final" << round(lintner / recipe->mashs_kg);
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
301 ui->lintnerShow->setValue(round(lintner / recipe->mashs_kg));
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
302 } else {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
303 qDebug() << " lintner N/A";
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
304 ui->lintnerShow->setValue(0);
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
305 }
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 * Calculate the apparant attenuation.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 double svg = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 if (recipe->yeasts.size() > 0) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 for (i = 0; i < recipe->yeasts.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 if (recipe->yeasts.at(i).y_use == 0) { // Used in primary
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 if (recipe->yeasts.at(i).y_attenuation > svg)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 svg = recipe->yeasts.at(i).y_attenuation; // Take the highest if multiple yeasts.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 // TODO: brett or others in secondary.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 qDebug() << " SVG" << svg;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 if (svg == 0)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 svg = 77.0;
142
1caa15a0eefc Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
323 ui->est_svgEdit->setValue(svg);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 double fg;
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
326 if (recipe->mashs_kg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0)
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
327 fg = Utils::estimate_fg(psugar, pcara, mashinfuse / recipe->mashs_kg, mashtime, mashtemp, svg, og);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 else
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, og);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 qDebug() << " FG" << ui->est_fgEdit->value() << fg;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 recipe->est_fg = fg;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 ui->est_fgEdit->setValue(fg);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 ui->est_fg3Edit->setValue(fg);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 ui->est_fgShow->setValue(fg);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 double abv = Utils::abvol(og, fg);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337 qDebug() << " ABV" << ui->est_abvEdit->value() << abv;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338 ui->est_abvEdit->setValue(abv);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 ui->est_abv2Edit->setValue(abv);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 ui->est_abvShow->setValue(abv);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341 recipe->est_abv = abv;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 * Calculate kilocalories/liter. Formula from brouwhulp.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 * Take the alcohol and sugar parts and then combine.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 double alc = 1881.22 * fg * (og - fg) / (1.775 - og);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 double sug = 3550 * fg * (0.1808 * og + 0.8192 * fg - 1.0004);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296)));
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
350
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
351 // Bottle priming
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
352 double priming_total = 0;
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
353 for (i = 0; i < recipe->fermentables.size(); i++) {
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
354 if (recipe->fermentables.at(i).f_added == 4) {
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
355 priming_total += ((recipe->fermentables.at(i).f_yield / 100) * (1 - recipe->fermentables.at(i).f_moisture / 100)) *
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
356 recipe->fermentables.at(i).f_amount;
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
357 qDebug() << " priming" << recipe->fermentables.at(i).f_amount << "total" << priming_total;
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
358 }
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
359 }
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
360 double grl = priming_total * 1000.0 * (1 / recipe->batch_size);
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
361 double volco2 = grl * 0.510;
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
362 qDebug() << " priming gr/l" << grl << "volco2" << volco2;
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
363
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
364 if (volco2 > 0) {
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
365 recipe->est_carb = volco2;
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
366 ui->est_carbEdit->setValue(recipe->est_carb);
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
367 ui->est_carbShow->setValue(recipe->est_carb);
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
368 }
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371
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: 148
diff changeset
372 void EditRecipe::calcFermentablesFromOG(double og)
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: 148
diff changeset
373 {
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: 148
diff changeset
374 qDebug() << "calcFermentablesFromOG" << og;
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: 148
diff changeset
375
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: 148
diff changeset
376 int i;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 148
diff changeset
377 double totmass = 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: 148
diff changeset
378 double tot = 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: 148
diff changeset
379 double d, 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: 148
diff changeset
380 double efficiency = recipe->efficiency;
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: 148
diff changeset
381 double sug = Utils::sg_to_plato(og) * recipe->batch_size * og / 100.0; // total amount of sugars in kg.
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: 148
diff changeset
382
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: 148
diff changeset
383 for (i = 0; i < recipe->fermentables.size(); i++) {
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 148
diff changeset
384 if (recipe->fermentables.at(i).f_added < 4) {
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: 148
diff changeset
385 d = recipe->fermentables.at(i).f_percentage / 100.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: 148
diff changeset
386 (recipe->fermentables.at(i).f_yield / 100.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: 148
diff changeset
387 (1 - recipe->fermentables.at(i).f_moisture / 100.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: 148
diff changeset
388 if (recipe->fermentables.at(i).f_added == 0) // Mash
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: 148
diff changeset
389 d = efficiency / 100.0 * d;
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: 148
diff changeset
390 tot += d;
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: 148
diff changeset
391 }
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: 148
diff changeset
392 }
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: 148
diff changeset
393 if (tot)
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: 148
diff changeset
394 totmass = round((sug / tot) * 1000.0) / 1000.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: 148
diff changeset
395
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: 148
diff changeset
396 if (totmass) {
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: 148
diff changeset
397 for (i = 0; i < recipe->fermentables.size(); i++) {
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 148
diff changeset
398 amount = round(recipe->fermentables.at(i).f_percentage * 10.0 * totmass) / 1000.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: 148
diff changeset
399 recipe->fermentables[i].f_amount = amount;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 148
diff changeset
400 }
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: 148
diff changeset
401 }
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: 148
diff changeset
402 }
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: 148
diff changeset
403
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: 148
diff changeset
404
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: 132
diff changeset
405 void EditRecipe::ferment_perc_mash_valueChanged(int value)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
406 {
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
407 if (value < 90) {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
408 ui->perc_mashShow->setStyleSheet(bar_green);
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
409 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
410 double s1 = 90.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
411 if (value < 100) {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
412 ui->perc_mashShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
413 "stop: 0 green, stop: %1 green, stop: %2 orange, stop: 1 orange"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
414 ");}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
415 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
416 double s2 = 100.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
417 ui->perc_mashShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
418 "stop: 0 green, stop: %1 green, stop: %2 orange, stop: %3 orange, stop: %4 red, stop: 1 red"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
419 ");}").arg(s1 - 0.00003).arg(s1 - 0.00002).arg(s2 - 0.00001).arg(s2));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
420 }
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
421 }
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424
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: 132
diff changeset
425 void EditRecipe::ferment_perc_sugars_valueChanged(int value)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427 if (value < 20)
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
428 ui->perc_sugarsShow->setStyleSheet(bar_green);
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
429 else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
430 double s1 = 20.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
431 ui->perc_sugarsShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
432 "stop: 0 green, stop: %1 green, stop: %2 red, stop: 1 red);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
433 }
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436
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: 132
diff changeset
437 void EditRecipe::ferment_perc_cara_valueChanged(int value)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439 if (value < 25)
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
440 ui->perc_caraShow->setStyleSheet(bar_green);
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
441 else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
442 double s1 = 25.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
443 ui->perc_caraShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
444 "stop: 0 green, stop: %1 green, stop: %2 red, stop: 1 red);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
445 }
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448
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: 132
diff changeset
449 void EditRecipe::ferment_lintner_valueChanged(int value)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 {
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
451 /*
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
452 * Calculate the color stop positions
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
453 */
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
454 if (value < 30) {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
455 ui->lintnerShow->setStyleSheet(bar_red);
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
456 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
457 double s1 = 30.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
458 if (value < 40) {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
459 ui->lintnerShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
460 "stop: 0 red, stop: %1 red, stop: %2 orange, stop: 1 orange);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
461 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
462 double s2 = 40.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
463 ui->lintnerShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
464 "stop: 0 red, stop: %1 red, stop: %2 orange, stop: %3 orange, stop: %4 green, stop: 1 green"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
465 ");}").arg(s1 - 0.00003).arg(s1 - 0.00002).arg(s2 - 0.00001).arg(s2));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
466 }
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
467 }
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
468 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470
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: 132
diff changeset
471 void EditRecipe::addFermentRow_clicked()
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 Fermentables newf;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 qDebug() << "Add fermentable row";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 for (int i = 0; i < recipe->fermentables.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 if (recipe->fermentables.at(i).f_amount == 0 && recipe->fermentables.at(i).f_color == 0)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 return; // Add only one at a time.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 newf.f_name = "Select one";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 newf.f_origin = "";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 newf.f_supplier = "";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 newf.f_amount = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486 newf.f_cost = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 newf.f_type = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488 newf.f_yield = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489 newf.f_color = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490 newf.f_coarse_fine_diff = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491 newf.f_moisture = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492 newf.f_diastatic_power = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493 newf.f_protein = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 newf.f_dissolved_protein = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 newf.f_max_in_batch = 100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
496 newf.f_graintype = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 newf.f_added = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 newf.f_recommend_mash = true;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 newf.f_add_after_boil = false;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500 newf.f_adjust_to_total_100 = false;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 newf.f_percentage = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 newf.f_di_ph = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 newf.f_acid_to_ph_57 = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505 recipe->fermentables.append(newf);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 emit refreshAll();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509
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: 132
diff changeset
510 void EditRecipe::deleteFermentRow_clicked()
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 {
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
512 if (recipe->locked)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
513 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
514
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516 int row = pb->objectName().toInt();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 qDebug() << "Delete fermentable row" << row << recipe->fermentables.size();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 if (recipe->fermentables.size() < 1)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522 int rc = QMessageBox::warning(this, tr("Delete fermentable"), tr("Delete %1").arg(recipe->fermentables.at(row).f_name),
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 if (rc == QMessageBox::No)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527 recipe->fermentables.removeAt(row);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530 * Recalculate the percentages on the rows left.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532 double total = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 for (int i = 0; i < recipe->fermentables.size(); i++)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 if (recipe->fermentables.at(i).f_added < 4) // Only before bottle/kegging
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 total += recipe->fermentables.at(i).f_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536 for (int i = 0; i < recipe->fermentables.size(); i++)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 if (recipe->fermentables.at(i).f_added < 4)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538 recipe->fermentables[i].f_percentage = recipe->fermentables.at(i).f_amount / total * 100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539
132
9ede9c75cb54 Added miscs popup editor. No edit functions yet. Delete misc row added.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
540 is_changed();
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
541 emit refreshAll();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
542 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
543
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 void EditRecipe::ferment_amount_changed(double val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547 QTableWidgetItem *item;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 double total = 0, perc;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549
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
550 if (recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).f_added < 4)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 qDebug() << "ferment_amount_changed()" << recipe->fermentables_row << val;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 recipe->fermentables[recipe->fermentables_row].f_amount = val;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 item = new QTableWidgetItem(QString("%1 Kg").arg(val, 4, 'f', 3, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 ui->fermentablesTable->setItem(recipe->fermentables_row, 7, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 for (int i = 0; i < recipe->fermentables.size(); i++)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561 if (recipe->fermentables.at(i).f_added < 4) // Only before bottle/kegging
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 total += recipe->fermentables.at(i).f_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564 * Recalculate the percentages
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 for (int i = 0; i < recipe->fermentables.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 if (recipe->fermentables.at(i).f_added < 4) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 perc = recipe->fermentables.at(i).f_amount / total * 100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 recipe->fermentables[i].f_percentage = perc;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 item = new QTableWidgetItem(QString("%1%").arg(perc, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 ui->fermentablesTable->setItem(i, 8, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 if (i == recipe->fermentables_row)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 this->pctEdit->setValue(perc);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
576 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
577 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
578 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 void EditRecipe::ferment_pct_changed(double val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583 QTableWidgetItem *item;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 double total = 0, row100 = -1;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586 if (! recipe->fermentables_use100)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589 qDebug() << "ferment_pct_changed()" << recipe->fermentables_row << val;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
591 * Since we have arrived here, adjust_to_100 is active and
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 * this is not the entry to be adjusted to 100.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594 for (int i = 0; i < recipe->fermentables.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
595 if (recipe->fermentables.at(i).f_added < 4) // Only before bottle/kegging
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
596 total += recipe->fermentables.at(i).f_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
597 if (recipe->fermentables.at(i).f_adjust_to_total_100)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
598 row100 = i;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
599 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 double oldperc = recipe->fermentables.at(recipe->fermentables_row).f_percentage;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601 double diffp = val - oldperc;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 double diffw = (diffp / 100) * total;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 qDebug() << "row100" << row100 << "total" << total << "diff kg" << diffw << "diff %" << diffp;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 recipe->fermentables[recipe->fermentables_row].f_percentage += diffp;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 recipe->fermentables[recipe->fermentables_row].f_amount += diffw;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 recipe->fermentables[row100].f_percentage -= diffp;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608 recipe->fermentables[row100].f_amount -= diffw;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610 item = new QTableWidgetItem(QString("%1 Kg").arg(recipe->fermentables[recipe->fermentables_row].f_amount, 4, 'f', 3, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 ui->fermentablesTable->setItem(recipe->fermentables_row, 7, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 this->famountEdit->setValue(recipe->fermentables[recipe->fermentables_row].f_amount);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
614
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615 item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables[recipe->fermentables_row].f_percentage, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617 ui->fermentablesTable->setItem(recipe->fermentables_row, 8, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619 item = new QTableWidgetItem(QString("%1 Kg").arg(recipe->fermentables[row100].f_amount, 4, 'f', 3, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621 ui->fermentablesTable->setItem(row100, 7, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623 item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables[row100].f_percentage, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 ui->fermentablesTable->setItem(row100, 8, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
628 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 void EditRecipe::ferment_to100_changed(bool val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
633 qDebug() << "ferment_to100_changed()" << recipe->fermentables_row << val << recipe->fermentables_use100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634
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
635 if (recipe->fermentables.at(recipe->fermentables_row).f_added >= 4) {
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
636 const QSignalBlocker blocker1(to100Edit);
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
637 recipe->fermentables[recipe->fermentables_row].f_adjust_to_total_100 = false;
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
638 to100Edit->setChecked(false);
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
639 return;
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
640 }
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
641
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 * Three scenario's.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 * 1. There is no fermentable selected yet, just mark it.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 * 2. There is current one is selected, deselect it.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 * 3. There is another one selected, deselect and select this one.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 if (! recipe->fermentables_use100 && val) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 /* Scenario 1. */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650 recipe->fermentables_use100 = true;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 recipe->fermentables[recipe->fermentables_row].f_adjust_to_total_100 = true;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 pctEdit->setReadOnly(false);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 famountEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654 } else if (recipe->fermentables_use100 && recipe->fermentables[recipe->fermentables_row].f_adjust_to_total_100 && ! val) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655 /* Scenario 2. */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656 recipe->fermentables[recipe->fermentables_row].f_adjust_to_total_100 = false;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657 recipe->fermentables_use100 = false;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
658 pctEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 famountEdit->setReadOnly(false);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660 } else if (recipe->fermentables_use100 && ! recipe->fermentables[recipe->fermentables_row].f_adjust_to_total_100 && val) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661 /* Scenario 3. */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662 for (int i = 0; i < recipe->fermentables.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 recipe->fermentables[i].f_adjust_to_total_100 = false;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 recipe->fermentables[recipe->fermentables_row].f_adjust_to_total_100 = true;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
667 qDebug() << "bug";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
669 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
671 for (int i = 0; i < recipe->fermentables.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
672 to100Fermentables(i);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
676
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
677
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
678 void EditRecipe::ferment_select_changed(int val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
679 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
680 QSqlQuery query;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
681 bool instock = finstockEdit->isChecked();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
682 QString w;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683 QTableWidgetItem *item;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
684
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
685 if (val < 1)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688 qDebug() << "ferment_select_changed()" << recipe->fermentables_row << val << instock;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691 * Search the fermentable pointed by the index and instock flag.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 QString sql = "SELECT name,origin,supplier,cost,type,yield,color,coarse_fine_diff,moisture,diastatic_power,protein,dissolved_protein,max_in_batch,"
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 "graintype,recommend_mash,add_after_boil,di_ph,acid_to_ph_57 FROM inventory_fermentables ";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 if (instock)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 sql.append("WHERE inventory > 0 ");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 sql.append("ORDER BY supplier,name");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 query.prepare(sql);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 query.exec();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 query.first();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701 for (int i = 0; i < (val - 1); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 query.next();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 qDebug() << "found" << query.value(2).toString() << query.value(0).toString();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 * Replace the fermentable record contents
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
709 recipe->fermentables[recipe->fermentables_row].f_name = query.value(0).toString();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 recipe->fermentables[recipe->fermentables_row].f_origin = query.value(1).toString();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
711 recipe->fermentables[recipe->fermentables_row].f_supplier = query.value(2).toString();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 recipe->fermentables[recipe->fermentables_row].f_cost = query.value(3).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
713 recipe->fermentables[recipe->fermentables_row].f_type = query.value(4).toInt();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
714 recipe->fermentables[recipe->fermentables_row].f_yield = query.value(5).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715 recipe->fermentables[recipe->fermentables_row].f_color = query.value(6).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
716 recipe->fermentables[recipe->fermentables_row].f_coarse_fine_diff = query.value(7).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
717 recipe->fermentables[recipe->fermentables_row].f_moisture = query.value(8).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718 recipe->fermentables[recipe->fermentables_row].f_diastatic_power = query.value(9).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719 recipe->fermentables[recipe->fermentables_row].f_protein = query.value(10).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720 recipe->fermentables[recipe->fermentables_row].f_dissolved_protein = query.value(11).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 recipe->fermentables[recipe->fermentables_row].f_max_in_batch = query.value(12).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722 recipe->fermentables[recipe->fermentables_row].f_graintype = query.value(13).toInt();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723 recipe->fermentables[recipe->fermentables_row].f_recommend_mash = query.value(14).toInt() ? true:false;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
724 recipe->fermentables[recipe->fermentables_row].f_add_after_boil = query.value(15).toInt() ? true:false;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
725 recipe->fermentables[recipe->fermentables_row].f_di_ph = query.value(16).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
726 recipe->fermentables[recipe->fermentables_row].f_acid_to_ph_57 = query.value(17).toDouble();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
727
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
729 * Update the visible fields
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
730 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
731 fnameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_name);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
732 fsupplierEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_supplier);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 fmaxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_max_in_batch);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735 ui->fermentablesTable->setItem(recipe->fermentables_row, 0, new QTableWidgetItem(recipe->fermentables.at(recipe->fermentables_row).f_supplier));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736 ui->fermentablesTable->setItem(recipe->fermentables_row, 1, new QTableWidgetItem(recipe->fermentables.at(recipe->fermentables_row).f_name));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
737
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
738 w = QString("%1").arg(recipe->fermentables.at(recipe->fermentables_row).f_color, 1, 'f', 0, '0');
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
739 item = new QTableWidgetItem(w);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
740 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741 ui->fermentablesTable->setItem(recipe->fermentables_row, 2, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
743 item = new QTableWidgetItem(fermentable_types[recipe->fermentables.at(recipe->fermentables_row).f_type]);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 ui->fermentablesTable->setItem(recipe->fermentables_row, 3, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
747 item = new QTableWidgetItem(fermentable_graintypes[recipe->fermentables.at(recipe->fermentables_row).f_graintype]);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
749 ui->fermentablesTable->setItem(recipe->fermentables_row, 4, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
751 item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables.at(recipe->fermentables_row).f_yield, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753 ui->fermentablesTable->setItem(recipe->fermentables_row, 6, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 calcFermentables();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 void EditRecipe::ferment_instock_changed(bool val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 QSqlQuery query;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764 qDebug() << "ferment_instock_changed()" << recipe->fermentables_row << val;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766 this->fselectEdit->setCurrentIndex(-1);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767 this->fselectEdit->clear();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768 QString sql = "SELECT supplier,name,color,inventory FROM inventory_fermentables ";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
769 if (val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 sql.append("WHERE inventory > 0 ");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 sql.append("ORDER BY supplier,name");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 query.prepare(sql);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773 query.exec();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 query.first();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 this->fselectEdit->addItem(""); // Start with empty value
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
776 for (int i = 0; i < query.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
777 this->fselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+" EBC) "+
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778 QString("%1 kg").arg(query.value(3).toDouble(), 4, 'f', 3, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 query.next();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
783
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
784 void EditRecipe::ferment_added_changed(int val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
785 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
786 qDebug() << "ferment_added_changed()" << recipe->fermentables_row << val;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
787
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
788 recipe->fermentables[recipe->fermentables_row].f_added = val;
154
1af9f7b7f317 Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
789 QTableWidgetItem *item = new QTableWidgetItem(fermentable_added[val]);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
790 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
791 ui->fermentablesTable->setItem(recipe->fermentables_row, 5, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
792
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
793 famountEdit->setReadOnly(recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).f_added < 4);
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
794 pctEdit->setReadOnly(! (recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).f_added < 4));
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
795
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
796 double total = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
797 for (int i = 0; i < recipe->fermentables.size(); i++)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
798 if (recipe->fermentables.at(i).f_added < 4) // Only before bottle/kegging
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
799 total += recipe->fermentables.at(i).f_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 for (int i = 0; i < recipe->fermentables.size(); i++)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
801 if (recipe->fermentables.at(i).f_added < 4)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
802 recipe->fermentables[i].f_percentage = recipe->fermentables.at(i).f_amount / total * 100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
803
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
804 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
805 emit refreshAll();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
806 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
807
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
808
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: 132
diff changeset
809 void EditRecipe::editFermentRow_clicked()
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
810 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
811 QSqlQuery query;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
813 if (recipe->locked)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
814 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
815
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
816 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
817 recipe->fermentables_row = pb->objectName().toInt();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
818 qDebug() << "Edit fermentable row" << recipe->fermentables_row;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
819 Fermentables backup = recipe->fermentables.at(recipe->fermentables_row);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
820
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
821 QDialog* dialog = new QDialog(this);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
822 dialog->resize(738, 287);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
823 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
824 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
825 buttonBox->setGeometry(QRect(30, 240, 671, 32));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
826 buttonBox->setLayoutDirection(Qt::LeftToRight);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
827 buttonBox->setOrientation(Qt::Horizontal);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
828 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
829 buttonBox->setCenterButtons(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
830 QLabel *nameLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
831 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
832 nameLabel->setText(tr("Current ingredient:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
833 nameLabel->setGeometry(QRect(10, 10, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
834 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
835 QLabel *supplierLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
836 supplierLabel->setObjectName(QString::fromUtf8("supplierLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
837 supplierLabel->setText(tr("Supplier:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
838 supplierLabel->setGeometry(QRect(10, 40, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
839 supplierLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
840 QLabel *amountLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
841 amountLabel->setObjectName(QString::fromUtf8("amountLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
842 amountLabel->setText(tr("Amount in kg:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
843 amountLabel->setGeometry(QRect(10, 100, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
844 amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
845 QLabel *pctLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
846 pctLabel->setObjectName(QString::fromUtf8("pctLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
847 pctLabel->setText(tr("Percentage in batch:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
848 pctLabel->setGeometry(QRect(10, 130, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
849 pctLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
850 QLabel *to100Label = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
851 to100Label->setObjectName(QString::fromUtf8("to100Label"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
852 to100Label->setText(tr("Auto fill to 100%:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
853 to100Label->setGeometry(QRect(10, 160, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
854 to100Label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
855 QLabel *addedLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
856 addedLabel->setObjectName(QString::fromUtf8("addedLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
857 addedLabel->setText(tr("Use at:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
858 addedLabel->setGeometry(QRect(10, 190, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
859 addedLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
860 QLabel *selectLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
861 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
862 selectLabel->setText(tr("Select ingredient:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
863 selectLabel->setGeometry(QRect(10, 70, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
864 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
865 QLabel *instockLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
866 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
867 instockLabel->setText(tr("In stock:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
868 instockLabel->setGeometry(QRect(525, 70, 121, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
869 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
870 QLabel *maxLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
871 maxLabel->setObjectName(QString::fromUtf8("maxLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
872 maxLabel->setText(tr("Max in batch:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
873 maxLabel->setGeometry(QRect(420, 130, 121, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
874 maxLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
875
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
876 fselectEdit = new QComboBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
877 fselectEdit->setObjectName(QString::fromUtf8("fselectEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
878 fselectEdit->setGeometry(QRect(160, 70, 371, 23));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
879
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
880 fnameEdit = new QLineEdit(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
881 fnameEdit->setObjectName(QString::fromUtf8("fnameEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
882 fnameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_name);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
883 fnameEdit->setGeometry(QRect(160, 10, 511, 23));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
884 fnameEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
885 fsupplierEdit = new QLineEdit(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
886 fsupplierEdit->setObjectName(QString::fromUtf8("fsupplierEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
887 fsupplierEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_supplier);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
888 fsupplierEdit->setGeometry(QRect(160, 40, 511, 23));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
889 fsupplierEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
890 famountEdit = new QDoubleSpinBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
891 famountEdit->setObjectName(QString::fromUtf8("famountEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
892 famountEdit->setGeometry(QRect(160, 100, 121, 24));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
893 famountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
894 famountEdit->setAccelerated(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
895 famountEdit->setDecimals(3);
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
896 famountEdit->setReadOnly(recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).f_added < 4);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
897 famountEdit->setMaximum(100000.0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
898 famountEdit->setSingleStep(0.0010);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
899 famountEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_amount);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
900
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
901 pctEdit = new QDoubleSpinBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
902 pctEdit->setObjectName(QString::fromUtf8("pctEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
903 pctEdit->setGeometry(QRect(160, 130, 121, 24));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
904 pctEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
905 pctEdit->setAccelerated(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
906 pctEdit->setDecimals(1);
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
907 if (recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).f_added < 4) {
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
908 if (recipe->fermentables.at(recipe->fermentables_row).f_adjust_to_total_100)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
909 pctEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
910 else
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
911 pctEdit->setReadOnly(false);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
912 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
913 pctEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
914 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
915 pctEdit->setMaximum(100.0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
916 pctEdit->setSingleStep(0.1);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
917 pctEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_percentage);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
918
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
919 faddedEdit = new QComboBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
920 faddedEdit->setObjectName(QString::fromUtf8("faddedEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
921 faddedEdit->setGeometry(QRect(160, 190, 161, 23));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
922 faddedEdit->addItem(tr("Mash"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
923 faddedEdit->addItem(tr("Boil"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924 faddedEdit->addItem(tr("Fermentation"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
925 faddedEdit->addItem(tr("Lagering"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
926 faddedEdit->addItem(tr("Bottle"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
927 faddedEdit->addItem(tr("Kegs"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
928 faddedEdit->setCurrentIndex(recipe->fermentables.at(recipe->fermentables_row).f_added);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
929
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
930 to100Edit = new QCheckBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
931 to100Edit->setObjectName(QString::fromUtf8("to100Edit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
932 to100Edit->setGeometry(QRect(160, 160, 85, 21));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
933 to100Edit->setChecked(recipe->fermentables.at(recipe->fermentables_row).f_adjust_to_total_100);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
934
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
935 finstockEdit = new QCheckBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
936 finstockEdit->setObjectName(QString::fromUtf8("instockEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
937 finstockEdit->setGeometry(QRect(655, 70, 85, 21));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
938 finstockEdit->setChecked(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
939
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
940 fmaxEdit = new QDoubleSpinBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
941 fmaxEdit->setObjectName(QString::fromUtf8("fmaxEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
942 fmaxEdit->setGeometry(QRect(550, 130, 121, 24));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
943 fmaxEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
944 fmaxEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945 fmaxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
946 fmaxEdit->setDecimals(1);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
947 fmaxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_max_in_batch);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
948
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
949 ferment_instock_changed(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
950
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
951 connect(fselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_select_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
952 connect(famountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_amount_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
953 connect(pctEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_pct_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
954 connect(faddedEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_added_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
955 connect(to100Edit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_to100_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
956 connect(finstockEdit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_instock_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
957 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
958 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
959
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
960 dialog->setModal(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
961 dialog->exec();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
962 if (dialog->result() == QDialog::Rejected) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
963 qDebug() << "reject and rollback";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
964 recipe->fermentables[recipe->fermentables_row] = backup;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 * Recalculate the percentages
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968 double total = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
969 for (int i = 0; i < recipe->fermentables.size(); i++)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
970 if (recipe->fermentables.at(i).f_added < 4) // Only before bottle/kegging
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
971 total += recipe->fermentables.at(i).f_amount;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
972 recipe->fermentables_use100 = false;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
973 for (int i = 0; i < recipe->fermentables.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
974 if (recipe->fermentables.at(i).f_adjust_to_total_100)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
975 recipe->fermentables_use100 = true;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
976 if (recipe->fermentables.at(i).f_added < 4) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
977 recipe->fermentables[i].f_percentage = recipe->fermentables.at(i).f_amount / total * 100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
978 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
979 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
980 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
981
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
982 disconnect(fselectEdit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
983 disconnect(famountEdit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
984 disconnect(pctEdit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
985 disconnect(faddedEdit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
986 disconnect(to100Edit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
987 disconnect(finstockEdit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
988 disconnect(buttonBox, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
989
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
990 emit refreshAll();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
991 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
992
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
993

mercurial