diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-12-07 01:03:48 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-12-07 01:03:48 -0500 |
| commit | 7459a5a34a5bcf7011c4164e3c92c7770da09514 (patch) | |
| tree | 57c53a9fad0dbff587bc8249ec2e0d09308f5f7a /sigmod/CoinList.cpp | |
| parent | 67aefdbacc16395bda2a8bfb14004190ced25e00 (diff) | |
| download | sigen-7459a5a34a5bcf7011c4164e3c92c7770da09514.tar.gz sigen-7459a5a34a5bcf7011c4164e3c92c7770da09514.tar.xz sigen-7459a5a34a5bcf7011c4164e3c92c7770da09514.zip | |
Renamed CoinListObject to CoinListItem and added documentation for it
Diffstat (limited to 'sigmod/CoinList.cpp')
| -rw-r--r-- | sigmod/CoinList.cpp | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/sigmod/CoinList.cpp b/sigmod/CoinList.cpp index aeeceb46..4f0519e7 100644 --- a/sigmod/CoinList.cpp +++ b/sigmod/CoinList.cpp @@ -19,7 +19,7 @@ #include "CoinList.h" // Sigmod includes -#include "CoinListObject.h" +#include "CoinListItem.h" #include "Macros.h" #include "Sigmod.h" @@ -62,20 +62,20 @@ void Sigmod::CoinList::validate() TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); - if (!objectCount()) - emit(error("There are no objects")); + if (!itemCount()) + emit(error("There are no items")); QSet<int> idChecker; QSet<int> itemChecker; QSet<int> speciesChecker; - TEST_SUB_BEGIN(CoinListObject, objects); - TEST_SUB("object", id); - if (object->type() == CoinListObject::Item) + TEST_SUB_BEGIN(CoinListItem, items); + TEST_SUB("item", id); + if (object->type() == CoinListItem::Item) { - TEST_SUB_RAW(item, "object item", object); + TEST_SUB_RAW(item, "item item", object); } - else if (object->type() == CoinListObject::Species) + else if (object->type() == CoinListItem::Species) { - TEST_SUB_RAW(species, "object species", object); + TEST_SUB_RAW(species, "item species", object); } TEST_SUB_END(); // foreach (CoinListObject* object, m_objects) @@ -105,7 +105,7 @@ void Sigmod::CoinList::load(const QDomElement& xml) LOAD_BEGIN(); LOAD(name); LOAD(script); - LOAD_SUB(newObject, CoinListObject); + LOAD_SUB(newItem, CoinListItem); } QDomElement Sigmod::CoinList::save() const @@ -113,7 +113,7 @@ QDomElement Sigmod::CoinList::save() const SAVE_CREATE(); SAVE(name); SAVE(script); - SAVE_SUB(CoinListObject, objects); + SAVE_SUB(CoinListItem, items); return xml; } @@ -137,84 +137,84 @@ Sigcore::Script Sigmod::CoinList::script() const return m_script; } -const Sigmod::CoinListObject* Sigmod::CoinList::object(const int index) const +const Sigmod::CoinListItem* Sigmod::CoinList::item(const int index) const { - if (index < objectCount()) - return m_objects.at(index); + if (index < itemCount()) + return m_items.at(index); return NULL; } -Sigmod::CoinListObject* Sigmod::CoinList::object(const int index) +Sigmod::CoinListItem* Sigmod::CoinList::item(const int index) { - if (index < objectCount()) - return m_objects[index]; + if (index < itemCount()) + return m_items[index]; return NULL; } -const Sigmod::CoinListObject* Sigmod::CoinList::objectById(const int id) const +const Sigmod::CoinListItem* Sigmod::CoinList::itemById(const int id) const { - return object(objectIndex(id)); + return item(itemIndex(id)); } -Sigmod::CoinListObject* Sigmod::CoinList::objectById(const int id) +Sigmod::CoinListItem* Sigmod::CoinList::itemById(const int id) { - return object(objectIndex(id)); + return item(itemIndex(id)); } -int Sigmod::CoinList::objectIndex(const int id) const +int Sigmod::CoinList::itemIndex(const int id) const { - for (int i = 0; i < objectCount(); ++i) + for (int i = 0; i < itemCount(); ++i) { - if (m_objects[i]->id() == id) + if (m_items[i]->id() == id) return i; } return INT_MAX; } -int Sigmod::CoinList::objectCount() const +int Sigmod::CoinList::itemCount() const { - return m_objects.size(); + return m_items.size(); } -Sigmod::CoinListObject* Sigmod::CoinList::newObject() +Sigmod::CoinListItem* Sigmod::CoinList::newItem() { - return newObject(new CoinListObject(this, objectId())); + return newItem(new CoinListItem(this, itemId())); } -Sigmod::CoinListObject* Sigmod::CoinList::newObject(const QDomElement& xml) +Sigmod::CoinListItem* Sigmod::CoinList::newItem(const QDomElement& xml) { - return newObject(new CoinListObject(xml, this, objectId())); + return newItem(new CoinListItem(xml, this, itemId())); } -Sigmod::CoinListObject* Sigmod::CoinList::newObject(const CoinListObject& object) +Sigmod::CoinListItem* Sigmod::CoinList::newItem(const CoinListItem& item) { - return newObject(new CoinListObject(object, this, objectId())); + return newItem(new CoinListItem(item, this, itemId())); } -Sigmod::CoinListObject* Sigmod::CoinList::newObject(CoinListObject* object) +Sigmod::CoinListItem* Sigmod::CoinList::newItem(CoinListItem* item) { - m_objects.append(object); - return object; + m_items.append(item); + return item; } -void Sigmod::CoinList::deleteObject(const int index) +void Sigmod::CoinList::deleteItem(const int index) { - if (index < objectCount()) + if (index < itemCount()) { - delete m_objects[index]; - m_objects.removeAt(index); + delete m_items[index]; + m_items.removeAt(index); } } -void Sigmod::CoinList::deleteObjectById(const int id) +void Sigmod::CoinList::deleteItemById(const int id) { - deleteObject(objectIndex(id)); + deleteItem(itemIndex(id)); } -int Sigmod::CoinList::objectId() const +int Sigmod::CoinList::itemId() const { int i = 0; - while ((i < objectCount()) && (objectIndex(i) != INT_MAX)) + while ((i < itemCount()) && (itemIndex(i) != INT_MAX)) ++i; return i; } @@ -226,12 +226,12 @@ Sigmod::CoinList& Sigmod::CoinList::operator=(const CoinList& rhs) clear(); COPY(name); COPY(script); - COPY_SUB(CoinListObject, objects); + COPY_SUB(CoinListItem, items); return *this; } void Sigmod::CoinList::clear() { - qDeleteAll(m_objects); - m_objects.clear(); + qDeleteAll(m_items); + m_items.clear(); } |
