mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 05:27:15 +03:00
- Removed code that is no longer needed
This commit is contained in:
parent
1225d16413
commit
c38a8a2bec
4 changed files with 11 additions and 69 deletions
15
src/GUI.cpp
15
src/GUI.cpp
|
@ -127,7 +127,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
|||
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
|
||||
connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString)));
|
||||
connect(BTSession, SIGNAL(deletedTorrent(QString)), this, SLOT(deleteTorrent(QString)));
|
||||
connect(BTSession, SIGNAL(pausedTorrent(QString)), this, SLOT(pauseTorrent(QString)));
|
||||
qDebug("create tabWidget");
|
||||
tabs = new QTabWidget();
|
||||
// Download torrents tab
|
||||
|
@ -1185,8 +1184,8 @@ void GUI::togglePausedState(QString hash) {
|
|||
if(tabs->currentIndex() == 1)
|
||||
inDownloadList = false;
|
||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
if(BTSession->isPaused(hash)) {
|
||||
BTSession->resumeTorrent(hash);
|
||||
if(h.is_paused()) {
|
||||
h.resume();
|
||||
if(inDownloadList) {
|
||||
downloadingTorrentTab->resumeTorrent(hash);
|
||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||
|
@ -1195,7 +1194,7 @@ void GUI::togglePausedState(QString hash) {
|
|||
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
|
||||
}
|
||||
}else{
|
||||
BTSession->pauseTorrent(hash);
|
||||
h.pause();
|
||||
if(inDownloadList) {
|
||||
downloadingTorrentTab->pauseTorrent(hash);
|
||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||
|
@ -1262,7 +1261,9 @@ void GUI::on_actionPause_triggered() {
|
|||
}
|
||||
QString hash;
|
||||
foreach(hash, hashes) {
|
||||
if(BTSession->pauseTorrent(hash)){
|
||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
if(!h.is_paused()){
|
||||
h.pause();
|
||||
if(inDownloadList) {
|
||||
downloadingTorrentTab->pauseTorrent(hash);
|
||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||
|
@ -1319,7 +1320,9 @@ void GUI::on_actionStart_triggered() {
|
|||
}
|
||||
QString hash;
|
||||
foreach(hash, hashes) {
|
||||
if(BTSession->resumeTorrent(hash)){
|
||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
if(!h.is_paused()){
|
||||
h.resume();
|
||||
if(inDownloadList) {
|
||||
downloadingTorrentTab->resumeTorrent(hash);
|
||||
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
|
||||
|
|
|
@ -225,17 +225,6 @@ QTorrentHandle bittorrent::getTorrentHandle(QString hash) const{
|
|||
return QTorrentHandle(s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))));
|
||||
}
|
||||
|
||||
// Return true if the torrent corresponding to the
|
||||
// hash is paused
|
||||
bool bittorrent::isPaused(QString hash) const{
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
if(!h.is_valid()) {
|
||||
qDebug("/!\\ Error: Invalid handle");
|
||||
return true;
|
||||
}
|
||||
return h.is_paused();
|
||||
}
|
||||
|
||||
unsigned int bittorrent::getFinishedPausedTorrentsNb() const {
|
||||
unsigned int nbPaused = 0;
|
||||
std::vector<torrent_handle> torrents = getTorrents();
|
||||
|
@ -298,53 +287,6 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) {
|
|||
emit deletedTorrent(hash);
|
||||
}
|
||||
|
||||
// Pause a running torrent
|
||||
bool bittorrent::pauseTorrent(QString hash) {
|
||||
bool change = false;
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
if(h.is_valid() && !h.is_paused()) {
|
||||
h.pause();
|
||||
change = true;
|
||||
// Save fast resume data
|
||||
saveFastResumeData(hash);
|
||||
qDebug("Torrent paused successfully");
|
||||
emit pausedTorrent(hash);
|
||||
}else{
|
||||
if(!h.is_valid()) {
|
||||
qDebug("Could not pause torrent %s, reason: invalid", hash.toUtf8().data());
|
||||
}else{
|
||||
qDebug("Could not pause torrent %s, reason: already paused", hash.toUtf8().data());
|
||||
}
|
||||
}
|
||||
// Create .paused file if necessary
|
||||
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
||||
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
paused_file.write(QByteArray::number((double)h.progress()));
|
||||
paused_file.close();
|
||||
if(change) {
|
||||
addConsoleMessage(tr("'%1' paused.", "e.g: xxx.avi paused.").arg(h.name()));
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
// Resume a torrent in paused state
|
||||
bool bittorrent::resumeTorrent(QString hash) {
|
||||
bool change = false;
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
if(h.is_valid() && h.is_paused()) {
|
||||
h.resume();
|
||||
change = true;
|
||||
emit resumedTorrent(hash);
|
||||
}
|
||||
// Delete .paused file
|
||||
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
||||
if(change) {
|
||||
addConsoleMessage(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name()));
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
void bittorrent::pauseAllTorrents() {
|
||||
std::vector<torrent_handle> torrents = getTorrents();
|
||||
std::vector<torrent_handle>::iterator torrentIT;
|
||||
|
|
|
@ -76,7 +76,6 @@ class bittorrent : public QObject {
|
|||
~bittorrent();
|
||||
QTorrentHandle getTorrentHandle(QString hash) const;
|
||||
std::vector<torrent_handle> getTorrents() const;
|
||||
bool isPaused(QString hash) const;
|
||||
bool isFilePreviewPossible(QString fileHash) const;
|
||||
bool isDHTEnabled() const;
|
||||
float getPayloadDownloadRate() const;
|
||||
|
@ -107,8 +106,6 @@ class bittorrent : public QObject {
|
|||
void downloadFromUrl(QString url);
|
||||
void downloadFromURLList(const QStringList& url_list);
|
||||
void deleteTorrent(QString hash, bool permanent = false);
|
||||
bool pauseTorrent(QString hash);
|
||||
bool resumeTorrent(QString hash);
|
||||
void pauseAllTorrents();
|
||||
void resumeAllTorrents();
|
||||
void saveDHTEntry();
|
||||
|
|
|
@ -589,8 +589,8 @@ void DownloadingTorrents::addTorrent(QString hash) {
|
|||
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 was paused last time
|
||||
if(BTSession->isPaused(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"));
|
||||
|
|
Loading…
Reference in a new issue