Fri, 29 Jul 2022 13:12:26 +0200
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.
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * EditMisc.cpp is part of bmsapp. |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "EditMisc.h" |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | #include "../ui/ui_EditMisc.h" |
90
2396457a8167
Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents:
60
diff
changeset
|
19 | #include "MainWindow.h" |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | EditMisc::EditMisc(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditMisc) |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | QSqlQuery query; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | qDebug() << "EditMisc record:" << id; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | ui->setupUi(this); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | this->recno = id; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | WindowTitle(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | ui->typeEdit->addItem(tr("Spice")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | ui->typeEdit->addItem(tr("Herb")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | ui->typeEdit->addItem(tr("Flavor")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | ui->typeEdit->addItem(tr("Fining")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | ui->typeEdit->addItem(tr("Water agent")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | ui->typeEdit->addItem(tr("Yeast nutrient")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | ui->typeEdit->addItem(tr("Other")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | ui->useEdit->addItem(tr("Starter")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | ui->useEdit->addItem(tr("Mash")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | ui->useEdit->addItem(tr("Boil")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | ui->useEdit->addItem(tr("Primary")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | ui->useEdit->addItem(tr("Secondary")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | ui->useEdit->addItem(tr("Bottling")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | if (id >= 0) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | query.prepare("SELECT * FROM inventory_miscs WHERE record = :recno"); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | query.bindValue(":recno", id); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | query.exec(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | query.next(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
53 | ui->nameEdit->setText(query.value("name").toString()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
54 | ui->typeEdit->setCurrentIndex(query.value("type").toInt()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
55 | ui->useEdit->setCurrentIndex(query.value("use_use").toInt()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
56 | ui->timeEdit->setValue(query.value("time").toInt()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
57 | ui->isweightEdit->setChecked(query.value("amount_is_weight").toInt() ? true:false); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
58 | ui->useforEdit->setPlainText(query.value("use_for").toString()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
59 | ui->notesEdit->setPlainText(query.value("notes").toString()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
60 | ui->alwaysEdit->setChecked(query.value("always_on_stock").toInt() ? true:false); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
61 | ui->inventoryEdit->setValue(query.value("inventory").toDouble() * 1000.0); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
62 | ui->costEdit->setValue(query.value("cost").toDouble()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
63 | ui->valueEdit->setValue(query.value("inventory").toDouble() * query.value("cost").toDouble()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
64 | if (query.value("production_date").toString().length() == 10) { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
65 | ui->prodEdit->setDate(query.value("production_date").toDate()); |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | ui->prodEdit->clear(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | } |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
69 | if (query.value("tht_date").toString().length() == 10) { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
70 | ui->thtEdit->setDate(query.value("tht_date").toDate()); |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | ui->thtEdit->clear(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | /* Set some defaults */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | ui->typeEdit->setCurrentIndex(0); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | ui->useEdit->setCurrentIndex(0); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | ui->timeEdit->setValue(0); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | ui->prodEdit->clear(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | ui->thtEdit->clear(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | } |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
82 | UnitSet(); |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | TimeSet(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditMisc::is_changed); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditMisc::is_changed); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | connect(ui->useEdit, &QComboBox::currentTextChanged, this, &EditMisc::is_changed); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | connect(ui->timeEdit, &QSpinBox::textChanged, this, &EditMisc::time_changed); |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
88 | connect(ui->isweightEdit, &QCheckBox::stateChanged, this, &EditMisc::weight_changed); |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | connect(ui->useforEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditMisc::is_changed); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditMisc::is_changed); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditMisc::is_changed); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditMisc::is_changed); |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
95 | 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
|
96 | connect(ui->prodButton2, SIGNAL(clicked()), this, SLOT(prod_date_clear())); |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | connect(ui->thtEdit, &QDateEdit::dateChanged, this, &EditMisc::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->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
|
99 | connect(ui->thtButton2, SIGNAL(clicked()), this, SLOT(tht_date_clear())); |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | ui->saveButton->setEnabled(false); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | EditMisc::~EditMisc() |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | qDebug() << "EditMisc done"; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | delete ui; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | emit entry_changed(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | /* |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | * Window header, mark any change with '**' |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | void EditMisc::WindowTitle() |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | QString txt; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | if (this->recno < 0) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | txt = QString(tr("BMSapp - Add new misc ingredient")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | txt = QString(tr("BMSapp - Edit misc ingredient %1").arg(this->recno)); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | if (this->textIsChanged) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | txt.append((QString(" **"))); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | setWindowTitle(txt); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | void EditMisc::on_saveButton_clicked() |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | QSqlQuery query; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | /* If there are errors in the form, show a message and do "return;" */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | if (ui->nameEdit->text().length() < 2) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | QMessageBox::warning(this, tr("Edit Misc"), tr("Name empty or too short.")); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | return; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | if (this->textIsChanged) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | if (this->recno == -1) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | query.prepare("INSERT INTO inventory_miscs SET name=:name, type=:type, use_use=:use, " |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | "time=:time, amount_is_weight=:isweight, use_for=:usefor, notes=:notes, " |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | "always_on_stock=:always, inventory=:inventory, cost=:cost, production_date=:prod, " |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | "tht_date=:tht, uuid = :uuid"); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | query.prepare("UPDATE inventory_miscs SET name=:name, type=:type, use_use=:use, " |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | "time=:time, amount_is_weight=:isweight, use_for=:usefor, notes=:notes, " |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | "always_on_stock=:always, inventory=:inventory, cost=:cost, production_date=:prod, " |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | "tht_date=:tht WHERE record = :recno"); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | query.bindValue(":name", ui->nameEdit->text()); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | query.bindValue(":type", ui->typeEdit->currentIndex()); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | query.bindValue(":use", ui->useEdit->currentIndex()); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | query.bindValue(":time", ui->timeEdit->value()); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | query.bindValue(":isweight", ui->isweightEdit->isChecked() ? 1:0); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | query.bindValue(":usefor", ui->useforEdit->toPlainText()); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | query.bindValue(":notes", ui->notesEdit->toPlainText()); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | query.bindValue(":inventory", QString("%1").arg(ui->inventoryEdit->value() / 1000.0, 5, 'f', 4, '0')); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 3, 'f', 2, '0')); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | /* Uses https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | query.bindValue(":prod", ui->prodEdit->nullDate()); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | query.bindValue(":tht", ui->thtEdit->nullDate()); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | if (this->recno == -1) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | query.bindValue(":recno", this->recno); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
174 | query.exec(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | if (query.lastError().isValid()) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | qDebug() << "EditMisc" << query.lastError(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | QMessageBox::warning(this, tr("Database error"), |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
178 | tr("MySQL error: %1\n%2\n%3") |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | .arg(query.lastError().nativeErrorCode()) |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | .arg(query.lastError().driverText()) |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | .arg(query.lastError().databaseText())); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | qDebug() << "EditMisc Saved"; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
184 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
187 | ui->saveButton->setEnabled(false); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | this->textIsChanged = false; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | WindowTitle(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | void EditMisc::on_deleteButton_clicked() |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | QSqlQuery query; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | query.prepare("DELETE FROM inventory_miscs WHERE record = :recno"); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | query.bindValue(":recno", this->recno); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | query.exec(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | if (query.lastError().isValid()) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | qDebug() << "EditMisc" << query.lastError(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | QMessageBox::warning(this, tr("Database error"), |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | tr("MySQL error: %1\n%2\n%3") |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | .arg(query.lastError().nativeErrorCode()) |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | .arg(query.lastError().driverText()) |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
206 | .arg(query.lastError().databaseText())); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | qDebug() << "EditMisc Deleted" << this->recno; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | this->close(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | this->setResult(1); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
216 | void EditMisc::UnitSet() |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
217 | { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
218 | if (ui->isweightEdit->isChecked()) { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
219 | ui->inventoryEdit->setSuffix(tr(" gr")); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
220 | } else { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
221 | ui->inventoryEdit->setSuffix(tr(" ml")); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
222 | } |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
223 | } |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
224 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
225 | |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | void EditMisc::TimeSet() |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
227 | { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | int time = ui->timeEdit->value(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
229 | QString w = QString(""); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
230 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | if (time == 0) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | ui->timeEdit->setSingleStep(1); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | } else if (time == 1) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | w = QString("1 minute"); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | ui->timeEdit->setSingleStep(1); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | } else if (time < 180) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
239 | w = QString("%1 minutes").arg(time); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
240 | ui->timeEdit->setSingleStep(1); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
242 | } else if (time == 180) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
243 | w = QString("3 hours"); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
244 | if (lasttime == 240) |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
245 | ui->timeEdit->setSingleStep(1); /* Going down */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
246 | else |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
247 | ui->timeEdit->setSingleStep(60); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
248 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
249 | } else if (time < 1440) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
250 | w = QString("%1 hours").arg(time / 60); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
251 | ui->timeEdit->setSingleStep(60); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
252 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
253 | } else if (time == 1440) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
254 | w = QString("1 day"); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
255 | if (lasttime == 2880) |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
256 | ui->timeEdit->setSingleStep(60); /* Going down */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
257 | else |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
258 | ui->timeEdit->setSingleStep(1440); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
259 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
260 | } else { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
261 | w = QString("%1 days").arg(time / 1440); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
262 | ui->timeEdit->setSingleStep(1440); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
263 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
264 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
265 | ui->timeShow->setText(w); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
266 | lasttime = time; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
267 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
268 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
269 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
270 | void EditMisc::is_changed() |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
271 | { |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
272 | ui->valueEdit->setValue((ui->inventoryEdit->value() / 1000.0) * ui->costEdit->value()); |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
273 | ui->saveButton->setEnabled(true); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
274 | ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && this->recno >= 0) ? true:false); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
275 | this->textIsChanged = true; |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
276 | WindowTitle(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
277 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
278 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
279 | |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
280 | void EditMisc::weight_changed() |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
281 | { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
282 | UnitSet(); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
283 | is_changed(); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
284 | } |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
285 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
286 | |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
287 | void EditMisc::time_changed() |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
288 | { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
289 | TimeSet(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
290 | is_changed(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
291 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
292 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
293 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
294 | void EditMisc::on_quitButton_clicked() |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
295 | { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
296 | if (this->textIsChanged) { |
60
0d65238ebedc
Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents:
28
diff
changeset
|
297 | int rc = QMessageBox::warning(this, tr("Misc changed"), tr("The ingredient has been modified. Save changes?"), |
28
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
298 | QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
299 | switch (rc) { |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
300 | case QMessageBox::Save: |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
301 | on_saveButton_clicked(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
302 | break; /* Saved and then Quit */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
303 | case QMessageBox::Discard: |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
304 | break; /* Quit without Save */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
305 | case QMessageBox::Cancel: |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
306 | return; /* Return to the editor page */ |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
307 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
308 | } |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
309 | |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
310 | this->close(); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
311 | this->setResult(1); |
93a70b1502ca
Added the inventory miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
312 | } |
292
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
313 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
314 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
315 | void EditMisc::prod_date_clear() |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
316 | { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
317 | ui->prodEdit->setDate(QDate()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
318 | is_changed(); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
319 | } |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
320 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
321 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
322 | void EditMisc::prod_date_today() |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
323 | { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
324 | ui->prodEdit->setDate(QDate::currentDate()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
325 | is_changed(); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
326 | } |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
327 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
328 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
329 | void EditMisc::tht_date_clear() |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
330 | { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
331 | ui->thtEdit->setDate(QDate()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
332 | is_changed(); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
333 | } |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
334 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
335 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
336 | void EditMisc::tht_date_today() |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
337 | { |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
338 | ui->thtEdit->setDate(QDate::currentDate()); |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
339 | is_changed(); |
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 | |
b6ec2e275736
Fixed missing settings from the Miscs and Hops editors.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
342 |