From a069898249b863b0982b1807afa8d0b0912b496e Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 30 Dec 2012 10:44:04 +0100 Subject: Allow adding files to existing Seriesparts with subtitles With siterips it's possible to have several files with the same subtitle. Now we ask if we want to add to it or cancel. --- newmoviewizard.cpp | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp index dfeb538..7f1f869 100644 --- a/newmoviewizard.cpp +++ b/newmoviewizard.cpp @@ -87,32 +87,42 @@ void NewMovieWizard::accept(){ }else{ seriesPartIdx = seriesModel->find(subTitle, SeriesTreeModel::Subtitle, seriesIdx); } + + bool addSeriesPart = true; if(seriesPartIdx.isValid()){ if(hasPartNo){ QString error = QString(tr("Already have part %1 of %2")).arg(seriesno).arg(series); QMessageBox::critical(this, tr("Error"), error); return; }else{ - QString error = QString(tr("Already have a part with subtitle %1")).arg(seriesPartIdx.data(SeriesTreeModel::SubtitleRole).toString()); - QMessageBox::critical(this, tr("Error"), error); - return; + // this is getting a little convoluted now + QString question = QString(tr("Already have a part with subtitle %1. To add current file click OK.")).arg(seriesPartIdx.data(SeriesTreeModel::SubtitleRole).toString()); + int r = QMessageBox::question(this, tr("Question"), question, QMessageBox::Ok | QMessageBox::Cancel); + if(r == QMessageBox::Ok){ + addSeriesPart = false; + }else{ + return; + } } } - if(!seriesModel->addSeriesPart(seriesno, seriesIdx, subTitle)){ - QMessageBox::critical(this, tr("Error"), tr("Failed to create series part!")); - return; - } - //model has changed, so we need to reevaluate... - if(hasPartNo){ - seriesPartIdx = seriesModel->find(seriesno, SeriesTreeModel::SeriesPart, seriesIdx); - }else{ - seriesPartIdx = seriesModel->find(subTitle, SeriesTreeModel::Subtitle, seriesIdx); + // we don't have an already existing SeriesPart, so add it + if(addSeriesPart){ + if(!seriesModel->addSeriesPart(seriesno, seriesIdx, subTitle)){ + QMessageBox::critical(this, tr("Error"), tr("Failed to create series part!")); + return; + } + //model has changed, so we need to reevaluate... + if(hasPartNo){ + seriesPartIdx = seriesModel->find(seriesno, SeriesTreeModel::SeriesPart, seriesIdx); + }else{ + seriesPartIdx = seriesModel->find(subTitle, SeriesTreeModel::Subtitle, seriesIdx); + } + if(!seriesPartIdx.isValid()){ + QMessageBox::critical(this, tr("Error"), tr("Strange. Could not find series part! Cowardly bailing out.")); + return; + } } - if(!seriesPartIdx.isValid()){ - QMessageBox::critical(this, tr("Error"), tr("Strange. Could not find series part! Cowardly bailing out.")); - return; - } int seriesPartId = seriesPartIdx.data(SeriesTreeModel::SeriesPartIdRole).toInt(); //handle files -- cgit v1.2.3-70-g09d2