diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index 90a1c42fa..cb7e919d7 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -139,3 +139,11 @@ void FinishedTorrents::deleteFromFinishedList(QString hash){ --nbFinished; ((GUI*)parent)->setTabText(1, tr("Finished") +" ("+QString(misc::toString(nbFinished).c_str())+")"); } + +QTreeView* FinishedTorrents::getFinishedList(){ + return finishedList; +} + +QStandardItemModel* FinishedTorrents::getFinishedListModel(){ + return finishedListModel; +} diff --git a/src/FinishedTorrents.h b/src/FinishedTorrents.h index 1f9560e4e..24df9c225 100644 --- a/src/FinishedTorrents.h +++ b/src/FinishedTorrents.h @@ -47,6 +47,8 @@ class FinishedTorrents : public QWidget, public Ui::seeding{ void addFinishedSHA(QString sha); void updateFinishedList(); void deleteFromFinishedList(QString hash); + QTreeView* getFinishedList(); + QStandardItemModel* getFinishedListModel(); protected slots: void setRowColor(int row, const QString& color); diff --git a/src/GUI.cpp b/src/GUI.cpp index 9782ef55b..5998b735e 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -769,14 +769,33 @@ void GUI::askForTorrents(){ // delete from download list AND from hard drive void GUI::deletePermanently(){ - 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; + } if(!selectedIndexes.isEmpty()){ - if(QMessageBox::question( - this, - tr("Are you sure? -- qBittorrent"), - tr("Are you sure you want to delete the selected item(s) in download list and in hard drive?"), - tr("&Yes"), tr("&No"), - QString(), 0, 1) == 0) { + int ret; + if(inDownloadList) { + ret = QMessageBox::question( + this, + tr("Are you sure? -- qBittorrent"), + tr("Are you sure you want to delete the selected item(s) in download list and in hard drive?"), + tr("&Yes"), tr("&No"), + QString(), 0, 1); + }else{ + ret = QMessageBox::question( + this, + tr("Are you sure? -- qBittorrent"), + tr("Are you sure you want to delete the selected item(s) in finished list and in hard drive?"), + tr("&Yes"), tr("&No"), + QString(), 0, 1); + } + if(ret == 0) { //User clicked YES QModelIndex index; QList > sortedIndexes; @@ -792,17 +811,28 @@ void GUI::deletePermanently(){ QPair sortedIndex; foreach(sortedIndex, sortedIndexes){ qDebug("deleting row: %d, %d, col: %d", sortedIndex.first, sortedIndex.second.row(), sortedIndex.second.column()); - // Get the file name - QString fileName = DLListModel->data(DLListModel->index(sortedIndex.second.row(), NAME)).toString(); - QString fileHash = DLListModel->data(DLListModel->index(sortedIndex.second.row(), HASH)).toString(); + // Get the file name & hash + QString fileName; + QString fileHash; + if(inDownloadList){ + fileName = DLListModel->data(DLListModel->index(sortedIndex.second.row(), NAME)).toString(); + fileHash = DLListModel->data(DLListModel->index(sortedIndex.second.row(), HASH)).toString(); + }else{ + fileName = finishedTorrentTab->getFinishedListModel()->data(finishedTorrentTab->getFinishedListModel()->index(sortedIndex.second.row(), NAME)).toString(); + fileHash = finishedTorrentTab->getFinishedListModel()->data(finishedTorrentTab->getFinishedListModel()->index(sortedIndex.second.row(), HASH)).toString(); + } // Remove the torrent BTSession.deleteTorrent(fileHash, true); // Delete item from download list - DLListModel->removeRow(sortedIndex.first); - // Update info bar - setInfoBar(tr("'%1' was removed.", "'xxx.avi' was removed.").arg(fileName)); + if(inDownloadList) { + DLListModel->removeRow(sortedIndex.first); --nbTorrents; tabs->setTabText(0, tr("Downloads") +" ("+QString(misc::toString(nbTorrents).c_str())+")"); + } else { + finishedTorrentTab->deleteFromFinishedList(fileHash); + } + // Update info bar + setInfoBar(tr("'%1' was removed.", "'xxx.avi' was removed.").arg(fileName)); } } }