diff options
author | Arno <arno@disconnect.de> | 2017-12-28 11:45:34 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2017-12-28 11:45:34 +0100 |
commit | c6c4900e4cf9aa69b2de3c9c5af701800c0c25de (patch) | |
tree | b030e7611d02b80d9680169a68fe0bf8f6655c52 | |
parent | 1fdeb5deddefcb49ebdef90c852d2a7b3bd91e50 (diff) | |
download | SheMov-c6c4900e4cf9aa69b2de3c9c5af701800c0c25de.tar.gz SheMov-c6c4900e4cf9aa69b2de3c9c5af701800c0c25de.tar.bz2 SheMov-c6c4900e4cf9aa69b2de3c9c5af701800c0c25de.zip |
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!
-rw-r--r-- | newmoviewizard.cpp | 30 | ||||
-rw-r--r-- | newmoviewizard.h | 2 |
2 files changed, 32 insertions, 0 deletions
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("<p>Also delete origins?</p><ul>"); + for(const QString &o : origins){ + q.append(QString("<li>%1</li>").arg(o)); + } + q.append("</ul>"); + 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; }; |