src/EditRecipeTab6.cpp

Tue, 19 Apr 2022 21:15:42 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 19 Apr 2022 21:15:42 +0200
changeset 145
fd4f0de86fd9
parent 144
c4b107bf153a
child 146
aad2f9f38fc5
permissions
-rw-r--r--

Implemented most parts of the mash editor.

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 qDebug() << "refreshYeasts" << recipe->yeasts.size();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
33 std::sort(recipe->yeasts.begin(), recipe->yeasts.end(), yeast_sort_test);
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 /*
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
36 * During filling the table turn off the cellChanged signal because every cell that is filled
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
37 * triggers the cellChanged signal. The QTableWidget has no better signal to use.
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
38 */
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
39 this->ignoreChanges = true;
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
40
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
41 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
42 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
43
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
44 ui->mashsTable->setColumnCount(14);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 ui->mashsTable->setHorizontalHeaderLabels(labels);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
60 ui->mashsTable->verticalHeader()->hide();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
61 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
62
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
63 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
64
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
65 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
66
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
67 item = new QTableWidgetItem(step_types[recipe->mashs.at(i).step_type]);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
68 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
69 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
70
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
71 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
72 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
73 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
74
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
75 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
76 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
77 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
78
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 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
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, 4, item);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
82
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
83 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
84 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
85 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
86
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
87 if (recipe->mashs.at(i).step_infuse_amount) {
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
88 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
89 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
90 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
91 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
92 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
93 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
94 } else {
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
95 ui->mashsTable->removeCellWidget(i, 6);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
96 ui->mashsTable->removeCellWidget(i, 7);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
97 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
98
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
99 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
100 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
101 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
102
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
103 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
104 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
105 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
106
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
107 if (i > 0) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
108 pWidget = new QWidget();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
109 QPushButton* btn_up = new QPushButton();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
110 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
111 btn_up->setIcon(up_icon);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
112 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
113 pLayout = new QHBoxLayout(pWidget);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
114 pLayout->addWidget(btn_up);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
115 pLayout->setContentsMargins(5, 0, 5, 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
116 pWidget->setLayout(pLayout);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
117 ui->mashsTable->setCellWidget(i, 10, pWidget);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
118 } else {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
119 ui->mashsTable->removeCellWidget(i, 10);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
120 }
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
121
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
122 if (i < (recipe->mashs.size() - 1)) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
123 pWidget = new QWidget();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
124 QPushButton* btn_down = new QPushButton();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
125 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
126 btn_down->setIcon(down_icon);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
127 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
128 pLayout = new QHBoxLayout(pWidget);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
129 pLayout->addWidget(btn_down);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
130 pLayout->setContentsMargins(5, 0, 5, 0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
131 pWidget->setLayout(pLayout);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
132 ui->mashsTable->setCellWidget(i, 11, pWidget);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
133 } else {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
134 ui->mashsTable->removeCellWidget(i, 11);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
135 }
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
136
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
137 pWidget = new QWidget();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
138 QPushButton* btn_dele = new QPushButton();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
139 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
140 btn_dele->setText(tr("Delete"));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
141 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
142 pLayout = new QHBoxLayout(pWidget);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
143 pLayout->addWidget(btn_dele);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
144 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
145 pWidget->setLayout(pLayout);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
146 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
147
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
148 pWidget = new QWidget();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
149 QPushButton* btn_edit = new QPushButton();
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
150 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
151 btn_edit->setText(tr("Edit"));
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
152 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
153 pLayout = new QHBoxLayout(pWidget);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
154 pLayout->addWidget(btn_edit);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
155 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
156 pWidget->setLayout(pLayout);
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
157 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
158 }
128
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 }
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160
0f4eee875ea6 More file splitting
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
162 void EditRecipe::addMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
163 {
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
164 Mashs newm;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
165
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
166 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
167 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
168 return; // Add only one at a time.
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
169 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
170
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
171 newm.step_name = "Name me";
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
172 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
173 newm.step_time = 20;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
174 newm.ramp_time = 10;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
175 if (recipe->mashs.size()) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
176 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
177 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
178 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
179 } else {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
180 newm.step_volume = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
181 newm.step_wg_ratio = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
182 newm.step_type = 1;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
183 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
184 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
185
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
186 recipe->mashs.append(newm);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
187 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
188 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
189 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
190
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
191
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
192 void EditRecipe::deleteMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
193 {
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
194 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
195 int row = pb->objectName().toInt();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
196 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
197
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
198 if (recipe->mashs.size() < 1)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
199 return;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
200
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
201 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
202 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
203 if (rc == QMessageBox::No)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
204 return;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
205
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
206 this->ignoreChanges = true;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
207 recipe->mashs.removeAt(row);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
208 this->ignoreChanges = false;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
209 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
210 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
211 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
212
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
213
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
214 void EditRecipe::upMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
215 {
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
216 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
217 int row = pb->objectName().toInt();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
218 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
219
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
220 if (recipe->mashs.size() < 1)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
221 return;
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
222 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
223
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
224
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
225 void EditRecipe::downMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
226 {
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
227 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
228 int row = pb->objectName().toInt();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
229 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
230
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
231 if (recipe->mashs.size() < 1)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
232 return;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
233 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
234
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
235
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
236 void EditRecipe::step_name_changed(QString val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
237 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
238 this->ignoreChanges = true;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
239 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
240 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
241 this->ignoreChanges = false;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
242 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
243 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
244
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
245
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
246 void EditRecipe::step_type_changed(int val)
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 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
249
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
250 this->ignoreChanges = true;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
251 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
252 this->ignoreChanges = false;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
253 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
254 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
255 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
256 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
257 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
258 emit refreshAll();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
259 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
260
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
261
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
262 void EditRecipe::step_temp_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
263 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
264 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
265 this->ignoreChanges = true;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
266 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
267 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
268 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
269 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
270 this->ignoreChanges = false;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
271 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
272 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
273
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
274
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
275 void EditRecipe::end_temp_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
276 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
277 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
278 this->ignoreChanges = true;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
279 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
280 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
281 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
282 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
283 this->ignoreChanges = false;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
284 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
285 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
286
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 void EditRecipe::step_time_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
289 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
290 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
291 this->ignoreChanges = true;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
292 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
293 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
294 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
295 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
296 this->ignoreChanges = false;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
297 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
298 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
299
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
300
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
301 void EditRecipe::ramp_time_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
302 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
303 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
304 this->ignoreChanges = true;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
305 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
306 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
307 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
308 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
309 this->ignoreChanges = false;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
310 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
311 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
312
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
313
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
314 void EditRecipe::infuse_changed(double val)
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
315 {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
316 qDebug() << "infuse_changed" << recipe->mashs_row << val;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
317 this->ignoreChanges = true;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
318 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
319 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
320 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
321 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
322
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
323 /*
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
324 * Recalculate water volumes
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
325 */
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
326 double volume = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
327 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
328 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
329 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
330 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
331 recipe->mashs[i].step_volume = volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
332 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
333 recipe->w1_amount = volume - recipe->w2_amount;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
334 recipe->wg_amount = volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
335 ui->w1_volEdit->setValue(recipe->w1_amount);
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 this->ignoreChanges = false;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
338 is_changed();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
339 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
340 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
341
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
342
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
343 void EditRecipe::editMashRow_clicked()
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
344 {
145
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
345 QSqlQuery query;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
346
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
347 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
348 recipe->mashs_row = pb->objectName().toInt();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
349 qDebug() << "Edit mash row" << recipe->mashs_row;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
350 Mashs backup = recipe->mashs.at(recipe->mashs_row);
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 QDialog* dialog = new QDialog(this);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
353 dialog->resize(738, 230);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
354 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
355 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
356 buttonBox->setGeometry(QRect(30, 180, 671, 32));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
357 buttonBox->setLayoutDirection(Qt::LeftToRight);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
358 buttonBox->setOrientation(Qt::Horizontal);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
359 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
360 buttonBox->setCenterButtons(true);
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 QLabel *nameLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
363 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
364 nameLabel->setText(tr("Step name:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
365 nameLabel->setGeometry(QRect(10, 10, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
366 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
367 stepnameEdit = new QLineEdit(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
368 stepnameEdit->setObjectName(QString::fromUtf8("stepnameEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
369 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
370 stepnameEdit->setGeometry(QRect(160, 10, 511, 23));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
371
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
372 QLabel *typeLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
373 typeLabel->setObjectName(QString::fromUtf8("typeLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
374 typeLabel->setText(tr("Step type:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
375 typeLabel->setGeometry(QRect(10, 40, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
376 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
377 QComboBox *typeEdit = new QComboBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
378 typeEdit->setObjectName(QString::fromUtf8("typeEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
379 typeEdit->setGeometry(QRect(160, 40, 161, 23));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
380 typeEdit->addItem(tr("Infusion"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
381 typeEdit->addItem(tr("Temperature"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
382 typeEdit->addItem(tr("Decoction"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
383 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
384
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
385 QLabel *tempLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
386 tempLabel->setObjectName(QString::fromUtf8("tempLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
387 tempLabel->setText(tr("Step start temp:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
388 tempLabel->setGeometry(QRect(10, 70, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
389 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
390 steptempEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
391 steptempEdit->setObjectName(QString::fromUtf8("steptempEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
392 steptempEdit->setGeometry(QRect(160, 70, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
393 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
394 steptempEdit->setDecimals(1);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
395 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
396
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
397 QLabel *endLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
398 endLabel->setObjectName(QString::fromUtf8("endLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
399 endLabel->setText(tr("Step end temp:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
400 endLabel->setGeometry(QRect(360, 70, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
401 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
402 endtempEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
403 endtempEdit->setObjectName(QString::fromUtf8("endtempEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
404 endtempEdit->setGeometry(QRect(510, 70, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
405 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
406 endtempEdit->setDecimals(1);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
407 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
408
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
409 QLabel *timeLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
410 timeLabel->setObjectName(QString::fromUtf8("timeLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
411 timeLabel->setText(tr("Step rest time:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
412 timeLabel->setGeometry(QRect(10, 100, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
413 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
414 steptimeEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
415 steptimeEdit->setObjectName(QString::fromUtf8("steptimeEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
416 steptimeEdit->setGeometry(QRect(160, 100, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
417 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
418 steptimeEdit->setDecimals(0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
419 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
420
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
421 QLabel *rampLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
422 rampLabel->setObjectName(QString::fromUtf8("rampLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
423 rampLabel->setText(tr("Step ramp time:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
424 rampLabel->setGeometry(QRect(360, 100, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
425 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
426 ramptimeEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
427 ramptimeEdit->setObjectName(QString::fromUtf8("ramptimeEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
428 ramptimeEdit->setGeometry(QRect(510, 100, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
429 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
430 ramptimeEdit->setDecimals(0);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
431 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
432
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
433 /*
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
434 * Only used for Infusion steps.
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
435 */
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
436 ivolLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
437 ivolLabel->setObjectName(QString::fromUtf8("ivolLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
438 ivolLabel->setText(tr("Infusion volume:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
439 ivolLabel->setGeometry(QRect(10, 130, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
440 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
441 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
442 stepivolEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
443 stepivolEdit->setObjectName(QString::fromUtf8("stepivolEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
444 stepivolEdit->setGeometry(QRect(160, 130, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
445 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
446 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
447 stepivolEdit->setDecimals(1);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
448 stepivolEdit->setSingleStep(0.5);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
449 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
450
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
451 itmpLabel = new QLabel(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
452 itmpLabel->setObjectName(QString::fromUtf8("itmpLabel"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
453 itmpLabel->setText(tr("Infusion Temperature:"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
454 itmpLabel->setGeometry(QRect(360, 130, 141, 20));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
455 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
456 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
457 stepitmpEdit = new QDoubleSpinBox(dialog);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
458 stepitmpEdit->setObjectName(QString::fromUtf8("stepitmpEdit"));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
459 stepitmpEdit->setGeometry(QRect(510, 130, 121, 24));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
460 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
461 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
462 stepitmpEdit->setDecimals(1);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
463 stepitmpEdit->setReadOnly(true);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
464 stepitmpEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
465 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
466
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
467 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
468 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
469 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
470 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
471 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
472 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
473 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
474 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
475 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
476
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
477 dialog->setModal(true);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
478 dialog->exec();
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
479 if (dialog->result() == QDialog::Rejected) {
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
480 qDebug() << "reject and rollback";
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
481 recipe->mashs[recipe->mashs_row] = backup;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
482 /* Rollback water volumes too */
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
483 double volume = 0;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
484 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
485 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
486 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
487 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
488 recipe->mashs[i].step_volume = volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
489 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
490 recipe->w1_amount = volume - recipe->w2_amount;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
491 recipe->wg_amount = volume;
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
492 ui->w1_volEdit->setValue(recipe->w1_amount);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
493 }
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
494
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
495 disconnect(stepnameEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
496 disconnect(steptempEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
497 disconnect(endtempEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
498 disconnect(steptimeEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
499 disconnect(ramptimeEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
500 disconnect(stepivolEdit, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
501 disconnect(buttonBox, nullptr, nullptr, nullptr);
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
502
fd4f0de86fd9 Implemented most parts of the mash editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
503 emit refreshAll();
144
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
504 }
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
505
c4b107bf153a First setup of the mash tab with the table.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
506

mercurial