src/EditHop.cpp

Thu, 18 Aug 2022 20:34:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 20:34:15 +0200
changeset 401
583148eb6e01
parent 385
09af9f46518f
permissions
-rw-r--r--

Init est_carb field for new products.

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 delete ui;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 emit entry_changed();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 }
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 * Window header, mark any change with '**'
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 void EditHop::WindowTitle()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 QString txt;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 if (this->recno < 0) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 txt = QString(tr("BMSapp - Add new hop"));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 txt = QString(tr("BMSapp - Edit hop %1").arg(this->recno));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 }
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 if (this->textIsChanged) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 txt.append((QString(" **")));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 setWindowTitle(txt);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 }
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 void EditHop::on_saveButton_clicked()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 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
144 QString sql = "";
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 /* 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
147 if (ui->nameEdit->text().length() < 2) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 QMessageBox::warning(this, tr("Edit Hop"), tr("Name empty or too short."));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 return;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 if (ui->originEdit->text().length() < 2) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 QMessageBox::warning(this, tr("Edit Hop"), tr("Origin empty or too short."));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 return;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 }
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 if (this->textIsChanged) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 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
158 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
159 } 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
160 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
161 }
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 sql.append("name=:name, alpha=:alpha, beta=:beta, "
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 "humulene=:humulene, caryophyllene=:cary, cohumulone=:cohumulone, myrcene=:myrcene, "
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 "hsi=:hsi, type=:type, form=:form, notes=:notes, origin=:origin, substitutes=:substitutes, "
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 "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
166 "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
167 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
168 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
169 } 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
170 sql.append(" WHERE record = :recno");
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 }
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
172
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 query.prepare(sql);
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 query.bindValue(":name", ui->nameEdit->text());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 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
176 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
177 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
178 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
179 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
180 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
181 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
182 query.bindValue(":type", ui->typeEdit->currentIndex());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 query.bindValue(":form", ui->formEdit->currentIndex());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 query.bindValue(":notes", ui->notesEdit->toPlainText());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 query.bindValue(":origin", ui->originEdit->text());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 query.bindValue(":substitutes", ui->substitutesEdit->text());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 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
189 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
190 /* 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
191 query.bindValue(":prod", ui->prodEdit->nullDate());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 query.bindValue(":tht", ui->thtEdit->nullDate());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 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
194 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
195 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
196 if (this->recno == -1) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 query.bindValue(":recno", this->recno);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 query.exec();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 if (query.lastError().isValid()) {
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
203 qWarning() << "EditHop" << query.lastError();
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 QMessageBox::warning(this, tr("Database error"),
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 tr("MySQL error: %1\n%2\n%3")
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 .arg(query.lastError().nativeErrorCode())
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 .arg(query.lastError().driverText())
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 .arg(query.lastError().databaseText()));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 qDebug() << "EditHop Saved";
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 }
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 ui->saveButton->setEnabled(false);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 this->textIsChanged = false;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 WindowTitle();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 }
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
377
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
220 void EditHop::on_cloneButton_clicked()
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
221 {
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
222 QSqlQuery query;
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
223
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
224 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
225 "humulene=:humulene, caryophyllene=:cary, cohumulone=:cohumulone, myrcene=:myrcene, "
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
226 "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
227 "always_on_stock=:always, inventory=:inventory, cost=:cost, production_date=:prod, "
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
228 "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
229
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
230 query.prepare(sql);
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
231 query.bindValue(":name", ui->nameEdit->text() + " [copy]");
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 query.bindValue(":type", ui->typeEdit->currentIndex());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
240 query.bindValue(":form", ui->formEdit->currentIndex());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
241 query.bindValue(":notes", ui->notesEdit->toPlainText());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
242 query.bindValue(":origin", ui->originEdit->text());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
243 query.bindValue(":substitutes", ui->substitutesEdit->text());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
244 query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0);
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
245 query.bindValue(":inventory", QString("%1").arg(0, 5, 'f', 4, '0'));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
246 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
247 query.bindValue(":prod", QDate());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
248 query.bindValue(":tht", QDate());
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
249 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
250 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
251 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
252 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
253 query.exec();
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
254 if (query.lastError().isValid()) {
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
255 qWarning() << "EditHop" << query.lastError();
377
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
256 QMessageBox::warning(this, tr("Database error"),
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
257 tr("MySQL error: %1\n%2\n%3")
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
258 .arg(query.lastError().nativeErrorCode())
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
259 .arg(query.lastError().driverText())
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
260 .arg(query.lastError().databaseText()));
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
261 } else {
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
262 qDebug() << "EditHop Saved";
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
263 }
5c1f81c75bc4 Added hop clone
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
264
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
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 void EditHop::on_deleteButton_clicked()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 QSqlQuery query;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
272 int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(ui->nameEdit->text()),
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
273 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
274 if (rc == QMessageBox::No)
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
275 return;
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
276
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 query.prepare("DELETE FROM inventory_hops WHERE record = :recno");
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 query.bindValue(":recno", this->recno);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 query.exec();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 if (query.lastError().isValid()) {
385
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
281 qWarning() << "EditHop" << query.lastError();
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 QMessageBox::warning(this, tr("Database error"),
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 tr("MySQL error: %1\n%2\n%3")
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 .arg(query.lastError().nativeErrorCode())
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 .arg(query.lastError().driverText())
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 .arg(query.lastError().databaseText()));
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 } else {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 qDebug() << "EditHop Deleted" << this->recno;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 }
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 this->close();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 this->setResult(1);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 }
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
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 void EditHop::is_changed()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 ui->valueEdit->setValue(ui->inventoryEdit->value() * ui->costEdit->value());
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 ui->saveButton->setEnabled(true);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && this->recno >= 0) ? true:false);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 this->textIsChanged = true;
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 WindowTitle();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305
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
306 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
307 {
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 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
309 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
310 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
311 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
312 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
313 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
314 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
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 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
317 }
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
318
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
319
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 void EditHop::on_quitButton_clicked()
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 if (this->textIsChanged) {
60
0d65238ebedc Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
323 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
324 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 switch (rc) {
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 case QMessageBox::Save:
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 on_saveButton_clicked();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 break; /* Saved and then Quit */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 case QMessageBox::Discard:
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 break; /* Quit without Save */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 case QMessageBox::Cancel:
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 return; /* Return to the editor page */
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 }
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 this->close();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337 this->setResult(1);
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338 }
292
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
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
341 void EditHop::prod_date_clear()
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 ui->prodEdit->setDate(QDate());
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
344 is_changed();
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
345 }
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
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
348 void EditHop::prod_date_today()
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 ui->prodEdit->setDate(QDate::currentDate());
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
351 is_changed();
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
352 }
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
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
355 void EditHop::tht_date_clear()
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 ui->thtEdit->setDate(QDate());
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
358 is_changed();
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
359 }
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
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
362 void EditHop::tht_date_today()
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 ui->thtEdit->setDate(QDate::currentDate());
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
365 is_changed();
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
366 }
b6ec2e275736 Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
367

mercurial