Browse Source

- Display piece_availability bar when we have something to display (torrent has metadata, torrent is not paused/queued/checking/seeding)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
eca262f5f4
  1. 30
      src/propertieswidget.cpp
  2. 3
      src/propertieswidget.h

30
src/propertieswidget.cpp

@ -132,14 +132,21 @@ PropertiesWidget::~PropertiesWidget() { @@ -132,14 +132,21 @@ PropertiesWidget::~PropertiesWidget() {
delete actionHigh;
}
void PropertiesWidget::showPieceBars(bool show) {
void PropertiesWidget::showPiecesAvailability(bool show) {
avail_pieces_lbl->setVisible(show);
pieces_availability->setVisible(show);
avail_average_lbl->setVisible(show);
if(show || (!show && !downloaded_pieces->isVisible()))
line_2->setVisible(show);
}
void PropertiesWidget::showPiecesDownloaded(bool show) {
downloaded_pieces_lbl->setVisible(show);
downloaded_pieces->setVisible(show);
progress_lbl->setVisible(show);
line_2->setVisible(show);
avail_average_lbl->setVisible(show);
if(show || (!show && !pieces_availability->isVisible()))
line_2->setVisible(show);
}
void PropertiesWidget::reduce() {
@ -191,7 +198,8 @@ void PropertiesWidget::clear() { @@ -191,7 +198,8 @@ void PropertiesWidget::clear() {
shareRatio->clear();
listWebSeeds->clear();
PropListModel->clear();
showPieceBars(false);
showPiecesAvailability(false);
showPiecesDownloaded(false);
setEnabled(false);
}
@ -213,10 +221,6 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { @@ -213,10 +221,6 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
setEnabled(true);
try {
if(!h.is_seed())
showPieceBars(true);
else
showPieceBars(false);
// Save path
save_path->setText(TorrentPersistentData::getSavePath(h.hash()));
// Creation date
@ -327,20 +331,24 @@ void PropertiesWidget::loadDynamicData() { @@ -327,20 +331,24 @@ void PropertiesWidget::loadDynamicData() {
else
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1)));
if(!h.is_seed()) {
showPieceBars(true);
showPiecesDownloaded(true);
// Downloaded pieces
downloaded_pieces->setProgress(h.pieces());
// Pieces availability
if(h.has_metadata()) {
if(h.has_metadata() && !h.is_paused() && !h.is_queued() && !h.is_checking()) {
showPiecesAvailability(true);
std::vector<int> avail;
h.piece_availability(avail);
double avail_average = pieces_availability->setAvailability(avail);
avail_average_lbl->setText(QString::number(avail_average, 'f', 1));
} else {
showPiecesAvailability(false);
}
// Progress
progress_lbl->setText(QString::number(h.progress()*100., 'f', 1)+"%");
} else {
showPieceBars(false);
showPiecesAvailability(false);
showPiecesDownloaded(false);
}
return;
}

3
src/propertieswidget.h

@ -95,7 +95,8 @@ protected slots: @@ -95,7 +95,8 @@ protected slots:
void displayFilesListMenu(const QPoint& pos);
void on_changeSavePathButton_clicked();
void filteredFilesChanged();
void showPieceBars(bool show);
void showPiecesDownloaded(bool show);
void showPiecesAvailability(bool show);
public slots:
void loadDynamicData();

Loading…
Cancel
Save