Oracle: fetch release date and set type
and save them in cards.xml
This commit is contained in:
parent
a320af70da
commit
cb37073828
4 changed files with 31 additions and 11 deletions
|
@ -22,13 +22,15 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set)
|
||||||
xml.writeStartElement("set");
|
xml.writeStartElement("set");
|
||||||
xml.writeTextElement("name", set->getShortName());
|
xml.writeTextElement("name", set->getShortName());
|
||||||
xml.writeTextElement("longname", set->getLongName());
|
xml.writeTextElement("longname", set->getLongName());
|
||||||
|
xml.writeTextElement("settype", set->getSetType());
|
||||||
|
xml.writeTextElement("releasedate", set->getReleaseDate().toString(Qt::ISODate));
|
||||||
xml.writeEndElement();
|
xml.writeEndElement();
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardSet::CardSet(const QString &_shortName, const QString &_longName)
|
CardSet::CardSet(const QString &_shortName, const QString &_longName, const QString &_setType, const QDate &_releaseDate)
|
||||||
: shortName(_shortName), longName(_longName)
|
: shortName(_shortName), longName(_longName), setType(_setType), releaseDate(_releaseDate)
|
||||||
{
|
{
|
||||||
updateSortKey();
|
updateSortKey();
|
||||||
}
|
}
|
||||||
|
@ -703,7 +705,8 @@ void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
|
||||||
if (xml.readNext() == QXmlStreamReader::EndElement)
|
if (xml.readNext() == QXmlStreamReader::EndElement)
|
||||||
break;
|
break;
|
||||||
if (xml.name() == "set") {
|
if (xml.name() == "set") {
|
||||||
QString shortName, longName;
|
QString shortName, longName, setType;
|
||||||
|
QDate releaseDate;
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
if (xml.readNext() == QXmlStreamReader::EndElement)
|
if (xml.readNext() == QXmlStreamReader::EndElement)
|
||||||
break;
|
break;
|
||||||
|
@ -711,8 +714,12 @@ void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
|
||||||
shortName = xml.readElementText();
|
shortName = xml.readElementText();
|
||||||
else if (xml.name() == "longname")
|
else if (xml.name() == "longname")
|
||||||
longName = xml.readElementText();
|
longName = xml.readElementText();
|
||||||
|
else if (xml.name() == "settype")
|
||||||
|
setType = xml.readElementText();
|
||||||
|
else if (xml.name() == "releasedate")
|
||||||
|
releaseDate = QDate::fromString(xml.readElementText(), Qt::ISODate);
|
||||||
}
|
}
|
||||||
sets.insert(shortName, new CardSet(shortName, longName));
|
sets.insert(shortName, new CardSet(shortName, longName, setType, releaseDate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QDate>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
@ -27,11 +28,15 @@ class CardSet : public QList<CardInfo *> {
|
||||||
private:
|
private:
|
||||||
QString shortName, longName;
|
QString shortName, longName;
|
||||||
unsigned int sortKey;
|
unsigned int sortKey;
|
||||||
|
QDate releaseDate;
|
||||||
|
QString setType;
|
||||||
public:
|
public:
|
||||||
CardSet(const QString &_shortName = QString(), const QString &_longName = QString());
|
CardSet(const QString &_shortName = QString(), const QString &_longName = QString(), const QString &_setType = QString(), const QDate &_releaseDate = QDate());
|
||||||
QString getCorrectedShortName() const;
|
QString getCorrectedShortName() const;
|
||||||
QString getShortName() const { return shortName; }
|
QString getShortName() const { return shortName; }
|
||||||
QString getLongName() const { return longName; }
|
QString getLongName() const { return longName; }
|
||||||
|
QString getSetType() const { return setType; }
|
||||||
|
QDate getReleaseDate() const { return releaseDate; }
|
||||||
int getSortKey() const { return sortKey; }
|
int getSortKey() const { return sortKey; }
|
||||||
void setSortKey(unsigned int _sortKey);
|
void setSortKey(unsigned int _sortKey);
|
||||||
void updateSortKey();
|
void updateSortKey();
|
||||||
|
|
|
@ -30,6 +30,8 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
|
||||||
QString edition;
|
QString edition;
|
||||||
QString editionLong;
|
QString editionLong;
|
||||||
QVariant editionCards;
|
QVariant editionCards;
|
||||||
|
QString setType;
|
||||||
|
QDate releaseDate;
|
||||||
bool import;
|
bool import;
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
@ -37,12 +39,14 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
|
||||||
edition = map.value("code").toString();
|
edition = map.value("code").toString();
|
||||||
editionLong = map.value("name").toString();
|
editionLong = map.value("name").toString();
|
||||||
editionCards = map.value("cards");
|
editionCards = map.value("cards");
|
||||||
|
setType = map.value("type").toString();
|
||||||
|
releaseDate = map.value("releaseDate").toDate();
|
||||||
|
|
||||||
// core and expansion sets are marked to be imported by default
|
// core and expansion sets are marked to be imported by default
|
||||||
import = (0 == QString::compare(map.value("type").toString(), QString("core"), Qt::CaseInsensitive) ||
|
import = (0 == QString::compare(setType, QString("core"), Qt::CaseInsensitive) ||
|
||||||
0 == QString::compare(map.value("type").toString(), QString("expansion"), Qt::CaseInsensitive));
|
0 == QString::compare(setType, QString("expansion"), Qt::CaseInsensitive));
|
||||||
|
|
||||||
newSetList.append(SetToDownload(edition, editionLong, editionCards, import));
|
newSetList.append(SetToDownload(edition, editionLong, editionCards, import, setType, releaseDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
qSort(newSetList);
|
qSort(newSetList);
|
||||||
|
@ -237,7 +241,7 @@ int OracleImporter::startImport()
|
||||||
if(!curSet->getImport())
|
if(!curSet->getImport())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName());
|
CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName(), curSet->getSetType(), curSet->getReleaseDate());
|
||||||
if (!sets.contains(set->getShortName()))
|
if (!sets.contains(set->getShortName()))
|
||||||
sets.insert(set->getShortName(), set);
|
sets.insert(set->getShortName(), set);
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,18 @@ private:
|
||||||
QString shortName, longName;
|
QString shortName, longName;
|
||||||
bool import;
|
bool import;
|
||||||
QVariant cards;
|
QVariant cards;
|
||||||
|
QDate releaseDate;
|
||||||
|
QString setType;
|
||||||
public:
|
public:
|
||||||
const QString &getShortName() const { return shortName; }
|
const QString &getShortName() const { return shortName; }
|
||||||
const QString &getLongName() const { return longName; }
|
const QString &getLongName() const { return longName; }
|
||||||
const QVariant &getCards() const { return cards; }
|
const QVariant &getCards() const { return cards; }
|
||||||
|
const QString &getSetType() const { return setType; }
|
||||||
|
const QDate &getReleaseDate() const { return releaseDate; }
|
||||||
bool getImport() const { return import; }
|
bool getImport() const { return import; }
|
||||||
void setImport(bool _import) { import = _import; }
|
void setImport(bool _import) { import = _import; }
|
||||||
SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import)
|
SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import, const QString &_setType = QString(), const QDate &_releaseDate = QDate())
|
||||||
: shortName(_shortName), longName(_longName), import(_import), cards(_cards) { }
|
: shortName(_shortName), longName(_longName), import(_import), cards(_cards), setType(_setType), releaseDate(_releaseDate) { }
|
||||||
bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; }
|
bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue