diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index ab78fd259..3c465c282 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -756,25 +756,6 @@ void bittorrent::loadFilesPriorities(QTorrentHandle &h) { h.prioritize_files(v); } -float bittorrent::getUncheckedTorrentProgress(QString hash) const { - QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"); - paused_file.open(QIODevice::ReadOnly | QIODevice::Text); - if(!paused_file.exists()) { - return 0.; - } - QByteArray progress_char = paused_file.readAll(); - qDebug("Read progress: %s", (const char*)progress_char.data()); - paused_file.close(); - bool ok = false; - float progress = progress_char.toFloat(&ok); - if(!ok) { - qDebug("Error converting progress in .paused file!"); - return 0.; - } - qDebug("Unchecked torrent progress is %f", progress); - return progress; -} - float bittorrent::getRealRatio(QString hash) const{ QTorrentHandle h = getTorrentHandle(hash); Q_ASSERT(h.all_time_download() >= 0); diff --git a/src/bittorrent.h b/src/bittorrent.h index 6fb2cb7d2..fb6bc6a23 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -96,7 +96,6 @@ class bittorrent : public QObject { int loadTorrentPriority(QString hash); QStringList getConsoleMessages() const; QStringList getPeerBanMessages() const; - float getUncheckedTorrentProgress(QString hash) const; qlonglong getETA(QString hash) const; public slots: diff --git a/src/downloadingTorrents.cpp b/src/downloadingTorrents.cpp index fd659804f..a722d4042 100644 --- a/src/downloadingTorrents.cpp +++ b/src/downloadingTorrents.cpp @@ -512,6 +512,8 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) { return added; } } + if(!downloadList->isColumnHidden(PROGRESS)) + DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); // No need to update a paused torrent if(h.is_paused()) return added; // Parse download state @@ -521,9 +523,6 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) { case torrent_status::queued_for_checking: DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/time.png"))), Qt::DecorationRole); setRowColor(row, QString::fromUtf8("grey")); - if(!downloadList->isColumnHidden(PROGRESS)) { - DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); - } break; case torrent_status::downloading: case torrent_status::downloading_metadata: @@ -540,9 +539,6 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) { } setRowColor(row, QApplication::palette().color(QPalette::WindowText)); } - if(!downloadList->isColumnHidden(PROGRESS)) { - DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); - } if(!downloadList->isColumnHidden(DLSPEED)) { DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)h.download_payload_rate())); } @@ -578,17 +574,16 @@ void DownloadingTorrents::addTorrent(QString hash) { DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.)); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.)); DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0"))); + DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); if(BTSession->isQueueingEnabled()) DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash))); DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash)); // Pause torrent if it is if(h.is_paused()) { - DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)BTSession->getUncheckedTorrentProgress(hash))); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole); setRowColor(row, QString::fromUtf8("red")); }else{ - DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress())); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalled.png"))), Qt::DecorationRole); setRowColor(row, QString::fromUtf8("grey")); } diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index b7236a3c2..a426d2782 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -323,7 +323,6 @@ void QTorrentHandle::pause() { if(!QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused")) { QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused"); paused_file.open(QIODevice::WriteOnly | QIODevice::Text); - paused_file.write(QByteArray::number((double)progress())); paused_file.close(); } }