From d910d8ec38e0c33eeb32b7ceaaea9b40632cbd17 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 20 May 2008 22:24:45 +0000 Subject: [FIX] Models cleaned up (each class is now in its own file, parenting not hard-coded, etc.) [FIX] Tree bug fixed! :) git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@157 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/models/MapWildListModel.cpp | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'pokemodr/models/MapWildListModel.cpp') diff --git a/pokemodr/models/MapWildListModel.cpp b/pokemodr/models/MapWildListModel.cpp index 30a5b1af..2403efe1 100644 --- a/pokemodr/models/MapWildListModel.cpp +++ b/pokemodr/models/MapWildListModel.cpp @@ -64,11 +64,6 @@ QVariant MapWildListModel::data(int role) const return GroupObjectModel::data(role); } -int MapWildListModel::rowCount() const -{ - return static_cast(m_object)->encounterCount(); -} - bool MapWildListModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -93,22 +88,10 @@ bool MapWildListModel::setData(const QVariant& value, int role) return false; } -BaseModel* MapWildListModel::childItem(const int row) -{ - if (row < m_encounters.size()) - return m_encounters[row]; - return NULL; -} - -int MapWildListModel::indexNumber() const -{ - return static_cast(m_object->parent())->wildListIndex(m_object->id()); -} - bool MapWildListModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) - m_encounters.append(new MapWildListEncounterModel(this, static_cast(m_object)->newEncounter())); + m_objects.append(new MapWildListEncounterModel(this, static_cast(m_object)->newEncounter())); return true; } @@ -117,8 +100,8 @@ bool MapWildListModel::removeRows(const int position, const int rows) for (int i = 0; i < rows; ++i) { static_cast(m_object)->deleteEncounter(position); - delete m_encounters[position]; - m_encounters.removeAt(position); + delete m_objects[position]; + m_objects.removeAt(position); } return true; } @@ -127,11 +110,5 @@ void MapWildListModel::setupData() { MapWildList* wildList = static_cast(m_object); for (int i = 0; i < wildList->encounterCount(); ++i) - m_encounters.append(new MapWildListEncounterModel(this, wildList->encounter(i))); -} - -void MapWildListModel::clearData() -{ - foreach (MapWildListEncounterModel* model, m_encounters) - delete model; + m_objects.append(new MapWildListEncounterModel(this, wildList->encounter(i))); } -- cgit