Partial support for storing the cover information in the DB. Work in progress.

This commit is contained in:
Luis Ángel San Martín
2018-03-11 14:43:07 +01:00
parent 0c303e6ea3
commit 69395398e1
6 changed files with 58 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include <QtCore>
#include "library_creator.h"
#include "check_new_version.h"
#include "db_helper.h"
static QString fields = "title ,"
@ -181,7 +182,8 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
//new 7.1 fields
"comicVineID TEXT,"
//new 8.6 fields
"lastTimeOpened INTEGER"
"lastTimeOpened INTEGER,"
"coverSizeRatio REAL" //h/w
")");
success = success && queryComicInfo.exec();
@ -421,7 +423,9 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
"comicVineID = :comicVineID,"
"lastTimeOpened = :lastTimeOpened"
"lastTimeOpened = :lastTimeOpened,"
"coverSizeRatio = :coverSizeRatio"
" WHERE hash = :hash ");
@ -456,6 +460,7 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
"edited,"
"comicVineID,"
"lastTimeOpened,"
"coverSizeRatio,"
"hash)"
"VALUES (:title,"
@ -495,6 +500,8 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
":lastTimeOpened,"
":coverSizeRatio,"
":hash )");
QSqlRecord record = newInfo.record();
@ -607,6 +614,8 @@ void DataBaseManagement::bindValuesFromRecord(const QSqlRecord & record, QSqlQue
bindString("lastTimeOpened",record,query);
bindDouble("coverSizeRatio",record,query);
bindString("hash",record,query);
}
@ -655,6 +664,14 @@ void DataBaseManagement::bindInt(const QString & name, const QSqlRecord & record
}
}
void DataBaseManagement::bindDouble(const QString & name, const QSqlRecord & record, QSqlQuery & query)
{
if(!record.value(name).isNull())
{
query.bindValue(":"+name,record.value(name).toDouble());
}
}
QString DataBaseManagement::checkValidDB(const QString & fullPath)
{
QSqlDatabase db = loadDatabaseFromFile(fullPath);
@ -787,11 +804,22 @@ bool DataBaseManagement::updateToCurrentVersion(const QString & fullPath)
{//comic_info
QStringList columnDefs;
columnDefs << "lastTimeOpened INTEGER";
columnDefs << "coverSizeRatio REAL";
returnValue = returnValue && addColumns("comic_info", columnDefs, db);
QSqlQuery queryIndexLastTimeOpened(db);
returnValue = returnValue && queryIndexLastTimeOpened.exec("CREATE INDEX last_time_opened_index ON comic_info (lastTimeOpened)");
}
//update folders info
{
DBHelper::updateChildrenInfo(db);
}
//TODO udate covers info
{
//cover sizes...
}
}
}