mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
- Improved start/Pause & start_all/pause_all functions
This commit is contained in:
parent
0a144708d8
commit
c6285d8f67
7
TODO
7
TODO
@ -48,4 +48,9 @@
|
||||
- Wait for some bug fixes in libtorrent :
|
||||
- upload/download limit per torrent
|
||||
- double free or corruption on exit
|
||||
- Crash due to connection_queue
|
||||
- Crash due to connection_queue
|
||||
LANGUAGES UPDATED:
|
||||
- French
|
||||
- English
|
||||
- Japanese
|
||||
- Swedish
|
55
src/GUI.cpp
55
src/GUI.cpp
@ -588,6 +588,8 @@ void GUI::updateDlList(bool force){
|
||||
setRowColor(row, "red");
|
||||
BTSession->pauseTorrent(fileHash);
|
||||
continue;
|
||||
}else{
|
||||
qDebug("%s should be paused but it hasn't finished checking yet", (const char*)DLListModel->index(row, NAME).data().toString().toUtf8());
|
||||
}
|
||||
}
|
||||
if(delayedSorting && BTSession->getUncheckedTorrentsList().indexOf(fileHash) != -1){
|
||||
@ -1370,16 +1372,12 @@ void GUI::configureSession(bool deleteOptions){
|
||||
// Pause All Downloads in DL list
|
||||
void GUI::on_actionPause_All_triggered(){
|
||||
QString fileHash;
|
||||
// Pause all torrents
|
||||
if(BTSession->pauseAllTorrents()){
|
||||
// update download list
|
||||
unsigned int nbRows = DLListModel->rowCount();
|
||||
for(unsigned int i=0; i<nbRows; ++i){
|
||||
fileHash = DLListModel->data(DLListModel->index(i, HASH)).toString();
|
||||
// Create .paused file
|
||||
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
|
||||
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
paused_file.close();
|
||||
bool change = false;
|
||||
// update download list
|
||||
unsigned int nbRows = DLListModel->rowCount();
|
||||
for(unsigned int i=0; i<nbRows; ++i){
|
||||
fileHash = DLListModel->data(DLListModel->index(i, HASH)).toString();
|
||||
if(BTSession->pauseTorrent(fileHash)){
|
||||
// Update DL list items
|
||||
DLListModel->setData(DLListModel->index(i, DLSPEED), QVariant((double)0.));
|
||||
DLListModel->setData(DLListModel->index(i, UPSPEED), QVariant((double)0.));
|
||||
@ -1387,9 +1385,11 @@ void GUI::on_actionPause_All_triggered(){
|
||||
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
||||
DLListModel->setData(DLListModel->index(i, SEEDSLEECH), QVariant("0/0"));
|
||||
setRowColor(i, "red");
|
||||
change = true;
|
||||
}
|
||||
setInfoBar(tr("All downloads were paused."));
|
||||
}
|
||||
if(change)
|
||||
setInfoBar(tr("All downloads were paused."));
|
||||
}
|
||||
|
||||
// pause selected items in the list
|
||||
@ -1400,9 +1400,7 @@ void GUI::on_actionPause_triggered(){
|
||||
if(index.column() == NAME){
|
||||
// Get the file name
|
||||
QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
||||
if(!BTSession->isPaused(fileHash)){
|
||||
// Pause the torrent
|
||||
BTSession->pauseTorrent(fileHash);
|
||||
if(BTSession->pauseTorrent(fileHash)){
|
||||
// Update DL status
|
||||
int row = index.row();
|
||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
|
||||
@ -1420,20 +1418,19 @@ void GUI::on_actionPause_triggered(){
|
||||
// Resume All Downloads in DL list
|
||||
void GUI::on_actionStart_All_triggered(){
|
||||
QString fileHash;
|
||||
// Pause all torrents
|
||||
if(BTSession->resumeAllTorrents()){
|
||||
// update download list
|
||||
unsigned int nbRows = DLListModel->rowCount();
|
||||
for(unsigned int i=0; i<nbRows; ++i){
|
||||
fileHash = DLListModel->data(DLListModel->index(i, HASH)).toString();
|
||||
// Remove .paused file
|
||||
if(QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused")){
|
||||
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||
setRowColor(i, "grey");
|
||||
}
|
||||
unsigned int nbRows = DLListModel->rowCount();
|
||||
bool change = false;
|
||||
for(unsigned int i=0; i<nbRows; ++i){
|
||||
fileHash = DLListModel->data(DLListModel->index(i, HASH)).toString();
|
||||
// Remove .paused file
|
||||
if(BTSession->resumeTorrent(fileHash)){
|
||||
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||
setRowColor(i, "grey");
|
||||
change = true;
|
||||
}
|
||||
setInfoBar(tr("All downloads were resumed."));
|
||||
}
|
||||
if(change)
|
||||
setInfoBar(tr("All downloads were resumed."));
|
||||
}
|
||||
|
||||
// start selected items in the list
|
||||
@ -1444,11 +1441,7 @@ void GUI::on_actionStart_triggered(){
|
||||
if(index.column() == NAME){
|
||||
// Get the file name
|
||||
QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
||||
if(BTSession->isPaused(fileHash)){
|
||||
// Resume the torrent
|
||||
BTSession->resumeTorrent(fileHash);
|
||||
// Delete .paused file
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
|
||||
if(BTSession->resumeTorrent(fileHash)){
|
||||
// Update DL status
|
||||
int row = index.row();
|
||||
setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(QString(BTSession->getTorrentHandle(fileHash).name().c_str())));
|
||||
|
@ -190,33 +190,48 @@ void bittorrent::cleanDeleter(deleteThread* deleter){
|
||||
}
|
||||
|
||||
// Pause a running torrent
|
||||
void bittorrent::pauseTorrent(QString hash){
|
||||
bool bittorrent::pauseTorrent(QString hash){
|
||||
bool change = false;
|
||||
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
|
||||
if(h.is_valid() && !h.is_paused()){
|
||||
h.pause();
|
||||
// Create .paused file
|
||||
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
||||
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
paused_file.close();
|
||||
change = true;
|
||||
qDebug("Torrent paused successfully");
|
||||
}else{
|
||||
qDebug("Could not pause torrent, invalid or already paused.");
|
||||
}
|
||||
// Create .paused file if necessary
|
||||
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.close();
|
||||
}
|
||||
// Remove from the list of torrents to pause after checking
|
||||
int index = torrentsToPauseAfterChecking.indexOf(hash);
|
||||
if(index != -1) {
|
||||
torrentsToPauseAfterChecking.removeAt(index);
|
||||
qDebug("A torrent was paused just after checking, good");
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
// Resume a torrent in paused state
|
||||
void bittorrent::resumeTorrent(QString hash){
|
||||
bool bittorrent::resumeTorrent(QString hash){
|
||||
bool success = false;
|
||||
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
|
||||
if(h.is_valid() && h.is_paused()){
|
||||
h.resume();
|
||||
// Delete .paused file
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
||||
success = true;
|
||||
}
|
||||
// Delete .paused file
|
||||
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
||||
int index = torrentsToPauseAfterChecking.indexOf(hash);
|
||||
if(index != -1){
|
||||
torrentsToPauseAfterChecking.removeAt(index);
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void bittorrent::loadWebSeeds(QString fileHash){
|
||||
@ -811,34 +826,6 @@ void bittorrent::saveTrackerFile(QString hash){
|
||||
tracker_file.close();
|
||||
}
|
||||
|
||||
// Pause all torrents in session
|
||||
bool bittorrent::pauseAllTorrents(){
|
||||
bool paused_torrents = false;
|
||||
std::vector<torrent_handle> handles = s->get_torrents();
|
||||
for(unsigned int i=0; i<handles.size(); ++i){
|
||||
torrent_handle h = handles[i];
|
||||
if(h.is_valid() && !h.is_paused()){
|
||||
h.pause();
|
||||
paused_torrents = true;
|
||||
}
|
||||
}
|
||||
return paused_torrents;
|
||||
}
|
||||
|
||||
// Resume all torrents in session
|
||||
bool bittorrent::resumeAllTorrents(){
|
||||
bool resumed_torrents = false;
|
||||
std::vector<torrent_handle> handles = s->get_torrents();
|
||||
for(unsigned int i=0; i<handles.size(); ++i){
|
||||
torrent_handle h = handles[i];
|
||||
if(h.is_valid() && h.is_paused()){
|
||||
h.resume();
|
||||
resumed_torrents = true;
|
||||
}
|
||||
}
|
||||
return resumed_torrents;
|
||||
}
|
||||
|
||||
// Add uT PeX extension to bittorrent session
|
||||
void bittorrent::enablePeerExchange(){
|
||||
qDebug("Enabling Peer eXchange");
|
||||
|
@ -88,10 +88,8 @@ class bittorrent : public QObject{
|
||||
void downloadFromUrl(QString url);
|
||||
void downloadFromURLList(const QStringList& url_list);
|
||||
void deleteTorrent(QString hash, bool permanent = false);
|
||||
void pauseTorrent(QString hash);
|
||||
bool pauseAllTorrents();
|
||||
bool resumeAllTorrents();
|
||||
void resumeTorrent(QString hash);
|
||||
bool pauseTorrent(QString hash);
|
||||
bool resumeTorrent(QString hash);
|
||||
void enableDHT();
|
||||
void disableDHT();
|
||||
void saveDHTEntry();
|
||||
|
@ -18,10 +18,12 @@ DEFINES += VERSION_BUGFIX=0
|
||||
|
||||
contains(DEBUG_MODE, 1){
|
||||
CONFIG += debug
|
||||
CONFIG -= release
|
||||
message(Debug build!)
|
||||
}
|
||||
contains(DEBUG_MODE, 0){
|
||||
CONFIG -= debug
|
||||
CONFIG += release
|
||||
message(Release build!)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user