mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 00:06:16 -07:00
- Added ratio column
This commit is contained in:
parent
eb3db365e7
commit
86a0e68f46
8 changed files with 110 additions and 27 deletions
|
@ -21,6 +21,7 @@
|
||||||
- FEATURE: Added a way to link against static libtorrent (useful for deb packages)
|
- FEATURE: Added a way to link against static libtorrent (useful for deb packages)
|
||||||
- FEATURE: Allow to set global upload/download limits from tray icon menu
|
- FEATURE: Allow to set global upload/download limits from tray icon menu
|
||||||
- FEATURE: IPv6 is now fully supported
|
- FEATURE: IPv6 is now fully supported
|
||||||
|
- FEATURE: Real torrent share ratio is now displayed in transfer list
|
||||||
- I18N: Added Hungarian translation
|
- I18N: Added Hungarian translation
|
||||||
- BUGFIX: Progress of paused torrents is now correct on restart
|
- BUGFIX: Progress of paused torrents is now correct on restart
|
||||||
- BUGFIX: Progress column gets sorted on restart it is was during last execution
|
- BUGFIX: Progress column gets sorted on restart it is was during last execution
|
||||||
|
|
2
TODO
2
TODO
|
@ -35,7 +35,6 @@
|
||||||
- Check storage st creation + hasher in torrent creation
|
- Check storage st creation + hasher in torrent creation
|
||||||
- test IPv6 support
|
- test IPv6 support
|
||||||
- Display Url seeds in torrent properties and allow to edit them
|
- Display Url seeds in torrent properties and allow to edit them
|
||||||
- Improve ratio display / calculation / saving / per torrent... (beta2?)
|
|
||||||
- Sorting in Download Status column should be smarter than just an alphabetical sort
|
- Sorting in Download Status column should be smarter than just an alphabetical sort
|
||||||
- Windows port : http://www.peerweb.nl/qbittorrent/experimentalbuild/testing.zip
|
- Windows port : http://www.peerweb.nl/qbittorrent/experimentalbuild/testing.zip
|
||||||
- Write documentation
|
- Write documentation
|
||||||
|
@ -43,6 +42,7 @@
|
||||||
- Fix all (or almost all) opened bugs in bug tracker
|
- Fix all (or almost all) opened bugs in bug tracker
|
||||||
- Fix sorting with Qt 4.3 - Reported to Trolltech, waiting for fix
|
- Fix sorting with Qt 4.3 - Reported to Trolltech, waiting for fix
|
||||||
- update sorting when a new torrent is added?
|
- update sorting when a new torrent is added?
|
||||||
|
- Allow to hide columns
|
||||||
* beta2
|
* beta2
|
||||||
- Wait for some bug fixes in libtorrent :
|
- Wait for some bug fixes in libtorrent :
|
||||||
- upload/download limit per torrent
|
- upload/download limit per torrent
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#define DLSPEED 3
|
#define DLSPEED 3
|
||||||
#define UPSPEED 4
|
#define UPSPEED 4
|
||||||
#define SEEDSLEECH 5
|
#define SEEDSLEECH 5
|
||||||
#define STATUS 6
|
#define RATIO 6
|
||||||
#define ETA 7
|
#define ETA 7
|
||||||
#define HASH 8
|
#define HASH 8
|
||||||
|
|
||||||
|
@ -92,6 +92,12 @@ class DLListDelegate: public QAbstractItemDelegate {
|
||||||
painter->drawText(option.rect, Qt::AlignCenter, QString(tmp)+" "+tr("KiB/s"));
|
painter->drawText(option.rect, Qt::AlignCenter, QString(tmp)+" "+tr("KiB/s"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case RATIO:{
|
||||||
|
float ratio = index.data().toDouble();
|
||||||
|
snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio);
|
||||||
|
painter->drawText(option.rect, Qt::AlignCenter, QString(tmp));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case PROGRESS:{
|
case PROGRESS:{
|
||||||
QStyleOptionProgressBarV2 newopt;
|
QStyleOptionProgressBarV2 newopt;
|
||||||
float progress;
|
float progress;
|
||||||
|
|
|
@ -38,7 +38,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){
|
||||||
finishedListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("DL Speed", "i.e: Download speed"));
|
finishedListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("DL Speed", "i.e: Download speed"));
|
||||||
finishedListModel->setHeaderData(UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
|
finishedListModel->setHeaderData(UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
|
||||||
finishedListModel->setHeaderData(SEEDSLEECH, Qt::Horizontal, tr("Seeds/Leechs", "i.e: full/partial sources"));
|
finishedListModel->setHeaderData(SEEDSLEECH, Qt::Horizontal, tr("Seeds/Leechs", "i.e: full/partial sources"));
|
||||||
finishedListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status"));
|
finishedListModel->setHeaderData(RATIO, Qt::Horizontal, tr("Ratio"));
|
||||||
finishedListModel->setHeaderData(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left"));
|
finishedListModel->setHeaderData(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left"));
|
||||||
finishedList->setModel(finishedListModel);
|
finishedList->setModel(finishedListModel);
|
||||||
// Hide ETA & hash column
|
// Hide ETA & hash column
|
||||||
|
@ -89,6 +89,7 @@ void FinishedTorrents::addFinishedSHA(QString hash){
|
||||||
finishedListModel->setData(finishedListModel->index(row, DLSPEED), QVariant((double)0.));
|
finishedListModel->setData(finishedListModel->index(row, DLSPEED), QVariant((double)0.));
|
||||||
finishedListModel->setData(finishedListModel->index(row, UPSPEED), QVariant((double)0.));
|
finishedListModel->setData(finishedListModel->index(row, UPSPEED), QVariant((double)0.));
|
||||||
finishedListModel->setData(finishedListModel->index(row, SEEDSLEECH), QVariant("0/0"));
|
finishedListModel->setData(finishedListModel->index(row, SEEDSLEECH), QVariant("0/0"));
|
||||||
|
finishedListModel->setData(finishedListModel->index(row, RATIO), QVariant(QString(misc::toString(BTSession->getRealRatio(hash)).c_str())));
|
||||||
finishedListModel->setData(finishedListModel->index(row, ETA), QVariant((qlonglong)-1));
|
finishedListModel->setData(finishedListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
finishedListModel->setData(finishedListModel->index(row, HASH), QVariant(hash));
|
finishedListModel->setData(finishedListModel->index(row, HASH), QVariant(hash));
|
||||||
finishedListModel->setData(finishedListModel->index(row, PROGRESS), QVariant((double)1.));
|
finishedListModel->setData(finishedListModel->index(row, PROGRESS), QVariant((double)1.));
|
||||||
|
@ -99,7 +100,6 @@ void FinishedTorrents::addFinishedSHA(QString hash){
|
||||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finishedListModel->setData(finishedListModel->index(row, STATUS), QVariant(tr("Finished", "i.e: Torrent has finished downloading")));
|
|
||||||
finishedListModel->setData(finishedListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/seeding.png")), Qt::DecorationRole);
|
finishedListModel->setData(finishedListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/seeding.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "orange");
|
setRowColor(row, "orange");
|
||||||
// Create .finished file
|
// Create .finished file
|
||||||
|
@ -263,6 +263,7 @@ void FinishedTorrents::updateFinishedList(){
|
||||||
}
|
}
|
||||||
finishedListModel->setData(finishedListModel->index(row, UPSPEED), QVariant((double)torrentStatus.upload_payload_rate));
|
finishedListModel->setData(finishedListModel->index(row, UPSPEED), QVariant((double)torrentStatus.upload_payload_rate));
|
||||||
finishedListModel->setData(finishedListModel->index(row, SEEDSLEECH), QVariant(QString(misc::toString(torrentStatus.num_seeds, true).c_str())+"/"+QString(misc::toString(torrentStatus.num_peers - torrentStatus.num_seeds, true).c_str())));
|
finishedListModel->setData(finishedListModel->index(row, SEEDSLEECH), QVariant(QString(misc::toString(torrentStatus.num_seeds, true).c_str())+"/"+QString(misc::toString(torrentStatus.num_peers - torrentStatus.num_seeds, true).c_str())));
|
||||||
|
finishedListModel->setData(finishedListModel->index(row, RATIO), QVariant(QString(misc::toString(BTSession->getRealRatio(hash)).c_str())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
src/GUI.cpp
21
src/GUI.cpp
|
@ -131,7 +131,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
||||||
DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("DL Speed", "i.e: Download speed"));
|
DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("DL Speed", "i.e: Download speed"));
|
||||||
DLListModel->setHeaderData(UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
|
DLListModel->setHeaderData(UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
|
||||||
DLListModel->setHeaderData(SEEDSLEECH, Qt::Horizontal, tr("Seeds/Leechs", "i.e: full/partial sources"));
|
DLListModel->setHeaderData(SEEDSLEECH, Qt::Horizontal, tr("Seeds/Leechs", "i.e: full/partial sources"));
|
||||||
DLListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status"));
|
DLListModel->setHeaderData(RATIO, Qt::Horizontal, tr("Ratio"));
|
||||||
DLListModel->setHeaderData(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left"));
|
DLListModel->setHeaderData(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left"));
|
||||||
downloadList->setModel(DLListModel);
|
downloadList->setModel(DLListModel);
|
||||||
DLDelegate = new DLListDelegate(downloadList);
|
DLDelegate = new DLListDelegate(downloadList);
|
||||||
|
@ -305,7 +305,6 @@ void GUI::togglePausedState(const QModelIndex& index){
|
||||||
QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString();
|
QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString();
|
||||||
if(BTSession->isPaused(fileHash)){
|
if(BTSession->isPaused(fileHash)){
|
||||||
BTSession->resumeTorrent(fileHash);
|
BTSession->resumeTorrent(fileHash);
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
|
||||||
setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "grey");
|
setRowColor(row, "grey");
|
||||||
|
@ -313,7 +312,6 @@ void GUI::togglePausedState(const QModelIndex& index){
|
||||||
BTSession->pauseTorrent(fileHash);
|
BTSession->pauseTorrent(fileHash);
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
|
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
|
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
||||||
|
@ -524,7 +522,6 @@ void GUI::updateDlList(bool force){
|
||||||
if(torrentStatus.state != torrent_status::checking_files && torrentStatus.state != torrent_status::queued_for_checking){
|
if(torrentStatus.state != torrent_status::checking_files && torrentStatus.state != torrent_status::queued_for_checking){
|
||||||
qDebug("Paused torrent finished checking with state: %d", torrentStatus.state);
|
qDebug("Paused torrent finished checking with state: %d", torrentStatus.state);
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
|
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "red");
|
setRowColor(row, "red");
|
||||||
BTSession->pauseTorrent(fileHash);
|
BTSession->pauseTorrent(fileHash);
|
||||||
|
@ -555,7 +552,6 @@ void GUI::updateDlList(bool force){
|
||||||
continue;
|
continue;
|
||||||
case torrent_status::checking_files:
|
case torrent_status::checking_files:
|
||||||
case torrent_status::queued_for_checking:
|
case torrent_status::queued_for_checking:
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Checking...", "i.e: Checking already downloaded parts...")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "grey");
|
setRowColor(row, "grey");
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
|
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
|
||||||
|
@ -563,12 +559,10 @@ void GUI::updateDlList(bool force){
|
||||||
case torrent_status::connecting_to_tracker:
|
case torrent_status::connecting_to_tracker:
|
||||||
if(torrentStatus.download_payload_rate > 0){
|
if(torrentStatus.download_payload_rate > 0){
|
||||||
// Display "Downloading" status when connecting if download speed > 0
|
// Display "Downloading" status when connecting if download speed > 0
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Downloading...")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)BTSession->getETA(fileHash)));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)BTSession->getETA(fileHash)));
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/downloading.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/downloading.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "green");
|
setRowColor(row, "green");
|
||||||
}else{
|
}else{
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "grey");
|
setRowColor(row, "grey");
|
||||||
|
@ -580,12 +574,10 @@ void GUI::updateDlList(bool force){
|
||||||
case torrent_status::downloading:
|
case torrent_status::downloading:
|
||||||
case torrent_status::downloading_metadata:
|
case torrent_status::downloading_metadata:
|
||||||
if(torrentStatus.download_payload_rate > 0){
|
if(torrentStatus.download_payload_rate > 0){
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Downloading...")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/downloading.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/downloading.png")), Qt::DecorationRole);
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)BTSession->getETA(fileHash)));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)BTSession->getETA(fileHash)));
|
||||||
setRowColor(row, "green");
|
setRowColor(row, "green");
|
||||||
}else{
|
}else{
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Stalled", "i.e: State of a torrent whose download speed is 0kb/s")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/stalled.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/stalled.png")), Qt::DecorationRole);
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
setRowColor(row, "black");
|
setRowColor(row, "black");
|
||||||
|
@ -598,6 +590,7 @@ void GUI::updateDlList(bool force){
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
}
|
}
|
||||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString(misc::toString(torrentStatus.num_seeds, true).c_str())+"/"+QString(misc::toString(torrentStatus.num_peers - torrentStatus.num_seeds, true).c_str())));
|
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString(misc::toString(torrentStatus.num_seeds, true).c_str())+"/"+QString(misc::toString(torrentStatus.num_peers - torrentStatus.num_seeds, true).c_str())));
|
||||||
|
DLListModel->setData(DLListModel->index(row, RATIO), QVariant(QString(misc::toString(BTSession->getRealRatio(fileHash)).c_str())));
|
||||||
}catch(invalid_handle e){
|
}catch(invalid_handle e){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -619,11 +612,9 @@ void GUI::restoreInDownloadList(torrent_handle h){
|
||||||
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
||||||
// Pause torrent if it was paused last time
|
// Pause torrent if it was paused last time
|
||||||
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
|
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "red");
|
setRowColor(row, "red");
|
||||||
}else{
|
}else{
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "grey");
|
setRowColor(row, "grey");
|
||||||
}
|
}
|
||||||
|
@ -1093,15 +1084,14 @@ void GUI::torrentAdded(const QString& path, torrent_handle& h, bool fastResume){
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
|
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
|
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
|
||||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
|
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
|
||||||
|
DLListModel->setData(DLListModel->index(row, RATIO), QVariant(QString(misc::toString(BTSession->getRealRatio(hash)).c_str())));
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
||||||
// Pause torrent if it was paused last time
|
// Pause torrent if it was paused last time
|
||||||
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
|
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "red");
|
setRowColor(row, "red");
|
||||||
}else{
|
}else{
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "grey");
|
setRowColor(row, "grey");
|
||||||
}
|
}
|
||||||
|
@ -1337,7 +1327,6 @@ void GUI::on_actionPause_All_triggered(){
|
||||||
// Update DL list items
|
// Update DL list items
|
||||||
DLListModel->setData(DLListModel->index(i, DLSPEED), QVariant((double)0.));
|
DLListModel->setData(DLListModel->index(i, DLSPEED), QVariant((double)0.));
|
||||||
DLListModel->setData(DLListModel->index(i, UPSPEED), QVariant((double)0.));
|
DLListModel->setData(DLListModel->index(i, UPSPEED), QVariant((double)0.));
|
||||||
DLListModel->setData(DLListModel->index(i, STATUS), QVariant(tr("Paused")));
|
|
||||||
DLListModel->setData(DLListModel->index(i, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(i, ETA), QVariant((qlonglong)-1));
|
||||||
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
||||||
DLListModel->setData(DLListModel->index(i, SEEDSLEECH), QVariant("0/0"));
|
DLListModel->setData(DLListModel->index(i, SEEDSLEECH), QVariant("0/0"));
|
||||||
|
@ -1362,7 +1351,6 @@ void GUI::on_actionPause_triggered(){
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
|
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
|
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
||||||
|
@ -1385,7 +1373,6 @@ void GUI::on_actionStart_All_triggered(){
|
||||||
// Remove .paused file
|
// Remove .paused file
|
||||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
|
||||||
// Update DL list items
|
// Update DL list items
|
||||||
DLListModel->setData(DLListModel->index(i, STATUS), QVariant(tr("Connecting...", "i.e: Connecting to the tracker...")));
|
|
||||||
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||||
setRowColor(i, "grey");
|
setRowColor(i, "grey");
|
||||||
}
|
}
|
||||||
|
@ -1408,7 +1395,6 @@ void GUI::on_actionStart_triggered(){
|
||||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
|
||||||
// Update DL status
|
// Update DL status
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
|
||||||
setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "grey");
|
setRowColor(row, "grey");
|
||||||
|
@ -1474,7 +1460,6 @@ void GUI::fullDiskError(torrent_handle& h){
|
||||||
int row = getRowFromHash(QString(misc::toString(h.info_hash()).c_str()));
|
int row = getRowFromHash(QString(misc::toString(h.info_hash()).c_str()));
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
|
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
|
||||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
|
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
|
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
setInfoBar(tr("An error occured (full disk?), '%1' paused.", "e.g: An error occured (full disk?), 'xxx.avi' paused.").arg(QString(h.get_torrent_info().name().c_str())));
|
setInfoBar(tr("An error occured (full disk?), '%1' paused.", "e.g: An error occured (full disk?), 'xxx.avi' paused.").arg(QString(h.get_torrent_info().name().c_str())));
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
||||||
|
|
|
@ -146,9 +146,12 @@ void bittorrent::deleteTorrent(const QString& hash, bool permanent){
|
||||||
torrentBackup.remove(hash+".savepath");
|
torrentBackup.remove(hash+".savepath");
|
||||||
torrentBackup.remove(hash+".trackers");
|
torrentBackup.remove(hash+".trackers");
|
||||||
torrentBackup.remove(hash+".speedLimits");
|
torrentBackup.remove(hash+".speedLimits");
|
||||||
|
torrentBackup.remove(hash+".ratio");
|
||||||
// Remove it from ETAs hash tables
|
// Remove it from ETAs hash tables
|
||||||
ETAstats.take(hash);
|
ETAstats.take(hash);
|
||||||
ETAs.take(hash);
|
ETAs.take(hash);
|
||||||
|
// Remove it from ratio table
|
||||||
|
ratioData.take(hash);
|
||||||
int index = fullAllocationModeList.indexOf(hash);
|
int index = fullAllocationModeList.indexOf(hash);
|
||||||
if(index != -1)
|
if(index != -1)
|
||||||
fullAllocationModeList.removeAt(index);
|
fullAllocationModeList.removeAt(index);
|
||||||
|
@ -290,6 +293,8 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir, bool onStartu
|
||||||
loadFilesPriorities(h);
|
loadFilesPriorities(h);
|
||||||
// Load speed limit from hard drive
|
// Load speed limit from hard drive
|
||||||
loadTorrentSpeedLimits(hash);
|
loadTorrentSpeedLimits(hash);
|
||||||
|
// Load ratio data
|
||||||
|
loadDownloadUploadForTorrent(hash);
|
||||||
// Load trackers
|
// Load trackers
|
||||||
bool loaded_trackers = loadTrackerFile(hash);
|
bool loaded_trackers = loadTrackerFile(hash);
|
||||||
// Doing this to order trackers well
|
// Doing this to order trackers well
|
||||||
|
@ -528,6 +533,61 @@ void bittorrent::loadFilesPriorities(torrent_handle &h){
|
||||||
h.prioritize_files(v);
|
h.prioritize_files(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bittorrent::loadDownloadUploadForTorrent(QString hash){
|
||||||
|
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
||||||
|
// Checking if torrentBackup Dir exists
|
||||||
|
// create it if it is not
|
||||||
|
if(! torrentBackup.exists()){
|
||||||
|
torrentBackup.mkpath(torrentBackup.path());
|
||||||
|
}
|
||||||
|
qDebug("Loading ratio data for %s", (const char*)hash.toUtf8());
|
||||||
|
QFile ratio_file(torrentBackup.path()+QDir::separator()+ hash + ".ratio");
|
||||||
|
if(!ratio_file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QByteArray data = ratio_file.readAll();
|
||||||
|
QList<QByteArray> data_list = data.split(' ');
|
||||||
|
if(data_list.size() != 2){
|
||||||
|
std::cerr << "Corrupted ratio file for torrent: " << hash.toStdString() << '\n';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QPair<size_type,size_type> downUp;
|
||||||
|
downUp.first = (size_type)data_list.at(0).toLong();
|
||||||
|
downUp.second = (size_type)data_list.at(1).toLong();
|
||||||
|
ratioData[hash] = downUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To remember share ratio or a torrent, we must save current
|
||||||
|
// total_upload and total_upload and reload them on startup
|
||||||
|
void bittorrent::saveDownloadUploadForTorrent(QString hash){
|
||||||
|
qDebug("Saving ratio data");
|
||||||
|
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
||||||
|
// Checking if torrentBackup Dir exists
|
||||||
|
// create it if it is not
|
||||||
|
if(! torrentBackup.exists()){
|
||||||
|
torrentBackup.mkpath(torrentBackup.path());
|
||||||
|
}
|
||||||
|
torrent_handle h = getTorrentHandle(hash);
|
||||||
|
if(!h.is_valid()){
|
||||||
|
qDebug("/!\\ Error: Invalid handle");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
torrent_status torrentStatus = h.status();
|
||||||
|
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
|
||||||
|
QPair<size_type,size_type> ratioInfo = ratioData.value(fileHash, QPair<size_type, size_type>(0,0));
|
||||||
|
long download = torrentStatus.total_payload_download;
|
||||||
|
download += ratioInfo.first;
|
||||||
|
long upload = torrentStatus.total_payload_upload;
|
||||||
|
upload += ratioInfo.second;
|
||||||
|
QFile ratio_file(torrentBackup.path()+QDir::separator()+ fileHash + ".ratio");
|
||||||
|
if(!ratio_file.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
|
std::cerr << "Couldn't save ratio data for torrent: " << fileHash.toStdString() << '\n';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ratio_file.write(QByteArray(misc::toString(download).c_str()) + QByteArray(" ") + QByteArray(misc::toString(upload).c_str()));
|
||||||
|
ratio_file.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Save fastresume data for all torrents
|
// Save fastresume data for all torrents
|
||||||
// and remove them from the session
|
// and remove them from the session
|
||||||
void bittorrent::saveFastResumeData(){
|
void bittorrent::saveFastResumeData(){
|
||||||
|
@ -562,6 +622,8 @@ void bittorrent::saveFastResumeData(){
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), resumeData);
|
bencode(std::ostream_iterator<char>(out), resumeData);
|
||||||
}
|
}
|
||||||
|
// Save ratio data
|
||||||
|
saveDownloadUploadForTorrent(fileHash);
|
||||||
// Save trackers
|
// Save trackers
|
||||||
saveTrackerFile(fileHash);
|
saveTrackerFile(fileHash);
|
||||||
}
|
}
|
||||||
|
@ -869,6 +931,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){
|
||||||
loadFilesPriorities(new_h);
|
loadFilesPriorities(new_h);
|
||||||
// Load speed limit from hard drive
|
// Load speed limit from hard drive
|
||||||
loadTorrentSpeedLimits(fileHash);
|
loadTorrentSpeedLimits(fileHash);
|
||||||
|
// Load ratio data
|
||||||
|
loadDownloadUploadForTorrent(fileHash);
|
||||||
// Pause torrent if it was paused last time
|
// Pause torrent if it was paused last time
|
||||||
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused")){
|
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused")){
|
||||||
new_h.pause();
|
new_h.pause();
|
||||||
|
@ -884,6 +948,25 @@ int bittorrent::getListenPort() const{
|
||||||
return s->listen_port();
|
return s->listen_port();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float bittorrent::getRealRatio(QString hash) const{
|
||||||
|
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0));
|
||||||
|
size_type download = downUpInfo.first;
|
||||||
|
size_type upload = downUpInfo.second;
|
||||||
|
torrent_handle h = getTorrentHandle(hash);
|
||||||
|
torrent_status torrentStatus = h.status();
|
||||||
|
download += torrentStatus.total_payload_download;
|
||||||
|
upload += torrentStatus.total_payload_upload;
|
||||||
|
if(download == 0){
|
||||||
|
if(upload == 0)
|
||||||
|
return 1.;
|
||||||
|
return 10.;
|
||||||
|
}
|
||||||
|
float ratio = (float)upload / (float)download;
|
||||||
|
if(ratio > 10.)
|
||||||
|
ratio = 10.;
|
||||||
|
return ratio;
|
||||||
|
}
|
||||||
|
|
||||||
session_status bittorrent::getSessionStatus() const{
|
session_status bittorrent::getSessionStatus() const{
|
||||||
return s->status();
|
return s->status();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ class bittorrent : public QObject{
|
||||||
QStringList torrentsUnchecked;
|
QStringList torrentsUnchecked;
|
||||||
QHash<QString, QList<long> > ETAstats;
|
QHash<QString, QList<long> > ETAstats;
|
||||||
QHash<QString, long> ETAs;
|
QHash<QString, long> ETAs;
|
||||||
|
QHash<QString, QPair<size_type,size_type> > ratioData;
|
||||||
QTimer ETARefresher;
|
QTimer ETARefresher;
|
||||||
QList<QString> fullAllocationModeList;
|
QList<QString> fullAllocationModeList;
|
||||||
|
|
||||||
|
@ -87,6 +88,7 @@ class bittorrent : public QObject{
|
||||||
long getETA(QString hash) const;
|
long getETA(QString hash) const;
|
||||||
size_type torrentEffectiveSize(QString hash) const;
|
size_type torrentEffectiveSize(QString hash) const;
|
||||||
bool inFullAllocationMode(const QString& hash) const;
|
bool inFullAllocationMode(const QString& hash) const;
|
||||||
|
float getRealRatio(QString hash) const;
|
||||||
session* getSession() const;
|
session* getSession() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -113,6 +115,8 @@ class bittorrent : public QObject{
|
||||||
void updateETAs();
|
void updateETAs();
|
||||||
void saveTorrentSpeedLimits(QString hash);
|
void saveTorrentSpeedLimits(QString hash);
|
||||||
void loadTorrentSpeedLimits(QString hash);
|
void loadTorrentSpeedLimits(QString hash);
|
||||||
|
void saveDownloadUploadForTorrent(QString hash);
|
||||||
|
void loadDownloadUploadForTorrent(QString hash);
|
||||||
// Session configuration - Setters
|
// Session configuration - Setters
|
||||||
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
|
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
|
||||||
void setMaxConnections(int maxConnec);
|
void setMaxConnections(int maxConnec);
|
||||||
|
|
|
@ -69,17 +69,20 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h
|
||||||
upTotal->setText(misc::friendlyUnit(torrentStatus.total_payload_upload));
|
upTotal->setText(misc::friendlyUnit(torrentStatus.total_payload_upload));
|
||||||
dlTotal->setText(misc::friendlyUnit(torrentStatus.total_payload_download));
|
dlTotal->setText(misc::friendlyUnit(torrentStatus.total_payload_download));
|
||||||
// Update ratio info
|
// Update ratio info
|
||||||
if(torrentStatus.total_payload_download <= 0 || torrentStatus.total_payload_upload <= 0){
|
float ratio;
|
||||||
shareRatio->setText(tr("Unknown"));
|
if(torrentStatus.total_payload_download == 0){
|
||||||
|
if(torrentStatus.total_payload_upload == 0)
|
||||||
|
ratio = 1.;
|
||||||
|
else
|
||||||
|
ratio = 10.; // Max ratio
|
||||||
}else{
|
}else{
|
||||||
float ratio = 1.;
|
|
||||||
ratio = (float)torrentStatus.total_payload_upload/(float)torrentStatus.total_payload_download;
|
ratio = (float)torrentStatus.total_payload_upload/(float)torrentStatus.total_payload_download;
|
||||||
if(ratio > 10.){
|
if(ratio > 10.){
|
||||||
ratio = 10.;
|
ratio = 10.;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio);
|
snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio);
|
||||||
shareRatio->setText(tmp);
|
shareRatio->setText(tmp);
|
||||||
}
|
|
||||||
// Tracker Errors
|
// Tracker Errors
|
||||||
for(int i=0; i < trackerErrors.size(); ++i){
|
for(int i=0; i < trackerErrors.size(); ++i){
|
||||||
this->trackerErrors->append(trackerErrors.at(i));
|
this->trackerErrors->append(trackerErrors.at(i));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue