diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-20 22:24:45 +0000 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-20 22:24:45 +0000 |
commit | d910d8ec38e0c33eeb32b7ceaaea9b40632cbd17 (patch) | |
tree | a2fd6b050b2eea3bf26e6d04121e07a478ca5d16 | |
parent | 8ac53af4a15a59b8f6adf7a2468a1bd90a7cc549 (diff) | |
download | sigen-d910d8ec38e0c33eeb32b7ceaaea9b40632cbd17.tar.gz sigen-d910d8ec38e0c33eeb32b7ceaaea9b40632cbd17.tar.xz sigen-d910d8ec38e0c33eeb32b7ceaaea9b40632cbd17.zip |
[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
137 files changed, 3298 insertions, 2413 deletions
@@ -1,4 +1,12 @@ ----------------- +Rev: 157 +Date: 20 May 2008 +User: MathStuf +----------------- +[FIX] Models cleaned up +[FIX] Tree bug fixed! :) + +----------------- Rev: 156 Date: 20 May 2008 User: MathStuf diff --git a/pokemodr/PokemodTreeModel.cpp b/pokemodr/PokemodTreeModel.cpp index 2844f73f..60bab37d 100644 --- a/pokemodr/PokemodTreeModel.cpp +++ b/pokemodr/PokemodTreeModel.cpp @@ -24,6 +24,7 @@ // Qt includes #include <QDomDocument> #include <QMimeData> +#include <QStringList> PokemodTreeModel::PokemodTreeModel(const QStringList& pokemods, QObject* parent) : QAbstractItemModel(parent) diff --git a/pokemodr/commands/CommandWidget.cpp b/pokemodr/commands/CommandWidget.cpp index 83d4dc9f..8bd3b0c6 100644 --- a/pokemodr/commands/CommandWidget.cpp +++ b/pokemodr/commands/CommandWidget.cpp @@ -18,8 +18,10 @@ // Header include #include "CommandWidget.h" -CommandWidget::CommandWidget(const Pokemod* pokemod) : - QWidget(NULL) +CommandWidget::CommandWidget(const Pokemod* pokemod, const int command) : + QWidget(NULL), + m_pokemod(pokemod), + m_command(command) { } diff --git a/pokemodr/commands/CommandWidget.h b/pokemodr/commands/CommandWidget.h index 3abc4bb9..7a14dd58 100644 --- a/pokemodr/commands/CommandWidget.h +++ b/pokemodr/commands/CommandWidget.h @@ -29,7 +29,7 @@ class CommandWidget : public QWidget Q_OBJECT public: - CommandWidget(const Pokemod* pokemod); + CommandWidget(const Pokemod* pokemod, const int command); virtual ~CommandWidget(); signals: void command(const QString&) const; @@ -38,7 +38,8 @@ class CommandWidget : public QWidget protected: virtual QString commandString() const = 0; - Pokemod* pokemod; + const Pokemod* m_pokemod; + const int m_command; }; #endif diff --git a/pokemodr/models/AbilityEffectModel.cpp b/pokemodr/models/AbilityEffectModel.cpp index 0c7bb8c6..0c6fc661 100644 --- a/pokemodr/models/AbilityEffectModel.cpp +++ b/pokemodr/models/AbilityEffectModel.cpp @@ -80,8 +80,3 @@ bool AbilityEffectModel::setData(const QVariant& value, int role) } return false; } - -int AbilityEffectModel::indexNumber() const -{ - return static_cast<const Ability*>(m_object->parent())->effectIndex(m_object->id()); -} diff --git a/pokemodr/models/AbilityEffectModel.h b/pokemodr/models/AbilityEffectModel.h index f5d61a05..9f5070dc 100644 --- a/pokemodr/models/AbilityEffectModel.h +++ b/pokemodr/models/AbilityEffectModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_ABILITYEFFECTMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class AbilityEffect; @@ -33,8 +33,6 @@ class AbilityEffectModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/AbilityGroupModel.cpp b/pokemodr/models/AbilityGroupModel.cpp new file mode 100644 index 00000000..26cadf56 --- /dev/null +++ b/pokemodr/models/AbilityGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "AbilityGroupModel.h" + +// Model includes +#include "AbilityModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +AbilityGroupModel::AbilityGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Abilities") +{ + setupData(); +} + +AbilityGroupModel::~AbilityGroupModel() +{ +} + +bool AbilityGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new AbilityModel(this, static_cast<Pokemod*>(m_object)->newAbility())); + return true; +} + +bool AbilityGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteAbility(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void AbilityGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->abilityCount(); ++i) + m_objects.append(new AbilityModel(this, pokemod->ability(i))); +} diff --git a/pokemodr/models/AbilityGroupModel.h b/pokemodr/models/AbilityGroupModel.h new file mode 100644 index 00000000..4b212770 --- /dev/null +++ b/pokemodr/models/AbilityGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_ABILITYGROUPMODEL__ +#define __POKEMODR_ABILITYGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class AbilityGroupModel : public GroupModel +{ + public: + AbilityGroupModel(BaseModel* parent, Pokemod* pokemod); + ~AbilityGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/AbilityModel.cpp b/pokemodr/models/AbilityModel.cpp index a149a1e6..9a3f6b76 100644 --- a/pokemodr/models/AbilityModel.cpp +++ b/pokemodr/models/AbilityModel.cpp @@ -60,11 +60,6 @@ QVariant AbilityModel::data(int role) const return GroupObjectModel::data(role); } -int AbilityModel::rowCount() const -{ - return m_effects.size(); -} - bool AbilityModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -89,22 +84,10 @@ bool AbilityModel::setData(const QVariant& value, int role) return false; } -BaseModel* AbilityModel::childItem(const int row) -{ - if (row < m_effects.size()) - return m_effects[row]; - return NULL; -} - -int AbilityModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->abilityIndex(m_object->id()); -} - bool AbilityModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) - m_effects.append(new AbilityEffectModel(this, static_cast<Ability*>(m_object)->newEffect())); + m_objects.append(new AbilityEffectModel(this, static_cast<Ability*>(m_object)->newEffect())); return true; } @@ -113,8 +96,8 @@ bool AbilityModel::removeRows(const int position, const int rows) for (int i = 0; i < rows; ++i) { static_cast<Ability*>(m_object)->deleteEffect(position); - delete m_effects[position]; - m_effects.removeAt(position); + delete m_objects[position]; + m_objects.removeAt(position); } return true; } @@ -123,11 +106,5 @@ void AbilityModel::setupData() { Ability* ability = static_cast<Ability*>(m_object); for (int i = 0; i < ability->effectCount(); ++i) - m_effects.append(new AbilityEffectModel(this, ability->effect(i))); -} - -void AbilityModel::clearData() -{ - foreach (AbilityEffectModel* model, m_effects) - delete model; + m_objects.append(new AbilityEffectModel(this, ability->effect(i))); } diff --git a/pokemodr/models/AbilityModel.h b/pokemodr/models/AbilityModel.h index 756abfbe..23a87699 100644 --- a/pokemodr/models/AbilityModel.h +++ b/pokemodr/models/AbilityModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_ABILITYMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupObjectModel.h" // Forward declarations class Ability; @@ -32,21 +32,14 @@ class AbilityModel : public GroupObjectModel ~AbilityModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int rows); bool removeRows(const int position, const int rows); protected: void setupData(); - void clearData(); - private: - QList<AbilityEffectModel*> m_effects; }; #endif diff --git a/pokemodr/models/AuthorGroupModel.cpp b/pokemodr/models/AuthorGroupModel.cpp new file mode 100644 index 00000000..b2709df8 --- /dev/null +++ b/pokemodr/models/AuthorGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "AuthorGroupModel.h" + +// Model includes +#include "AuthorModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +AuthorGroupModel::AuthorGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Authors") +{ + setupData(); +} + +AuthorGroupModel::~AuthorGroupModel() +{ +} + +bool AuthorGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new AuthorModel(this, static_cast<Pokemod*>(m_object)->newAuthor())); + return true; +} + +bool AuthorGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteAuthor(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void AuthorGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->authorCount(); ++i) + m_objects.append(new AuthorModel(this, pokemod->author(i))); +} diff --git a/pokemodr/models/AuthorGroupModel.h b/pokemodr/models/AuthorGroupModel.h new file mode 100644 index 00000000..1e15f93d --- /dev/null +++ b/pokemodr/models/AuthorGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_AUTHORGROUPMODEL__ +#define __POKEMODR_AUTHORGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class AuthorGroupModel : public GroupModel +{ + public: + AuthorGroupModel(BaseModel* parent, Pokemod* pokemod); + ~AuthorGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/AuthorModel.cpp b/pokemodr/models/AuthorModel.cpp index d7b36b90..2daa76ab 100644 --- a/pokemodr/models/AuthorModel.cpp +++ b/pokemodr/models/AuthorModel.cpp @@ -76,8 +76,3 @@ bool AuthorModel::setData(const QVariant& value, int role) } return false; } - -int AuthorModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->authorIndex(m_object->id()); -} diff --git a/pokemodr/models/AuthorModel.h b/pokemodr/models/AuthorModel.h index 0c40b336..b924d12d 100644 --- a/pokemodr/models/AuthorModel.h +++ b/pokemodr/models/AuthorModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_AUTHORMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Author; @@ -33,8 +33,6 @@ class AuthorModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/BadgeGroupModel.cpp b/pokemodr/models/BadgeGroupModel.cpp new file mode 100644 index 00000000..fe615ed2 --- /dev/null +++ b/pokemodr/models/BadgeGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "BadgeGroupModel.h" + +// Model includes +#include "BadgeModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +BadgeGroupModel::BadgeGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Badges") +{ + setupData(); +} + +BadgeGroupModel::~BadgeGroupModel() +{ +} + +bool BadgeGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new BadgeModel(this, static_cast<Pokemod*>(m_object)->newBadge())); + return true; +} + +bool BadgeGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteBadge(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void BadgeGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->badgeCount(); ++i) + m_objects.append(new BadgeModel(this, pokemod->badge(i))); +} diff --git a/pokemodr/models/BadgeGroupModel.h b/pokemodr/models/BadgeGroupModel.h new file mode 100644 index 00000000..5c61a5bf --- /dev/null +++ b/pokemodr/models/BadgeGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_BADGEGROUPMODEL__ +#define __POKEMODR_BADGEGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class BadgeGroupModel : public GroupModel +{ + public: + BadgeGroupModel(BaseModel* parent, Pokemod* pokemod); + ~BadgeGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/BadgeModel.cpp b/pokemodr/models/BadgeModel.cpp index 22429921..275016eb 100644 --- a/pokemodr/models/BadgeModel.cpp +++ b/pokemodr/models/BadgeModel.cpp @@ -76,8 +76,3 @@ bool BadgeModel::setData(const QVariant& value, int role) } return false; } - -int BadgeModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->badgeIndex(m_object->id()); -} diff --git a/pokemodr/models/BadgeModel.h b/pokemodr/models/BadgeModel.h index 30ca6d61..0a06821f 100644 --- a/pokemodr/models/BadgeModel.h +++ b/pokemodr/models/BadgeModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_BADGEMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Badge; @@ -33,8 +33,6 @@ class BadgeModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/BaseModel.cpp b/pokemodr/models/BaseModel.cpp index 832903c5..8d76f928 100644 --- a/pokemodr/models/BaseModel.cpp +++ b/pokemodr/models/BaseModel.cpp @@ -44,174 +44,14 @@ BaseModel* BaseModel::parent() return m_parent; } -BaseObjectModel::BaseObjectModel(BaseModel* parent, Object* object) : - BaseModel(parent, object, "") +int BaseModel::indexNumber() const { + if (m_parent) + return m_parent->findChild(this); + return -1; } -BaseObjectModel::~BaseObjectModel() +int BaseModel::findChild(const BaseModel* /*model*/) const { -} - -QVariant BaseObjectModel::data(int role) const -{ - return BaseModel::data(role); -} - -Qt::ItemFlags BaseObjectModel::flags() const -{ - return Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled; -} - -Qt::DropActions BaseObjectModel::supportedDragActions() -{ - return Qt::CopyAction | Qt::MoveAction; -} - -Qt::DropActions BaseObjectModel::supportedDropActions() -{ - return Qt::CopyAction | Qt::MoveAction; -} - -QString BaseObjectModel::type() const -{ - return m_object->className(); -} - -ObjectModel::ObjectModel(BaseModel* parent, Object* object) : - BaseObjectModel(parent, object) -{ -} - -ObjectModel::~ObjectModel() -{ -} - -int ObjectModel::rowCount() const -{ - return 0; -} - -QVariant ObjectModel::data(int role) const -{ - return BaseObjectModel::data(role); -} - -BaseModel* ObjectModel::childItem(const int /*row*/) -{ - return NULL; -} - -bool ObjectModel::canInsertRows() const -{ - return false; -} - -bool ObjectModel::insertRows(const int /*rows*/) -{ - return false; -} - -bool ObjectModel::canRemoveRows() const -{ - return false; -} - -bool ObjectModel::removeRows(const int /*position*/, const int /*rows*/) -{ - return false; -} - -GroupObjectModel::GroupObjectModel(BaseModel* parent, Object* object) : - BaseObjectModel(parent, object) -{ -} - -GroupObjectModel::~GroupObjectModel() -{ -} - -QVariant GroupObjectModel::data(int role) const -{ - return BaseObjectModel::data(role); -} - -bool GroupObjectModel::canInsertRows() const -{ - return true; -} - -bool GroupObjectModel::canRemoveRows() const -{ - return true; -} - -GroupModel::GroupModel(BaseModel* parent, Object* object, const QString& name) : - BaseModel(parent, object, name) -{ -} - -GroupModel::~GroupModel() -{ - clearData(); -} - -QVariant GroupModel::data(int role) const -{ - if (role == Qt::DisplayRole) - return m_name; - return BaseModel::data(role); -} - -int GroupModel::rowCount() const -{ - return m_objects.size(); -} - -Qt::ItemFlags GroupModel::flags() const -{ - return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled; -} - -bool GroupModel::setData(const QVariant& /*value*/, int /*role = Qt::EditRole*/) -{ - return false; -} - -BaseModel* GroupModel::childItem(const int row) -{ - if (row < m_objects.size()) - return m_objects[row]; - return NULL; -} - -bool GroupModel::canInsertRows() const -{ - return true; -} - -bool GroupModel::canRemoveRows() const -{ - return true; -} - -Qt::DropActions GroupModel::supportedDragActions() -{ - return 0; -} - -Qt::DropActions GroupModel::supportedDropActions() -{ - return Qt::CopyAction | Qt::MoveAction; -} - -QString GroupModel::type() const -{ - return ""; -} - -void GroupModel::clearData() -{ - foreach (BaseObjectModel* model, m_objects) - delete model; + return -1; } diff --git a/pokemodr/models/BaseModel.h b/pokemodr/models/BaseModel.h index 5c65c733..0540e859 100644 --- a/pokemodr/models/BaseModel.h +++ b/pokemodr/models/BaseModel.h @@ -19,7 +19,6 @@ #define __POKEMODR_BASEMODEL__ // Qt includes -#include <QList> #include <QString> #include <QVariant> @@ -41,7 +40,7 @@ class BaseModel virtual bool setData(const QVariant& value, const int role = Qt::EditRole) = 0; virtual BaseModel* childItem(const int row) = 0; - virtual int indexNumber() const = 0; + int indexNumber() const; virtual bool canInsertRows() const = 0; virtual bool insertRows(const int rows) = 0; @@ -59,115 +58,12 @@ class BaseModel static const int WidgetRole = Qt::UserRole + 2; static const int ContextMenuRole = Qt::UserRole + 3; protected: + virtual int findChild(const BaseModel* /*model*/) const; + Object* m_object; QString m_name; BaseModel* m_parent; }; -class BaseObjectModel : public BaseModel -{ - public: - BaseObjectModel(BaseModel* parent, Object* object); - virtual ~BaseObjectModel(); - - virtual QVariant data(int role = Qt::DisplayRole) const; - virtual int rowCount() const = 0; - - Qt::ItemFlags flags() const; - virtual bool setData(const QVariant& value, int role = Qt::EditRole) = 0; - - virtual BaseModel* childItem(const int row) = 0; - virtual int indexNumber() const = 0; - - virtual bool canInsertRows() const = 0; - virtual bool insertRows(const int rows) = 0; - - virtual bool canRemoveRows() const = 0; - virtual bool removeRows(const int position, const int rows) = 0; - - Qt::DropActions supportedDragActions(); - Qt::DropActions supportedDropActions(); - - QString type() const; -}; - -class ObjectModel : public BaseObjectModel -{ - public: - ObjectModel(BaseModel* parent, Object* object); - virtual ~ObjectModel(); - - virtual QVariant data(int role = Qt::DisplayRole) const = 0; - int rowCount() const; - - virtual bool setData(const QVariant& value, int role = Qt::EditRole) = 0; - - BaseModel* childItem(const int /*row*/); - virtual int indexNumber() const = 0; - - bool canInsertRows() const; - bool insertRows(const int /*rows*/); - - bool canRemoveRows() const; - bool removeRows(const int /*position*/, const int /*rows*/); -}; - -class GroupObjectModel : public BaseObjectModel -{ - public: - GroupObjectModel(BaseModel* parent, Object* object); - virtual ~GroupObjectModel(); - - virtual QVariant data(int role = Qt::DisplayRole) const; - virtual int rowCount() const = 0; - - virtual bool setData(const QVariant& value, int role = Qt::EditRole) = 0; - - virtual BaseModel* childItem(const int row) = 0; - virtual int indexNumber() const = 0; - - bool canInsertRows() const; - virtual bool insertRows(const int rows) = 0; - - bool canRemoveRows() const; - virtual bool removeRows(const int position, const int rows) = 0; - protected: - virtual void setupData() = 0; - virtual void clearData() = 0; -}; - -class GroupModel : public BaseModel -{ - public: - GroupModel(BaseModel* parent, Object* object, const QString& name = ""); - virtual ~GroupModel(); - - QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; - - Qt::ItemFlags flags() const; - virtual bool setData(const QVariant& /*value*/, int /*role = Qt::EditRole*/); - - BaseModel* childItem(const int row); - virtual int indexNumber() const = 0; - - bool canInsertRows() const; - virtual bool insertRows(const int rows) = 0; - - bool canRemoveRows() const; - virtual bool removeRows(const int position, const int rows) = 0; - - Qt::DropActions supportedDragActions(); - Qt::DropActions supportedDropActions(); - - QString type() const; - protected: - virtual void setupData() = 0; - - QList<BaseObjectModel*> m_objects; - private: - void clearData(); -}; - #endif diff --git a/pokemodr/models/BaseObjectModel.cpp b/pokemodr/models/BaseObjectModel.cpp new file mode 100644 index 00000000..8e60ffad --- /dev/null +++ b/pokemodr/models/BaseObjectModel.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "BaseObjectModel.h" + +// Pokemod includes +#include "../../pokemod/Object.h" + +BaseObjectModel::BaseObjectModel(BaseModel* parent, Object* object) : + BaseModel(parent, object, "") +{ +} + +BaseObjectModel::~BaseObjectModel() +{ +} + +QVariant BaseObjectModel::data(int role) const +{ + return BaseModel::data(role); +} + +Qt::ItemFlags BaseObjectModel::flags() const +{ + return Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled; +} + +Qt::DropActions BaseObjectModel::supportedDragActions() +{ + return Qt::CopyAction | Qt::MoveAction; +} + +Qt::DropActions BaseObjectModel::supportedDropActions() +{ + return Qt::CopyAction | Qt::MoveAction; +} + +QString BaseObjectModel::type() const +{ + return m_object->className(); +} + +int BaseObjectModel::findChild(const BaseModel* /*model*/) const +{ + return -1; +} diff --git a/pokemodr/models/BaseObjectModel.h b/pokemodr/models/BaseObjectModel.h new file mode 100644 index 00000000..2c5aaa82 --- /dev/null +++ b/pokemodr/models/BaseObjectModel.h @@ -0,0 +1,52 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_BASEOBJECTMODEL__ +#define __POKEMODR_BASEOBJECTMODEL__ + +// Model includes +#include "BaseModel.h" + +class BaseObjectModel : public BaseModel +{ + public: + BaseObjectModel(BaseModel* parent, Object* object); + virtual ~BaseObjectModel(); + + virtual QVariant data(int role = Qt::DisplayRole) const; + virtual int rowCount() const = 0; + + Qt::ItemFlags flags() const; + virtual bool setData(const QVariant& value, int role = Qt::EditRole) = 0; + + virtual BaseModel* childItem(const int row) = 0; + + virtual bool canInsertRows() const = 0; + virtual bool insertRows(const int rows) = 0; + + virtual bool canRemoveRows() const = 0; + virtual bool removeRows(const int position, const int rows) = 0; + + Qt::DropActions supportedDragActions(); + Qt::DropActions supportedDropActions(); + + QString type() const; + protected: + virtual int findChild(const BaseModel* /*model*/) const; +}; + +#endif diff --git a/pokemodr/models/CoinListGroupModel.cpp b/pokemodr/models/CoinListGroupModel.cpp new file mode 100644 index 00000000..5351e616 --- /dev/null +++ b/pokemodr/models/CoinListGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "CoinListGroupModel.h" + +// Model includes +#include "CoinListModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +CoinListGroupModel::CoinListGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Coin Lists") +{ + setupData(); +} + +CoinListGroupModel::~CoinListGroupModel() +{ +} + +bool CoinListGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new CoinListModel(this, static_cast<Pokemod*>(m_object)->newCoinList())); + return true; +} + +bool CoinListGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteCoinList(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void CoinListGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->coinListCount(); ++i) + m_objects.append(new CoinListModel(this, pokemod->coinList(i))); +} diff --git a/pokemodr/models/CoinListGroupModel.h b/pokemodr/models/CoinListGroupModel.h new file mode 100644 index 00000000..bdbd4b48 --- /dev/null +++ b/pokemodr/models/CoinListGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_COINLISTGROUPMODEL__ +#define __POKEMODR_COINLISTGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class CoinListGroupModel : public GroupModel +{ + public: + CoinListGroupModel(BaseModel* parent, Pokemod* pokemod); + ~CoinListGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/CoinListModel.cpp b/pokemodr/models/CoinListModel.cpp index 36312ce1..167d9070 100644 --- a/pokemodr/models/CoinListModel.cpp +++ b/pokemodr/models/CoinListModel.cpp @@ -60,11 +60,6 @@ QVariant CoinListModel::data(int role) const return GroupObjectModel::data(role); } -int CoinListModel::rowCount() const -{ - return m_objects.size(); -} - bool CoinListModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -89,18 +84,6 @@ bool CoinListModel::setData(const QVariant& value, int role) return false; } -BaseModel* CoinListModel::childItem(const int row) -{ - if (row < m_objects.size()) - return m_objects[row]; - return NULL; -} - -int CoinListModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->coinListIndex(m_object->id()); -} - bool CoinListModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) @@ -125,9 +108,3 @@ void CoinListModel::setupData() for (int i = 0; i < coinList->objectCount(); ++i) m_objects.append(new CoinListObjectModel(this, coinList->object(i))); } - -void CoinListModel::clearData() -{ - foreach (CoinListObjectModel* model, m_objects) - delete model; -} diff --git a/pokemodr/models/CoinListModel.h b/pokemodr/models/CoinListModel.h index ac5d14c9..e6cbe9a6 100644 --- a/pokemodr/models/CoinListModel.h +++ b/pokemodr/models/CoinListModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_COINLISTMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupObjectModel.h" // Forward declarations class CoinList; @@ -32,21 +32,14 @@ class CoinListModel : public GroupObjectModel ~CoinListModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int rows); bool removeRows(const int position, const int rows); protected: void setupData(); - void clearData(); - private: - QList<CoinListObjectModel*> m_objects; }; #endif diff --git a/pokemodr/models/CoinListObjectModel.cpp b/pokemodr/models/CoinListObjectModel.cpp index ffce721e..0bf7152f 100644 --- a/pokemodr/models/CoinListObjectModel.cpp +++ b/pokemodr/models/CoinListObjectModel.cpp @@ -93,8 +93,3 @@ bool CoinListObjectModel::setData(const QVariant& value, int role) } return false; } - -int CoinListObjectModel::indexNumber() const -{ - return static_cast<const CoinList*>(m_object->parent())->objectIndex(m_object->id()); -} diff --git a/pokemodr/models/CoinListObjectModel.h b/pokemodr/models/CoinListObjectModel.h index 7a7d0ff4..585ae4fd 100644 --- a/pokemodr/models/CoinListObjectModel.h +++ b/pokemodr/models/CoinListObjectModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_COINLISTOBJECTMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class CoinListObject; @@ -33,8 +33,6 @@ class CoinListObjectModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/DialogGroupModel.cpp b/pokemodr/models/DialogGroupModel.cpp new file mode 100644 index 00000000..1eeeb4be --- /dev/null +++ b/pokemodr/models/DialogGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "DialogGroupModel.h" + +// Model includes +#include "DialogModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +DialogGroupModel::DialogGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Dialogs") +{ + setupData(); +} + +DialogGroupModel::~DialogGroupModel() +{ +} + +bool DialogGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new DialogModel(this, static_cast<Pokemod*>(m_object)->newDialog())); + return true; +} + +bool DialogGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteDialog(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void DialogGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->dialogCount(); ++i) + m_objects.append(new DialogModel(this, pokemod->dialog(i))); +} diff --git a/pokemodr/models/DialogGroupModel.h b/pokemodr/models/DialogGroupModel.h new file mode 100644 index 00000000..0e338f48 --- /dev/null +++ b/pokemodr/models/DialogGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_DIALOGGROUPMODEL__ +#define __POKEMODR_DIALOGGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class DialogGroupModel : public GroupModel +{ + public: + DialogGroupModel(BaseModel* parent, Pokemod* pokemod); + ~DialogGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/DialogModel.cpp b/pokemodr/models/DialogModel.cpp index f0e2b330..c5b3370e 100644 --- a/pokemodr/models/DialogModel.cpp +++ b/pokemodr/models/DialogModel.cpp @@ -76,8 +76,3 @@ bool DialogModel::setData(const QVariant& value, int role) } return false; } - -int DialogModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->dialogIndex(m_object->id()); -} diff --git a/pokemodr/models/DialogModel.h b/pokemodr/models/DialogModel.h index 5f4d4a8c..d64c9724 100644 --- a/pokemodr/models/DialogModel.h +++ b/pokemodr/models/DialogModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_DIALOGMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Dialog; @@ -33,8 +33,6 @@ class DialogModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/EggGroupGroupModel.cpp b/pokemodr/models/EggGroupGroupModel.cpp new file mode 100644 index 00000000..2b30fbb7 --- /dev/null +++ b/pokemodr/models/EggGroupGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "EggGroupGroupModel.h" + +// Model includes +#include "EggGroupModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +EggGroupGroupModel::EggGroupGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Egg Groups") +{ + setupData(); +} + +EggGroupGroupModel::~EggGroupGroupModel() +{ +} + +bool EggGroupGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new EggGroupModel(this, static_cast<Pokemod*>(m_object)->newEggGroup())); + return true; +} + +bool EggGroupGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteEggGroup(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void EggGroupGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->eggGroupCount(); ++i) + m_objects.append(new EggGroupModel(this, pokemod->eggGroup(i))); +} diff --git a/pokemodr/models/EggGroupGroupModel.h b/pokemodr/models/EggGroupGroupModel.h new file mode 100644 index 00000000..5d2192c0 --- /dev/null +++ b/pokemodr/models/EggGroupGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_EGGGROUPGROUPMODEL__ +#define __POKEMODR_EGGGROUPGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class EggGroupGroupModel : public GroupModel +{ + public: + EggGroupGroupModel(BaseModel* parent, Pokemod* pokemod); + ~EggGroupGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/EggGroupModel.cpp b/pokemodr/models/EggGroupModel.cpp index f3ded839..1e25b26d 100644 --- a/pokemodr/models/EggGroupModel.cpp +++ b/pokemodr/models/EggGroupModel.cpp @@ -76,8 +76,3 @@ bool EggGroupModel::setData(const QVariant& value, int role) } return false; } - -int EggGroupModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->eggGroupIndex(m_object->id()); -} diff --git a/pokemodr/models/EggGroupModel.h b/pokemodr/models/EggGroupModel.h index 14ff212f..87a9b637 100644 --- a/pokemodr/models/EggGroupModel.h +++ b/pokemodr/models/EggGroupModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_EGGGROUPMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class EggGroup; @@ -33,8 +33,6 @@ class EggGroupModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/GroupModel.cpp b/pokemodr/models/GroupModel.cpp new file mode 100644 index 00000000..90beb41f --- /dev/null +++ b/pokemodr/models/GroupModel.cpp @@ -0,0 +1,98 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "GroupModel.h" + +// Model includes +#include "BaseObjectModel.h" + +GroupModel::GroupModel(BaseModel* parent, Object* object, const QString& name) : + BaseModel(parent, object, name) +{ +} + +GroupModel::~GroupModel() +{ + clearData(); +} + +QVariant GroupModel::data(int role) const +{ + if (role == Qt::DisplayRole) + return m_name; + return BaseModel::data(role); +} + +int GroupModel::rowCount() const +{ + return m_objects.size(); +} + +Qt::ItemFlags GroupModel::flags() const +{ + return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled; +} + +bool GroupModel::setData(const QVariant& /*value*/, int /*role = Qt::EditRole*/) +{ + return false; +} + +BaseModel* GroupModel::childItem(const int row) +{ + if (row < m_objects.size()) + return m_objects[row]; + return NULL; +} + +bool GroupModel::canInsertRows() const +{ + return true; +} + +bool GroupModel::canRemoveRows() const +{ + return true; +} + +Qt::DropActions GroupModel::supportedDragActions() +{ + return 0; +} + +Qt::DropActions GroupModel::supportedDropActions() +{ + return Qt::CopyAction | Qt::MoveAction; +} + +QString GroupModel::type() const +{ + return ""; +} + +int GroupModel::findChild(const BaseModel* model) const +{ + return m_objects.indexOf(const_cast<BaseObjectModel*>(static_cast<const BaseObjectModel*>(model))); +} + +void GroupModel::clearData() +{ + foreach (BaseObjectModel* model, m_objects) + delete model; + m_objects.clear(); +} diff --git a/pokemodr/models/GroupModel.h b/pokemodr/models/GroupModel.h new file mode 100644 index 00000000..df548a53 --- /dev/null +++ b/pokemodr/models/GroupModel.h @@ -0,0 +1,64 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_GROUPMODEL__ +#define __POKEMODR_GROUPMODEL__ + +// Model includes +#include "BaseModel.h" + +// Qt includes +#include <QList> + +// Forward declarations +class BaseObjectModel; + +class GroupModel : public BaseModel +{ + public: + GroupModel(BaseModel* parent, Object* object, const QString& name = ""); + virtual ~GroupModel(); + + QVariant data(int role = Qt::DisplayRole) const; + int rowCount() const; + + Qt::ItemFlags flags() const; + virtual bool setData(const QVariant& /*value*/, int /*role = Qt::EditRole*/); + + BaseModel* childItem(const int row); + + bool canInsertRows() const; + virtual bool insertRows(const int rows) = 0; + + bool canRemoveRows() const; + virtual bool removeRows(const int position, const int rows) = 0; + + Qt::DropActions supportedDragActions(); + Qt::DropActions supportedDropActions(); + + QString type() const; + protected: + int findChild(const BaseModel* model) const; + + virtual void setupData() = 0; + + QList<BaseObjectModel*> m_objects; + private: + void clearData(); +}; + +#endif diff --git a/pokemodr/models/GroupObjectModel.cpp b/pokemodr/models/GroupObjectModel.cpp new file mode 100644 index 00000000..0536354d --- /dev/null +++ b/pokemodr/models/GroupObjectModel.cpp @@ -0,0 +1,67 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "GroupObjectModel.h" + +GroupObjectModel::GroupObjectModel(BaseModel* parent, Object* object) : + BaseObjectModel(parent, object) +{ +} + +GroupObjectModel::~GroupObjectModel() +{ +} + +QVariant GroupObjectModel::data(int role) const +{ + return BaseObjectModel::data(role); +} + +int GroupObjectModel::rowCount() const +{ + return m_objects.size(); +} + +BaseModel* GroupObjectModel::childItem(const int row) +{ + if (row < m_objects.size()) + return m_objects[row]; + return NULL; +} + +bool GroupObjectModel::canInsertRows() const +{ + return true; +} + +bool GroupObjectModel::canRemoveRows() const +{ + return true; +} + +int GroupObjectModel::findChild(const BaseModel* model) const +{ + return m_objects.indexOf(const_cast<BaseModel*>(model)); +} + +void GroupObjectModel::clearData() +{ + foreach (BaseModel* model, m_objects) + delete model; + m_objects.clear(); +} diff --git a/pokemodr/models/GroupObjectModel.h b/pokemodr/models/GroupObjectModel.h new file mode 100644 index 00000000..6b5ed04e --- /dev/null +++ b/pokemodr/models/GroupObjectModel.h @@ -0,0 +1,52 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_GROUPOBJECTMODEL__ +#define __POKEMODR_GROUPOBJECTMODEL__ + +// Model includes +#include "BaseObjectModel.h" +#include "GroupModel.h" + +class GroupObjectModel : public BaseObjectModel +{ + public: + GroupObjectModel(BaseModel* parent, Object* object); + virtual ~GroupObjectModel(); + + virtual QVariant data(int role = Qt::DisplayRole) const; + int rowCount() const; + + virtual bool setData(const QVariant& value, int role = Qt::EditRole) = 0; + + BaseModel* childItem(const int row); + + virtual bool canInsertRows() const; + virtual bool insertRows(const int rows) = 0; + + virtual bool canRemoveRows() const; + virtual bool removeRows(const int position, const int rows) = 0; + protected: + int findChild(const BaseModel* model) const; + + virtual void setupData() = 0; + void clearData(); + + QList<BaseModel*> m_objects; +}; + +#endif diff --git a/pokemodr/models/ItemEffectModel.cpp b/pokemodr/models/ItemEffectModel.cpp index 02a08c70..841768e8 100644 --- a/pokemodr/models/ItemEffectModel.cpp +++ b/pokemodr/models/ItemEffectModel.cpp @@ -80,8 +80,3 @@ bool ItemEffectModel::setData(const QVariant& value, int role) } return false; } - -int ItemEffectModel::indexNumber() const -{ - return static_cast<const Item*>(m_object->parent())->effectIndex(m_object->id()); -} diff --git a/pokemodr/models/ItemEffectModel.h b/pokemodr/models/ItemEffectModel.h index 45ef7843..53116f88 100644 --- a/pokemodr/models/ItemEffectModel.h +++ b/pokemodr/models/ItemEffectModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_ITEMEFFECTMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class ItemEffect; @@ -33,8 +33,6 @@ class ItemEffectModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/ItemGroupModel.cpp b/pokemodr/models/ItemGroupModel.cpp new file mode 100644 index 00000000..635dac2d --- /dev/null +++ b/pokemodr/models/ItemGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "ItemGroupModel.h" + +// Model includes +#include "ItemModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +ItemGroupModel::ItemGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Items") +{ + setupData(); +} + +ItemGroupModel::~ItemGroupModel() +{ +} + +bool ItemGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new ItemModel(this, static_cast<Pokemod*>(m_object)->newItem())); + return true; +} + +bool ItemGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteItem(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void ItemGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->itemCount(); ++i) + m_objects.append(new ItemModel(this, pokemod->item(i))); +} diff --git a/pokemodr/models/ItemGroupModel.h b/pokemodr/models/ItemGroupModel.h new file mode 100644 index 00000000..732f1210 --- /dev/null +++ b/pokemodr/models/ItemGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_ITEMGROUPMODEL__ +#define __POKEMODR_ITEMGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class ItemGroupModel : public GroupModel +{ + public: + ItemGroupModel(BaseModel* parent, Pokemod* pokemod); + ~ItemGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/ItemModel.cpp b/pokemodr/models/ItemModel.cpp index aebdcd7a..daa5f903 100644 --- a/pokemodr/models/ItemModel.cpp +++ b/pokemodr/models/ItemModel.cpp @@ -60,11 +60,6 @@ QVariant ItemModel::data(int role) const return GroupObjectModel::data(role); } -int ItemModel::rowCount() const -{ - return m_effects.size(); -} - bool ItemModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -89,22 +84,10 @@ bool ItemModel::setData(const QVariant& value, int role) return false; } -BaseModel* ItemModel::childItem(const int row) -{ - if (row < m_effects.size()) - return m_effects[row]; - return NULL; -} - -int ItemModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->itemIndex(m_object->id()); -} - bool ItemModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) - m_effects.append(new ItemEffectModel(this, static_cast<Item*>(m_object)->newEffect())); + m_objects.append(new ItemEffectModel(this, static_cast<Item*>(m_object)->newEffect())); return true; } @@ -113,8 +96,8 @@ bool ItemModel::removeRows(const int position, const int rows) for (int i = 0; i < rows; ++i) { static_cast<Item*>(m_object)->deleteEffect(position); - delete m_effects[position]; - m_effects.removeAt(position); + delete m_objects[position]; + m_objects.removeAt(position); } return true; } @@ -123,11 +106,5 @@ void ItemModel::setupData() { Item* item = static_cast<Item*>(m_object); for (int i = 0; i < item->effectCount(); ++i) - m_effects.append(new ItemEffectModel(this, item->effect(i))); -} - -void ItemModel::clearData() -{ - foreach (ItemEffectModel* model, m_effects) - delete model; + m_objects.append(new ItemEffectModel(this, item->effect(i))); } diff --git a/pokemodr/models/ItemModel.h b/pokemodr/models/ItemModel.h index f7442bca..bc0419d6 100644 --- a/pokemodr/models/ItemModel.h +++ b/pokemodr/models/ItemModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_ITEMMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupObjectModel.h" // Forward declarations class Item; @@ -32,21 +32,14 @@ class ItemModel : public GroupObjectModel ~ItemModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int rows); bool removeRows(const int position, const int rows); protected: void setupData(); - void clearData(); - private: - QList<ItemEffectModel*> m_effects; }; #endif diff --git a/pokemodr/models/ItemTypeGroupModel.cpp b/pokemodr/models/ItemTypeGroupModel.cpp new file mode 100644 index 00000000..72af42d5 --- /dev/null +++ b/pokemodr/models/ItemTypeGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "ItemTypeGroupModel.h" + +// Model includes +#include "ItemTypeModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +ItemTypeGroupModel::ItemTypeGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Item Types") +{ + setupData(); +} + +ItemTypeGroupModel::~ItemTypeGroupModel() +{ +} + +bool ItemTypeGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new ItemTypeModel(this, static_cast<Pokemod*>(m_object)->newItemType())); + return true; +} + +bool ItemTypeGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteItemType(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void ItemTypeGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->itemTypeCount(); ++i) + m_objects.append(new ItemTypeModel(this, pokemod->itemType(i))); +} diff --git a/pokemodr/models/ItemTypeGroupModel.h b/pokemodr/models/ItemTypeGroupModel.h new file mode 100644 index 00000000..c592c8d8 --- /dev/null +++ b/pokemodr/models/ItemTypeGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_ITEMTYPEGROUPMODEL__ +#define __POKEMODR_ITEMTYPEGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class ItemTypeGroupModel : public GroupModel +{ + public: + ItemTypeGroupModel(BaseModel* parent, Pokemod* pokemod); + ~ItemTypeGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/ItemTypeModel.cpp b/pokemodr/models/ItemTypeModel.cpp index 51d0b3d1..ffe92bc3 100644 --- a/pokemodr/models/ItemTypeModel.cpp +++ b/pokemodr/models/ItemTypeModel.cpp @@ -76,8 +76,3 @@ bool ItemTypeModel::setData(const QVariant& value, int role) } return false; } - -int ItemTypeModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->itemTypeIndex(m_object->id()); -} diff --git a/pokemodr/models/ItemTypeModel.h b/pokemodr/models/ItemTypeModel.h index abf933ea..b52a3b4b 100644 --- a/pokemodr/models/ItemTypeModel.h +++ b/pokemodr/models/ItemTypeModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_ITEMTYPEMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class ItemType; @@ -33,8 +33,6 @@ class ItemTypeModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/MapEffectGroupModel.cpp b/pokemodr/models/MapEffectGroupModel.cpp new file mode 100644 index 00000000..ca0b787c --- /dev/null +++ b/pokemodr/models/MapEffectGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapEffectGroupModel.h" + +// Model includes +#include "MapEffectModel.h" + +// Map includes +#include "../../pokemod/Map.h" + +MapEffectGroupModel::MapEffectGroupModel(BaseModel* parent, Map* map) : + GroupModel(parent, map, "Effects") +{ + setupData(); +} + +MapEffectGroupModel::~MapEffectGroupModel() +{ +} + +bool MapEffectGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new MapEffectModel(this, static_cast<Map*>(m_object)->newEffect())); + return true; +} + +bool MapEffectGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Map*>(m_object)->deleteEffect(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void MapEffectGroupModel::setupData() +{ + Map* map = static_cast<Map*>(m_object); + for (int i = 0; i < map->effectCount(); ++i) + m_objects.append(new MapEffectModel(this, map->effect(i))); +} diff --git a/pokemodr/models/MapEffectGroupModel.h b/pokemodr/models/MapEffectGroupModel.h new file mode 100644 index 00000000..b972641e --- /dev/null +++ b/pokemodr/models/MapEffectGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_MAPEFFECTGROUPMODEL__ +#define __POKEMODR_MAPEFFECTGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Map; + +class MapEffectGroupModel : public GroupModel +{ + public: + MapEffectGroupModel(BaseModel* parent, Map* map); + ~MapEffectGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/MapEffectModel.cpp b/pokemodr/models/MapEffectModel.cpp index d9b49edd..208a5c62 100644 --- a/pokemodr/models/MapEffectModel.cpp +++ b/pokemodr/models/MapEffectModel.cpp @@ -76,8 +76,3 @@ bool MapEffectModel::setData(const QVariant& value, int role) } return false; } - -int MapEffectModel::indexNumber() const -{ - return static_cast<const Map*>(m_object->parent())->effectIndex(m_object->id()); -} diff --git a/pokemodr/models/MapEffectModel.h b/pokemodr/models/MapEffectModel.h index 4482b063..00b9deaf 100644 --- a/pokemodr/models/MapEffectModel.h +++ b/pokemodr/models/MapEffectModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_MAPEFFECTMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class MapEffect; @@ -33,8 +33,6 @@ class MapEffectModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/MapGroupModel.cpp b/pokemodr/models/MapGroupModel.cpp new file mode 100644 index 00000000..767a1007 --- /dev/null +++ b/pokemodr/models/MapGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapGroupModel.h" + +// Model includes +#include "MapModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +MapGroupModel::MapGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Maps") +{ + setupData(); +} + +MapGroupModel::~MapGroupModel() +{ +} + +bool MapGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new MapModel(this, static_cast<Pokemod*>(m_object)->newMap())); + return true; +} + +bool MapGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteMap(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void MapGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->mapCount(); ++i) + m_objects.append(new MapModel(this, pokemod->map(i))); +} diff --git a/pokemodr/models/MapGroupModel.h b/pokemodr/models/MapGroupModel.h new file mode 100644 index 00000000..cad9de1e --- /dev/null +++ b/pokemodr/models/MapGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_MAPGROUPMODEL__ +#define __POKEMODR_MAPGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class MapGroupModel : public GroupModel +{ + public: + MapGroupModel(BaseModel* parent, Pokemod* pokemod); + ~MapGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/MapModel.cpp b/pokemodr/models/MapModel.cpp index e3834e1a..4fc65ae1 100644 --- a/pokemodr/models/MapModel.cpp +++ b/pokemodr/models/MapModel.cpp @@ -19,10 +19,10 @@ #include "MapModel.h" // Model includes -#include "MapEffectModel.h" -#include "MapTrainerModel.h" -#include "MapWarpModel.h" -#include "MapWildListModel.h" +#include "MapEffectGroupModel.h" +#include "MapTrainerGroupModel.h" +#include "MapWarpGroupModel.h" +#include "MapWildListGroupModel.h" // PokeModr includes #include "../MapUI.h" @@ -34,166 +34,6 @@ // Qt includes #include <QFile> -MapEffectGroupModel::MapEffectGroupModel(BaseModel* parent, Map* map) : - GroupModel(parent, map, "Effects") -{ - setupData(); -} - -MapEffectGroupModel::~MapEffectGroupModel() -{ -} - -int MapEffectGroupModel::indexNumber() const -{ - return 0; -} - -bool MapEffectGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new MapEffectModel(this, static_cast<Map*>(m_object)->newEffect())); - return true; -} - -bool MapEffectGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Map*>(m_object)->deleteEffect(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void MapEffectGroupModel::setupData() -{ - Map* map = static_cast<Map*>(m_object); - for (int i = 0; i < map->effectCount(); ++i) - m_objects.append(new MapEffectModel(this, map->effect(i))); -} - -MapTrainerGroupModel::MapTrainerGroupModel(BaseModel* parent, Map* map) : - GroupModel(parent, map, "Trainers") -{ - setupData(); -} - -MapTrainerGroupModel::~MapTrainerGroupModel() -{ -} - -int MapTrainerGroupModel::indexNumber() const -{ - return 1; -} - -bool MapTrainerGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new MapTrainerModel(this, static_cast<Map*>(m_object)->newTrainer())); - return true; -} - -bool MapTrainerGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Map*>(m_object)->deleteTrainer(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void MapTrainerGroupModel::setupData() -{ - Map* map = static_cast<Map*>(m_object); - for (int i = 0; i < map->trainerCount(); ++i) - m_objects.append(new MapTrainerModel(this, map->trainer(i))); -} - -MapWarpGroupModel::MapWarpGroupModel(BaseModel* parent, Map* map) : - GroupModel(parent, map, "Warps") -{ - setupData(); -} - -MapWarpGroupModel::~MapWarpGroupModel() -{ -} - -int MapWarpGroupModel::indexNumber() const -{ - return 2; -} - -bool MapWarpGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new MapWarpModel(this, static_cast<Map*>(m_object)->newWarp())); - return true; -} - -bool MapWarpGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Map*>(m_object)->deleteWarp(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void MapWarpGroupModel::setupData() -{ - Map* map = static_cast<Map*>(m_object); - for (int i = 0; i < map->warpCount(); ++i) - m_objects.append(new MapWarpModel(this, map->warp(i))); -} - -MapWildListGroupModel::MapWildListGroupModel(BaseModel* parent, Map* map) : - GroupModel(parent, map, "Wild Lists") -{ - setupData(); -} - -MapWildListGroupModel::~MapWildListGroupModel() -{ -} - -int MapWildListGroupModel::indexNumber() const -{ - return 3; -} - -bool MapWildListGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new MapWildListModel(this, static_cast<Map*>(m_object)->newWildList())); - return true; -} - -bool MapWildListGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Map*>(m_object)->deleteWildList(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void MapWildListGroupModel::setupData() -{ - Map* map = static_cast<Map*>(m_object); - for (int i = 0; i < map->wildListCount(); ++i) - m_objects.append(new MapWildListModel(this, map->wildList(i))); -} - MapModel::MapModel(BaseModel* parent, Map* map) : GroupObjectModel(parent, map) { @@ -202,7 +42,6 @@ MapModel::MapModel(BaseModel* parent, Map* map) : MapModel::~MapModel() { - clearData(); } QVariant MapModel::data(int role) const @@ -223,11 +62,6 @@ QVariant MapModel::data(int role) const return GroupObjectModel::data(role); } -int MapModel::rowCount() const -{ - return 4; -} - bool MapModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -252,35 +86,6 @@ bool MapModel::setData(const QVariant& value, int role) return false; } -BaseModel* MapModel::childItem(const int row) -{ - BaseModel* model; - switch (row) - { - case 0: - model = m_effects; - break; - case 1: - model = m_trainers; - break; - case 2: - model = m_warps; - break; - case 3: - model = m_wildLists; - break; - default: - model = NULL; - break; - } - return model; -} - -int MapModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->mapIndex(m_object->id()); -} - bool MapModel::insertRows(const int /*rows*/) { return false; @@ -293,16 +98,8 @@ bool MapModel::removeRows(const int /*position*/, const int /*rows*/) void MapModel::setupData() { - m_effects = new MapEffectGroupModel(this, static_cast<Map*>(m_object)); - m_trainers = new MapTrainerGroupModel(this, static_cast<Map*>(m_object)); - m_warps = new MapWarpGroupModel(this, static_cast<Map*>(m_object)); - m_wildLists = new MapWildListGroupModel(this, static_cast<Map*>(m_object)); -} - -void MapModel::clearData() -{ - delete m_effects; - delete m_trainers; - delete m_warps; - delete m_wildLists; + m_objects.append(new MapEffectGroupModel(this, static_cast<Map*>(m_object))); + m_objects.append(new MapTrainerGroupModel(this, static_cast<Map*>(m_object))); + m_objects.append(new MapWarpGroupModel(this, static_cast<Map*>(m_object))); + m_objects.append(new MapWildListGroupModel(this, static_cast<Map*>(m_object))); } diff --git a/pokemodr/models/MapModel.h b/pokemodr/models/MapModel.h index f3f0b7ff..d53a6edd 100644 --- a/pokemodr/models/MapModel.h +++ b/pokemodr/models/MapModel.h @@ -19,71 +19,11 @@ #define __POKEMODR_MAPMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupObjectModel.h" // Forward declarations class Map; -class MapEffectGroupModel : public GroupModel -{ - public: - MapEffectGroupModel(BaseModel* parent, Map* map); - ~MapEffectGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class MapTrainerGroupModel : public GroupModel -{ - public: - MapTrainerGroupModel(BaseModel* parent, Map* map); - ~MapTrainerGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class MapWarpGroupModel : public GroupModel -{ - public: - MapWarpGroupModel(BaseModel* parent, Map* map); - ~MapWarpGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class MapWildListGroupModel : public GroupModel -{ - public: - MapWildListGroupModel(BaseModel* parent, Map* map); - ~MapWildListGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - class MapModel : public GroupObjectModel { public: @@ -91,24 +31,14 @@ class MapModel : public GroupObjectModel ~MapModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int /*rows*/); bool removeRows(const int /*position*/, const int /*rows*/); protected: void setupData(); - void clearData(); - private: - MapEffectGroupModel* m_effects; - MapTrainerGroupModel* m_trainers; - MapWarpGroupModel* m_warps; - MapWildListGroupModel* m_wildLists; }; #endif diff --git a/pokemodr/models/MapTrainerGroupModel.cpp b/pokemodr/models/MapTrainerGroupModel.cpp new file mode 100644 index 00000000..289ac6fc --- /dev/null +++ b/pokemodr/models/MapTrainerGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapTrainerGroupModel.h" + +// Model includes +#include "MapTrainerModel.h" + +// Map includes +#include "../../pokemod/Map.h" + +MapTrainerGroupModel::MapTrainerGroupModel(BaseModel* parent, Map* map) : + GroupModel(parent, map, "Trainers") +{ + setupData(); +} + +MapTrainerGroupModel::~MapTrainerGroupModel() +{ +} + +bool MapTrainerGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new MapTrainerModel(this, static_cast<Map*>(m_object)->newTrainer())); + return true; +} + +bool MapTrainerGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Map*>(m_object)->deleteTrainer(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void MapTrainerGroupModel::setupData() +{ + Map* map = static_cast<Map*>(m_object); + for (int i = 0; i < map->trainerCount(); ++i) + m_objects.append(new MapTrainerModel(this, map->trainer(i))); +} diff --git a/pokemodr/models/MapTrainerGroupModel.h b/pokemodr/models/MapTrainerGroupModel.h new file mode 100644 index 00000000..f5269188 --- /dev/null +++ b/pokemodr/models/MapTrainerGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_MAPTRAINERGROUPMODEL__ +#define __POKEMODR_MAPTRAINERGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Map; + +class MapTrainerGroupModel : public GroupModel +{ + public: + MapTrainerGroupModel(BaseModel* parent, Map* map); + ~MapTrainerGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/MapTrainerModel.cpp b/pokemodr/models/MapTrainerModel.cpp index a6d87af2..1ef4b875 100644 --- a/pokemodr/models/MapTrainerModel.cpp +++ b/pokemodr/models/MapTrainerModel.cpp @@ -60,11 +60,6 @@ QVariant MapTrainerModel::data(int role) const return GroupObjectModel::data(role); } -int MapTrainerModel::rowCount() const -{ - return static_cast<MapTrainer*>(m_object)->teamMemberCount(); -} - bool MapTrainerModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -89,22 +84,10 @@ bool MapTrainerModel::setData(const QVariant& value, int role) return false; } -BaseModel* MapTrainerModel::childItem(const int row) -{ - if (row < m_teamMembers.size()) - return m_teamMembers[row]; - return NULL; -} - -int MapTrainerModel::indexNumber() const -{ - return static_cast<const Map*>(m_object->parent())->trainerIndex(m_object->id()); -} - bool MapTrainerModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) - m_teamMembers.append(new MapTrainerTeamMemberModel(this, static_cast<MapTrainer*>(m_object)->newTeamMember())); + m_objects.append(new MapTrainerTeamMemberModel(this, static_cast<MapTrainer*>(m_object)->newTeamMember())); return true; } @@ -113,8 +96,8 @@ bool MapTrainerModel::removeRows(const int position, const int rows) for (int i = 0; i < rows; ++i) { static_cast<MapTrainer*>(m_object)->deleteTeamMember(position); - delete m_teamMembers[position]; - m_teamMembers.removeAt(position); + delete m_objects[position]; + m_objects.removeAt(position); } return true; } @@ -123,11 +106,5 @@ void MapTrainerModel::setupData() { MapTrainer* trainer = static_cast<MapTrainer*>(m_object); for (int i = 0; i < trainer->teamMemberCount(); ++i) - m_teamMembers.append(new MapTrainerTeamMemberModel(this, trainer->teamMember(i))); -} - -void MapTrainerModel::clearData() -{ - foreach (MapTrainerTeamMemberModel* model, m_teamMembers) - delete model; + m_objects.append(new MapTrainerTeamMemberModel(this, trainer->teamMember(i))); } diff --git a/pokemodr/models/MapTrainerModel.h b/pokemodr/models/MapTrainerModel.h index e2f729cd..daf3fb5b 100644 --- a/pokemodr/models/MapTrainerModel.h +++ b/pokemodr/models/MapTrainerModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_MAPTRAINERMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupObjectModel.h" // Forward declarations class MapTrainer; @@ -32,21 +32,14 @@ class MapTrainerModel : public GroupObjectModel ~MapTrainerModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int rows); bool removeRows(const int position, const int rows); protected: void setupData(); - void clearData(); - private: - QList<MapTrainerTeamMemberModel*> m_teamMembers; }; #endif diff --git a/pokemodr/models/MapTrainerTeamMemberModel.cpp b/pokemodr/models/MapTrainerTeamMemberModel.cpp index c22de944..045fde58 100644 --- a/pokemodr/models/MapTrainerTeamMemberModel.cpp +++ b/pokemodr/models/MapTrainerTeamMemberModel.cpp @@ -82,8 +82,3 @@ bool MapTrainerTeamMemberModel::setData(const QVariant& value, int role) } return false; } - -int MapTrainerTeamMemberModel::indexNumber() const -{ - return static_cast<const MapTrainer*>(m_object->parent())->teamMemberIndex(m_object->id()); -} diff --git a/pokemodr/models/MapTrainerTeamMemberModel.h b/pokemodr/models/MapTrainerTeamMemberModel.h index 8345f103..e1bbfd77 100644 --- a/pokemodr/models/MapTrainerTeamMemberModel.h +++ b/pokemodr/models/MapTrainerTeamMemberModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_MAPTRAINERTEAMMEMBERMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class MapTrainerTeamMember; @@ -33,8 +33,6 @@ class MapTrainerTeamMemberModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/MapWarpGroupModel.cpp b/pokemodr/models/MapWarpGroupModel.cpp new file mode 100644 index 00000000..5491b423 --- /dev/null +++ b/pokemodr/models/MapWarpGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapWarpGroupModel.h" + +// Model includes +#include "MapWarpModel.h" + +// Map includes +#include "../../pokemod/Map.h" + +MapWarpGroupModel::MapWarpGroupModel(BaseModel* parent, Map* map) : + GroupModel(parent, map, "Warps") +{ + setupData(); +} + +MapWarpGroupModel::~MapWarpGroupModel() +{ +} + +bool MapWarpGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new MapWarpModel(this, static_cast<Map*>(m_object)->newWarp())); + return true; +} + +bool MapWarpGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Map*>(m_object)->deleteWarp(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void MapWarpGroupModel::setupData() +{ + Map* map = static_cast<Map*>(m_object); + for (int i = 0; i < map->warpCount(); ++i) + m_objects.append(new MapWarpModel(this, map->warp(i))); +} diff --git a/pokemodr/models/MapWarpGroupModel.h b/pokemodr/models/MapWarpGroupModel.h new file mode 100644 index 00000000..c4b3dc10 --- /dev/null +++ b/pokemodr/models/MapWarpGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_MAPWARPGROUPMODEL__ +#define __POKEMODR_MAPWARPGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Map; + +class MapWarpGroupModel : public GroupModel +{ + public: + MapWarpGroupModel(BaseModel* parent, Map* map); + ~MapWarpGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/MapWarpModel.cpp b/pokemodr/models/MapWarpModel.cpp index 098b99d1..ba3a55a0 100644 --- a/pokemodr/models/MapWarpModel.cpp +++ b/pokemodr/models/MapWarpModel.cpp @@ -76,8 +76,3 @@ bool MapWarpModel::setData(const QVariant& value, int role) } return false; } - -int MapWarpModel::indexNumber() const -{ - return static_cast<const Map*>(m_object->parent())->warpIndex(m_object->id()); -} diff --git a/pokemodr/models/MapWarpModel.h b/pokemodr/models/MapWarpModel.h index 312300eb..602d0565 100644 --- a/pokemodr/models/MapWarpModel.h +++ b/pokemodr/models/MapWarpModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_MAPWARPMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class MapWarp; @@ -33,8 +33,6 @@ class MapWarpModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/MapWildListEncounterModel.cpp b/pokemodr/models/MapWildListEncounterModel.cpp index 7c1d7587..94f38818 100644 --- a/pokemodr/models/MapWildListEncounterModel.cpp +++ b/pokemodr/models/MapWildListEncounterModel.cpp @@ -82,8 +82,3 @@ bool MapWildListEncounterModel::setData(const QVariant& value, int role) } return false; } - -int MapWildListEncounterModel::indexNumber() const -{ - return static_cast<const MapWildList*>(m_object->parent())->encounterIndex(m_object->id()); -} diff --git a/pokemodr/models/MapWildListEncounterModel.h b/pokemodr/models/MapWildListEncounterModel.h index 2be6aeaf..bf0d2d9a 100644 --- a/pokemodr/models/MapWildListEncounterModel.h +++ b/pokemodr/models/MapWildListEncounterModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_MAPWILDLISTENCOUNTERMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class MapWildListEncounter; @@ -33,8 +33,6 @@ class MapWildListEncounterModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/MapWildListGroupModel.cpp b/pokemodr/models/MapWildListGroupModel.cpp new file mode 100644 index 00000000..1e5ac344 --- /dev/null +++ b/pokemodr/models/MapWildListGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapWildListGroupModel.h" + +// Model includes +#include "MapWildListModel.h" + +// Map includes +#include "../../pokemod/Map.h" + +MapWildListGroupModel::MapWildListGroupModel(BaseModel* parent, Map* map) : + GroupModel(parent, map, "Wild Lists") +{ + setupData(); +} + +MapWildListGroupModel::~MapWildListGroupModel() +{ +} + +bool MapWildListGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new MapWildListModel(this, static_cast<Map*>(m_object)->newWildList())); + return true; +} + +bool MapWildListGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Map*>(m_object)->deleteWildList(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void MapWildListGroupModel::setupData() +{ + Map* map = static_cast<Map*>(m_object); + for (int i = 0; i < map->wildListCount(); ++i) + m_objects.append(new MapWildListModel(this, map->wildList(i))); +} diff --git a/pokemodr/models/MapWildListGroupModel.h b/pokemodr/models/MapWildListGroupModel.h new file mode 100644 index 00000000..72267444 --- /dev/null +++ b/pokemodr/models/MapWildListGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_MAPWILDLISTGROUPMODEL__ +#define __POKEMODR_MAPWILDLISTGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Map; + +class MapWildListGroupModel : public GroupModel +{ + public: + MapWildListGroupModel(BaseModel* parent, Map* map); + ~MapWildListGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif 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<MapWildList*>(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<const Map*>(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<MapWildList*>(m_object)->newEncounter())); + m_objects.append(new MapWildListEncounterModel(this, static_cast<MapWildList*>(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<MapWildList*>(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<MapWildList*>(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))); } diff --git a/pokemodr/models/MapWildListModel.h b/pokemodr/models/MapWildListModel.h index 93651b2c..d3dc6617 100644 --- a/pokemodr/models/MapWildListModel.h +++ b/pokemodr/models/MapWildListModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_MAPWILDLISTMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupObjectModel.h" // Forward declarations class MapWildList; @@ -32,21 +32,14 @@ class MapWildListModel : public GroupObjectModel ~MapWildListModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int rows); bool removeRows(const int position, const int rows); protected: void setupData(); - void clearData(); - private: - QList<MapWildListEncounterModel*> m_encounters; }; #endif diff --git a/pokemodr/models/MoveEffectModel.cpp b/pokemodr/models/MoveEffectModel.cpp index d320555f..fcb0fb00 100644 --- a/pokemodr/models/MoveEffectModel.cpp +++ b/pokemodr/models/MoveEffectModel.cpp @@ -81,8 +81,3 @@ bool MoveEffectModel::setData(const QVariant& value, int role) } return false; } - -int MoveEffectModel::indexNumber() const -{ - return static_cast<const Move*>(m_object->parent())->effectIndex(m_object->id()); -} diff --git a/pokemodr/models/MoveEffectModel.h b/pokemodr/models/MoveEffectModel.h index 2c8bca91..ef20671a 100644 --- a/pokemodr/models/MoveEffectModel.h +++ b/pokemodr/models/MoveEffectModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_MOVEEFFECTMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class MoveEffect; @@ -33,8 +33,6 @@ class MoveEffectModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/MoveGroupModel.cpp b/pokemodr/models/MoveGroupModel.cpp new file mode 100644 index 00000000..cb98f9a9 --- /dev/null +++ b/pokemodr/models/MoveGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MoveGroupModel.h" + +// Model includes +#include "MoveModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +MoveGroupModel::MoveGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Moves") +{ + setupData(); +} + +MoveGroupModel::~MoveGroupModel() +{ +} + +bool MoveGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new MoveModel(this, static_cast<Pokemod*>(m_object)->newMove())); + return true; +} + +bool MoveGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteMove(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void MoveGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->moveCount(); ++i) + m_objects.append(new MoveModel(this, pokemod->move(i))); +} diff --git a/pokemodr/models/MoveGroupModel.h b/pokemodr/models/MoveGroupModel.h new file mode 100644 index 00000000..baecd50a --- /dev/null +++ b/pokemodr/models/MoveGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_MOVEGROUPMODEL__ +#define __POKEMODR_MOVEGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class MoveGroupModel : public GroupModel +{ + public: + MoveGroupModel(BaseModel* parent, Pokemod* pokemod); + ~MoveGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/MoveModel.cpp b/pokemodr/models/MoveModel.cpp index 286d6002..f0db1dfd 100644 --- a/pokemodr/models/MoveModel.cpp +++ b/pokemodr/models/MoveModel.cpp @@ -60,11 +60,6 @@ QVariant MoveModel::data(int role) const return GroupObjectModel::data(role); } -int MoveModel::rowCount() const -{ - return m_effects.size(); -} - bool MoveModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -89,22 +84,10 @@ bool MoveModel::setData(const QVariant& value, int role) return false; } -BaseModel* MoveModel::childItem(const int row) -{ - if (row < m_effects.size()) - return m_effects[row]; - return NULL; -} - -int MoveModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->moveIndex(m_object->id()); -} - bool MoveModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) - m_effects.append(new MoveEffectModel(this, static_cast<Move*>(m_object)->newEffect())); + m_objects.append(new MoveEffectModel(this, static_cast<Move*>(m_object)->newEffect())); return true; } @@ -113,8 +96,8 @@ bool MoveModel::removeRows(const int position, const int rows) for (int i = 0; i < rows; ++i) { static_cast<Move*>(m_object)->deleteEffect(position); - delete m_effects[position]; - m_effects.removeAt(position); + delete m_objects[position]; + m_objects.removeAt(position); } return true; } @@ -123,11 +106,5 @@ void MoveModel::setupData() { Move* move = static_cast<Move*>(m_object); for (int i = 0; i < move->effectCount(); ++i) - m_effects.append(new MoveEffectModel(this, move->effect(i))); -} - -void MoveModel::clearData() -{ - foreach (MoveEffectModel* model, m_effects) - delete model; + m_objects.append(new MoveEffectModel(this, move->effect(i))); } diff --git a/pokemodr/models/MoveModel.h b/pokemodr/models/MoveModel.h index 8bd69cdf..f6b89de5 100644 --- a/pokemodr/models/MoveModel.h +++ b/pokemodr/models/MoveModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_MOVEMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupObjectModel.h" // Forward declarations class Move; @@ -32,21 +32,14 @@ class MoveModel : public GroupObjectModel ~MoveModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int rows); bool removeRows(const int position, const int rows); protected: void setupData(); - void clearData(); - private: - QList<MoveEffectModel*> m_effects; }; #endif diff --git a/pokemodr/models/NatureGroupModel.cpp b/pokemodr/models/NatureGroupModel.cpp new file mode 100644 index 00000000..8b308878 --- /dev/null +++ b/pokemodr/models/NatureGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "NatureGroupModel.h" + +// Model includes +#include "NatureModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +NatureGroupModel::NatureGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Natures") +{ + setupData(); +} + +NatureGroupModel::~NatureGroupModel() +{ +} + +bool NatureGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new NatureModel(this, static_cast<Pokemod*>(m_object)->newNature())); + return true; +} + +bool NatureGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteNature(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void NatureGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->natureCount(); ++i) + m_objects.append(new NatureModel(this, pokemod->nature(i))); +} diff --git a/pokemodr/models/NatureGroupModel.h b/pokemodr/models/NatureGroupModel.h new file mode 100644 index 00000000..872b860e --- /dev/null +++ b/pokemodr/models/NatureGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_NATUREGROUPMODEL__ +#define __POKEMODR_NATUREGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class NatureGroupModel : public GroupModel +{ + public: + NatureGroupModel(BaseModel* parent, Pokemod* pokemod); + ~NatureGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/NatureModel.cpp b/pokemodr/models/NatureModel.cpp index dab805f4..801ca8ae 100644 --- a/pokemodr/models/NatureModel.cpp +++ b/pokemodr/models/NatureModel.cpp @@ -76,8 +76,3 @@ bool NatureModel::setData(const QVariant& value, int role) } return false; } - -int NatureModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->natureIndex(m_object->id()); -} diff --git a/pokemodr/models/NatureModel.h b/pokemodr/models/NatureModel.h index 3f441601..c954917d 100644 --- a/pokemodr/models/NatureModel.h +++ b/pokemodr/models/NatureModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_NATUREMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Nature; @@ -33,8 +33,6 @@ class NatureModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/ObjectModel.cpp b/pokemodr/models/ObjectModel.cpp new file mode 100644 index 00000000..82a6e674 --- /dev/null +++ b/pokemodr/models/ObjectModel.cpp @@ -0,0 +1,63 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "ObjectModel.h" + +ObjectModel::ObjectModel(BaseModel* parent, Object* object) : + BaseObjectModel(parent, object) +{ +} + +ObjectModel::~ObjectModel() +{ +} + +int ObjectModel::rowCount() const +{ + return 0; +} + +QVariant ObjectModel::data(int role) const +{ + return BaseObjectModel::data(role); +} + +BaseModel* ObjectModel::childItem(const int /*row*/) +{ + return NULL; +} + +bool ObjectModel::canInsertRows() const +{ + return false; +} + +bool ObjectModel::insertRows(const int /*rows*/) +{ + return false; +} + +bool ObjectModel::canRemoveRows() const +{ + return false; +} + +bool ObjectModel::removeRows(const int /*position*/, const int /*rows*/) +{ + return false; +} diff --git a/pokemodr/models/ObjectModel.h b/pokemodr/models/ObjectModel.h new file mode 100644 index 00000000..743c5d2e --- /dev/null +++ b/pokemodr/models/ObjectModel.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_OBJECTMODEL__ +#define __POKEMODR_OBJECTMODEL__ + +// Model includes +#include "BaseObjectModel.h" + +class ObjectModel : public BaseObjectModel +{ + public: + ObjectModel(BaseModel* parent, Object* object); + virtual ~ObjectModel(); + + virtual QVariant data(int role = Qt::DisplayRole) const = 0; + int rowCount() const; + + virtual bool setData(const QVariant& value, int role = Qt::EditRole) = 0; + + BaseModel* childItem(const int /*row*/); + + bool canInsertRows() const; + bool insertRows(const int /*rows*/); + + bool canRemoveRows() const; + bool removeRows(const int /*position*/, const int /*rows*/); +}; + +#endif diff --git a/pokemodr/models/PokemodModel.cpp b/pokemodr/models/PokemodModel.cpp index e4409f10..3309107a 100644 --- a/pokemodr/models/PokemodModel.cpp +++ b/pokemodr/models/PokemodModel.cpp @@ -19,24 +19,25 @@ #include "PokemodModel.h" // Model includes -#include "AbilityModel.h" -#include "AuthorModel.h" -#include "BadgeModel.h" -#include "CoinListModel.h" -#include "DialogModel.h" -#include "EggGroupModel.h" -#include "ItemModel.h" -#include "ItemTypeModel.h" -#include "MapModel.h" -#include "MoveModel.h" -#include "NatureModel.h" -#include "SoundModel.h" -#include "SpeciesModel.h" -#include "StoreModel.h" -#include "TileModel.h" -#include "TimeModel.h" -#include "TrainerModel.h" -#include "TypeModel.h" +#include "AbilityGroupModel.h" +#include "AuthorGroupModel.h" +#include "BadgeGroupModel.h" +#include "CoinListGroupModel.h" +#include "DialogGroupModel.h" +#include "EggGroupGroupModel.h" +#include "ItemGroupModel.h" +#include "ItemTypeGroupModel.h" +#include "MapGroupModel.h" +#include "MoveGroupModel.h" +#include "NatureGroupModel.h" +#include "RulesModel.h" +#include "SoundGroupModel.h" +#include "SpeciesGroupModel.h" +#include "StoreGroupModel.h" +#include "TileGroupModel.h" +#include "TimeGroupModel.h" +#include "TrainerGroupModel.h" +#include "TypeGroupModel.h" // PokeModr includes #include "../PokemodUI.h" @@ -47,727 +48,6 @@ // Qt includes #include <QFile> -AbilityGroupModel::AbilityGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Abilities") -{ - setupData(); -} - -AbilityGroupModel::~AbilityGroupModel() -{ -} - -int AbilityGroupModel::indexNumber() const -{ - return 1; -} - -bool AbilityGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new AbilityModel(this, static_cast<Pokemod*>(m_object)->newAbility())); - return true; -} - -bool AbilityGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteAbility(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void AbilityGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->abilityCount(); ++i) - m_objects.append(new AbilityModel(this, pokemod->ability(i))); -} - -AuthorGroupModel::AuthorGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Authors") -{ - setupData(); -} - -AuthorGroupModel::~AuthorGroupModel() -{ -} - -int AuthorGroupModel::indexNumber() const -{ - return 2; -} - -bool AuthorGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new AuthorModel(this, static_cast<Pokemod*>(m_object)->newAuthor())); - return true; -} - -bool AuthorGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteAuthor(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void AuthorGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->authorCount(); ++i) - m_objects.append(new AuthorModel(this, pokemod->author(i))); -} - -BadgeGroupModel::BadgeGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Badges") -{ - setupData(); -} - -BadgeGroupModel::~BadgeGroupModel() -{ -} - -int BadgeGroupModel::indexNumber() const -{ - return 3; -} - -bool BadgeGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new BadgeModel(this, static_cast<Pokemod*>(m_object)->newBadge())); - return true; -} - -bool BadgeGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteBadge(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void BadgeGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->badgeCount(); ++i) - m_objects.append(new BadgeModel(this, pokemod->badge(i))); -} - -CoinListGroupModel::CoinListGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Coin Lists") -{ - setupData(); -} - -CoinListGroupModel::~CoinListGroupModel() -{ -} - -int CoinListGroupModel::indexNumber() const -{ - return 4; -} - -bool CoinListGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new CoinListModel(this, static_cast<Pokemod*>(m_object)->newCoinList())); - return true; -} - -bool CoinListGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteCoinList(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void CoinListGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->coinListCount(); ++i) - m_objects.append(new CoinListModel(this, pokemod->coinList(i))); -} - -DialogGroupModel::DialogGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Dialogs") -{ - setupData(); -} - -DialogGroupModel::~DialogGroupModel() -{ -} - -int DialogGroupModel::indexNumber() const -{ - return 5; -} - -bool DialogGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new DialogModel(this, static_cast<Pokemod*>(m_object)->newDialog())); - return true; -} - -bool DialogGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteDialog(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void DialogGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->dialogCount(); ++i) - m_objects.append(new DialogModel(this, pokemod->dialog(i))); -} - -EggGroupGroupModel::EggGroupGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Egg Groups") -{ - setupData(); -} - -EggGroupGroupModel::~EggGroupGroupModel() -{ -} - -int EggGroupGroupModel::indexNumber() const -{ - return 6; -} - -bool EggGroupGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new EggGroupModel(this, static_cast<Pokemod*>(m_object)->newEggGroup())); - return true; -} - -bool EggGroupGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteEggGroup(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void EggGroupGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->eggGroupCount(); ++i) - m_objects.append(new EggGroupModel(this, pokemod->eggGroup(i))); -} - -ItemGroupModel::ItemGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Items") -{ - setupData(); -} - -ItemGroupModel::~ItemGroupModel() -{ -} - -int ItemGroupModel::indexNumber() const -{ - return 7; -} - -bool ItemGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new ItemModel(this, static_cast<Pokemod*>(m_object)->newItem())); - return true; -} - -bool ItemGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteItem(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void ItemGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->itemCount(); ++i) - m_objects.append(new ItemModel(this, pokemod->item(i))); -} - -ItemTypeGroupModel::ItemTypeGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Item Types") -{ - setupData(); -} - -ItemTypeGroupModel::~ItemTypeGroupModel() -{ -} - -int ItemTypeGroupModel::indexNumber() const -{ - return 8; -} - -bool ItemTypeGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new ItemTypeModel(this, static_cast<Pokemod*>(m_object)->newItemType())); - return true; -} - -bool ItemTypeGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteItemType(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void ItemTypeGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->itemTypeCount(); ++i) - m_objects.append(new ItemTypeModel(this, pokemod->itemType(i))); -} - -MapGroupModel::MapGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Maps") -{ - setupData(); -} - -MapGroupModel::~MapGroupModel() -{ -} - -int MapGroupModel::indexNumber() const -{ - return 9; -} - -bool MapGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new MapModel(this, static_cast<Pokemod*>(m_object)->newMap())); - return true; -} - -bool MapGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteMap(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void MapGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->mapCount(); ++i) - m_objects.append(new MapModel(this, pokemod->map(i))); -} - -MoveGroupModel::MoveGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Moves") -{ - setupData(); -} - -MoveGroupModel::~MoveGroupModel() -{ -} - -int MoveGroupModel::indexNumber() const -{ - return 10; -} - -bool MoveGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new MoveModel(this, static_cast<Pokemod*>(m_object)->newMove())); - return true; -} - -bool MoveGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteMove(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void MoveGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->moveCount(); ++i) - m_objects.append(new MoveModel(this, pokemod->move(i))); -} - -NatureGroupModel::NatureGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Natures") -{ - setupData(); -} - -NatureGroupModel::~NatureGroupModel() -{ -} - -int NatureGroupModel::indexNumber() const -{ - return 11; -} - -bool NatureGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new NatureModel(this, static_cast<Pokemod*>(m_object)->newNature())); - return true; -} - -bool NatureGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteNature(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void NatureGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->natureCount(); ++i) - 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") -{ - setupData(); -} - -SpeciesGroupModel::~SpeciesGroupModel() -{ -} - -int SpeciesGroupModel::indexNumber() const -{ - return 13; -} - -bool SpeciesGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new SpeciesModel(this, static_cast<Pokemod*>(m_object)->newSpecies())); - return true; -} - -bool SpeciesGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteSpecies(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void SpeciesGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->speciesCount(); ++i) - m_objects.append(new SpeciesModel(this, pokemod->species(i))); -} - -StoreGroupModel::StoreGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Stores") -{ - setupData(); -} - -StoreGroupModel::~StoreGroupModel() -{ -} - -int StoreGroupModel::indexNumber() const -{ - return 14; -} - -bool StoreGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new StoreModel(this, static_cast<Pokemod*>(m_object)->newStore())); - return true; -} - -bool StoreGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteStore(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void StoreGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->storeCount(); ++i) - m_objects.append(new StoreModel(this, pokemod->store(i))); -} - -TileGroupModel::TileGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Tiles") -{ - setupData(); -} - -TileGroupModel::~TileGroupModel() -{ -} - -int TileGroupModel::indexNumber() const -{ - return 15; -} - -bool TileGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new TileModel(this, static_cast<Pokemod*>(m_object)->newTile())); - return true; -} - -bool TileGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteTile(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void TileGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->tileCount(); ++i) - m_objects.append(new TileModel(this, pokemod->tile(i))); -} - -TimeGroupModel::TimeGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Times") -{ - setupData(); -} - -TimeGroupModel::~TimeGroupModel() -{ -} - -int TimeGroupModel::indexNumber() const -{ - return 16; -} - -bool TimeGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new TimeModel(this, static_cast<Pokemod*>(m_object)->newTime())); - return true; -} - -bool TimeGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteTime(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void TimeGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->timeCount(); ++i) - m_objects.append(new TimeModel(this, pokemod->time(i))); -} - -TrainerGroupModel::TrainerGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Trainers") -{ - setupData(); -} - -TrainerGroupModel::~TrainerGroupModel() -{ - setupData(); -} - -int TrainerGroupModel::indexNumber() const -{ - return 17; -} - -bool TrainerGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new TrainerModel(this, static_cast<Pokemod*>(m_object)->newTrainer())); - return true; -} - -bool TrainerGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteTrainer(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void TrainerGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->trainerCount(); ++i) - m_objects.append(new TrainerModel(this, pokemod->trainer(i))); -} - -TypeGroupModel::TypeGroupModel(BaseModel* parent, Pokemod* pokemod) : - GroupModel(parent, pokemod, "Types") -{ - setupData(); -} - -TypeGroupModel::~TypeGroupModel() -{ -} - -int TypeGroupModel::indexNumber() const -{ - return 18; -} - -bool TypeGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new TypeModel(this, static_cast<Pokemod*>(m_object)->newType())); - return true; -} - -bool TypeGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Pokemod*>(m_object)->deleteType(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void TypeGroupModel::setupData() -{ - Pokemod* pokemod = static_cast<Pokemod*>(m_object); - for (int i = 0; i < pokemod->typeCount(); ++i) - m_objects.append(new TypeModel(this, pokemod->type(i))); -} - PokemodModel::PokemodModel(BaseModel* parent, Pokemod* pokemod) : GroupObjectModel(parent, pokemod) { @@ -797,11 +77,6 @@ QVariant PokemodModel::data(int role) const return GroupObjectModel::data(role); } -int PokemodModel::rowCount() const -{ - return 19; -} - bool PokemodModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -826,80 +101,6 @@ bool PokemodModel::setData(const QVariant& value, int role) return false; } -BaseModel* PokemodModel::childItem(const int row) -{ - BaseModel* model; - switch (row) - { - case 0: - model = m_rules; - break; - case 1: - model = m_abilities; - break; - case 2: - model = m_authors; - break; - case 3: - model = m_badges; - break; - case 4: - model = m_coinLists; - break; - case 5: - model = m_dialogs; - break; - case 6: - model = m_eggGroups; - break; - case 7: - model = m_items; - break; - case 8: - model = m_itemTypes; - break; - case 9: - model = m_maps; - break; - case 10: - model = m_moves; - break; - case 11: - model = m_natures; - break; - case 12: - model = m_sounds; - break; - case 13: - model = m_species; - break; - case 14: - model = m_stores; - break; - case 15: - model = m_tiles; - break; - case 16: - model = m_times; - break; - case 17: - model = m_trainers; - break; - case 18: - model = m_types; - break; - default: - model = NULL; - break; - } - return model; -} - -int PokemodModel::indexNumber() const -{ - // TODO: get pokemod index -} - bool PokemodModel::insertRows(const int /*rows*/) { return false; @@ -912,46 +113,23 @@ bool PokemodModel::removeRows(const int /*position*/, const int /*rows*/) void PokemodModel::setupData() { - m_rules = new RulesModel(this, static_cast<Pokemod*>(m_object)->rules()); - m_abilities = new AbilityGroupModel(this, static_cast<Pokemod*>(m_object)); - m_authors = new AuthorGroupModel(this, static_cast<Pokemod*>(m_object)); - m_badges = new BadgeGroupModel(this, static_cast<Pokemod*>(m_object)); - m_coinLists = new CoinListGroupModel(this, static_cast<Pokemod*>(m_object)); - m_dialogs = new DialogGroupModel(this, static_cast<Pokemod*>(m_object)); - m_eggGroups = new EggGroupGroupModel(this, static_cast<Pokemod*>(m_object)); - m_items = new ItemGroupModel(this, static_cast<Pokemod*>(m_object)); - m_itemTypes = new ItemTypeGroupModel(this, static_cast<Pokemod*>(m_object)); - 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)); - m_times = new TimeGroupModel(this, static_cast<Pokemod*>(m_object)); - m_trainers = new TrainerGroupModel(this, static_cast<Pokemod*>(m_object)); - m_types = new TypeGroupModel(this, static_cast<Pokemod*>(m_object)); -} - -void PokemodModel::clearData() -{ - delete m_rules; - delete m_abilities; - delete m_authors; - delete m_badges; - delete m_coinLists; - delete m_dialogs; - delete m_eggGroups; - delete m_items; - delete m_itemTypes; - delete m_maps; - delete m_moves; - delete m_natures; - delete m_sounds; - delete m_species; - delete m_stores; - delete m_tiles; - delete m_times; - delete m_trainers; - delete m_types; + m_objects.append(new RulesModel(this, static_cast<Pokemod*>(m_object)->rules())); + m_objects.append(new AbilityGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new AuthorGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new BadgeGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new CoinListGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new DialogGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new EggGroupGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new ItemGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new ItemTypeGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new MapGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new MoveGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new NatureGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new SoundGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new SpeciesGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new StoreGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new TileGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new TimeGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new TrainerGroupModel(this, static_cast<Pokemod*>(m_object))); + m_objects.append(new TypeGroupModel(this, static_cast<Pokemod*>(m_object))); } diff --git a/pokemodr/models/PokemodModel.h b/pokemodr/models/PokemodModel.h index 5b69f5c0..3760b4f3 100644 --- a/pokemodr/models/PokemodModel.h +++ b/pokemodr/models/PokemodModel.h @@ -19,282 +19,11 @@ #define __POKEMODR_POKEMODMODEL__ // Model includes -#include "BaseModel.h" -#include "RulesModel.h" +#include "GroupObjectModel.h" // Forward declarations class Pokemod; -class AbilityGroupModel : public GroupModel -{ - public: - AbilityGroupModel(BaseModel* parent, Pokemod* pokemod); - ~AbilityGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class AuthorGroupModel : public GroupModel -{ - public: - AuthorGroupModel(BaseModel* parent, Pokemod* pokemod); - ~AuthorGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class BadgeGroupModel : public GroupModel -{ - public: - BadgeGroupModel(BaseModel* parent, Pokemod* pokemod); - ~BadgeGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class CoinListGroupModel : public GroupModel -{ - public: - CoinListGroupModel(BaseModel* parent, Pokemod* pokemod); - ~CoinListGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class DialogGroupModel : public GroupModel -{ - public: - DialogGroupModel(BaseModel* parent, Pokemod* pokemod); - ~DialogGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class EggGroupGroupModel : public GroupModel -{ - public: - EggGroupGroupModel(BaseModel* parent, Pokemod* pokemod); - ~EggGroupGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class ItemGroupModel : public GroupModel -{ - public: - ItemGroupModel(BaseModel* parent, Pokemod* pokemod); - ~ItemGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class ItemTypeGroupModel : public GroupModel -{ - public: - ItemTypeGroupModel(BaseModel* parent, Pokemod* pokemod); - ~ItemTypeGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class MapGroupModel : public GroupModel -{ - public: - MapGroupModel(BaseModel* parent, Pokemod* pokemod); - ~MapGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class MoveGroupModel : public GroupModel -{ - public: - MoveGroupModel(BaseModel* parent, Pokemod* pokemod); - ~MoveGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class NatureGroupModel : public GroupModel -{ - public: - NatureGroupModel(BaseModel* parent, Pokemod* pokemod); - ~NatureGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class SoundGroupModel : public GroupModel -{ - public: - SoundGroupModel(BaseModel* parent, Pokemod* pokemod); - ~SoundGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class SpeciesGroupModel : public GroupModel -{ - public: - SpeciesGroupModel(BaseModel* parent, Pokemod* pokemod); - ~SpeciesGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class StoreGroupModel : public GroupModel -{ - public: - StoreGroupModel(BaseModel* parent, Pokemod* pokemod); - ~StoreGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class TileGroupModel : public GroupModel -{ - public: - TileGroupModel(BaseModel* parent, Pokemod* pokemod); - ~TileGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class TimeGroupModel : public GroupModel -{ - public: - TimeGroupModel(BaseModel* parent, Pokemod* pokemod); - ~TimeGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class TrainerGroupModel : public GroupModel -{ - public: - TrainerGroupModel(BaseModel* parent, Pokemod* pokemod); - ~TrainerGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class TypeGroupModel : public GroupModel -{ - public: - TypeGroupModel(BaseModel* parent, Pokemod* pokemod); - ~TypeGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - class PokemodModel : public GroupObjectModel { public: @@ -302,39 +31,14 @@ class PokemodModel : public GroupObjectModel ~PokemodModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int /*rows*/); bool removeRows(const int /*position*/, const int /*rows*/); protected: void setupData(); - void clearData(); - private: - RulesModel* m_rules; - AbilityGroupModel* m_abilities; - AuthorGroupModel* m_authors; - BadgeGroupModel* m_badges; - CoinListGroupModel* m_coinLists; - DialogGroupModel* m_dialogs; - EggGroupGroupModel* m_eggGroups; - ItemGroupModel* m_items; - ItemTypeGroupModel* m_itemTypes; - MapGroupModel* m_maps; - MoveGroupModel* m_moves; - NatureGroupModel* m_natures; - SoundGroupModel* m_sounds; - SpeciesGroupModel* m_species; - StoreGroupModel* m_stores; - TileGroupModel* m_tiles; - TimeGroupModel* m_times; - TrainerGroupModel* m_trainers; - TypeGroupModel* m_types; }; #endif diff --git a/pokemodr/models/RootModel.cpp b/pokemodr/models/RootModel.cpp index 4817ea04..7f9616e7 100644 --- a/pokemodr/models/RootModel.cpp +++ b/pokemodr/models/RootModel.cpp @@ -37,11 +37,6 @@ RootModel::~RootModel() { } -int RootModel::indexNumber() const -{ - return -1; -} - bool RootModel::insertRows(const int rows) { for (int i = 0; i < rows; ++i) diff --git a/pokemodr/models/RootModel.h b/pokemodr/models/RootModel.h index edf1def0..f5539b78 100644 --- a/pokemodr/models/RootModel.h +++ b/pokemodr/models/RootModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_ROOTMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupModel.h" #include "PokemodModel.h" class PokemodModel; @@ -30,8 +30,6 @@ class RootModel : public GroupModel RootModel(const QList<QVariant>& pokemods); ~RootModel(); - int indexNumber() const; - bool insertRows(const int rows); bool removeRows(const int position, const int rows); diff --git a/pokemodr/models/RulesModel.cpp b/pokemodr/models/RulesModel.cpp index 35b40f06..777fa6e7 100644 --- a/pokemodr/models/RulesModel.cpp +++ b/pokemodr/models/RulesModel.cpp @@ -75,8 +75,3 @@ bool RulesModel::setData(const QVariant& value, int role) } return false; } - -int RulesModel::indexNumber() const -{ - return 0; -} diff --git a/pokemodr/models/RulesModel.h b/pokemodr/models/RulesModel.h index 1090d713..8b94cb05 100644 --- a/pokemodr/models/RulesModel.h +++ b/pokemodr/models/RulesModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_RULESMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Rules; @@ -33,8 +33,6 @@ class RulesModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/SoundGroupModel.cpp b/pokemodr/models/SoundGroupModel.cpp new file mode 100644 index 00000000..6cafc742 --- /dev/null +++ b/pokemodr/models/SoundGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SoundGroupModel.h" + +// Model includes +#include "SoundModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +SoundGroupModel::SoundGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Sounds") +{ + setupData(); +} + +SoundGroupModel::~SoundGroupModel() +{ +} + +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))); +} diff --git a/pokemodr/models/SoundGroupModel.h b/pokemodr/models/SoundGroupModel.h new file mode 100644 index 00000000..0b97c31a --- /dev/null +++ b/pokemodr/models/SoundGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_SOUNDGROUPMODEL__ +#define __POKEMODR_SOUNDGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class SoundGroupModel : public GroupModel +{ + public: + SoundGroupModel(BaseModel* parent, Pokemod* pokemod); + ~SoundGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/SoundModel.cpp b/pokemodr/models/SoundModel.cpp index 00d5c0ae..739ac34c 100644 --- a/pokemodr/models/SoundModel.cpp +++ b/pokemodr/models/SoundModel.cpp @@ -76,8 +76,3 @@ bool SoundModel::setData(const QVariant& value, int role) } return false; } - -int SoundModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->natureIndex(m_object->id()); -} diff --git a/pokemodr/models/SoundModel.h b/pokemodr/models/SoundModel.h index 5a33236e..690cc1c1 100644 --- a/pokemodr/models/SoundModel.h +++ b/pokemodr/models/SoundModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_SOUNDMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Sound; @@ -33,8 +33,6 @@ class SoundModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/SpeciesAbilityGroupModel.cpp b/pokemodr/models/SpeciesAbilityGroupModel.cpp new file mode 100644 index 00000000..d6341c52 --- /dev/null +++ b/pokemodr/models/SpeciesAbilityGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesAbilityGroupModel.h" + +// Model includes +#include "SpeciesAbilityModel.h" + +// Pokemod includes +#include "../../pokemod/Species.h" + +SpeciesAbilityGroupModel::SpeciesAbilityGroupModel(BaseModel* parent, Species* species) : + GroupModel(parent, species, "Abilities") +{ + setupData(); +} + +SpeciesAbilityGroupModel::~SpeciesAbilityGroupModel() +{ +} + +bool SpeciesAbilityGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new SpeciesAbilityModel(this, static_cast<Species*>(m_object)->newAbility())); + return true; +} + +bool SpeciesAbilityGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Species*>(m_object)->deleteAbility(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void SpeciesAbilityGroupModel::setupData() +{ + Species* species = static_cast<Species*>(m_object); + for (int i = 0; i < species->abilityCount(); ++i) + m_objects.append(new SpeciesAbilityModel(this, species->ability(i))); +} diff --git a/pokemodr/models/SpeciesAbilityGroupModel.h b/pokemodr/models/SpeciesAbilityGroupModel.h new file mode 100644 index 00000000..cb3e699b --- /dev/null +++ b/pokemodr/models/SpeciesAbilityGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_SPECIESABILITYGROUPMODEL__ +#define __POKEMODR_SPECIESABILITYGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Species; + +class SpeciesAbilityGroupModel : public GroupModel +{ + public: + SpeciesAbilityGroupModel(BaseModel* parent, Species* species); + ~SpeciesAbilityGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/SpeciesAbilityModel.cpp b/pokemodr/models/SpeciesAbilityModel.cpp index 11f63463..5ecd2212 100644 --- a/pokemodr/models/SpeciesAbilityModel.cpp +++ b/pokemodr/models/SpeciesAbilityModel.cpp @@ -82,8 +82,3 @@ bool SpeciesAbilityModel::setData(const QVariant& value, int role) } return false; } - -int SpeciesAbilityModel::indexNumber() const -{ - return static_cast<const Species*>(m_object->parent())->abilityIndex(m_object->id()); -} diff --git a/pokemodr/models/SpeciesAbilityModel.h b/pokemodr/models/SpeciesAbilityModel.h index 87a914a1..8974e2f8 100644 --- a/pokemodr/models/SpeciesAbilityModel.h +++ b/pokemodr/models/SpeciesAbilityModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_SPECIESABILITYMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class SpeciesAbility; @@ -33,8 +33,6 @@ class SpeciesAbilityModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/SpeciesEvolutionGroupModel.cpp b/pokemodr/models/SpeciesEvolutionGroupModel.cpp new file mode 100644 index 00000000..f129891d --- /dev/null +++ b/pokemodr/models/SpeciesEvolutionGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesEvolutionGroupModel.h" + +// Model includes +#include "SpeciesEvolutionModel.h" + +// Pokemod includes +#include "../../pokemod/Species.h" + +SpeciesEvolutionGroupModel::SpeciesEvolutionGroupModel(BaseModel* parent, Species* species) : + GroupModel(parent, species, "Evolutions") +{ + setupData(); +} + +SpeciesEvolutionGroupModel::~SpeciesEvolutionGroupModel() +{ +} + +bool SpeciesEvolutionGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new SpeciesEvolutionModel(this, static_cast<Species*>(m_object)->newEvolution())); + return true; +} + +bool SpeciesEvolutionGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Species*>(m_object)->deleteEvolution(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void SpeciesEvolutionGroupModel::setupData() +{ + Species* species = static_cast<Species*>(m_object); + for (int i = 0; i < species->evolutionCount(); ++i) + m_objects.append(new SpeciesEvolutionModel(this, species->evolution(i))); +} diff --git a/pokemodr/models/SpeciesEvolutionGroupModel.h b/pokemodr/models/SpeciesEvolutionGroupModel.h new file mode 100644 index 00000000..fec293e2 --- /dev/null +++ b/pokemodr/models/SpeciesEvolutionGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_SPECIESEVOLUTIONGROUPMODEL__ +#define __POKEMODR_SPECIESEVOLUTIONGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Species; + +class SpeciesEvolutionGroupModel : public GroupModel +{ + public: + SpeciesEvolutionGroupModel(BaseModel* parent, Species* species); + ~SpeciesEvolutionGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/SpeciesEvolutionModel.cpp b/pokemodr/models/SpeciesEvolutionModel.cpp index 458f950d..a31e0d31 100644 --- a/pokemodr/models/SpeciesEvolutionModel.cpp +++ b/pokemodr/models/SpeciesEvolutionModel.cpp @@ -81,8 +81,3 @@ bool SpeciesEvolutionModel::setData(const QVariant& value, int role) } return false; } - -int SpeciesEvolutionModel::indexNumber() const -{ - return static_cast<const Species*>(m_object->parent())->evolutionIndex(m_object->id()); -} diff --git a/pokemodr/models/SpeciesEvolutionModel.h b/pokemodr/models/SpeciesEvolutionModel.h index 47b99805..ea66d402 100644 --- a/pokemodr/models/SpeciesEvolutionModel.h +++ b/pokemodr/models/SpeciesEvolutionModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_SPECIESEVOLUTIONMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class SpeciesEvolution; @@ -33,8 +33,6 @@ class SpeciesEvolutionModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/SpeciesGroupModel.cpp b/pokemodr/models/SpeciesGroupModel.cpp new file mode 100644 index 00000000..56de02c0 --- /dev/null +++ b/pokemodr/models/SpeciesGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesGroupModel.h" + +// Model includes +#include "SpeciesModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +SpeciesGroupModel::SpeciesGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Species") +{ + setupData(); +} + +SpeciesGroupModel::~SpeciesGroupModel() +{ +} + +bool SpeciesGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new SpeciesModel(this, static_cast<Pokemod*>(m_object)->newSpecies())); + return true; +} + +bool SpeciesGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteSpecies(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void SpeciesGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->speciesCount(); ++i) + m_objects.append(new SpeciesModel(this, pokemod->species(i))); +} diff --git a/pokemodr/models/SpeciesGroupModel.h b/pokemodr/models/SpeciesGroupModel.h new file mode 100644 index 00000000..c2e6e01b --- /dev/null +++ b/pokemodr/models/SpeciesGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_SPECIESGROUPMODEL__ +#define __POKEMODR_SPECIESGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class SpeciesGroupModel : public GroupModel +{ + public: + SpeciesGroupModel(BaseModel* parent, Pokemod* pokemod); + ~SpeciesGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/SpeciesItemGroupModel.cpp b/pokemodr/models/SpeciesItemGroupModel.cpp new file mode 100644 index 00000000..c6e39da9 --- /dev/null +++ b/pokemodr/models/SpeciesItemGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesItemGroupModel.h" + +// Model includes +#include "SpeciesItemModel.h" + +// Pokemod includes +#include "../../pokemod/Species.h" + +SpeciesItemGroupModel::SpeciesItemGroupModel(BaseModel* parent, Species* species) : + GroupModel(parent, species, "Items") +{ + setupData(); +} + +SpeciesItemGroupModel::~SpeciesItemGroupModel() +{ +} + +bool SpeciesItemGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new SpeciesItemModel(this, static_cast<Species*>(m_object)->newItem())); + return true; +} + +bool SpeciesItemGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Species*>(m_object)->deleteItem(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void SpeciesItemGroupModel::setupData() +{ + Species* species = static_cast<Species*>(m_object); + for (int i = 0; i < species->itemCount(); ++i) + m_objects.append(new SpeciesItemModel(this, species->item(i))); +} diff --git a/pokemodr/models/SpeciesItemGroupModel.h b/pokemodr/models/SpeciesItemGroupModel.h new file mode 100644 index 00000000..70018bc9 --- /dev/null +++ b/pokemodr/models/SpeciesItemGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_SPECIESITEMGROUPMODEL__ +#define __POKEMODR_SPECIESITEMGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Species; + +class SpeciesItemGroupModel : public GroupModel +{ + public: + SpeciesItemGroupModel(BaseModel* parent, Species* species); + ~SpeciesItemGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/SpeciesItemModel.cpp b/pokemodr/models/SpeciesItemModel.cpp index 73c6aa0c..2303d408 100644 --- a/pokemodr/models/SpeciesItemModel.cpp +++ b/pokemodr/models/SpeciesItemModel.cpp @@ -82,8 +82,3 @@ bool SpeciesItemModel::setData(const QVariant& value, int role) } return false; } - -int SpeciesItemModel::indexNumber() const -{ - return static_cast<const Species*>(m_object->parent())->itemIndex(m_object->id()); -} diff --git a/pokemodr/models/SpeciesItemModel.h b/pokemodr/models/SpeciesItemModel.h index c27b369a..f7968f4b 100644 --- a/pokemodr/models/SpeciesItemModel.h +++ b/pokemodr/models/SpeciesItemModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_SPECIESITEMMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class SpeciesItem; @@ -33,8 +33,6 @@ class SpeciesItemModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/SpeciesModel.cpp b/pokemodr/models/SpeciesModel.cpp index 07c0dbff..60463cbf 100644 --- a/pokemodr/models/SpeciesModel.cpp +++ b/pokemodr/models/SpeciesModel.cpp @@ -19,181 +19,21 @@ #include "SpeciesModel.h" // Model includes -#include "SpeciesAbilityModel.h" -#include "SpeciesEvolutionModel.h" -#include "SpeciesItemModel.h" -#include "SpeciesMoveModel.h" +#include "SpeciesAbilityGroupModel.h" +#include "SpeciesEvolutionGroupModel.h" +#include "SpeciesItemGroupModel.h" +#include "SpeciesMoveGroupModel.h" // PokeModr includes #include "../SpeciesUI.h" -// Species includes +// Pokemod includes #include "../../pokemod/Species.h" #include "../../pokemod/Pokemod.h" // Qt includes #include <QFile> -SpeciesAbilityGroupModel::SpeciesAbilityGroupModel(BaseModel* parent, Species* species) : - GroupModel(parent, species, "Abilities") -{ - setupData(); -} - -SpeciesAbilityGroupModel::~SpeciesAbilityGroupModel() -{ -} - -int SpeciesAbilityGroupModel::indexNumber() const -{ - return 0; -} - -bool SpeciesAbilityGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new SpeciesAbilityModel(this, static_cast<Species*>(m_object)->newAbility())); - return true; -} - -bool SpeciesAbilityGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Species*>(m_object)->deleteAbility(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void SpeciesAbilityGroupModel::setupData() -{ - Species* species = static_cast<Species*>(m_object); - for (int i = 0; i < species->abilityCount(); ++i) - m_objects.append(new SpeciesAbilityModel(this, species->ability(i))); -} - -SpeciesEvolutionGroupModel::SpeciesEvolutionGroupModel(BaseModel* parent, Species* species) : - GroupModel(parent, species, "Evolutions") -{ - setupData(); -} - -SpeciesEvolutionGroupModel::~SpeciesEvolutionGroupModel() -{ -} - -int SpeciesEvolutionGroupModel::indexNumber() const -{ - return 1; -} - -bool SpeciesEvolutionGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new SpeciesEvolutionModel(this, static_cast<Species*>(m_object)->newEvolution())); - return true; -} - -bool SpeciesEvolutionGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Species*>(m_object)->deleteEvolution(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void SpeciesEvolutionGroupModel::setupData() -{ - Species* species = static_cast<Species*>(m_object); - for (int i = 0; i < species->evolutionCount(); ++i) - m_objects.append(new SpeciesEvolutionModel(this, species->evolution(i))); -} - -SpeciesItemGroupModel::SpeciesItemGroupModel(BaseModel* parent, Species* species) : - GroupModel(parent, species, "Items") -{ - setupData(); -} - -SpeciesItemGroupModel::~SpeciesItemGroupModel() -{ -} - -int SpeciesItemGroupModel::indexNumber() const -{ - return 2; -} - -bool SpeciesItemGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new SpeciesItemModel(this, static_cast<Species*>(m_object)->newItem())); - return true; -} - -bool SpeciesItemGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Species*>(m_object)->deleteItem(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void SpeciesItemGroupModel::setupData() -{ - Species* species = static_cast<Species*>(m_object); - for (int i = 0; i < species->itemCount(); ++i) - m_objects.append(new SpeciesItemModel(this, species->item(i))); -} - -SpeciesMoveGroupModel::SpeciesMoveGroupModel(BaseModel* parent, Species* species) : - GroupModel(parent, species, "Moves") -{ - setupData(); -} - -SpeciesMoveGroupModel::~SpeciesMoveGroupModel() -{ -} - -int SpeciesMoveGroupModel::indexNumber() const -{ - return 3; -} - -bool SpeciesMoveGroupModel::insertRows(const int rows) -{ - for (int i = 0; i < rows; ++i) - m_objects.append(new SpeciesMoveModel(this, static_cast<Species*>(m_object)->newMove())); - return true; -} - -bool SpeciesMoveGroupModel::removeRows(const int position, const int rows) -{ - for (int i = 0; i < rows; ++i) - { - static_cast<Species*>(m_object)->deleteMove(position); - delete m_objects[position]; - m_objects.removeAt(position); - } - return true; -} - -void SpeciesMoveGroupModel::setupData() -{ - Species* species = static_cast<Species*>(m_object); - for (int i = 0; i < species->moveCount(); ++i) - m_objects.append(new SpeciesMoveModel(this, species->move(i))); -} - SpeciesModel::SpeciesModel(BaseModel* parent, Species* species) : GroupObjectModel(parent, species) { @@ -223,11 +63,6 @@ QVariant SpeciesModel::data(int role) const return GroupObjectModel::data(role); } -int SpeciesModel::rowCount() const -{ - return 4; -} - bool SpeciesModel::setData(const QVariant& value, int role) { if (role == BaseModel::XmlRole) @@ -252,35 +87,6 @@ bool SpeciesModel::setData(const QVariant& value, int role) return false; } -BaseModel* SpeciesModel::childItem(const int row) -{ - BaseModel* model; - switch (row) - { - case 0: - model = m_abilities; - break; - case 1: - model = m_evolutions; - break; - case 2: - model = m_items; - break; - case 3: - model = m_moves; - break; - default: - model = NULL; - break; - } - return model; -} - -int SpeciesModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->speciesIndex(m_object->id()); -} - bool SpeciesModel::insertRows(const int /*rows*/) { return false; @@ -293,16 +99,8 @@ bool SpeciesModel::removeRows(const int /*position*/, const int /*rows*/) void SpeciesModel::setupData() { - m_abilities = new SpeciesAbilityGroupModel(this, static_cast<Species*>(m_object)); - m_evolutions = new SpeciesEvolutionGroupModel(this, static_cast<Species*>(m_object)); - m_items = new SpeciesItemGroupModel(this, static_cast<Species*>(m_object)); - m_moves = new SpeciesMoveGroupModel(this, static_cast<Species*>(m_object)); -} - -void SpeciesModel::clearData() -{ - delete m_abilities; - delete m_evolutions; - delete m_items; - delete m_moves; + m_objects.append(new SpeciesAbilityGroupModel(this, static_cast<Species*>(m_object))); + m_objects.append(new SpeciesEvolutionGroupModel(this, static_cast<Species*>(m_object))); + m_objects.append(new SpeciesItemGroupModel(this, static_cast<Species*>(m_object))); + m_objects.append(new SpeciesMoveGroupModel(this, static_cast<Species*>(m_object))); } diff --git a/pokemodr/models/SpeciesModel.h b/pokemodr/models/SpeciesModel.h index daa2dca9..df904cd0 100644 --- a/pokemodr/models/SpeciesModel.h +++ b/pokemodr/models/SpeciesModel.h @@ -19,71 +19,11 @@ #define __POKEMODR_SPECIESMODEL__ // Model includes -#include "BaseModel.h" +#include "GroupObjectModel.h" // Forward declarations class Species; -class SpeciesAbilityGroupModel : public GroupModel -{ - public: - SpeciesAbilityGroupModel(BaseModel* parent, Species* species); - ~SpeciesAbilityGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class SpeciesEvolutionGroupModel : public GroupModel -{ - public: - SpeciesEvolutionGroupModel(BaseModel* parent, Species* species); - ~SpeciesEvolutionGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class SpeciesItemGroupModel : public GroupModel -{ - public: - SpeciesItemGroupModel(BaseModel* parent, Species* species); - ~SpeciesItemGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - -class SpeciesMoveGroupModel : public GroupModel -{ - public: - SpeciesMoveGroupModel(BaseModel* parent, Species* species); - ~SpeciesMoveGroupModel(); - - int indexNumber() const; - - bool insertRows(const int rows); - - bool removeRows(const int position, const int rows); - protected: - void setupData(); -}; - class SpeciesModel : public GroupObjectModel { public: @@ -91,24 +31,14 @@ class SpeciesModel : public GroupObjectModel ~SpeciesModel(); QVariant data(int role = Qt::DisplayRole) const; - int rowCount() const; bool setData(const QVariant& value, int role = Qt::EditRole); - BaseModel* childItem(const int row); - int indexNumber() const; - bool insertRows(const int /*rows*/); bool removeRows(const int /*position*/, const int /*rows*/); protected: void setupData(); - void clearData(); - private: - SpeciesAbilityGroupModel* m_abilities; - SpeciesEvolutionGroupModel* m_evolutions; - SpeciesItemGroupModel* m_items; - SpeciesMoveGroupModel* m_moves; }; #endif diff --git a/pokemodr/models/SpeciesMoveGroupModel.cpp b/pokemodr/models/SpeciesMoveGroupModel.cpp new file mode 100644 index 00000000..8c2c9482 --- /dev/null +++ b/pokemodr/models/SpeciesMoveGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesMoveGroupModel.h" + +// Model includes +#include "SpeciesMoveModel.h" + +// Pokemod includes +#include "../../pokemod/Species.h" + +SpeciesMoveGroupModel::SpeciesMoveGroupModel(BaseModel* parent, Species* species) : + GroupModel(parent, species, "Moves") +{ + setupData(); +} + +SpeciesMoveGroupModel::~SpeciesMoveGroupModel() +{ +} + +bool SpeciesMoveGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new SpeciesMoveModel(this, static_cast<Species*>(m_object)->newMove())); + return true; +} + +bool SpeciesMoveGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Species*>(m_object)->deleteMove(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void SpeciesMoveGroupModel::setupData() +{ + Species* species = static_cast<Species*>(m_object); + for (int i = 0; i < species->moveCount(); ++i) + m_objects.append(new SpeciesMoveModel(this, species->move(i))); +} diff --git a/pokemodr/models/SpeciesMoveGroupModel.h b/pokemodr/models/SpeciesMoveGroupModel.h new file mode 100644 index 00000000..2b303d30 --- /dev/null +++ b/pokemodr/models/SpeciesMoveGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_SPECIESMOVEGROUPMODEL__ +#define __POKEMODR_SPECIESMOVEGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Species; + +class SpeciesMoveGroupModel : public GroupModel +{ + public: + SpeciesMoveGroupModel(BaseModel* parent, Species* species); + ~SpeciesMoveGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/SpeciesMoveModel.cpp b/pokemodr/models/SpeciesMoveModel.cpp index 05a687c5..ac1e3bda 100644 --- a/pokemodr/models/SpeciesMoveModel.cpp +++ b/pokemodr/models/SpeciesMoveModel.cpp @@ -82,8 +82,3 @@ bool SpeciesMoveModel::setData(const QVariant& value, int role) } return false; } - -int SpeciesMoveModel::indexNumber() const -{ - return static_cast<const Species*>(m_object->parent())->moveIndex(m_object->id()); -} diff --git a/pokemodr/models/SpeciesMoveModel.h b/pokemodr/models/SpeciesMoveModel.h index a86b9436..6eccca83 100644 --- a/pokemodr/models/SpeciesMoveModel.h +++ b/pokemodr/models/SpeciesMoveModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_SPECIESMOVEMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class SpeciesMove; @@ -33,8 +33,6 @@ class SpeciesMoveModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/StoreGroupModel.cpp b/pokemodr/models/StoreGroupModel.cpp new file mode 100644 index 00000000..69d73d57 --- /dev/null +++ b/pokemodr/models/StoreGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "StoreGroupModel.h" + +// Model includes +#include "StoreModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +StoreGroupModel::StoreGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Stores") +{ + setupData(); +} + +StoreGroupModel::~StoreGroupModel() +{ +} + +bool StoreGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new StoreModel(this, static_cast<Pokemod*>(m_object)->newStore())); + return true; +} + +bool StoreGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteStore(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void StoreGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->storeCount(); ++i) + m_objects.append(new StoreModel(this, pokemod->store(i))); +} diff --git a/pokemodr/models/StoreGroupModel.h b/pokemodr/models/StoreGroupModel.h new file mode 100644 index 00000000..1eb16e21 --- /dev/null +++ b/pokemodr/models/StoreGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_STOREGROUPMODEL__ +#define __POKEMODR_STOREGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class StoreGroupModel : public GroupModel +{ + public: + StoreGroupModel(BaseModel* parent, Pokemod* pokemod); + ~StoreGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/StoreModel.cpp b/pokemodr/models/StoreModel.cpp index a11f1881..50d69b8c 100644 --- a/pokemodr/models/StoreModel.cpp +++ b/pokemodr/models/StoreModel.cpp @@ -76,8 +76,3 @@ bool StoreModel::setData(const QVariant& value, int role) } return false; } - -int StoreModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->storeIndex(m_object->id()); -} diff --git a/pokemodr/models/StoreModel.h b/pokemodr/models/StoreModel.h index 06dd05dc..a0c17beb 100644 --- a/pokemodr/models/StoreModel.h +++ b/pokemodr/models/StoreModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_STOREMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Store; @@ -33,8 +33,6 @@ class StoreModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/TileGroupModel.cpp b/pokemodr/models/TileGroupModel.cpp new file mode 100644 index 00000000..4e0fc89b --- /dev/null +++ b/pokemodr/models/TileGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TileGroupModel.h" + +// Model includes +#include "TileModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +TileGroupModel::TileGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Tiles") +{ + setupData(); +} + +TileGroupModel::~TileGroupModel() +{ +} + +bool TileGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new TileModel(this, static_cast<Pokemod*>(m_object)->newTile())); + return true; +} + +bool TileGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteTile(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void TileGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->tileCount(); ++i) + m_objects.append(new TileModel(this, pokemod->tile(i))); +} diff --git a/pokemodr/models/TileGroupModel.h b/pokemodr/models/TileGroupModel.h new file mode 100644 index 00000000..cbd88ddb --- /dev/null +++ b/pokemodr/models/TileGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_TILEGROUPMODEL__ +#define __POKEMODR_TILEGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class TileGroupModel : public GroupModel +{ + public: + TileGroupModel(BaseModel* parent, Pokemod* pokemod); + ~TileGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/TileModel.cpp b/pokemodr/models/TileModel.cpp index 1add6ae1..e48d27ae 100644 --- a/pokemodr/models/TileModel.cpp +++ b/pokemodr/models/TileModel.cpp @@ -76,8 +76,3 @@ bool TileModel::setData(const QVariant& value, int role) } return false; } - -int TileModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->tileIndex(m_object->id()); -} diff --git a/pokemodr/models/TileModel.h b/pokemodr/models/TileModel.h index b7c92920..4f6ac412 100644 --- a/pokemodr/models/TileModel.h +++ b/pokemodr/models/TileModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_TILEMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Tile; @@ -33,8 +33,6 @@ class TileModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/TimeGroupModel.cpp b/pokemodr/models/TimeGroupModel.cpp new file mode 100644 index 00000000..358d4abe --- /dev/null +++ b/pokemodr/models/TimeGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TimeGroupModel.h" + +// Model includes +#include "TimeModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +TimeGroupModel::TimeGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Times") +{ + setupData(); +} + +TimeGroupModel::~TimeGroupModel() +{ +} + +bool TimeGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new TimeModel(this, static_cast<Pokemod*>(m_object)->newTime())); + return true; +} + +bool TimeGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteTime(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void TimeGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->timeCount(); ++i) + m_objects.append(new TimeModel(this, pokemod->time(i))); +} diff --git a/pokemodr/models/TimeGroupModel.h b/pokemodr/models/TimeGroupModel.h new file mode 100644 index 00000000..deb5fa2e --- /dev/null +++ b/pokemodr/models/TimeGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_TIMEGROUPMODEL__ +#define __POKEMODR_TIMEGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class TimeGroupModel : public GroupModel +{ + public: + TimeGroupModel(BaseModel* parent, Pokemod* pokemod); + ~TimeGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/TimeModel.cpp b/pokemodr/models/TimeModel.cpp index 58146af7..372a90d3 100644 --- a/pokemodr/models/TimeModel.cpp +++ b/pokemodr/models/TimeModel.cpp @@ -76,8 +76,3 @@ bool TimeModel::setData(const QVariant& value, int role) } return false; } - -int TimeModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->timeIndex(m_object->id()); -} diff --git a/pokemodr/models/TimeModel.h b/pokemodr/models/TimeModel.h index b8fa24b4..3f9ba657 100644 --- a/pokemodr/models/TimeModel.h +++ b/pokemodr/models/TimeModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_TIMEMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Time; @@ -33,8 +33,6 @@ class TimeModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/TrainerGroupModel.cpp b/pokemodr/models/TrainerGroupModel.cpp new file mode 100644 index 00000000..5749442b --- /dev/null +++ b/pokemodr/models/TrainerGroupModel.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TrainerGroupModel.h" + +// Model includes +#include "TrainerModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +TrainerGroupModel::TrainerGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Trainers") +{ + setupData(); +} + +TrainerGroupModel::~TrainerGroupModel() +{ + setupData(); +} + +bool TrainerGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new TrainerModel(this, static_cast<Pokemod*>(m_object)->newTrainer())); + return true; +} + +bool TrainerGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteTrainer(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void TrainerGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->trainerCount(); ++i) + m_objects.append(new TrainerModel(this, pokemod->trainer(i))); +} diff --git a/pokemodr/models/TrainerGroupModel.h b/pokemodr/models/TrainerGroupModel.h new file mode 100644 index 00000000..0a777310 --- /dev/null +++ b/pokemodr/models/TrainerGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_TRAINERGROUPMODEL__ +#define __POKEMODR_TRAINERGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class TrainerGroupModel : public GroupModel +{ + public: + TrainerGroupModel(BaseModel* parent, Pokemod* pokemod); + ~TrainerGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/TrainerModel.cpp b/pokemodr/models/TrainerModel.cpp index 0fd440ec..ccc9b54c 100644 --- a/pokemodr/models/TrainerModel.cpp +++ b/pokemodr/models/TrainerModel.cpp @@ -76,8 +76,3 @@ bool TrainerModel::setData(const QVariant& value, int role) } return false; } - -int TrainerModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->trainerIndex(m_object->id()); -} diff --git a/pokemodr/models/TrainerModel.h b/pokemodr/models/TrainerModel.h index 215083b3..052bb39c 100644 --- a/pokemodr/models/TrainerModel.h +++ b/pokemodr/models/TrainerModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_TRAINERMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Trainer; @@ -33,8 +33,6 @@ class TrainerModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/models/TypeGroupModel.cpp b/pokemodr/models/TypeGroupModel.cpp new file mode 100644 index 00000000..513d86e7 --- /dev/null +++ b/pokemodr/models/TypeGroupModel.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TypeGroupModel.h" + +// Model includes +#include "TypeModel.h" + +// Pokemod includes +#include "../../pokemod/Pokemod.h" + +TypeGroupModel::TypeGroupModel(BaseModel* parent, Pokemod* pokemod) : + GroupModel(parent, pokemod, "Types") +{ + setupData(); +} + +TypeGroupModel::~TypeGroupModel() +{ +} + +bool TypeGroupModel::insertRows(const int rows) +{ + for (int i = 0; i < rows; ++i) + m_objects.append(new TypeModel(this, static_cast<Pokemod*>(m_object)->newType())); + return true; +} + +bool TypeGroupModel::removeRows(const int position, const int rows) +{ + for (int i = 0; i < rows; ++i) + { + static_cast<Pokemod*>(m_object)->deleteType(position); + delete m_objects[position]; + m_objects.removeAt(position); + } + return true; +} + +void TypeGroupModel::setupData() +{ + Pokemod* pokemod = static_cast<Pokemod*>(m_object); + for (int i = 0; i < pokemod->typeCount(); ++i) + m_objects.append(new TypeModel(this, pokemod->type(i))); +} diff --git a/pokemodr/models/TypeGroupModel.h b/pokemodr/models/TypeGroupModel.h new file mode 100644 index 00000000..4f87c718 --- /dev/null +++ b/pokemodr/models/TypeGroupModel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKEMODR_TYPEGROUPMODEL__ +#define __POKEMODR_TYPEGROUPMODEL__ + +// Model includes +#include "GroupModel.h" + +// Forward declarations +class Pokemod; + +class TypeGroupModel : public GroupModel +{ + public: + TypeGroupModel(BaseModel* parent, Pokemod* pokemod); + ~TypeGroupModel(); + + bool insertRows(const int rows); + + bool removeRows(const int position, const int rows); + protected: + void setupData(); +}; + +#endif diff --git a/pokemodr/models/TypeModel.cpp b/pokemodr/models/TypeModel.cpp index b968368d..72c07ab6 100644 --- a/pokemodr/models/TypeModel.cpp +++ b/pokemodr/models/TypeModel.cpp @@ -76,8 +76,3 @@ bool TypeModel::setData(const QVariant& value, int role) } return false; } - -int TypeModel::indexNumber() const -{ - return static_cast<const Pokemod*>(m_object->parent())->typeIndex(m_object->id()); -} diff --git a/pokemodr/models/TypeModel.h b/pokemodr/models/TypeModel.h index ca21c458..b6ebeab2 100644 --- a/pokemodr/models/TypeModel.h +++ b/pokemodr/models/TypeModel.h @@ -19,7 +19,7 @@ #define __POKEMODR_TYPEMODEL__ // Model includes -#include "BaseModel.h" +#include "ObjectModel.h" // Forward declarations class Type; @@ -33,8 +33,6 @@ class TypeModel : public ObjectModel QVariant data(int role = Qt::DisplayRole) const; bool setData(const QVariant& value, int role = Qt::EditRole); - - int indexNumber() const; }; #endif diff --git a/pokemodr/pokemodr.pro b/pokemodr/pokemodr.pro index f8eac96a..acfc2724 100644 --- a/pokemodr/pokemodr.pro +++ b/pokemodr/pokemodr.pro @@ -75,41 +75,71 @@ SOURCES += AbilityUI.cpp \ TimeUI.cpp \ TrainerUI.cpp \ TypeUI.cpp \ + models/AbilityGroupModel.cpp \ models/AbilityModel.cpp \ models/AbilityEffectModel.cpp \ + models/AuthorGroupModel.cpp \ models/AuthorModel.cpp \ + models/BadgeGroupModel.cpp \ models/BadgeModel.cpp \ models/BaseModel.cpp \ + models/BaseObjectModel.cpp \ + models/CoinListGroupModel.cpp \ models/CoinListModel.cpp \ models/CoinListObjectModel.cpp \ + models/DialogGroupModel.cpp \ models/DialogModel.cpp \ + models/EggGroupGroupModel.cpp \ models/EggGroupModel.cpp \ + models/GroupModel.cpp \ + models/GroupObjectModel.cpp \ + models/ItemGroupModel.cpp \ models/ItemModel.cpp \ models/ItemEffectModel.cpp \ + models/ItemTypeGroupModel.cpp \ models/ItemTypeModel.cpp \ + models/MapGroupModel.cpp \ models/MapModel.cpp \ + models/MapEffectGroupModel.cpp \ models/MapEffectModel.cpp \ + models/MapTrainerGroupModel.cpp \ models/MapTrainerModel.cpp \ models/MapTrainerTeamMemberModel.cpp \ + models/MapWarpGroupModel.cpp \ models/MapWarpModel.cpp \ + models/MapWildListGroupModel.cpp \ models/MapWildListModel.cpp \ models/MapWildListEncounterModel.cpp \ + models/MoveGroupModel.cpp \ models/MoveModel.cpp \ models/MoveEffectModel.cpp \ + models/NatureGroupModel.cpp \ models/NatureModel.cpp \ + models/ObjectModel.cpp \ models/PokemodModel.cpp \ models/RootModel.cpp \ models/RulesModel.cpp \ + models/SoundGroupModel.cpp \ models/SoundModel.cpp \ + models/SpeciesGroupModel.cpp \ models/SpeciesModel.cpp \ + models/SpeciesAbilityGroupModel.cpp \ models/SpeciesAbilityModel.cpp \ + models/SpeciesEvolutionGroupModel.cpp \ models/SpeciesEvolutionModel.cpp \ + models/SpeciesItemGroupModel.cpp \ models/SpeciesItemModel.cpp \ + models/SpeciesMoveGroupModel.cpp \ models/SpeciesMoveModel.cpp \ + models/StoreGroupModel.cpp \ models/StoreModel.cpp \ + models/TileGroupModel.cpp \ models/TileModel.cpp \ + models/TimeGroupModel.cpp \ models/TimeModel.cpp \ + models/TrainerGroupModel.cpp \ models/TrainerModel.cpp \ + models/TypeGroupModel.cpp \ models/TypeModel.cpp \ commands/CommandWidget.cpp @@ -158,41 +188,71 @@ HEADERS += AbilityUI.h \ TypechartWidgetItem.h \ TrainerUI.h \ TypeUI.h \ - models/AbilityEffectModel.h \ + models/AbilityGroupModel.h \ models/AbilityModel.h \ + models/AbilityEffectModel.h \ + models/AuthorGroupModel.h \ models/AuthorModel.h \ + models/BadgeGroupModel.h \ models/BadgeModel.h \ models/BaseModel.h \ + models/BaseObjectModel.h \ + models/CoinListGroupModel.h \ models/CoinListModel.h \ models/CoinListObjectModel.h \ + models/DialogGroupModel.h \ models/DialogModel.h \ + models/EggGroupGroupModel.h \ models/EggGroupModel.h \ + models/GroupModel.h \ + models/GroupObjectModel.h \ + models/ItemGroupModel.h \ models/ItemModel.h \ models/ItemEffectModel.h \ + models/ItemTypeGroupModel.h \ models/ItemTypeModel.h \ + models/MapGroupModel.h \ models/MapModel.h \ + models/MapEffectGroupModel.h \ models/MapEffectModel.h \ + models/MapTrainerGroupModel.h \ models/MapTrainerModel.h \ models/MapTrainerTeamMemberModel.h \ + models/MapWarpGroupModel.h \ models/MapWarpModel.h \ + models/MapWildListGroupModel.h \ models/MapWildListModel.h \ models/MapWildListEncounterModel.h \ + models/MoveGroupModel.h \ models/MoveModel.h \ models/MoveEffectModel.h \ + models/NatureGroupModel.h \ models/NatureModel.h \ + models/ObjectModel.h \ models/PokemodModel.h \ models/RootModel.h \ models/RulesModel.h \ + models/SoundGroupModel.h \ models/SoundModel.h \ + models/SpeciesGroupModel.h \ models/SpeciesModel.h \ + models/SpeciesAbilityGroupModel.h \ models/SpeciesAbilityModel.h \ + models/SpeciesEvolutionGroupModel.h \ models/SpeciesEvolutionModel.h \ + models/SpeciesItemGroupModel.h \ models/SpeciesItemModel.h \ + models/SpeciesMoveGroupModel.h \ models/SpeciesMoveModel.h \ + models/StoreGroupModel.h \ models/StoreModel.h \ + models/TileGroupModel.h \ models/TileModel.h \ + models/TimeGroupModel.h \ models/TimeModel.h \ + models/TrainerGroupModel.h \ models/TrainerModel.h \ + models/TypeGroupModel.h \ models/TypeModel.h \ commands/CommandWidget.h |