Tue, 14 Jun 2022 09:39:31 +0200
Added import waters
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * ImportXML.cpp is part of bmsapp. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "ImportXML.h" |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | #include "../ui/ui_ImportXML.h" |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
19 | #include "global.h" |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
20 | #include "Utils.h" |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | #include "MainWindow.h" |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | ImportXML::ImportXML(QWidget *parent) : QDialog(parent), ui(new Ui::ImportXML) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | qDebug() << "ImportXML start"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | ui->setupUi(this); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | WindowTitle(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | ui->progressBar->setValue(0); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | connect(ui->quitButton, SIGNAL(clicked()), parent, SLOT(fromImportXML())); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | ImportXML::~ImportXML() |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | qDebug() << "ImportXML done"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | delete ui; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | void ImportXML::WindowTitle() |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | QString txt = QString(tr("BMSapp - Import XML")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | setWindowTitle(txt); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | void ImportXML::on_openButton_clicked() |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | QSqlQuery query; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
51 | QString log; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | int total = 0, errors = 0; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath() + "/*.xml", tr("Files (*.xml)")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | if (fileName == 0) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | QMessageBox::warning(this, tr("Open File"), tr("No XML file selected.")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | return; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | ui->fileEdit->setText(fileName); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | QFile file(fileName); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | qint64 fsize = file.size(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | log = "Import XML file `" + fileName + "`\n\n"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | qInfo() << "Import XML" << fileName << "length" << fsize << "bytes"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | file.open(QIODevice::ReadOnly); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | QXmlStreamReader *xml = new QXmlStreamReader(&file); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | if (xml->tokenType() == QXmlStreamReader::StartDocument) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
76 | qDebug() << xml->documentVersion() << xml->documentEncoding(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | // Just skip |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EQUIPMENTS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | * Equipments |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "EQUIPMENTS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | qDebug() << "0 /EQUIPMENTS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EQUIPMENT")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | * Equipment |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | total++; |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
94 | Equipment *eq = new Equipment(); |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
95 | eq->notes = ""; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "EQUIPMENT")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
101 | query.prepare("INSERT INTO inventory_equipments SET name=:name, boil_size=:boil_size, " |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
102 | "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, " |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
103 | "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, " |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
104 | "top_up_water=:top_up_water, trub_chiller_loss=:chiller_loss, evap_rate=:evap_rate, " |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
105 | "boil_time=:boil_time, calc_boil_volume=:calcboil, top_up_kettle=:top_up_kettle, " |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
106 | "hop_utilization=:hopfactor, notes=:notes, lauter_volume=:lauter_volume, " |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
107 | "lauter_height=:lauter_height, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
108 | "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
109 | "efficiency=:efficiency, uuid=:uuid"); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
110 | query.bindValue(":name", eq->name); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
111 | query.bindValue(":boil_size", QString("%1").arg(eq->boil_size, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
112 | query.bindValue(":batch_size", QString("%1").arg(eq->batch_size, 3, 'f', 2, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
113 | query.bindValue(":tun_volume", QString("%1").arg(eq->tun_volume, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
114 | query.bindValue(":tun_weight", QString("%1").arg(eq->tun_weight, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
115 | query.bindValue(":tun_specific_heat", QString("%1").arg(eq->tun_specific_heat, 4, 'f', 3, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
116 | query.bindValue(":tun_material", eq->tun_material); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
117 | query.bindValue(":tun_height", QString("%1").arg(eq->tun_height, 4, 'f', 3, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
118 | query.bindValue(":top_up_water", QString("%1").arg(eq->top_up_water, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
119 | query.bindValue(":chiller_loss", QString("%1").arg(eq->trub_chiller_loss, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
120 | /* The evaporation in beerxml is percentage, but we use the real volume per hour */ |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
121 | query.bindValue(":evap_rate", QString("%1").arg((eq->evap_rate / 100) * eq->boil_size, 3, 'f', 2, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
122 | query.bindValue(":boil_time", QString("%1").arg(eq->boil_time, 1, 'f', 0, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
123 | query.bindValue(":calcboil", eq->calc_boil_volume ? 1:0); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
124 | query.bindValue(":top_up_kettle", QString("%1").arg(eq->top_up_kettle, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
125 | query.bindValue(":hopfactor", QString("%1").arg(eq->hop_utilization, 1, 'f', 0, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
126 | query.bindValue(":notes", eq->notes); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
127 | query.bindValue(":lauter_volume", QString("%1").arg(eq->lauter_volume, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
128 | query.bindValue(":lauter_height", QString("%1").arg(eq->lauter_height, 4, 'f', 3, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
129 | query.bindValue(":lauter_deadspace", QString("%1").arg(eq->lauter_deadspace, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
130 | query.bindValue(":kettle_volume", QString("%1").arg(eq->kettle_volume, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
131 | query.bindValue(":kettle_height", QString("%1").arg(eq->kettle_height, 4, 'f', 3, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
132 | query.bindValue(":mash_volume", QString("%1").arg(eq->mash_volume, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
133 | query.bindValue(":mash_max", QString("%1").arg(eq->mash_max, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
134 | query.bindValue(":efficiency", QString("%1").arg(eq->efficiency, 2, 'f', 1, '0')); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
135 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
136 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | if (query.lastError().isValid()) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
138 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
142 | delete eq; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | } |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
145 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
146 | ((xml->name() == "VERSION") || (xml->name() == "DISPLAY_BOIL_SIZE") || |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
147 | (xml->name() == "DISPLAY_BATCH_SIZE") || (xml->name() == "DISPLAY_TUN_VOLUME") || |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
148 | (xml->name() == "DISPLAY_TUN_WEIGHT") || (xml->name() == "DISPLAY_TRUB_CHILLER_LOSS") || |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
149 | (xml->name() == "DISPLAY_LAUTERDEADSPACE") || (xml->name() == "TUN_MATERIAL") || |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
150 | (xml->name() == "ATTENUATION_FACTOR_YEAST") || (xml->name() == "ATTENUATION_FACTOR_WATER_TO_GRAIN_RATIO") || |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
151 | (xml->name() == "ATTENUATION_FACTOR_TOTAL_MASH_TIME") || (xml->name() == "ATTENUATION_FACTOR_PERC_SIMPLE_SUGAR") || |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
152 | (xml->name() == "ATTENUATION_FACTOR_CONSTANT"))) { |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
155 | eq->name = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
157 | eq->notes = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BOIL_SIZE")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
159 | eq->boil_size = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BATCH_SIZE")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
161 | eq->batch_size = xml->readElementText().toDouble(); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
162 | qDebug() << eq->batch_size; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TUN_VOLUME")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
164 | eq->tun_volume = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TUN_WEIGHT")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
166 | eq->tun_weight = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TUN_SPECIFIC_HEAT")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
168 | eq->tun_specific_heat = xml->readElementText().toDouble(); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
169 | if (eq->tun_specific_heat == 0.22) |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
170 | eq->tun_material = 1; |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
171 | else if (eq->tun_specific_heat == 0.46) |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
172 | eq->tun_material = 2; |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
173 | else if (eq->tun_specific_heat == 0.092) |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
174 | eq->tun_material = 3; |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
175 | else |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
176 | eq->tun_material = 0; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TUN_HEIGHT")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
178 | eq->tun_height = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TRUB_CHILLER_LOSS")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
180 | eq->trub_chiller_loss = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EVAP_RATE")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
182 | eq->evap_rate = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BOIL_TIME")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
184 | eq->boil_time = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CALC_BOIL_VOLUME")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
186 | eq->calc_boil_volume = (xml->readElementText() == "TRUE") ? true:false; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
187 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOP_UP_KETTLE")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
188 | eq->top_up_kettle = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOP_UTILIZATION")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
190 | eq->hop_utilization = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LAUTER_VOLUME")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
192 | eq->lauter_volume = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LAUTER_HEIGHT")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
194 | eq->lauter_height = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LAUTER_DEADSPACE")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
196 | eq->lauter_deadspace = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "KETTLE_VOLUME")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
198 | eq->kettle_volume = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "KETTLE_HEIGHT")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
200 | eq->kettle_height = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH_VOLUME")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
202 | eq->mash_volume = xml->readElementText().toDouble(); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
203 | eq->mash_max = eq->mash_volume / 3; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EFFICIENCY")) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
205 | eq->efficiency = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
206 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | * Styles |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "STYLES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | qDebug() << "0 /STYLES"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | * Style |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
227 | */ |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
228 | Style *st = new Style(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
229 | st->notes = st->category = st->style_letter = st->profile = st->ingredients = st->examples = ""; |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
230 | st->style_guide = "BKG 2019"; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "STYLE")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
237 | query.prepare("INSERT INTO profile_styles SET name=:name, category=:category, " |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
238 | "category_number=:catnr, style_letter=:group, style_guide=:guide, type=:type, " |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
239 | "og_min=:og_min, og_max=:og_max, fg_min=:fg_min, fg_max=:fg_max, ibu_min=:ibu_min, " |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
240 | "ibu_max=:ibu_max, color_min=:ebc_min, color_max=:ebc_max, carb_min=:co2_min, " |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
241 | "carb_max=:co2_max, abv_min=:abv_min, abv_max=:abv_max, notes=:notes, " |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
242 | "profile=:profile, ingredients=:ingredients, examples=:examples, uuid=:uuid"); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
243 | query.bindValue(":name", st->name); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
244 | query.bindValue(":category", st->category); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
245 | query.bindValue(":catnr", st->category_number); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
246 | query.bindValue(":group", st->style_letter); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
247 | query.bindValue(":guide", st->style_guide); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
248 | query.bindValue(":type", st->type); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
249 | query.bindValue(":og_min", QString("%1").arg(st->og_min, 4, 'f', 3, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
250 | query.bindValue(":og_max", QString("%1").arg(st->og_max, 4, 'f', 3, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
251 | query.bindValue(":fg_min", QString("%1").arg(st->fg_min, 4, 'f', 3, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
252 | query.bindValue(":fg_max", QString("%1").arg(st->fg_max, 4, 'f', 3, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
253 | query.bindValue(":ibu_min", QString("%1").arg(st->ibu_min, 1, 'f', 0, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
254 | query.bindValue(":ibu_max", QString("%1").arg(st->ibu_max, 1, 'f', 0, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
255 | query.bindValue(":ebc_min", QString("%1").arg(st->color_min, 1, 'f', 0, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
256 | query.bindValue(":ebc_max", QString("%1").arg(st->color_max, 1, 'f', 0, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
257 | query.bindValue(":co2_min", QString("%1").arg(st->carb_min, 2, 'f', 1, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
258 | query.bindValue(":co2_max", QString("%1").arg(st->carb_max, 2, 'f', 1, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
259 | query.bindValue(":abv_min", QString("%1").arg(st->abv_min, 2, 'f', 1, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
260 | query.bindValue(":abv_max", QString("%1").arg(st->abv_max, 2, 'f', 1, '0')); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
261 | query.bindValue(":notes", st->notes); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
262 | query.bindValue(":profile", st->profile); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
263 | query.bindValue(":ingredients", st->ingredients); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
264 | query.bindValue(":examples", st->examples); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
265 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
266 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
267 | if (query.lastError().isValid()) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
268 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
269 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
270 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
271 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
272 | delete st; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
273 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
274 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
275 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "VERSION")) || |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
276 | (xml->name() == "DISPLAY_OG_MIN") || (xml->name() == "DISPLAY_OG_MAX") || (xml->name() == "DISPLAY_FG_MIN") || |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
277 | (xml->name() == "DISPLAY_FG_MAX") || (xml->name() == "DISPLAY_IBU_MIN") || (xml->name() == "DISPLAY_IBU_MAX") || |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
278 | (xml->name() == "DISPLAY_COLOR_MIN") || (xml->name() == "DISPLAY_COLOR_MAX") || (xml->name() == "DISPLAY_CARB_MIN") || |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
279 | (xml->name() == "DISPLAY_CARB_MAX") || (xml->name() == "DISPLAY_ABV_MIN") || (xml->name() == "DISPLAY_ABV_MAX") || |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
280 | (xml->name() == "OG_RANGE") || (xml->name() == "FG_RANGE") || (xml->name() == "IBU_RANGE") || |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
281 | (xml->name() == "CARB_RANGE") || (xml->name() == "COLOR_RANGE") || (xml->name() == "ABV_RANGE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
282 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
283 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
284 | st->name = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
285 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CATEGORY")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
286 | st->category = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
287 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CATEGORY_NUMBER")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
288 | st->category_number = xml->readElementText().toInt(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
289 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLE_LETTER")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
290 | st->style_letter = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
291 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLE_GUIDE")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
292 | st->style_guide = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
293 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
294 | QString temp = xml->readElementText(); |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
295 | if (temp == "Lager") |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
296 | st->type = 0; |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
297 | else if (temp == "Ale") |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
298 | st->type = 1; |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
299 | else if (temp == "Mead") |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
300 | st->type = 2; |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
301 | else if (temp == "Wheat") |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
302 | st->type = 3; |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
303 | else if (temp == "Mixed") |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
304 | st->type = 4; |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
305 | else if (temp == "Cider") |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
306 | st->type = 5; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
307 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
308 | st->notes = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
309 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "OG_MIN")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
310 | st->og_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
311 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "OG_MAX")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
312 | st->og_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
313 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FG_MIN")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
314 | st->fg_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
315 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FG_MAX")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
316 | st->fg_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
317 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "IBU_MIN")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
318 | st->ibu_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
319 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "IBU_MAX")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
320 | st->ibu_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
321 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR_MIN")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
322 | st->color_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
323 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR_MAX")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
324 | st->color_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
325 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CARB_MIN")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
326 | st->carb_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
327 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CARB_MAX")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
328 | st->carb_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
329 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ABV_MIN")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
330 | st->abv_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
331 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ABV_MAX")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
332 | st->abv_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
333 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PROFILE")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
334 | st->profile = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
335 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "INGREDIENTS")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
336 | st->ingredients = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
337 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EXAMPLES")) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
338 | st->examples = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
339 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
340 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
341 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
342 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
343 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
344 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
345 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
346 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FERMENTABLES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
347 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
348 | * Fermentables |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
349 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
350 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
351 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
352 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
353 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
354 | qDebug() << "0 /FERMENTABLES"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
355 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
356 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
357 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FERMENTABLE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
358 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
359 | * Fermentable |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
360 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
361 | total++; |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
362 | Fermentables *f = new Fermentables(); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
363 | f->supplier = f->origin = f->notes = ""; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
364 | f->yield = 80; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
365 | f->max_in_batch = 100; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
366 | f->recommend_mash = true; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
367 | f->di_ph = 5.7; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
368 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
369 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
370 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
371 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
372 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLE")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
373 | query.prepare("INSERT INTO inventory_fermentables SET name=:name, type=:type, yield=:yield, color=:color, " |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
374 | "add_after_boil=:addafter, origin=:origin, supplier=:supplier, notes=:notes, coarse_fine_diff=:coarse, " |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
375 | "moisture=:moisture, diastatic_power=:diastatic, protein=:protein, dissolved_protein=:dissolved, " |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
376 | "max_in_batch=:maxinbatch, recommend_mash=:mash, added=:added, di_ph=:diph, " |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
377 | "acid_to_ph_57=:acidph, graintype=:graintype, uuid = :uuid"); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
378 | query.bindValue(":name", f->name); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
379 | query.bindValue(":type", f->type); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
380 | query.bindValue(":yield", QString("%1").arg(f->yield, 2, 'f', 1, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
381 | query.bindValue(":color", QString("%1").arg(Utils::srm_to_ebc(f->color), 1, 'f', 0, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
382 | query.bindValue(":addafter", f->add_after_boil ? 1:0); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
383 | query.bindValue(":origin", f->origin); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
384 | query.bindValue(":supplier", f->supplier); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
385 | query.bindValue(":notes", f->notes); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
386 | query.bindValue(":coarse", QString("%1").arg(f->coarse_fine_diff, 4, 'f', 3, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
387 | query.bindValue(":moisture", QString("%1").arg(f->moisture, 4, 'f', 3, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
388 | query.bindValue(":diastatic", Utils::kolbach_to_lintner(f->diastatic_power)); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
389 | query.bindValue(":protein", QString("%1").arg(f->protein, 4, 'f', 3, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
390 | query.bindValue(":dissolved", QString("%1").arg(f->dissolved_protein, 4, 'f', 3, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
391 | query.bindValue(":maxinbatch", QString("%1").arg(f->max_in_batch, 2, 'f', 1, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
392 | query.bindValue(":mash", f->recommend_mash ? 1:0); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
393 | query.bindValue(":added", f->added); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
394 | query.bindValue(":diph", QString("%1").arg(f->di_ph, 6, 'f', 5, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
395 | query.bindValue(":acidph", QString("%1").arg(f->acid_to_ph_57, 6, 'f', 5, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
396 | query.bindValue(":graintype", f->graintype); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
397 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
398 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
399 | if (query.lastError().isValid()) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
400 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
401 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
402 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
403 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
404 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
405 | } |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
406 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
407 | ((xml->name() == "VERSION") || (xml->name() == "DISPLAY_COST") || |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
408 | (xml->name() == "DISPLAY_COLOR") || (xml->name() == "INVENTORY") || |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
409 | (xml->name() == "COST") || (xml->name() == "ALWAYS_ON_STOCK") || |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
410 | (xml->name() == "PERCENTAGE") || (xml->name() == "ADJUST_TO_TOTAL_100") )) { |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
411 | // Ignore. |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
412 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
413 | f->name = xml->readElementText(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
414 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
415 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
416 | if (temp == "Sugar") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
417 | f->type = 1; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
418 | else if (temp == "Extract") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
419 | f->type = 2; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
420 | else if (temp == "Dry extract") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
421 | f->type = 3; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
422 | else if (temp == "Adjunct") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
423 | f->type = 4; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
424 | else |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
425 | f->type = 0; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
426 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
427 | f->origin = xml->readElementText(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
428 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUPPLIER")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
429 | f->supplier = xml->readElementText(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
430 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
431 | f->notes = xml->readElementText(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
432 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YIELD")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
433 | f->yield = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
434 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COARSE_FINE_DIFF")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
435 | f->coarse_fine_diff = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
436 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MOISTURE")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
437 | f->moisture = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
438 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DIASTATIC_POWER")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
439 | f->diastatic_power = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
440 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_IN_BATCH")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
441 | f->max_in_batch = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
442 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECOMMEND_MASH")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
443 | f->recommend_mash = (xml->readElementText() == "TRUE") ? true:false; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
444 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "GRAINTYPE")) { |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
445 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
446 | if (temp == "Roast") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
447 | f->graintype = 1; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
448 | else if (temp == "Crystal") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
449 | f->graintype = 2; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
450 | else if (temp == "Kilned") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
451 | f->graintype = 3; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
452 | else if (temp == "Sour Malt") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
453 | f->graintype = 4; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
454 | else if (temp == "Special") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
455 | f->graintype = 5; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
456 | else if (temp == "No malt") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
457 | f->graintype = 6; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
458 | else |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
459 | f->graintype = 0; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
460 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ADDED")) { |
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
461 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
462 | if (temp == "Boil") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
463 | f->added = 1; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
464 | else if (temp == "Fermentation") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
465 | f->added = 2; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
466 | else if (temp == "Lagering") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
467 | f->added = 3; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
468 | else if (temp == "Bottle") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
469 | f->added = 4; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
470 | else |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
471 | f->added = 0; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
472 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ADD_AFTER_BOIL")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
473 | f->add_after_boil = (xml->readElementText() == "TRUE") ? true:false; |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
474 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
475 | f->color = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
476 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PROTEIN")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
477 | f->protein = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
478 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DISSOLVED_PROTEIN")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
479 | f->dissolved_protein = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
480 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DI_pH")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
481 | f->di_ph = xml->readElementText().toDouble(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
482 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ACID_TO_pH_5.7")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
483 | f->acid_to_ph_57 = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
484 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
485 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
486 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
487 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
488 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
489 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
490 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
491 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOPS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
492 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
493 | * Hops |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
494 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
495 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
496 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
497 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
498 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOPS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
499 | qDebug() << "0 /HOPS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
500 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
501 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
502 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOP")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
503 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
504 | * Hop |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
505 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
506 | total++; |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
507 | Hops *h = new Hops(); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
508 | h->notes = h->origin = h->substitutes = ""; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
509 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
510 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
511 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
512 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
513 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOP")) { |
279 | 514 | query.prepare("INSERT INTO inventory_hops SET name=:name, alpha=:alpha, beta=:beta, " |
515 | "humulene=:humulene, caryophyllene=:cary, cohumulone=:cohumulone, myrcene=:myrcene, " | |
516 | "hsi=:hsi, type=:type, form=:form, notes=:notes, origin=:origin, substitutes=:substitutes, " | |
517 | "total_oil=:oil, uuid = :uuid"); | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
518 | query.bindValue(":name", h->name); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
519 | query.bindValue(":alpha", QString("%1").arg(h->alpha, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
520 | query.bindValue(":beta", QString("%1").arg(h->beta, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
521 | query.bindValue(":humulene", QString("%1").arg(h->humulene, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
522 | query.bindValue(":cary", QString("%1").arg(h->caryophyllene, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
523 | query.bindValue(":cohumulone", QString("%1").arg(h->cohumulone, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
524 | query.bindValue(":myrcene", QString("%1").arg(h->myrcene, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
525 | query.bindValue(":hsi", QString("%1").arg(h->hsi, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
526 | query.bindValue(":type", h->type); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
527 | query.bindValue(":form", h->form); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
528 | query.bindValue(":notes", h->notes); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
529 | query.bindValue(":origin", h->origin); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
530 | query.bindValue(":substitutes", h->substitutes); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
531 | query.bindValue(":oil", QString("%1").arg(h->total_oil, 2, 'f', 1, '0')); |
279 | 532 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
533 | query.exec(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
534 | if (query.lastError().isValid()) { |
279 | 535 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
536 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
537 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
538 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
539 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
540 | } |
279 | 541 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
542 | (xml->name() == "VERSION") || (xml->name() == "ALWAYS_ON_STOCK") || | |
543 | (xml->name() == "HARVEST_DATE") || (xml->name() == "DISPLAY_COST") || | |
544 | (xml->name() == "COST") || (xml->name() == "INVENTORY"))) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
545 | // Ignore. |
279 | 546 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
547 | h->name = xml->readElementText(); |
279 | 548 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
549 | h->origin = xml->readElementText(); |
279 | 550 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
551 | h->notes = xml->readElementText(); |
279 | 552 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FORM")) { |
553 | QString temp = xml->readElementText(); | |
554 | if (temp == "Plug") | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
555 | h->form = 1; |
279 | 556 | else if (temp == "Leaf") |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
557 | h->form = 2; |
279 | 558 | else if (temp == "Leaf wet") |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
559 | h->form = 3; |
279 | 560 | else if (temp == "Cryo") |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
561 | h->form = 4; |
279 | 562 | else |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
563 | h->form = 0; |
279 | 564 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ALPHA")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
565 | h->alpha = xml->readElementText().toDouble(); |
279 | 566 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { |
567 | QString temp = xml->readElementText(); | |
568 | if (temp == "Aroma") | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
569 | h->type = 1; |
279 | 570 | else if (temp == "Both") |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
571 | h->type = 2; |
279 | 572 | else |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
573 | h->type = 0; |
279 | 574 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE")) { |
575 | QString temp = xml->readElementText(); | |
576 | if (temp == "First wort") | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
577 | h->useat = 1; |
279 | 578 | else if (temp == "Boil") |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
579 | h->useat = 2; |
279 | 580 | else if (temp == "Aroma") |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
581 | h->useat = 3; |
279 | 582 | else if (temp == "Whirlpool") |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
583 | h->useat = 4; |
279 | 584 | else if (temp == "Dry hop") |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
585 | h->useat = 5; |
279 | 586 | else |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
587 | h->useat = 0; |
279 | 588 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BETA")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
589 | h->beta = xml->readElementText().toDouble(); |
279 | 590 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HSI")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
591 | h->hsi = xml->readElementText().toDouble(); |
279 | 592 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUBSTITUTES")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
593 | h->substitutes = xml->readElementText(); |
279 | 594 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HUMULENE")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
595 | h->humulene = xml->readElementText().toDouble(); |
279 | 596 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && |
597 | ((xml->name() == "CARYOPHYLLENE") || (xml->name() == "CAROPHYLLENE"))) { | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
598 | h->caryophyllene = xml->readElementText().toDouble(); |
279 | 599 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COHUMULONE")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
600 | h->cohumulone = xml->readElementText().toDouble(); |
279 | 601 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MYRCENE")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
602 | h->myrcene = xml->readElementText().toDouble(); |
279 | 603 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOTAL_OIL")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
604 | h->total_oil = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
605 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
606 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
607 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
608 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
609 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
610 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
611 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
612 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MISCS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
613 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
614 | * Miscs |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
615 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
616 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
617 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
618 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
619 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISCS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
620 | qDebug() << "0 /MISCS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
621 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
622 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
623 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MISC")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
624 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
625 | * Misc |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
626 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
627 | total++; |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
628 | Miscs *m = new Miscs(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
629 | m->name = m->use_for = m->notes = ""; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
630 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
631 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
632 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
633 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
634 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISC")) { |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
635 | query.prepare("INSERT INTO inventory_miscs SET name=:name, type=:type, use_use=:use, " |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
636 | "time=:time, amount_is_weight=:isweight, use_for=:usefor, notes=:notes, " |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
637 | "uuid = :uuid"); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
638 | query.bindValue(":name", m->name); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
639 | query.bindValue(":type", m->type); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
640 | query.bindValue(":use", m->use_use); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
641 | query.bindValue(":time", QString("%1").arg(m->time, 1, 'f', 0, '0')); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
642 | query.bindValue(":isweight", m->amount_is_weight ? 1:0); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
643 | query.bindValue(":usefor", m->use_for); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
644 | query.bindValue(":notes", m->notes); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
645 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
646 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
647 | if (query.lastError().isValid()) { |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
648 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
649 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
650 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
651 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
652 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
653 | } |
279 | 654 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
655 | (xml->name() == "VERSION") || (xml->name() == "DISPLAY_AMOUNT") || |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
656 | (xml->name() == "AMOUNT") || (xml->name() == "ALWAYS_ON_STOCK") || |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
657 | (xml->name() == "COST") || (xml->name() == "DISPLAY_COST") || |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
658 | (xml->name() == "INVENTORY") || (xml->name() == "DISPLAY_TIME") || |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
659 | (xml->name() == "FREE_FIELD") || (xml->name() == "FREE_FIELD_NAME") |
279 | 660 | )) { |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
661 | // Ignore. |
279 | 662 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
663 | m->name = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
664 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
665 | m->notes = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
666 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE_FOR")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
667 | m->use_for = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
668 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
669 | QString temp = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
670 | if (temp == "Herb") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
671 | m->type = 1; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
672 | else if (temp == "Flavor") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
673 | m->type = 2; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
674 | else if (temp == "Fining") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
675 | m->type = 3; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
676 | else if (temp == "Water agent") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
677 | m->type = 4; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
678 | else if (temp == "Yeast nutrient") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
679 | m->type = 5; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
680 | else if (temp == "Other") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
681 | m->type = 6; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
682 | else |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
683 | m->type = 0; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
684 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
685 | QString temp = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
686 | if (temp == "Mash") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
687 | m->use_use = 1; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
688 | else if (temp == "Boil") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
689 | m->use_use = 2; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
690 | else if (temp == "Primary") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
691 | m->use_use = 3; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
692 | else if (temp == "Secondary") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
693 | m->use_use = 4; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
694 | else if (temp == "Bottling") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
695 | m->use_use = 5; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
696 | else |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
697 | m->use_use = 0; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
698 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "AMOUNT_IS_WEIGHT")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
699 | m->amount_is_weight = (xml->readElementText() == "TRUE") ? true:false; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
700 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TIME")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
701 | m->time = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
702 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
703 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
704 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
705 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
706 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
707 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
708 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
709 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YEASTS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
710 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
711 | * Yeasts |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
712 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
713 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
714 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
715 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
716 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEASTS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
717 | qDebug() << "0 /YEASTS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
718 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
719 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
720 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YEAST")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
721 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
722 | * Yeast |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
723 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
724 | total++; |
285 | 725 | Yeasts *y = new Yeasts(); |
726 | y->laboratory = y->product_id = y->best_for = y->notes = y->short_desc = ""; | |
727 | y->max_reuse = 10; | |
728 | y->min_temperature = 18; | |
729 | y->max_temperature = 22; | |
730 | y->attenuation = 77; | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
731 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
732 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
733 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
734 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
735 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEAST")) { |
285 | 736 | query.prepare("INSERT INTO inventory_yeasts SET name=:name, type=:type, form=:form, " |
737 | "laboratory=:laboratory, product_id=:productid, min_temperature=:templo, max_temperature=:temphi, " | |
738 | "flocculation=:floc, attenuation=:att, notes=:notes, best_for=:bestfor, " | |
739 | "max_reuse=:reuse, short_desc='', uuid = :uuid"); | |
740 | query.bindValue(":name", y->name); | |
741 | query.bindValue(":type", y->type); | |
742 | query.bindValue(":form", y->form); | |
743 | query.bindValue(":laboratory", y->laboratory); | |
744 | query.bindValue(":productid", y->product_id); | |
745 | query.bindValue(":templo", QString("%1").arg(y->min_temperature, 2, 'f', 1, '0')); | |
746 | query.bindValue(":temphi", QString("%1").arg(y->max_temperature, 2, 'f', 1, '0')); | |
747 | query.bindValue(":floc", y->flocculation); | |
748 | query.bindValue(":att", QString("%1").arg(y->attenuation, 2, 'f', 1, '0')); | |
749 | query.bindValue(":notes", y->notes); | |
750 | query.bindValue(":bestfor", y->best_for); | |
751 | query.bindValue(":reuse", y->max_reuse); | |
752 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); | |
753 | query.exec(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
754 | if (query.lastError().isValid()) { |
285 | 755 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
756 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
757 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
758 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
759 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
760 | } |
285 | 761 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
762 | (xml->name() == "VERSION") || (xml->name() == "TIMES_CULTURED") || | |
763 | (xml->name() == "DISP_MIN_TEMP") || (xml->name() == "DISP_MAX_TEMP") || | |
764 | (xml->name() == "CULTURE_DATE") || (xml->name() == "STARTER_TYPE") || | |
765 | (xml->name() == "STARTER_MADE") || (xml->name() == "STARTER_VOLUME") || | |
766 | (xml->name() == "OG_STARTER") || (xml->name() == "TIME_AERATED") || | |
767 | (xml->name() == "ZINC_ADDED") || (xml->name() == "AMOUNT_ZINC") || | |
768 | (xml->name() == "AMOUNT_EXTRACT") || (xml->name() == "COST_EXTRACT") || | |
769 | (xml->name() == "ALWAYS_ON_STOCK") || (xml->name() == "DISPLAY_AMOUNT") || | |
770 | (xml->name() == "AMOUNT") || (xml->name() == "DISPLAY_AMOUNT") || | |
771 | (xml->name() == "AMOUNT_IS_WEIGHT") || (xml->name() == "ADD_TO_SECONDARY") || | |
772 | (xml->name() == "COST") || (xml->name() == "DISPLAY_COST") || | |
773 | (xml->name() == "TEMP") || (xml->name() == "INVENTORY"))) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
774 | // Ignore. |
285 | 775 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
776 | y->name = xml->readElementText(); | |
777 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LABORATORY")) { | |
778 | y->laboratory = xml->readElementText(); | |
779 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PRODUCT_ID")) { | |
780 | y->product_id = xml->readElementText(); | |
781 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
782 | y->notes = xml->readElementText(); | |
783 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BEST_FOR")) { | |
784 | y->best_for = xml->readElementText(); | |
785 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
786 | QString temp = xml->readElementText(); | |
787 | if (temp == "Ale") | |
788 | y->type = 1; | |
789 | else if (temp == "Wheat") | |
790 | y->type = 2; | |
791 | else if (temp == "Wine") | |
792 | y->type = 3; | |
793 | else if (temp == "Champagne") | |
794 | y->type = 4; | |
795 | else if (temp == "Brett") | |
796 | y->type = 5; | |
797 | else if (temp == "Kveik") | |
798 | y->type = 6; | |
799 | else if (temp == "Hybrid") | |
800 | y->type = 7; | |
801 | else | |
802 | y->type = 0; | |
803 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FORM")) { | |
804 | QString temp = xml->readElementText(); | |
805 | if (temp == "Dry") | |
806 | y->form = 1; | |
807 | else if (temp == "Slant") | |
808 | y->form = 2; | |
809 | else if (temp == "Culture") | |
810 | y->form = 3; | |
811 | else if (temp == "Frozen") | |
812 | y->form = 4; | |
813 | else if (temp == "Bottle") | |
814 | y->form = 5; | |
815 | else if (temp == "Dried") | |
816 | y->form = 6; | |
817 | else | |
818 | y->form = 0; | |
819 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FLOCCULATION")) { | |
820 | QString temp = xml->readElementText(); | |
821 | if (temp == "Medium") | |
822 | y->flocculation = 1; | |
823 | else if (temp == "High") | |
824 | y->flocculation = 1; | |
825 | else if (temp == "Very high") | |
826 | y->flocculation = 3; | |
827 | else | |
828 | y->flocculation = 0; | |
829 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MIN_TEMPERATURE")) { | |
830 | y->min_temperature = xml->readElementText().toDouble(); | |
831 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_TEMPERATURE")) { | |
832 | y->max_temperature = xml->readElementText().toDouble(); | |
833 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ATTENUATION")) { | |
834 | y->attenuation = xml->readElementText().toDouble(); | |
835 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_REUSE")) { | |
836 | y->max_reuse = xml->readElementText().toInt(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
837 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
838 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
839 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
840 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
841 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
842 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
843 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
844 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "WATERS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
845 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
846 | * Waters |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
847 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
848 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
849 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
850 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
851 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATERS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
852 | qDebug() << "0 /WATERS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
853 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
854 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
855 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "WATER")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
856 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
857 | * Water |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
858 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
859 | total++; |
286 | 860 | Waters *w = new Waters(); |
861 | w->notes = ""; | |
862 | w->ph = 7.0; | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
863 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
864 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
865 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
866 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
867 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATER")) { |
286 | 868 | query.prepare("INSERT INTO inventory_waters SET name=:name, unlimited_stock=:unlimited, calcium=:ca, " |
869 | "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, " | |
870 | "total_alkalinity=:alkalinity, nitrate=:no, uuid = :uuid"); | |
871 | query.bindValue(":name", w->name); | |
872 | query.bindValue(":unlimited", w->unlimited_stock ? 1:0); | |
873 | query.bindValue(":ca", QString("%1").arg(w->calcium, 4, 'f', 3, '0')); | |
874 | query.bindValue(":hco", QString("%1").arg(w->bicarbonate, 4, 'f', 3, '0')); | |
875 | query.bindValue(":so4", QString("%1").arg(w->sulfate, 4, 'f', 3, '0')); | |
876 | query.bindValue(":cl", QString("%1").arg(w->chloride, 4, 'f', 3, '0')); | |
877 | query.bindValue(":na", QString("%1").arg(w->sodium, 4, 'f', 3, '0')); | |
878 | query.bindValue(":mg", QString("%1").arg(w->magnesium, 4, 'f', 3, '0')); | |
879 | query.bindValue(":ph", QString("%1").arg(w->ph, 4, 'f', 3, '0')); | |
880 | query.bindValue(":notes", w->notes); | |
881 | query.bindValue(":alkalinity", QString("%1").arg(w->total_alkalinity, 4, 'f', 3, '0')); | |
882 | query.bindValue(":no", QString("%1").arg(w->nitrate, 4, 'f', 3, '0')); | |
883 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); | |
884 | query.exec(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
885 | if (query.lastError().isValid()) { |
286 | 886 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
887 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
888 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
889 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
890 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
891 | } |
286 | 892 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
893 | (xml->name() == "VERSION") || (xml->name() == "DEFAULT_WATER") || | |
894 | (xml->name() == "ALWAYS_ON_STOCK") || (xml->name() == "AMOUNT") || | |
895 | (xml->name() == "DISPLAY_AMOUNT"))) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
896 | // Ignore. |
286 | 897 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
898 | w->name = xml->readElementText(); | |
899 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
900 | w->notes = xml->readElementText(); | |
901 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "xUNLIMITED_STOCK")) { | |
902 | w->unlimited_stock = (xml->readElementText() == "TRUE") ? true:false; | |
903 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CALCIUM")) { | |
904 | w->calcium = xml->readElementText().toDouble(); | |
905 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BICARBONATE")) { | |
906 | w->bicarbonate = xml->readElementText().toDouble(); | |
907 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOTAL_ALKALINITY")) { | |
908 | w->total_alkalinity = xml->readElementText().toDouble(); | |
909 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SULFATE")) { | |
910 | w->sulfate = xml->readElementText().toDouble(); | |
911 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CHLORIDE")) { | |
912 | w->chloride = xml->readElementText().toDouble(); | |
913 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SODIUM")) { | |
914 | w->sodium = xml->readElementText().toDouble(); | |
915 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAGNESIUM")) { | |
916 | w->magnesium = xml->readElementText().toDouble(); | |
917 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PH")) { | |
918 | w->ph = xml->readElementText().toDouble(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
919 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
920 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
921 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
922 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
923 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
924 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
925 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
926 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECIPES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
927 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
928 | * Recipes |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
929 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
930 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
931 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
932 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
933 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "RECIPES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
934 | qDebug() << "0 /RECIPES"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
935 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
936 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
937 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECIPE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
938 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
939 | * Recipe |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
940 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
941 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
942 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
943 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
944 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
945 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
946 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "RECIPE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
947 | // query.exec(sql); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
948 | if (query.lastError().isValid()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
949 | // qWarning() << sql << query.lastError(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
950 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
951 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
952 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
953 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
954 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
955 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
956 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
957 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
958 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
959 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
960 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
961 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
962 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
963 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
964 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASHS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
965 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
966 | * Mashes |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
967 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
968 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
969 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
970 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
971 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASHS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
972 | qDebug() << "0 /MASHS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
973 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
974 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
975 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
976 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
977 | * Mash |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
978 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
979 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
980 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
981 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
982 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
983 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
984 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
985 | // query.exec(sql); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
986 | if (query.lastError().isValid()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
987 | // qWarning() << sql << query.lastError(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
988 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
989 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
990 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
991 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
992 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
993 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
994 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
995 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
996 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
997 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
998 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
999 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1000 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1001 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1002 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1003 | qDebug() << "Unknown level 0" << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1004 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1005 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1006 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1007 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1008 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1009 | log.append(QString(" total errors\n")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1010 | log.append(QString(" ----- ------\n")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1011 | log.append(QString("total %1 %2\n").arg(total, 3).arg(errors, 3)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1012 | ui->logEdit->setPlainText(log); |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1013 | qInfo() << "Import" << total << "records, " << total - errors << "ok, " << errors << "errors"; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1014 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1015 | ui->progressBar->setValue(100); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1016 | if (xml->hasError()) { |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
1017 | qWarning() << "XML error" << xml->error() << xml->errorString(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1018 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1019 | file.close(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1020 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1021 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1022 |