Code clean up

This commit is contained in:
Christophe Dumez 2010-11-14 19:22:39 +00:00
parent 1d795d85d2
commit 5cd376d2c3
3 changed files with 14 additions and 37 deletions

View file

@ -802,12 +802,13 @@ void QBtSession::pauseAllTorrents() {
std::vector<torrent_handle> torrents = s->get_torrents(); std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT; std::vector<torrent_handle>::iterator torrentIT;
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
QTorrentHandle h = QTorrentHandle(*torrentIT); try {
if(!h.is_valid()) continue; QTorrentHandle h = QTorrentHandle(*torrentIT);
if(!h.is_paused()) { if(!h.is_paused()) {
h.pause(); h.pause();
emit pausedTorrent(h); emit pausedTorrent(h);
} }
} catch(invalid_handle&) {}
} }
} }
@ -819,12 +820,13 @@ void QBtSession::resumeAllTorrents() {
std::vector<torrent_handle> torrents = s->get_torrents(); std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT; std::vector<torrent_handle>::iterator torrentIT;
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
QTorrentHandle h = QTorrentHandle(*torrentIT); try {
if(!h.is_valid()) continue; QTorrentHandle h = QTorrentHandle(*torrentIT);
if(h.is_paused()) { if(h.is_paused()) {
h.resume(); h.resume();
emit resumedTorrent(h); emit resumedTorrent(h);
} }
} catch(invalid_handle&) {}
} }
} }

View file

@ -131,10 +131,6 @@ TorrentModel* TransferListWidget::getSourceModel() const {
return listModel; return listModel;
} }
int TransferListWidget::getNbTorrents() const {
return listModel->rowCount();
}
void TransferListWidget::previewFile(QString filePath) { void TransferListWidget::previewFile(QString filePath) {
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
QDesktopServices::openUrl(QUrl(QString("file:///")+filePath)); QDesktopServices::openUrl(QUrl(QString("file:///")+filePath));
@ -260,15 +256,6 @@ void TransferListWidget::startSelectedTorrents() {
} }
} }
void TransferListWidget::startAllTorrents() {
for(int i=0; i<listModel->rowCount(); ++i) {
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(i));
if(h.is_valid() && h.is_paused()) {
h.resume();
}
}
}
void TransferListWidget::startVisibleTorrents() { void TransferListWidget::startVisibleTorrents() {
QStringList hashes; QStringList hashes;
for(int i=0; i<nameFilterModel->rowCount(); ++i) { for(int i=0; i<nameFilterModel->rowCount(); ++i) {
@ -293,15 +280,6 @@ void TransferListWidget::pauseSelectedTorrents() {
} }
} }
void TransferListWidget::pauseAllTorrents() {
for(int i=0; i<listModel->rowCount(); ++i) {
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(i));
if(h.is_valid() && !h.is_paused()) {
h.pause();
}
}
}
void TransferListWidget::pauseVisibleTorrents() { void TransferListWidget::pauseVisibleTorrents() {
QStringList hashes; QStringList hashes;
for(int i=0; i<nameFilterModel->rowCount(); ++i) { for(int i=0; i<nameFilterModel->rowCount(); ++i) {

View file

@ -50,7 +50,6 @@ class TransferListWidget: public QTreeView {
public: public:
TransferListWidget(QWidget *parent, MainWindow *main_window, QBtSession* BTSession); TransferListWidget(QWidget *parent, MainWindow *main_window, QBtSession* BTSession);
~TransferListWidget(); ~TransferListWidget();
int getNbTorrents() const;
TorrentModel* getSourceModel() const; TorrentModel* getSourceModel() const;
public slots: public slots:
@ -58,10 +57,8 @@ public slots:
void setRefreshInterval(int t); void setRefreshInterval(int t);
void setSelectedTorrentsLocation(); void setSelectedTorrentsLocation();
void startSelectedTorrents(); void startSelectedTorrents();
void startAllTorrents();
void startVisibleTorrents(); void startVisibleTorrents();
void pauseSelectedTorrents(); void pauseSelectedTorrents();
void pauseAllTorrents();
void pauseVisibleTorrents(); void pauseVisibleTorrents();
void deleteSelectedTorrents(); void deleteSelectedTorrents();
void deleteVisibleTorrents(); void deleteVisibleTorrents();