Browse Source

Improved start_All and resume_All functions to detect if a torrent's state changed or not. This way, it doesn't flood the GUI if the user keeps on clicking on those buttons

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
d12e510fad
  1. 6
      src/GUI.cpp
  2. 10
      src/bittorrent.cpp
  3. 4
      src/bittorrent.h

6
src/GUI.cpp

@ -1300,7 +1300,7 @@ void GUI::configureSession(bool deleteOptions){ @@ -1300,7 +1300,7 @@ void GUI::configureSession(bool deleteOptions){
void GUI::on_actionPause_All_triggered(){
QString fileHash;
// Pause all torrents
BTSession.pauseAllTorrents();
if(BTSession.pauseAllTorrents()){
// update download list
unsigned int nbRows = DLListModel->rowCount();
for(unsigned int i=0; i<nbRows; ++i){
@ -1320,6 +1320,7 @@ void GUI::on_actionPause_All_triggered(){ @@ -1320,6 +1320,7 @@ void GUI::on_actionPause_All_triggered(){
}
setInfoBar(tr("All downloads were paused."));
}
}
// pause selected items in the list
void GUI::on_actionPause_triggered(){
@ -1351,7 +1352,7 @@ void GUI::on_actionPause_triggered(){ @@ -1351,7 +1352,7 @@ void GUI::on_actionPause_triggered(){
void GUI::on_actionStart_All_triggered(){
QString fileHash;
// Pause all torrents
BTSession.resumeAllTorrents();
if(BTSession.resumeAllTorrents()){
// update download list
unsigned int nbRows = DLListModel->rowCount();
for(unsigned int i=0; i<nbRows; ++i){
@ -1365,6 +1366,7 @@ void GUI::on_actionStart_All_triggered(){ @@ -1365,6 +1366,7 @@ void GUI::on_actionStart_All_triggered(){
}
setInfoBar(tr("All downloads were resumed."));
}
}
// start selected items in the list
void GUI::on_actionStart_triggered(){

10
src/bittorrent.cpp

@ -612,25 +612,31 @@ void bittorrent::saveTrackerFile(const QString& hash){ @@ -612,25 +612,31 @@ void bittorrent::saveTrackerFile(const QString& hash){
}
// Pause all torrents in session
void bittorrent::pauseAllTorrents(){
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
void bittorrent::resumeAllTorrents(){
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

4
src/bittorrent.h

@ -91,8 +91,8 @@ class bittorrent : public QObject{ @@ -91,8 +91,8 @@ class bittorrent : public QObject{
void downloadFromURLList(const QStringList& url_list);
void deleteTorrent(const QString& hash, bool permanent = false);
void pauseTorrent(const QString& hash);
void pauseAllTorrents();
void resumeAllTorrents();
bool pauseAllTorrents();
bool resumeAllTorrents();
void resumeTorrent(const QString& hash);
void enableDHT();
void disableDHT();

Loading…
Cancel
Save