Add a new method to serialize a comic remote information to json

This commit is contained in:
Luis Ángel San Martín 2018-03-11 11:28:41 +01:00
parent da5a4def96
commit 7e571c8ffe
2 changed files with 18 additions and 0 deletions

View File

@ -23,4 +23,20 @@ QString YACReaderServerDataHelper::comicToYSFormat(const qulonglong libraryId,co
.arg(comic.info.read?1:0);
}
static QJsonObject YACReaderServerDataHelper::comicToJSON(const qulonglong libraryId, const ComicDB & comic)
{
QJsonObject json;
json["type"] = "comic";
json["id"] = comic.id;
json["file_name"] = comic.getFileName();
json["file_size"] = comic.getFileSize();
json["hash"] = comic.info.hash;
json["current_page"] = comic.info.currentPage;
json["num_pages"] = comic.info.numPages.toInt();
json["read"] = comic.info.read;
return json;
}
YACReaderServerDataHelper::YACReaderServerDataHelper() {}

View File

@ -11,6 +11,8 @@ public:
static QString folderToYSFormat(const qulonglong libraryId, const Folder & folder);
static QString comicToYSFormat(const qulonglong libraryId, const ComicDB & comic);
static QJsonObject comicToJSON(const qulonglong libraryId, const ComicDB & comic);
private:
YACReaderServerDataHelper();