src/EditHop.cpp

Sat, 30 Jul 2022 16:30:02 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 30 Jul 2022 16:30:02 +0200
changeset 380
8f5c03ed4321
parent 377
5c1f81c75bc4
child 385
09af9f46518f
permissions
-rw-r--r--

Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.

24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditHop.cpp is part of bmsapp.
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "EditHop.h"
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "../ui/ui_EditHop.h"
90
2396457a8167 Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
19 #include "MainWindow.h"
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
20 #include "global.h"
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 EditHop::EditHop(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditHop)
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 QSqlQuery query;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 qDebug() << "EditHop record:" << id;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 ui->setupUi(this);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 this->recno = id;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
31 for (int i = 0; i < 3; i++)
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
32 ui->typeEdit->addItem(QCoreApplication::translate("HopTypes", g_hop_types[i]));
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
33 for (int i = 0; i < 7; i++)
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
34 ui->formEdit->addItem(QCoreApplication::translate("HopForm", g_hop_forms[i]));
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 if (id >= 0) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 query.prepare("SELECT * FROM inventory_hops WHERE record = :recno");
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 query.bindValue(":recno", id);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 query.exec();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 query.next();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
42 ui->nameEdit->setText(query.value("name").toString());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
43 ui->alphaEdit->setValue(query.value("alpha").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
44 ui->betaEdit->setValue(query.value("beta").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
45 ui->humuleneEdit->setValue(query.value("humulene").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
46 ui->caryEdit->setValue(query.value("caryophyllene").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
47 ui->cohumuloneEdit->setValue(query.value("cohumulone").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
48 ui->myrceneEdit->setValue(query.value("myrcene").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
49 ui->hsiEdit->setValue(query.value("hsi").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
50 ui->typeEdit->setCurrentIndex(query.value("type").toInt());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
51 ui->formEdit->setCurrentIndex(query.value("form").toInt());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
52 ui->notesEdit->setPlainText(query.value("notes").toString());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
53 ui->originEdit->setText(query.value("origin").toString());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
54 ui->substitutesEdit->setText(query.value("substitutes").toString());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
55 ui->alwaysEdit->setChecked(query.value("always_on_stock").toInt() ? true:false);
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
56 ui->inventoryEdit->setValue(query.value("inventory").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
57 ui->costEdit->setValue(query.value("cost").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
58 ui->valueEdit->setValue(query.value("inventory").toDouble() * query.value("cost").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
59 if (query.value("production_date").toString().length() == 10) {
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
60 ui->prodEdit->setDate(query.value("production_date").toDate());
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 ui->prodEdit->clear();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 }
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
64 if (query.value("tht_date").toString().length() == 10) {
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
65 ui->thtEdit->setDate(query.value("tht_date").toDate());
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 ui->thtEdit->clear();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 }
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
69 ui->oilEdit->setValue(query.value("total_oil").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
70 ui->utilisationEdit->setValue(query.value("utilisation").toDouble());
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
71 ui->bufactorEdit->setValue(query.value("bu_factor").toDouble());
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 /* Set some defaults */
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
74 ui->typeEdit->setCurrentIndex(HOP_TYPE_BITTERING);
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
75 ui->formEdit->setCurrentIndex(HOP_FORMS_PELLET);
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
76 ui->utilisationEdit->setValue(my_ut_pellet);
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
77 ui->bufactorEdit->setValue(1.0);
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 ui->prodEdit->clear();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 ui->thtEdit->clear();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 connect(ui->alphaEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 connect(ui->betaEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 connect(ui->humuleneEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 connect(ui->caryEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 connect(ui->cohumuloneEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 connect(ui->myrceneEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 connect(ui->hsiEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditHop::is_changed);
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
90 connect(ui->formEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditHop::form_changed);
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 connect(ui->originEdit, &QLineEdit::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 connect(ui->substitutesEdit, &QLineEdit::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditHop::is_changed);
292
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
98 connect(ui->prodButton1, SIGNAL(clicked()), this, SLOT(prod_date_today()));
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
99 connect(ui->prodButton2, SIGNAL(clicked()), this, SLOT(prod_date_clear()));
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 connect(ui->thtEdit, &QDateEdit::dateChanged, this, &EditHop::is_changed);
292
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
101 connect(ui->thtButton1, SIGNAL(clicked()), this, SLOT(tht_date_today()));
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
102 connect(ui->thtButton2, SIGNAL(clicked()), this, SLOT(tht_date_clear()));
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 connect(ui->oilEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
104 connect(ui->utilisationEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
105 connect(ui->bufactorEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 ui->saveButton->setEnabled(false);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false);
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
109
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
110 WindowTitle();
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 EditHop::~EditHop()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 qDebug() << "EditHop done";
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 delete ui;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 emit entry_changed();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 /*
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 * Window header, mark any change with '**'
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 void EditHop::WindowTitle()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 QString txt;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 if (this->recno < 0) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 txt = QString(tr("BMSapp - Add new hop"));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 txt = QString(tr("BMSapp - Edit hop %1").arg(this->recno));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 if (this->textIsChanged) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 txt.append((QString(" **")));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 setWindowTitle(txt);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 void EditHop::on_saveButton_clicked()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 QSqlQuery query;
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
145 QString sql = "";
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 /* If there are errors in the form, show a message and do "return;" */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 if (ui->nameEdit->text().length() < 2) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 QMessageBox::warning(this, tr("Edit Hop"), tr("Name empty or too short."));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 return;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 if (ui->originEdit->text().length() < 2) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 QMessageBox::warning(this, tr("Edit Hop"), tr("Origin empty or too short."));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 return;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 if (this->textIsChanged) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 if (this->recno == -1) {
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
159 sql = "INSERT INTO inventory_hops SET ";
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
160 } else {
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
161 sql = "UPDATE inventory_hops SET ";
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
162 }
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
163 sql.append("name=:name, alpha=:alpha, beta=:beta, "
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 "humulene=:humulene, caryophyllene=:cary, cohumulone=:cohumulone, myrcene=:myrcene, "
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 "hsi=:hsi, type=:type, form=:form, notes=:notes, origin=:origin, substitutes=:substitutes, "
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 "always_on_stock=:always, inventory=:inventory, cost=:cost, production_date=:prod, "
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
167 "tht_date=:tht, total_oil=:oil, utilisation=:utilisation, bu_factor=:bu_factor");
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
168 if (this->recno == -1) {
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
169 sql.append(", uuid=:uuid");
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
170 } else {
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
171 sql.append(" WHERE record = :recno");
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 }
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
173
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
174 query.prepare(sql);
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 query.bindValue(":name", ui->nameEdit->text());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 query.bindValue(":alpha", QString("%1").arg(ui->alphaEdit->value(), 2, 'f', 1, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 query.bindValue(":beta", QString("%1").arg(ui->betaEdit->value(), 2, 'f', 1, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 query.bindValue(":humulene", QString("%1").arg(ui->humuleneEdit->value(), 2, 'f', 1, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 query.bindValue(":cary", QString("%1").arg(ui->caryEdit->value(), 2, 'f', 1, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 query.bindValue(":cohumulone", QString("%1").arg(ui->cohumuloneEdit->value(), 2, 'f', 1, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 query.bindValue(":myrcene", QString("%1").arg(ui->myrceneEdit->value(), 2, 'f', 1, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 query.bindValue(":hsi", QString("%1").arg(ui->hsiEdit->value(), 2, 'f', 1, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 query.bindValue(":type", ui->typeEdit->currentIndex());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 query.bindValue(":form", ui->formEdit->currentIndex());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 query.bindValue(":notes", ui->notesEdit->toPlainText());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 query.bindValue(":origin", ui->originEdit->text());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 query.bindValue(":substitutes", ui->substitutesEdit->text());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 query.bindValue(":inventory", QString("%1").arg(ui->inventoryEdit->value(), 5, 'f', 4, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 3, 'f', 2, '0'));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 /* Uses https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 query.bindValue(":prod", ui->prodEdit->nullDate());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 query.bindValue(":tht", ui->thtEdit->nullDate());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 query.bindValue(":oil", QString("%1").arg(ui->oilEdit->value(), 2, 'f', 1, '0'));
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
195 query.bindValue(":utilisation", QString("%1").arg(ui->utilisationEdit->value(), 2, 'f', 1, '0'));
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
196 query.bindValue(":bu_factor", QString("%1").arg(ui->bufactorEdit->value(), 2, 'f', 1, '0'));
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 if (this->recno == -1) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 query.bindValue(":recno", this->recno);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 query.exec();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 if (query.lastError().isValid()) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 qDebug() << "EditHop" << query.lastError();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 QMessageBox::warning(this, tr("Database error"),
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 tr("MySQL error: %1\n%2\n%3")
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 .arg(query.lastError().nativeErrorCode())
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 .arg(query.lastError().driverText())
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 .arg(query.lastError().databaseText()));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 qDebug() << "EditHop Saved";
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 ui->saveButton->setEnabled(false);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 this->textIsChanged = false;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 WindowTitle();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220
377
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
221 void EditHop::on_cloneButton_clicked()
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
222 {
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
223 QSqlQuery query;
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
224
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
225 QString sql = "INSERT INTO inventory_hops SET name=:name, alpha=:alpha, beta=:beta, "
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
226 "humulene=:humulene, caryophyllene=:cary, cohumulone=:cohumulone, myrcene=:myrcene, "
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
227 "hsi=:hsi, type=:type, form=:form, notes=:notes, origin=:origin, substitutes=:substitutes, "
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
228 "always_on_stock=:always, inventory=:inventory, cost=:cost, production_date=:prod, "
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
229 "tht_date=:tht, total_oil=:oil, utilisation=:utilisation, bu_factor=:bu_factor, uuid=:uuid";
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
230
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
231 query.prepare(sql);
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
232 query.bindValue(":name", ui->nameEdit->text() + " [copy]");
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
233 query.bindValue(":alpha", QString("%1").arg(ui->alphaEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
234 query.bindValue(":beta", QString("%1").arg(ui->betaEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
235 query.bindValue(":humulene", QString("%1").arg(ui->humuleneEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
236 query.bindValue(":cary", QString("%1").arg(ui->caryEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
237 query.bindValue(":cohumulone", QString("%1").arg(ui->cohumuloneEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
238 query.bindValue(":myrcene", QString("%1").arg(ui->myrceneEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
239 query.bindValue(":hsi", QString("%1").arg(ui->hsiEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
240 query.bindValue(":type", ui->typeEdit->currentIndex());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
241 query.bindValue(":form", ui->formEdit->currentIndex());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
242 query.bindValue(":notes", ui->notesEdit->toPlainText());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
243 query.bindValue(":origin", ui->originEdit->text());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
244 query.bindValue(":substitutes", ui->substitutesEdit->text());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
245 query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0);
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
246 query.bindValue(":inventory", QString("%1").arg(0, 5, 'f', 4, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
247 query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 3, 'f', 2, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
248 /* Uses https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit */
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
249 query.bindValue(":prod", QDate());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
250 query.bindValue(":tht", QDate());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
251 query.bindValue(":oil", QString("%1").arg(ui->oilEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
252 query.bindValue(":utilisation", QString("%1").arg(ui->utilisationEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
253 query.bindValue(":bu_factor", QString("%1").arg(ui->bufactorEdit->value(), 2, 'f', 1, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
254 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
255 query.exec();
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
256 if (query.lastError().isValid()) {
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
257 qDebug() << "EditHop" << query.lastError();
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
258 QMessageBox::warning(this, tr("Database error"),
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
259 tr("MySQL error: %1\n%2\n%3")
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
260 .arg(query.lastError().nativeErrorCode())
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
261 .arg(query.lastError().driverText())
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
262 .arg(query.lastError().databaseText()));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
263 } else {
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
264 qDebug() << "EditHop Saved";
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
265 }
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
266
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
267 }
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
268
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
269
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 void EditHop::on_deleteButton_clicked()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 QSqlQuery query;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 query.prepare("DELETE FROM inventory_hops WHERE record = :recno");
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 query.bindValue(":recno", this->recno);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 query.exec();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 if (query.lastError().isValid()) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 qDebug() << "EditHop" << query.lastError();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 QMessageBox::warning(this, tr("Database error"),
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 tr("MySQL error: %1\n%2\n%3")
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281 .arg(query.lastError().nativeErrorCode())
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 .arg(query.lastError().driverText())
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 .arg(query.lastError().databaseText()));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 qDebug() << "EditHop Deleted" << this->recno;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 this->close();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 this->setResult(1);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 void EditHop::is_changed()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 ui->valueEdit->setValue(ui->inventoryEdit->value() * ui->costEdit->value());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 ui->saveButton->setEnabled(true);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && this->recno >= 0) ? true:false);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 this->textIsChanged = true;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 WindowTitle();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
303 void EditHop::form_changed(int val)
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
304 {
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
305 switch (val) {
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
306 case HOP_FORMS_PELLET: ui->utilisationEdit->setValue(my_ut_pellet); break;
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
307 case HOP_FORMS_PLUG: ui->utilisationEdit->setValue(my_ut_plug); break;
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
308 case HOP_FORMS_LEAF: ui->utilisationEdit->setValue(my_ut_leaf); break;
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
309 case HOP_FORMS_LEAF_WET: ui->utilisationEdit->setValue(my_ut_wethop); break;
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
310 case HOP_FORMS_CRYO: ui->utilisationEdit->setValue(my_ut_t45); break;
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
311 case HOP_FORMS_CO2EXTRACT: ui->utilisationEdit->setValue(my_ut_co2extract); break;
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
312 }
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
313 is_changed();
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
314 }
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
315
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 377
diff changeset
316
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 void EditHop::on_quitButton_clicked()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 if (this->textIsChanged) {
60
0d65238ebedc Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
320 int rc = QMessageBox::warning(this, tr("Hop changed"), tr("This hop has been modified. Save changes?"),
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 switch (rc) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 case QMessageBox::Save:
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 on_saveButton_clicked();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 break; /* Saved and then Quit */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 case QMessageBox::Discard:
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 break; /* Quit without Save */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 case QMessageBox::Cancel:
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 return; /* Return to the editor page */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 this->close();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 this->setResult(1);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335 }
292
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
336
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
337
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
338 void EditHop::prod_date_clear()
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
339 {
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
340 ui->prodEdit->setDate(QDate());
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
341 is_changed();
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
342 }
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
343
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
344
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
345 void EditHop::prod_date_today()
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
346 {
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
347 ui->prodEdit->setDate(QDate::currentDate());
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
348 is_changed();
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
349 }
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
350
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
351
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
352 void EditHop::tht_date_clear()
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
353 {
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
354 ui->thtEdit->setDate(QDate());
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
355 is_changed();
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
356 }
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
357
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
358
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
359 void EditHop::tht_date_today()
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
360 {
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
361 ui->thtEdit->setDate(QDate::currentDate());
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
362 is_changed();
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
363 }
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
364

mercurial