[CardInfo] use QString QHash instead of QVariantHash for properties (#7063)
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 44 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Servatrice_Debian 12 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 15 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled

* [CardInfo] use QString QHash instead of QVariantHash for properties

* bump CACHE_VERSION

* cleanups
This commit is contained in:
RickyRister 2026-08-02 20:02:37 -07:00 committed by GitHub
parent b44dcf5951
commit 1ed9823b56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 70 additions and 73 deletions

View file

@ -12,7 +12,6 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QSharedPointer> #include <QSharedPointer>
#include <QString> #include <QString>
#include <QVariant>
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
@ -24,7 +23,7 @@ using CardInfoPtr = QSharedPointer<CardInfo>;
namespace namespace
{ {
QByteArray serializeProperties(const QVariantHash &props) QByteArray serializeProperties(const QHash<QString, QString> &props)
{ {
QByteArray blob; QByteArray blob;
QDataStream out(&blob, QIODevice::WriteOnly); QDataStream out(&blob, QIODevice::WriteOnly);
@ -48,7 +47,7 @@ void CardInfo::ensurePropertiesLoaded() const
propertiesLoaded = true; propertiesLoaded = true;
} }
const QVariantHash &CardInfo::getPropertiesHash() const const QHash<QString, QString> &CardInfo::getPropertiesHash() const
{ {
ensurePropertiesLoaded(); ensurePropertiesLoaded();
return propertiesCache; return propertiesCache;
@ -57,7 +56,7 @@ const QVariantHash &CardInfo::getPropertiesHash() const
void CardInfo::setProperty(const QString &_name, const QString &_value) void CardInfo::setProperty(const QString &_name, const QString &_value)
{ {
ensurePropertiesLoaded(); ensurePropertiesLoaded();
if (propertiesCache.value(_name).toString() == _value) { if (propertiesCache.value(_name) == _value) {
return; return;
} }
propertiesCache.insert(_name, _value); propertiesCache.insert(_name, _value);
@ -65,7 +64,7 @@ void CardInfo::setProperty(const QString &_name, const QString &_value)
emit cardInfoChanged(smartThis); emit cardInfoChanged(smartThis);
} }
void CardInfo::setProperties(const QVariantHash &_props) void CardInfo::setProperties(const QHash<QString, QString> &_props)
{ {
ensurePropertiesLoaded(); ensurePropertiesLoaded();
propertiesCache = _props; propertiesCache = _props;
@ -76,7 +75,7 @@ void CardInfo::setProperties(const QVariantHash &_props)
CardInfo::CardInfo(const QString &_name, CardInfo::CardInfo(const QString &_name,
const QString &_text, const QString &_text,
bool _isToken, bool _isToken,
QVariantHash _properties, QHash<QString, QString> _properties,
const QList<CardRelation *> &_relatedCards, const QList<CardRelation *> &_relatedCards,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
SetToPrintingsMap _sets, SetToPrintingsMap _sets,
@ -122,7 +121,7 @@ CardInfoPtr CardInfo::newInstance(const QString &_name)
CardInfoPtr CardInfo::newInstance(const QString &_name, CardInfoPtr CardInfo::newInstance(const QString &_name,
const QString &_text, const QString &_text,
bool _isToken, bool _isToken,
QVariantHash _properties, QHash<QString, QString> _properties,
const QList<CardRelation *> &_relatedCards, const QList<CardRelation *> &_relatedCards,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
SetToPrintingsMap _sets, SetToPrintingsMap _sets,
@ -210,10 +209,10 @@ void CardInfo::addToSet(const CardSetPtr &_set, const PrintingInfo &_info)
refreshCachedSets(); refreshCachedSets();
} }
void CardInfo::combineLegalities(const QVariantHash &props) void CardInfo::combineLegalities(const QHash<QString, QString> &props)
{ {
ensurePropertiesLoaded(); ensurePropertiesLoaded();
QHashIterator<QString, QVariant> it(props); QHashIterator it(props);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
if (it.key().startsWith("format-")) { if (it.key().startsWith("format-")) {

View file

@ -76,10 +76,10 @@ private:
QString text; ///< Text description or rules text of the card. QString text; ///< Text description or rules text of the card.
bool isToken; ///< Whether this card is a token or not. bool isToken; ///< Whether this card is a token or not.
// Properties are stored as a pre-serialized blob (cheap to load) and the // Properties are stored as a pre-serialized blob (cheap to load) and the
// QVariantHash is materialized on first query, so database load avoids // QHash<QString, QString> is materialized on first query, so database load avoids
// constructing thousands of QVariants per card. // constructing thousands of QStrings per card.
mutable QByteArray propertiesBlob; ///< Serialized properties (load form). mutable QByteArray propertiesBlob; ///< Serialized properties (load form).
mutable QVariantHash propertiesCache; ///< Materialized properties (query form). mutable QHash<QString, QString> propertiesCache; ///< Materialized properties (query form).
mutable bool propertiesLoaded = false; ///< Whether propertiesCache is valid. mutable bool propertiesLoaded = false; ///< Whether propertiesCache is valid.
mutable QMutex propertiesMutex; ///< Guards lazy materialization. mutable QMutex propertiesMutex; ///< Guards lazy materialization.
@ -114,7 +114,7 @@ public:
explicit CardInfo(const QString &_name, explicit CardInfo(const QString &_name,
const QString &_text, const QString &_text,
bool _isToken, bool _isToken,
QVariantHash _properties, QHash<QString, QString> _properties,
const QList<CardRelation *> &_relatedCards, const QList<CardRelation *> &_relatedCards,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
SetToPrintingsMap _sets, SetToPrintingsMap _sets,
@ -127,7 +127,7 @@ public:
* Used by the binary cache reader to skip recomputing @p _simpleName and * Used by the binary cache reader to skip recomputing @p _simpleName and
* @p _altNames (which otherwise require a Unicode normalization and a full * @p _altNames (which otherwise require a Unicode normalization and a full
* printing scan). Properties are supplied as a pre-serialized @p _propertiesBlob * printing scan). Properties are supplied as a pre-serialized @p _propertiesBlob
* so the QVariantHash is not built at load time (it is materialized on first * so the QHash<QString, QString> is not built at load time (it is materialized on first
* query). * query).
* *
* @param _name The card name. * @param _name The card name.
@ -194,7 +194,7 @@ public:
static CardInfoPtr newInstance(const QString &_name, static CardInfoPtr newInstance(const QString &_name,
const QString &_text, const QString &_text,
bool _isToken, bool _isToken,
QVariantHash _properties, QHash<QString, QString> _properties,
const QList<CardRelation *> &_relatedCards, const QList<CardRelation *> &_relatedCards,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
SetToPrintingsMap _sets, SetToPrintingsMap _sets,
@ -288,12 +288,12 @@ public:
{ {
return getPropertiesHash().keys(); return getPropertiesHash().keys();
} }
[[nodiscard]] const QVariantHash &getPropertiesHash() const; [[nodiscard]] const QHash<QString, QString> &getPropertiesHash() const;
/** /**
* @brief Stores the pre-serialized properties blob and invalidates the * @brief Stores the pre-serialized properties blob and invalidates the
* materialized cache. Used by the binary cache reader so the * materialized cache. Used by the binary cache reader so the
* QVariantHash is not built at load time. * QHash<QString, QString> is not built at load time.
* @param _blob The serialized properties (as written by the cache writer). * @param _blob The serialized properties (as written by the cache writer).
*/ */
void setPropertiesBlob(QByteArray _blob) const void setPropertiesBlob(QByteArray _blob) const
@ -305,10 +305,10 @@ public:
} }
[[nodiscard]] QString getProperty(const QString &propertyName) const [[nodiscard]] QString getProperty(const QString &propertyName) const
{ {
return getPropertiesHash().value(propertyName).toString(); return getPropertiesHash().value(propertyName);
} }
void setProperty(const QString &_name, const QString &_value); void setProperty(const QString &_name, const QString &_value);
void setProperties(const QVariantHash &_props); void setProperties(const QHash<QString, QString> &_props);
[[nodiscard]] bool hasProperty(const QString &propertyName) const [[nodiscard]] bool hasProperty(const QString &propertyName) const
{ {
return getPropertiesHash().contains(propertyName); return getPropertiesHash().contains(propertyName);
@ -415,7 +415,7 @@ public:
* *
* @param props Key-value mapping of format legalities. * @param props Key-value mapping of format legalities.
*/ */
void combineLegalities(const QVariantHash &props); void combineLegalities(const QHash<QString, QString> &props);
/** /**
* @brief Refreshes all cached fields that are calculated from the contained sets and printings. * @brief Refreshes all cached fields that are calculated from the contained sets and printings.

View file

@ -66,7 +66,7 @@ QVariant CardInfoComparator::getProperty(const CardInfoPtr &card, const QString
return card->getIsToken(); return card->getIsToken();
} }
// Otherwise, check if it's a custom property in the QVariantHash // Otherwise, check if it's a custom property in the properties hash
if (card->hasProperty(property)) { if (card->hasProperty(property)) {
return card->getProperty(property); return card->getProperty(property);
} }

View file

@ -13,12 +13,11 @@
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QFile> #include <QFile>
#include <QSaveFile> #include <QSaveFile>
#include <QVariantHash>
namespace namespace
{ {
constexpr quint32 CACHE_MAGIC = 0x43445243; // "CDRC" constexpr quint32 CACHE_MAGIC = 0x43445243; // "CDRC"
constexpr quint32 CACHE_VERSION = 1; constexpr quint32 CACHE_VERSION = 2;
// ---- Primitives ----------------------------------------------------------- // ---- Primitives -----------------------------------------------------------
@ -34,11 +33,11 @@ QString readString(QDataStream &in)
return s; return s;
} }
// Stores a QVariantHash as a single pre-serialized blob. The reader keeps the // Stores a QHash<QString, QString> as a single pre-serialized blob. The reader keeps the
// blob as-is and materializes the QVariantHash lazily on first query, which is // blob as-is and materializes the QHash<QString, QString> lazily on first query, which is
// what removes the allocation storm from database load (see card_info.cpp / // what removes the allocation storm from database load (see card_info.cpp /
// printing_info.cpp). // printing_info.cpp).
void writeHashBlob(QDataStream &out, const QVariantHash &h) void writeHashBlob(QDataStream &out, const QHash<QString, QString> &h)
{ {
QByteArray blob; QByteArray blob;
QDataStream blobOut(&blob, QIODevice::WriteOnly); QDataStream blobOut(&blob, QIODevice::WriteOnly);

View file

@ -172,7 +172,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
if (xmlName == "card") { if (xmlName == "card") {
QString name = QString(""); QString name = QString("");
QString text = QString(""); QString text = QString("");
QVariantHash properties = QVariantHash(); QHash<QString, QString> properties;
QString colors = QString(""); QString colors = QString("");
QList<CardRelation *> relatedCards, reverseRelatedCards; QList<CardRelation *> relatedCards, reverseRelatedCards;
auto _sets = SetToPrintingsMap(); auto _sets = SetToPrintingsMap();
@ -229,7 +229,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
// behaviour. Without this check, disabling a set has no effect on v3 databases. // behaviour. Without this check, disabling a set has no effect on v3 databases.
if (set->getEnabled()) { if (set->getEnabled()) {
PrintingInfo setInfo(set); PrintingInfo setInfo(set);
QVariantHash printingProps; QHash<QString, QString> printingProps;
if (attrs.hasAttribute("muId")) { if (attrs.hasAttribute("muId")) {
printingProps.insert("muid", attrs.value("muId").toString()); printingProps.insert("muid", attrs.value("muId").toString());
} }

View file

@ -243,9 +243,9 @@ void CockatriceXml4Parser::loadSetsFromXml(QXmlStreamReader &xml)
} }
} }
QVariantHash CockatriceXml4Parser::loadCardPropertiesFromXml(QXmlStreamReader &xml) QHash<QString, QString> CockatriceXml4Parser::loadCardPropertiesFromXml(QXmlStreamReader &xml)
{ {
QVariantHash properties = QVariantHash(); QHash<QString, QString> properties;
while (!xml.atEnd()) { while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::EndElement) { if (xml.readNext() == QXmlStreamReader::EndElement) {
break; break;
@ -272,7 +272,7 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
if (xmlName == "card") { if (xmlName == "card") {
QString name = QString(""); QString name = QString("");
QString text = QString(""); QString text = QString("");
QVariantHash properties = QVariantHash(); QHash<QString, QString> properties;
QList<CardRelation *> relatedCards, reverseRelatedCards; QList<CardRelation *> relatedCards, reverseRelatedCards;
auto _sets = SetToPrintingsMap(); auto _sets = SetToPrintingsMap();
int tableRow = 0; int tableRow = 0;
@ -315,7 +315,7 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
auto set = internalAddSet(setName); auto set = internalAddSet(setName);
if (set->getEnabled()) { if (set->getEnabled()) {
PrintingInfo printingInfo(set); PrintingInfo printingInfo(set);
QVariantHash printingProps; QHash<QString, QString> printingProps;
for (QXmlStreamAttribute attr : attrs) { for (QXmlStreamAttribute attr : attrs) {
QString attrName = attr.name().toString(); QString attrName = attr.name().toString();
if (attrName == "picURL") { if (attrName == "picURL") {

View file

@ -19,7 +19,7 @@ inline Q_LOGGING_CATEGORY(CockatriceXml4Log, "cockatrice_xml.xml_4_parser");
* making the parser more extensible and schema-compliant. * making the parser more extensible and schema-compliant.
* *
* @note Differences from v3: * @note Differences from v3:
* - Card properties are stored in <prop> blocks as a QVariantHash. * - Card properties are stored in <prop> blocks as a QHash<QString, QString>.
* - Sets can include a <priority> element. * - Sets can include a <priority> element.
* - Supports user preferences via ICardPreferenceProvider (e.g., skipping rebalanced cards). * - Supports user preferences via ICardPreferenceProvider (e.g., skipping rebalanced cards).
* - Related cards support persistent relations and multiple attach types (e.g., transform). * - Related cards support persistent relations and multiple attach types (e.g., transform).
@ -70,9 +70,9 @@ private:
/** /**
* @brief Loads a generic <prop> block from a <card> element. * @brief Loads a generic <prop> block from a <card> element.
* @param xml The open QXmlStreamReader positioned at a <prop> element. * @param xml The open QXmlStreamReader positioned at a <prop> element.
* @return A QVariantHash mapping property names to values. * @return A QHash<QString, QString> mapping property names to values.
*/ */
QVariantHash loadCardPropertiesFromXml(QXmlStreamReader &xml); QHash<QString, QString> loadCardPropertiesFromXml(QXmlStreamReader &xml);
/** /**
* @brief Load all <card> elements from the XML stream. * @brief Load all <card> elements from the XML stream.

View file

@ -27,14 +27,14 @@ void PrintingInfo::ensurePropertiesLoaded() const
void PrintingInfo::setProperty(const QString &_name, const QString &_value) void PrintingInfo::setProperty(const QString &_name, const QString &_value)
{ {
ensurePropertiesLoaded(); ensurePropertiesLoaded();
if (propertiesCache.value(_name).toString() == _value) { if (propertiesCache.value(_name) == _value) {
return; return;
} }
propertiesCache.insert(_name, _value); propertiesCache.insert(_name, _value);
setProperties(propertiesCache); setProperties(propertiesCache);
} }
void PrintingInfo::setProperties(const QVariantHash &_props) void PrintingInfo::setProperties(const QHash<QString, QString> &_props)
{ {
ensurePropertiesLoaded(); ensurePropertiesLoaded();
propertiesCache = _props; propertiesCache = _props;
@ -48,10 +48,10 @@ void PrintingInfo::setProperties(const QVariantHash &_props)
*/ */
QString PrintingInfo::getUuid() const QString PrintingInfo::getUuid() const
{ {
return getPropertiesHash().value("uuid").toString(); return getPropertiesHash().value("uuid");
} }
QString PrintingInfo::getFlavorName() const QString PrintingInfo::getFlavorName() const
{ {
return getPropertiesHash().value("flavorName").toString(); return getPropertiesHash().value("flavorName");
} }

View file

@ -70,10 +70,10 @@ private:
CardSetPtr set; ///< The set this variation belongs to. CardSetPtr set; ///< The set this variation belongs to.
// Properties are stored as a pre-serialized blob (cheap to load) and the // Properties are stored as a pre-serialized blob (cheap to load) and the
// QVariantHash is materialized on first query. This avoids constructing // QHash<QString, QString> is materialized on first query. This avoids constructing
// thousands of QVariants per card at database-load time. // thousands of QStrings per card at database-load time.
mutable QByteArray propertiesBlob; ///< Serialized properties (load form). mutable QByteArray propertiesBlob; ///< Serialized properties (load form).
mutable QVariantHash propertiesCache; ///< Materialized properties (query form). mutable QHash<QString, QString> propertiesCache; ///< Materialized properties (query form).
mutable bool propertiesLoaded = false; ///< Whether propertiesCache is valid. mutable bool propertiesLoaded = false; ///< Whether propertiesCache is valid.
mutable QSharedPointer<QBasicMutex> propertiesMutex = mutable QSharedPointer<QBasicMutex> propertiesMutex =
QSharedPointer<QBasicMutex>::create(); ///< Guards lazy materialization. QSharedPointer<QBasicMutex>::create(); ///< Guards lazy materialization.
@ -101,7 +101,7 @@ public:
return getPropertiesHash().keys(); return getPropertiesHash().keys();
} }
[[nodiscard]] const QVariantHash &getPropertiesHash() const [[nodiscard]] const QHash<QString, QString> &getPropertiesHash() const
{ {
ensurePropertiesLoaded(); ensurePropertiesLoaded();
return propertiesCache; return propertiesCache;
@ -115,7 +115,7 @@ public:
*/ */
[[nodiscard]] QString getProperty(const QString &propertyName) const [[nodiscard]] QString getProperty(const QString &propertyName) const
{ {
return getPropertiesHash().value(propertyName).toString(); return getPropertiesHash().value(propertyName);
} }
/** /**
@ -127,12 +127,12 @@ public:
* @param _value The string value to assign. * @param _value The string value to assign.
*/ */
void setProperty(const QString &_name, const QString &_value); void setProperty(const QString &_name, const QString &_value);
void setProperties(const QVariantHash &_props); void setProperties(const QHash<QString, QString> &_props);
/** /**
* @brief Stores the pre-serialized properties blob and marks the materialized * @brief Stores the pre-serialized properties blob and marks the materialized
* cache as invalid. Used by the binary cache reader to avoid building a * cache as invalid. Used by the binary cache reader to avoid building a
* QVariantHash at load time. * QHash<QString, QString> at load time.
* @param _blob The serialized properties (as written by the cache writer). * @param _blob The serialized properties (as written by the cache writer).
*/ */
void setPropertiesBlob(QByteArray _blob) const void setPropertiesBlob(QByteArray _blob) const

View file

@ -18,7 +18,7 @@ static const QList<AllowedCount> kSingletonCounts = {{1, "legal"}, {0, "banned"}
SplitCardPart::SplitCardPart(const QString &_name, SplitCardPart::SplitCardPart(const QString &_name,
const QString &_text, const QString &_text,
const QVariantHash &_properties, const QHash<QString, QString> &_properties,
const PrintingInfo &_printingInfo) const PrintingInfo &_printingInfo)
: name(_name), text(_text), properties(_properties), printingInfo(_printingInfo) : name(_name), text(_text), properties(_properties), printingInfo(_printingInfo)
{ {
@ -135,7 +135,7 @@ static void sortAndReduceColors(QString &colors)
CardInfoPtr OracleImporter::addCard(QString name, CardInfoPtr OracleImporter::addCard(QString name,
const QString &text, const QString &text,
bool isToken, bool isToken,
QVariantHash properties, QHash<QString, QString> properties,
const QList<CardRelation *> &relatedCards, const QList<CardRelation *> &relatedCards,
const PrintingInfo &printingInfo) const PrintingInfo &printingInfo)
{ {
@ -152,7 +152,7 @@ CardInfoPtr OracleImporter::addCard(QString name,
} }
// Remove {} around mana costs, except if it's split cost // Remove {} around mana costs, except if it's split cost
QString manacost = properties.value("manacost").toString(); QString manacost = properties.value("manacost");
if (!manacost.isEmpty()) { if (!manacost.isEmpty()) {
QStringList symbols = manacost.split("}"); QStringList symbols = manacost.split("}");
QString formattedCardCost; QString formattedCardCost;
@ -169,12 +169,12 @@ CardInfoPtr OracleImporter::addCard(QString name,
} }
// fix colors // fix colors
QString allColors = properties.value("colors").toString(); QString allColors = properties.value("colors");
if (allColors.size() > 1) { if (allColors.size() > 1) {
sortAndReduceColors(allColors); sortAndReduceColors(allColors);
properties.insert("colors", allColors); properties.insert("colors", allColors);
} }
QString allColorIdent = properties.value("coloridentity").toString(); QString allColorIdent = properties.value("coloridentity");
if (allColorIdent.size() > 1) { if (allColorIdent.size() > 1) {
sortAndReduceColors(allColorIdent); sortAndReduceColors(allColorIdent);
properties.insert("coloridentity", allColorIdent); properties.insert("coloridentity", allColorIdent);
@ -182,16 +182,15 @@ CardInfoPtr OracleImporter::addCard(QString name,
// DETECT CARD POSITIONING INFO // DETECT CARD POSITIONING INFO
bool landscapeOrientation = properties.value("maintype").toString() == "Battle" || bool landscapeOrientation = properties.value("maintype") == "Battle" || properties.value("layout") == "split" ||
properties.value("layout").toString() == "split" || properties.value("layout") == "planar";
properties.value("layout").toString() == "planar";
// cards that enter the field tapped // cards that enter the field tapped
bool cipt = parseCipt(name, text) || landscapeOrientation; bool cipt = parseCipt(name, text) || landscapeOrientation;
// table row // table row
int tableRow = 1; int tableRow = 1;
QString mainCardType = properties.value("maintype").toString(); QString mainCardType = properties.value("maintype");
if (mainCardType == "Land") { if (mainCardType == "Land") {
tableRow = 0; tableRow = 0;
} else if (mainCardType == "Sorcery" || mainCardType == "Instant") { } else if (mainCardType == "Sorcery" || mainCardType == "Instant") {
@ -201,11 +200,11 @@ CardInfoPtr OracleImporter::addCard(QString name,
} }
// card side // card side
QString side = properties.value("side").toString() == "b" ? "back" : "front"; QString side = properties.value("side") == "b" ? "back" : "front";
properties.insert("side", side); properties.insert("side", side);
// upsideDown (flip cards) // upsideDown (flip cards)
QString layout = properties.value("layout").toString(); QString layout = properties.value("layout");
bool upsideDown = layout == "flip" && side == "back"; bool upsideDown = layout == "flip" && side == "back";
// insert the card and its properties // insert the card and its properties
@ -279,7 +278,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
} }
// card properties // card properties
QVariantHash properties; QHash<QString, QString> properties;
for (auto i = cardProperties.cbegin(), end = cardProperties.cend(); i != end; ++i) { for (auto i = cardProperties.cbegin(), end = cardProperties.cend(); i != end; ++i) {
QString mtgjsonProperty = i.key(); QString mtgjsonProperty = i.key();
QString xmlPropertyName = i.value(); QString xmlPropertyName = i.value();
@ -291,7 +290,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
// per-set properties // per-set properties
PrintingInfo printingInfo = PrintingInfo(currentSet); PrintingInfo printingInfo = PrintingInfo(currentSet);
QVariantHash printingProps; QHash<QString, QString> printingProps;
for (auto i = setInfoProperties.cbegin(), end = setInfoProperties.cend(); i != end; ++i) { for (auto i = setInfoProperties.cbegin(), end = setInfoProperties.cend(); i != end; ++i) {
QString mtgjsonProperty = i.key(); QString mtgjsonProperty = i.key();
QString xmlPropertyName = i.value(); QString xmlPropertyName = i.value();
@ -431,7 +430,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
QList<QPair<QList<SplitCardPart>, QString>> partsAndNames = splitCards.values(); QList<QPair<QList<SplitCardPart>, QString>> partsAndNames = splitCards.values();
for (auto [splitCardParts, name] : partsAndNames) { for (auto [splitCardParts, name] : partsAndNames) {
QString text; QString text;
QVariantHash properties; QHash<QString, QString> properties;
PrintingInfo printingInfo; PrintingInfo printingInfo;
for (const SplitCardPart &tmp : splitCardParts) { for (const SplitCardPart &tmp : splitCardParts) {
@ -444,11 +443,11 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
properties = tmp.getProperties(); properties = tmp.getProperties();
printingInfo = tmp.getPrintingInfo(); printingInfo = tmp.getPrintingInfo();
} else { } else {
const QVariantHash &tmpProps = tmp.getProperties(); const QHash<QString, QString> &tmpProps = tmp.getProperties();
for (auto i = tmpProps.cbegin(), end = tmpProps.cend(); i != end; ++i) { for (auto i = tmpProps.cbegin(), end = tmpProps.cend(); i != end; ++i) {
QString prop = i.key(); QString prop = i.key();
QString originalPropertyValue = properties.value(prop).toString(); QString originalPropertyValue = properties.value(prop);
QString thisCardPropertyValue = i.value().toString(); QString thisCardPropertyValue = i.value();
if (!thisCardPropertyValue.isEmpty() && originalPropertyValue != thisCardPropertyValue) { if (!thisCardPropertyValue.isEmpty() && originalPropertyValue != thisCardPropertyValue) {
if (originalPropertyValue.isEmpty()) { // don't create //es if one field is empty if (originalPropertyValue.isEmpty()) { // don't create //es if one field is empty
properties.insert(prop, thisCardPropertyValue); properties.insert(prop, thisCardPropertyValue);

View file

@ -95,7 +95,7 @@ class SplitCardPart
public: public:
SplitCardPart(const QString &_name, SplitCardPart(const QString &_name,
const QString &_text, const QString &_text,
const QVariantHash &_properties, const QHash<QString, QString> &_properties,
const PrintingInfo &_printingInfo); const PrintingInfo &_printingInfo);
inline const QString &getName() const inline const QString &getName() const
{ {
@ -105,7 +105,7 @@ public:
{ {
return text; return text;
} }
inline const QVariantHash &getProperties() const inline const QHash<QString, QString> &getProperties() const
{ {
return properties; return properties;
} }
@ -117,7 +117,7 @@ public:
private: private:
QString name; QString name;
QString text; QString text;
QVariantHash properties; QHash<QString, QString> properties;
PrintingInfo printingInfo; PrintingInfo printingInfo;
}; };
@ -142,7 +142,7 @@ private:
CardInfoPtr addCard(QString name, CardInfoPtr addCard(QString name,
const QString &text, const QString &text,
bool isToken, bool isToken,
QVariantHash properties, QHash<QString, QString> properties,
const QList<CardRelation *> &relatedCards, const QList<CardRelation *> &relatedCards,
const PrintingInfo &printingInfo); const PrintingInfo &printingInfo);
signals: signals: