-
Notifications
You must be signed in to change notification settings - Fork 0
/
torWindow.cpp
70 lines (51 loc) · 1.51 KB
/
torWindow.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "torWindow.h"
using namespace TransmissionRC::Terminal;
void
torWindow::Draw(std::shared_ptr<std::vector<rcTorrent>> torrents){
werase(win);
for(int i=0,t=offset;torrents !=nullptr &&t<torrents->size();i++,t++){
int posy = i+(i*3);
if(posy/4>=winH/4){
break;
}
if(posy==my){
wattron(win,A_STANDOUT);
wattron(win,COLOR_PAIR(1));
}
std::string ln = (*torrents)[t].Name;
//ln.insert(ln.length(),winW-ln.length(),' ');
mvwprintw(win,posy,0,ln.substr(0,winW-1).c_str());
posy++;
ln ="";
ln.insert(ln.begin(),
(winW-2)*(*torrents)[t].percentDone,'=');
ln.insert(ln.end(),
(winW-2)*(1-(*torrents)[t].percentDone),'-');
ln.insert(ln.begin(),1,'[');
ln.insert(ln.end(),1,']');
std::stringstream strper;
strper<<((*torrents)[t].percentDone*100);
ln.replace(((ln.length()-2)/2)-(strper.str().length()/2),
strper.str().length(),
strper.str().c_str());
mvwprintw(win,posy,0,ln.c_str());
posy++;
strper.str(std::string());
strper<<std::string("["+std::string(
c_trStatus[(*torrents)[t].Status])+"]")
<<" "<<"D:"
<<Utility::convertTransferSpeed(
(*torrents)[t].rateDownload).get()
<<" "<<"U:"
<<Utility::convertTransferSpeed(
(*torrents)[t].rateUpload).get();
ln = strper.str();
//ln.insert(ln.length(),winW-ln.length(),' ');
mvwprintw(win,posy,0,ln.c_str());
wattroff(win,A_STANDOUT);
wattroff(win,COLOR_PAIR(1));
}
wrefresh(win);
}
void
torWindow::Draw(rcTorrent torrent){}