-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathTransFileModel.cpp
More file actions
152 lines (119 loc) · 3.02 KB
/
Copy pathTransFileModel.cpp
File metadata and controls
152 lines (119 loc) · 3.02 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "config.h"
#include "iptux-core/TransFileModel.h"
#include "iptux-utils/utils.h"
#include <glib.h>
namespace iptux {
TransFileModel::TransFileModel()
: fileLength(0), finishedLength(0), finished(false) {}
TransFileModel& TransFileModel::setStatus(const std::string& value) {
status = value;
return *this;
}
TransFileModel& TransFileModel::setTask(const std::string& value) {
task = value;
return *this;
}
TransFileModel& TransFileModel::setPeer(const std::string& value) {
peer = value;
return *this;
}
TransFileModel& TransFileModel::setIp(const std::string& value) {
ip = value;
return *this;
}
TransFileModel& TransFileModel::setFilename(const std::string& value) {
filename = value;
return *this;
}
TransFileModel& TransFileModel::setFileLength(int64_t value) {
fileLength = value;
return *this;
}
TransFileModel& TransFileModel::setFinishedLength(int64_t value) {
finishedLength = value;
return *this;
}
TransFileModel& TransFileModel::setCost(const std::string& value) {
cost = value;
return *this;
}
TransFileModel& TransFileModel::setRemain(const std::string& value) {
remain = value;
return *this;
}
TransFileModel& TransFileModel::setRate(const std::string& value) {
rate = value;
return *this;
}
TransFileModel& TransFileModel::setFilePath(const std::string& value) {
filePath = value;
return *this;
}
TransFileModel& TransFileModel::setTaskId(int taskId) {
this->taskId = taskId;
return *this;
}
void TransFileModel::finish() {
finished = true;
}
const std::string& TransFileModel::getStatus() const {
return status;
}
const std::string& TransFileModel::getTask() const {
return task;
}
const std::string& TransFileModel::getPeer() const {
return peer;
}
const std::string& TransFileModel::getIp() const {
return ip;
}
const std::string& TransFileModel::getFilename() const {
return filename;
}
std::string TransFileModel::getFileLengthText() const {
const char* t = numeric_to_size(fileLength);
std::string res(t);
g_free(gpointer(t));
return res;
}
std::string TransFileModel::getFinishedLengthText() const {
const char* t = numeric_to_size(finishedLength);
std::string res(t);
g_free(gpointer(t));
return res;
}
double TransFileModel::getProgress() const {
if (fileLength <= 0) {
return 0.0; // Avoid division by zero
}
return percent(finishedLength, fileLength);
}
std::string TransFileModel::getProgressText() const {
const char* t = g_strdup_printf("%.1f", getProgress());
std::string res(t);
g_free(gpointer(t));
return res;
}
const std::string& TransFileModel::getCost() const {
return cost;
}
const std::string& TransFileModel::getRemain() const {
return remain;
}
const std::string& TransFileModel::getRate() const {
return rate;
}
const std::string& TransFileModel::getFilePath() const {
return filePath;
}
int64_t TransFileModel::getFileLength() const {
return fileLength;
}
bool TransFileModel::isFinished() const {
return finished;
}
int TransFileModel::getTaskId() const {
return taskId;
}
} // namespace iptux