26 qDebug() << "EditEquipment record:" << id; |
27 qDebug() << "EditEquipment record:" << id; |
27 ui->setupUi(this); |
28 ui->setupUi(this); |
28 this->recno = id; |
29 this->recno = id; |
29 |
30 |
30 WindowTitle(); |
31 WindowTitle(); |
31 |
32 |
32 ui->tun_materialEdit->addItem(tr("Stainless Steel")); |
33 for (int i = 0; i < 4; i++) |
33 ui->tun_materialEdit->addItem(tr("Aluminium")); |
34 ui->tun_materialEdit->addItem(QCoreApplication::translate("TunMaterial", g_tun_materials[i])); |
34 ui->tun_materialEdit->addItem(tr("Plastics")); |
35 |
35 ui->tun_materialEdit->addItem(tr("Copper")); |
36 for (int i = 0; i < 5; i++) |
|
37 ui->chiller_typeEdit->addItem(QCoreApplication::translate("ChillerType", g_chiller_types[i])); |
36 |
38 |
37 if (id >= 0) { |
39 if (id >= 0) { |
38 query.prepare("SELECT * FROM inventory_equipments WHERE record = :recno"); |
40 query.prepare("SELECT * FROM inventory_equipments WHERE record = :recno"); |
39 query.bindValue(":recno", id); |
41 query.bindValue(":recno", id); |
40 query.exec(); |
42 query.exec(); |
41 query.next(); |
43 query.next(); |
42 |
44 |
43 ui->nameEdit->setText(query.value(1).toString()); |
45 ui->nameEdit->setText(query.value("name").toString()); |
44 ui->boil_sizeEdit->setValue(query.value(2).toDouble()); |
46 ui->boil_sizeEdit->setValue(query.value("boil_size").toDouble()); |
45 ui->batch_sizeEdit->setValue(query.value(3).toDouble()); |
47 ui->batch_sizeEdit->setValue(query.value("batch_size").toDouble()); |
46 ui->tun_volumeEdit->setValue(query.value(4).toDouble()); |
48 ui->tun_volumeEdit->setValue(query.value("tun_volume").toDouble()); |
47 ui->tun_weightEdit->setValue(query.value(5).toDouble()); |
49 ui->tun_weightEdit->setValue(query.value("tun_weight").toDouble()); |
48 ui->tun_specific_heatEdit->setValue(query.value(6).toDouble()); |
50 ui->tun_specific_heatEdit->setValue(query.value("tun_specific_heat").toDouble()); |
49 ui->tun_materialEdit->setCurrentIndex(query.value(7).toInt()); |
51 ui->tun_materialEdit->setCurrentIndex(query.value("tun_material").toInt()); |
50 ui->tun_heightEdit->setValue(query.value(8).toDouble() * 100.0); |
52 ui->tun_heightEdit->setValue(query.value("tun_height").toDouble() * 100.0); |
51 ui->top_up_waterEdit->setValue(query.value(9).toDouble()); |
53 ui->top_up_waterEdit->setValue(query.value("top_up_water").toDouble()); |
52 ui->chiller_lossEdit->setValue(query.value(10).toDouble()); |
54 ui->trub_lossEdit->setValue(query.value("trub_chiller_loss").toDouble()); |
53 ui->evap_rateEdit->setValue(query.value(11).toDouble()); |
55 ui->evap_rateEdit->setValue(query.value("evap_rate").toDouble()); |
54 ui->boil_timeEdit->setValue(query.value(12).toDouble()); |
56 ui->boil_timeEdit->setValue(query.value("boil_time").toDouble()); |
55 ui->calcboilEdit->setChecked(query.value(13).toInt() ? true:false); |
57 ui->calcboilEdit->setChecked(query.value("calc_boil_volume").toInt() ? true:false); |
56 ui->top_up_kettleEdit->setValue(query.value(14).toDouble()); |
58 ui->top_up_kettleEdit->setValue(query.value("top_up_kettle").toDouble()); |
57 ui->hopfactorEdit->setValue(query.value(15).toDouble()); |
59 ui->notesEdit->setPlainText(query.value("notes").toString()); |
58 ui->notesEdit->setPlainText(query.value(16).toString()); |
60 ui->lauter_deadspaceEdit->setValue(query.value("lauter_deadspace").toDouble()); |
59 ui->lauter_volumeEdit->setValue(query.value(17).toDouble()); |
61 ui->kettle_volumeEdit->setValue(query.value("kettle_volume").toDouble()); |
60 ui->lauter_heightEdit->setValue(query.value(18).toDouble() * 100.0); |
62 ui->kettle_heightEdit->setValue(query.value("kettle_height").toDouble() * 100.0); |
61 ui->lauter_deadspaceEdit->setValue(query.value(19).toDouble()); |
63 ui->mash_volumeEdit->setValue(query.value("mash_volume").toDouble()); |
62 ui->kettle_volumeEdit->setValue(query.value(20).toDouble()); |
64 ui->mash_maxEdit->setValue(query.value("mash_max").toDouble()); |
63 ui->kettle_heightEdit->setValue(query.value(21).toDouble() * 100.0); |
65 ui->efficiencyEdit->setValue(query.value("efficiency").toDouble()); |
64 ui->mash_volumeEdit->setValue(query.value(22).toDouble()); |
66 ui->chiller_typeEdit->setCurrentIndex(query.value("chiller_type").toInt()); |
65 ui->mash_maxEdit->setValue(query.value(23).toDouble()); |
67 ui->chiller_to79Edit->setValue(query.value("chiller_to79").toDouble()); |
66 ui->efficiencyEdit->setValue(query.value(24).toDouble()); |
68 ui->chiller_lossEdit->setValue(query.value("chiller_loss").toDouble()); |
|
69 ui->chiller_volumeEdit->setValue(query.value("chiller_volume").toDouble()); |
|
70 ui->chiller_lpmEdit->setValue(query.value("chiller_lpm").toDouble()); |
67 /* |
71 /* |
68 * Now we have loaded this record, check if this equipment is |
72 * Now we have loaded this record, check if this equipment is |
69 * being used by a product. If so, make the name field read-only. |
73 * being used by a product. If so, make the name field read-only. |
70 */ |
74 */ |
71 query2.prepare("SELECT eq_name FROM products WHERE eq_name=:name"); |
75 query2.prepare("SELECT eq_name FROM products WHERE eq_name=:name"); |
72 query2.bindValue(":name", query.value(1).toString()); |
76 query2.bindValue(":name", query.value("name").toString()); |
73 query2.exec(); |
77 query2.exec(); |
74 inuse = query2.size(); |
78 inuse = query2.size(); |
75 ui->nameEdit->setReadOnly(inuse > 0); |
79 ui->nameEdit->setReadOnly(inuse > 0); |
76 } else { |
80 } else { |
77 /* Set some defaults */ |
81 /* Set some defaults */ |
81 ui->tun_weightEdit->setValue(2); |
85 ui->tun_weightEdit->setValue(2); |
82 ui->tun_specific_heatEdit->setValue(0.11); |
86 ui->tun_specific_heatEdit->setValue(0.11); |
83 ui->tun_materialEdit->setCurrentIndex(0); |
87 ui->tun_materialEdit->setCurrentIndex(0); |
84 ui->tun_heightEdit->setValue(20); |
88 ui->tun_heightEdit->setValue(20); |
85 ui->top_up_waterEdit->setValue(0); |
89 ui->top_up_waterEdit->setValue(0); |
86 ui->chiller_lossEdit->setValue(0.5); |
90 ui->trub_lossEdit->setValue(0.5); |
87 ui->evap_rateEdit->setValue(1.8); |
91 ui->evap_rateEdit->setValue(1.8); |
88 ui->boil_timeEdit->setValue(90); |
92 ui->boil_timeEdit->setValue(90); |
89 ui->calcboilEdit->setChecked(true); |
93 ui->calcboilEdit->setChecked(true); |
90 ui->top_up_kettleEdit->setValue(0); |
94 ui->top_up_kettleEdit->setValue(0); |
91 ui->hopfactorEdit->setValue(100); |
|
92 ui->lauter_volumeEdit->setValue(20); |
|
93 ui->lauter_heightEdit->setValue(20); |
|
94 ui->lauter_deadspaceEdit->setValue(0.5); |
95 ui->lauter_deadspaceEdit->setValue(0.5); |
95 ui->kettle_volumeEdit->setValue(20); |
96 ui->kettle_volumeEdit->setValue(20); |
96 ui->kettle_heightEdit->setValue(20); |
97 ui->kettle_heightEdit->setValue(20); |
97 ui->mash_volumeEdit->setValue(18); |
98 ui->mash_volumeEdit->setValue(18); |
98 ui->mash_maxEdit->setValue(6); |
99 ui->mash_maxEdit->setValue(6); |
99 ui->efficiencyEdit->setValue(75); |
100 ui->efficiencyEdit->setValue(75); |
|
101 ui->chiller_typeEdit->setCurrentIndex(1); |
|
102 ui->chiller_to79Edit->setValue(10); |
|
103 ui->chiller_lossEdit->setValue(0); |
|
104 ui->chiller_volumeEdit->setValue(0.5); |
|
105 ui->chiller_lpmEdit->setValue(0); |
100 inuse = 0; |
106 inuse = 0; |
101 } |
107 } |
|
108 /* Block select no chiller used */ |
|
109 qobject_cast<QStandardItemModel*>(ui->chiller_typeEdit->model())->item(CHILLER_TYPE_NONE)->setEnabled(false); |
|
110 chiller_setup(ui->chiller_typeEdit->currentIndex()); |
|
111 |
102 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditEquipment::is_changed); |
112 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditEquipment::is_changed); |
103 connect(ui->boil_sizeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
113 connect(ui->boil_sizeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
104 connect(ui->batch_sizeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
114 connect(ui->batch_sizeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
105 connect(ui->tun_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
115 connect(ui->tun_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
106 connect(ui->tun_weightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
116 connect(ui->tun_weightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
107 connect(ui->tun_materialEdit, &QComboBox::currentTextChanged, this, &EditEquipment::material_changed); |
117 connect(ui->tun_materialEdit, &QComboBox::currentTextChanged, this, &EditEquipment::material_changed); |
108 connect(ui->tun_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
118 connect(ui->tun_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
109 connect(ui->top_up_waterEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
119 connect(ui->top_up_waterEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
110 connect(ui->chiller_lossEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
120 connect(ui->trub_lossEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
111 connect(ui->evap_rateEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
121 connect(ui->evap_rateEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
112 connect(ui->boil_timeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
122 connect(ui->boil_timeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
113 connect(ui->calcboilEdit, &QCheckBox::stateChanged, this, &EditEquipment::is_changed); |
123 connect(ui->calcboilEdit, &QCheckBox::stateChanged, this, &EditEquipment::is_changed); |
114 connect(ui->top_up_kettleEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
124 connect(ui->top_up_kettleEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
115 connect(ui->hopfactorEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
|
116 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
125 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
117 connect(ui->lauter_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
|
118 connect(ui->lauter_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
|
119 connect(ui->lauter_deadspaceEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
126 connect(ui->lauter_deadspaceEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
120 connect(ui->kettle_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
127 connect(ui->kettle_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
121 connect(ui->kettle_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
128 connect(ui->kettle_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
122 connect(ui->mash_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
129 connect(ui->mash_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
123 connect(ui->mash_maxEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
130 connect(ui->mash_maxEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
124 connect(ui->efficiencyEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
131 connect(ui->efficiencyEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
|
132 connect(ui->chiller_typeEdit, &QComboBox::currentTextChanged, this, &EditEquipment::chiller_changed); |
|
133 connect(ui->chiller_to79Edit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
|
134 connect(ui->chiller_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
|
135 connect(ui->chiller_lpmEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
|
136 connect(ui->chiller_lossEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); |
125 |
137 |
126 calcBatchVolume(); |
138 calcBatchVolume(); |
127 ui->saveButton->setEnabled(false); |
139 ui->saveButton->setEnabled(false); |
128 ui->deleteButton->setEnabled((inuse == 0 && id >= 0) ? true:false); |
140 ui->deleteButton->setEnabled((inuse == 0 && id >= 0) ? true:false); |
129 } |
141 } |
157 |
169 |
158 |
170 |
159 void EditEquipment::on_saveButton_clicked() |
171 void EditEquipment::on_saveButton_clicked() |
160 { |
172 { |
161 QSqlQuery query; |
173 QSqlQuery query; |
|
174 QString sql = ""; |
162 |
175 |
163 /* If there are errors in the form, show a message and do "return;" */ |
176 /* If there are errors in the form, show a message and do "return;" */ |
164 if (ui->nameEdit->text().length() < 2) { |
177 if (ui->nameEdit->text().length() < 2) { |
165 QMessageBox::warning(this, tr("Edit Equipment"), tr("Name empty or too short.")); |
178 QMessageBox::warning(this, tr("Edit Equipment"), tr("Name empty or too short.")); |
166 return; |
179 return; |
167 } |
180 } |
168 |
181 |
169 if (this->textIsChanged) { |
182 if (this->textIsChanged) { |
170 if (this->recno == -1) { |
183 if (this->recno == -1) { |
171 query.prepare("INSERT INTO inventory_equipments SET name=:name, boil_size=:boil_size, " |
184 sql = "INSERT INTO"; |
|
185 } else { |
|
186 sql = "UPDATE"; |
|
187 } |
|
188 sql.append(" inventory_equipments SET name=:name, boil_size=:boil_size, " |
172 "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, " |
189 "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, " |
173 "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, " |
190 "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, " |
174 "top_up_water=:top_up_water, trub_chiller_loss=:chiller_loss, evap_rate=:evap_rate, " |
191 "top_up_water=:top_up_water, trub_chiller_loss=:trub_loss, evap_rate=:evap_rate, " |
175 "boil_time=:boil_time, calc_boil_volume=:calcboil, top_up_kettle=:top_up_kettle, " |
192 "boil_time=:boil_time, calc_boil_volume=:calcboil, top_up_kettle=:top_up_kettle, " |
176 "hop_utilization=:hopfactor, notes=:notes, lauter_volume=:lauter_volume, " |
193 "notes=:notes, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " |
177 "lauter_height=:lauter_height, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " |
|
178 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " |
194 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " |
179 "efficiency=:efficiency, uuid=:uuid"); |
195 "efficiency=:efficiency, chiller_type=:chiller_type, chiller_to79=:chiller_to79, " |
180 } else { |
196 "chiller_volume=:chiller_volume, chiller_lpm=:chiller_lpm, chiller_loss=:chiller_loss"); |
181 query.prepare("UPDATE inventory_equipments SET name=:name, boil_size=:boil_size, " |
197 if (this->recno == -1) { |
182 "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, " |
198 sql.append(", uuid=:uuid"); |
183 "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, " |
199 } else { |
184 "top_up_water=:top_up_water, trub_chiller_loss=:chiller_loss, evap_rate=:evap_rate, " |
200 sql.append(" WHERE record = :recno"); |
185 "boil_time=:boil_time, calc_boil_volume=:calcboil, top_up_kettle=:top_up_kettle, " |
201 } |
186 "hop_utilization=:hopfactor, notes=:notes, lauter_volume=:lauter_volume, " |
202 query.prepare(sql); |
187 "lauter_height=:lauter_height, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " |
|
188 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " |
|
189 "efficiency=:efficiency WHERE record=:recno"); |
|
190 } |
|
191 query.bindValue(":name", ui->nameEdit->text()); |
203 query.bindValue(":name", ui->nameEdit->text()); |
192 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0')); |
204 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0')); |
193 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0')); |
205 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0')); |
194 query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0')); |
206 query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0')); |
195 query.bindValue(":tun_weight", QString("%1").arg(ui->tun_weightEdit->value(), 2, 'f', 1, '0')); |
207 query.bindValue(":tun_weight", QString("%1").arg(ui->tun_weightEdit->value(), 2, 'f', 1, '0')); |
196 query.bindValue(":tun_specific_heat", QString("%1").arg(ui->tun_specific_heatEdit->value(), 4, 'f', 3, '0')); |
208 query.bindValue(":tun_specific_heat", QString("%1").arg(ui->tun_specific_heatEdit->value(), 4, 'f', 3, '0')); |
197 query.bindValue(":tun_material", ui->tun_materialEdit->currentIndex()); |
209 query.bindValue(":tun_material", ui->tun_materialEdit->currentIndex()); |
198 query.bindValue(":tun_height", QString("%1").arg(ui->tun_heightEdit->value() / 100, 4, 'f', 3, '0')); |
210 query.bindValue(":tun_height", QString("%1").arg(ui->tun_heightEdit->value() / 100, 4, 'f', 3, '0')); |
199 query.bindValue(":top_up_water", QString("%1").arg(ui->top_up_waterEdit->value(), 2, 'f', 1, '0')); |
211 query.bindValue(":top_up_water", QString("%1").arg(ui->top_up_waterEdit->value(), 2, 'f', 1, '0')); |
200 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 2, 'f', 1, '0')); |
212 query.bindValue(":trub_loss", QString("%1").arg(ui->trub_lossEdit->value(), 2, 'f', 1, '0')); |
201 query.bindValue(":evap_rate", QString("%1").arg(ui->evap_rateEdit->value(), 3, 'f', 2, '0')); |
213 query.bindValue(":evap_rate", QString("%1").arg(ui->evap_rateEdit->value(), 3, 'f', 2, '0')); |
202 query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 1, 'f', 0, '0')); |
214 query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 1, 'f', 0, '0')); |
203 query.bindValue(":calcboil", ui->calcboilEdit->isChecked() ? 1:0); |
215 query.bindValue(":calcboil", ui->calcboilEdit->isChecked() ? 1:0); |
204 query.bindValue(":top_up_kettle", QString("%1").arg(ui->top_up_kettleEdit->value(), 2, 'f', 1, '0')); |
216 query.bindValue(":top_up_kettle", QString("%1").arg(ui->top_up_kettleEdit->value(), 2, 'f', 1, '0')); |
205 query.bindValue(":hopfactor", QString("%1").arg(ui->hopfactorEdit->value(), 1, 'f', 0, '0')); |
|
206 query.bindValue(":notes", ui->notesEdit->toPlainText()); |
217 query.bindValue(":notes", ui->notesEdit->toPlainText()); |
207 query.bindValue(":lauter_volume", QString("%1").arg(ui->lauter_volumeEdit->value(), 2, 'f', 1, '0')); |
|
208 query.bindValue(":lauter_height", QString("%1").arg(ui->lauter_heightEdit->value() / 100, 4, 'f', 3, '0')); |
|
209 query.bindValue(":lauter_deadspace", QString("%1").arg(ui->lauter_deadspaceEdit->value(), 2, 'f', 1, '0')); |
218 query.bindValue(":lauter_deadspace", QString("%1").arg(ui->lauter_deadspaceEdit->value(), 2, 'f', 1, '0')); |
210 query.bindValue(":kettle_volume", QString("%1").arg(ui->kettle_volumeEdit->value(), 2, 'f', 1, '0')); |
219 query.bindValue(":kettle_volume", QString("%1").arg(ui->kettle_volumeEdit->value(), 2, 'f', 1, '0')); |
211 query.bindValue(":kettle_height", QString("%1").arg(ui->kettle_heightEdit->value() / 100, 4, 'f', 3, '0')); |
220 query.bindValue(":kettle_height", QString("%1").arg(ui->kettle_heightEdit->value() / 100, 4, 'f', 3, '0')); |
212 query.bindValue(":mash_volume", QString("%1").arg(ui->mash_volumeEdit->value(), 2, 'f', 1, '0')); |
221 query.bindValue(":mash_volume", QString("%1").arg(ui->mash_volumeEdit->value(), 2, 'f', 1, '0')); |
213 query.bindValue(":mash_max", QString("%1").arg(ui->mash_maxEdit->value(), 2, 'f', 1, '0')); |
222 query.bindValue(":mash_max", QString("%1").arg(ui->mash_maxEdit->value(), 2, 'f', 1, '0')); |
214 query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0')); |
223 query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0')); |
|
224 query.bindValue(":chiller_type", ui->chiller_typeEdit->currentIndex()); |
|
225 query.bindValue(":chiller_to79", QString("%1").arg(ui->chiller_to79Edit->value(), 1, 'f', 0, '0')); |
|
226 query.bindValue(":chiller_volume", QString("%1").arg(ui->chiller_volumeEdit->value(), 3, 'f', 2, '0')); |
|
227 query.bindValue(":chiller_lpm", QString("%1").arg(ui->chiller_lpmEdit->value(), 3, 'f', 2, '0')); |
|
228 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 3, 'f', 2, '0')); |
|
229 |
215 if (this->recno == -1) { |
230 if (this->recno == -1) { |
216 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
231 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
217 } else { |
232 } else { |
218 query.bindValue(":recno", this->recno); |
233 query.bindValue(":recno", this->recno); |
219 } |
234 } |
241 QSqlQuery query; |
256 QSqlQuery query; |
242 |
257 |
243 query.prepare("INSERT INTO inventory_equipments SET name=:name, boil_size=:boil_size, " |
258 query.prepare("INSERT INTO inventory_equipments SET name=:name, boil_size=:boil_size, " |
244 "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, " |
259 "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, " |
245 "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, " |
260 "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, " |
246 "top_up_water=:top_up_water, trub_chiller_loss=:chiller_loss, evap_rate=:evap_rate, " |
261 "top_up_water=:top_up_water, trub_chiller_loss=:trub_loss, evap_rate=:evap_rate, " |
247 "boil_time=:boil_time, calc_boil_volume=:calcboil, top_up_kettle=:top_up_kettle, " |
262 "boil_time=:boil_time, calc_boil_volume=:calcboil, top_up_kettle=:top_up_kettle, " |
248 "hop_utilization=:hopfactor, notes=:notes, lauter_volume=:lauter_volume, " |
263 "notes=:notes, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " |
249 "lauter_height=:lauter_height, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " |
|
250 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " |
264 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " |
251 "efficiency=:efficiency, uuid=:uuid"); |
265 "efficiency=:efficiency, chiller_type=:chiller_type, chiller_to79=:chiller_to79, " |
|
266 "chiller_volume=:chiller_volume, chiller_lpm=:chiller_lpm, chiller_loss=:chiller_loss, uuid=:uuid"); |
252 |
267 |
253 query.bindValue(":name", ui->nameEdit->text() + " [copy]"); |
268 query.bindValue(":name", ui->nameEdit->text() + " [copy]"); |
254 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0')); |
269 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0')); |
255 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0')); |
270 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0')); |
256 query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0')); |
271 query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0')); |
257 query.bindValue(":tun_weight", QString("%1").arg(ui->tun_weightEdit->value(), 2, 'f', 1, '0')); |
272 query.bindValue(":tun_weight", QString("%1").arg(ui->tun_weightEdit->value(), 2, 'f', 1, '0')); |
258 query.bindValue(":tun_specific_heat", QString("%1").arg(ui->tun_specific_heatEdit->value(), 4, 'f', 3, '0')); |
273 query.bindValue(":tun_specific_heat", QString("%1").arg(ui->tun_specific_heatEdit->value(), 4, 'f', 3, '0')); |
259 query.bindValue(":tun_material", ui->tun_materialEdit->currentIndex()); |
274 query.bindValue(":tun_material", ui->tun_materialEdit->currentIndex()); |
260 query.bindValue(":tun_height", QString("%1").arg(ui->tun_heightEdit->value() / 100, 4, 'f', 3, '0')); |
275 query.bindValue(":tun_height", QString("%1").arg(ui->tun_heightEdit->value() / 100, 4, 'f', 3, '0')); |
261 query.bindValue(":top_up_water", QString("%1").arg(ui->top_up_waterEdit->value(), 2, 'f', 1, '0')); |
276 query.bindValue(":top_up_water", QString("%1").arg(ui->top_up_waterEdit->value(), 2, 'f', 1, '0')); |
262 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 2, 'f', 1, '0')); |
277 query.bindValue(":trub_loss", QString("%1").arg(ui->trub_lossEdit->value(), 2, 'f', 1, '0')); |
263 query.bindValue(":evap_rate", QString("%1").arg(ui->evap_rateEdit->value(), 3, 'f', 2, '0')); |
278 query.bindValue(":evap_rate", QString("%1").arg(ui->evap_rateEdit->value(), 3, 'f', 2, '0')); |
264 query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 1, 'f', 0, '0')); |
279 query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 1, 'f', 0, '0')); |
265 query.bindValue(":calcboil", ui->calcboilEdit->isChecked() ? 1:0); |
280 query.bindValue(":calcboil", ui->calcboilEdit->isChecked() ? 1:0); |
266 query.bindValue(":top_up_kettle", QString("%1").arg(ui->top_up_kettleEdit->value(), 2, 'f', 1, '0')); |
281 query.bindValue(":top_up_kettle", QString("%1").arg(ui->top_up_kettleEdit->value(), 2, 'f', 1, '0')); |
267 query.bindValue(":hopfactor", QString("%1").arg(ui->hopfactorEdit->value(), 1, 'f', 0, '0')); |
|
268 query.bindValue(":notes", ui->notesEdit->toPlainText()); |
282 query.bindValue(":notes", ui->notesEdit->toPlainText()); |
269 query.bindValue(":lauter_volume", QString("%1").arg(ui->lauter_volumeEdit->value(), 2, 'f', 1, '0')); |
|
270 query.bindValue(":lauter_height", QString("%1").arg(ui->lauter_heightEdit->value() / 100, 4, 'f', 3, '0')); |
|
271 query.bindValue(":lauter_deadspace", QString("%1").arg(ui->lauter_deadspaceEdit->value(), 2, 'f', 1, '0')); |
283 query.bindValue(":lauter_deadspace", QString("%1").arg(ui->lauter_deadspaceEdit->value(), 2, 'f', 1, '0')); |
272 query.bindValue(":kettle_volume", QString("%1").arg(ui->kettle_volumeEdit->value(), 2, 'f', 1, '0')); |
284 query.bindValue(":kettle_volume", QString("%1").arg(ui->kettle_volumeEdit->value(), 2, 'f', 1, '0')); |
273 query.bindValue(":kettle_height", QString("%1").arg(ui->kettle_heightEdit->value() / 100, 4, 'f', 3, '0')); |
285 query.bindValue(":kettle_height", QString("%1").arg(ui->kettle_heightEdit->value() / 100, 4, 'f', 3, '0')); |
274 query.bindValue(":mash_volume", QString("%1").arg(ui->mash_volumeEdit->value(), 2, 'f', 1, '0')); |
286 query.bindValue(":mash_volume", QString("%1").arg(ui->mash_volumeEdit->value(), 2, 'f', 1, '0')); |
275 query.bindValue(":mash_max", QString("%1").arg(ui->mash_maxEdit->value(), 2, 'f', 1, '0')); |
287 query.bindValue(":mash_max", QString("%1").arg(ui->mash_maxEdit->value(), 2, 'f', 1, '0')); |
276 query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0')); |
288 query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0')); |
277 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
289 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
|
290 query.bindValue(":chiller_type", ui->chiller_typeEdit->currentIndex()); |
|
291 query.bindValue(":chiller_to79", QString("%1").arg(ui->chiller_to79Edit->value(), 1, 'f', 0, '0')); |
|
292 query.bindValue(":chiller_volume", QString("%1").arg(ui->chiller_volumeEdit->value(), 3, 'f', 2, '0')); |
|
293 query.bindValue(":chiller_lpm", QString("%1").arg(ui->chiller_lpmEdit->value(), 3, 'f', 2, '0')); |
|
294 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 3, 'f', 2, '0')); |
278 query.exec(); |
295 query.exec(); |
279 if (query.lastError().isValid()) { |
296 if (query.lastError().isValid()) { |
280 qWarning() << "EditEquipment" << query.lastError(); |
297 qWarning() << "EditEquipment" << query.lastError(); |
281 QMessageBox::warning(this, tr("Database error"), |
298 QMessageBox::warning(this, tr("Database error"), |
282 tr("MySQL error: %1\n%2\n%3") |
299 tr("MySQL error: %1\n%2\n%3") |
343 case 0: ui->tun_specific_heatEdit->setValue(0.11); break; |
362 case 0: ui->tun_specific_heatEdit->setValue(0.11); break; |
344 case 1: ui->tun_specific_heatEdit->setValue(0.22); break; |
363 case 1: ui->tun_specific_heatEdit->setValue(0.22); break; |
345 case 2: ui->tun_specific_heatEdit->setValue(0.46); break; |
364 case 2: ui->tun_specific_heatEdit->setValue(0.46); break; |
346 case 3: ui->tun_specific_heatEdit->setValue(0.092); break; |
365 case 3: ui->tun_specific_heatEdit->setValue(0.092); break; |
347 } |
366 } |
|
367 is_changed(); |
|
368 } |
|
369 |
|
370 |
|
371 void EditEquipment::chiller_setup(int val) |
|
372 { |
|
373 if (val == CHILLER_TYPE_IMMERSION) { |
|
374 ui->chiller_volumeEdit->setReadOnly(false); |
|
375 ui->chiller_volumeEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows); |
|
376 ui->chiller_volumeEdit->setFixedSize(101, 24); |
|
377 if (ui->chiller_volumeEdit->value() == 0) |
|
378 ui->chiller_volumeEdit->setValue(0.5); |
|
379 } else { |
|
380 ui->chiller_volumeEdit->setReadOnly(true); |
|
381 ui->chiller_volumeEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
|
382 ui->chiller_volumeEdit->setFixedSize(86, 24); |
|
383 ui->chiller_volumeEdit->setValue(0); |
|
384 } |
|
385 |
|
386 if (val == CHILLER_TYPE_COUNTERFLOW) { |
|
387 ui->chiller_to79Edit->setReadOnly(true); |
|
388 ui->chiller_to79Edit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
|
389 ui->chiller_to79Edit->setFixedSize(86, 24); |
|
390 ui->chiller_to79Edit->setValue(0); |
|
391 |
|
392 ui->chiller_lpmEdit->setReadOnly(false); |
|
393 ui->chiller_lpmEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows); |
|
394 ui->chiller_lpmEdit->setFixedSize(101, 24); |
|
395 if (ui->chiller_lpmEdit->value() == 0) |
|
396 ui->chiller_lpmEdit->setValue(2.5); |
|
397 |
|
398 ui->chiller_lossEdit->setReadOnly(false); |
|
399 ui->chiller_lossEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows); |
|
400 ui->chiller_lossEdit->setFixedSize(101, 24); |
|
401 if (ui->chiller_lossEdit->value() == 0) |
|
402 ui->chiller_lossEdit->setValue(3); |
|
403 |
|
404 } else { |
|
405 ui->chiller_to79Edit->setReadOnly(false); |
|
406 ui->chiller_to79Edit->setButtonSymbols(QAbstractSpinBox::UpDownArrows); |
|
407 ui->chiller_to79Edit->setFixedSize(101, 24); |
|
408 int time = 5; |
|
409 if (val == CHILLER_TYPE_AUBAINMARIE) |
|
410 time = 20; |
|
411 if (val == CHILLER_TYPE_NOCHILL) |
|
412 time = 240; |
|
413 if (ui->chiller_to79Edit->value() == 0) |
|
414 ui->chiller_to79Edit->setValue(time); |
|
415 |
|
416 ui->chiller_lpmEdit->setReadOnly(true); |
|
417 ui->chiller_lpmEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
|
418 ui->chiller_lpmEdit->setFixedSize(86, 24); |
|
419 ui->chiller_lpmEdit->setValue(0); |
|
420 |
|
421 ui->chiller_lossEdit->setReadOnly(true); |
|
422 ui->chiller_lossEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
|
423 ui->chiller_lossEdit->setFixedSize(86, 24); |
|
424 ui->chiller_lossEdit->setValue(0); |
|
425 } |
|
426 } |
|
427 |
|
428 |
|
429 void EditEquipment::chiller_changed() |
|
430 { |
|
431 const QSignalBlocker blocker1(ui->chiller_to79Edit); |
|
432 const QSignalBlocker blocker2(ui->chiller_volumeEdit); |
|
433 const QSignalBlocker blocker3(ui->chiller_lpmEdit); |
|
434 const QSignalBlocker blocker4(ui->chiller_lossEdit); |
|
435 |
|
436 chiller_setup(ui->chiller_typeEdit->currentIndex()); |
348 is_changed(); |
437 is_changed(); |
349 } |
438 } |
350 |
439 |
351 |
440 |
352 void EditEquipment::on_quitButton_clicked() |
441 void EditEquipment::on_quitButton_clicked() |