summaryrefslogtreecommitdiffstats
path: root/seriestreemodel.cpp
diff options
context:
space:
mode:
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()){