mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
- Removed workaround for getting progress of paused torrents, apparently it works
This commit is contained in:
parent
afbfe1a96d
commit
c97bce4d61
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -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…
x
Reference in New Issue
Block a user