added sync back reading progress from remote clients - full info sync is out of scope by now

This commit is contained in:
Luis Ángel San Martín
2015-04-24 22:48:17 +02:00
parent ebeddbe73b
commit f38251dbff
4 changed files with 80 additions and 8 deletions

View File

@ -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);