Change CardInfo's PixmapCacheKey to be the UUID of the card in the preferred set after database loading has finished. Otherwise, and if no UUID of a preferred set is available, default to the card name. (#5158)

* Change CardInfo's PixmapCacheKey to be the UUID of the preferred set after database loading has finished. Otherwise, and if no UUID of a preferred set is available, default to the card name.

* Clean up some variable names, clarify preferred Set insertion for PictureLoader, use the new CardDatabaseManager.

* Code formatting.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2024-11-10 23:49:11 +01:00 committed by GitHub
parent 3c40cc4b7d
commit c54f47efbf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 135 additions and 2 deletions

View file

@ -43,6 +43,14 @@ PictureToLoad::PictureToLoad(CardInfoPtr _card)
sortedSets << CardSet::newInstance("", "", "", QDate());
}
std::sort(sortedSets.begin(), sortedSets.end(), SetDownloadPriorityComparator());
// If the pixmapCacheKey corresponds to a specific set, we have to try to load it first.
for (const auto &set : card->getSets()) {
if (QLatin1String("card_") + QString(set.getProperty("uuid")) == card->getPixmapCacheKey()) {
long long setIndex = sortedSets.indexOf(set.getPtr());
CardSetPtr setForCardUUID = sortedSets.takeAt(setIndex);
sortedSets.prepend(setForCardUUID);
}
}
// The first time called, nextSet will also populate the Urls for the first set.
nextSet();
}
@ -170,8 +178,11 @@ void PictureLoaderWorker::processLoadQueue()
qDebug().nospace() << "PictureLoader: [card: " << cardName << " set: " << setName
<< "]: Trying to load picture";
if (cardImageExistsOnDisk(setName, correctedCardName)) {
continue;
if (CardDatabaseManager::getInstance()->isUuidForPreferredPrinting(
cardName, cardBeingLoaded.getCard()->getPixmapCacheKey())) {
if (cardImageExistsOnDisk(setName, correctedCardName)) {
continue;
}
}
qDebug().nospace() << "PictureLoader: [card: " << cardName << " set: " << setName