-
Notifications
You must be signed in to change notification settings - Fork 0
/
picturepath.cpp
55 lines (48 loc) · 1.16 KB
/
picturepath.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
#include "picturepath.h"
#include <QMessageBox>
QString PicturePath::filePath;
PicturePath::PicturePath()
{
}
PicturePath::~PicturePath()
{
}
//***************************************************************
QString PicturePath::getAbsFilePath(unsigned int position)
{
QFile file(filePath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
return "ERROR";
QTextStream in(&file);
in.setCodec("UTF-8");
unsigned int iterator = 0;
QString line;
while(!in.atEnd())
{
line = in.readLine();
if(iterator == position)
break;
iterator ++;
}
file.close();
return line;
}
//*********************************************************************
unsigned int PicturePath::getAbsPicsQuantity()
{
unsigned int picsQuantity = 0;
if(!filePath.isEmpty())
{
QFile file(filePath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
return 0;
QTextStream in(&file);
in.setCodec("UTF-8");
while(!in.atEnd())
{
in.readLine();
++picsQuantity;
}
}
return picsQuantity;
}