/* * Copyright 2008 Ben Boeckel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ // Header include #include "RootModel.h" // Model includes #include "PokemodModel.h" // Pokemod includes #include "../../pokemod/Pokemod.h" // Test code includes #include #include "../../pokemod/Ability.h" #include "../../pokemod/AbilityEffect.h" #include "../../pokemod/Sound.h" #include "AbilityModel.h" #include "SoundModel.h" RootModel::RootModel(const QList& pokemods) : GroupModel(NULL, NULL) { setupData(); } RootModel::~RootModel() { } int RootModel::indexNumber() const { return -1; } bool RootModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) m_objects.append(new PokemodModel(this, new Pokemod())); return true; } bool RootModel::removeRows(const int position, const int rows) { for (int i = 0; i < rows; ++i) { delete m_objects[position]; m_objects.removeAt(position); } return true; } void RootModel::setupData() { setupData(QList()); } void RootModel::setupData(const QList& pokemods) { QFile fin("full.pmod"); fin.open(QIODevice::ReadOnly); QDomDocument xml; xml.setContent(&fin); fin.close(); Pokemod* pokemod = new Pokemod(); Ability* ability = pokemod->newAbility(); ability->setName("foo"); ability->newEffect()->setEffect(AbilityEffect::E_PreventDamage); Sound* sound = pokemod->newSound(); sound->setName("bar"); m_objects.append(new AbilityModel(this, ability)); m_objects.append(new SoundModel(this, sound)); m_objects.append(new AbilityGroupModel(this, pokemod)); Pokemod* full = new Pokemod(xml.documentElement()); m_objects.append(new PokemodModel(this, full)); // TODO: make sub models from data }