summaryrefslogtreecommitdiffstats
path: root/seriestreemodel.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2011-05-14 08:54:07 +0200
committerArno <am@disconnect.de>2011-05-14 08:54:07 +0200
commit189dbc38b5a4495553303a705e54eb1c95bc8e52 (patch)
tree288610c9ce660a5089cb3fccca439e90b1cccce5 /seriestreemodel.cpp
parent5ca7f74c5b66cb9496f8a6aa4ecbb1f687247995 (diff)
downloadSheMov-189dbc38b5a4495553303a705e54eb1c95bc8e52.tar.gz
SheMov-189dbc38b5a4495553303a705e54eb1c95bc8e52.tar.bz2
SheMov-189dbc38b5a4495553303a705e54eb1c95bc8e52.zip
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.
Diffstat (limited to 'seriestreemodel.cpp')
-rw-r--r--seriestreemodel.cpp10
1 files changed, 9 insertions, 1 deletions
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()){