Merge pull request #1921 from ctrlaltca/number

Implemented !setnumber!
This commit is contained in:
ctrlaltca 2016-04-11 15:16:25 +02:00
commit 4f30b5cd31
6 changed files with 49 additions and 6 deletions

View file

@ -172,7 +172,8 @@ CardInfo::CardInfo(const QString &_name,
int _tableRow,
const SetList &_sets,
const QStringMap &_customPicURLs,
MuidMap _muIds
MuidMap _muIds,
QStringMap _setNumbers
)
: name(_name),
isToken(_isToken),
@ -190,6 +191,7 @@ CardInfo::CardInfo(const QString &_name,
loyalty(_loyalty),
customPicURLs(_customPicURLs),
muIds(_muIds),
setNumbers(_setNumbers),
cipt(_cipt),
tableRow(_tableRow)
{
@ -316,6 +318,10 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
tmpSet=sets[i]->getShortName();
xml.writeAttribute("muId", QString::number(info->getMuId(tmpSet)));
tmpString = info->getSetNumber(tmpSet);
if(!tmpString.isEmpty())
xml.writeAttribute("num", info->getSetNumber(tmpSet));
tmpString = info->getCustomPicURL(tmpSet);
if(!tmpString.isEmpty())
xml.writeAttribute("picURL", tmpString);
@ -487,6 +493,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
QStringList colors, relatedCards, reverseRelatedCards;
QStringMap customPicURLs;
MuidMap muids;
QStringMap setNumbers;
SetList sets;
int tableRow = 0;
int loyalty = 0;
@ -518,6 +525,9 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
if (attrs.hasAttribute("picURL")) {
customPicURLs[setName] = attrs.value("picURL").toString();
}
if (attrs.hasAttribute("num")) {
setNumbers[setName] = attrs.value("num").toString();
}
} else if (xml.name() == "color")
colors << xml.readElementText();
else if (xml.name() == "related")
@ -540,7 +550,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
}
}
addCard(new CardInfo(name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, reverseRelatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, muids));
addCard(new CardInfo(name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, reverseRelatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, muids, setNumbers));
}
}
}

View file

@ -87,6 +87,7 @@ private:
int loyalty;
QStringMap customPicURLs;
MuidMap muIds;
QStringMap setNumbers;
bool cipt;
int tableRow;
QString pixmapCacheKey;
@ -107,7 +108,8 @@ public:
int _tableRow = 0,
const SetList &_sets = SetList(),
const QStringMap &_customPicURLs = QStringMap(),
MuidMap muids = MuidMap()
MuidMap muids = MuidMap(),
QStringMap _setNumbers = QStringMap()
);
~CardInfo();
inline const QString &getName() const { return name; }
@ -139,6 +141,7 @@ public:
bool getUpsideDownArt() const { return upsideDownArt; }
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
int getMuId(const QString &set) const { return muIds.value(set); }
QString getSetNumber(const QString &set) const { return setNumbers.value(set); }
QString getMainCardType() const;
QString getCorrectedName() const;
int getTableRow() const { return tableRow; }
@ -146,6 +149,7 @@ public:
void setLoyalty(int _loyalty) { loyalty = _loyalty; emit cardInfoChanged(this); }
void setCustomPicURL(const QString &_set, const QString &_customPicURL) { customPicURLs.insert(_set, _customPicURL); }
void setMuId(const QString &_set, const int &_muId) { muIds.insert(_set, _muId); }
void setSetNumber(const QString &_set, const QString &_setNumber) { setNumbers.insert(_set, _setNumber); }
void addToSet(CardSet *set);
void emitPixmapUpdated() { emit pixmapUpdated(); }
void refreshCachedSetNames();

View file

@ -220,6 +220,7 @@ QString PictureLoaderWorker::getPicUrl()
picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(muid)));
if (set)
{
picUrl.replace("!setnumber!", QUrl::toPercentEncoding(card->getSetNumber(set->getShortName())));
picUrl.replace("!setcode!", QUrl::toPercentEncoding(set->getShortName()));
picUrl.replace("!setcode_lower!", QUrl::toPercentEncoding(set->getShortName().toLower()));
picUrl.replace("!setname!", QUrl::toPercentEncoding(set->getLongName()));
@ -229,6 +230,7 @@ QString PictureLoaderWorker::getPicUrl()
if (
picUrl.contains("!name!") ||
picUrl.contains("!name_lower!") ||
picUrl.contains("!setnumber!") ||
picUrl.contains("!setcode!") ||
picUrl.contains("!setcode_lower!") ||
picUrl.contains("!setname!") ||