-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathint64filereader.cpp
More file actions
48 lines (40 loc) · 911 Bytes
/
int64filereader.cpp
File metadata and controls
48 lines (40 loc) · 911 Bytes
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
#include "int64filereader.h"
Int64FileReader::Int64FileReader(QFile& sourceFile, QObject *parent)
: QObject(parent)
, _percent(0)
, _file(sourceFile)
{
}
qint64 Int64FileReader::readNextNumber(bool* ok)
{
QString number;
while (!_file.atEnd())
{
QByteArray nextChar = _file.read(1);
if (nextChar.isEmpty())
break;
if (nextChar[0] == ' ')
break;
if (nextChar[0] == '\n')
break;
number.append(nextChar);
}
setPercent(_file.pos() * 100 / _file.size());
if (number.isEmpty())
{
*ok = false;
return 0;
}
return number.toLongLong(ok);
}
bool Int64FileReader::isFinished() const
{
return _file.atEnd();
}
void Int64FileReader::setPercent(int percent)
{
if (_percent == percent)
return;
_percent = percent;
emit completePercentChanged(percent);
}