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

Method insertComic

YACReaderLibrary/library_creator.cpp:373–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373void LibraryCreator::insertComic(const QString &relativePath, const QFileInfo &fileInfo)
374{
375 auto _database = QSqlDatabase::database(_databaseConnection);
376
377 QString hash = pseudoHash(fileInfo);
378
379 ComicDB comic = DBHelper::loadComic(fileInfo.fileName(), relativePath, hash, _database);
380 int numPages = 0;
381 QPair<int, int> originalCoverSize = { 0, 0 };
382 bool exists = checkCover(hash);
383
384 auto coverPath = LibraryPaths::coverPathFromLibraryDataPath(_target, hash);
385 YACReader::InitialComicInfoExtractor ie(QDir::cleanPath(fileInfo.absoluteFilePath()), coverPath, comic.info.coverPage.toInt(), settings->value(IMPORT_COMIC_INFO_XML_METADATA, false).toBool());
386
387 if (!(comic.hasCover() && exists)) {
388 ie.extract();
389 numPages = ie.getNumPages();
390 originalCoverSize = ie.getOriginalCoverSize();
391 if (numPages > 0) {
392 emit comicAdded(relativePath, coverPath);
393 }
394 }
395
396 if (numPages > 0 || exists) {
397 // en este punto sabemos que todos los folders que hay en _currentPath, deberían estar añadidos a la base de datos
398 insertFolders();
399
400 bool parsed = YACReader::parseXMLIntoInfo(ie.getXMLInfoRawData(), comic.info);
401
402 comic.info.numPages = numPages;
403 if (originalCoverSize.second > 0) {
404 comic.info.originalCoverSize = QString("%1x%2").arg(originalCoverSize.first).arg(originalCoverSize.second);
405 comic.info.coverSizeRatio = static_cast<float>(originalCoverSize.first) / originalCoverSize.second;
406 }
407
408 comic.parentId = _currentPathFolders.last().id;
409 comic.info.type = QVariant::fromValue(_currentPathFolders.last().type);
410
411 DBHelper::insert(&comic, _database, parsed);
412 }
413}
414
415void LibraryCreator::replaceComic(const QString &relativePath, const QFileInfo &fileInfo, ComicDB *comic)
416{

Callers

nothing calls this directly

Calls 7

pseudoHashFunction · 0.85
hasCoverMethod · 0.80
extractMethod · 0.80
getNumPagesMethod · 0.80
getOriginalCoverSizeMethod · 0.80
getXMLInfoRawDataMethod · 0.80
QStringClass · 0.70

Tested by

no test coverage detected