From eca262f5f490ed48b197367dd5eef0aeea9a180f Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 2 Dec 2009 20:41:59 +0000 Subject: [PATCH] - Display piece_availability bar when we have something to display (torrent has metadata, torrent is not paused/queued/checking/seeding) --- src/propertieswidget.cpp | 30 +++++++++++++++++++----------- src/propertieswidget.h | 3 ++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 9477592c0..91a76d8ff 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -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() { shareRatio->clear(); listWebSeeds->clear(); PropListModel->clear(); - showPieceBars(false); + showPiecesAvailability(false); + showPiecesDownloaded(false); setEnabled(false); } @@ -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() { 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 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; } diff --git a/src/propertieswidget.h b/src/propertieswidget.h index cbbab14f3..44d481b05 100644 --- a/src/propertieswidget.h +++ b/src/propertieswidget.h @@ -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();