src/ImportXML.cpp

Sat, 11 Jun 2022 19:29:20 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 11 Jun 2022 19:29:20 +0200
changeset 276
7316a419334d
parent 275
f472f9773782
child 277
2228d833c52a
permissions
-rw-r--r--

Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.

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"
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "MainWindow.h"
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 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
24 {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 qDebug() << "ImportXML start";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 ui->setupUi(this);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 WindowTitle();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 ui->progressBar->setValue(0);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 connect(ui->quitButton, SIGNAL(clicked()), parent, SLOT(fromImportXML()));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 ImportXML::~ImportXML()
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 qDebug() << "ImportXML done";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 delete ui;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 void ImportXML::WindowTitle()
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 QString txt = QString(tr("BMSapp - Import XML"));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 setWindowTitle(txt);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 void ImportXML::on_openButton_clicked()
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 QSqlQuery query;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 QString sql, log;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 int total = 0, errors = 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
52 bool hasnotes;
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath() + "/*.xml", tr("Files (*.xml)"));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 if (fileName == 0) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 QMessageBox::warning(this, tr("Open File"), tr("No XML file selected."));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 return;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 ui->fileEdit->setText(fileName);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 QFile file(fileName);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 qint64 fsize = file.size();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 log = "Import XML file `" + fileName + "`\n\n";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 qInfo() << "Import XML" << fileName << "length" << fsize << "bytes";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 file.open(QIODevice::ReadOnly);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 QXmlStreamReader *xml = new QXmlStreamReader(&file);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 if (xml->tokenType() == QXmlStreamReader::StartDocument) {
276
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
76 qDebug() << xml->documentVersion() << xml->documentEncoding();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 // Just skip
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EQUIPMENTS")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 * Equipments
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "EQUIPMENTS")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 qDebug() << "0 /EQUIPMENTS";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EQUIPMENT")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 * Equipment
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 total++;
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
94 hasnotes = false;
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 sql = "INSERT INTO inventory_equipments SET uuid='";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 sql.append(QUuid::createUuid().toString().mid(1, 36));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 sql.append("', top_up_water=0");
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "EQUIPMENT")) {
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
103 if (! hasnotes)
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
104 sql.append(", notes=''");
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 query.exec(sql);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 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
107 qWarning() << sql << query.lastError();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 errors++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 }
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
113 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
114 ((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
115 (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
116 (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
117 (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
118 (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
119 (xml->name() == "ATTENUATION_FACTOR_TOTAL_MASH_TIME") || (xml->name() == "ATTENUATION_FACTOR_PERC_SIMPLE_SUGAR") ||
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
120 (xml->name() == "ATTENUATION_FACTOR_CONSTANT"))) {
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 // Ignore.
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 sql.append(QString(", name='%1'").arg(xml->readElementText()));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 sql.append(QString(", notes='%1'").arg(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
126 hasnotes = true;
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BOIL_SIZE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 sql.append(QString(", boil_size=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BATCH_SIZE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 sql.append(QString(", batch_size=%1").arg(xml->readElementText().toDouble(), 3, 'f', 2, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TUN_VOLUME")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 sql.append(QString(", tun_volume=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TUN_WEIGHT")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 sql.append(QString(", tun_weight=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TUN_SPECIFIC_HEAT")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 sql.append(QString(", tun_specific_heat=%1").arg(xml->readElementText().toDouble(), 4, 'f', 3, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TUN_HEIGHT")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 sql.append(QString(", tun_height=%1").arg(xml->readElementText().toDouble(), 4, 'f', 3, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TRUB_CHILLER_LOSS")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 sql.append(QString(", trub_chiller_loss=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "EVAP_RATE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 sql.append(QString(", evap_rate=%1").arg(xml->readElementText().toDouble(), 3, 'f', 2, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BOIL_TIME")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 sql.append(QString(", boil_time=%1").arg(xml->readElementText().toDouble(), 1, 'f', 0, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "CALC_BOIL_VOLUME")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 sql.append(QString(", calc_boil_volume=%1").arg((xml->readElementText() == "TRUE") ? "true":"false"));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOP_UP_KETTLE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 sql.append(QString(", top_up_kettle=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOP_UTILIZATION")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 sql.append(QString(", hop_utilization=%1").arg(xml->readElementText().toDouble(), 1, 'f', 0, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LAUTER_VOLUME")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 sql.append(QString(", lauter_volume=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LAUTER_HEIGHT")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 sql.append(QString(", lauter_height=%1").arg(xml->readElementText().toDouble(), 4, 'f', 3, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "LAUTER_DEADSPACE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 sql.append(QString(", lauter_deadspace=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "KETTLE_VOLUME")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 sql.append(QString(", kettle_volume=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "KETTLE_HEIGHT")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 sql.append(QString(", kettle_height=%1").arg(xml->readElementText().toDouble(), 4, 'f', 3, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH_VOLUME")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 sql.append(QString(", mash_volume=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
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() == "EFFICIENCY")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 sql.append(QString(", efficiency=%1").arg(xml->readElementText().toDouble(), 2, 'f', 1, '0'));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 qDebug() << "2 " << xml->tokenType() << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 } 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
173 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 * Styles
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "STYLES")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 qDebug() << "0 /STYLES";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "STYLE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 * Style
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 */
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
187 Style *st = new Style;
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
188 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
189 st->style_guide = "BKG 2019";
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
190 st->category_number = 0;
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 total++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 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
197 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
198 "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
199 "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
200 "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
201 "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
202 "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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 query.exec();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 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
228 qWarning() << query.lastError();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 errors++;
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 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
232 delete st;
275
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 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "VERSION")) ||
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 (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
237 (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
238 (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
239 (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
240 (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
241 (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
242 // Ignore.
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 } 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
244 st->name = xml->readElementText();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 } 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
246 st->category = xml->readElementText();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 } 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
248 st->category_number = xml->readElementText().toInt();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 } 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
250 st->style_letter = xml->readElementText();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 } 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
252 st->style_guide = xml->readElementText();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 } 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 st->type = 5;
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 } 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
268 st->notes = xml->readElementText();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 } 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
270 st->og_min = xml->readElementText().toDouble();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 } 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
272 st->og_max = xml->readElementText().toDouble();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 } 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
274 st->fg_min = xml->readElementText().toDouble();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 } 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
276 st->fg_max = xml->readElementText().toDouble();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 } 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
278 st->ibu_min = xml->readElementText().toDouble();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 } 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
280 st->ibu_max = xml->readElementText().toDouble();
275
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() == "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
282 st->color_min = xml->readElementText().toDouble();
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() == "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
284 st->color_max = xml->readElementText().toDouble();
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() == "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
286 st->carb_min = xml->readElementText().toDouble();
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() == "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
288 st->carb_max = xml->readElementText().toDouble();
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() == "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
290 st->abv_min = xml->readElementText().toDouble();
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() == "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
292 st->abv_max = xml->readElementText().toDouble();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "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
294 st->profile = xml->readElementText();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "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
296 st->ingredients = xml->readElementText();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 } 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
298 st->examples = xml->readElementText();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 qDebug() << "2 " << xml->tokenType() << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FERMENTABLES")) {
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
307 qDebug() << "start FERMENTABLES";
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 * Fermentables
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLES")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 qDebug() << "0 /FERMENTABLES";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FERMENTABLE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 * Fermentable
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 total++;
276
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
323 hasnotes = false;
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 sql = "INSERT INTO inventory_fermentables SET uuid='";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 sql.append(QUuid::createUuid().toString().mid(1, 36));
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 sql.append("'");
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "FERMENTABLE")) {
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 qDebug() << "hasnotes" << hasnotes;
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
333 if (! hasnotes)
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(", 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
335 query.exec(sql);
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 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
337 qWarning() << sql << query.lastError();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338 errors++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 }
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
343 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
344 ((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
345 (xml->name() == "DISPLAY_COLOR") || (xml->name() == "INVENTORY") ||
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
346 (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
347 // 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
348 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "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
349 sql.append(QString(", name='%1'").arg(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
350 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "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
351 sql.append(QString(", cost=%1").arg(xml->readElementText().toDouble(), 3, 'f', 2, '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
352 } 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
353 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
354 if (temp == "Grain")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
355 sql.append(", 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
356 else if (temp == "Sugar")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
357 sql.append(", 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
358 else if (temp == "Extract")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
359 sql.append(", 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
360 else if (temp == "Dry extract")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
361 sql.append(", 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
362 else if (temp == "Adjunct")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
363 sql.append(", 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
364 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
365 sql.append(QString(", origin='%1'").arg(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
366 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUPPLIER")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
367 sql.append(QString(", supplier='%1'").arg(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
368 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "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
369 sql.append(QString(", notes='%1'").arg(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
370 hasnotes = true;
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
371 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ALWAYS_ON_STOCK")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
372 sql.append(QString(", always_on_stock=%1").arg(xml->readElementText().toLower()));
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
373 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YIELD")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
374 sql.append(QString(", yield=%1").arg(xml->readElementText().toDouble(), 5, 'f', 4, '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
375 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COARSE_FINE_DIFF")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
376 sql.append(QString(", coarse_fine_diff=%1").arg(xml->readElementText().toDouble(), 5, 'f', 4, '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
377 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MOISTURE")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
378 sql.append(QString(", moisture=%1").arg(xml->readElementText().toDouble(), 5, 'f', 4, '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
379 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DIASTATIC_POWER")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
380 sql.append(QString(", diastatic_power=%1").arg(xml->readElementText().toDouble(), 5, 'f', 4, '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
381 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MAX_IN_BATCH")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
382 sql.append(QString(", max_in_batch=%1").arg(xml->readElementText().toDouble(), 5, 'f', 4, '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
383 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECOMMEND_MASH")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
384 sql.append(QString(", recommend_mash=%1").arg(xml->readElementText().toLower()));
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
385 } 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
386 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
387 if (temp == "Base")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
388 sql.append(QString(", graintype=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
389 else if (temp == "Roast")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
390 sql.append(QString(", graintype=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
391 else if (temp == "Crystal")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
392 sql.append(QString(", graintype=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
393 else if (temp == "Kilned")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
394 sql.append(QString(", graintype=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
395 else if (temp == "Sour Malt")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
396 sql.append(QString(", graintype=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
397 else if (temp == "Special")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
398 sql.append(QString(", graintype=5"));
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
399 else if (temp == "No malt")
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
400 sql.append(QString(", graintype=6"));
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
401 } 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
402 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
403 if (temp == "Mash")
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", added=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
405 else if (temp == "Boil")
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", added=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
407 else if (temp == "Fermentation")
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", added=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
409 else if (temp == "Lagering")
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", added=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
411 else if (temp == "Bottle")
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", added=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
413 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ADD_AFTER_BOIL")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
414 sql.append(QString(", add_after_boil=%1").arg(xml->readElementText().toLower()));
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
415 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COLOR")) {
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", color=%1").arg(xml->readElementText().toDouble(), 5, 'f', 4, '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
417 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "PROTEIN")) {
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", protein=%1").arg(xml->readElementText().toDouble(), 5, 'f', 4, '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
419 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DISSOLVED_PROTEIN")) {
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", dissolved_protein=%1").arg(xml->readElementText().toDouble(), 5, 'f', 4, '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
421 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "DI_pH")) {
7316a419334d Changed import XML method for beer styles using a temporary struct and native database functions. This is the correct method which gives the correct results.
Michiel Broek <mbroek@mbse.eu>
parents: 275
diff changeset
422 sql.append(QString(", di_ph=%1").arg(xml->readElementText().toDouble(), 6, 'f', 5, '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
423 } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ACID_TO_pH_5.7")) {
7316a419334d Changed import XML method for beer styles using a temporary 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 sql.append(QString(", acid_to_ph_57=%1").arg(xml->readElementText().toDouble(), 6, 'f', 5, '0'));
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427 qDebug() << "2 " << xml->tokenType() << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 } 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
433 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 * Hops
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOPS")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 qDebug() << "0 /HOPS";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HOP")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 * Hop
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 total++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 sql = "INSERT INTO inventory_hops SET uuid='";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 sql.append(QUuid::createUuid().toString().mid(1, 36));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "HOP")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455 // query.exec(sql);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 if (query.lastError().isValid()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 // qWarning() << sql << query.lastError();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 errors++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464 // Ignore.
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
466 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
467 qDebug() << "2 " << xml->tokenType() << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
468 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
471 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472 } 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
473 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474 * Miscs
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISCS")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 qDebug() << "0 /MISCS";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MISC")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 * Misc
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 total++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488 sql = "INSERT INTO inventory_miscs SET uuid='";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489 sql.append(QUuid::createUuid().toString().mid(1, 36));
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 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MISC")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 // query.exec(sql);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
496 if (query.lastError().isValid()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 // qWarning() << sql << query.lastError();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 errors++;
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 ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 // Ignore.
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 qDebug() << "2 " << xml->tokenType() << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 }
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 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 } 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
513 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 * Yeasts
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEASTS")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520 qDebug() << "0 /YEASTS";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "YEAST")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525 * Yeast
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527 total++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 sql = "INSERT INTO inventory_yeasts SET uuid='";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 sql.append(QUuid::createUuid().toString().mid(1, 36));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "YEAST")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 // query.exec(sql);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536 if (query.lastError().isValid()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 // qWarning() << sql << query.lastError();
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 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
543 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 // Ignore.
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547 qDebug() << "2 " << xml->tokenType() << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552 } 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
553 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 * Waters
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATERS")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 qDebug() << "0 /WATERS";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "WATER")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565 * Water
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 total++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 sql = "INSERT INTO inventory_waters SET uuid='";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 sql.append(QUuid::createUuid().toString().mid(1, 36));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "WATER")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 // query.exec(sql);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
576 if (query.lastError().isValid()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
577 // qWarning() << sql << query.lastError();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
578 errors++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 // Ignore.
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 qDebug() << "2 " << xml->tokenType() << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
591 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 } 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
593 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594 * Recipes
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
595 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
596 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
597 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
598 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
599 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "RECIPES")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 qDebug() << "0 /RECIPES";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "RECIPE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 * Recipe
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 total++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608 sql = "INSERT INTO recipes SET uuid='";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609 sql.append(QUuid::createUuid().toString().mid(1, 36));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
614 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "RECIPE")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615 // query.exec(sql);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 if (query.lastError().isValid()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617 // qWarning() << sql << query.lastError();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618 errors++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 // Ignore.
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 qDebug() << "2 " << xml->tokenType() << xml->name();
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 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 } 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
633 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 * Mashes
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 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
637 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASHS")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640 qDebug() << "0 /MASHS";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
641 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MASH")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 /*
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 * Mash
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 */
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 total++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 sql = "INSERT INTO inventory_mashs SET uuid='";
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 sql.append(QUuid::createUuid().toString().mid(1, 36));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 while (xml->readNext()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654 if ((xml->tokenType() == QXmlStreamReader::EndElement) && (xml->name() == "MASH")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655 // query.exec(sql);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656 if (query.lastError().isValid()) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657 // qWarning() << sql << query.lastError();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
658 errors++;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660 ui->progressBar->setValue(round(100 * xml->characterOffset() / fsize));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "VERSION")) {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 // Ignore.
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 if (xml->tokenType() == QXmlStreamReader::StartElement)
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
667 qDebug() << "2 " << xml->tokenType() << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
669 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
671 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
672 } else {
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673 qDebug() << "Unknown level 0" << xml->name();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675 if (xml->atEnd())
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
676 break;
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
677 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
678
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
679 log.append(QString(" total errors\n"));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
680 log.append(QString(" ----- ------\n"));
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
681 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
682 ui->logEdit->setPlainText(log);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
684 ui->progressBar->setValue(100);
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
685 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
686 qWarning() << "XML error" << xml->error() << xml->errorString();
275
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688 file.close();
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 }
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690
f472f9773782 Added import from xml, equipments and beerstyles.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691

mercurial