/* * Copyright 2007-2008 Ben Boeckel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ /** * \file sigmod/CoinListItem.cpp */ // Header include #include "CoinListItem.h" // Sigmod includes #include "CoinList.h" #include "Macros.h" #include "Sigmod.h" const QStringList Sigmod::CoinListItem::TypeStr = QStringList() << "Item" << "Team Member"; Sigmod::CoinListItem::CoinListItem(const CoinListItem& item) : Object(item.parent(), item.id()) { *this = item; } Sigmod::CoinListItem::CoinListItem(const CoinList* parent, const int id) : Object(parent, id), m_type(Item), m_object(-1), m_cost(0) { } Sigmod::CoinListItem::CoinListItem(const CoinListItem& item, const CoinList* parent, const int id) : Object(parent, id) { *this = item; } Sigmod::CoinListItem::CoinListItem(const QDomElement& xml, const CoinList* parent, const int id) : Object(parent, id) { LOAD_ID(); load(xml); } void Sigmod::CoinListItem::validate() { TEST_BEGIN(); TEST(setObject, object); TEST(setCost, cost); TEST_END(); } void Sigmod::CoinListItem::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(type); LOAD(object); LOAD(cost); } QDomElement Sigmod::CoinListItem::save() const { SAVE_CREATE(); SAVE(type); SAVE(object); SAVE(cost); return xml; } void Sigmod::CoinListItem::setType(const Type type) { CHECK(type); } void Sigmod::CoinListItem::setObject(const int object) { if (((Item == m_type) && !sigmod()->itemById(object)) || ((Species == m_type) && !sigmod()->speciesById(object))) emit(error(bounds("object", object))); else CHECK(object); } void Sigmod::CoinListItem::setCost(const int cost) { if (cost <= 0) emit(error(bounds("cost", 1, INT_MAX, cost))); else CHECK(cost); } Sigmod::CoinListItem::Type Sigmod::CoinListItem::type() const { return m_type; } int Sigmod::CoinListItem::object() const { return m_object; } int Sigmod::CoinListItem::cost() const { return m_cost; } Sigmod::CoinListItem& Sigmod::CoinListItem::operator=(const CoinListItem& rhs) { if (this == &rhs) return *this; COPY(type); COPY(object); COPY(cost); return *this; }