diff options
author | Arno <am@disconnect.de> | 2010-07-18 12:51:36 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-07-18 12:51:36 +0200 |
commit | 6d00ae1d57ed37a8d3d6d35181cb6b155dd7801c (patch) | |
tree | 04dee534c2a3e3f62f134c9434ab0a4718e759bf /filestreewidget.cpp | |
parent | 1bffedb2177e7b42112ccb5d0a98076eab0dc0a9 (diff) | |
download | SheMov-6d00ae1d57ed37a8d3d6d35181cb6b155dd7801c.tar.gz SheMov-6d00ae1d57ed37a8d3d6d35181cb6b155dd7801c.tar.bz2 SheMov-6d00ae1d57ed37a8d3d6d35181cb6b155dd7801c.zip |
Implemented delete files from tree view
Files can now be delete from the files tree view. When doing so, the
files will be deleted permanently and also removed from the database.
Diffstat (limited to 'filestreewidget.cpp')
-rw-r--r-- | filestreewidget.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/filestreewidget.cpp b/filestreewidget.cpp index b25804f..89de946 100644 --- a/filestreewidget.cpp +++ b/filestreewidget.cpp @@ -110,6 +110,26 @@ void FilesTreeWidget::setDvdNo(){ } } +void FilesTreeWidget::removeFiles(){ + QModelIndexList selected = mView->selectionModel()->selectedRows(); + if(selected.isEmpty()){ + return; + } + QString message = QString(tr("<p>Really delete these file(s):</p><ul>")); + foreach(QModelIndex i, selected){ + message.append(QString(tr("<li>%1</li>")).arg(i.data(FilesTreeModel::FileNameRole).toString())); + } + message.append("</ul>"); + int retval = QMessageBox::critical(this, tr("Question"), message, QMessageBox::Yes | QMessageBox::No); + if(retval == QMessageBox::Yes){ + QModelIndexList realSelected; + foreach(QModelIndex i, selected){ + realSelected << mProxy->mapToSource(i); + } + mModel->deleteFiles(realSelected); + } +} + void FilesTreeWidget::fileSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous){ Q_UNUSED(previous); int seriesPartId = current.data(FilesTreeModel::SeriesPartIdRole).toInt(); |