mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
- Implemented DeleteFromHardDrive & finishedList
This commit is contained in:
parent
37027c0480
commit
6d0b550f5d
@ -139,3 +139,11 @@ void FinishedTorrents::deleteFromFinishedList(QString hash){
|
|||||||
--nbFinished;
|
--nbFinished;
|
||||||
((GUI*)parent)->setTabText(1, tr("Finished") +" ("+QString(misc::toString(nbFinished).c_str())+")");
|
((GUI*)parent)->setTabText(1, tr("Finished") +" ("+QString(misc::toString(nbFinished).c_str())+")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTreeView* FinishedTorrents::getFinishedList(){
|
||||||
|
return finishedList;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStandardItemModel* FinishedTorrents::getFinishedListModel(){
|
||||||
|
return finishedListModel;
|
||||||
|
}
|
||||||
|
@ -47,6 +47,8 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
|
|||||||
void addFinishedSHA(QString sha);
|
void addFinishedSHA(QString sha);
|
||||||
void updateFinishedList();
|
void updateFinishedList();
|
||||||
void deleteFromFinishedList(QString hash);
|
void deleteFromFinishedList(QString hash);
|
||||||
|
QTreeView* getFinishedList();
|
||||||
|
QStandardItemModel* getFinishedListModel();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void setRowColor(int row, const QString& color);
|
void setRowColor(int row, const QString& color);
|
||||||
|
56
src/GUI.cpp
56
src/GUI.cpp
@ -769,14 +769,33 @@ void GUI::askForTorrents(){
|
|||||||
|
|
||||||
// delete from download list AND from hard drive
|
// delete from download list AND from hard drive
|
||||||
void GUI::deletePermanently(){
|
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(!selectedIndexes.isEmpty()){
|
||||||
if(QMessageBox::question(
|
int ret;
|
||||||
this,
|
if(inDownloadList) {
|
||||||
tr("Are you sure? -- qBittorrent"),
|
ret = QMessageBox::question(
|
||||||
tr("Are you sure you want to delete the selected item(s) in download list and in hard drive?"),
|
this,
|
||||||
tr("&Yes"), tr("&No"),
|
tr("Are you sure? -- qBittorrent"),
|
||||||
QString(), 0, 1) == 0) {
|
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
|
//User clicked YES
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
QList<QPair<int, QModelIndex> > sortedIndexes;
|
QList<QPair<int, QModelIndex> > sortedIndexes;
|
||||||
@ -792,17 +811,28 @@ void GUI::deletePermanently(){
|
|||||||
QPair<int, QModelIndex> sortedIndex;
|
QPair<int, QModelIndex> sortedIndex;
|
||||||
foreach(sortedIndex, sortedIndexes){
|
foreach(sortedIndex, sortedIndexes){
|
||||||
qDebug("deleting row: %d, %d, col: %d", sortedIndex.first, sortedIndex.second.row(), sortedIndex.second.column());
|
qDebug("deleting row: %d, %d, col: %d", sortedIndex.first, sortedIndex.second.row(), sortedIndex.second.column());
|
||||||
// Get the file name
|
// Get the file name & hash
|
||||||
QString fileName = DLListModel->data(DLListModel->index(sortedIndex.second.row(), NAME)).toString();
|
QString fileName;
|
||||||
QString fileHash = DLListModel->data(DLListModel->index(sortedIndex.second.row(), HASH)).toString();
|
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
|
// Remove the torrent
|
||||||
BTSession.deleteTorrent(fileHash, true);
|
BTSession.deleteTorrent(fileHash, true);
|
||||||
// Delete item from download list
|
// Delete item from download list
|
||||||
DLListModel->removeRow(sortedIndex.first);
|
if(inDownloadList) {
|
||||||
// Update info bar
|
DLListModel->removeRow(sortedIndex.first);
|
||||||
setInfoBar(tr("'%1' was removed.", "'xxx.avi' was removed.").arg(fileName));
|
|
||||||
--nbTorrents;
|
--nbTorrents;
|
||||||
tabs->setTabText(0, tr("Downloads") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user