[Card] Pass localized card names and texts into CardInfo construction

Address review: instead of constructing the card and then calling
setLocalizedName/setLocalizedText (which emit a cardInfoChanged signal per
language), both constructors, both newInstance overloads and their callers
(cards.xml v4 parser and the binary cache reader) now pass the localized maps
as constructor arguments.
This commit is contained in:
Lukas Brübach 2026-09-18 05:11:27 +02:00
parent 8bb2337117
commit c35aff8b7f
4 changed files with 44 additions and 29 deletions

View file

@ -301,9 +301,6 @@ CardInfoPtr readCard(QDataStream &in, const SetNameMap &sets)
reverse.append(readRelation(in));
}
CardInfoPtr card = CardInfo::newInstance(name, text, isToken, propertiesBlob, related, reverse, cardSets, ui,
simpleName, altNames, false);
const QMap<QString, QString> localizedNames = readStringMap(in);
if (in.status() != QDataStream::Ok) {
return nullptr;
@ -312,12 +309,9 @@ CardInfoPtr readCard(QDataStream &in, const SetNameMap &sets)
if (in.status() != QDataStream::Ok) {
return nullptr;
}
for (auto it = localizedNames.constBegin(); it != localizedNames.constEnd(); ++it) {
card->setLocalizedName(it.key(), it.value());
}
for (auto it = localizedTexts.constBegin(); it != localizedTexts.constEnd(); ++it) {
card->setLocalizedText(it.key(), it.value());
}
CardInfoPtr card = CardInfo::newInstance(name, text, isToken, propertiesBlob, related, reverse, cardSets, ui,
simpleName, altNames, false, localizedNames, localizedTexts);
return card;
}