mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
- Display piece availability average next to the bar
This commit is contained in:
parent
0c617f0a03
commit
cdce77962a
@ -50,7 +50,8 @@ public:
|
||||
setFixedHeight(BAR_HEIGHT);
|
||||
}
|
||||
|
||||
void setAvailability(std::vector<int>& avail) {
|
||||
double setAvailability(std::vector<int>& avail) {
|
||||
double average = 0;
|
||||
if(avail.empty()) {
|
||||
// Empty bar
|
||||
pixmap = QPixmap(1, 1);
|
||||
@ -59,7 +60,7 @@ public:
|
||||
painter.drawPoint(0,0);
|
||||
} else {
|
||||
// Look for maximum value
|
||||
double average = std::accumulate(avail.begin(), avail.end(), 0)/(double)avail.size();
|
||||
average = std::accumulate(avail.begin(), avail.end(), 0)/(double)avail.size();
|
||||
uint nb_pieces = avail.size();
|
||||
pixmap = QPixmap(nb_pieces, 1);
|
||||
QPainter painter(&pixmap);
|
||||
@ -70,6 +71,7 @@ public:
|
||||
}
|
||||
}
|
||||
update();
|
||||
return average;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
|
@ -139,6 +139,7 @@ void PropertiesWidget::showPieceBars(bool show) {
|
||||
downloaded_pieces->setVisible(show);
|
||||
progress_lbl->setVisible(show);
|
||||
line_2->setVisible(show);
|
||||
avail_average_lbl->setVisible(show);
|
||||
}
|
||||
|
||||
void PropertiesWidget::reduce() {
|
||||
@ -178,6 +179,7 @@ void PropertiesWidget::clear() {
|
||||
trackerList->clear();
|
||||
downloaded_pieces->clear();
|
||||
pieces_availability->clear();
|
||||
avail_average_lbl->clear();
|
||||
wasted->clear();
|
||||
upTotal->clear();
|
||||
dlTotal->clear();
|
||||
@ -329,7 +331,8 @@ void PropertiesWidget::loadDynamicData() {
|
||||
// Pieces availability
|
||||
std::vector<int> avail;
|
||||
h.piece_availability(avail);
|
||||
pieces_availability->setAvailability(avail);
|
||||
double avail_average = pieces_availability->setAvailability(avail);
|
||||
avail_average_lbl->setText(QString::number(avail_average, 'f', 1));
|
||||
// Progress
|
||||
progress_lbl->setText(QString::number(h.progress()*100., 'f', 1)+"%");
|
||||
}
|
||||
|
@ -135,7 +135,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<widget class="QLabel" name="avail_average_lbl">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
@ -143,7 +143,10 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
<string notr="true">0.0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user