Sun, 12 Jun 2022 20:06:39 +0200
Added xml import hops
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++; |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
94 | Equipment *eq = new Equipment; |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
95 | eq->notes = ""; |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
96 | eq->top_up_kettle = eq->top_up_water = 0; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | 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
|
102 | 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
|
103 | "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
|
104 | "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
|
105 | "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
|
106 | "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
|
107 | "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
|
108 | "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
|
109 | "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
|
110 | "efficiency=:efficiency, uuid=:uuid"); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
111 | query.bindValue(":name", eq->name); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
112 | 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
|
113 | 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
|
114 | 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
|
115 | 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
|
116 | 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
|
117 | query.bindValue(":tun_material", eq->tun_material); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
118 | 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
|
119 | 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
|
120 | 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
|
121 | /* 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
|
122 | 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
|
123 | 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
|
124 | 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
|
125 | 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
|
126 | 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
|
127 | query.bindValue(":notes", eq->notes); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | 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
|
137 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | if (query.lastError().isValid()) { |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
139 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | 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
|
143 | delete eq; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | } |
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
|
146 | 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
|
147 | ((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
|
148 | (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
|
149 | (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
|
150 | (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
|
151 | (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
|
152 | (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
|
153 | (xml->name() == "ATTENUATION_FACTOR_CONSTANT"))) { |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | } 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
|
156 | eq->name = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | } 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
|
158 | eq->notes = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | } 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
|
160 | eq->boil_size = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | } 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
|
162 | eq->batch_size = xml->readElementText().toDouble(); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
163 | qDebug() << eq->batch_size; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | } 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
|
165 | eq->tun_volume = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | } 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
|
167 | eq->tun_weight = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | } 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
|
169 | eq->tun_specific_heat = xml->readElementText().toDouble(); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
170 | if (eq->tun_specific_heat == 0.22) |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
171 | eq->tun_material = 1; |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
172 | else if (eq->tun_specific_heat == 0.46) |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
173 | eq->tun_material = 2; |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
174 | else if (eq->tun_specific_heat == 0.092) |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
175 | eq->tun_material = 3; |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
176 | else |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
177 | eq->tun_material = 0; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
178 | } 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
|
179 | eq->tun_height = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | } 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
|
181 | eq->trub_chiller_loss = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | } 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
|
183 | eq->evap_rate = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
184 | } 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
|
185 | eq->boil_time = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | } 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
|
187 | 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
|
188 | } 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
|
189 | eq->top_up_kettle = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | } 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
|
191 | eq->hop_utilization = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | } 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
|
193 | eq->lauter_volume = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | } 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
|
195 | eq->lauter_height = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | } 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
|
197 | eq->lauter_deadspace = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | } 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
|
199 | eq->kettle_volume = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | } 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
|
201 | eq->kettle_height = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | } 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
|
203 | eq->mash_volume = xml->readElementText().toDouble(); |
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
204 | eq->mash_max = eq->mash_volume / 3; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | } 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
|
206 | eq->efficiency = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
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 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | } 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
|
215 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | * Styles |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "STYLES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | qDebug() << "0 /STYLES"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
227 | * Style |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | */ |
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 | Style *st = new Style; |
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->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
|
231 | st->style_guide = "BKG 2019"; |
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
|
232 | st->category_number = 0; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | 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
|
239 | 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
|
240 | "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
|
241 | "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
|
242 | "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
|
243 | "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
|
244 | "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
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | 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
|
250 | 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
|
251 | 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
|
252 | 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
|
253 | 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
|
254 | 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
|
255 | 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
|
256 | 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
|
257 | 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
|
258 | 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
|
259 | 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
|
260 | 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
|
261 | 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
|
262 | 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
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | 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
|
267 | 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
|
268 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
269 | 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
|
270 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
271 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
272 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
273 | 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
|
274 | delete st; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
275 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
276 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
277 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "VERSION")) || |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
278 | (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
|
279 | (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
|
280 | (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
|
281 | (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
|
282 | (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
|
283 | (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
|
284 | // Ignore. |
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() == "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
|
286 | st->name = 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")) { |
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 = xml->readElementText(); |
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() == "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
|
290 | st->category_number = xml->readElementText().toInt(); |
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_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
|
292 | st->style_letter = 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() == "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
|
294 | st->style_guide = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
295 | } 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
|
296 | 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
|
297 | 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
|
298 | 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
|
299 | 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
|
300 | 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
|
301 | 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
|
302 | 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
|
303 | 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
|
304 | 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
|
305 | 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
|
306 | 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
|
307 | 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
|
308 | st->type = 5; |
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() == "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
|
310 | st->notes = xml->readElementText(); |
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_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
|
312 | st->og_min = 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() == "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
|
314 | st->og_max = 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_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
|
316 | st->fg_min = 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() == "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
|
318 | st->fg_max = 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_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
|
320 | st->ibu_min = 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() == "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
|
322 | st->ibu_max = 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_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
|
324 | st->color_min = 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() == "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
|
326 | st->color_max = 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_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
|
328 | st->carb_min = 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() == "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
|
330 | st->carb_max = 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_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
|
332 | st->abv_min = 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() == "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
|
334 | st->abv_max = xml->readElementText().toDouble(); |
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() == "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
|
336 | st->profile = 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() == "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
|
338 | st->ingredients = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
339 | } 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
|
340 | st->examples = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
341 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
342 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
343 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
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 | } |
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 | } 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
|
349 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
350 | * Fermentables |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
351 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
352 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
353 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
354 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
355 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
356 | qDebug() << "0 /FERMENTABLES"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
357 | break; |
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 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "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 | * Fermentable |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
362 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
363 | total++; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
364 | Fermentables *f = new Fermentables; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
365 | f->f_supplier = f->f_origin = f->f_notes = ""; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
366 | f->f_yield = 80; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
367 | f->f_max_in_batch = 100; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
368 | f->f_recommend_mash = true; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
369 | f->f_protein = f->f_dissolved_protein = f->f_coarse_fine_diff = f->f_moisture = f->f_diastatic_power = 0; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
370 | f->f_di_ph = 5.7; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
371 | f->f_acid_to_ph_57 = 0; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
372 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
373 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
374 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
375 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
376 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLE")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
377 | 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
|
378 | "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
|
379 | "moisture=:moisture, diastatic_power=:diastatic, protein=:protein, dissolved_protein=:dissolved, " |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
380 | "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
|
381 | "acid_to_ph_57=:acidph, graintype=:graintype, uuid = :uuid"); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
382 | query.bindValue(":name", f->f_name); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
383 | query.bindValue(":type", f->f_type); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
384 | query.bindValue(":yield", QString("%1").arg(f->f_yield, 2, 'f', 1, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
385 | query.bindValue(":color", QString("%1").arg(Utils::srm_to_ebc(f->f_color), 1, 'f', 0, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
386 | query.bindValue(":addafter", f->f_add_after_boil ? 1:0); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
387 | query.bindValue(":origin", f->f_origin); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
388 | query.bindValue(":supplier", f->f_supplier); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
389 | query.bindValue(":notes", f->f_notes); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
390 | query.bindValue(":coarse", QString("%1").arg(f->f_coarse_fine_diff, 4, 'f', 3, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
391 | query.bindValue(":moisture", QString("%1").arg(f->f_moisture, 4, 'f', 3, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
392 | query.bindValue(":diastatic", Utils::kolbach_to_lintner(f->f_diastatic_power)); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
393 | query.bindValue(":protein", QString("%1").arg(f->f_protein, 4, 'f', 3, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
394 | query.bindValue(":dissolved", QString("%1").arg(f->f_dissolved_protein, 4, 'f', 3, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
395 | query.bindValue(":maxinbatch", QString("%1").arg(f->f_max_in_batch, 2, 'f', 1, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
396 | query.bindValue(":mash", f->f_recommend_mash ? 1:0); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
397 | query.bindValue(":added", f->f_added); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
398 | query.bindValue(":diph", QString("%1").arg(f->f_di_ph, 6, 'f', 5, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
399 | query.bindValue(":acidph", QString("%1").arg(f->f_acid_to_ph_57, 6, 'f', 5, '0')); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
400 | query.bindValue(":graintype", f->f_graintype); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
401 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
402 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
403 | if (query.lastError().isValid()) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
404 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
405 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
406 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
407 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
408 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
409 | } |
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 | 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
|
411 | ((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
|
412 | (xml->name() == "DISPLAY_COLOR") || (xml->name() == "INVENTORY") || |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
413 | (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
|
414 | (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
|
415 | // 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
|
416 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
417 | f->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
|
418 | } 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
|
419 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
420 | if (temp == "Sugar") |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
421 | f->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
|
422 | else if (temp == "Extract") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
423 | f->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
|
424 | else if (temp == "Dry extract") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
425 | f->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
|
426 | else if (temp == "Adjunct") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
427 | f->f_type = 4; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
428 | else |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
429 | f->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
|
430 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
431 | f->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
|
432 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUPPLIER")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
433 | f->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
|
434 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
435 | f->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
|
436 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YIELD")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
437 | f->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
|
438 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COARSE_FINE_DIFF")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
439 | f->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
|
440 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MOISTURE")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
441 | f->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
|
442 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DIASTATIC_POWER")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
443 | f->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
|
444 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_IN_BATCH")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
445 | f->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
|
446 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECOMMEND_MASH")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
447 | f->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
|
448 | } 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
|
449 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
450 | if (temp == "Roast") |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
451 | f->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
|
452 | else if (temp == "Crystal") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
453 | f->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
|
454 | else if (temp == "Kilned") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
455 | f->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
|
456 | else if (temp == "Sour Malt") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
457 | f->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
|
458 | else if (temp == "Special") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
459 | f->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
|
460 | else if (temp == "No malt") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
461 | f->f_graintype = 6; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
462 | else |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
463 | f->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
|
464 | } 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
|
465 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
466 | if (temp == "Boil") |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
467 | f->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
|
468 | else if (temp == "Fermentation") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
469 | f->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
|
470 | else if (temp == "Lagering") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
471 | f->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
|
472 | else if (temp == "Bottle") |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
473 | f->f_added = 4; |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
474 | else |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
475 | f->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
|
476 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ADD_AFTER_BOIL")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
477 | f->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
|
478 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
479 | f->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
|
480 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PROTEIN")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
481 | f->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
|
482 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DISSOLVED_PROTEIN")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
483 | f->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
|
484 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DI_pH")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
485 | f->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
|
486 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ACID_TO_pH_5.7")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
487 | f->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
|
488 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
489 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
490 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
491 | } |
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 | } |
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 | } 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
|
496 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
497 | * Hops |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
498 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
499 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
500 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
501 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
502 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOPS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
503 | qDebug() << "0 /HOPS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
504 | break; |
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 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOP")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
507 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
508 | * Hop |
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 | total++; |
279 | 511 | Hops *h = new Hops; |
512 | h->h_inventory = h->h_cost = 0; | |
513 | h->h_notes = h->h_origin = h->h_substitutes = ""; | |
514 | h->h_beta = h->h_hsi = h->h_humulene = h->h_caryophyllene = h->h_cohumulone = h->h_myrcene = h->h_total_oil = 0; | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
515 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
516 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
517 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
518 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
519 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOP")) { |
279 | 520 | query.prepare("INSERT INTO inventory_hops SET name=:name, alpha=:alpha, beta=:beta, " |
521 | "humulene=:humulene, caryophyllene=:cary, cohumulone=:cohumulone, myrcene=:myrcene, " | |
522 | "hsi=:hsi, type=:type, form=:form, notes=:notes, origin=:origin, substitutes=:substitutes, " | |
523 | "total_oil=:oil, uuid = :uuid"); | |
524 | query.bindValue(":name", h->h_name); | |
525 | query.bindValue(":alpha", QString("%1").arg(h->h_alpha, 2, 'f', 1, '0')); | |
526 | query.bindValue(":beta", QString("%1").arg(h->h_beta, 2, 'f', 1, '0')); | |
527 | query.bindValue(":humulene", QString("%1").arg(h->h_humulene, 2, 'f', 1, '0')); | |
528 | query.bindValue(":cary", QString("%1").arg(h->h_caryophyllene, 2, 'f', 1, '0')); | |
529 | query.bindValue(":cohumulone", QString("%1").arg(h->h_cohumulone, 2, 'f', 1, '0')); | |
530 | query.bindValue(":myrcene", QString("%1").arg(h->h_myrcene, 2, 'f', 1, '0')); | |
531 | query.bindValue(":hsi", QString("%1").arg(h->h_hsi, 2, 'f', 1, '0')); | |
532 | query.bindValue(":type", h->h_type); | |
533 | query.bindValue(":form", h->h_form); | |
534 | query.bindValue(":notes", h->h_notes); | |
535 | query.bindValue(":origin", h->h_origin); | |
536 | query.bindValue(":substitutes", h->h_substitutes); | |
537 | query.bindValue(":oil", QString("%1").arg(h->h_total_oil, 2, 'f', 1, '0')); | |
538 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); | |
539 | query.exec(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
540 | if (query.lastError().isValid()) { |
279 | 541 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
542 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
543 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
544 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
545 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
546 | } |
279 | 547 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
548 | (xml->name() == "VERSION") || (xml->name() == "ALWAYS_ON_STOCK") || | |
549 | (xml->name() == "HARVEST_DATE") || (xml->name() == "DISPLAY_COST") || | |
550 | (xml->name() == "COST") || (xml->name() == "INVENTORY"))) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
551 | // Ignore. |
279 | 552 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
553 | h->h_name = xml->readElementText(); | |
554 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { | |
555 | h->h_origin = xml->readElementText(); | |
556 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
557 | h->h_notes = xml->readElementText(); | |
558 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FORM")) { | |
559 | QString temp = xml->readElementText(); | |
560 | if (temp == "Plug") | |
561 | h->h_form = 1; | |
562 | else if (temp == "Leaf") | |
563 | h->h_form = 2; | |
564 | else if (temp == "Leaf wet") | |
565 | h->h_form = 3; | |
566 | else if (temp == "Cryo") | |
567 | h->h_form = 4; | |
568 | else | |
569 | h->h_form = 0; | |
570 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ALPHA")) { | |
571 | h->h_alpha = xml->readElementText().toDouble(); | |
572 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
573 | QString temp = xml->readElementText(); | |
574 | if (temp == "Aroma") | |
575 | h->h_type = 1; | |
576 | else if (temp == "Both") | |
577 | h->h_type = 2; | |
578 | else | |
579 | h->h_type = 0; | |
580 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE")) { | |
581 | QString temp = xml->readElementText(); | |
582 | if (temp == "First wort") | |
583 | h->h_useat = 1; | |
584 | else if (temp == "Boil") | |
585 | h->h_useat = 2; | |
586 | else if (temp == "Aroma") | |
587 | h->h_useat = 3; | |
588 | else if (temp == "Whirlpool") | |
589 | h->h_useat = 4; | |
590 | else if (temp == "Dry hop") | |
591 | h->h_useat = 5; | |
592 | else | |
593 | h->h_useat = 0; | |
594 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BETA")) { | |
595 | h->h_beta = xml->readElementText().toDouble(); | |
596 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HSI")) { | |
597 | h->h_hsi = xml->readElementText().toDouble(); | |
598 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUBSTITUTES")) { | |
599 | h->h_substitutes = xml->readElementText(); | |
600 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HUMULENE")) { | |
601 | h->h_humulene = xml->readElementText().toDouble(); | |
602 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && | |
603 | ((xml->name() == "CARYOPHYLLENE") || (xml->name() == "CAROPHYLLENE"))) { | |
604 | h->h_caryophyllene = xml->readElementText().toDouble(); | |
605 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COHUMULONE")) { | |
606 | h->h_cohumulone = xml->readElementText().toDouble(); | |
607 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MYRCENE")) { | |
608 | h->h_myrcene = xml->readElementText().toDouble(); | |
609 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOTAL_OIL")) { | |
610 | h->h_total_oil = xml->readElementText().toDouble(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
611 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
612 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
613 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
614 | } |
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 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
617 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
618 | } 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
|
619 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
620 | * Miscs |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
621 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
622 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
623 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
624 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
625 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISCS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
626 | qDebug() << "0 /MISCS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
627 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
628 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
629 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MISC")) { |
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 | * Misc |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
632 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
633 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
634 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
635 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
636 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
637 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
638 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISC")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
639 | // query.exec(sql); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
640 | if (query.lastError().isValid()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
641 | // qWarning() << sql << query.lastError(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
642 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
643 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
644 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
645 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
646 | } |
279 | 647 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
648 | (xml->name() == "VERSION") | |
649 | )) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
650 | // Ignore. |
279 | 651 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
652 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
653 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
654 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
655 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
656 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
657 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
658 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
659 | } 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
|
660 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
661 | * Yeasts |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
662 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
663 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
664 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
665 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
666 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEASTS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
667 | qDebug() << "0 /YEASTS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
668 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
669 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
670 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YEAST")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
671 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
672 | * Yeast |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
673 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
674 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
675 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
676 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
677 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
678 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
679 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEAST")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
680 | // query.exec(sql); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
681 | if (query.lastError().isValid()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
682 | // qWarning() << sql << query.lastError(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
683 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
684 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
685 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
686 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
687 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
688 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
689 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
690 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
691 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
692 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
693 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
694 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
695 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
696 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
697 | } 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
|
698 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
699 | * Waters |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
700 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
701 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
702 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
703 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
704 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATERS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
705 | qDebug() << "0 /WATERS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
706 | break; |
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 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "WATER")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
709 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
710 | * Water |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
711 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
712 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
713 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
714 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
715 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
716 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
717 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATER")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
718 | // query.exec(sql); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
719 | if (query.lastError().isValid()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
720 | // qWarning() << sql << query.lastError(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
721 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
722 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
723 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
724 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
725 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
726 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
727 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
728 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
729 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
730 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
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 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
733 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
734 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
735 | } 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
|
736 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
737 | * Recipes |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
738 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
739 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
740 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
741 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
742 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "RECIPES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
743 | qDebug() << "0 /RECIPES"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
744 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
745 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
746 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECIPE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
747 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
748 | * Recipe |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
749 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
750 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
751 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
752 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
753 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
754 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
755 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "RECIPE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
756 | // query.exec(sql); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
757 | if (query.lastError().isValid()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
758 | // qWarning() << sql << query.lastError(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
759 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
760 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
761 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
762 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
763 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
764 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
765 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
766 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
767 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
768 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
769 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
770 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
771 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
772 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
773 | } 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
|
774 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
775 | * Mashes |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
776 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
777 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
778 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
779 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
780 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASHS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
781 | qDebug() << "0 /MASHS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
782 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
783 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
784 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
785 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
786 | * Mash |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
787 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
788 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
789 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
790 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
791 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
792 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
793 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
794 | // query.exec(sql); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
795 | if (query.lastError().isValid()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
796 | // qWarning() << sql << query.lastError(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
797 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
798 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
799 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
800 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
801 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
802 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
803 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
804 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
805 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
806 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
807 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
808 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
809 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
810 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
811 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
812 | qDebug() << "Unknown level 0" << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
813 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
814 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
815 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
816 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
817 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
818 | log.append(QString(" total errors\n")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
819 | log.append(QString(" ----- ------\n")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
820 | 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
|
821 | ui->logEdit->setPlainText(log); |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
822 | 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
|
823 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
824 | ui->progressBar->setValue(100); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
825 | 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
|
826 | qWarning() << "XML error" << xml->error() << xml->errorString(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
827 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
828 | file.close(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
829 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
830 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
831 |