Sat, 14 Oct 2023 11:23:24 +0200
Load and show current calibration data.
24 | 1 | /** |
2 | * InventoryHops.cpp is part of bmsapp. | |
3 | * | |
4 | * bmsapp is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 3 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * bmsapp is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | #include "InventoryHops.h" | |
18 | #include "EditHop.h" | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
19 | #include "MainWindow.h" |
24 | 20 | #include "config.h" |
155
f671c599f65b
Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
21 | #include "global.h" |
24 | 22 | |
23 | ||
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
24 | InventoryHops::InventoryHops(QWidget *parent) : QDialog(parent) |
24 | 25 | { |
26 | qDebug() << "InventoryHops start"; | |
27 | ||
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
28 | gridLayout = new QGridLayout(this); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
29 | gridLayout->setObjectName(QString::fromUtf8("gridLayout")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
30 | tableHops = new QTableWidget(this); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
31 | tableHops->setObjectName(QString::fromUtf8("tableHops")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
32 | tableHops->setEnabled(true); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
33 | QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
34 | sizePolicy.setHorizontalStretch(0); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
35 | sizePolicy.setVerticalStretch(0); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
36 | tableHops->setSizePolicy(sizePolicy); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
37 | tableHops->setMinimumSize(QSize(1124, 0)); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
38 | gridLayout->addWidget(tableHops, 0, 0, 1, 1); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
39 | |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
40 | groupBox = new QGroupBox(this); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
41 | groupBox->setObjectName(QString::fromUtf8("groupBox")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
42 | groupBox->setEnabled(true); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
43 | groupBox->setFlat(false); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
44 | horizontalLayout = new QHBoxLayout(groupBox); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
45 | horizontalLayout->setSpacing(6); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
46 | horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
47 | horizontalLayout->setContentsMargins(0, 0, 0, 0); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
48 | |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
49 | quitButton = new QPushButton(groupBox); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
50 | quitButton->setObjectName(QString::fromUtf8("quitButton")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
51 | quitButton->setMinimumSize(QSize(80, 24)); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
52 | quitButton->setText(tr("Quit")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
53 | QIcon icon; |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
54 | icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
55 | quitButton->setIcon(icon); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
56 | horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
57 | |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
58 | exportButton = new QPushButton(groupBox); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
59 | exportButton->setObjectName(QString::fromUtf8("exportButton")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
60 | exportButton->setMinimumSize(QSize(80, 24)); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
61 | exportButton->setText(tr("Export")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
62 | QIcon icon1; |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
63 | icon1.addFile(QString::fromUtf8(":/icons/silk/database_save.png"), QSize(), QIcon::Normal, QIcon::Off); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
64 | exportButton->setIcon(icon1); |
290
93820a8ffbff
Removed unneeded import buttons from the inventory screens.
Michiel Broek <mbroek@mbse.eu>
parents:
155
diff
changeset
|
65 | horizontalLayout->addWidget(exportButton, 0, Qt::AlignCenter); |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
66 | |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
67 | insertButton = new QPushButton(groupBox); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
68 | insertButton->setObjectName(QString::fromUtf8("insertButton")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
69 | insertButton->setMinimumSize(QSize(80, 24)); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
70 | insertButton->setText(tr("New")); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
71 | QIcon icon3; |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
72 | icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
73 | insertButton->setIcon(icon3); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
74 | horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
75 | gridLayout->addWidget(groupBox, 1, 0, 1, 1); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
76 | |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
77 | connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryHops())); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
78 | connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
79 | connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked())); |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
80 | connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); |
24 | 81 | emit refreshTable(); |
82 | } | |
83 | ||
84 | ||
85 | void InventoryHops::refreshTable() | |
86 | { | |
87 | QString w; | |
88 | ||
89 | qDebug() << "InventoryHops reload"; | |
90 | ||
91 | QSqlQuery query("SELECT * FROM inventory_hops ORDER BY origin,name"); | |
92 | const QStringList labels({tr("Origin"), tr("Name"), tr("Type"), tr("Form"), tr("Alpha"), tr("Beta"), tr("Cohumulone"), tr("HSI"), tr("Harvest"), tr("Stock"), tr("Edit")}); | |
93 | ||
94 | /* origin supplier name type graintype color yield inventory Edit */ | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
95 | this->tableHops->setColumnCount(11); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
96 | this->tableHops->setColumnWidth(0, 130); /* Origin */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
97 | this->tableHops->setColumnWidth(1, 250); /* Name */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
98 | this->tableHops->setColumnWidth(2, 80); /* Type */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
99 | this->tableHops->setColumnWidth(3, 80); /* Form */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
100 | this->tableHops->setColumnWidth(4, 80); /* Alpha */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
101 | this->tableHops->setColumnWidth(5, 80); /* Beta */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
102 | this->tableHops->setColumnWidth(6, 80); /* cohumulone */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
103 | this->tableHops->setColumnWidth(7, 80); /* HSI */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
104 | this->tableHops->setColumnWidth(8, 80); /* Harvest date */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
105 | this->tableHops->setColumnWidth(9, 80); /* Stock */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
106 | this->tableHops->setColumnWidth(10, 80); /* Edit button */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
107 | this->tableHops->setRowCount(query.size()); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
108 | this->tableHops->setHorizontalHeaderLabels(labels); |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
109 | this->tableHops->verticalHeader()->hide(); |
24 | 110 | |
111 | QTableWidgetItem *rightitem = new QTableWidgetItem(); | |
112 | rightitem->setTextAlignment(Qt::AlignRight); | |
113 | ||
114 | query.first(); | |
115 | for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
116 | this->tableHops->setItem(ridx, 0, new QTableWidgetItem(query.value(12).toString())); /* Origin */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
117 | this->tableHops->setItem(ridx, 1, new QTableWidgetItem(query.value(1).toString())); /* Name */ |
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
290
diff
changeset
|
118 | this->tableHops->setItem(ridx, 2, new QTableWidgetItem(g_hop_types[query.value(9).toInt()])); /* Type */ |
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
290
diff
changeset
|
119 | this->tableHops->setItem(ridx, 3, new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[query.value(10).toInt()]))); /* Form */ |
24 | 120 | w = QString("%1 %").arg(query.value(2).toDouble(), 2, 'f', 1, '0' ); /* Alpha% */ |
121 | QTableWidgetItem *item = new QTableWidgetItem(w); | |
122 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
123 | this->tableHops->setItem(ridx, 4, item); |
24 | 124 | w = QString("%1 %").arg(query.value(3).toDouble(), 2, 'f', 1, '0' ); /* Beta% */ |
125 | item = new QTableWidgetItem(w); | |
126 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
127 | this->tableHops->setItem(ridx, 5, item); |
24 | 128 | |
129 | w = QString("%1 %").arg(query.value(6).toDouble(), 2, 'f', 1, '0' ); /* Cohumulone */ | |
130 | item = new QTableWidgetItem(w); | |
131 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
132 | this->tableHops->setItem(ridx, 6, item); |
24 | 133 | |
134 | w = QString("%1").arg(query.value(8).toDouble(), 2, 'f', 1, '0' ); /* HSI */ | |
135 | item = new QTableWidgetItem(w); | |
136 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
137 | this->tableHops->setItem(ridx, 7, item); |
24 | 138 | |
373
b02aca4e926c
First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
139 | if (query.value("inventory").toDouble() > 0) |
b02aca4e926c
First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
140 | this->tableHops->setItem(ridx, 8, new QTableWidgetItem(query.value("production_date").toString())); |
24 | 141 | else |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
142 | this->tableHops->setItem(ridx, 8, new QTableWidgetItem(QString(""))); |
24 | 143 | |
144 | w = QString(""); | |
373
b02aca4e926c
First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
145 | if (query.value("inventory").toDouble() > 0) { |
380
8f5c03ed4321
Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents:
373
diff
changeset
|
146 | if (query.value("inventory").toDouble() < 1.000) { |
8f5c03ed4321
Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents:
373
diff
changeset
|
147 | w = QString("%1 gr").arg(query.value("inventory").toDouble() * 1000.0, 2, 'f', 1, '0' ); |
373
b02aca4e926c
First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
148 | } else { |
380
8f5c03ed4321
Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents:
373
diff
changeset
|
149 | w = QString("%1 kg").arg(query.value("inventory").toDouble(), 4, 'f', 3, '0' ); |
373
b02aca4e926c
First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
150 | } |
b02aca4e926c
First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
151 | } |
24 | 152 | item = new QTableWidgetItem(w); |
153 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
154 | this->tableHops->setItem(ridx, 9, item); |
24 | 155 | |
156 | /* Add the Edit button */ | |
157 | QWidget* pWidget = new QWidget(); | |
158 | QPushButton* btn_edit = new QPushButton(); | |
159 | btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */ | |
160 | btn_edit->setText(tr("Edit")); | |
161 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); | |
162 | QHBoxLayout* pLayout = new QHBoxLayout(pWidget); | |
163 | pLayout->addWidget(btn_edit); | |
164 | pLayout->setContentsMargins(5, 0, 5, 0); | |
165 | pWidget->setLayout(pLayout); | |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
166 | this->tableHops->setCellWidget(ridx, 10, pWidget); |
24 | 167 | query.next(); |
168 | } | |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
169 | emit setStatus(QString(tr("Total items: %1")).arg(query.size())); |
24 | 170 | } |
171 | ||
172 | ||
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
173 | InventoryHops::~InventoryHops() {} |
24 | 174 | |
175 | ||
176 | void InventoryHops::edit(int recno) | |
177 | { | |
178 | EditHop dialog(recno, this); | |
179 | /* Signal from editor if a refresh is needed */ | |
180 | connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); | |
181 | dialog.setModal(true); | |
182 | dialog.exec(); | |
183 | } | |
184 | ||
185 | ||
186 | void InventoryHops::on_editButton_clicked() | |
187 | { | |
188 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); | |
189 | int recno = pb->objectName().toInt(); | |
190 | edit(recno); | |
191 | } | |
192 | ||
193 | ||
194 | void InventoryHops::on_insertButton_clicked() | |
195 | { | |
196 | edit(-1); | |
197 | } | |
198 | ||
199 | ||
44
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
200 | void InventoryHops::on_exportButton_clicked() |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
201 | { |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
202 | qDebug() << Q_FUNC_INFO; |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
203 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
204 | QSqlQuery query("SELECT * FROM inventory_hops ORDER BY origin,name"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
205 | const QStringList types({ "Bittering", "Aroma", "Both" }); |
383
bd20f8710f45
A small correction on beerxml export.
Michiel Broek <mbroek@mbse.eu>
parents:
382
diff
changeset
|
206 | const QStringList forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet", "Pellet", "Pellet" }); |
bd20f8710f45
A small correction on beerxml export.
Michiel Broek <mbroek@mbse.eu>
parents:
382
diff
changeset
|
207 | /* "Pellet", "Plug", "Leaf", "Leaf Wet", "Cryo", "CO2 extract", "Iso extract" */ |
69
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
208 | /* We use more hop forms then beerxml knows about, so we send known names */ |
228cb2a01acf
Inventory Hops now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
209 | /* instead of what we internally use. */ |
44
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
210 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
211 | QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/hops.xml", tr("Files (*.xml)")); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
212 | if (fileName == 0) { |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
213 | QMessageBox::warning(this, tr("Save File"), tr("No XML file selected.")); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
214 | return; |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
215 | } |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
216 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
217 | QFile file(fileName); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
218 | file.open(QIODevice::WriteOnly); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
219 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
220 | QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
221 | xmlWriter->writeStartDocument(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
222 | xmlWriter->setAutoFormatting(true); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
223 | xmlWriter->setAutoFormattingIndent(1); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
224 | xmlWriter->writeStartElement("HOPS"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
225 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
226 | query.first(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
227 | for (int i = 0 ; i < query.size() ; i++ ) { |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
228 | xmlWriter->writeStartElement("HOP"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
229 | xmlWriter->writeTextElement("VERSION", "1"); |
382
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
230 | xmlWriter->writeTextElement("NAME", query.value("name").toString()); |
383
bd20f8710f45
A small correction on beerxml export.
Michiel Broek <mbroek@mbse.eu>
parents:
382
diff
changeset
|
231 | if (query.value("notes").toString().length()) |
382
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
232 | xmlWriter->writeTextElement("NOTES", query.value("notes").toString()); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
233 | xmlWriter->writeTextElement("ALWAYS_ON_STOCK", query.value("always_on_stock").toInt() ? "TRUE":"FALSE"); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
234 | xmlWriter->writeTextElement("ALPHA", QString::number(query.value("alpha").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
235 | xmlWriter->writeTextElement("BETA", QString::number(query.value("beta").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
236 | xmlWriter->writeTextElement("HUMULENE", QString::number(query.value("humulene").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
237 | xmlWriter->writeTextElement("CAROPHYLLENE", QString::number(query.value("caryophyllene").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
238 | xmlWriter->writeTextElement("COHUMULONE", QString::number(query.value("cohumulone").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
239 | xmlWriter->writeTextElement("MYRCENE", QString::number(query.value("myrcene").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
240 | xmlWriter->writeTextElement("TOTAL_OIL", QString::number(query.value("total_oil").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
241 | xmlWriter->writeTextElement("HSI", QString::number(query.value("hsi").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
242 | xmlWriter->writeTextElement("TYPE", types[query.value("type").toInt()]); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
243 | xmlWriter->writeTextElement("FORM", forms[query.value("form").toInt()]); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
244 | xmlWriter->writeTextElement("BMS_FORM", g_hop_forms[query.value("form").toInt()]); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
245 | xmlWriter->writeTextElement("BMS_UTILISATION", QString::number(query.value("utilisation").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
246 | xmlWriter->writeTextElement("BMS_BU_FACTOR", QString::number(query.value("bu_factor").toDouble(), 'f', 4)); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
247 | xmlWriter->writeTextElement("ORIGIN", query.value("origin").toString()); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
248 | if (query.value("substitutes").toString().length()) |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
249 | xmlWriter->writeTextElement("SUBSTITUTES", query.value("substitutes").toString()); |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
250 | if (query.value("cost").toDouble() > 0) |
a4b218e7c10b
With inventory hops beerxml export support hop extracts. Added private xml values to show the real values and hide these in the poort designed beerxml know values.
Michiel Broek <mbroek@mbse.eu>
parents:
380
diff
changeset
|
251 | xmlWriter->writeTextElement("COST", QString::number(query.value("cost").toDouble(), 'f', 4)); |
44
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
252 | xmlWriter->writeEndElement(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
253 | query.next(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
254 | } |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
255 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
256 | xmlWriter->writeEndElement(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
257 | xmlWriter->writeEndDocument(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
258 | QMessageBox::information(this, tr("Save File"), tr("XML export ready")); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
259 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
260 | file.close(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
261 | } |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
262 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
24
diff
changeset
|
263 |