diff options
| author | Arno <am@disconnect.de> | 2011-05-14 08:54:07 +0200 | 
|---|---|---|
| committer | Arno <am@disconnect.de> | 2011-05-14 08:54:07 +0200 | 
| commit | 189dbc38b5a4495553303a705e54eb1c95bc8e52 (patch) | |
| tree | 288610c9ce660a5089cb3fccca439e90b1cccce5 /seriestreemodel.cpp | |
| parent | 5ca7f74c5b66cb9496f8a6aa4ecbb1f687247995 (diff) | |
| download | SheMov-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.cpp | 10 | 
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()){  | 
