-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.cpp
More file actions
executable file
·65 lines (62 loc) · 1.76 KB
/
Copy pathparser.cpp
File metadata and controls
executable file
·65 lines (62 loc) · 1.76 KB
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
59
60
61
62
63
64
65
#include "parser.h"
parser::parser(QObject *parent) :
QObject(parent)
{
}
void parser::setDialogManager(dialogs *dm)
{
dialogsManager = dm;
}
void parser::SLOTparse(const QString &path)
{
QFile priceList(path);
QString line;
if (!priceList.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug() << "LOL";
}
QString vendorName = dialogsManager->getText();
emit SIGNALsetVendor(vendorName);
int n = 0;
QByteArray buf = priceList.readLine();
do {
buf = priceList.readLine();
n++;
} while (!buf.isEmpty());
int oneProcent = n/100;
int currentCount = 0;
int labelCount = 0;
int allCount = 0;
priceList.seek(0);
QTextStream stream( &priceList );
line = stream.readLine();
QStringList fields;
QString additionalLine;
emit SIGNALstartParsing(n);
while (!stream.atEnd()) {
line = stream.readLine();
if(line.count(';')<2){
additionalLine = stream.readLine();
line += additionalLine;
}
fields = line.split(";");
allCount++;
currentCount++;
if(currentCount == oneProcent){
emit SIGNALupDateProgressBar();
currentCount = 0;
}
labelCount++;
if(labelCount == 5){
emit SIGNALuodateLabelCount(allCount, n);
labelCount = 0;
}
if(fields.at(0) == "" || fields.at(2) == ""){
continue;
}
QString tempString = fields.at(2);
tempString.replace(',', '.');
emit SIGNALaddToDb(fields.at(0), fields.at(1), tempString.toFloat());
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
}
emit SIGNALfinalParsing();
}