Import related cards in the card database

This commit is contained in:
Fabio Bas 2015-06-11 10:48:50 +02:00
parent 50b908c7c4
commit da84bb33e1
4 changed files with 28 additions and 9 deletions

View file

@ -482,13 +482,15 @@ CardInfo::CardInfo(CardDatabase *_db,
const QString &_powtough,
const QString &_text,
const QStringList &_colors,
const QStringList &_relatedCards,
int _loyalty,
bool _cipt,
int _tableRow,
const SetList &_sets,
const QStringMap &_customPicURLs,
const QStringMap &_customPicURLsHq,
MuidMap _muIds)
MuidMap _muIds
)
: db(_db),
name(_name),
isToken(_isToken),
@ -499,6 +501,7 @@ CardInfo::CardInfo(CardDatabase *_db,
powtough(_powtough),
text(_text),
colors(_colors),
relatedCards(_relatedCards),
loyalty(_loyalty),
customPicURLs(_customPicURLs),
customPicURLsHq(_customPicURLsHq),
@ -685,6 +688,10 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
for (int i = 0; i < colors.size(); i++)
xml.writeTextElement("color", colors[i]);
const QStringList &related = info->getRelatedCards();
for (int i = 0; i < related.size(); i++)
xml.writeTextElement("related", related[i]);
xml.writeTextElement("manacost", info->getManaCost());
xml.writeTextElement("cmc", info->getCmc());
xml.writeTextElement("type", info->getCardType());
@ -852,7 +859,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
break;
if (xml.name() == "card") {
QString name, manacost, cmc, type, pt, text;
QStringList colors;
QStringList colors, relatedCards;
QStringMap customPicURLs, customPicURLsHq;
MuidMap muids;
SetList sets;
@ -890,6 +897,8 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
}
} else if (xml.name() == "color")
colors << xml.readElementText();
else if (xml.name() == "related")
relatedCards << xml.readElementText();
else if (xml.name() == "tablerow")
tableRow = xml.readElementText().toInt();
else if (xml.name() == "cipt")
@ -901,7 +910,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
}
if (isToken == tokens) {
addCard(new CardInfo(this, name, isToken, manacost, cmc, type, pt, text, colors, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
addCard(new CardInfo(this, name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
}
}
}

View file

@ -138,6 +138,7 @@ private:
bool cipt;
int tableRow;
QString pixmapCacheKey;
QStringList relatedCards;
public:
CardInfo(CardDatabase *_db,
const QString &_name = QString(),
@ -148,13 +149,15 @@ public:
const QString &_powtough = QString(),
const QString &_text = QString(),
const QStringList &_colors = QStringList(),
const QStringList &_relatedCards = QStringList(),
int _loyalty = 0,
bool _cipt = false,
int _tableRow = 0,
const SetList &_sets = SetList(),
const QStringMap &_customPicURLs = QStringMap(),
const QStringMap &_customPicURLsHq = QStringMap(),
MuidMap muids = MuidMap());
MuidMap muids = MuidMap()
);
~CardInfo();
const QString &getName() const { return name; }
const QString &getSimpleName() const { return simpleName; }
@ -174,6 +177,7 @@ public:
void setText(const QString &_text) { text = _text; emit cardInfoChanged(this); }
void setColors(const QStringList &_colors) { colors = _colors; emit cardInfoChanged(this); }
const QStringList &getColors() const { return colors; }
const QStringList &getRelatedCards() const { return relatedCards; }
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
QString getCustomPicURLHq(const QString &set) const { return customPicURLsHq.value(set); }
int getMuId(const QString &set) const { return muIds.value(set); }