mirror of
https://github.com/YACReader/yacreader
synced 2025-07-23 23:44:52 -04:00
Merged luisangelsm/yacreader into default
This commit is contained in:
@ -348,7 +348,7 @@ void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
||||
|
||||
updateComicInfo.bindValue(":comicVineID", comicInfo->comicVineID);
|
||||
|
||||
updateComicInfo.exec();
|
||||
updateComicInfo.exec();
|
||||
}
|
||||
|
||||
void DBHelper::updateRead(ComicInfo * comicInfo, QSqlDatabase & db)
|
||||
@ -391,6 +391,44 @@ void DBHelper::updateProgress(qulonglong libraryId, const ComicInfo &comicInfo)
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
}
|
||||
|
||||
void DBHelper::updateReadingRemoteProgress(const ComicInfo &comicInfo, QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery updateComicInfo(db);
|
||||
updateComicInfo.prepare("UPDATE comic_info SET "
|
||||
"read = :read, "
|
||||
"currentPage = :currentPage, "
|
||||
"hasBeenOpened = :hasBeenOpened"
|
||||
" WHERE id = :id ");
|
||||
|
||||
updateComicInfo.bindValue(":read", comicInfo.read?1:0);
|
||||
updateComicInfo.bindValue(":currentPage", comicInfo.currentPage);
|
||||
updateComicInfo.bindValue(":hasBeenOpened", comicInfo.hasBeenOpened?1:0);
|
||||
updateComicInfo.bindValue(":id", comicInfo.id);
|
||||
updateComicInfo.exec();
|
||||
}
|
||||
|
||||
|
||||
void DBHelper::updateFromRemoteClient(qulonglong libraryId,const ComicInfo & comicInfo)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
ComicDB comic = DBHelper::loadComic(comicInfo.id,db);
|
||||
|
||||
if(comic.info.hash == comicInfo.hash)
|
||||
{
|
||||
if(comic.info.currentPage == comic.info.numPages)
|
||||
comic.info.read = true;
|
||||
comic.info.currentPage = comicInfo.currentPage;
|
||||
comic.info.hasBeenOpened = true;
|
||||
|
||||
DBHelper::updateReadingRemoteProgress(comic.info,db);
|
||||
}
|
||||
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
}
|
||||
|
||||
void DBHelper::renameLabel(qulonglong id, const QString &name, QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery renameLabelQuery(db);
|
||||
@ -566,16 +604,21 @@ qulonglong DBHelper::insertReadingSubList(const QString &name, qulonglong parent
|
||||
|
||||
void DBHelper::insertComicsInFavorites(const QList<ComicDB> &comicsList, QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery getNumComicsInFavoritesQuery("SELECT count(*) FROM comic_default_reading_list WHERE default_reading_list_id = 1;",db);
|
||||
getNumComicsInFavoritesQuery.next();
|
||||
QSqlRecord record = getNumComicsInFavoritesQuery.record();
|
||||
int numComics = record.value(0).toInt();
|
||||
|
||||
db.transaction();
|
||||
|
||||
QSqlQuery query(db);
|
||||
query.prepare("INSERT INTO comic_default_reading_list (default_reading_list_id, comic_id) "
|
||||
"VALUES (1, :comic_id)");
|
||||
query.prepare("INSERT INTO comic_default_reading_list (default_reading_list_id, comic_id, ordering) "
|
||||
"VALUES (1, :comic_id, :ordering)");
|
||||
|
||||
foreach(ComicDB comic, comicsList)
|
||||
{
|
||||
query.bindValue(":comic_id", comic.id);
|
||||
//query.bindValue(":order", numComics++);
|
||||
query.bindValue(":ordering", numComics++);
|
||||
query.exec();
|
||||
}
|
||||
|
||||
@ -584,16 +627,22 @@ void DBHelper::insertComicsInFavorites(const QList<ComicDB> &comicsList, QSqlDat
|
||||
|
||||
void DBHelper::insertComicsInLabel(const QList<ComicDB> &comicsList, qulonglong labelId, QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery getNumComicsInFavoritesQuery(QString("SELECT count(*) FROM comic_label WHERE label_id = %1;").arg(labelId) ,db);
|
||||
getNumComicsInFavoritesQuery.next();
|
||||
QSqlRecord record = getNumComicsInFavoritesQuery.record();
|
||||
int numComics = record.value(0).toInt();
|
||||
|
||||
db.transaction();
|
||||
|
||||
QSqlQuery query(db);
|
||||
query.prepare("INSERT INTO comic_label (label_id, comic_id) "
|
||||
"VALUES (:label_id, :comic_id)");
|
||||
query.prepare("INSERT INTO comic_label (label_id, comic_id, ordering) "
|
||||
"VALUES (:label_id, :comic_id, :ordering)");
|
||||
|
||||
foreach(ComicDB comic, comicsList)
|
||||
{
|
||||
query.bindValue(":label_id", labelId);
|
||||
query.bindValue(":comic_id", comic.id);
|
||||
query.bindValue(":ordering", numComics++);
|
||||
query.exec();
|
||||
}
|
||||
|
||||
@ -602,7 +651,7 @@ void DBHelper::insertComicsInLabel(const QList<ComicDB> &comicsList, qulonglong
|
||||
|
||||
void DBHelper::insertComicsInReadingList(const QList<ComicDB> &comicsList, qulonglong readingListId, QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery getNumComicsInFavoritesQuery("SELECT count(*) from comic_reading_list;",db);
|
||||
QSqlQuery getNumComicsInFavoritesQuery("SELECT count(*) FROM comic_reading_list;",db);
|
||||
getNumComicsInFavoritesQuery.next();
|
||||
QSqlRecord record = getNumComicsInFavoritesQuery.record();
|
||||
int numComics = record.value(0).toInt();
|
||||
|
Reference in New Issue
Block a user