- COSMETIC: Display "unpaused/total_torrent" in download/upload tabs

This commit is contained in:
Christophe Dumez 2008-05-18 09:26:02 +00:00
parent fc931d8c88
commit 711699e200
4 changed files with 47 additions and 6 deletions

View file

@ -17,6 +17,7 @@
- COSMETIC: Do not display progress bar in seeding list (always 100%) - COSMETIC: Do not display progress bar in seeding list (always 100%)
- COSMETIC: Added a progress bar for torrent creation - COSMETIC: Added a progress bar for torrent creation
- COSMETIC: Display tracker errors in a cleaner way - COSMETIC: Display tracker errors in a cleaner way
- COSMETIC: Display "unpaused/total_torrent" in download/upload tabs
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.0.0 * Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.0.0
- FEATURE: Based on new libtorrent v0.13 - FEATURE: Based on new libtorrent v0.13

View file

@ -127,14 +127,14 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
tabs = new QTabWidget(); tabs = new QTabWidget();
// Download torrents tab // Download torrents tab
downloadingTorrentTab = new DownloadingTorrents(this, BTSession); downloadingTorrentTab = new DownloadingTorrents(this, BTSession);
tabs->addTab(downloadingTorrentTab, tr("Downloads") + QString::fromUtf8(" (0)")); tabs->addTab(downloadingTorrentTab, tr("Downloads") + QString::fromUtf8(" (0/0)"));
tabs->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))); tabs->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/skin/downloading.png")));
vboxLayout->addWidget(tabs); vboxLayout->addWidget(tabs);
connect(downloadingTorrentTab, SIGNAL(unfinishedTorrentsNumberChanged(unsigned int)), this, SLOT(updateUnfinishedTorrentNumber(unsigned int))); connect(downloadingTorrentTab, SIGNAL(unfinishedTorrentsNumberChanged(unsigned int)), this, SLOT(updateUnfinishedTorrentNumber(unsigned int)));
connect(downloadingTorrentTab, SIGNAL(torrentDoubleClicked(QString, bool)), this, SLOT(torrentDoubleClicked(QString, bool))); connect(downloadingTorrentTab, SIGNAL(torrentDoubleClicked(QString, bool)), this, SLOT(torrentDoubleClicked(QString, bool)));
// Finished torrents tab // Finished torrents tab
finishedTorrentTab = new FinishedTorrents(this, BTSession); finishedTorrentTab = new FinishedTorrents(this, BTSession);
tabs->addTab(finishedTorrentTab, tr("Finished") + QString::fromUtf8(" (0)")); tabs->addTab(finishedTorrentTab, tr("Finished") + QString::fromUtf8(" (0/0)"));
tabs->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); tabs->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
connect(finishedTorrentTab, SIGNAL(torrentDoubleClicked(QString, bool)), this, SLOT(torrentDoubleClicked(QString, bool))); connect(finishedTorrentTab, SIGNAL(torrentDoubleClicked(QString, bool)), this, SLOT(torrentDoubleClicked(QString, bool)));
@ -1021,11 +1021,13 @@ void GUI::configureSession(bool deleteOptions) {
} }
void GUI::updateUnfinishedTorrentNumber(unsigned int nb) { void GUI::updateUnfinishedTorrentNumber(unsigned int nb) {
tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nb)+QString::fromUtf8(")")); unsigned int paused = BTSession->getUnfinishedPausedTorrentsNb();
tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
} }
void GUI::updateFinishedTorrentNumber(unsigned int nb) { void GUI::updateFinishedTorrentNumber(unsigned int nb) {
tabs->setTabText(1, tr("Finished") +QString::fromUtf8(" (")+misc::toQString(nb)+QString::fromUtf8(")")); unsigned int paused = BTSession->getFinishedPausedTorrentsNb();
tabs->setTabText(1, tr("Finished") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
} }
// Allow to change action on double-click // Allow to change action on double-click
@ -1072,15 +1074,19 @@ void GUI::togglePausedState(QString hash) {
downloadingTorrentTab->setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name())); downloadingTorrentTab->setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name()));
if(inDownloadList) { if(inDownloadList) {
downloadingTorrentTab->resumeTorrent(hash); downloadingTorrentTab->resumeTorrent(hash);
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
}else{ }else{
finishedTorrentTab->resumeTorrent(hash); finishedTorrentTab->resumeTorrent(hash);
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
} }
}else{ }else{
BTSession->pauseTorrent(hash); BTSession->pauseTorrent(hash);
if(inDownloadList) { if(inDownloadList) {
downloadingTorrentTab->pauseTorrent(hash); downloadingTorrentTab->pauseTorrent(hash);
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
}else{ }else{
finishedTorrentTab->pauseTorrent(hash); finishedTorrentTab->pauseTorrent(hash);
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
} }
downloadingTorrentTab->setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(h.name())); downloadingTorrentTab->setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(h.name()));
} }
@ -1104,9 +1110,12 @@ void GUI::on_actionPause_All_triggered() {
finishedTorrentTab->pauseTorrent(hash); finishedTorrentTab->pauseTorrent(hash);
} }
} }
if(change) if(change) {
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
downloadingTorrentTab->setInfoBar(tr("All downloads were paused.")); downloadingTorrentTab->setInfoBar(tr("All downloads were paused."));
} }
}
// pause selected items in the list // pause selected items in the list
void GUI::on_actionPause_triggered() { void GUI::on_actionPause_triggered() {
@ -1125,8 +1134,10 @@ void GUI::on_actionPause_triggered() {
if(BTSession->pauseTorrent(hash)){ if(BTSession->pauseTorrent(hash)){
if(inDownloadList) { if(inDownloadList) {
downloadingTorrentTab->pauseTorrent(hash); downloadingTorrentTab->pauseTorrent(hash);
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
} else { } else {
finishedTorrentTab->pauseTorrent(hash); finishedTorrentTab->pauseTorrent(hash);
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
} }
downloadingTorrentTab->setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(BTSession->getTorrentHandle(hash).name())); downloadingTorrentTab->setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(BTSession->getTorrentHandle(hash).name()));
} }
@ -1136,6 +1147,8 @@ void GUI::on_actionPause_triggered() {
void GUI::pauseTorrent(QString hash) { void GUI::pauseTorrent(QString hash) {
downloadingTorrentTab->pauseTorrent(hash); downloadingTorrentTab->pauseTorrent(hash);
finishedTorrentTab->pauseTorrent(hash); finishedTorrentTab->pauseTorrent(hash);
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
} }
// Resume All Downloads in DL list // Resume All Downloads in DL list
@ -1156,9 +1169,12 @@ void GUI::on_actionStart_All_triggered() {
finishedTorrentTab->resumeTorrent(hash); finishedTorrentTab->resumeTorrent(hash);
} }
} }
if(change) if(change) {
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
downloadingTorrentTab->setInfoBar(tr("All downloads were resumed.")); downloadingTorrentTab->setInfoBar(tr("All downloads were resumed."));
} }
}
// start selected items in the list // start selected items in the list
void GUI::on_actionStart_triggered() { void GUI::on_actionStart_triggered() {
@ -1177,8 +1193,10 @@ void GUI::on_actionStart_triggered() {
if(BTSession->resumeTorrent(hash)){ if(BTSession->resumeTorrent(hash)){
if(inDownloadList) { if(inDownloadList) {
downloadingTorrentTab->resumeTorrent(hash); downloadingTorrentTab->resumeTorrent(hash);
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
} else { } else {
finishedTorrentTab->resumeTorrent(hash); finishedTorrentTab->resumeTorrent(hash);
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
} }
downloadingTorrentTab->setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(BTSession->getTorrentHandle(hash).name())); downloadingTorrentTab->setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(BTSession->getTorrentHandle(hash).name()));
} }

View file

@ -203,6 +203,26 @@ bool bittorrent::isPaused(QString hash) const{
return h.is_paused(); return h.is_paused();
} }
unsigned int bittorrent::getFinishedPausedTorrentsNb() const {
unsigned int nbPaused = 0;
foreach(QString hash, finishedTorrents) {
if(isPaused(hash)) {
++nbPaused;
}
}
return nbPaused;
}
unsigned int bittorrent::getUnfinishedPausedTorrentsNb() const {
unsigned int nbPaused = 0;
foreach(QString hash, unfinishedTorrents) {
if(isPaused(hash)) {
++nbPaused;
}
}
return nbPaused;
}
// Delete a torrent from the session, given its hash // Delete a torrent from the session, given its hash
// permanent = true means that the torrent will be removed from the hard-drive too // permanent = true means that the torrent will be removed from the hard-drive too
void bittorrent::deleteTorrent(QString hash, bool permanent) { void bittorrent::deleteTorrent(QString hash, bool permanent) {

View file

@ -95,6 +95,8 @@ class bittorrent : public QObject{
QStringList getUnfinishedTorrents() const; QStringList getUnfinishedTorrents() const;
bool isFinished(QString hash) const; bool isFinished(QString hash) const;
bool has_filtered_files(QString hash) const; bool has_filtered_files(QString hash) const;
unsigned int getFinishedPausedTorrentsNb() const;
unsigned int getUnfinishedPausedTorrentsNb() const;
public slots: public slots:
void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false); void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);