- CardItems have dummy CardInfos if they arent in the database (#3589)

- If a CardInfo has no sets, add a dummy one to try to download it by non-set specific templates.
This commit is contained in:
Rob Blanckaert 2019-02-23 16:52:38 -08:00 committed by Zach H
parent c2150fd9bd
commit e68305d7bf
3 changed files with 12 additions and 3 deletions

View file

@ -45,8 +45,14 @@ void AbstractCardItem::pixmapUpdated()
void AbstractCardItem::cardInfoUpdated() void AbstractCardItem::cardInfoUpdated()
{ {
info = db->getCard(name); info = db->getCard(name);
if (info)
connect(info.data(), SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated())); if (!info) {
QVariantHash properties = QVariantHash();
info = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(),
CardInfoPerSetMap(), false, -1, false);
}
connect(info.data(), SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
cacheBgColor(); cacheBgColor();
update(); update();

View file

@ -33,6 +33,9 @@ PictureToLoad::PictureToLoad(CardInfoPtr _card) : card(std::move(_card))
for (const auto &set : card->getSets()) { for (const auto &set : card->getSets()) {
sortedSets << set.getPtr(); sortedSets << set.getPtr();
} }
if (sortedSets.empty()) {
sortedSets << CardSet::newInstance("", "", "", QDate());
}
qSort(sortedSets.begin(), sortedSets.end(), SetDownloadPriorityComparator()); qSort(sortedSets.begin(), sortedSets.end(), SetDownloadPriorityComparator());
// The first time called, nextSet will also populate the Urls for the first set. // The first time called, nextSet will also populate the Urls for the first set.
nextSet(); nextSet();

View file

@ -1514,7 +1514,7 @@ void Player::eventCreateToken(const Event_CreateToken &event)
if (!QString::fromStdString(event.pt()).isEmpty()) { if (!QString::fromStdString(event.pt()).isEmpty()) {
card->setPT(QString::fromStdString(event.pt())); card->setPT(QString::fromStdString(event.pt()));
} else { } else {
CardInfoPtr dbCard = db->getCard(QString::fromStdString(event.card_name())); CardInfoPtr dbCard = card->getInfo();
if (dbCard) { if (dbCard) {
card->setPT(dbCard->getPowTough()); card->setPT(dbCard->getPowTough());
} }