diff options
-rw-r--r-- | torrentwidget.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/torrentwidget.cpp b/torrentwidget.cpp index 7f88eef..f93115b 100644 --- a/torrentwidget.cpp +++ b/torrentwidget.cpp @@ -223,9 +223,10 @@ void TorrentWidget::deleteFiles(){ } QString q = QString(tr("Really delete %1 file(s)?")).arg(QString::number(sel.count())); int res = QMessageBox::question(this, tr("Delete files..."), q); - int ctr = 0; if(res == QMessageBox::Yes){ - foreach(QModelIndex i, sel){ + int ctr = 0; + QStringList removed; + for(const QModelIndex &i : sel){ QString fp = i.data(FullPathRole).toString(); bool ok = QFile::remove(fp); if(ok){ @@ -235,10 +236,16 @@ void TorrentWidget::deleteFiles(){ QString msg = QString(tr("Shit: %1 vanished from under us!")).arg(fi.fileName()); QMessageBox::critical(this, tr("Error"), msg); } + removed << i.data().toString(); + } + for(const QString& f : removed){ + QList<QStandardItem*> res = mModel->findItems(f, Qt::MatchExactly, NameColumn); + if(!res.isEmpty()){ + mModel->removeRow(res.at(0)->row()); + } } QString msg = QString(tr("Successfully deleted %1 of %2 file(s)")).arg(QString::number(ctr)).arg(QString::number(sel.count())); emit statusMessage(msg); - gatherData(); emit freeSpaceChanged(mDir->text()); } } |