Mon, 18 Apr 2022 20:00:49 +0200
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * InventoryYeasts.cpp is part of bmsapp. |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "InventoryYeasts.h" |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | #include "EditYeast.h" |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
19 | #include "MainWindow.h" |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | #include "config.h" |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
23 | InventoryYeasts::InventoryYeasts(QWidget *parent) : QDialog(parent) |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | { |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | qDebug() << "InventoryYeasts start"; |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
27 | gridLayout = new QGridLayout(this); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
28 | gridLayout->setObjectName(QString::fromUtf8("gridLayout")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
29 | tableYeasts = new QTableWidget(this); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
30 | tableYeasts->setObjectName(QString::fromUtf8("tableYeasts")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
31 | tableYeasts->setEnabled(true); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
32 | QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
33 | sizePolicy.setHorizontalStretch(0); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
34 | sizePolicy.setVerticalStretch(0); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
35 | tableYeasts->setSizePolicy(sizePolicy); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
36 | tableYeasts->setMinimumSize(QSize(1094, 0)); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
37 | gridLayout->addWidget(tableYeasts, 0, 0, 1, 1); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
38 | |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
39 | groupBox = new QGroupBox(this); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
40 | groupBox->setObjectName(QString::fromUtf8("groupBox")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
41 | groupBox->setEnabled(true); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
42 | groupBox->setFlat(false); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
43 | horizontalLayout = new QHBoxLayout(groupBox); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
44 | horizontalLayout->setSpacing(6); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
45 | horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
46 | horizontalLayout->setContentsMargins(0, 0, 0, 0); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
47 | |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
48 | quitButton = new QPushButton(groupBox); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
49 | quitButton->setObjectName(QString::fromUtf8("quitButton")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
50 | quitButton->setMinimumSize(QSize(80, 24)); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
51 | quitButton->setText(tr("Quit")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
52 | QIcon icon; |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
53 | icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
54 | quitButton->setIcon(icon); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
55 | horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
56 | |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
57 | exportButton = new QPushButton(groupBox); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
58 | exportButton->setObjectName(QString::fromUtf8("exportButton")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
59 | exportButton->setMinimumSize(QSize(80, 24)); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
60 | exportButton->setText(tr("Export")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
61 | QIcon icon1; |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
62 | icon1.addFile(QString::fromUtf8(":/icons/silk/database_save.png"), QSize(), QIcon::Normal, QIcon::Off); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
63 | exportButton->setIcon(icon1); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
64 | horizontalLayout->addWidget(exportButton, 0, Qt::AlignRight); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
65 | |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
66 | importButton = new QPushButton(groupBox); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
67 | importButton->setObjectName(QString::fromUtf8("importButton")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
68 | importButton->setMinimumSize(QSize(80, 24)); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
69 | importButton->setText(tr("Import")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
70 | QIcon icon2; |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
71 | icon2.addFile(QString::fromUtf8(":/icons/silk/database_add.png"), QSize(), QIcon::Normal, QIcon::Off); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
72 | importButton->setIcon(icon2); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
73 | horizontalLayout->addWidget(importButton, 0, Qt::AlignRight); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
74 | |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
75 | insertButton = new QPushButton(groupBox); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
76 | insertButton->setObjectName(QString::fromUtf8("insertButton")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
77 | insertButton->setMinimumSize(QSize(80, 24)); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
78 | insertButton->setText(tr("New")); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
79 | QIcon icon3; |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
80 | icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
81 | insertButton->setIcon(icon3); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
82 | horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
83 | gridLayout->addWidget(groupBox, 1, 0, 1, 1); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
84 | |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
85 | connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryYeasts())); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
86 | connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
87 | connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked())); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
88 | // connect(importButton, SIGNAL(clicked()), this, SLOT(on_importButton_clicked())); |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
89 | connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | emit refreshTable(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | } |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | void InventoryYeasts::refreshTable() |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | { |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | QString w; |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | QWidget* pWidget; |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | QLabel *label; |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | QHBoxLayout* pLayout; |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | qDebug() << "InventoryYeasts reload"; |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | QSqlQuery query("SELECT * FROM inventory_yeasts ORDER BY laboratory,product_id,name"); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | const QStringList labels({tr("Laboratory"), tr("Product id"), tr("Name"), tr("Type"), tr("Form"), tr("SVG %"), tr("Tol %"), tr("POF+"), tr("STA1"), tr("Stock"), tr("Edit")}); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | const QStringList types({tr("Lager"), tr("Ale"), tr("Wheat"), tr("Wine"), tr("Champagne"), tr("Brett"), tr("Kveik"), tr("Hybrid")}); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | const QStringList form({tr("Liquid"), tr("Dry"), tr("Slant"), tr("Culture"), tr("Frozen"), tr("Bottle"), tr("Dried")}); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | /* origin supplier name type graintype color yield inventory Edit */ |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
109 | this->tableYeasts->setColumnCount(11); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
110 | this->tableYeasts->setColumnWidth(0, 120); /* Laboratory */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
111 | this->tableYeasts->setColumnWidth(1, 120); /* Product ID */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
112 | this->tableYeasts->setColumnWidth(2, 250); /* Name */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
113 | this->tableYeasts->setColumnWidth(3, 70); /* Type */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
114 | this->tableYeasts->setColumnWidth(4, 70); /* Form */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
115 | this->tableYeasts->setColumnWidth(5, 80); /* SVG */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
116 | this->tableYeasts->setColumnWidth(6, 80); /* Tolerance */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
117 | this->tableYeasts->setColumnWidth(7, 60); /* POF+ */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
118 | this->tableYeasts->setColumnWidth(8, 60); /* STA1 */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
119 | this->tableYeasts->setColumnWidth(9, 80); /* Stock */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
120 | this->tableYeasts->setColumnWidth(10, 80); /* Edit button */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
121 | this->tableYeasts->setRowCount(query.size()); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
122 | this->tableYeasts->setHorizontalHeaderLabels(labels); |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
123 | this->tableYeasts->verticalHeader()->hide(); |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | QTableWidgetItem *rightitem = new QTableWidgetItem(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | rightitem->setTextAlignment(Qt::AlignRight); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | query.first(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
130 | this->tableYeasts->setItem(ridx, 0, new QTableWidgetItem(query.value(4).toString())); /* Laboratory */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
131 | this->tableYeasts->setItem(ridx, 1, new QTableWidgetItem(query.value(5).toString())); /* Product id */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
132 | this->tableYeasts->setItem(ridx, 2, new QTableWidgetItem(query.value(1).toString())); /* Name */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
133 | this->tableYeasts->setItem(ridx, 3, new QTableWidgetItem(types[query.value(2).toInt()])); /* Type */ |
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
134 | this->tableYeasts->setItem(ridx, 4, new QTableWidgetItem(form[query.value(3).toInt()])); /* Form */ |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | w = QString("%1 %").arg(query.value(9).toDouble(), 2, 'f', 1, '0' ); /* Attenuation% */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | QTableWidgetItem *item = new QTableWidgetItem(w); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
138 | this->tableYeasts->setItem(ridx, 5, item); |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | w = QString(""); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | if (query.value(10).toDouble() > 0) |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | w = QString("%1 %").arg(query.value(10).toDouble(), 2, 'f', 1, '0' ); /* Alcohol% */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | item = new QTableWidgetItem(w); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
144 | this->tableYeasts->setItem(ridx, 6, item); |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | if (query.value(24).toInt()) { |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | pWidget = new QWidget(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | label = new QLabel; |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | label->setPixmap(QPixmap(":icons/silk/tick.png")); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | pLayout = new QHBoxLayout(pWidget); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | pLayout->addWidget(label); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | pLayout->setAlignment(Qt::AlignCenter); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | pLayout->setContentsMargins(0, 0, 0, 0); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | pWidget->setLayout(pLayout); |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
155 | this->tableYeasts->setCellWidget(ridx, 7, pWidget); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
25
diff
changeset
|
156 | } else { |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
157 | this->tableYeasts->removeCellWidget(ridx, 7); |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | } |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | if (query.value(19).toInt()) { |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | pWidget = new QWidget(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | label = new QLabel; |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | label->setPixmap(QPixmap(":icons/silk/tick.png")); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | pLayout = new QHBoxLayout(pWidget); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | pLayout->addWidget(label); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | pLayout->setAlignment(Qt::AlignCenter); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | pLayout->setContentsMargins(0, 0, 0, 0); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | pWidget->setLayout(pLayout); |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
168 | this->tableYeasts->setCellWidget(ridx, 8, pWidget); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
25
diff
changeset
|
169 | } else { |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
170 | this->tableYeasts->removeCellWidget(ridx, 8); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
25
diff
changeset
|
171 | } |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | w = QString(""); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
174 | if (query.value(14).toDouble() > 0) { |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | if (query.value(3).toInt() == 0 && query.value(14).toDouble() > 1) { /* Liquid yeast, multiple packs */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | w = QString("%1 packs").arg(query.value(14).toDouble(), 1, 'f', 0, '0'); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | } else if (query.value(3).toInt() == 0) { /* Liquid yeast */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
178 | w = QString("%1 pack").arg(query.value(14).toDouble(), 1, 'f', 0, '0'); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | } else if (query.value(3).toInt() == 1 || query.value(3).toInt() == 6) { /* Dry or dried */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | w = QString("%1 gram").arg(query.value(14).toDouble() * 1000, 2, 'f', 1, '0'); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | } else { /* Any other form */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | w = QString("%1 ml").arg(query.value(14).toDouble() * 1000, 2, 'f', 1, '0'); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | } |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
184 | } |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | item = new QTableWidgetItem(w); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
187 | this->tableYeasts->setItem(ridx, 9, item); |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | /* Add the Edit button */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | pWidget = new QWidget(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | QPushButton* btn_edit = new QPushButton(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | btn_edit->setText(tr("Edit")); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | pLayout = new QHBoxLayout(pWidget); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | pLayout->addWidget(btn_edit); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | pLayout->setContentsMargins(5, 0, 5, 0); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | pWidget->setLayout(pLayout); |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
199 | this->tableYeasts->setCellWidget(ridx, 10, pWidget); |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | query.next(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | } |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
70
diff
changeset
|
202 | emit setStatus(QString(tr("Total items: %1")).arg(query.size())); |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | } |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | |
70
556b4202c5e7
Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
206 | InventoryYeasts::~InventoryYeasts() {} |
25
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | void InventoryYeasts::edit(int recno) |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | { |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | EditYeast dialog(recno, this); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | /* Signal from editor if a refresh is needed */ |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | dialog.setModal(true); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | dialog.exec(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | } |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | void InventoryYeasts::on_editButton_clicked() |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | { |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | int recno = pb->objectName().toInt(); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | edit(recno); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | } |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
227 | void InventoryYeasts::on_insertButton_clicked() |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | { |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
229 | edit(-1); |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
230 | } |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | |
a9da2744609e
Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | |
44
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
233 | void InventoryYeasts::on_exportButton_clicked() |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
234 | { |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
235 | qDebug() << Q_FUNC_INFO; |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
236 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
237 | QSqlQuery query("SELECT * FROM inventory_yeasts ORDER BY laboratory,product_id,name"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
238 | const QStringList types({ "Lager", "Ale", "Wheat", "Wine", "Champagne", "Other", "Other", "Other" }); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
239 | /* "Lager", "Ale", "Wheat", "Wine", "Champagne", "Brett", "Kveik", "Hybrid" */ |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
240 | /* We use more yeat forms then beerxml knows about, so we send known names */ |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
241 | /* instead of what we internally use. */ |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
242 | const QStringList forms({ "Liquid", "Dry", "Slant", "Culture", "Culture", "Culture", "Dry" }); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
243 | /* "Liquid", "Dry", "Slant", "Culture", "Frozen", "Bottle", "Dried" */ |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
244 | const QStringList flocs({ "Low", "Medium", "High", "Very high" }); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
245 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
246 | QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/yeasts.xml", tr("Files (*.xml)")); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
247 | if (fileName == 0) { |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
248 | QMessageBox::warning(this, tr("Save File"), tr("No XML file selected.")); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
249 | return; |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
250 | } |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
251 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
252 | QFile file(fileName); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
253 | file.open(QIODevice::WriteOnly); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
254 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
255 | QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
256 | xmlWriter->writeStartDocument(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
257 | xmlWriter->setAutoFormatting(true); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
258 | xmlWriter->setAutoFormattingIndent(1); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
259 | xmlWriter->writeStartElement("YEASTS"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
260 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
261 | query.first(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
262 | for (int i = 0 ; i < query.size() ; i++ ) { |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
263 | xmlWriter->writeStartElement("YEAST"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
264 | xmlWriter->writeTextElement("VERSION", "1"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
265 | xmlWriter->writeTextElement("NAME", query.value(1).toString()); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
266 | xmlWriter->writeTextElement("TYPE", types[query.value(2).toInt()]); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
267 | xmlWriter->writeTextElement("FORM", forms[query.value(3).toInt()]); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
268 | xmlWriter->writeTextElement("AMOUNT_IS_WEIGHT", (query.value(3).toInt() == 1 || query.value(3).toInt() == 6) ? "TRUE":"FALSE"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
269 | xmlWriter->writeTextElement("LABORATORY", query.value(4).toString()); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
270 | if (query.value(5).toString().length()) |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
271 | xmlWriter->writeTextElement("PRODUCT_ID", query.value(5).toString()); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
272 | xmlWriter->writeTextElement("MIN_TEMPERATURE", QString::number(query.value(6).toDouble(), 'f', 4)); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
273 | xmlWriter->writeTextElement("MAX_TEMPERATURE", QString::number(query.value(7).toDouble(), 'f', 4)); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
274 | xmlWriter->writeTextElement("ATTENUATION", QString::number(query.value(9).toDouble(), 'f', 4)); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
275 | xmlWriter->writeTextElement("ADD_TO_SECONDARY", "FALSE"); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
276 | xmlWriter->writeTextElement("FLOCCULATION", flocs[query.value(8).toInt()]); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
277 | xmlWriter->writeTextElement("MAX_REUSE", QString::number(query.value(13).toInt())); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
278 | if (query.value(15).toDouble() > 0) |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
279 | xmlWriter->writeTextElement("COST", QString::number(query.value(15).toDouble(), 'f', 5)); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
280 | if (query.value(11).toString().length()) |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
281 | xmlWriter->writeTextElement("NOTES", query.value(11).toString()); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
282 | xmlWriter->writeEndElement(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
283 | query.next(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
284 | } |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
285 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
286 | xmlWriter->writeEndElement(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
287 | xmlWriter->writeEndDocument(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
288 | QMessageBox::information(this, tr("Save File"), tr("XML export ready")); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
289 | |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
290 | file.close(); |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
291 | } |
5a9a159c2d34
Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
292 |