diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-13 01:32:22 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-13 01:32:22 +0000 |
| commit | 571f40d02ec5322b7aa62e8b0f7d37ba538a9a25 (patch) | |
| tree | 5d5c7d9c250369d3acdc5f05f1eeca4aede66cb8 /pokemodr/models/PokemodModel.cpp | |
| parent | e11ae3d4907f0ce39b96ba6b29442be05f99b59c (diff) | |
| download | sigen-571f40d02ec5322b7aa62e8b0f7d37ba538a9a25.tar.gz sigen-571f40d02ec5322b7aa62e8b0f7d37ba538a9a25.tar.xz sigen-571f40d02ec5322b7aa62e8b0f7d37ba538a9a25.zip | |
[ADD] Added Sound class and related code
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@125 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/models/PokemodModel.cpp')
| -rw-r--r-- | pokemodr/models/PokemodModel.cpp | 70 |
1 files changed, 58 insertions, 12 deletions
diff --git a/pokemodr/models/PokemodModel.cpp b/pokemodr/models/PokemodModel.cpp index b26b2121..d4662360 100644 --- a/pokemodr/models/PokemodModel.cpp +++ b/pokemodr/models/PokemodModel.cpp @@ -30,6 +30,7 @@ #include "MapModel.h" #include "MoveModel.h" #include "NatureModel.h" +#include "SoundModel.h" #include "SpeciesModel.h" #include "StoreModel.h" #include "TileModel.h" @@ -486,6 +487,46 @@ void NatureGroupModel::setupData() m_objects.append(new NatureModel(this, pokemod->nature(i))); } +SoundGroupModel::SoundGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Sounds") +{ + setupData(); +} + +SoundGroupModel::~SoundGroupModel() +{ +} + +int SoundGroupModel::indexNumber() const +{ + return 12; +} + +bool SoundGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new SoundModel(this, static_cast<Pokemod*>(m_object)->newSound())); + return true; +} + +bool SoundGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteSound(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void SoundGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->soundCount(); ++i) + m_objects.append(new SoundModel(this, pokemod->sound(i))); +} + SpeciesGroupModel::SpeciesGroupModel(BaseModel* parent, Pokemod* pokemod) : GroupModel(parent, pokemod, "Species") { @@ -498,7 +539,7 @@ SpeciesGroupModel::~SpeciesGroupModel() int SpeciesGroupModel::indexNumber() const { - return 12; + return 13; } bool SpeciesGroupModel::insertRows(const int rows) @@ -538,7 +579,7 @@ StoreGroupModel::~StoreGroupModel() int StoreGroupModel::indexNumber() const { - return 13; + return 14; } bool StoreGroupModel::insertRows(const int rows) @@ -578,7 +619,7 @@ TileGroupModel::~TileGroupModel() int TileGroupModel::indexNumber() const { - return 14; + return 15; } bool TileGroupModel::insertRows(const int rows) @@ -618,7 +659,7 @@ TimeGroupModel::~TimeGroupModel() int TimeGroupModel::indexNumber() const { - return 15; + return 16; } bool TimeGroupModel::insertRows(const int rows) @@ -659,7 +700,7 @@ TrainerGroupModel::~TrainerGroupModel() int TrainerGroupModel::indexNumber() const { - return 16; + return 17; } bool TrainerGroupModel::insertRows(const int rows) @@ -699,7 +740,7 @@ TypeGroupModel::~TypeGroupModel() int TypeGroupModel::indexNumber() const { - return 17; + return 18; } bool TypeGroupModel::insertRows(const int rows) @@ -758,7 +799,7 @@ QVariant PokemodModel::data(int role) const int PokemodModel::rowCount() const { - return 18; + return 19; } bool PokemodModel::setData(const QVariant& value, int role) @@ -827,21 +868,24 @@ BaseModel* PokemodModel::childItem(const int row) model = m_natures; break; case 12: - model = m_species; + model = m_sounds; break; case 13: - model = m_stores; + model = m_species; break; case 14: - model = m_tiles; + model = m_stores; break; case 15: - model = m_times; + model = m_tiles; break; case 16: - model = m_trainers; + model = m_times; break; case 17: + model = m_trainers; + break; + case 18: model = m_types; break; default: @@ -880,6 +924,7 @@ void PokemodModel::setupData() m_maps = new MapGroupModel(this, static_cast<Pokemod*>(m_object)); m_moves = new MoveGroupModel(this, static_cast<Pokemod*>(m_object)); m_natures = new NatureGroupModel(this, static_cast<Pokemod*>(m_object)); + m_sounds = new SoundGroupModel(this, static_cast<Pokemod*>(m_object)); m_species = new SpeciesGroupModel(this, static_cast<Pokemod*>(m_object)); m_stores = new StoreGroupModel(this, static_cast<Pokemod*>(m_object)); m_tiles = new TileGroupModel(this, static_cast<Pokemod*>(m_object)); @@ -902,6 +947,7 @@ void PokemodModel::clearData() delete m_maps; delete m_moves; delete m_natures; + delete m_sounds; delete m_species; delete m_stores; delete m_tiles; |
