Browse Source

- Oups, sorry I forgot pause_all() & start_all() functions in last commit :)

- Updated version to v0.9.0beta4
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
aa6f6161c3
  1. 43
      src/GUI.cpp
  2. 2
      src/GUI.h
  3. 5
      src/about_imp.h
  4. 22
      src/bittorrent.cpp
  5. 4
      src/bittorrent.h

43
src/GUI.cpp

@ -152,6 +152,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ @@ -152,6 +152,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
connect(actionPause, SIGNAL(triggered()), this, SLOT(pauseSelection()));
connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection()));
connect(actionStart, SIGNAL(triggered()), this, SLOT(startSelection()));
connect(actionPause_All, SIGNAL(triggered()), this, SLOT(pauseAll()));
connect(actionStart_All, SIGNAL(triggered()), this, SLOT(resumeAll()));
connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
connect(actionCreate_torrent, SIGNAL(triggered()), this, SLOT(showCreateWindow()));
connect(actionClearLog, SIGNAL(triggered()), this, SLOT(clearLog()));
@ -1204,6 +1206,29 @@ void GUI::configureSession(){ @@ -1204,6 +1206,29 @@ void GUI::configureSession(){
qDebug("Session configured");
}
// Pause All Downloads in DL list
void GUI::pauseAll(){
QString fileHash;
// Pause all torrents
BTSession.pauseAllTorrents();
// update download list
for(int i=0; i<DLListModel->rowCount(); ++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();
// Update DL list items
DLListModel->setData(DLListModel->index(i, DLSPEED), 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, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
setRowColor(i, "red");
setInfoBar(tr("All downloads paused."));
}
}
// pause selected items in the list
void GUI::pauseSelection(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
@ -1229,6 +1254,24 @@ void GUI::pauseSelection(){ @@ -1229,6 +1254,24 @@ void GUI::pauseSelection(){
}
}
// Resume All Downloads in DL list
void GUI::resumeAll(){
QString fileHash;
// Pause all torrents
BTSession.resumeAllTorrents();
// update download list
for(int i=0; i<DLListModel->rowCount(); ++i){
fileHash = DLListModel->data(DLListModel->index(i, HASH)).toString();
// Remove .paused file
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
// Update DL list items
DLListModel->setData(DLListModel->index(i, STATUS), QVariant(tr("Connecting...")));
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
setRowColor(i, "grey");
setInfoBar(tr("All downloads resumed."));
}
}
// start selected items in the list
void GUI::startSelection(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();

2
src/GUI.h

@ -139,7 +139,9 @@ class GUI : public QMainWindow, private Ui::MainWindow{ @@ -139,7 +139,9 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void showProperties(const QModelIndex &index);
void propertiesSelection();
void pauseSelection();
void pauseAll();
void startSelection();
void resumeAll();
void askForTorrents();
void deletePermanently();
void deleteSelection();

5
src/about_imp.h

@ -23,10 +23,7 @@ @@ -23,10 +23,7 @@
#define ABOUT_H
#include "ui_about.h"
#define VERSION "v0.9.0beta3"
#define VERSION_MAJOR 0
#define VERSION_MINOR 9
#define VERSION_BUGFIX 0
#define VERSION "v0.9.0beta4"
class about : public QDialog, private Ui::AboutDlg{
Q_OBJECT

22
src/bittorrent.cpp

@ -497,6 +497,28 @@ void bittorrent::setGlobalRatio(float ratio){ @@ -497,6 +497,28 @@ void bittorrent::setGlobalRatio(float ratio){
}
}
// Pause all torrents in session
void bittorrent::pauseAllTorrents(){
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();
}
}
}
// Resume all torrents in session
void bittorrent::resumeAllTorrents(){
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();
}
}
}
// Add uT PeX extension to bittorrent session
void bittorrent::enablePeerExchange(){
s->add_extension(&create_ut_pex_plugin);

4
src/bittorrent.h

@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
#include "deleteThread.h"
#define VERSION "v0.9.0beta3"
#define VERSION "v0.9.0beta4"
#define VERSION_MAJOR 0
#define VERSION_MINOR 9
#define VERSION_BUGFIX 0
@ -91,6 +91,8 @@ class bittorrent : public QObject{ @@ -91,6 +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();
void resumeTorrent(const QString& hash);
void enableDHT();
void disableDHT();

Loading…
Cancel
Save