MCPcopy Create free account
hub / github.com/YACReader/yacreader / comicToJSON

Method comicToJSON

YACReaderLibrary/server/yacreader_server_data_helper.cpp:83–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83QJsonObject YACReaderServerDataHelper::comicToJSON(const qulonglong libraryId, const QUuid libraryUuid, const ComicDB &comic)
84{
85 QJsonObject json;
86
87 json["type"] = "comic";
88 json["id"] = QString::number(comic.id);
89 json["comic_info_id"] = QString::number(comic.info.id);
90 json["parent_id"] = QString::number(comic.parentId); // 9.14
91 json["library_id"] = QString::number(libraryId);
92 if (!libraryUuid.isNull()) {
93 json["library_uuid"] = libraryUuid.toString();
94 }
95 json["file_name"] = comic.name;
96 json["file_size"] = QString::number(comic.getFileSize());
97 json["hash"] = comic.info.hash;
98 json["path"] = comic.path; // 9.14
99
100 json["current_page"] = comic.info.currentPage;
101 json["num_pages"] = comic.info.numPages.toInt();
102 json["read"] = comic.info.read;
103 auto type = comic.info.type.value<YACReader::FileType>();
104 json["manga"] = type == YACReader::FileType::Manga; // legacy, kept for compatibility with old clients
105 json["file_type"] = comic.info.type.toInt(); // 9.13
106 json["cover_size_ratio"] = comic.info.coverSizeRatio.toFloat();
107
108 // legacy
109 json["number"] = comic.info.number.toInt();
110
111 variantToJson("cover_page", QMetaType::Int, comic.info.coverPage, json);
112 variantToJson("title", QMetaType::QString, comic.info.title, json);
113 variantToJson("universal_number", QMetaType::QString, comic.info.number, json);
114 variantToJson("last_time_opened", QMetaType::LongLong, comic.info.lastTimeOpened, json);
115 json["has_been_opened"] = comic.info.hasBeenOpened;
116
117 variantToJson("added", QMetaType::LongLong, comic.info.added, json);
118
119 return json;
120}
121
122QJsonObject YACReaderServerDataHelper::fullComicToJSON(const qulonglong libraryId, const QUuid libraryUuid, const ComicDB &comic)
123{

Callers

nothing calls this directly

Calls 3

variantToJsonFunction · 0.85
toStringMethod · 0.80
getFileSizeMethod · 0.80

Tested by

no test coverage detected