src/InventoryYeasts.cpp

Mon, 06 Jun 2022 13:04:27 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 06 Jun 2022 13:04:27 +0200
changeset 257
cfba041bdaee
parent 155
f671c599f65b
child 290
93820a8ffbff
permissions
-rw-r--r--

Changed some logging levels. Fixed copy recipe to product sparge water setteings. Added export to forum via clipboard. The recipe export is completed.

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"
155
f671c599f65b Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
21 #include "global.h"
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
24 InventoryYeasts::InventoryYeasts(QWidget *parent) : QDialog(parent)
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 qDebug() << "InventoryYeasts start";
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
28 gridLayout = new QGridLayout(this);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
29 gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
30 tableYeasts = new QTableWidget(this);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
31 tableYeasts->setObjectName(QString::fromUtf8("tableYeasts"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
32 tableYeasts->setEnabled(true);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
33 QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
34 sizePolicy.setHorizontalStretch(0);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
35 sizePolicy.setVerticalStretch(0);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
36 tableYeasts->setSizePolicy(sizePolicy);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
37 tableYeasts->setMinimumSize(QSize(1094, 0));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
38 gridLayout->addWidget(tableYeasts, 0, 0, 1, 1);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
39
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
40 groupBox = new QGroupBox(this);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
41 groupBox->setObjectName(QString::fromUtf8("groupBox"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
42 groupBox->setEnabled(true);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
43 groupBox->setFlat(false);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
44 horizontalLayout = new QHBoxLayout(groupBox);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
45 horizontalLayout->setSpacing(6);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
46 horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
47 horizontalLayout->setContentsMargins(0, 0, 0, 0);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
48
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
49 quitButton = new QPushButton(groupBox);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
50 quitButton->setObjectName(QString::fromUtf8("quitButton"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
51 quitButton->setMinimumSize(QSize(80, 24));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
52 quitButton->setText(tr("Quit"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
53 QIcon icon;
556b4202c5e7 Inventory Yeasts 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);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
55 quitButton->setIcon(icon);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
56 horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
57
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
58 exportButton = new QPushButton(groupBox);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
59 exportButton->setObjectName(QString::fromUtf8("exportButton"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
60 exportButton->setMinimumSize(QSize(80, 24));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
61 exportButton->setText(tr("Export"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
62 QIcon icon1;
556b4202c5e7 Inventory Yeasts 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);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
64 exportButton->setIcon(icon1);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
65 horizontalLayout->addWidget(exportButton, 0, Qt::AlignRight);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
66
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
67 importButton = new QPushButton(groupBox);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
68 importButton->setObjectName(QString::fromUtf8("importButton"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
69 importButton->setMinimumSize(QSize(80, 24));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
70 importButton->setText(tr("Import"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
71 QIcon icon2;
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
72 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
73 importButton->setIcon(icon2);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
74 horizontalLayout->addWidget(importButton, 0, Qt::AlignRight);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
75
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
76 insertButton = new QPushButton(groupBox);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
77 insertButton->setObjectName(QString::fromUtf8("insertButton"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
78 insertButton->setMinimumSize(QSize(80, 24));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
79 insertButton->setText(tr("New"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
80 QIcon icon3;
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
81 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
82 insertButton->setIcon(icon3);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
83 horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
84 gridLayout->addWidget(groupBox, 1, 0, 1, 1);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
85
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
86 connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryYeasts()));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
87 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
88 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
89 // 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
90 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
91 emit refreshTable();
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
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 void InventoryYeasts::refreshTable()
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 QString w;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 QWidget* pWidget;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 QLabel *label;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 QHBoxLayout* pLayout;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 qDebug() << "InventoryYeasts reload";
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 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
105 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
106
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 /* 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
108 this->tableYeasts->setColumnCount(11);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
109 this->tableYeasts->setColumnWidth(0, 120); /* Laboratory */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
110 this->tableYeasts->setColumnWidth(1, 120); /* Product ID */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
111 this->tableYeasts->setColumnWidth(2, 250); /* Name */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
112 this->tableYeasts->setColumnWidth(3, 70); /* Type */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
113 this->tableYeasts->setColumnWidth(4, 70); /* Form */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
114 this->tableYeasts->setColumnWidth(5, 80); /* SVG */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
115 this->tableYeasts->setColumnWidth(6, 80); /* Tolerance */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
116 this->tableYeasts->setColumnWidth(7, 60); /* POF+ */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
117 this->tableYeasts->setColumnWidth(8, 60); /* STA1 */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
118 this->tableYeasts->setColumnWidth(9, 80); /* Stock */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
119 this->tableYeasts->setColumnWidth(10, 80); /* Edit button */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
120 this->tableYeasts->setRowCount(query.size());
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
121 this->tableYeasts->setHorizontalHeaderLabels(labels);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
122 this->tableYeasts->verticalHeader()->hide();
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 QTableWidgetItem *rightitem = new QTableWidgetItem();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 rightitem->setTextAlignment(Qt::AlignRight);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 query.first();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 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
129 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
130 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
131 this->tableYeasts->setItem(ridx, 2, new QTableWidgetItem(query.value(1).toString())); /* Name */
155
f671c599f65b Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
132 this->tableYeasts->setItem(ridx, 3, new QTableWidgetItem(yeast_types[query.value(2).toInt()])); /* Type */
f671c599f65b Moved more QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
133 this->tableYeasts->setItem(ridx, 4, new QTableWidgetItem(yeast_forms[query.value(3).toInt()])); /* Form */
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 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
135 QTableWidgetItem *item = new QTableWidgetItem(w);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
137 this->tableYeasts->setItem(ridx, 5, item);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 w = QString("");
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 if (query.value(10).toDouble() > 0)
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 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
141 item = new QTableWidgetItem(w);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
143 this->tableYeasts->setItem(ridx, 6, item);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 if (query.value(24).toInt()) {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 pWidget = new QWidget();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 label = new QLabel;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 label->setPixmap(QPixmap(":icons/silk/tick.png"));
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 pLayout = new QHBoxLayout(pWidget);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 pLayout->addWidget(label);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 pLayout->setAlignment(Qt::AlignCenter);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 pLayout->setContentsMargins(0, 0, 0, 0);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 pWidget->setLayout(pLayout);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
154 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
155 } else {
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
156 this->tableYeasts->removeCellWidget(ridx, 7);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 }
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 if (query.value(19).toInt()) {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 pWidget = new QWidget();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 label = new QLabel;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 label->setPixmap(QPixmap(":icons/silk/tick.png"));
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 pLayout = new QHBoxLayout(pWidget);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 pLayout->addWidget(label);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 pLayout->setAlignment(Qt::AlignCenter);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 pLayout->setContentsMargins(0, 0, 0, 0);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 pWidget->setLayout(pLayout);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
167 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
168 } else {
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
169 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
170 }
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 w = QString("");
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 if (query.value(14).toDouble() > 0) {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 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
175 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
176 } 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
177 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
178 } 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
179 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
180 } else { /* Any other form */
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 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
182 }
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 item = new QTableWidgetItem(w);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
186 this->tableYeasts->setItem(ridx, 9, item);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 /* Add the Edit button */
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 pWidget = new QWidget();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 QPushButton* btn_edit = new QPushButton();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 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
192 btn_edit->setText(tr("Edit"));
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 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
194 pLayout = new QHBoxLayout(pWidget);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 pLayout->addWidget(btn_edit);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 pLayout->setContentsMargins(5, 0, 5, 0);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 pWidget->setLayout(pLayout);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
198 this->tableYeasts->setCellWidget(ridx, 10, pWidget);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 query.next();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 }
79
e726db72da3c All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents: 70
diff changeset
201 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
202 }
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
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
205 InventoryYeasts::~InventoryYeasts() {}
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206
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 void InventoryYeasts::edit(int recno)
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 EditYeast dialog(recno, this);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 /* 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
212 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
213 dialog.setModal(true);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 dialog.exec();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 }
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 void InventoryYeasts::on_editButton_clicked()
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 int recno = pb->objectName().toInt();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 edit(recno);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 }
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 void InventoryYeasts::on_insertButton_clicked()
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 edit(-1);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 }
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
44
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
232 void InventoryYeasts::on_exportButton_clicked()
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
233 {
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
234 qDebug() << Q_FUNC_INFO;
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
235
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
236 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
237 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
238 /* "Lager", "Ale", "Wheat", "Wine", "Champagne", "Brett", "Kveik", "Hybrid" */
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
239 /* 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
240 /* instead of what we internally use. */
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
241 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
242 /* "Liquid", "Dry", "Slant", "Culture", "Frozen", "Bottle", "Dried" */
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
243 const QStringList flocs({ "Low", "Medium", "High", "Very high" });
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
244
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
245 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
246 if (fileName == 0) {
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
247 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
248 return;
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
249 }
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 QFile file(fileName);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
252 file.open(QIODevice::WriteOnly);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
253
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
254 QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
255 xmlWriter->writeStartDocument();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
256 xmlWriter->setAutoFormatting(true);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
257 xmlWriter->setAutoFormattingIndent(1);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
258 xmlWriter->writeStartElement("YEASTS");
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
259
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
260 query.first();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
261 for (int i = 0 ; i < query.size() ; i++ ) {
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
262 xmlWriter->writeStartElement("YEAST");
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
263 xmlWriter->writeTextElement("VERSION", "1");
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
264 xmlWriter->writeTextElement("NAME", query.value(1).toString());
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
265 xmlWriter->writeTextElement("TYPE", types[query.value(2).toInt()]);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
266 xmlWriter->writeTextElement("FORM", forms[query.value(3).toInt()]);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
267 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
268 xmlWriter->writeTextElement("LABORATORY", query.value(4).toString());
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
269 if (query.value(5).toString().length())
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
270 xmlWriter->writeTextElement("PRODUCT_ID", query.value(5).toString());
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
271 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
272 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
273 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
274 xmlWriter->writeTextElement("ADD_TO_SECONDARY", "FALSE");
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
275 xmlWriter->writeTextElement("FLOCCULATION", flocs[query.value(8).toInt()]);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
276 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
277 if (query.value(15).toDouble() > 0)
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
278 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
279 if (query.value(11).toString().length())
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
280 xmlWriter->writeTextElement("NOTES", query.value(11).toString());
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
281 xmlWriter->writeEndElement();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
282 query.next();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
283 }
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 xmlWriter->writeEndElement();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
286 xmlWriter->writeEndDocument();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
287 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
288
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
289 file.close();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
290 }
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
291

mercurial