diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-12-29 11:51:33 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-12-29 11:51:33 -0500 |
| commit | 02d571db3ef9fa2cb73203ef3dc46827ee6960cf (patch) | |
| tree | c4550579979c4cb067b52dbf169e3e80ca0cf1aa /sigmod/CoinList.cpp | |
| parent | aef78077e88da4626eddadd1cb8b13eaab3a16ca (diff) | |
| download | sigen-02d571db3ef9fa2cb73203ef3dc46827ee6960cf.tar.gz sigen-02d571db3ef9fa2cb73203ef3dc46827ee6960cf.tar.xz sigen-02d571db3ef9fa2cb73203ef3dc46827ee6960cf.zip | |
Added macros for subclass handling
Diffstat (limited to 'sigmod/CoinList.cpp')
| -rw-r--r-- | sigmod/CoinList.cpp | 85 |
1 files changed, 2 insertions, 83 deletions
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); } |
