-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathread_file.cpp
More file actions
119 lines (74 loc) · 2.17 KB
/
read_file.cpp
File metadata and controls
119 lines (74 loc) · 2.17 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "read_file.h"
#include <QString>
#include <QFile>
#include <QIODevice>
#include <QWidget>
#include <QTextBrowser>
#include <QDialog>
#include "ui_all_trade_reports.h"
read_file::read_file(QString add)
{
address=add;
}
read_file::read_file(){
}
QString read_file::read_name(){
QFile file(address);
file.open(QFile::ReadOnly);
int i=0;
int n=0;
while(!file.atEnd()){ //find numbers of line in file
file.readLine();
i++;
}
file.QFile::seek(0);
while(!file.atEnd()){
n++;
QString line=file.readLine();
if(n==i){
return line;
}
}
file.close();
}
double read_file::read_num(){
QFile file(address);
file.open(QFile::ReadOnly);
int i=0;
int n=0;
while(!file.atEnd()){ //find numbers of line in file
file.readLine();
i++;
}
file.QFile::seek(0);
while(!file.atEnd()){
n++;
double line=file.readLine().toDouble();
if(n==i){
return line;
}
}
file.close();
}
/*
void read_file::read_all(QTextBrowser x,QString addname,QString addentry,QString addclose){
QFile file_name(addname);
QFile file_entry(addentry);
QFile file_close(addclose);
file_name.open(QFile::ReadOnly);
file_entry.open(QFile::ReadOnly);
file_close.open(QFile::ReadOnly);
while(!file_name.atEnd()){
QString entry=file_entry.readLine();
QString close=file_close.readLine();
x.QTextBrowser::append("نام " +file_name.readLine());
x.QTextBrowser::append("قیمت ورود : "+entry);
x.QTextBrowser::append("قیمت خروج : "+close);
x.QTextBrowser::append("سود درصدی شما از این معامله : "+QString::number((close.toDouble()/entry.toDouble()-1.01)*100));
x.QTextBrowser::append("--------------------------------");
}
file_entry.close();
file_name.close();
file_close.close();
}
*/