From c6c4900e4cf9aa69b2de3c9c5af701800c0c25de Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 28 Dec 2017 11:45:34 +0100 Subject: Ask for removing origin files Pop up a dialog to ask if origin files should be deleted. Not tested yet, so beware of the leopard! --- newmoviewizard.cpp | 30 ++++++++++++++++++++++++++++++ newmoviewizard.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp index 3e5ca9b..427f1ad 100644 --- a/newmoviewizard.cpp +++ b/newmoviewizard.cpp @@ -292,6 +292,20 @@ void NewMovieWizard::accept(){ } db.commit(); mInfoPage->saveData(); + const QStringList &origins = mInfoPage->origins(); + if(!origins.isEmpty()){ + QString q = QString("

Also delete origins?

"); + int qRes = QMessageBox::question(this, tr("Delete other files"), q); + if(qRes == QMessageBox::Yes){ + for(const QString &o : origins){ + QFile::remove(o); + } + } + } QWizard::accept(); } @@ -387,6 +401,7 @@ void MovieInfoPage::initializePage(){ restoreData(); } mFileModel->clear(); + mOrigins.clear(); } void MovieInfoPage::addFile(const QString &file){ @@ -491,6 +506,7 @@ void MovieInfoPage::addOld(){ QModelIndex realIdx = mProxy->mapToSource(curIdxList[0]); mFileModel->appendRow(itemData, realIdx); mFileView->expandAll(); + mOrigins << fullPath; } oldFileDlg->deleteLater(); } @@ -521,6 +537,20 @@ void MovieInfoPage::removeFile(){ for(const QPersistentModelIndex &pi : curSel){ QModelIndex cur = mProxy->mapToSource(pi); if(cur.isValid()){ + int type = cur.data(WizardTreeModel::FileTypeRole).toInt(); + if(type == FT_ORIGIN){ + mOrigins.removeAll(pi.data(WizardTreeModel::FullPathRole).toString()); + }else{ + for(int i = 0; i < mProxy->rowCount(pi); ++i){ + QModelIndex child = mProxy->index(0, pi.column(), pi); + if(child.isValid()){ + int type = child.data(WizardTreeModel::FileTypeRole).toInt(); + if(type == FT_ORIGIN){ + mOrigins.removeAll(child.data(WizardTreeModel::FullPathRole).toString()); + } + } + } + } mFileModel->removeRow(cur.row(), cur.parent()); } } diff --git a/newmoviewizard.h b/newmoviewizard.h index e88be9f..d02cd62 100644 --- a/newmoviewizard.h +++ b/newmoviewizard.h @@ -57,6 +57,7 @@ class MovieInfoPage : public QWizardPage { void selectFirst(); void saveData(); void restoreData(); + const QStringList &origins() const { return mOrigins; } public slots: void initCompleters(); @@ -87,6 +88,7 @@ class MovieInfoPage : public QWizardPage { QString mCurrentDir; QString mCurTitle; QString mCurSubtitle; + QStringList mOrigins; int mCurSeriesno; int mCurQuality; }; -- cgit v1.2.3-70-g09d2