diff options
Diffstat (limited to 'sigmodr/tree/SigmodModel.cpp')
-rw-r--r-- | sigmodr/tree/SigmodModel.cpp | 163 |
1 files changed, 0 insertions, 163 deletions
diff --git a/sigmodr/tree/SigmodModel.cpp b/sigmodr/tree/SigmodModel.cpp deleted file mode 100644 index 5d9b75ac..00000000 --- a/sigmodr/tree/SigmodModel.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2008-2009 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 "GameModel.h" - -// Sigmodr tree includes -#include "AbilityGroupModel.h" -#include "AuthorGroupModel.h" -#include "BadgeGroupModel.h" -#include "CoinListGroupModel.h" -#include "EggGroupGroupModel.h" -#include "GlobalScriptGroupModel.h" -#include "ItemGroupModel.h" -#include "ItemTypeGroupModel.h" -#include "MapGroupModel.h" -#include "MoveGroupModel.h" -#include "NatureGroupModel.h" -#include "RulesModel.h" -#include "SkinGroupModel.h" -#include "SoundGroupModel.h" -#include "SpeciesGroupModel.h" -#include "SpriteGroupModel.h" -#include "StatusGroupModel.h" -#include "StoreGroupModel.h" -#include "TileGroupModel.h" -#include "TimeGroupModel.h" -#include "TrainerGroupModel.h" -#include "TypeGroupModel.h" -#include "WeatherGroupModel.h" - -// Sigmodr widget includes -#include <sigmodr/widgets/GameUI.h> - -// Sigmod includes -#include <sigmod/Game.h> - -// KDE includes -#include <KMenu> - -Sigmodr::Tree::GameModel::GameModel(BaseModel* parent, Sigmod::Game* game) : - GroupObjectModel(parent, game) -{ - setupData(); -} - -Sigmodr::Tree::GameModel::~GameModel() -{ - clearData(); -} - -QVariant Sigmodr::Tree::GameModel::data(int role) const -{ - if (role == Qt::DisplayRole) - return qobject_cast<Sigmod::Game*>(m_object)->title(); - else if (role == BaseModel::XmlRole) - { - QDomDocument xml(m_object->className()); - xml.appendChild(m_object->save()); - return xml.toString(); - } - else if (role == BaseModel::WidgetRole) - { - QWidget* widget = new SigmodUI(qobject_cast<Sigmod::Game*>(m_object), NULL); - return QVariant::fromValue(widget); - } - else if (role == BaseModel::ContextMenuRole) - { - KMenu* menu = new KMenu; - return QVariant::fromValue(menu); - } - return GroupObjectModel::data(role); -} - -bool Sigmodr::Tree::GameModel::setData(const QVariant& value, int role) -{ - if (role == BaseModel::XmlRole) - { - QString data = value.toString(); - if (!data.isEmpty()) - { - QDomDocument xml; - if (loadFromData(data, &xml)) - { - if (xml.doctype().name() == m_object->className()) - { - clearData(); - m_object->load(xml.documentElement()); - setupData(); - return true; - } - foreach (BaseModel* model, m_objects) - { - GroupModel* group = qobject_cast<GroupModel*>(model); - if (group && group->setData(value, role)) - return true; - } - } - } - } - return false; -} - -QString Sigmodr::Tree::GameModel::types() const -{ - return type().append(QString(";Rules;Ability;Author;Badge;CoinList;EggGroup;GlobalScript;Item;ItemType;Map;Move;Nature;Skin;Sound;Species;Sprite;Status;Store;Tile;Time;Trainer;Type;Weather")); -} - -void Sigmodr::Tree::GameModel::addObject(Sigmod::Object* object) -{ - Q_UNUSED(object) -} - -void Sigmodr::Tree::GameModel::deleteObject(BaseModel* model) -{ - Q_UNUSED(model) -} - -void Sigmodr::Tree::GameModel::deleteSelf() -{ -} - -void Sigmodr::Tree::GameModel::setupData() -{ - Sigmod::Game* game = qobject_cast<Sigmod::Game*>(m_object); - addChild(new RulesModel(this, game->rules())); - addChild(new AbilityGroupModel(this, game)); - addChild(new AuthorGroupModel(this, game)); - addChild(new BadgeGroupModel(this, game)); - addChild(new CoinListGroupModel(this, game)); - addChild(new EggGroupGroupModel(this, game)); - addChild(new GlobalScriptGroupModel(this, game)); - addChild(new ItemGroupModel(this, game)); - addChild(new ItemTypeGroupModel(this, game)); - addChild(new MapGroupModel(this, game)); - addChild(new MoveGroupModel(this, game)); - addChild(new NatureGroupModel(this, game)); - addChild(new SkinGroupModel(this, game)); - addChild(new SoundGroupModel(this, game)); - addChild(new SpeciesGroupModel(this, game)); - addChild(new SpriteGroupModel(this, game)); - addChild(new StatusGroupModel(this, game)); - addChild(new StoreGroupModel(this, game)); - addChild(new TileGroupModel(this, game)); - addChild(new TimeGroupModel(this, game)); - addChild(new TrainerGroupModel(this, game)); - addChild(new TypeGroupModel(this, game)); - addChild(new WeatherGroupModel(this, game)); -} |