src/EditRecipeTab6.cpp

Mon, 04 Mar 2024 19:51:57 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 04 Mar 2024 19:51:57 +0100
changeset 520
9166c0b82ada
parent 454
2dfead81c72f
permissions
-rw-r--r--

Code cleanup

128
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditRecipe.cpp is part of bmsapp.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * tab 6, mash.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the hope that it will be useful,
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 void EditRecipe::refreshMashs()
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 {
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
23 QString w;
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
24 QWidget* pWidget;
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
25 QHBoxLayout* pLayout;
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
26 QTableWidgetItem *item;
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
27 QIcon down_icon, up_icon;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
28
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
29 down_icon.addFile(QString::fromUtf8(":/icons/silk/bullet_arrow_down.png"), QSize(), QIcon::Normal, QIcon::Off);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
30 up_icon.addFile(QString::fromUtf8(":/icons/silk/bullet_arrow_up.png"), QSize(), QIcon::Normal, QIcon::Off);
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
31
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
32 const QStringList labels({tr("Step name"), tr("Type"), tr("Start"), tr("End"), tr("Rest"), tr("Ramp"),
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
33 tr("Inf/dec"), tr("Inf/dec"), tr("Volume"), tr("W/G ratio"), "", "", tr("Delete"), tr("Edit") });
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
34
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
35 ui->mashsTable->setColumnCount(14);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
36 ui->mashsTable->setColumnWidth(0, 189); /* Step name */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
37 ui->mashsTable->setColumnWidth(1, 100); /* Type */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
38 ui->mashsTable->setColumnWidth(2, 70); /* Start temp */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
39 ui->mashsTable->setColumnWidth(3, 70); /* End temp */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
40 ui->mashsTable->setColumnWidth(4, 70); /* Rest time */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
41 ui->mashsTable->setColumnWidth(5, 70); /* Ramp time */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
42 ui->mashsTable->setColumnWidth(6, 70); /* Infusion vol */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
43 ui->mashsTable->setColumnWidth(7, 70); /* Infusion tmp */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
44 ui->mashsTable->setColumnWidth(8, 70); /* Volume */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
45 ui->mashsTable->setColumnWidth(9, 80); /* W/G ratio */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
46 ui->mashsTable->setColumnWidth(10, 30); /* Up button */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
47 ui->mashsTable->setColumnWidth(11, 30); /* Down button */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
48 ui->mashsTable->setColumnWidth(12, 80); /* Delete */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
49 ui->mashsTable->setColumnWidth(13, 80); /* Edit */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
50 ui->mashsTable->setHorizontalHeaderLabels(labels);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
51 ui->mashsTable->verticalHeader()->hide();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
52 ui->mashsTable->setRowCount(recipe->mashs.size());
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
53
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
54 for (int i = 0; i < recipe->mashs.size(); i++) {
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
55
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
56 ui->mashsTable->setItem(i, 0, new QTableWidgetItem(recipe->mashs.at(i).step_name));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
57
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 287
diff changeset
58 item = new QTableWidgetItem(QCoreApplication::translate("StepType", g_step_types[recipe->mashs.at(i).step_type]));
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
59 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
60 ui->mashsTable->setItem(i, 1, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
61
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
62 item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).step_temp, 2, 'f', 1, '0'));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
63 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
64 ui->mashsTable->setItem(i, 2, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
65
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
66 item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).end_temp, 2, 'f', 1, '0'));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
67 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
68 ui->mashsTable->setItem(i, 3, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
69
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
70 item = new QTableWidgetItem(QString("%1 min").arg(recipe->mashs.at(i).step_time, 1, 'f', 0, '0'));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
71 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
72 ui->mashsTable->setItem(i, 4, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
73
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
74 item = new QTableWidgetItem(QString("%1 min").arg(recipe->mashs.at(i).ramp_time, 1, 'f', 0, '0'));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
75 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
76 ui->mashsTable->setItem(i, 5, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
77
147
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
78 if (recipe->mashs.at(i).step_infuse_amount > 0) {
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
79 item = new QTableWidgetItem(QString("%1 L").arg(recipe->mashs.at(i).step_infuse_amount, 2, 'f', 1, '0'));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
80 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
81 ui->mashsTable->setItem(i, 6, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
82 item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).step_infuse_temp, 3, 'f', 2, '0'));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
83 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
84 ui->mashsTable->setItem(i, 7, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
85 } else {
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
86 ui->mashsTable->removeCellWidget(i, 6);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
87 ui->mashsTable->removeCellWidget(i, 7);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
88 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
89
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
90 item = new QTableWidgetItem(QString("%1 L").arg(recipe->mashs.at(i).step_volume, 2, 'f', 1, '0'));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
91 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
92 ui->mashsTable->setItem(i, 8, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
93
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
94 item = new QTableWidgetItem(QString("%1 L/kg").arg(recipe->mashs.at(i).step_wg_ratio, 3, 'f', 2, '0'));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
95 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
96 ui->mashsTable->setItem(i, 9, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
97
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
98 if (i > 0) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
99 pWidget = new QWidget();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
100 QPushButton* btn_up = new QPushButton();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
101 btn_up->setObjectName(QString("%1").arg(i)); /* Send row with the button */
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
102 btn_up->setIcon(up_icon);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
103 connect(btn_up, SIGNAL(clicked()), this, SLOT(upMashRow_clicked()));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
104 pLayout = new QHBoxLayout(pWidget);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
105 pLayout->addWidget(btn_up);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
106 pLayout->setContentsMargins(5, 0, 5, 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
107 pWidget->setLayout(pLayout);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
108 ui->mashsTable->setCellWidget(i, 10, pWidget);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
109 } else {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
110 ui->mashsTable->removeCellWidget(i, 10);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
111 }
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
112
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
113 if (i < (recipe->mashs.size() - 1)) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
114 pWidget = new QWidget();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
115 QPushButton* btn_down = new QPushButton();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
116 btn_down->setObjectName(QString("%1").arg(i)); /* Send row with the button */
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
117 btn_down->setIcon(down_icon);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
118 connect(btn_down, SIGNAL(clicked()), this, SLOT(downMashRow_clicked()));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
119 pLayout = new QHBoxLayout(pWidget);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
120 pLayout->addWidget(btn_down);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
121 pLayout->setContentsMargins(5, 0, 5, 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
122 pWidget->setLayout(pLayout);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
123 ui->mashsTable->setCellWidget(i, 11, pWidget);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
124 } else {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
125 ui->mashsTable->removeCellWidget(i, 11);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
126 }
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
127
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
128 pWidget = new QWidget();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
129 QPushButton* btn_dele = new QPushButton();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
130 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
131 btn_dele->setText(tr("Delete"));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
132 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMashRow_clicked()));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
133 pLayout = new QHBoxLayout(pWidget);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
134 pLayout->addWidget(btn_dele);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
135 pLayout->setContentsMargins(5, 0, 5, 0);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
136 pWidget->setLayout(pLayout);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
137 ui->mashsTable->setCellWidget(i, 12, pWidget);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
138
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
139 pWidget = new QWidget();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
140 QPushButton* btn_edit = new QPushButton();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
141 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
142 btn_edit->setText(tr("Edit"));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
143 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editMashRow_clicked()));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
144 pLayout = new QHBoxLayout(pWidget);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
145 pLayout->addWidget(btn_edit);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
146 pLayout->setContentsMargins(5, 0, 5, 0);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
147 pWidget->setLayout(pLayout);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
148 ui->mashsTable->setCellWidget(i, 13, pWidget);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
149 }
128
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 }
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
153 double EditRecipe::infusionVol(double step_infused, double step_mashkg, double infuse_temp, double step_temp, double last_temp)
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
154 {
158
24bc2de721d9 Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
155 double a = last_temp * (equip_tun_weight * equip_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
24bc2de721d9 Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
156 double b = step_temp * (equip_tun_weight * equip_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
157 double vol = round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)) * 100.0) / 100.0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
158
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
159 if (vol < 0)
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
160 vol = 0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
161 qDebug() << " infusionVol(" << step_infused << "," << step_mashkg << "," << infuse_temp <<"," << step_temp << "," << last_temp << "):" << vol;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
162 return vol;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
163 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
164
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
165
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
166 double EditRecipe::decoctionVol(double step_volume, double step_temp, double prev_temp)
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
167 {
158
24bc2de721d9 Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
168 double a = (equip_tun_weight * equip_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp);
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
169 double b = SpecificHeatWater * (99 - step_temp);
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
170 double vol = 0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
171
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
172 if (b > 0)
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
173 vol = round((a / b) * 1000000.0) / 1000000.0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
174 qDebug() << " decoctionVol(" << step_volume << "," << step_temp << "," << prev_temp << "):" << vol;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
175 return vol;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
176 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
177
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
178
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
179 void EditRecipe::calcMash()
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
180 {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
181 double infused = 0, vol, a, b, temp;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
182 int i, j, n;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
183 double lasttemp = 18.0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
184 double graintemp = 18.0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
185 double tuntemp = 18.0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
186
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
187 recipe->mashs_time = 0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
188
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
189 if (recipe->mashs.size() && recipe->mashs_kg > 0) {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
190 qDebug() << "calcMash()";
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
191
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
192 for (i = 0; i < recipe->mashs.size(); i++) {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
193 if (recipe->mashs.at(i).step_type == 0) { // Infusion
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
194 if (i == 0) {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
195 // First mash step, temperature from the mashtun and malt.
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
196 n = 20; // tun is preheated.
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
197 tuntemp = recipe->mashs.at(i).step_temp;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
198 for (j = 0; j < n; j++) {
158
24bc2de721d9 Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
199 a = recipe->mashs_kg * graintemp * SpecificHeatMalt + equip_tun_weight * tuntemp * equip_tun_specific_heat;
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
200 b = recipe->mashs[i].step_temp *
158
24bc2de721d9 Activated print recipe button. The recipe record structure is now global. Added global product record structure.
Michiel Broek <mbroek@mbse.eu>
parents: 151
diff changeset
201 (equip_tun_weight * equip_tun_specific_heat +
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
202 recipe->mashs.at(i).step_infuse_amount * SpecificHeatWater +
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
203 recipe->mashs_kg * SpecificHeatMalt) -
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
204 SlakingHeat * recipe->mashs_kg;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
205 if (recipe->mashs.at(i).step_infuse_amount > 0) {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
206 temp = (b - a) / (recipe->mashs.at(i).step_infuse_amount * SpecificHeatWater);
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
207 } else {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
208 temp = 99;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
209 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
210 tuntemp += (temp - tuntemp) / 2;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
211 recipe->mashs[i].step_infuse_temp = round(temp * 1000000.0) / 1000000.0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
212 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
213 qDebug() << " init infuse temp:" << recipe->mashs.at(i).step_infuse_temp;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
214 } else {
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
215 // Calculate amount of infusion water.
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
216 recipe->mashs[i].step_infuse_amount =
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
217 infusionVol(infused, recipe->mashs_kg, recipe->mashs.at(i).step_infuse_temp, recipe->mashs.at(i).step_temp, lasttemp);
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
218 qDebug() << i << " vol:" << recipe->mashs.at(i).step_infuse_amount << "temp:" << recipe->mashs.at(i).step_infuse_temp;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
219 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
220 infused += recipe->mashs.at(i).step_infuse_amount;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
221 } else if (recipe->mashs.at(i).step_type == 1) { // Temperature
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
222 if (i > 0)
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
223 recipe->mashs[i].step_infuse_amount = 0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
224 recipe->mashs[i].step_infuse_temp = 0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
225 } else if (recipe->mashs.at(i).step_type == 2) { // Decoction
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
226 recipe->mashs[i].step_infuse_amount = decoctionVol(infused, recipe->mashs.at(i).step_temp, lasttemp);
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
227 recipe->mashs[i].step_infuse_temp = 99;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
228 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
229 recipe->mashs[i].step_volume = infused;
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: 148
diff changeset
230 //qDebug() << i << " type:" << recipe->mashs.at(i).step_type << "volume:" << recipe->mashs.at(i).step_infuse_amount << "temp:" << recipe->mashs.at(i).step_infuse_temp;
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
231 lasttemp = recipe->mashs.at(i).step_temp;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
232 recipe->mashs_time += recipe->mashs.at(i).step_time;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
233 if (i > 0)
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
234 recipe->mashs_time += recipe->mashs.at(i).ramp_time;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
235 recipe->mashs[i].step_wg_ratio = round((infused / recipe->mashs_kg) * 1000000.0) / 1000000.0;
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
236 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
237 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
238
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
239 /* Show the calculated total mash time. */
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
240 ui->mash_timeEdit->setText(QString("%1:%2").arg(recipe->mashs_time / 60).arg(recipe->mashs_time % 60, 2, 'f', 0, '0'));
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
241 }
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
242
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
243
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
244 void EditRecipe::addMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
245 {
287
83e66c6b6e07 Renamed struct Mashs to MashSteps
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
246 MashSteps newm;
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
247
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
248 for (int i = 0; i < recipe->mashs.size(); i++) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
249 if (recipe->mashs.at(i).step_time == 0)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
250 return; // Add only one at a time.
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
251 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
252
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
253 newm.step_name = "Name me";
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
254 newm.step_temp = newm.end_temp = 67.0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
255 newm.step_time = 20;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
256 newm.ramp_time = 10;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
257 if (recipe->mashs.size()) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
258 newm.step_volume = recipe->mashs.at(recipe->mashs.size() - 1).step_volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
259 newm.step_wg_ratio = recipe->mashs.at(recipe->mashs.size() - 1).step_wg_ratio;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
260 newm.step_type = recipe->mashs.at(recipe->mashs.size() - 1).step_type;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
261 } else {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
262 newm.step_volume = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
263 newm.step_wg_ratio = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
264 newm.step_type = 1;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
265 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
266 newm.step_infuse_amount = newm.step_infuse_temp = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
267
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
268 recipe->mashs.append(newm);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
269 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
270 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
271 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
272
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
273
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
274 void EditRecipe::deleteMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
275 {
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
276 if (recipe->locked || recipe->mashs.size() < 1)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
277 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
278
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
279 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
280 int row = pb->objectName().toInt();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
281 qDebug() << "Delete mash row" << row << recipe->mashs.size();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
282
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
283 int rc = QMessageBox::warning(this, tr("Delete mash step"), tr("Delete %1").arg(recipe->mashs.at(row).step_name),
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
284 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
285 if (rc == QMessageBox::No)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
286 return;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
287
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
288 recipe->mashs.removeAt(row);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
289 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
290 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
291 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
292
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
293
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
294 void EditRecipe::upMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
295 {
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
296 if (recipe->locked || recipe->mashs.size() < 1)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
297 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
298
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
299 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
300 int row = pb->objectName().toInt();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
301 qDebug() << "Move up mash row" << row << recipe->mashs.size();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
302
287
83e66c6b6e07 Renamed struct Mashs to MashSteps
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
303 MashSteps temp;
146
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
304 temp = recipe->mashs[row - 1];
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
305 recipe->mashs[row - 1] = recipe->mashs[row];
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
306 recipe->mashs[row] = temp;
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
307 is_changed();
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
308 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
309 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
310
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
311
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
312 void EditRecipe::downMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
313 {
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
314 if (recipe->locked || recipe->mashs.size() < 1)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
315 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
316
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
317 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
318 int row = pb->objectName().toInt();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
319 qDebug() << "Move down mash row" << row << recipe->mashs.size();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
320
287
83e66c6b6e07 Renamed struct Mashs to MashSteps
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
321 MashSteps temp;
146
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
322 temp = recipe->mashs[row + 1];
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
323 recipe->mashs[row + 1] = recipe->mashs[row];
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
324 recipe->mashs[row] = temp;
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
325 is_changed();
aad2f9f38fc5 Added swap mash rows.
Michiel Broek <mbroek@mbse.eu>
parents: 145
diff changeset
326 emit refreshAll();
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
327 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
328
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
329
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
330 void EditRecipe::step_name_changed(QString val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
331 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
332 recipe->mashs[recipe->mashs_row].step_name = val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
333 ui->mashsTable->setItem(recipe->mashs_row, 0, new QTableWidgetItem(val));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
334 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
335 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
336
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
337
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
338 void EditRecipe::step_type_changed(int val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
339 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
340 qDebug() << "step_type_changed" << recipe->mashs_row << val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
341
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
342 recipe->mashs[recipe->mashs_row].step_type = val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
343 ivolLabel->setVisible(recipe->mashs.at(recipe->mashs_row).step_type == 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
344 stepivolEdit->setVisible(recipe->mashs.at(recipe->mashs_row).step_type == 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
345 itmpLabel->setVisible(recipe->mashs.at(recipe->mashs_row).step_type == 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
346 stepitmpEdit->setVisible(recipe->mashs.at(recipe->mashs_row).step_type == 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
347 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
348 emit refreshAll();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
349 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
350
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
351
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
352 void EditRecipe::step_temp_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
353 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
354 qDebug() << "step_temp_changed" << recipe->mashs_row << val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
355 recipe->mashs[recipe->mashs_row].step_temp = val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
356 QTableWidgetItem *item = new QTableWidgetItem(QString("%1 °C").arg(val, 2, 'f', 1, '0'));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
357 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
358 ui->mashsTable->setItem(recipe->mashs_row, 2, item);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
359 is_changed();
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
360 emit refreshAll();
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
361 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
362
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
363
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
364 void EditRecipe::end_temp_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
365 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
366 qDebug() << "end_temp_changed" << recipe->mashs_row << val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
367 recipe->mashs[recipe->mashs_row].end_temp = val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
368 QTableWidgetItem *item = new QTableWidgetItem(QString("%1 °C").arg(val, 2, 'f', 1, '0'));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
369 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
370 ui->mashsTable->setItem(recipe->mashs_row, 3, item);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
371 is_changed();
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
372 emit refreshAll();
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
373 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
374
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
375
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
376 void EditRecipe::step_time_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
377 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
378 qDebug() << "step_time_changed" << recipe->mashs_row << val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
379 recipe->mashs[recipe->mashs_row].step_time = val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
380 QTableWidgetItem *item = new QTableWidgetItem(QString("%1 min").arg(val, 1, 'f', 0, '0'));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
381 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
382 ui->mashsTable->setItem(recipe->mashs_row, 4, item);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
383 is_changed();
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
384 emit refreshAll();
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
385 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
386
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
387
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
388 void EditRecipe::ramp_time_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
389 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
390 qDebug() << "ramp_time_changed" << recipe->mashs_row << val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
391 recipe->mashs[recipe->mashs_row].ramp_time = val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
392 QTableWidgetItem *item = new QTableWidgetItem(QString("%1 min").arg(val, 1, 'f', 0, '0'));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
393 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
394 ui->mashsTable->setItem(recipe->mashs_row, 5, item);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
395 is_changed();
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
396 emit refreshAll();
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
397 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
398
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
399
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
400 void EditRecipe::infuse_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
401 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
402 qDebug() << "infuse_changed" << recipe->mashs_row << val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
403 recipe->mashs[recipe->mashs_row].step_infuse_amount = val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
404 QTableWidgetItem *item = new QTableWidgetItem(QString("%1 L").arg(val, 1, 'f', 0, '0'));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
405 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
406 ui->mashsTable->setItem(recipe->mashs_row, 6, item);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
407
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
408 /*
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
409 * Recalculate water volumes
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
410 */
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
411 double volume = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
412 for (int i = 0; i < recipe->mashs.size(); i++) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
413 if (recipe->mashs.at(i).step_type == 0) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
414 volume += recipe->mashs.at(i).step_infuse_amount;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
415 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
416 recipe->mashs[i].step_volume = volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
417 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
418 recipe->w1_amount = volume - recipe->w2_amount;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
419 recipe->wg_amount = volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
420 ui->w1_volEdit->setValue(recipe->w1_amount);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
421
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
422 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
423 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
424 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
425
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
426
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
427 void EditRecipe::editMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
428 {
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
429 QSqlQuery query;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
430
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
431 if (recipe->locked)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
432 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
433
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
434 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
435 recipe->mashs_row = pb->objectName().toInt();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
436 qDebug() << "Edit mash row" << recipe->mashs_row;
287
83e66c6b6e07 Renamed struct Mashs to MashSteps
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
437 MashSteps backup = recipe->mashs.at(recipe->mashs_row);
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
438
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
439 QDialog* dialog = new QDialog(this);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
440 dialog->resize(738, 230);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
441 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
442 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
443 buttonBox->setGeometry(QRect(30, 180, 671, 32));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
444 buttonBox->setLayoutDirection(Qt::LeftToRight);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
445 buttonBox->setOrientation(Qt::Horizontal);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
446 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
447 buttonBox->setCenterButtons(true);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
448
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
449 QLabel *nameLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
450 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
451 nameLabel->setText(tr("Step name:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
452 nameLabel->setGeometry(QRect(10, 10, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
453 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
454 stepnameEdit = new QLineEdit(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
455 stepnameEdit->setObjectName(QString::fromUtf8("stepnameEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
456 stepnameEdit->setText(recipe->mashs.at(recipe->mashs_row).step_name);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
457 stepnameEdit->setGeometry(QRect(160, 10, 511, 23));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
458
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
459 QLabel *typeLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
460 typeLabel->setObjectName(QString::fromUtf8("typeLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
461 typeLabel->setText(tr("Step type:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
462 typeLabel->setGeometry(QRect(10, 40, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
463 typeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
464 QComboBox *typeEdit = new QComboBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
465 typeEdit->setObjectName(QString::fromUtf8("typeEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
466 typeEdit->setGeometry(QRect(160, 40, 161, 23));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
467 typeEdit->addItem(tr("Infusion"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
468 typeEdit->addItem(tr("Temperature"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
469 typeEdit->addItem(tr("Decoction"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
470 typeEdit->setCurrentIndex(recipe->mashs.at(recipe->mashs_row).step_type);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
471
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
472 QLabel *tempLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
473 tempLabel->setObjectName(QString::fromUtf8("tempLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
474 tempLabel->setText(tr("Step start temp:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
475 tempLabel->setGeometry(QRect(10, 70, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
476 tempLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
477 steptempEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
478 steptempEdit->setObjectName(QString::fromUtf8("steptempEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
479 steptempEdit->setGeometry(QRect(160, 70, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
480 steptempEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
481 steptempEdit->setDecimals(1);
452
c4c5d02131be Limit mash steptime to 240 minutes. Limit mash steps to 82 degrees celsius. In estimate_fg limit total mash time to 240 minutes and increased the water/grain ration from 5.5 to 6 l/kg.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
482 steptempEdit->setAccelerated(true);
c4c5d02131be Limit mash steptime to 240 minutes. Limit mash steps to 82 degrees celsius. In estimate_fg limit total mash time to 240 minutes and increased the water/grain ration from 5.5 to 6 l/kg.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
483 steptempEdit->setSingleStep(0.5);
c4c5d02131be Limit mash steptime to 240 minutes. Limit mash steps to 82 degrees celsius. In estimate_fg limit total mash time to 240 minutes and increased the water/grain ration from 5.5 to 6 l/kg.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
484 steptempEdit->setMaximum(82);
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
485 steptempEdit->setValue(recipe->mashs.at(recipe->mashs_row).step_temp);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
486
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
487 QLabel *endLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
488 endLabel->setObjectName(QString::fromUtf8("endLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
489 endLabel->setText(tr("Step end temp:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
490 endLabel->setGeometry(QRect(360, 70, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
491 endLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
492 endtempEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
493 endtempEdit->setObjectName(QString::fromUtf8("endtempEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
494 endtempEdit->setGeometry(QRect(510, 70, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
495 endtempEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
496 endtempEdit->setDecimals(1);
452
c4c5d02131be Limit mash steptime to 240 minutes. Limit mash steps to 82 degrees celsius. In estimate_fg limit total mash time to 240 minutes and increased the water/grain ration from 5.5 to 6 l/kg.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
497 endtempEdit->setAccelerated(true);
c4c5d02131be Limit mash steptime to 240 minutes. Limit mash steps to 82 degrees celsius. In estimate_fg limit total mash time to 240 minutes and increased the water/grain ration from 5.5 to 6 l/kg.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
498 endtempEdit->setSingleStep(0.5);
c4c5d02131be Limit mash steptime to 240 minutes. Limit mash steps to 82 degrees celsius. In estimate_fg limit total mash time to 240 minutes and increased the water/grain ration from 5.5 to 6 l/kg.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
499 endtempEdit->setMaximum(82);
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
500 endtempEdit->setValue(recipe->mashs.at(recipe->mashs_row).end_temp);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
501
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
502 QLabel *timeLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
503 timeLabel->setObjectName(QString::fromUtf8("timeLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
504 timeLabel->setText(tr("Step rest time:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
505 timeLabel->setGeometry(QRect(10, 100, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
506 timeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
507 steptimeEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
508 steptimeEdit->setObjectName(QString::fromUtf8("steptimeEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
509 steptimeEdit->setGeometry(QRect(160, 100, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
510 steptimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
511 steptimeEdit->setDecimals(0);
452
c4c5d02131be Limit mash steptime to 240 minutes. Limit mash steps to 82 degrees celsius. In estimate_fg limit total mash time to 240 minutes and increased the water/grain ration from 5.5 to 6 l/kg.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
512 steptimeEdit->setAccelerated(true);
c4c5d02131be Limit mash steptime to 240 minutes. Limit mash steps to 82 degrees celsius. In estimate_fg limit total mash time to 240 minutes and increased the water/grain ration from 5.5 to 6 l/kg.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
513 steptimeEdit->setMaximum(240.0);
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
514 steptimeEdit->setValue(recipe->mashs.at(recipe->mashs_row).step_time);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
515
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
516 QLabel *rampLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
517 rampLabel->setObjectName(QString::fromUtf8("rampLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
518 rampLabel->setText(tr("Step ramp time:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
519 rampLabel->setGeometry(QRect(360, 100, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
520 rampLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
521 ramptimeEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
522 ramptimeEdit->setObjectName(QString::fromUtf8("ramptimeEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
523 ramptimeEdit->setGeometry(QRect(510, 100, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
524 ramptimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
525 ramptimeEdit->setDecimals(0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
526 ramptimeEdit->setValue(recipe->mashs.at(recipe->mashs_row).ramp_time);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
527
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
528 /*
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
529 * Only used for Infusion steps.
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
530 */
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
531 ivolLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
532 ivolLabel->setObjectName(QString::fromUtf8("ivolLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
533 ivolLabel->setText(tr("Infusion volume:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
534 ivolLabel->setGeometry(QRect(10, 130, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
535 ivolLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
536 ivolLabel->setVisible(recipe->mashs.at(recipe->mashs_row).step_type == 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
537 stepivolEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
538 stepivolEdit->setObjectName(QString::fromUtf8("stepivolEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
539 stepivolEdit->setGeometry(QRect(160, 130, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
540 stepivolEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
541 stepivolEdit->setVisible(recipe->mashs.at(recipe->mashs_row).step_type == 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
542 stepivolEdit->setDecimals(1);
163
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
543 stepivolEdit->setAccelerated(true);
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
544 stepivolEdit->setMaximum(100000.0);
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
545 stepivolEdit->setSingleStep(0.5);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
546 stepivolEdit->setValue(recipe->mashs.at(recipe->mashs_row).step_infuse_amount);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
547
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
548 itmpLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
549 itmpLabel->setObjectName(QString::fromUtf8("itmpLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
550 itmpLabel->setText(tr("Infusion Temperature:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
551 itmpLabel->setGeometry(QRect(360, 130, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
552 itmpLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
553 itmpLabel->setVisible(recipe->mashs.at(recipe->mashs_row).step_type == 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
554 stepitmpEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
555 stepitmpEdit->setObjectName(QString::fromUtf8("stepitmpEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
556 stepitmpEdit->setGeometry(QRect(510, 130, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
557 stepitmpEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
558 stepitmpEdit->setVisible(recipe->mashs.at(recipe->mashs_row).step_type == 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
559 stepitmpEdit->setDecimals(1);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
560 stepitmpEdit->setReadOnly(true);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
561 stepitmpEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
562 stepitmpEdit->setValue(recipe->mashs.at(recipe->mashs_row).step_infuse_temp);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
563
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
564 connect(stepnameEdit, &QLineEdit::textEdited, this, &EditRecipe::step_name_changed);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
565 connect(typeEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::step_type_changed);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
566 connect(steptempEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::step_temp_changed);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
567 connect(endtempEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::end_temp_changed);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
568 connect(steptimeEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::step_time_changed);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
569 connect(ramptimeEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ramp_time_changed);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
570 connect(stepivolEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::infuse_changed);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
571 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
572 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
573
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
574 dialog->setModal(true);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
575 dialog->exec();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
576 if (dialog->result() == QDialog::Rejected) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
577 qDebug() << "reject and rollback";
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
578 recipe->mashs[recipe->mashs_row] = backup;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
579 /* Rollback water volumes too */
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
580 double volume = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
581 for (int i = 0; i < recipe->mashs.size(); i++) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
582 if (recipe->mashs.at(i).step_type == 0) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
583 volume += recipe->mashs.at(i).step_infuse_amount;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
584 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
585 recipe->mashs[i].step_volume = volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
586 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
587 recipe->w1_amount = volume - recipe->w2_amount;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
588 recipe->wg_amount = volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
589 ui->w1_volEdit->setValue(recipe->w1_amount);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
590 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
591
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
592 disconnect(stepnameEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
593 disconnect(steptempEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
594 disconnect(endtempEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
595 disconnect(steptimeEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
596 disconnect(ramptimeEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
597 disconnect(stepivolEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
598 disconnect(buttonBox, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
599
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
600 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
601 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
602
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
603
163
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
604 void EditRecipe::mash_name_changed(QString name)
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
605 {
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
606 qDebug() << "mash_name_changed" << name;
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
607 recipe->mash_name = name;
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
608 is_changed();
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
609 }
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
610
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
611
147
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
612 void EditRecipe::mash_select_changed(int val)
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
613 {
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
614 QSqlQuery query;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
615 int i;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
616
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
617 qDebug() << "mash_select_changed" << val;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
618
163
6cccd340ea8c Version 0.1.3. Mash name can be edited manual. Added a remark about EBC calculations. Updated dustch translation. Still items in recipe tables are not shown translated, another qt mistery. Extended some number input ranges for large batches.
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
619 const QSignalBlocker blocker1(ui->mash_nameEdit);
147
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
620 query.prepare("SELECT name,steps FROM profile_mash ORDER BY name");
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
621 query.exec();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
622 query.first();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
623 for (i = 0; i < (val -1); i++) {
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
624 query.next();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
625 }
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
626
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: 148
diff changeset
627 recipe->mash_name = query.value(0).toString();
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: 148
diff changeset
628 ui->mash_nameEdit->setText(recipe->mash_name);
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: 148
diff changeset
629
147
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
630 QJsonParseError parseError;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
631 const auto& json = query.value(1).toString();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
632 if (!json.trimmed().isEmpty()) {
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
633 const auto& formattedJson = QString("%1").arg(json);
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
634 QJsonDocument newsteps = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError);
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
635
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
636 if (parseError.error != QJsonParseError::NoError) {
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
637 qDebug() << "Parse error: " << parseError.errorString() << "at" << parseError.offset;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
638 } else {
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
639 /*
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
640 * Got the json data in the steps array, replace the recipe steps.
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
641 */
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: 148
diff changeset
642 double infuse = 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: 148
diff changeset
643 if (recipe->mashs.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: 148
diff changeset
644 infuse = recipe->mashs.at(0).step_infuse_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: 148
diff changeset
645 recipe->mashs.clear();
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: 148
diff changeset
646 ui->mashsTable->clear();
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: 148
diff changeset
647 }
147
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
648 if (newsteps.isArray()) {
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
649 for (i = 0; i < newsteps.array().size(); i++) {
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
650 QJsonObject obj = newsteps.array().at(i).toObject();
287
83e66c6b6e07 Renamed struct Mashs to MashSteps
Michiel Broek <mbroek@mbse.eu>
parents: 171
diff changeset
651 MashSteps m;
147
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
652 m.step_name = obj["step_name"].toString();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
653 if (obj["step_type"].isString())
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
654 m.step_type = QString(obj["step_type"].toString()).toInt();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
655 else
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
656 m.step_type = obj["step_type"].toInt();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
657 m.step_volume = 0;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
658 m.step_infuse_amount = 0;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
659 m.step_infuse_temp = 0;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
660 if (obj["step_temp"].isString())
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
661 m.step_temp = QString(obj["step_temp"].toString()).toDouble();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
662 else
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
663 m.step_temp = obj["step_temp"].toDouble();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
664 if (obj["step_time"].isString())
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
665 m.step_time = QString(obj["step_time"].toString()).toDouble();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
666 else
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
667 m.step_time = obj["step_time"].toDouble();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
668 if (obj["ramp_time"].isString())
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
669 m.ramp_time = QString(obj["ramp_time"].toString()).toDouble();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
670 else
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
671 m.ramp_time = obj["ramp_time"].toDouble();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
672 if (obj["end_temp"].isString())
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
673 m.end_temp = QString(obj["end_temp"].toString()).toDouble();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
674 else
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
675 m.end_temp = obj["end_temp"].toDouble();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
676 m.step_wg_ratio = 0;
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
677 recipe->mashs.append(m);
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
678 }
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
679 }
148
ba25a566b100 Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
680 if (recipe->mashs.at(0).step_type == 0)
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: 148
diff changeset
681 recipe->mashs[0].step_infuse_amount = infuse; // Restore saved initial infusion
147
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
682 }
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
683 }
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
684 is_changed();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
685 emit refreshAll();
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
686 }
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
687
af1386a6ece7 Added mash table replace
Michiel Broek <mbroek@mbse.eu>
parents: 146
diff changeset
688

mercurial