From 02d571db3ef9fa2cb73203ef3dc46827ee6960cf Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 29 Dec 2008 11:51:33 -0500 Subject: Added macros for subclass handling --- sigmod/CoinList.cpp | 85 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 83 deletions(-) (limited to 'sigmod/CoinList.cpp') diff --git a/sigmod/CoinList.cpp b/sigmod/CoinList.cpp index bc3a6fcb..a8fd4f2f 100644 --- a/sigmod/CoinList.cpp +++ b/sigmod/CoinList.cpp @@ -111,87 +111,7 @@ GETTER(CoinList, Sigcore::Script, script) CHECK(CoinList, QString&, name) CHECK(CoinList, Sigcore::Script&, script) -const Sigmod::CoinListItem* Sigmod::CoinList::item(const int index) const -{ - if (index < itemCount()) - return m_items.at(index); - return NULL; -} - -Sigmod::CoinListItem* Sigmod::CoinList::item(const int index) -{ - if (index < itemCount()) - return m_items[index]; - return NULL; -} - -const Sigmod::CoinListItem* Sigmod::CoinList::itemById(const int id) const -{ - return item(itemIndex(id)); -} - -Sigmod::CoinListItem* Sigmod::CoinList::itemById(const int id) -{ - return item(itemIndex(id)); -} - -int Sigmod::CoinList::itemIndex(const int id) const -{ - for (int i = 0; i < itemCount(); ++i) - { - if (m_items[i]->id() == id) - return i; - } - return INT_MAX; -} - -int Sigmod::CoinList::itemCount() const -{ - return m_items.size(); -} - -Sigmod::CoinListItem* Sigmod::CoinList::newItem() -{ - return newItem(new CoinListItem(this, itemId())); -} - -Sigmod::CoinListItem* Sigmod::CoinList::newItem(const QDomElement& xml) -{ - return newItem(new CoinListItem(xml, this, itemId())); -} - -Sigmod::CoinListItem* Sigmod::CoinList::newItem(const CoinListItem& item) -{ - return newItem(new CoinListItem(item, this, itemId())); -} - -Sigmod::CoinListItem* Sigmod::CoinList::newItem(CoinListItem* item) -{ - m_items.append(item); - return item; -} - -void Sigmod::CoinList::deleteItem(const int index) -{ - if (index < itemCount()) - { - delete m_items[index]; - m_items.removeAt(index); - } -} - -void Sigmod::CoinList::deleteItemById(const int id) -{ - deleteItem(itemIndex(id)); -} - -int Sigmod::CoinList::itemId() const -{ - int i = 0; - while ((i < itemCount()) && (itemIndex(i) != INT_MAX)) - ++i; - return i; -} +SUBCLASS(CoinList, Item, item, items) Sigmod::CoinList& Sigmod::CoinList::operator=(const CoinList& rhs) { @@ -206,6 +126,5 @@ Sigmod::CoinList& Sigmod::CoinList::operator=(const CoinList& rhs) void Sigmod::CoinList::clear() { - qDeleteAll(m_items); - m_items.clear(); + SUBCLASS_CLEAR(items); } -- cgit