Exemple #1
0
bool InnerDecklistNode::readElement(QXmlStreamReader *xml)
{
	while (!xml->atEnd()) {
		xml->readNext();
		const QString childName = xml->name().toString();
		if (xml->isStartElement()) {
			if (childName == "zone") {
				InnerDecklistNode *newZone = new InnerDecklistNode(xml->attributes().value("name").toString(), this);
				newZone->readElement(xml);
			} else if (childName == "card") {
				float price = (xml->attributes().value("price") != NULL) ? xml->attributes().value("price").toString().toFloat() : 0;
				DecklistCardNode *newCard = new DecklistCardNode(xml->attributes().value("name").toString(), xml->attributes().value("number").toString().toInt(), price, this);
				newCard->readElement(xml);
			}
		} else if (xml->isEndElement() && (childName == "zone"))
			return false;
	}
	return true;
}
Exemple #2
0
bool DeckList::readElement(QXmlStreamReader *xml)
{
	const QString childName = xml->name().toString();
	if (xml->isStartElement()) {
		if (childName == "deckname")
			name = xml->readElementText();
		else if (childName == "comments")
			comments = xml->readElementText();
		else if (childName == "zone") {
			InnerDecklistNode *newZone = new InnerDecklistNode(xml->attributes().value("name").toString(), root);
			newZone->readElement(xml);
		} else if (childName == "sideboard_plan") {
			SideboardPlan *newSideboardPlan = new SideboardPlan;
			if (newSideboardPlan->readElement(xml))
				sideboardPlans.insert(newSideboardPlan->getName(), newSideboardPlan);
			else
				delete newSideboardPlan;
		}
	} else if (xml->isEndElement() && (childName == "cockatrice_deck"))
		return false;
	return true;
}