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