-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparserxmlworker.cpp
58 lines (45 loc) · 1.35 KB
/
parserxmlworker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "parserxmlworker.h"
#include <QDebug>
#include <QThread>
ParserXMLWorker::ParserXMLWorker()
{
}
void ParserXMLWorker::doParser(QFileInfoList *fileList, QMultiMap<QString, QString> *arrayXml)
{
for(int iii = 0; iii<fileList->size(); iii++)
{
bool result = true;
QString fileName(fileList->at(iii).absoluteFilePath());
qDebug() << "Try work with file" << fileName;
QFile file(fileName);
if(file.open(QIODevice::ReadOnly))
{
QXmlStreamReader sr(&file);
do
{
sr.readNext();
if(sr.attributes().size() > 0)
{
for(auto jjj : sr.attributes())
{
arrayXml->insert(jjj.name().toString(), jjj.value().toString());
}
}
} while(!sr.atEnd());
if(sr.hasError())
{
qDebug() << "Error:" << sr.errorString();
result = false;
}
file.close();
}
else
{
qDebug() << "Error open file" << fileName;
result = false;
}
emit changeProgressParseXML(iii, fileList->at(iii).fileName(), result);
QThread::sleep(1);
}
emit changeProgressParseXML(fileList->size(), QString(""), true);
}