src/EditFermentable.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.

20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditFermentable.cpp is part of bmsapp.
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "EditFermentable.h"
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "../ui/ui_EditFermentable.h"
90
2396457a8167 Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
19 #include "MainWindow.h"
2396457a8167 Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
20 #include "Utils.h"
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 EditFermentable::EditFermentable(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditFermentable)
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 QSqlQuery query;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 qDebug() << "EditFermentable record:" << id;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 ui->setupUi(this);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 this->recno = id;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 WindowTitle();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 ui->typeEdit->addItem(tr("Grain"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 ui->typeEdit->addItem(tr("Sugar"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 ui->typeEdit->addItem(tr("Extract"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 ui->typeEdit->addItem(tr("Dry extract"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 ui->typeEdit->addItem(tr("Adjunct"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 ui->graintypeEdit->addItem(tr("Base"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 ui->graintypeEdit->addItem(tr("Roast"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 ui->graintypeEdit->addItem(tr("Crystal"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 ui->graintypeEdit->addItem(tr("Kilned"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 ui->graintypeEdit->addItem(tr("Sour Malt"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 ui->graintypeEdit->addItem(tr("Special"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 ui->graintypeEdit->addItem(tr("No malt"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 ui->addedEdit->addItem(tr("Mash"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 ui->addedEdit->addItem(tr("Boil"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 ui->addedEdit->addItem(tr("Fermentation"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 ui->addedEdit->addItem(tr("Lagering"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 ui->addedEdit->addItem(tr("Bottle"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 ui->addedEdit->addItem(tr("Kegs"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 if (id >= 0) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 query.prepare("SELECT * FROM inventory_fermentables WHERE record = :recno");
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 query.bindValue(":recno", id);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 query.exec();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 query.next();
250
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
59 ui->nameEdit->setText(query.value("name").toString());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
60 ui->notesEdit->setPlainText(query.value("notes").toString());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
61 ui->originEdit->setText(query.value("origin").toString());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
62 ui->supplierEdit->setText(query.value("supplier").toString());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
63 ui->typeEdit->setCurrentIndex(query.value("type").toInt());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
64 ui->graintypeEdit->setCurrentIndex(query.value("graintype").toInt());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
65 ui->maxinbatchEdit->setValue(query.value("max_in_batch").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
66 ui->mashEdit->setChecked(query.value("recommend_mash").toInt() ? true:false);
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
67 ui->addafterEdit->setChecked(query.value("add_after_boil").toInt() ? true:false);
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
68 ui->addedEdit->setCurrentIndex(query.value("added").toInt());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
69 ui->alwaysEdit->setChecked(query.value("always_on_stock").toInt() ? true:false);
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
70 ui->inventoryEdit->setValue(query.value("inventory").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
71 ui->costEdit->setValue(query.value("cost").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
72 ui->valueEdit->setValue(query.value("inventory").toDouble() * query.value("cost").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
73 ui->yieldEdit->setValue(query.value("yield").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
74 ui->colorEdit->setValue(query.value("color").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
75 ui->moistureEdit->setValue(query.value("moisture").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
76 ui->coarseEdit->setValue(query.value("coarse_fine_diff").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
77 ui->proteinEdit->setValue(query.value("protein").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
78 ui->dissolvedEdit->setValue(query.value("dissolved_protein").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
79 ui->lintnerEdit->setValue(query.value("diastatic_power").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
80 ui->wkEdit->setValue(Utils::lintner_to_kolbach(query.value("diastatic_power").toDouble()));
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
81 ui->diphEdit->setValue(query.value("di_ph").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
82 ui->acidphEdit->setValue(query.value("acid_to_ph_57").toDouble());
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
83 if (query.value("production_date").toString().length() == 10) {
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
84 ui->prodEdit->setDate(query.value("production_date").toDate());
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 } else {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 ui->prodEdit->clear();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 }
250
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
88 if (query.value("tht_date").toString().length() == 10) {
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
89 ui->thtEdit->setDate(query.value("tht_date").toDate());
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 } else {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 ui->thtEdit->clear();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 } else {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 /* Set some defaults */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 ui->typeEdit->setCurrentIndex(0);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 ui->graintypeEdit->setCurrentIndex(0);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 ui->maxinbatchEdit->setValue(100);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 ui->mashEdit->setChecked(true);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 ui->addedEdit->setCurrentIndex(0);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 ui->yieldEdit->setValue(80);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 ui->colorEdit->setValue(3);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 ui->coarseEdit->setValue(3);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 ui->moistureEdit->setValue(4);
24
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents: 20
diff changeset
104 ui->prodEdit->clear();
684c6e74cc1b Added hops editor.
Michiel Broek <mbroek@mbse.eu>
parents: 20
diff changeset
105 ui->thtEdit->clear();
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 connect(ui->originEdit, &QLineEdit::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 connect(ui->supplierEdit, &QLineEdit::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 connect(ui->graintypeEdit, &QComboBox::currentTextChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 connect(ui->maxinbatchEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 connect(ui->mashEdit, &QCheckBox::stateChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 connect(ui->addafterEdit, &QCheckBox::stateChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 connect(ui->addedEdit, &QComboBox::currentTextChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 connect(ui->yieldEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 connect(ui->colorEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 connect(ui->moistureEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 connect(ui->coarseEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 connect(ui->proteinEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 connect(ui->dissolvedEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
250
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
126 connect(ui->wkEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditFermentable::wk_changed);
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
127 connect(ui->lintnerEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditFermentable::lintner_changed);
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 connect(ui->diphEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 connect(ui->acidphEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditFermentable::is_changed);
293
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
131 connect(ui->prodButton1, SIGNAL(clicked()), this, SLOT(prod_date_today()));
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
132 connect(ui->prodButton2, SIGNAL(clicked()), this, SLOT(prod_date_clear()));
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 connect(ui->thtEdit, &QDateEdit::dateChanged, this, &EditFermentable::is_changed);
293
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
134 connect(ui->thtButton1, SIGNAL(clicked()), this, SLOT(tht_date_today()));
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
135 connect(ui->thtButton2, SIGNAL(clicked()), this, SLOT(tht_date_clear()));
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 ui->saveButton->setEnabled(false);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 EditFermentable::~EditFermentable()
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 delete ui;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 emit entry_changed();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 /*
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 * Window header, mark any change with '**'
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 void EditFermentable::WindowTitle()
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 QString txt;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 if (this->recno < 0) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 txt = QString(tr("BMSapp - Add new fermentable"));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 } else {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 txt = QString(tr("BMSapp - Edit fermentable %1").arg(this->recno));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 if (this->textIsChanged) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 txt.append((QString(" **")));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 setWindowTitle(txt);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 void EditFermentable::on_saveButton_clicked()
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 QSqlQuery query;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 /* If there are errors in the form, show a message and do "return;" */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 if (ui->nameEdit->text().length() < 2) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 QMessageBox::warning(this, tr("Edit Fermentable"), tr("Name empty or too short."));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 return;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 if (ui->originEdit->text().length() < 2) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 QMessageBox::warning(this, tr("Edit Fermentable"), tr("Origin empty or too short."));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 return;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 if (ui->supplierEdit->text().length() < 2) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 QMessageBox::warning(this, tr("Edit Fermentable"), tr("Supplier empty or too short."));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 return;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 if (this->textIsChanged) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 if (this->recno == -1) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 query.prepare("INSERT INTO inventory_fermentables SET name=:name, type=:type, yield=:yield, color=:color, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 "add_after_boil=:addafter, origin=:origin, supplier=:supplier, notes=:notes, coarse_fine_diff=:coarse, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 "moisture=:moisture, diastatic_power=:diastatic, protein=:protein, dissolved_protein=:dissolved, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 "max_in_batch=:maxinbatch, recommend_mash=:mash, added=:added, always_on_stock=:always, di_ph=:diph, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 "acid_to_ph_57=:acidph, graintype=:graintype, inventory=:inventory, cost=:cost, production_date=:prod, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 "tht_date=:tht, uuid = :uuid");
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 } else {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 query.prepare("UPDATE inventory_fermentables SET name=:name, type=:type, yield=:yield, color=:color, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 "add_after_boil=:addafter, origin=:origin, supplier=:supplier, notes=:notes, coarse_fine_diff=:coarse, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 "moisture=:moisture, diastatic_power=:diastatic, protein=:protein, dissolved_protein=:dissolved, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 "max_in_batch=:maxinbatch, recommend_mash=:mash, added=:added, always_on_stock=:always, di_ph=:diph, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 "acid_to_ph_57=:acidph, graintype=:graintype, inventory=:inventory, cost=:cost, production_date=:prod, "
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 "tht_date=:tht WHERE record = :recno");
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 query.bindValue(":name", ui->nameEdit->text());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 query.bindValue(":type", ui->typeEdit->currentIndex());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 query.bindValue(":yield", QString("%1").arg(ui->yieldEdit->value(), 2, 'f', 1, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 query.bindValue(":color", QString("%1").arg(ui->colorEdit->value(), 1, 'f', 0, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 query.bindValue(":addafter", ui->addafterEdit->isChecked() ? 1:0);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 query.bindValue(":origin", ui->originEdit->text());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 query.bindValue(":supplier", ui->supplierEdit->text());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 query.bindValue(":notes", ui->notesEdit->toPlainText());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 query.bindValue(":coarse", QString("%1").arg(ui->coarseEdit->value(), 2, 'f', 1, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 query.bindValue(":moisture", QString("%1").arg(ui->moistureEdit->value(), 2, 'f', 1, '0'));
250
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
213 query.bindValue(":diastatic", Utils::kolbach_to_lintner(ui->wkEdit->value()));
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 query.bindValue(":protein", QString("%1").arg(ui->proteinEdit->value(), 2, 'f', 1, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 query.bindValue(":dissolved", QString("%1").arg(ui->dissolvedEdit->value(), 2, 'f', 1, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 query.bindValue(":maxinbatch", QString("%1").arg(ui->maxinbatchEdit->value(), 2, 'f', 1, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 query.bindValue(":mash", ui->mashEdit->isChecked() ? 1:0);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 query.bindValue(":added", ui->addedEdit->currentIndex());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 query.bindValue(":diph", QString("%1").arg(ui->diphEdit->value(), 3, 'f', 2, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 query.bindValue(":acidph", QString("%1").arg(ui->acidphEdit->value(), 6, 'f', 5, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 query.bindValue(":graintype", ui->graintypeEdit->currentIndex());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 query.bindValue(":inventory", QString("%1").arg(ui->inventoryEdit->value(), 4, 'f', 3, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 3, 'f', 2, '0'));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 /* Uses https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 query.bindValue(":prod", ui->prodEdit->nullDate());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 query.bindValue(":tht", ui->thtEdit->nullDate());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 if (this->recno == -1) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 } else {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 query.bindValue(":recno", this->recno);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 query.exec();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 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: 293
diff changeset
235 qWarning() << "EditFermentable" << query.lastError();
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 QMessageBox::warning(this, tr("Database error"),
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 tr("MySQL error: %1\n%2\n%3")
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 .arg(query.lastError().nativeErrorCode())
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 .arg(query.lastError().driverText())
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 .arg(query.lastError().databaseText()));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 } else {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 qDebug() << "EditFermentable Saved";
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 ui->saveButton->setEnabled(false);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 this->textIsChanged = false;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 WindowTitle();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251
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: 293
diff changeset
252 void EditFermentable::on_cloneButton_clicked()
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
253 {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
254 QSqlQuery query;
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
255
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: 293
diff changeset
256 query.prepare("INSERT INTO inventory_fermentables SET name=:name, type=:type, yield=:yield, color=:color, "
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: 293
diff changeset
257 "add_after_boil=:addafter, origin=:origin, supplier=:supplier, notes=:notes, coarse_fine_diff=:coarse, "
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: 293
diff changeset
258 "moisture=:moisture, diastatic_power=:diastatic, protein=:protein, dissolved_protein=:dissolved, "
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: 293
diff changeset
259 "max_in_batch=:maxinbatch, recommend_mash=:mash, added=:added, always_on_stock=:always, di_ph=:diph, "
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: 293
diff changeset
260 "acid_to_ph_57=:acidph, graintype=:graintype, inventory=:inventory, cost=:cost, production_date=:prod, "
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: 293
diff changeset
261 "tht_date=:tht, uuid = :uuid");
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: 293
diff changeset
262 query.bindValue(":name", ui->nameEdit->text() + " [copy]");
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
263 query.bindValue(":type", ui->typeEdit->currentIndex());
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
264 query.bindValue(":yield", QString("%1").arg(ui->yieldEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
265 query.bindValue(":color", QString("%1").arg(ui->colorEdit->value(), 1, 'f', 0, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
266 query.bindValue(":addafter", ui->addafterEdit->isChecked() ? 1:0);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
267 query.bindValue(":origin", ui->originEdit->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: 293
diff changeset
268 query.bindValue(":supplier", ui->supplierEdit->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: 293
diff changeset
269 query.bindValue(":notes", ui->notesEdit->toPlainText());
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
270 query.bindValue(":coarse", QString("%1").arg(ui->coarseEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
271 query.bindValue(":moisture", QString("%1").arg(ui->moistureEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
272 query.bindValue(":diastatic", Utils::kolbach_to_lintner(ui->wkEdit->value()));
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: 293
diff changeset
273 query.bindValue(":protein", QString("%1").arg(ui->proteinEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
274 query.bindValue(":dissolved", QString("%1").arg(ui->dissolvedEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
275 query.bindValue(":maxinbatch", QString("%1").arg(ui->maxinbatchEdit->value(), 2, 'f', 1, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
276 query.bindValue(":mash", ui->mashEdit->isChecked() ? 1:0);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
277 query.bindValue(":added", ui->addedEdit->currentIndex());
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
278 query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0);
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
279 query.bindValue(":diph", QString("%1").arg(ui->diphEdit->value(), 3, 'f', 2, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
280 query.bindValue(":acidph", QString("%1").arg(ui->acidphEdit->value(), 6, 'f', 5, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
281 query.bindValue(":graintype", ui->graintypeEdit->currentIndex());
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
282 query.bindValue(":inventory", QString("%1").arg(0, 4, 'f', 3, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
283 query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 3, 'f', 2, '0'));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
284 query.bindValue(":prod", QDate());
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: 293
diff changeset
285 query.bindValue(":tht", QDate());
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: 293
diff changeset
286 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
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: 293
diff changeset
287 query.exec();
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
288 if (query.lastError().isValid()) {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
289 qWarning() << "EditFermentable" << query.lastError();
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
290 QMessageBox::warning(this, tr("Database error"),
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
291 tr("MySQL error: %1\n%2\n%3")
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
292 .arg(query.lastError().nativeErrorCode())
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
293 .arg(query.lastError().driverText())
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
294 .arg(query.lastError().databaseText()));
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
295 } else {
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
296 qDebug() << "EditFermentable Saved";
09af9f46518f All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents: 293
diff changeset
297 }
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: 293
diff changeset
298 }
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: 293
diff changeset
299
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: 293
diff changeset
300
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 void EditFermentable::on_deleteButton_clicked()
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 QSqlQuery query;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304
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: 293
diff changeset
305 int rc = QMessageBox::warning(this, tr("Delete fermentable"), 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: 293
diff changeset
306 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: 293
diff changeset
307 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: 293
diff changeset
308 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: 293
diff changeset
309
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 query.prepare("DELETE FROM inventory_fermentables WHERE record = :recno");
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 query.bindValue(":recno", this->recno);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 query.exec();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 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: 293
diff changeset
314 qWarning() << "EditFermentable" << query.lastError();
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 QMessageBox::warning(this, tr("Database error"),
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 tr("MySQL error: %1\n%2\n%3")
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 .arg(query.lastError().nativeErrorCode())
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 .arg(query.lastError().driverText())
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 .arg(query.lastError().databaseText()));
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 } else {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 qDebug() << "EditFermentable Deleted" << this->recno;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 this->close();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 this->setResult(1);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 void EditFermentable::is_changed()
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 ui->valueEdit->setValue(ui->inventoryEdit->value() * ui->costEdit->value());
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 ui->saveButton->setEnabled(true);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && this->recno >= 0) ? true:false);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 this->textIsChanged = true;
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335 WindowTitle();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338
250
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
339 void EditFermentable::wk_changed(double val)
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
340 {
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
341 const QSignalBlocker blocker1(ui->lintnerEdit);
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
342 if (val == 0)
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
343 ui->lintnerEdit->setValue(0);
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
344 else
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
345 ui->lintnerEdit->setValue(Utils::kolbach_to_lintner(val));
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
346 is_changed();
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
347 }
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
348
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
349
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
350 void EditFermentable::lintner_changed(double val)
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
351 {
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
352 const QSignalBlocker blocker1(ui->wkEdit);
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
353 ui->wkEdit->setValue(Utils::lintner_to_kolbach(val));
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
354 is_changed();
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
355 }
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
356
baab61fb8bcd Edit fermentables load record using namefields. Splitted diastaticEdit edit field in wkEdit and lintnerEdit. These fields are linked using the kolbach/lintner convert formula. The date input fields start on 1-1-2000 instead of ages ago.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
357
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 void EditFermentable::on_quitButton_clicked()
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 if (this->textIsChanged) {
60
0d65238ebedc Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
361 int rc = QMessageBox::warning(this, tr("Fermentable changed"), tr("This fermentable has been modified. Save changes?"),
20
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 switch (rc) {
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 case QMessageBox::Save:
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 on_saveButton_clicked();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 break; /* Saved and then Quit */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367 case QMessageBox::Discard:
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368 break; /* Quit without Save */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 case QMessageBox::Cancel:
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 return; /* Return to the editor page */
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372 }
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374 this->close();
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
375 this->setResult(1);
fcbbddcc22c1 Completed the Fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376 }
293
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
377
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
378
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
379 void EditFermentable::prod_date_clear()
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
380 {
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
381 ui->prodEdit->setDate(QDate());
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
382 is_changed();
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
383 }
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
384
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
385
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
386 void EditFermentable::prod_date_today()
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
387 {
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
388 ui->prodEdit->setDate(QDate::currentDate());
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
389 is_changed();
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
390 }
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
391
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
392
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
393 void EditFermentable::tht_date_clear()
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
394 {
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
395 ui->thtEdit->setDate(QDate());
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
396 is_changed();
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
397 }
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
398
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
399
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
400 void EditFermentable::tht_date_today()
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
401 {
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
402 ui->thtEdit->setDate(QDate::currentDate());
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
403 is_changed();
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
404 }
6df94ca2bfde Added date set/clear buttons for inventory Fermentables and Yeasts.
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
405

mercurial