Browse Source

- Removed workaround for getting progress of paused torrents, apparently it works

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
c97bce4d61
  1. 19
      src/bittorrent.cpp
  2. 1
      src/bittorrent.h
  3. 11
      src/downloadingTorrents.cpp
  4. 1
      src/qtorrenthandle.cpp

19
src/bittorrent.cpp

@ -756,25 +756,6 @@ void bittorrent::loadFilesPriorities(QTorrentHandle &h) { @@ -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);

1
src/bittorrent.h

@ -96,7 +96,6 @@ class bittorrent : public QObject { @@ -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:

11
src/downloadingTorrents.cpp

@ -512,6 +512,8 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) { @@ -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) { @@ -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) { @@ -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) { @@ -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"));
}

1
src/qtorrenthandle.cpp

@ -323,7 +323,6 @@ void QTorrentHandle::pause() { @@ -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();
}
}

Loading…
Cancel
Save