src/EditEquipment.cpp

Tue, 05 Mar 2024 10:25:15 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 05 Mar 2024 10:25:15 +0100
changeset 521
5fbe71d69fe5
parent 462
1654ff5446c7
permissions
-rw-r--r--

Clear mash measurments when duplicating a product.

30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditEquipment.cpp is part of bmsapp.
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
17 #include "MainWindow.h"
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "EditEquipment.h"
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "../ui/ui_EditEquipment.h"
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
20 #include "global.h"
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 EditEquipment::EditEquipment(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditEquipment)
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 QSqlQuery query, query2;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 qDebug() << "EditEquipment record:" << id;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 ui->setupUi(this);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 this->recno = id;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 WindowTitle();
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
32
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
33 for (int i = 0; i < 4; i++)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
34 ui->tun_materialEdit->addItem(QCoreApplication::translate("TunMaterial", g_tun_materials[i]));
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
35
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
36 for (int i = 0; i < 5; i++)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
37 ui->chiller_typeEdit->addItem(QCoreApplication::translate("ChillerType", g_chiller_types[i]));
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 if (id >= 0) {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 query.prepare("SELECT * FROM inventory_equipments WHERE record = :recno");
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 query.bindValue(":recno", id);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 query.exec();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 query.next();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
45 ui->nameEdit->setText(query.value("name").toString());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
46 ui->boil_sizeEdit->setValue(query.value("boil_size").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
47 ui->batch_sizeEdit->setValue(query.value("batch_size").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
48 ui->tun_volumeEdit->setValue(query.value("tun_volume").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
49 ui->tun_weightEdit->setValue(query.value("tun_weight").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
50 ui->tun_specific_heatEdit->setValue(query.value("tun_specific_heat").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
51 ui->tun_materialEdit->setCurrentIndex(query.value("tun_material").toInt());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
52 ui->tun_heightEdit->setValue(query.value("tun_height").toDouble() * 100.0);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
53 ui->top_up_waterEdit->setValue(query.value("top_up_water").toDouble());
458
ac216a75ca9b Renamed trub_chiller_loss fields to trub_loss
Michiel Broek <mbroek@mbse.eu>
parents: 423
diff changeset
54 ui->trub_lossEdit->setValue(query.value("trub_loss").toDouble());
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
55 ui->evap_rateEdit->setValue(query.value("evap_rate").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
56 ui->boil_timeEdit->setValue(query.value("boil_time").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
57 ui->top_up_kettleEdit->setValue(query.value("top_up_kettle").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
58 ui->notesEdit->setPlainText(query.value("notes").toString());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
59 ui->lauter_deadspaceEdit->setValue(query.value("lauter_deadspace").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
60 ui->kettle_volumeEdit->setValue(query.value("kettle_volume").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
61 ui->kettle_heightEdit->setValue(query.value("kettle_height").toDouble() * 100.0);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
62 ui->mash_volumeEdit->setValue(query.value("mash_volume").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
63 ui->mash_maxEdit->setValue(query.value("mash_max").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
64 ui->efficiencyEdit->setValue(query.value("efficiency").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
65 ui->chiller_typeEdit->setCurrentIndex(query.value("chiller_type").toInt());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
66 ui->chiller_to79Edit->setValue(query.value("chiller_to79").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
67 ui->chiller_lossEdit->setValue(query.value("chiller_loss").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
68 ui->chiller_volumeEdit->setValue(query.value("chiller_volume").toDouble());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
69 ui->chiller_lpmEdit->setValue(query.value("chiller_lpm").toDouble());
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 /*
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 * Now we have loaded this record, check if this equipment is
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 * being used by a product. If so, make the name field read-only.
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 */
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 query2.prepare("SELECT eq_name FROM products WHERE eq_name=:name");
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
75 query2.bindValue(":name", query.value("name").toString());
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 query2.exec();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 inuse = query2.size();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 ui->nameEdit->setReadOnly(inuse > 0);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 } else {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 /* Set some defaults */
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 ui->boil_sizeEdit->setValue(18);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 ui->batch_sizeEdit->setValue(15.3);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 ui->tun_volumeEdit->setValue(20);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 ui->tun_weightEdit->setValue(2);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 ui->tun_specific_heatEdit->setValue(0.11);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 ui->tun_materialEdit->setCurrentIndex(0);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 ui->tun_heightEdit->setValue(20);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 ui->top_up_waterEdit->setValue(0);
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
89 ui->trub_lossEdit->setValue(0.5);
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 ui->evap_rateEdit->setValue(1.8);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 ui->boil_timeEdit->setValue(90);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 ui->top_up_kettleEdit->setValue(0);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 ui->lauter_deadspaceEdit->setValue(0.5);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 ui->kettle_volumeEdit->setValue(20);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 ui->kettle_heightEdit->setValue(20);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 ui->mash_volumeEdit->setValue(18);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 ui->mash_maxEdit->setValue(6);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 ui->efficiencyEdit->setValue(75);
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
99 ui->chiller_typeEdit->setCurrentIndex(1);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
100 ui->chiller_to79Edit->setValue(10);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
101 ui->chiller_lossEdit->setValue(0);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
102 ui->chiller_volumeEdit->setValue(0.5);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
103 ui->chiller_lpmEdit->setValue(0);
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 inuse = 0;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 }
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
106 /* Block select no chiller used */
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
107 qobject_cast<QStandardItemModel*>(ui->chiller_typeEdit->model())->item(CHILLER_TYPE_NONE)->setEnabled(false);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
108 chiller_setup(ui->chiller_typeEdit->currentIndex());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
109
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 connect(ui->boil_sizeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 connect(ui->batch_sizeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 connect(ui->tun_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 connect(ui->tun_weightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 connect(ui->tun_materialEdit, &QComboBox::currentTextChanged, this, &EditEquipment::material_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 connect(ui->tun_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 connect(ui->top_up_waterEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
118 connect(ui->trub_lossEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 connect(ui->evap_rateEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 connect(ui->boil_timeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 connect(ui->top_up_kettleEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 connect(ui->lauter_deadspaceEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 connect(ui->kettle_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 connect(ui->kettle_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 connect(ui->mash_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 connect(ui->mash_maxEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 connect(ui->efficiencyEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
129 connect(ui->chiller_typeEdit, &QComboBox::currentTextChanged, this, &EditEquipment::chiller_changed);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
130 connect(ui->chiller_to79Edit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
131 connect(ui->chiller_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
132 connect(ui->chiller_lpmEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
133 connect(ui->chiller_lossEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed);
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 calcBatchVolume();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 ui->saveButton->setEnabled(false);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 ui->deleteButton->setEnabled((inuse == 0 && id >= 0) ? true:false);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 EditEquipment::~EditEquipment()
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 delete ui;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 emit entry_changed();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 /*
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 * Window header, mark any change with '**'
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 */
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 void EditEquipment::WindowTitle()
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 QString txt;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 if (this->recno < 0) {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 txt = QString(tr("BMSapp - Add new equipment"));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 } else {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 txt = QString(tr("BMSapp - Edit equipment %1").arg(this->recno));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 if (this->textIsChanged) {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 txt.append((QString(" **")));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 setWindowTitle(txt);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 void EditEquipment::on_saveButton_clicked()
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 QSqlQuery query;
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
171 QString sql = "";
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 /* If there are errors in the form, show a message and do "return;" */
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 if (ui->nameEdit->text().length() < 2) {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 QMessageBox::warning(this, tr("Edit Equipment"), tr("Name empty or too short."));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 return;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 if (this->textIsChanged) {
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
180 if (this->recno == -1) {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
181 sql = "INSERT INTO";
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
182 } else {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
183 sql = "UPDATE";
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
184 }
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
185 sql.append(" inventory_equipments SET name=:name, boil_size=:boil_size, "
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, "
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, "
458
ac216a75ca9b Renamed trub_chiller_loss fields to trub_loss
Michiel Broek <mbroek@mbse.eu>
parents: 423
diff changeset
188 "top_up_water=:top_up_water, trub_loss=:trub_loss, evap_rate=:evap_rate, "
462
1654ff5446c7 Removed the last bits of equipent calc_volume setting. Changed to the equipment setup screen using suffixes in the fields. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
189 "boil_time=:boil_time, top_up_kettle=:top_up_kettle, "
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
190 "notes=:notes, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, "
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, "
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
192 "efficiency=:efficiency, chiller_type=:chiller_type, chiller_to79=:chiller_to79, "
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
193 "chiller_volume=:chiller_volume, chiller_lpm=:chiller_lpm, chiller_loss=:chiller_loss");
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
194 if (this->recno == -1) {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
195 sql.append(", uuid=:uuid");
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
196 } else {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
197 sql.append(" WHERE record = :recno");
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
198 }
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
199 query.prepare(sql);
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 query.bindValue(":name", ui->nameEdit->text());
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 query.bindValue(":tun_weight", QString("%1").arg(ui->tun_weightEdit->value(), 2, 'f', 1, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 query.bindValue(":tun_specific_heat", QString("%1").arg(ui->tun_specific_heatEdit->value(), 4, 'f', 3, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 query.bindValue(":tun_material", ui->tun_materialEdit->currentIndex());
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 query.bindValue(":tun_height", QString("%1").arg(ui->tun_heightEdit->value() / 100, 4, 'f', 3, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 query.bindValue(":top_up_water", QString("%1").arg(ui->top_up_waterEdit->value(), 2, 'f', 1, '0'));
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
209 query.bindValue(":trub_loss", QString("%1").arg(ui->trub_lossEdit->value(), 2, 'f', 1, '0'));
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 query.bindValue(":evap_rate", QString("%1").arg(ui->evap_rateEdit->value(), 3, 'f', 2, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 1, 'f', 0, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 query.bindValue(":top_up_kettle", QString("%1").arg(ui->top_up_kettleEdit->value(), 2, 'f', 1, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 query.bindValue(":notes", ui->notesEdit->toPlainText());
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 query.bindValue(":lauter_deadspace", QString("%1").arg(ui->lauter_deadspaceEdit->value(), 2, 'f', 1, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 query.bindValue(":kettle_volume", QString("%1").arg(ui->kettle_volumeEdit->value(), 2, 'f', 1, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 query.bindValue(":kettle_height", QString("%1").arg(ui->kettle_heightEdit->value() / 100, 4, 'f', 3, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 query.bindValue(":mash_volume", QString("%1").arg(ui->mash_volumeEdit->value(), 2, 'f', 1, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 query.bindValue(":mash_max", QString("%1").arg(ui->mash_maxEdit->value(), 2, 'f', 1, '0'));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0'));
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
220 query.bindValue(":chiller_type", ui->chiller_typeEdit->currentIndex());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
221 query.bindValue(":chiller_to79", QString("%1").arg(ui->chiller_to79Edit->value(), 1, 'f', 0, '0'));
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
222 query.bindValue(":chiller_volume", QString("%1").arg(ui->chiller_volumeEdit->value(), 3, 'f', 2, '0'));
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
223 query.bindValue(":chiller_lpm", QString("%1").arg(ui->chiller_lpmEdit->value(), 3, 'f', 2, '0'));
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
224 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 3, 'f', 2, '0'));
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
225
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 if (this->recno == -1) {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 } else {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 query.bindValue(":recno", this->recno);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 query.exec();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 if (query.lastError().isValid()) {
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
233 qWarning() << "EditEquipment" << query.lastError();
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 QMessageBox::warning(this, tr("Database error"),
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 tr("MySQL error: %1\n%2\n%3")
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 .arg(query.lastError().nativeErrorCode())
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 .arg(query.lastError().driverText())
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 .arg(query.lastError().databaseText()));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 } else {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 qDebug() << "EditEquipment Saved";
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 ui->saveButton->setEnabled(false);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 this->textIsChanged = false;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 WindowTitle();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
250 void EditEquipment::on_cloneButton_clicked()
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
251 {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
252 QSqlQuery query;
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
253
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
254 query.prepare("INSERT INTO inventory_equipments SET name=:name, boil_size=:boil_size, "
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
255 "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, "
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
256 "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, "
458
ac216a75ca9b Renamed trub_chiller_loss fields to trub_loss
Michiel Broek <mbroek@mbse.eu>
parents: 423
diff changeset
257 "top_up_water=:top_up_water, trub_loss=:trub_loss, evap_rate=:evap_rate, "
462
1654ff5446c7 Removed the last bits of equipent calc_volume setting. Changed to the equipment setup screen using suffixes in the fields. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
258 "boil_time=:boil_time, top_up_kettle=:top_up_kettle, "
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
259 "notes=:notes, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, "
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
260 "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, "
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
261 "efficiency=:efficiency, chiller_type=:chiller_type, chiller_to79=:chiller_to79, "
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
262 "chiller_volume=:chiller_volume, chiller_lpm=:chiller_lpm, chiller_loss=:chiller_loss, uuid=:uuid");
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
263
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
264 query.bindValue(":name", ui->nameEdit->text() + " [copy]");
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
265 query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
266 query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
267 query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
268 query.bindValue(":tun_weight", QString("%1").arg(ui->tun_weightEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
269 query.bindValue(":tun_specific_heat", QString("%1").arg(ui->tun_specific_heatEdit->value(), 4, 'f', 3, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
270 query.bindValue(":tun_material", ui->tun_materialEdit->currentIndex());
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
271 query.bindValue(":tun_height", QString("%1").arg(ui->tun_heightEdit->value() / 100, 4, 'f', 3, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
272 query.bindValue(":top_up_water", QString("%1").arg(ui->top_up_waterEdit->value(), 2, 'f', 1, '0'));
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
273 query.bindValue(":trub_loss", QString("%1").arg(ui->trub_lossEdit->value(), 2, 'f', 1, '0'));
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
274 query.bindValue(":evap_rate", QString("%1").arg(ui->evap_rateEdit->value(), 3, 'f', 2, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
275 query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 1, 'f', 0, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
276 query.bindValue(":top_up_kettle", QString("%1").arg(ui->top_up_kettleEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
277 query.bindValue(":notes", ui->notesEdit->toPlainText());
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
278 query.bindValue(":lauter_deadspace", QString("%1").arg(ui->lauter_deadspaceEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
279 query.bindValue(":kettle_volume", QString("%1").arg(ui->kettle_volumeEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
280 query.bindValue(":kettle_height", QString("%1").arg(ui->kettle_heightEdit->value() / 100, 4, 'f', 3, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
281 query.bindValue(":mash_volume", QString("%1").arg(ui->mash_volumeEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
282 query.bindValue(":mash_max", QString("%1").arg(ui->mash_maxEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
283 query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
284 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
285 query.bindValue(":chiller_type", ui->chiller_typeEdit->currentIndex());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
286 query.bindValue(":chiller_to79", QString("%1").arg(ui->chiller_to79Edit->value(), 1, 'f', 0, '0'));
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
287 query.bindValue(":chiller_volume", QString("%1").arg(ui->chiller_volumeEdit->value(), 3, 'f', 2, '0'));
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
288 query.bindValue(":chiller_lpm", QString("%1").arg(ui->chiller_lpmEdit->value(), 3, 'f', 2, '0'));
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
289 query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 3, 'f', 2, '0'));
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
290 query.exec();
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
291 if (query.lastError().isValid()) {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
292 qWarning() << "EditEquipment" << query.lastError();
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
293 QMessageBox::warning(this, tr("Database error"),
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
294 tr("MySQL error: %1\n%2\n%3")
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
295 .arg(query.lastError().nativeErrorCode())
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
296 .arg(query.lastError().driverText())
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
297 .arg(query.lastError().databaseText()));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
298 } else {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
299 qDebug() << "EditEquipment Saved";
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
300 }
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
301 }
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
302
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
303
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 void EditEquipment::on_deleteButton_clicked()
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 QSqlQuery query;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
308 int rc = QMessageBox::warning(this, tr("Delete equipment"), tr("Delete %1").arg(ui->nameEdit->text()),
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
309 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
310 if (rc == QMessageBox::No)
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
311 return;
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
312
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 query.prepare("DELETE FROM inventory_equipments WHERE record = :recno");
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 query.bindValue(":recno", this->recno);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 query.exec();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 if (query.lastError().isValid()) {
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
317 qWarning() << "EditEquipment" << query.lastError();
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 QMessageBox::warning(this, tr("Database error"),
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 tr("MySQL error: %1\n%2\n%3")
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 .arg(query.lastError().nativeErrorCode())
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 .arg(query.lastError().driverText())
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 .arg(query.lastError().databaseText()));
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 } else {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 qDebug() << "EditEquipment Deleted" << this->recno;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 this->close();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 this->setResult(1);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 void EditEquipment::calcBatchVolume()
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 double batch = ui->boil_sizeEdit->value() - (ui->evap_rateEdit->value() * ui->boil_timeEdit->value() / 60) + ui->top_up_kettleEdit->value();
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
335 double fermenter = round(((batch / 1.04) + ui->top_up_waterEdit->value() - ui->trub_lossEdit->value() - ui->chiller_lossEdit->value()) * 100) / 100.0;
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 batch = round(batch * 100) / 100.0;
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
337 if (ui->batch_sizeEdit->value() != batch)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
338 qDebug() << "Batch volue updated to" << batch;
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 ui->batch_sizeEdit->setValue(batch);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 ui->vol_fermenterEdit->setValue(fermenter);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 void EditEquipment::is_changed()
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 calcBatchVolume();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 ui->saveButton->setEnabled(true);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 ui->deleteButton->setEnabled((inuse == 0 && this->recno >= 0) ? true:false);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 this->textIsChanged = true;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 WindowTitle();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 void EditEquipment::material_changed()
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 switch (ui->tun_materialEdit->currentIndex()) {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 case 0: ui->tun_specific_heatEdit->setValue(0.11); break;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 case 1: ui->tun_specific_heatEdit->setValue(0.22); break;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 case 2: ui->tun_specific_heatEdit->setValue(0.46); break;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 case 3: ui->tun_specific_heatEdit->setValue(0.092); break;
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362 is_changed();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
366 void EditEquipment::chiller_setup(int val)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
367 {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
368 if (val == CHILLER_TYPE_IMMERSION) {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
369 ui->chiller_volumeEdit->setReadOnly(false);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
370 ui->chiller_volumeEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
371 ui->chiller_volumeEdit->setFixedSize(101, 24);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
372 if (ui->chiller_volumeEdit->value() == 0)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
373 ui->chiller_volumeEdit->setValue(0.5);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
374 } else {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
375 ui->chiller_volumeEdit->setReadOnly(true);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
376 ui->chiller_volumeEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
377 ui->chiller_volumeEdit->setFixedSize(86, 24);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
378 ui->chiller_volumeEdit->setValue(0);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
379 }
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
380
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
381 if (val == CHILLER_TYPE_COUNTERFLOW) {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
382 ui->chiller_to79Edit->setReadOnly(true);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
383 ui->chiller_to79Edit->setButtonSymbols(QAbstractSpinBox::NoButtons);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
384 ui->chiller_to79Edit->setFixedSize(86, 24);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
385 ui->chiller_to79Edit->setValue(0);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
386
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
387 ui->chiller_lpmEdit->setReadOnly(false);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
388 ui->chiller_lpmEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
389 ui->chiller_lpmEdit->setFixedSize(101, 24);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
390 if (ui->chiller_lpmEdit->value() == 0)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
391 ui->chiller_lpmEdit->setValue(2.5);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
392
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
393 ui->chiller_lossEdit->setReadOnly(false);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
394 ui->chiller_lossEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
395 ui->chiller_lossEdit->setFixedSize(101, 24);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
396 if (ui->chiller_lossEdit->value() == 0)
423
8cb46020796a Adjusted chiller_loss default value to 0.4. Disabled product fields eq_calc_boil_volume, eq_hop_utilization, eq_lauter_volume and eq_lauter_height. Added eq_chiller_type, eq_chiller_to79, eq_chiller_volume, eq_chiller_lpm, eq_chiller_loss with default values for immersion chilling. Load these values from new selected equipment. Changed edit product tab 2 to show new the new fields and removed the obsolete fields.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
397 ui->chiller_lossEdit->setValue(0.4);
419
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
398
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
399 } else {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
400 ui->chiller_to79Edit->setReadOnly(false);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
401 ui->chiller_to79Edit->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
402 ui->chiller_to79Edit->setFixedSize(101, 24);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
403 int time = 5;
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
404 if (val == CHILLER_TYPE_AUBAINMARIE)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
405 time = 20;
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
406 if (val == CHILLER_TYPE_NOCHILL)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
407 time = 240;
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
408 if (ui->chiller_to79Edit->value() == 0)
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
409 ui->chiller_to79Edit->setValue(time);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
410
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
411 ui->chiller_lpmEdit->setReadOnly(true);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
412 ui->chiller_lpmEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
413 ui->chiller_lpmEdit->setFixedSize(86, 24);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
414 ui->chiller_lpmEdit->setValue(0);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
415
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
416 ui->chiller_lossEdit->setReadOnly(true);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
417 ui->chiller_lossEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
418 ui->chiller_lossEdit->setFixedSize(86, 24);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
419 ui->chiller_lossEdit->setValue(0);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
420 }
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
421 }
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
422
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
423
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
424 void EditEquipment::chiller_changed()
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
425 {
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
426 const QSignalBlocker blocker1(ui->chiller_to79Edit);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
427 const QSignalBlocker blocker2(ui->chiller_volumeEdit);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
428 const QSignalBlocker blocker3(ui->chiller_lpmEdit);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
429 const QSignalBlocker blocker4(ui->chiller_lossEdit);
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
430
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
431 chiller_setup(ui->chiller_typeEdit->currentIndex());
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
432 is_changed();
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
433 }
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
434
d49f38cc76a0 The equipment editor uses named fields for database io. Edit field 'trub chiller loss' is now called 'trub loss', but will be renamed again. Removed editing hop_utilization, lauter_volume and lauter_height. These fields were never used in the application. Not yet removed from the database. Added chiller_type, chiller_to79, chiller_volume, chiller_lpm and chiller_loss fields so that we can tie a chiller to the equipment setup. Renamed some chiller names.
Michiel Broek <mbroek@mbse.eu>
parents: 385
diff changeset
435
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 void EditEquipment::on_quitButton_clicked()
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437 {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 if (this->textIsChanged) {
60
0d65238ebedc Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
439 int rc = QMessageBox::warning(this, tr("Equipment changed"), tr("This equipment has been modified. Save changes?"),
30
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441 switch (rc) {
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 case QMessageBox::Save:
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 on_saveButton_clicked();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444 break; /* Saved and then Quit */
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 case QMessageBox::Discard:
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 break; /* Quit without Save */
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 case QMessageBox::Cancel:
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 return; /* Return to the editor page */
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 }
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 this->close();
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 this->setResult(1);
0fec6a1abd13 Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 }

mercurial