Thu, 18 Aug 2022 20:34:15 +0200
Init est_carb field for new products.
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" |
289 | 21 | #include "database/db_recipe.h" |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | #include "MainWindow.h" |
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 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | 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
|
26 | { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | qDebug() << "ImportXML start"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | ui->setupUi(this); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | WindowTitle(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | ui->progressBar->setValue(0); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | connect(ui->quitButton, SIGNAL(clicked()), parent, SLOT(fromImportXML())); |
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 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | ImportXML::~ImportXML() |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | qDebug() << "ImportXML done"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | delete ui; |
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 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | void ImportXML::WindowTitle() |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | QString txt = QString(tr("BMSapp - Import XML")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | setWindowTitle(txt); |
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 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | void ImportXML::on_openButton_clicked() |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | QSqlQuery query; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
52 | QString log; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | int total = 0, errors = 0; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | 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
|
56 | if (fileName == 0) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | 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
|
58 | return; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | ui->fileEdit->setText(fileName); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | QFile file(fileName); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | qint64 fsize = file.size(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | log = "Import XML file `" + fileName + "`\n\n"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | qInfo() << "Import XML" << fileName << "length" << fsize << "bytes"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | file.open(QIODevice::ReadOnly); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | QXmlStreamReader *xml = new QXmlStreamReader(&file); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | 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
|
77 | qDebug() << xml->documentVersion() << xml->documentEncoding(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | // Just skip |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | } 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
|
80 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | * Equipments |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "EQUIPMENTS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | qDebug() << "0 /EQUIPMENTS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EQUIPMENT")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | * Equipment |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | total++; |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
95 | Equipment *eq = new Equipment(); |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
96 | eq->notes = ""; |
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 | */ |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
229 | Style *st = new Style(); |
276
7316a419334d
Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents:
275
diff
changeset
|
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"; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | total++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | 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
|
238 | 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
|
239 | "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
|
240 | "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
|
241 | "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
|
242 | "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
|
243 | "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
|
244 | 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
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | 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
|
250 | 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
|
251 | 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
|
252 | 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
|
253 | 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
|
254 | 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
|
255 | 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
|
256 | 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
|
257 | 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
|
258 | 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
|
259 | 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
|
260 | 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
|
261 | 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
|
262 | 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
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | 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
|
267 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
268 | 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
|
269 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
270 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
271 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
272 | 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
|
273 | delete st; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
274 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
275 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
276 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "VERSION")) || |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
277 | (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
|
278 | (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
|
279 | (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
|
280 | (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
|
281 | (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
|
282 | (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
|
283 | // Ignore. |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
284 | } 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
|
285 | st->name = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
286 | } 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
|
287 | st->category = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
288 | } 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
|
289 | st->category_number = xml->readElementText().toInt(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
290 | } 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
|
291 | st->style_letter = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
292 | } 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
|
293 | st->style_guide = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
294 | } 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
|
295 | 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
|
296 | 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
|
297 | 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
|
298 | 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
|
299 | 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
|
300 | 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
|
301 | 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
|
302 | 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
|
303 | 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
|
304 | 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
|
305 | 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
|
306 | 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
|
307 | st->type = 5; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
308 | } 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
|
309 | st->notes = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
310 | } 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
|
311 | st->og_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
312 | } 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
|
313 | st->og_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
314 | } 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
|
315 | st->fg_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
316 | } 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
|
317 | st->fg_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
318 | } 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
|
319 | st->ibu_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
320 | } 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
|
321 | st->ibu_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
322 | } 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
|
323 | st->color_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
324 | } 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
|
325 | st->color_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
326 | } 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
|
327 | st->carb_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
328 | } 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
|
329 | st->carb_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
330 | } 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
|
331 | st->abv_min = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
332 | } 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
|
333 | st->abv_max = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
334 | } 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
|
335 | st->profile = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
336 | } 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
|
337 | st->ingredients = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
338 | } 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
|
339 | st->examples = xml->readElementText(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
340 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
341 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
342 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
343 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
344 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
345 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
346 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
347 | } 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
|
348 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
349 | * Fermentables |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
350 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
351 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
352 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
353 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
354 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
355 | qDebug() << "0 /FERMENTABLES"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
356 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
357 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
358 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FERMENTABLE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
359 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
360 | * Fermentable |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
361 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
362 | total++; |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
363 | Fermentables *f = new Fermentables(); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
364 | f->supplier = f->origin = f->notes = ""; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
365 | f->yield = 80; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
366 | f->max_in_batch = 100; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
367 | f->recommend_mash = true; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
368 | f->di_ph = 5.7; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
369 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
370 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
371 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
372 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
373 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLE")) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
374 | 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
|
375 | "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
|
376 | "moisture=:moisture, diastatic_power=:diastatic, protein=:protein, dissolved_protein=:dissolved, " |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
377 | "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
|
378 | "acid_to_ph_57=:acidph, graintype=:graintype, uuid = :uuid"); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
379 | query.bindValue(":name", f->name); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
380 | query.bindValue(":type", f->type); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
381 | query.bindValue(":yield", QString("%1").arg(f->yield, 2, 'f', 1, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
382 | query.bindValue(":color", QString("%1").arg(Utils::srm_to_ebc(f->color), 1, 'f', 0, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
383 | query.bindValue(":addafter", f->add_after_boil ? 1:0); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
384 | query.bindValue(":origin", f->origin); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
385 | query.bindValue(":supplier", f->supplier); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
386 | query.bindValue(":notes", f->notes); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
387 | query.bindValue(":coarse", QString("%1").arg(f->coarse_fine_diff, 4, 'f', 3, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
388 | query.bindValue(":moisture", QString("%1").arg(f->moisture, 4, 'f', 3, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
389 | query.bindValue(":diastatic", Utils::kolbach_to_lintner(f->diastatic_power)); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
390 | query.bindValue(":protein", QString("%1").arg(f->protein, 4, 'f', 3, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
391 | query.bindValue(":dissolved", QString("%1").arg(f->dissolved_protein, 4, 'f', 3, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
392 | query.bindValue(":maxinbatch", QString("%1").arg(f->max_in_batch, 2, 'f', 1, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
393 | query.bindValue(":mash", f->recommend_mash ? 1:0); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
394 | query.bindValue(":added", f->added); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
395 | query.bindValue(":diph", QString("%1").arg(f->di_ph, 6, 'f', 5, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
396 | query.bindValue(":acidph", QString("%1").arg(f->acid_to_ph_57, 6, 'f', 5, '0')); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
397 | query.bindValue(":graintype", f->graintype); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
398 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
399 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
400 | if (query.lastError().isValid()) { |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
401 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
402 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
403 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
404 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
405 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
406 | } |
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
|
407 | 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
|
408 | ((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
|
409 | (xml->name() == "DISPLAY_COLOR") || (xml->name() == "INVENTORY") || |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
410 | (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
|
411 | (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
|
412 | // 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
|
413 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
414 | 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
|
415 | } 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
|
416 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
417 | if (temp == "Sugar") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
418 | 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
|
419 | else if (temp == "Extract") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
420 | 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
|
421 | else if (temp == "Dry extract") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
422 | 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
|
423 | else if (temp == "Adjunct") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
424 | f->type = 4; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
425 | else |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
426 | 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
|
427 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
428 | 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
|
429 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUPPLIER")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
430 | 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
|
431 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
432 | 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
|
433 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YIELD")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
434 | 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
|
435 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COARSE_FINE_DIFF")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
436 | 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
|
437 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MOISTURE")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
438 | 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
|
439 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DIASTATIC_POWER")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
440 | 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
|
441 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_IN_BATCH")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
442 | 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
|
443 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECOMMEND_MASH")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
444 | 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
|
445 | } 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
|
446 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
447 | if (temp == "Roast") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
448 | 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
|
449 | else if (temp == "Crystal") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
450 | 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
|
451 | else if (temp == "Kilned") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
452 | 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
|
453 | else if (temp == "Sour Malt") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
454 | 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
|
455 | else if (temp == "Special") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
456 | 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
|
457 | else if (temp == "No malt") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
458 | f->graintype = 6; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
459 | else |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
460 | 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
|
461 | } 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
|
462 | QString temp = xml->readElementText(); |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
463 | if (temp == "Boil") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
464 | 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
|
465 | else if (temp == "Fermentation") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
466 | 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
|
467 | else if (temp == "Lagering") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
468 | 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
|
469 | else if (temp == "Bottle") |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
470 | f->added = 4; |
278
ed562a2a4ca4
Finished import fermentables
Michiel Broek <mbroek@mbse.eu>
parents:
277
diff
changeset
|
471 | else |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
472 | 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
|
473 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ADD_AFTER_BOIL")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
474 | 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
|
475 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
476 | 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
|
477 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PROTEIN")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
478 | 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
|
479 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DISSOLVED_PROTEIN")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
480 | 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
|
481 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DI_pH")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
482 | 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
|
483 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ACID_TO_pH_5.7")) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
282
diff
changeset
|
484 | 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
|
485 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
486 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
487 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
488 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
489 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
490 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
491 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
492 | } 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
|
493 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
494 | * Hops |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
495 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
496 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
497 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
498 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
499 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOPS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
500 | qDebug() << "0 /HOPS"; |
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 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
503 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOP")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
504 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
505 | * Hop |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
506 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
507 | total++; |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
508 | Hops *h = new Hops(); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
509 | h->notes = h->origin = h->substitutes = ""; |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
510 | h->bu_factor = 1.0; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
511 | h->utilisation = my_ut_pellet; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
512 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
513 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
514 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
515 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
516 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOP")) { |
279 | 517 | query.prepare("INSERT INTO inventory_hops SET name=:name, alpha=:alpha, beta=:beta, " |
518 | "humulene=:humulene, caryophyllene=:cary, cohumulone=:cohumulone, myrcene=:myrcene, " | |
519 | "hsi=:hsi, type=:type, form=:form, notes=:notes, origin=:origin, substitutes=:substitutes, " | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
520 | "total_oil=:oil, utilisation=:utilisation, bu_factor=:bu_factor, uuid = :uuid"); |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
521 | query.bindValue(":name", h->name); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
522 | query.bindValue(":alpha", QString("%1").arg(h->alpha, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
523 | query.bindValue(":beta", QString("%1").arg(h->beta, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
524 | query.bindValue(":humulene", QString("%1").arg(h->humulene, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
525 | query.bindValue(":cary", QString("%1").arg(h->caryophyllene, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
526 | query.bindValue(":cohumulone", QString("%1").arg(h->cohumulone, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
527 | query.bindValue(":myrcene", QString("%1").arg(h->myrcene, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
528 | query.bindValue(":hsi", QString("%1").arg(h->hsi, 2, 'f', 1, '0')); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
529 | query.bindValue(":type", h->type); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
530 | query.bindValue(":form", h->form); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
531 | query.bindValue(":notes", h->notes); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
532 | query.bindValue(":origin", h->origin); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
533 | query.bindValue(":substitutes", h->substitutes); |
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
534 | query.bindValue(":oil", QString("%1").arg(h->total_oil, 2, 'f', 1, '0')); |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
535 | query.bindValue(":utilisation", QString("%1").arg(h->utilisation, 2, 'f', 1, '0')); |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
536 | query.bindValue(":bu_factor", QString("%1").arg(h->bu_factor, 2, 'f', 1, '0')); |
279 | 537 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
538 | query.exec(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
539 | if (query.lastError().isValid()) { |
279 | 540 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
541 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
542 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
543 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
544 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
545 | } |
279 | 546 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
547 | (xml->name() == "VERSION") || (xml->name() == "ALWAYS_ON_STOCK") || | |
548 | (xml->name() == "HARVEST_DATE") || (xml->name() == "DISPLAY_COST") || | |
549 | (xml->name() == "COST") || (xml->name() == "INVENTORY"))) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
550 | // Ignore. |
279 | 551 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
552 | h->name = xml->readElementText(); |
279 | 553 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
554 | h->origin = xml->readElementText(); |
279 | 555 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
556 | h->notes = xml->readElementText(); |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
557 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
558 | ((xml->name() == "FORM") || (xml->name() == "BMS_FORM"))) { |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
559 | QString temp = xml->readElementText(); |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
560 | if (temp == "Plug") |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
561 | h->form = HOP_FORMS_PLUG; |
279 | 562 | else if (temp == "Leaf") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
563 | h->form = HOP_FORMS_LEAF; |
279 | 564 | else if (temp == "Leaf wet") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
565 | h->form = HOP_FORMS_LEAF_WET; |
279 | 566 | else if (temp == "Cryo") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
567 | h->form = HOP_FORMS_CRYO; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
568 | else if (temp == "CO2 extract") |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
569 | h->form = HOP_FORMS_CO2EXTRACT; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
570 | else if (temp == "Iso extract") |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
571 | h->form = HOP_FORMS_ISOEXTRACT; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
572 | else |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
573 | h->form = HOP_FORMS_PELLET; |
279 | 574 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ALPHA")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
575 | h->alpha = xml->readElementText().toDouble(); |
279 | 576 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { |
577 | QString temp = xml->readElementText(); | |
578 | if (temp == "Aroma") | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
579 | h->type = HOP_TYPE_AROMA; |
279 | 580 | else if (temp == "Both") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
581 | h->type = HOP_TYPE_BOTH; |
279 | 582 | else |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
583 | h->type = HOP_TYPE_BITTERING; |
279 | 584 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE")) { |
585 | QString temp = xml->readElementText(); | |
586 | if (temp == "First wort") | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
587 | h->useat = HOP_USEAT_FWH; |
279 | 588 | else if (temp == "Boil") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
589 | h->useat = HOP_USEAT_BOIL; |
279 | 590 | else if (temp == "Aroma") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
591 | h->useat = HOP_USEAT_AROMA; |
279 | 592 | else if (temp == "Whirlpool") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
593 | h->useat = HOP_USEAT_WHIRLPOOL; |
279 | 594 | else if (temp == "Dry hop") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
595 | h->useat = HOP_USEAT_DRY_HOP; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
596 | else if (temp == "Bottling") |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
597 | h->useat = HOP_USEAT_BOTTLING; |
279 | 598 | else |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
599 | h->useat = 0; |
279 | 600 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BETA")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
601 | h->beta = xml->readElementText().toDouble(); |
279 | 602 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HSI")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
603 | h->hsi = xml->readElementText().toDouble(); |
279 | 604 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUBSTITUTES")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
605 | h->substitutes = xml->readElementText(); |
279 | 606 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HUMULENE")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
607 | h->humulene = xml->readElementText().toDouble(); |
279 | 608 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && |
609 | ((xml->name() == "CARYOPHYLLENE") || (xml->name() == "CAROPHYLLENE"))) { | |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
610 | h->caryophyllene = xml->readElementText().toDouble(); |
279 | 611 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COHUMULONE")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
612 | h->cohumulone = xml->readElementText().toDouble(); |
279 | 613 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MYRCENE")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
614 | h->myrcene = xml->readElementText().toDouble(); |
279 | 615 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOTAL_OIL")) { |
282
d1d208a857b0
Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
281
diff
changeset
|
616 | h->total_oil = xml->readElementText().toDouble(); |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
617 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BMS_UTILISATION")) { |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
618 | h->utilisation = xml->readElementText().toDouble(); |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
619 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BMS_UT_FACTOR")) { |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
620 | h->bu_factor = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
621 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
622 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
623 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
624 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
625 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
626 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
627 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
628 | } 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
|
629 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
630 | * Miscs |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
631 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
632 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
633 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
634 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
635 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISCS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
636 | qDebug() << "0 /MISCS"; |
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 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
639 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MISC")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
640 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
641 | * Misc |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
642 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
643 | total++; |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
644 | Miscs *m = new Miscs(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
645 | m->name = m->use_for = m->notes = ""; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
646 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
647 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
648 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
649 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
650 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISC")) { |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
651 | query.prepare("INSERT INTO inventory_miscs SET name=:name, type=:type, use_use=:use, " |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
652 | "time=:time, amount_is_weight=:isweight, use_for=:usefor, notes=:notes, " |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
653 | "uuid = :uuid"); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
654 | query.bindValue(":name", m->name); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
655 | query.bindValue(":type", m->type); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
656 | query.bindValue(":use", m->use_use); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
657 | query.bindValue(":time", QString("%1").arg(m->time, 1, 'f', 0, '0')); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
658 | query.bindValue(":isweight", m->amount_is_weight ? 1:0); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
659 | query.bindValue(":usefor", m->use_for); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
660 | query.bindValue(":notes", m->notes); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
661 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
662 | query.exec(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
663 | if (query.lastError().isValid()) { |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
664 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
665 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
666 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
667 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
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 | } |
279 | 670 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
671 | (xml->name() == "VERSION") || (xml->name() == "DISPLAY_AMOUNT") || |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
672 | (xml->name() == "AMOUNT") || (xml->name() == "ALWAYS_ON_STOCK") || |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
673 | (xml->name() == "COST") || (xml->name() == "DISPLAY_COST") || |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
674 | (xml->name() == "INVENTORY") || (xml->name() == "DISPLAY_TIME") || |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
675 | (xml->name() == "FREE_FIELD") || (xml->name() == "FREE_FIELD_NAME") |
279 | 676 | )) { |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
677 | // Ignore. |
279 | 678 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
281
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
679 | m->name = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
680 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
681 | m->notes = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
682 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE_FOR")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
683 | m->use_for = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
684 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
685 | QString temp = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
686 | if (temp == "Herb") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
687 | m->type = 1; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
688 | else if (temp == "Flavor") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
689 | m->type = 2; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
690 | else if (temp == "Fining") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
691 | m->type = 3; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
692 | else if (temp == "Water agent") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
693 | m->type = 4; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
694 | else if (temp == "Yeast nutrient") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
695 | m->type = 5; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
696 | else if (temp == "Other") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
697 | m->type = 6; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
698 | else |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
699 | m->type = 0; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
700 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
701 | QString temp = xml->readElementText(); |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
702 | if (temp == "Mash") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
703 | m->use_use = 1; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
704 | else if (temp == "Boil") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
705 | m->use_use = 2; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
706 | else if (temp == "Primary") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
707 | m->use_use = 3; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
708 | else if (temp == "Secondary") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
709 | m->use_use = 4; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
710 | else if (temp == "Bottling") |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
711 | m->use_use = 5; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
712 | else |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
713 | m->use_use = 0; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
714 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "AMOUNT_IS_WEIGHT")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
715 | m->amount_is_weight = (xml->readElementText() == "TRUE") ? true:false; |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
716 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TIME")) { |
af3dac6ff6c3
Fixed init of import record. Added miscs import
Michiel Broek <mbroek@mbse.eu>
parents:
279
diff
changeset
|
717 | m->time = xml->readElementText().toDouble(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
718 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
719 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
720 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
721 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
722 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
723 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
724 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
725 | } 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
|
726 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
727 | * Yeasts |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
728 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
729 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
730 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
731 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
732 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEASTS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
733 | qDebug() << "0 /YEASTS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
734 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
735 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
736 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YEAST")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
737 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
738 | * Yeast |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
739 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
740 | total++; |
285 | 741 | Yeasts *y = new Yeasts(); |
742 | y->laboratory = y->product_id = y->best_for = y->notes = y->short_desc = ""; | |
743 | y->max_reuse = 10; | |
744 | y->min_temperature = 18; | |
745 | y->max_temperature = 22; | |
746 | y->attenuation = 77; | |
275
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 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
749 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
750 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
751 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEAST")) { |
285 | 752 | query.prepare("INSERT INTO inventory_yeasts SET name=:name, type=:type, form=:form, " |
753 | "laboratory=:laboratory, product_id=:productid, min_temperature=:templo, max_temperature=:temphi, " | |
754 | "flocculation=:floc, attenuation=:att, notes=:notes, best_for=:bestfor, " | |
755 | "max_reuse=:reuse, short_desc='', uuid = :uuid"); | |
756 | query.bindValue(":name", y->name); | |
757 | query.bindValue(":type", y->type); | |
758 | query.bindValue(":form", y->form); | |
759 | query.bindValue(":laboratory", y->laboratory); | |
760 | query.bindValue(":productid", y->product_id); | |
761 | query.bindValue(":templo", QString("%1").arg(y->min_temperature, 2, 'f', 1, '0')); | |
762 | query.bindValue(":temphi", QString("%1").arg(y->max_temperature, 2, 'f', 1, '0')); | |
763 | query.bindValue(":floc", y->flocculation); | |
764 | query.bindValue(":att", QString("%1").arg(y->attenuation, 2, 'f', 1, '0')); | |
765 | query.bindValue(":notes", y->notes); | |
766 | query.bindValue(":bestfor", y->best_for); | |
767 | query.bindValue(":reuse", y->max_reuse); | |
768 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); | |
769 | query.exec(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
770 | if (query.lastError().isValid()) { |
285 | 771 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
772 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
773 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
774 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
775 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
776 | } |
285 | 777 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
778 | (xml->name() == "VERSION") || (xml->name() == "TIMES_CULTURED") || | |
779 | (xml->name() == "DISP_MIN_TEMP") || (xml->name() == "DISP_MAX_TEMP") || | |
780 | (xml->name() == "CULTURE_DATE") || (xml->name() == "STARTER_TYPE") || | |
781 | (xml->name() == "STARTER_MADE") || (xml->name() == "STARTER_VOLUME") || | |
782 | (xml->name() == "OG_STARTER") || (xml->name() == "TIME_AERATED") || | |
783 | (xml->name() == "ZINC_ADDED") || (xml->name() == "AMOUNT_ZINC") || | |
784 | (xml->name() == "AMOUNT_EXTRACT") || (xml->name() == "COST_EXTRACT") || | |
785 | (xml->name() == "ALWAYS_ON_STOCK") || (xml->name() == "DISPLAY_AMOUNT") || | |
786 | (xml->name() == "AMOUNT") || (xml->name() == "DISPLAY_AMOUNT") || | |
787 | (xml->name() == "AMOUNT_IS_WEIGHT") || (xml->name() == "ADD_TO_SECONDARY") || | |
788 | (xml->name() == "COST") || (xml->name() == "DISPLAY_COST") || | |
789 | (xml->name() == "TEMP") || (xml->name() == "INVENTORY"))) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
790 | // Ignore. |
285 | 791 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
792 | y->name = xml->readElementText(); | |
793 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LABORATORY")) { | |
794 | y->laboratory = xml->readElementText(); | |
795 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PRODUCT_ID")) { | |
796 | y->product_id = xml->readElementText(); | |
797 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
798 | y->notes = xml->readElementText(); | |
799 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BEST_FOR")) { | |
800 | y->best_for = xml->readElementText(); | |
801 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
802 | QString temp = xml->readElementText(); | |
803 | if (temp == "Ale") | |
804 | y->type = 1; | |
805 | else if (temp == "Wheat") | |
806 | y->type = 2; | |
807 | else if (temp == "Wine") | |
808 | y->type = 3; | |
809 | else if (temp == "Champagne") | |
810 | y->type = 4; | |
811 | else if (temp == "Brett") | |
812 | y->type = 5; | |
813 | else if (temp == "Kveik") | |
814 | y->type = 6; | |
815 | else if (temp == "Hybrid") | |
816 | y->type = 7; | |
817 | else | |
818 | y->type = 0; | |
819 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FORM")) { | |
820 | QString temp = xml->readElementText(); | |
821 | if (temp == "Dry") | |
822 | y->form = 1; | |
823 | else if (temp == "Slant") | |
824 | y->form = 2; | |
825 | else if (temp == "Culture") | |
826 | y->form = 3; | |
827 | else if (temp == "Frozen") | |
828 | y->form = 4; | |
829 | else if (temp == "Bottle") | |
830 | y->form = 5; | |
831 | else if (temp == "Dried") | |
832 | y->form = 6; | |
833 | else | |
834 | y->form = 0; | |
835 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FLOCCULATION")) { | |
836 | QString temp = xml->readElementText(); | |
837 | if (temp == "Medium") | |
838 | y->flocculation = 1; | |
839 | else if (temp == "High") | |
840 | y->flocculation = 1; | |
841 | else if (temp == "Very high") | |
842 | y->flocculation = 3; | |
843 | else | |
844 | y->flocculation = 0; | |
845 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MIN_TEMPERATURE")) { | |
846 | y->min_temperature = xml->readElementText().toDouble(); | |
847 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_TEMPERATURE")) { | |
848 | y->max_temperature = xml->readElementText().toDouble(); | |
849 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ATTENUATION")) { | |
850 | y->attenuation = xml->readElementText().toDouble(); | |
851 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_REUSE")) { | |
852 | y->max_reuse = xml->readElementText().toInt(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
853 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
854 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
855 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
856 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
857 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
858 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
859 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
860 | } 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
|
861 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
862 | * Waters |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
863 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
864 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
865 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
866 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
867 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATERS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
868 | qDebug() << "0 /WATERS"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
869 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
870 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
871 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "WATER")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
872 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
873 | * Water |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
874 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
875 | total++; |
286 | 876 | Waters *w = new Waters(); |
877 | w->notes = ""; | |
878 | w->ph = 7.0; | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
879 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
880 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
881 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
882 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
883 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATER")) { |
286 | 884 | query.prepare("INSERT INTO inventory_waters SET name=:name, unlimited_stock=:unlimited, calcium=:ca, " |
885 | "bicarbonate=:hco, sulfate=:so4, chloride=:cl, sodium=:na, magnesium=:mg, ph=:ph, notes=:notes, " | |
886 | "total_alkalinity=:alkalinity, nitrate=:no, uuid = :uuid"); | |
887 | query.bindValue(":name", w->name); | |
888 | query.bindValue(":unlimited", w->unlimited_stock ? 1:0); | |
889 | query.bindValue(":ca", QString("%1").arg(w->calcium, 4, 'f', 3, '0')); | |
890 | query.bindValue(":hco", QString("%1").arg(w->bicarbonate, 4, 'f', 3, '0')); | |
891 | query.bindValue(":so4", QString("%1").arg(w->sulfate, 4, 'f', 3, '0')); | |
892 | query.bindValue(":cl", QString("%1").arg(w->chloride, 4, 'f', 3, '0')); | |
893 | query.bindValue(":na", QString("%1").arg(w->sodium, 4, 'f', 3, '0')); | |
894 | query.bindValue(":mg", QString("%1").arg(w->magnesium, 4, 'f', 3, '0')); | |
895 | query.bindValue(":ph", QString("%1").arg(w->ph, 4, 'f', 3, '0')); | |
896 | query.bindValue(":notes", w->notes); | |
897 | query.bindValue(":alkalinity", QString("%1").arg(w->total_alkalinity, 4, 'f', 3, '0')); | |
898 | query.bindValue(":no", QString("%1").arg(w->nitrate, 4, 'f', 3, '0')); | |
899 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); | |
900 | query.exec(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
901 | if (query.lastError().isValid()) { |
286 | 902 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
903 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
904 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
905 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
906 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
907 | } |
286 | 908 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
909 | (xml->name() == "VERSION") || (xml->name() == "DEFAULT_WATER") || | |
910 | (xml->name() == "ALWAYS_ON_STOCK") || (xml->name() == "AMOUNT") || | |
911 | (xml->name() == "DISPLAY_AMOUNT"))) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
912 | // Ignore. |
286 | 913 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
914 | w->name = xml->readElementText(); | |
915 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
916 | w->notes = xml->readElementText(); | |
917 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "xUNLIMITED_STOCK")) { | |
918 | w->unlimited_stock = (xml->readElementText() == "TRUE") ? true:false; | |
919 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CALCIUM")) { | |
920 | w->calcium = xml->readElementText().toDouble(); | |
921 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BICARBONATE")) { | |
922 | w->bicarbonate = xml->readElementText().toDouble(); | |
923 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOTAL_ALKALINITY")) { | |
924 | w->total_alkalinity = xml->readElementText().toDouble(); | |
925 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SULFATE")) { | |
926 | w->sulfate = xml->readElementText().toDouble(); | |
927 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CHLORIDE")) { | |
928 | w->chloride = xml->readElementText().toDouble(); | |
929 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SODIUM")) { | |
930 | w->sodium = xml->readElementText().toDouble(); | |
931 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAGNESIUM")) { | |
932 | w->magnesium = xml->readElementText().toDouble(); | |
933 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PH")) { | |
934 | w->ph = xml->readElementText().toDouble(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
935 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
936 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
937 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
938 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
939 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
940 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
941 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
942 | } 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
|
943 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
944 | * Recipes |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
945 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
946 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
947 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
948 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
949 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "RECIPES")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
950 | qDebug() << "0 /RECIPES"; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
951 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
952 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
953 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECIPE")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
954 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
955 | * Recipe |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
956 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
957 | total++; |
289 | 958 | Recipe *r = new Recipe(); |
959 | r->record = -1; | |
960 | r->notes = r->st_guide = r->st_name = r->st_letter = r->st_category = ""; | |
961 | r->w1_name = r->w2_name = ""; | |
962 | r->w1_ph = r->w2_ph = r->wg_ph = r->wb_ph = 7; | |
963 | r->mash_name = ""; | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
964 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
965 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
966 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
967 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
968 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "RECIPE")) { |
289 | 969 | qDebug() << "recipe:" << r->name; |
970 | for (int i = 0; i < r->fermentables.size(); i++) | |
971 | qDebug() << " fermentable" << i << r->fermentables.at(i).name; | |
972 | for (int i = 0; i < r->hops.size(); i++) | |
973 | qDebug() << " hop" << i << r->hops.at(i).name; | |
974 | for (int i = 0; i < r->miscs.size(); i++) | |
975 | qDebug() << " misc" << i << r->miscs.at(i).name; | |
976 | for (int i = 0; i < r->yeasts.size(); i++) | |
977 | qDebug() << " yeast" << i << r->yeasts.at(i).name; | |
978 | for (int i = 0; i < r->mashs.size(); i++) | |
979 | qDebug() << " mash step" << i << r->mashs.at(i).step_name; | |
980 | qDebug() << " water" << 0 << r->w1_name << r->w1_amount; | |
981 | qDebug() << " water" << 1 << r->w2_name << r->w2_amount; | |
982 | if (DB_recipe::save(r, this)) { | |
983 | qInfo() << "Inserted recipe" << r->name; | |
984 | } else { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
985 | errors++; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
986 | } |
289 | 987 | delete r; |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
988 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
989 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
990 | } |
289 | 991 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
992 | (xml->name() == "VERSION") || (xml->name() == "AUTONR") || | |
993 | (xml->name() == "FORCED_CARBONATION") || (xml->name() == "DISPLAY_BATCH_SIZE") || | |
994 | (xml->name() == "DISPLAY_BOIL_SIZE") || (xml->name() == "SPARGE_WATER_COMP") || | |
995 | (xml->name() == "OG_BEFORE_BOIL") || (xml->name() == "SG_END_PRIMARY") || | |
996 | (xml->name() == "FORCED_CARB_KEGS") || (xml->name() == "COOLING_METHOD") || | |
997 | (xml->name() == "INVENTORY_REDUCED") || (xml->name() == "LOCKED") || | |
998 | (xml->name() == "PRIMING_SUGAR_BOTTLES") || (xml->name() == "PRIMING_SUGAR_KEGS") || | |
999 | (xml->name() == "NR_RECIPE") || (xml->name() == "LACTIC_SPARGE") || | |
1000 | (xml->name() == "TARGET_PH") || (xml->name() == "SG_END_MASH") || | |
1001 | (xml->name() == "VOLUME_HLT") || (xml->name() == "OG_FERMENTER") || | |
1002 | (xml->name() == "COOLING_TO") || (xml->name() == "AERATION_TYPE") || | |
1003 | (xml->name() == "BATCH_DIVIDED") || (xml->name() == "BATCH_DIVISION") || | |
1004 | (xml->name() == "DIVIDED_FROM") || (xml->name() == "PARENT") || | |
1005 | (xml->name() == "FERMENTATION_STAGES") || (xml->name() == "DATE") || | |
1006 | (xml->name() == "CALC_ACID") || (xml->name() == "BREWER") | |
1007 | )) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1008 | // Ignore. |
289 | 1009 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
1010 | r->name = xml->readElementText(); | |
1011 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
1012 | r->notes = xml->readElementText(); | |
1013 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BATCH_SIZE")) { | |
1014 | r->batch_size = xml->readElementText().toDouble(); | |
1015 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BOIL_SIZE")) { | |
1016 | r->boil_size = xml->readElementText().toDouble(); | |
1017 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BOIL_TIME")) { | |
1018 | r->boil_time = xml->readElementText().toDouble(); | |
1019 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EFFICIENCY")) { | |
1020 | r->efficiency = xml->readElementText().toDouble(); | |
1021 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "OG") || (xml->name() == "EST_OG"))) { | |
1022 | r->est_og = xml->readElementText().toDouble(); | |
1023 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "FG") || (xml->name() == "EST_FG"))) { | |
1024 | r->est_fg = xml->readElementText().toDouble(); | |
1025 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "ABV") || (xml->name() == "EST_ABV"))) { | |
1026 | r->est_abv = xml->readElementText().toDouble(); | |
1027 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "IBU") || (xml->name() == "EST_IBU"))) { | |
1028 | r->est_ibu = xml->readElementText().toDouble(); | |
1029 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EST_COLOR")) { | |
1030 | r->est_color = Utils::srm_to_ebc(xml->readElementText().toDouble()); | |
1031 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ACID_SPARGE_PERC")) { | |
1032 | r->sparge_acid_perc = Utils::srm_to_ebc(xml->readElementText().toDouble()); | |
1033 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SPARGE_ACID_TYPE")) { | |
1034 | QString temp = xml->readElementText(); | |
1035 | if (temp == "Hydrochloric") | |
1036 | r->sparge_acid_type = 1; | |
1037 | else if (temp == "Phosphoric") | |
1038 | r->sparge_acid_type = 2; | |
1039 | else if (temp == "Sulfuric") | |
1040 | r->sparge_acid_type = 3; | |
1041 | else | |
1042 | r->sparge_acid_type = 0; | |
1043 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
1044 | QString temp = xml->readElementText(); | |
1045 | if (temp == "Extract") | |
1046 | r->type = 0; | |
1047 | else if (temp == "Partial Mash") | |
1048 | r->type = 1; | |
1049 | else | |
1050 | r->type = 2; | |
1051 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "IBU_METHOD")) { | |
1052 | QString temp = xml->readElementText(); | |
338
473479de8c5b
With beerXML recipe import, the IBU method is always Tinseth.
Michiel Broek <mbroek@mbse.eu>
parents:
289
diff
changeset
|
1053 | /* For the known beerXML names, select Tinseth */ |
473479de8c5b
With beerXML recipe import, the IBU method is always Tinseth.
Michiel Broek <mbroek@mbse.eu>
parents:
289
diff
changeset
|
1054 | r->ibu_method = 0; |
289 | 1055 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR_METHOD")) { |
1056 | QString temp = xml->readElementText(); | |
1057 | if (temp == "Mosher") | |
1058 | r->color_method = 1; | |
1059 | else if (temp == "Daniels") | |
1060 | r->color_method = 2; | |
1061 | else if (temp == "Halberstadt") | |
1062 | r->color_method = 3; | |
1063 | else if (temp == "Naudts") | |
1064 | r->color_method = 4; | |
1065 | else | |
1066 | r->color_method = 0; | |
1067 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLE")) { | |
1068 | while (xml->readNext()) { | |
1069 | if (xml->atEnd()) | |
1070 | break; | |
1071 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "STYLE")) { | |
1072 | break; | |
1073 | } | |
1074 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( | |
1075 | (xml->name() == "VERSION") || (xml->name() == "NOTES") || | |
1076 | (xml->name() == "PROFILE") || (xml->name() == "EXAMPLES") || | |
1077 | (xml->name() == "DISPLAY_OG_MIN") || (xml->name() == "DISPLAY_OG_MAX") || | |
1078 | (xml->name() == "DISPLAY_FG_MIN") || (xml->name() == "DISPLAY_FG_MAX") || | |
1079 | (xml->name() == "DISPLAY_IBU_MIN") || (xml->name() == "DISPLAY_IBU_MAX") || | |
1080 | (xml->name() == "DISPLAY_COLOR_MIN") || (xml->name() == "DISPLAY_COLOR_MAX") || | |
1081 | (xml->name() == "DISPLAY_CARB_MIN") || (xml->name() == "DISPLAY_CARB_MAX") || | |
1082 | (xml->name() == "DISPLAY_ABV_MIN") || (xml->name() == "DISPLAY_ABV_MAX") || | |
1083 | (xml->name() == "OG_RANGE") || (xml->name() == "FG_RANGE") || | |
1084 | (xml->name() == "IBU_RANGE") || (xml->name() == "CARB_RANGE") || | |
1085 | (xml->name() == "COLOR_RANGE") || (xml->name() == "ABV_RANGE"))) { | |
1086 | // Ignore. | |
1087 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1088 | r->st_name = xml->readElementText(); | |
1089 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CATEGORY")) { | |
1090 | r->st_category = xml->readElementText(); | |
1091 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CATEGORY_NUMBER")) { | |
1092 | r->st_category_number = xml->readElementText().toInt(); | |
1093 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLE_LETTER")) { | |
1094 | r->st_letter = xml->readElementText(); | |
1095 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLE_GUIDE")) { | |
1096 | r->st_guide = xml->readElementText(); | |
1097 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
1098 | QString temp = xml->readElementText(); | |
1099 | if (temp == "Lager") | |
1100 | r->st_type = 0; | |
1101 | else if (temp == "Ale") | |
1102 | r->st_type = 1; | |
1103 | else if (temp == "Mead") | |
1104 | r->st_type = 2; | |
1105 | else if (temp == "Wheat") | |
1106 | r->st_type = 3; | |
1107 | else if (temp == "Mixed") | |
1108 | r->st_type = 4; | |
1109 | else if (temp == "Cider") | |
1110 | r->st_type = 5; | |
1111 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "OG_MIN")) { | |
1112 | r->st_og_min = xml->readElementText().toDouble(); | |
1113 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "OG_MAX")) { | |
1114 | r->st_og_max = xml->readElementText().toDouble(); | |
1115 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FG_MIN")) { | |
1116 | r->st_fg_min = xml->readElementText().toDouble(); | |
1117 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FG_MAX")) { | |
1118 | r->st_fg_max = xml->readElementText().toDouble(); | |
1119 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "IBU_MIN")) { | |
1120 | r->st_ibu_min = xml->readElementText().toDouble(); | |
1121 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "IBU_MAX")) { | |
1122 | r->st_ibu_max = xml->readElementText().toDouble(); | |
1123 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR_MIN")) { | |
1124 | r->st_color_min = xml->readElementText().toDouble(); | |
1125 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR_MAX")) { | |
1126 | r->st_color_max = xml->readElementText().toDouble(); | |
1127 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CARB_MIN")) { | |
1128 | r->st_carb_min = xml->readElementText().toDouble(); | |
1129 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CARB_MAX")) { | |
1130 | r->st_carb_max = xml->readElementText().toDouble(); | |
1131 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ABV_MIN")) { | |
1132 | r->st_abv_min = xml->readElementText().toDouble(); | |
1133 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ABV_MAX")) { | |
1134 | r->st_abv_max = xml->readElementText().toDouble(); | |
1135 | } else { | |
1136 | if (xml->tokenType() == QXmlStreamReader::StartElement) | |
1137 | qDebug() << xml->tokenType() << " STYLE->" << xml->name(); | |
1138 | } | |
1139 | } | |
1140 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EQUIPMENT")) { | |
1141 | while (xml->readNext()) { | |
1142 | if (xml->atEnd()) | |
1143 | break; | |
1144 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "EQUIPMENT")) { | |
1145 | break; | |
1146 | } | |
1147 | /* | |
1148 | * Ignore everything about equipment. Not usefull in a recipe, all calculations should | |
1149 | * be done after import. | |
1150 | */ | |
1151 | } | |
1152 | ||
1153 | /* | |
1154 | * Ingredients | |
1155 | */ | |
1156 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOPS")) { | |
1157 | while (xml->readNext()) { | |
1158 | if (xml->atEnd()) | |
1159 | break; | |
1160 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOPS")) { | |
1161 | break; | |
1162 | } | |
1163 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOP")) { | |
1164 | /* | |
1165 | * Process hop | |
1166 | */ | |
1167 | Hops *newh = new Hops(); | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1168 | newh->utilisation = my_ut_pellet; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1169 | newh->bu_factor = 1.0; |
289 | 1170 | while (xml->readNext()) { |
1171 | if (xml->atEnd()) | |
1172 | break; | |
1173 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOP")) { | |
1174 | r->hops.append(*newh); | |
1175 | delete newh; | |
1176 | break; | |
1177 | } | |
1178 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1179 | newh->name = xml->readElementText(); | |
1180 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { | |
1181 | newh->origin = xml->readElementText(); | |
1182 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
1183 | newh->notes = xml->readElementText(); | |
1184 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TIME")) { | |
1185 | newh->time = xml->readElementText().toDouble(); | |
1186 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "AMOUNT")) { | |
1187 | newh->amount = xml->readElementText().toDouble(); | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1188 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1189 | ((xml->name() == "FORM") || (xml->name() == "BMS_FORM"))) { |
289 | 1190 | QString temp = xml->readElementText(); |
1191 | if (temp == "Plug") | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1192 | newh->form = HOP_FORMS_PLUG; |
289 | 1193 | else if (temp == "Leaf") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1194 | newh->form = HOP_FORMS_LEAF; |
289 | 1195 | else if (temp == "Leaf wet") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1196 | newh->form = HOP_FORMS_LEAF_WET; |
289 | 1197 | else if (temp == "Cryo") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1198 | newh->form = HOP_FORMS_CRYO; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1199 | else if (temp == "CO2 extract") |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1200 | newh->form = HOP_FORMS_CO2EXTRACT; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1201 | else if (temp == "Iso extract") |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1202 | newh->form = HOP_FORMS_ISOEXTRACT; |
289 | 1203 | else |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1204 | newh->form = HOP_FORMS_PELLET; |
289 | 1205 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ALPHA")) { |
1206 | newh->alpha = xml->readElementText().toDouble(); | |
1207 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
1208 | QString temp = xml->readElementText(); | |
1209 | if (temp == "Aroma") | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1210 | newh->type = HOP_TYPE_AROMA; |
289 | 1211 | else if (temp == "Both") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1212 | newh->type = HOP_TYPE_BOTH; |
289 | 1213 | else |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1214 | newh->type = HOP_TYPE_BITTERING; |
289 | 1215 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE")) { |
1216 | QString temp = xml->readElementText(); | |
1217 | if (temp == "First wort") | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1218 | newh->useat = HOP_USEAT_FWH; |
289 | 1219 | else if (temp == "Boil") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1220 | newh->useat = HOP_USEAT_BOIL; |
289 | 1221 | else if (temp == "Aroma") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1222 | newh->useat = HOP_USEAT_AROMA; |
289 | 1223 | else if (temp == "Whirlpool") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1224 | newh->useat = HOP_USEAT_WHIRLPOOL; |
289 | 1225 | else if (temp == "Dry hop") |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1226 | newh->useat = HOP_USEAT_DRY_HOP; |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1227 | else if (temp == "Bottling") |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1228 | newh->useat = HOP_USEAT_BOTTLING; |
289 | 1229 | else |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1230 | newh->useat = HOP_USEAT_MASH; |
289 | 1231 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BETA")) { |
1232 | newh->beta = xml->readElementText().toDouble(); | |
1233 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HSI")) { | |
1234 | newh->hsi = xml->readElementText().toDouble(); | |
1235 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUBSTITUTES")) { | |
1236 | newh->substitutes = xml->readElementText(); | |
1237 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HUMULENE")) { | |
1238 | newh->humulene = xml->readElementText().toDouble(); | |
1239 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && | |
1240 | ((xml->name() == "CARYOPHYLLENE") || (xml->name() == "CAROPHYLLENE"))) { | |
1241 | newh->caryophyllene = xml->readElementText().toDouble(); | |
1242 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COHUMULONE")) { | |
1243 | newh->cohumulone = xml->readElementText().toDouble(); | |
1244 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MYRCENE")) { | |
1245 | newh->myrcene = xml->readElementText().toDouble(); | |
1246 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOTAL_OIL")) { | |
1247 | newh->total_oil = xml->readElementText().toDouble(); | |
389
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1248 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BMS_UTILISATION")) { |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1249 | newh->utilisation = xml->readElementText().toDouble(); |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1250 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BMS_UT_FACTOR")) { |
a98d45793808
Add support for hop extract values with XML import
Michiel Broek <mbroek@mbse.eu>
parents:
338
diff
changeset
|
1251 | newh->bu_factor = xml->readElementText().toDouble(); |
289 | 1252 | } |
1253 | } | |
1254 | } | |
1255 | } | |
1256 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FERMENTABLES")) { | |
1257 | while (xml->readNext()) { | |
1258 | if (xml->atEnd()) | |
1259 | break; | |
1260 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLES")) { | |
1261 | break; | |
1262 | } | |
1263 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FERMENTABLE")) { | |
1264 | /* | |
1265 | * Process fermentable | |
1266 | */ | |
1267 | Fermentables *f = new Fermentables(); | |
1268 | while (xml->readNext()) { | |
1269 | if (xml->atEnd()) | |
1270 | break; | |
1271 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLE")) { | |
1272 | r->fermentables.append(*f); | |
1273 | delete f; | |
1274 | break; | |
1275 | } | |
1276 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( | |
1277 | (xml->name() == "VERSION") || (xml->name() == "DISPLAY_STEP_TEMP") || | |
1278 | (xml->name() == "DISPLAY_AMOUNT") || (xml->name() == "COST") || | |
1279 | (xml->name() == "DISPLAY_COST") || (xml->name() == "INVENTORY") || | |
1280 | (xml->name() == "ALWAYS_ON_STOCK") || (xml->name() == "DISPLAY_COLOR") || | |
1281 | (xml->name() == "PERCENTAGE") || (xml->name() == "ADJUST_TO_TOTAL_100"))) { | |
1282 | // Ignore. | |
1283 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1284 | f->name = xml->readElementText(); | |
1285 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
1286 | QString temp = xml->readElementText(); | |
1287 | if (temp == "Sugar") | |
1288 | f->type = 1; | |
1289 | else if (temp == "Extract") | |
1290 | f->type = 2; | |
1291 | else if (temp == "Dry extract") | |
1292 | f->type = 3; | |
1293 | else if (temp == "Adjunct") | |
1294 | f->type = 4; | |
1295 | else | |
1296 | f->type = 0; | |
1297 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { | |
1298 | f->origin = xml->readElementText(); | |
1299 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUPPLIER")) { | |
1300 | f->supplier = xml->readElementText(); | |
1301 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
1302 | f->notes = xml->readElementText(); | |
1303 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "AMOUNT")) { | |
1304 | f->amount = xml->readElementText().toDouble(); | |
1305 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YIELD")) { | |
1306 | f->yield = xml->readElementText().toDouble(); | |
1307 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COARSE_FINE_DIFF")) { | |
1308 | f->coarse_fine_diff = xml->readElementText().toDouble(); | |
1309 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MOISTURE")) { | |
1310 | f->moisture = xml->readElementText().toDouble(); | |
1311 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DIASTATIC_POWER")) { | |
1312 | f->diastatic_power = xml->readElementText().toDouble(); | |
1313 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_IN_BATCH")) { | |
1314 | f->max_in_batch = xml->readElementText().toDouble(); | |
1315 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECOMMEND_MASH")) { | |
1316 | f->recommend_mash = (xml->readElementText() == "TRUE") ? true:false; | |
1317 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "GRAINTYPE")) { | |
1318 | QString temp = xml->readElementText(); | |
1319 | if (temp == "Roast") | |
1320 | f->graintype = 1; | |
1321 | else if (temp == "Crystal") | |
1322 | f->graintype = 2; | |
1323 | else if (temp == "Kilned") | |
1324 | f->graintype = 3; | |
1325 | else if (temp == "Sour Malt") | |
1326 | f->graintype = 4; | |
1327 | else if (temp == "Special") | |
1328 | f->graintype = 5; | |
1329 | else if (temp == "No malt") | |
1330 | f->graintype = 6; | |
1331 | else | |
1332 | f->graintype = 0; | |
1333 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ADDED")) { | |
1334 | QString temp = xml->readElementText(); | |
1335 | if (temp == "Boil") | |
1336 | f->added = 1; | |
1337 | else if (temp == "Fermentation") | |
1338 | f->added = 2; | |
1339 | else if (temp == "Lagering") | |
1340 | f->added = 3; | |
1341 | else if (temp == "Bottle") | |
1342 | f->added = 4; | |
1343 | else | |
1344 | f->added = 0; | |
1345 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ADD_AFTER_BOIL")) { | |
1346 | f->add_after_boil = (xml->readElementText() == "TRUE") ? true:false; | |
1347 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR")) { | |
1348 | f->color = Utils::srm_to_ebc(xml->readElementText().toDouble()); | |
1349 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PROTEIN")) { | |
1350 | f->protein = xml->readElementText().toDouble(); | |
1351 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DISSOLVED_PROTEIN")) { | |
1352 | f->dissolved_protein = xml->readElementText().toDouble(); | |
1353 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DI_pH")) { | |
1354 | f->di_ph = xml->readElementText().toDouble(); | |
1355 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ACID_TO_pH_5.7")) { | |
1356 | f->acid_to_ph_57 = xml->readElementText().toDouble(); | |
1357 | } else { | |
1358 | if (xml->tokenType() == QXmlStreamReader::StartElement) | |
1359 | qDebug() << xml->tokenType() << "FERMENTABLE->" << xml->name(); | |
1360 | } | |
1361 | } | |
1362 | } | |
1363 | } | |
1364 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MISCS")) { | |
1365 | while (xml->readNext()) { | |
1366 | if (xml->atEnd()) | |
1367 | break; | |
1368 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISCS")) { | |
1369 | break; | |
1370 | } | |
1371 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MISC")) { | |
1372 | /* | |
1373 | * Process misc | |
1374 | */ | |
1375 | Miscs *m = new Miscs(); | |
1376 | while (xml->readNext()) { | |
1377 | if (xml->atEnd()) | |
1378 | break; | |
1379 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISC")) { | |
1380 | r->miscs.append(*m); | |
1381 | delete m; | |
1382 | break; | |
1383 | } | |
1384 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( | |
1385 | (xml->name() == "VERSION") || (xml->name() == "DISPLAY_AMOUNT") || | |
1386 | (xml->name() == "FREE_FIELD") || (xml->name() == "FREE_FIELD_NAME") || | |
1387 | (xml->name() == "COST") || (xml->name() == "INVENTORY") || | |
1388 | (xml->name() == "DISPLAY_COST") || | |
1389 | (xml->name() == "ALWAYS_ON_STOCK") || (xml->name() == "DISPLAY_TIME"))) { | |
1390 | // Ignore. | |
1391 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1392 | m->name = xml->readElementText(); | |
1393 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
1394 | m->notes = xml->readElementText(); | |
1395 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "AMOUNT")) { | |
1396 | m->amount = xml->readElementText().toDouble(); | |
1397 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE_FOR")) { | |
1398 | m->use_for = xml->readElementText(); | |
1399 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
1400 | QString temp = xml->readElementText(); | |
1401 | if (temp == "Herb") | |
1402 | m->type = 1; | |
1403 | else if (temp == "Flavor") | |
1404 | m->type = 2; | |
1405 | else if (temp == "Fining") | |
1406 | m->type = 3; | |
1407 | else if (temp == "Water agent") | |
1408 | m->type = 4; | |
1409 | else if (temp == "Yeast nutrient") | |
1410 | m->type = 5; | |
1411 | else if (temp == "Other") | |
1412 | m->type = 6; | |
1413 | else | |
1414 | m->type = 0; | |
1415 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE")) { | |
1416 | QString temp = xml->readElementText(); | |
1417 | if (temp == "Mash") | |
1418 | m->use_use = 1; | |
1419 | else if (temp == "Boil") | |
1420 | m->use_use = 2; | |
1421 | else if (temp == "Primary") | |
1422 | m->use_use = 3; | |
1423 | else if (temp == "Secondary") | |
1424 | m->use_use = 4; | |
1425 | else if (temp == "Bottling") | |
1426 | m->use_use = 5; | |
1427 | else | |
1428 | m->use_use = 0; | |
1429 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "AMOUNT_IS_WEIGHT")) { | |
1430 | m->amount_is_weight = (xml->readElementText() == "TRUE") ? true:false; | |
1431 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TIME")) { | |
1432 | m->time = xml->readElementText().toDouble(); | |
1433 | } else { | |
1434 | if (xml->tokenType() == QXmlStreamReader::StartElement) | |
1435 | qDebug() << xml->tokenType() << " MISC->" << xml->name(); | |
1436 | } | |
1437 | } | |
1438 | } | |
1439 | } | |
1440 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YEASTS")) { | |
1441 | while (xml->readNext()) { | |
1442 | if (xml->atEnd()) | |
1443 | break; | |
1444 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEASTS")) { | |
1445 | break; | |
1446 | } | |
1447 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YEAST")) { | |
1448 | /* | |
1449 | * Process yeast | |
1450 | */ | |
1451 | Yeasts *y = new Yeasts(); | |
1452 | while (xml->readNext()) { | |
1453 | if (xml->atEnd()) | |
1454 | break; | |
1455 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEAST")) { | |
1456 | r->yeasts.append(*y); | |
1457 | delete y; | |
1458 | break; | |
1459 | } | |
1460 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1461 | y->name = xml->readElementText(); | |
1462 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LABORATORY")) { | |
1463 | y->laboratory = xml->readElementText(); | |
1464 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PRODUCT_ID")) { | |
1465 | y->product_id = xml->readElementText(); | |
1466 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
1467 | y->notes = xml->readElementText(); | |
1468 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BEST_FOR")) { | |
1469 | y->best_for = xml->readElementText(); | |
1470 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "AMOUNT")) { | |
1471 | y->amount = xml->readElementText().toDouble(); | |
1472 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
1473 | QString temp = xml->readElementText(); | |
1474 | if (temp == "Ale") | |
1475 | y->type = 1; | |
1476 | else if (temp == "Wheat") | |
1477 | y->type = 2; | |
1478 | else if (temp == "Wine") | |
1479 | y->type = 3; | |
1480 | else if (temp == "Champagne") | |
1481 | y->type = 4; | |
1482 | else if (temp == "Brett") | |
1483 | y->type = 5; | |
1484 | else if (temp == "Kveik") | |
1485 | y->type = 6; | |
1486 | else if (temp == "Hybrid") | |
1487 | y->type = 7; | |
1488 | else | |
1489 | y->type = 0; | |
1490 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FORM")) { | |
1491 | QString temp = xml->readElementText(); | |
1492 | if (temp == "Dry") | |
1493 | y->form = 1; | |
1494 | else if (temp == "Slant") | |
1495 | y->form = 2; | |
1496 | else if (temp == "Culture") | |
1497 | y->form = 3; | |
1498 | else if (temp == "Frozen") | |
1499 | y->form = 4; | |
1500 | else if (temp == "Bottle") | |
1501 | y->form = 5; | |
1502 | else if (temp == "Dried") | |
1503 | y->form = 6; | |
1504 | else | |
1505 | y->form = 0; | |
1506 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FLOCCULATION")) { | |
1507 | QString temp = xml->readElementText(); | |
1508 | if (temp == "Medium") | |
1509 | y->flocculation = 1; | |
1510 | else if (temp == "High") | |
1511 | y->flocculation = 1; | |
1512 | else if (temp == "Very high") | |
1513 | y->flocculation = 3; | |
1514 | else | |
1515 | y->flocculation = 0; | |
1516 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MIN_TEMPERATURE")) { | |
1517 | y->min_temperature = xml->readElementText().toDouble(); | |
1518 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_TEMPERATURE")) { | |
1519 | y->max_temperature = xml->readElementText().toDouble(); | |
1520 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ATTENUATION")) { | |
1521 | y->attenuation = xml->readElementText().toDouble(); | |
1522 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_REUSE")) { | |
1523 | y->max_reuse = xml->readElementText().toInt(); | |
1524 | } | |
1525 | } | |
1526 | } | |
1527 | } | |
1528 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH")) { | |
1529 | while (xml->readNext()) { | |
1530 | if (xml->atEnd()) | |
1531 | break; | |
1532 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH")) { | |
1533 | break; | |
1534 | } | |
1535 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( | |
1536 | (xml->name() == "VERSION") || (xml->name() == "NOTES") || | |
1537 | (xml->name() == "GRAIN_TEMP") || (xml->name() == "TUN_TEMP") || | |
1538 | (xml->name() == "SG_LAST_RUNNINGS") || (xml->name() == "PH_LAST_RUNNINGS") || | |
1539 | (xml->name() == "TUN_WEIGHT") || (xml->name() == "TUN_SPECIFIC_HEAT") || | |
1540 | (xml->name() == "EQUIP_ADJUST"))) { | |
1541 | // Ignore. | |
1542 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1543 | r->mash_name = xml->readElementText(); | |
1544 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PH")) { | |
1545 | r->mash_ph = xml->readElementText().toDouble(); | |
1546 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SPARGE_TEMP")) { | |
1547 | r->sparge_temp = xml->readElementText().toDouble(); | |
1548 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH_STEPS")) { | |
1549 | while (xml->readNext()) { | |
1550 | if (xml->atEnd()) | |
1551 | break; | |
1552 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH_STEPS")) { | |
1553 | break; | |
1554 | } | |
1555 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH_STEP")) { | |
1556 | /* | |
1557 | * Process mash step | |
1558 | */ | |
1559 | MashSteps *ms = new MashSteps(); | |
1560 | while (xml->readNext()) { | |
1561 | if (xml->atEnd()) | |
1562 | break; | |
1563 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH_STEP")) { | |
1564 | r->mashs.append(*ms); | |
1565 | delete ms; | |
1566 | break; | |
1567 | } | |
1568 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( | |
1569 | (xml->name() == "VERSION") || (xml->name() == "DISPLAY_STEP_TEMP") || | |
1570 | (xml->name() == "PH") || (xml->name() == "WATER_GRAIN_RATIO") || | |
1571 | (xml->name() == "DECOCTION_AMT") || (xml->name() == "INFUSE_TEMP") || | |
1572 | (xml->name() == "INFUSE_AMOUNT") || (xml->name() == "DISPLAY_INFUSE_AMT") | |
1573 | )) { | |
1574 | // Ignore. | |
1575 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1576 | ms->step_name = xml->readElementText(); | |
1577 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
1578 | QString temp = xml->readElementText(); | |
1579 | if (temp == "Infusion") | |
1580 | ms->step_type = 0; | |
1581 | else if (temp == "Temperature") | |
1582 | ms->step_type = 1; | |
1583 | else if (temp == "Decoction") | |
1584 | ms->step_type = 2; | |
1585 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STEP_TEMP")) { | |
1586 | ms->step_temp = xml->readElementText().toDouble(); | |
1587 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "END_TEMP")) { | |
1588 | ms->end_temp = xml->readElementText().toDouble(); | |
1589 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STEP_TIME")) { | |
1590 | ms->step_time = xml->readElementText().toDouble(); | |
1591 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RAMP_TIME")) { | |
1592 | ms->ramp_time = xml->readElementText().toDouble(); | |
1593 | } else { | |
1594 | if (xml->tokenType() == QXmlStreamReader::StartElement) | |
1595 | qDebug() << xml->tokenType() << " MASH_STEP->" << xml->name(); | |
1596 | } | |
1597 | } | |
1598 | } | |
1599 | } | |
1600 | } else { | |
1601 | if (xml->tokenType() == QXmlStreamReader::StartElement) | |
1602 | qDebug() << xml->tokenType() << " MASH->" << xml->name(); | |
1603 | } | |
1604 | } | |
1605 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "WATERS")) { | |
1606 | int waterno = 0; | |
1607 | while (xml->readNext()) { | |
1608 | if (xml->atEnd()) | |
1609 | break; | |
1610 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATERS")) { | |
1611 | break; | |
1612 | } | |
1613 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "WATER")) { | |
1614 | /* | |
1615 | * Process water | |
1616 | */ | |
1617 | while (xml->readNext()) { | |
1618 | if (xml->atEnd()) | |
1619 | break; | |
1620 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATER")) { | |
1621 | waterno++; | |
1622 | break; | |
1623 | } | |
1624 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( | |
1625 | (xml->name() == "VERSION") || (xml->name() == "DISPLAY_STEP_TEMP") || | |
1626 | (xml->name() == "NOTES") || (xml->name() == "DISPLAY_AMOUNT") || | |
1627 | (xml->name() == "ALWAYS_ON_STOCK") || (xml->name() == "DEFAULT_WATER") | |
1628 | )) { | |
1629 | // Ignore. | |
1630 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1631 | if (waterno) | |
1632 | r->w2_name = xml->readElementText(); | |
1633 | else | |
1634 | r->w1_name = xml->readElementText(); | |
1635 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PH")) { | |
1636 | if (waterno) | |
1637 | r->w2_ph = xml->readElementText().toDouble(); | |
1638 | else | |
1639 | r->w1_ph = xml->readElementText().toDouble(); | |
1640 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "AMOUNT")) { | |
1641 | if (waterno) | |
1642 | r->w2_amount = xml->readElementText().toDouble(); | |
1643 | else | |
1644 | r->w1_amount = xml->readElementText().toDouble(); | |
1645 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CALCIUM")) { | |
1646 | if (waterno) | |
1647 | r->w2_calcium = xml->readElementText().toDouble(); | |
1648 | else | |
1649 | r->w1_calcium = xml->readElementText().toDouble(); | |
1650 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BICARBONATE")) { | |
1651 | if (waterno) | |
1652 | r->w2_total_alkalinity = 1.22 * xml->readElementText().toDouble(); | |
1653 | else | |
1654 | r->w1_total_alkalinity = 1.22 * xml->readElementText().toDouble(); | |
1655 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SULFATE")) { | |
1656 | if (waterno) | |
1657 | r->w2_sulfate = xml->readElementText().toDouble(); | |
1658 | else | |
1659 | r->w1_sulfate = xml->readElementText().toDouble(); | |
1660 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CHLORIDE")) { | |
1661 | if (waterno) | |
1662 | r->w2_chloride = xml->readElementText().toDouble(); | |
1663 | else | |
1664 | r->w1_chloride = xml->readElementText().toDouble(); | |
1665 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SODIUM")) { | |
1666 | if (waterno) | |
1667 | r->w2_sodium = xml->readElementText().toDouble(); | |
1668 | else | |
1669 | r->w1_sodium = xml->readElementText().toDouble(); | |
1670 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAGNESIUM")) { | |
1671 | if (waterno) | |
1672 | r->w2_magnesium = xml->readElementText().toDouble(); | |
1673 | else | |
1674 | r->w1_magnesium = xml->readElementText().toDouble(); | |
1675 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOTAL_ALKALINITY")) { | |
1676 | if (waterno) | |
1677 | r->w2_total_alkalinity = xml->readElementText().toDouble(); | |
1678 | else | |
1679 | r->w1_total_alkalinity = xml->readElementText().toDouble(); | |
1680 | } else { | |
1681 | if (xml->tokenType() == QXmlStreamReader::StartElement) | |
1682 | qDebug() << xml->tokenType() << " WATER->" << xml->name(); | |
1683 | } | |
1684 | } | |
1685 | } | |
1686 | } | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1687 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1688 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
289 | 1689 | qDebug() << xml->tokenType() << " RECIPE" << xml->name(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1690 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1691 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1692 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1693 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1694 | } 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
|
1695 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1696 | * Mashes |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1697 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1698 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1699 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1700 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1701 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASHS")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1702 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1703 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1704 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH")) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1705 | /* |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1706 | * Mash |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1707 | */ |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1708 | total++; |
288 | 1709 | Mashs *m = new Mashs(); |
1710 | m->name = m->notes = ""; | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1711 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1712 | while (xml->readNext()) { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1713 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1714 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1715 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH")) { |
288 | 1716 | query.prepare("INSERT INTO profile_mash SET name=:name, notes=:notes, steps=:steps, uuid=:uuid"); |
1717 | query.bindValue(":name", m->name); | |
1718 | query.bindValue(":notes", m->notes); | |
1719 | query.bindValue(":steps", m->steps.toJson(QJsonDocument::Compact)); | |
1720 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); | |
1721 | query.exec(); | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1722 | if (query.lastError().isValid()) { |
288 | 1723 | qWarning() << query.lastError(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1724 | errors++; |
288 | 1725 | } else { |
1726 | qInfo() << "Inserted mash step" << m->name; | |
1727 | } | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1728 | ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize)); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1729 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1730 | } |
288 | 1731 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( |
1732 | (xml->name() == "VERSION") || (xml->name() == "GRAIN_TEMP") || | |
1733 | (xml->name() == "TUN_TEMP") || (xml->name() == "SPARGE_TEMP") || | |
1734 | (xml->name() == "SG_LAST_RUNNINGS") || (xml->name() == "PH_LAST_RUNNINGS") || | |
1735 | (xml->name() == "PH") || (xml->name() == "TUN_WEIGHT") || | |
1736 | (xml->name() == "TUN_SPECIFIC_HEAT") || (xml->name() == "EQUIP_ADJUST"))) { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1737 | // Ignore. |
288 | 1738 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { |
1739 | m->name = xml->readElementText(); | |
1740 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { | |
1741 | m->notes = xml->readElementText(); | |
1742 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH_STEPS")) { | |
1743 | QJsonArray array; | |
1744 | while (xml->readNext()) { | |
1745 | if (xml->atEnd()) | |
1746 | break; | |
1747 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH_STEPS")) { | |
1748 | m->steps.setArray(array); | |
1749 | break; | |
1750 | } | |
1751 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH_STEP")) { | |
1752 | /* | |
1753 | * Process mash step | |
1754 | */ | |
1755 | QJsonObject obj; | |
1756 | while (xml->readNext()) { | |
1757 | if (xml->atEnd()) | |
1758 | break; | |
1759 | if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH_STEP")) { | |
1760 | array.append(obj); | |
1761 | break; | |
1762 | } | |
1763 | if ((xml->tokenType() == QXmlStreamReader::StartElement) && ( | |
1764 | (xml->name() == "VERSION") || (xml->name() == "DISPLAY_STEP_TEMP") || | |
1765 | (xml->name() == "PH") || (xml->name() == "WATER_GRAIN_RATIO") || | |
1766 | (xml->name() == "DECOCTION_AMT") || (xml->name() == "INFUSE_TEMP") || | |
1767 | (xml->name() == "INFUSE_AMOUNT") || (xml->name() == "DISPLAY_INFUSE_AMT"))) { | |
1768 | // Ignore. | |
1769 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { | |
1770 | obj.insert("step_name", xml->readElementText()); | |
1771 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { | |
1772 | QString temp = xml->readElementText(); | |
1773 | if (temp == "Infusion") | |
1774 | obj.insert("step_type", 0); | |
1775 | else if (temp == "Temperature") | |
1776 | obj.insert("step_type", 1); | |
1777 | else if (temp == "Decoction") | |
1778 | obj.insert("step_type", 2); | |
1779 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STEP_TEMP")) { | |
1780 | obj.insert("step_temp", xml->readElementText().toDouble()); | |
1781 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "END_TEMP")) { | |
1782 | obj.insert("end_temp", xml->readElementText().toDouble()); | |
1783 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STEP_TIME")) { | |
1784 | obj.insert("step_time", xml->readElementText().toDouble()); | |
1785 | } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RAMP_TIME")) { | |
1786 | obj.insert("ramp_time", xml->readElementText().toDouble()); | |
1787 | } else { | |
1788 | if (xml->tokenType() == QXmlStreamReader::StartElement) | |
1789 | qDebug() << "4 " << xml->tokenType() << xml->name(); | |
1790 | } | |
1791 | } | |
1792 | } | |
1793 | } | |
1794 | ||
1795 | } else { | |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1796 | if (xml->tokenType() == QXmlStreamReader::StartElement) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1797 | qDebug() << "2 " << xml->tokenType() << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1798 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1799 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1800 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1801 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1802 | } else { |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1803 | qDebug() << "Unknown level 0" << xml->name(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1804 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1805 | if (xml->atEnd()) |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1806 | break; |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1807 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1808 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1809 | log.append(QString(" total errors\n")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1810 | log.append(QString(" ----- ------\n")); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1811 | 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
|
1812 | ui->logEdit->setPlainText(log); |
277
2228d833c52a
The equipment import is now final.
Michiel Broek <mbroek@mbse.eu>
parents:
276
diff
changeset
|
1813 | 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
|
1814 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1815 | ui->progressBar->setValue(100); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1816 | 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
|
1817 | qWarning() << "XML error" << xml->error() << xml->errorString(); |
275
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1818 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1819 | file.close(); |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1820 | } |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1821 | |
f472f9773782
Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1822 |