src/InventoryYeasts.cpp

Fri, 10 Feb 2023 14:06:47 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 10 Feb 2023 14:06:47 +0100
changeset 491
76f3a96e82b5
parent 301
fe6346211b5b
permissions
-rw-r--r--

Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.

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);
290
93820a8ffbff Removed unneeded import buttons from the inventory screens.
Michiel Broek <mbroek@mbse.eu>
parents: 155
diff changeset
65 horizontalLayout->addWidget(exportButton, 0, Qt::AlignCenter);
70
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 insertButton = new QPushButton(groupBox);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
68 insertButton->setObjectName(QString::fromUtf8("insertButton"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
69 insertButton->setMinimumSize(QSize(80, 24));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
70 insertButton->setText(tr("New"));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
71 QIcon icon3;
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
72 icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
73 insertButton->setIcon(icon3);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
74 horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
75 gridLayout->addWidget(groupBox, 1, 0, 1, 1);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
76
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
77 connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryYeasts()));
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
78 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
79 connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked()));
79
e726db72da3c All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents: 70
diff changeset
80 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
81 emit refreshTable();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 }
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 void InventoryYeasts::refreshTable()
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 QString w;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 QWidget* pWidget;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 QLabel *label;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 QHBoxLayout* pLayout;
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 qDebug() << "InventoryYeasts reload";
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 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
95 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
96
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 /* 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
98 this->tableYeasts->setColumnCount(11);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
99 this->tableYeasts->setColumnWidth(0, 120); /* Laboratory */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
100 this->tableYeasts->setColumnWidth(1, 120); /* Product ID */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
101 this->tableYeasts->setColumnWidth(2, 250); /* Name */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
102 this->tableYeasts->setColumnWidth(3, 70); /* Type */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
103 this->tableYeasts->setColumnWidth(4, 70); /* Form */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
104 this->tableYeasts->setColumnWidth(5, 80); /* SVG */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
105 this->tableYeasts->setColumnWidth(6, 80); /* Tolerance */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
106 this->tableYeasts->setColumnWidth(7, 60); /* POF+ */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
107 this->tableYeasts->setColumnWidth(8, 60); /* STA1 */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
108 this->tableYeasts->setColumnWidth(9, 80); /* Stock */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
109 this->tableYeasts->setColumnWidth(10, 80); /* Edit button */
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
110 this->tableYeasts->setRowCount(query.size());
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
111 this->tableYeasts->setHorizontalHeaderLabels(labels);
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
112 this->tableYeasts->verticalHeader()->hide();
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 QTableWidgetItem *rightitem = new QTableWidgetItem();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 rightitem->setTextAlignment(Qt::AlignRight);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 query.first();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 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
119 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
120 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
121 this->tableYeasts->setItem(ridx, 2, new QTableWidgetItem(query.value(1).toString())); /* Name */
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
122 this->tableYeasts->setItem(ridx, 3, new QTableWidgetItem(QCoreApplication::translate("YeastType", g_yeast_types[query.value(2).toInt()])));/* Type */
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 290
diff changeset
123 this->tableYeasts->setItem(ridx, 4, new QTableWidgetItem(QCoreApplication::translate("YeastForm", g_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
124 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
125 QTableWidgetItem *item = new QTableWidgetItem(w);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
127 this->tableYeasts->setItem(ridx, 5, item);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 w = QString("");
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 if (query.value(10).toDouble() > 0)
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 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
131 item = new QTableWidgetItem(w);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
133 this->tableYeasts->setItem(ridx, 6, item);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 if (query.value(24).toInt()) {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 pWidget = new QWidget();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 label = new QLabel;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 label->setPixmap(QPixmap(":icons/silk/tick.png"));
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 pLayout = new QHBoxLayout(pWidget);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 pLayout->addWidget(label);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 pLayout->setAlignment(Qt::AlignCenter);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 pLayout->setContentsMargins(0, 0, 0, 0);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 pWidget->setLayout(pLayout);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
144 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
145 } else {
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
146 this->tableYeasts->removeCellWidget(ridx, 7);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 }
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 if (query.value(19).toInt()) {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 pWidget = new QWidget();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 label = new QLabel;
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 label->setPixmap(QPixmap(":icons/silk/tick.png"));
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 pLayout = new QHBoxLayout(pWidget);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 pLayout->addWidget(label);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 pLayout->setAlignment(Qt::AlignCenter);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 pLayout->setContentsMargins(0, 0, 0, 0);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 pWidget->setLayout(pLayout);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
157 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
158 } else {
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
159 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
160 }
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 w = QString("");
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 if (query.value(14).toDouble() > 0) {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 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
165 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
166 } 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
167 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
168 } 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
169 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
170 } else { /* Any other form */
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 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
172 }
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 }
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 item = new QTableWidgetItem(w);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
176 this->tableYeasts->setItem(ridx, 9, item);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 /* Add the Edit button */
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 pWidget = new QWidget();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 QPushButton* btn_edit = new QPushButton();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 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
182 btn_edit->setText(tr("Edit"));
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 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
184 pLayout = new QHBoxLayout(pWidget);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 pLayout->addWidget(btn_edit);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 pLayout->setContentsMargins(5, 0, 5, 0);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 pWidget->setLayout(pLayout);
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
188 this->tableYeasts->setCellWidget(ridx, 10, pWidget);
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 query.next();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 }
79
e726db72da3c All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents: 70
diff changeset
191 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
192 }
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194
70
556b4202c5e7 Inventory Yeasts now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
195 InventoryYeasts::~InventoryYeasts() {}
25
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 void InventoryYeasts::edit(int recno)
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 {
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 EditYeast dialog(recno, this);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 /* 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
202 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
203 dialog.setModal(true);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 dialog.exec();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 }
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::on_editButton_clicked()
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 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 int recno = pb->objectName().toInt();
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 edit(recno);
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 }
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214
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 void InventoryYeasts::on_insertButton_clicked()
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 edit(-1);
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
a9da2744609e Added inventory yeasts editor. Fixed resource icons location.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221
44
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
222 void InventoryYeasts::on_exportButton_clicked()
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
223 {
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
224 qDebug() << Q_FUNC_INFO;
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
225
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
226 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
227 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
228 /* "Lager", "Ale", "Wheat", "Wine", "Champagne", "Brett", "Kveik", "Hybrid" */
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
229 /* 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
230 /* instead of what we internally use. */
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
231 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
232 /* "Liquid", "Dry", "Slant", "Culture", "Frozen", "Bottle", "Dried" */
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
233 const QStringList flocs({ "Low", "Medium", "High", "Very high" });
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 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
236 if (fileName == 0) {
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
237 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
238 return;
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
239 }
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
240
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
241 QFile file(fileName);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
242 file.open(QIODevice::WriteOnly);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
243
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
244 QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
245 xmlWriter->writeStartDocument();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
246 xmlWriter->setAutoFormatting(true);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
247 xmlWriter->setAutoFormattingIndent(1);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
248 xmlWriter->writeStartElement("YEASTS");
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 query.first();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
251 for (int i = 0 ; i < query.size() ; i++ ) {
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
252 xmlWriter->writeStartElement("YEAST");
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
253 xmlWriter->writeTextElement("VERSION", "1");
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
254 xmlWriter->writeTextElement("NAME", query.value(1).toString());
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
255 xmlWriter->writeTextElement("TYPE", types[query.value(2).toInt()]);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
256 xmlWriter->writeTextElement("FORM", forms[query.value(3).toInt()]);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
257 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
258 xmlWriter->writeTextElement("LABORATORY", query.value(4).toString());
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
259 if (query.value(5).toString().length())
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
260 xmlWriter->writeTextElement("PRODUCT_ID", query.value(5).toString());
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
261 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
262 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
263 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
264 xmlWriter->writeTextElement("ADD_TO_SECONDARY", "FALSE");
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
265 xmlWriter->writeTextElement("FLOCCULATION", flocs[query.value(8).toInt()]);
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
266 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
267 if (query.value(15).toDouble() > 0)
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
268 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
269 if (query.value(11).toString().length())
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
270 xmlWriter->writeTextElement("NOTES", query.value(11).toString());
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
271 xmlWriter->writeEndElement();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
272 query.next();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
273 }
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
274
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
275 xmlWriter->writeEndElement();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
276 xmlWriter->writeEndDocument();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
277 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
278
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
279 file.close();
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
280 }
5a9a159c2d34 Added yeasts and hops XML exports.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
281

mercurial