Browse Source

- Implemented Start/Pause in finished list

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
775afd6ac2
  1. 2
      src/FinishedTorrents.h
  2. 71
      src/GUI.cpp

2
src/FinishedTorrents.h

@ -52,8 +52,6 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
void showProperties(const QModelIndex &index); void showProperties(const QModelIndex &index);
void propertiesSelection(); void propertiesSelection();
void displayFinishedListMenu(const QPoint&); void displayFinishedListMenu(const QPoint&);
protected slots:
void setRowColor(int row, const QString& color); void setRowColor(int row, const QString& color);
}; };

71
src/GUI.cpp

@ -1140,25 +1140,46 @@ void GUI::pauseAll(){
// pause selected items in the list // pause selected items in the list
void GUI::pauseSelection(){ void GUI::pauseSelection(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes(); if(tabs->currentIndex() > 1) return;
QModelIndexList selectedIndexes;
bool inDownloadList = true;
if(tabs->currentIndex() == 0) {
selectedIndexes = downloadList->selectionModel()->selectedIndexes();
} else {
selectedIndexes = finishedTorrentTab->getFinishedList()->selectionModel()->selectedIndexes();
inDownloadList = false;
}
QModelIndex index; QModelIndex index;
foreach(index, selectedIndexes){ foreach(index, selectedIndexes){
if(index.column() == NAME){ if(index.column() == NAME){
// Get the file name // Get the file hash
QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString(); QString fileHash;
if(inDownloadList)
fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
else
fileHash = finishedTorrentTab->getFinishedListModel()->data(finishedTorrentTab->getFinishedListModel()->index(index.row(), HASH)).toString();
if(!BTSession.isPaused(fileHash)){ if(!BTSession.isPaused(fileHash)){
// Pause the torrent // Pause the torrent
BTSession.pauseTorrent(fileHash); BTSession.pauseTorrent(fileHash);
// Update DL status // Update DL status
int row = index.row(); int row = index.row();
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0)); if(inDownloadList) {
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0)); DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused"))); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
setRowColor(row, "red");
} else {
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, DLSPEED), QVariant((double)0.0));
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, UPSPEED), QVariant((double)0.0));
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, STATUS), QVariant(tr("Paused")));
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, ETA), QVariant((qlonglong)-1));
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, SEEDSLEECH), QVariant("0/0"));
}
setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(QString(BTSession.getTorrentHandle(fileHash).name().c_str()))); setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(QString(BTSession.getTorrentHandle(fileHash).name().c_str())));
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
setRowColor(row, "red");
} }
} }
} }
@ -1184,12 +1205,24 @@ void GUI::resumeAll(){
// start selected items in the list // start selected items in the list
void GUI::startSelection(){ void GUI::startSelection(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes(); if(tabs->currentIndex() > 1) return;
QModelIndexList selectedIndexes;
bool inDownloadList = true;
if(tabs->currentIndex() == 0) {
selectedIndexes = downloadList->selectionModel()->selectedIndexes();
} else {
selectedIndexes = finishedTorrentTab->getFinishedList()->selectionModel()->selectedIndexes();
inDownloadList = false;
}
QModelIndex index; QModelIndex index;
foreach(index, selectedIndexes){ foreach(index, selectedIndexes){
if(index.column() == NAME){ if(index.column() == NAME){
// Get the file name // Get the file hash
QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString(); QString fileHash;
if(inDownloadList)
fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
else
fileHash = finishedTorrentTab->getFinishedListModel()->data(finishedTorrentTab->getFinishedListModel()->index(index.row(), HASH)).toString();
if(BTSession.isPaused(fileHash)){ if(BTSession.isPaused(fileHash)){
// Resume the torrent // Resume the torrent
BTSession.resumeTorrent(fileHash); BTSession.resumeTorrent(fileHash);
@ -1197,10 +1230,16 @@ void GUI::startSelection(){
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
// Update DL status // Update DL status
int row = index.row(); int row = index.row();
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting..."))); if(inDownloadList) {
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
setRowColor(row, "grey");
} else {
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, STATUS), QVariant(tr("Finished", "i.e: Torrent has finished downloading")));
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, NAME), QVariant(QIcon(":/Icons/skin/seeding.png")), Qt::DecorationRole);
finishedTorrentTab->setRowColor(row, "orange");
}
setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(QString(BTSession.getTorrentHandle(fileHash).name().c_str()))); setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(QString(BTSession.getTorrentHandle(fileHash).name().c_str())));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
setRowColor(row, "grey");
} }
} }
} }

Loading…
Cancel
Save