From 189dbc38b5a4495553303a705e54eb1c95bc8e52 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 14 May 2011 08:54:07 +0200 Subject: Fix adding movies with subtitles When a movie has a subtitle, use a negative seriespart as id. I guess this will haunt me at some point, but for now it works. Added a sequence to the database layout for that. --- seriestreemodel.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'seriestreemodel.cpp') diff --git a/seriestreemodel.cpp b/seriestreemodel.cpp index f18ef4d..c091576 100644 --- a/seriestreemodel.cpp +++ b/seriestreemodel.cpp @@ -344,7 +344,15 @@ bool SeriesTreeModel::addSeriesPart(int seriesPart, const QModelIndex &parent, c } int seriesId = parent.data(SeriesIdRole).toInt(); mDb.transaction(); - mSeriesPartInsertQuery->bindValue(":part", seriesPart); + if(seriesPart > 0){ + mSeriesPartInsertQuery->bindValue(":part", seriesPart); + }else{ + QSqlQuery nextNegValQuery("SELECT nextval('seriesparts_iseriespart__seq')", mDb); + if(nextNegValQuery.next()){ + seriesPart = nextNegValQuery.value(0).toInt(); + mSeriesPartInsertQuery->bindValue(":part", seriesPart); + } + } mSeriesPartInsertQuery->bindValue(":id", seriesId); mSeriesPartInsertQuery->bindValue(":subtitle", subTitle.toLower()); if(mSeriesPartInsertQuery->exec()){ -- cgit v1.2.3-70-g09d2