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