From 6679f5cffa9d35a23b76605ddfbf3257f882b6ee Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 17 Apr 2008 23:34:36 +0000 Subject: [FIX] Frac -> Fraction [FIX] ImageCache and Ini removed [FIX] Fraction/Point widgets moved to pokemodr [FIX] Copy ctors made for pokemod classes [FIX] Ctors in pokemod fixed [FIX] Copyright headers fixed in pokemodr [FIX] PokeModr updated to new API and fixed in some places git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@99 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/PokeModTreeItem.cpp | 332 ++++++++++++++++++++++--------------------- 1 file changed, 167 insertions(+), 165 deletions(-) (limited to 'pokemodr/PokeModTreeItem.cpp') diff --git a/pokemodr/PokeModTreeItem.cpp b/pokemodr/PokeModTreeItem.cpp index 5a237f70..bfed8e1b 100644 --- a/pokemodr/PokeModTreeItem.cpp +++ b/pokemodr/PokeModTreeItem.cpp @@ -1,32 +1,29 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokegen/PokeModTreeItem.cpp -// Purpose: Subclass of QTreeWidgetItem that allows information to be -// tacked on as well -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Sat Feb 23 18:44:25 2008 -// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions -// Licence: -// 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 . -///////////////////////////////////////////////////////////////////////////// +/* + * Copyright 2008 Ben Boeckel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +// KDE includes #include #include +// Qt includes #include #include +// Pokemod includes #include #include #include @@ -61,6 +58,7 @@ #include #include +// PokeModr includes #include "AbilityUI.h" // #include "AbilityEffectUI.h" #include "AuthorUI.h" @@ -95,211 +93,215 @@ #include "TrainerUI.h" #include "TypeUI.h" +// Header include #include "PokeModTreeItem.h" +// FIXME: scrap for a better solution + +/* void PokeModTreeItem::update() { if (text(0).isEmpty()) { - QString name(obj->getClassName()); + QString name(m_object->className()); if (name == "Ability") - new PokeModTreeItem(this, obj, "Effects"); + new PokeModTreeItem(this, m_object, "Effects"); else if (name == "CoinList") - new PokeModTreeItem(this, obj, "Objects"); + new PokeModTreeItem(this, m_object, "Objects"); else if (name == "Item") - new PokeModTreeItem(this, obj, "Effects"); + new PokeModTreeItem(this, m_object, "Effects"); else if (name == "Map") { - new PokeModTreeItem(this, obj, "Effects"); - new PokeModTreeItem(this, obj, "Trainers"); - new PokeModTreeItem(this, obj, "Warps"); - new PokeModTreeItem(this, obj, "Wild Lists"); + new PokeModTreeItem(this, m_object, "Effects"); + new PokeModTreeItem(this, m_object, "Trainers"); + new PokeModTreeItem(this, m_object, "Warps"); + new PokeModTreeItem(this, m_object, "Wild Lists"); } else if (name == "MapTrainer") - new PokeModTreeItem(this, obj, "Team Members"); + new PokeModTreeItem(this, m_object, "Team Members"); else if (name == "MapWildList") - new PokeModTreeItem(this, obj, "Encounters"); + new PokeModTreeItem(this, m_object, "Encounters"); else if (name == "Move") - new PokeModTreeItem(this, obj, "Effects"); + new PokeModTreeItem(this, m_object, "Effects"); else if (name == "Pokemod") { - new PokeModTreeItem(this, static_cast(obj)->getRules()); - new PokeModTreeItem(this, obj, "Abilities"); - new PokeModTreeItem(this, obj, "Authors"); - new PokeModTreeItem(this, obj, "Badges"); - new PokeModTreeItem(this, obj, "Coin Lists"); - new PokeModTreeItem(this, obj, "Dialogs"); - new PokeModTreeItem(this, obj, "Egg Groups"); - new PokeModTreeItem(this, obj, "Items"); - new PokeModTreeItem(this, obj, "Item Types"); - new PokeModTreeItem(this, obj, "Maps"); - new PokeModTreeItem(this, obj, "Moves"); - new PokeModTreeItem(this, obj, "Natures"); - new PokeModTreeItem(this, obj, "Species"); - new PokeModTreeItem(this, obj, "Stores"); - new PokeModTreeItem(this, obj, "Tiles"); - new PokeModTreeItem(this, obj, "Times"); - new PokeModTreeItem(this, obj, "Trainers"); - new PokeModTreeItem(this, obj, "Types"); + new PokeModTreeItem(this, static_cast(m_object)->rules()); + new PokeModTreeItem(this, m_object, "Abilities"); + new PokeModTreeItem(this, m_object, "Authors"); + new PokeModTreeItem(this, m_object, "Badges"); + new PokeModTreeItem(this, m_object, "Coin Lists"); + new PokeModTreeItem(this, m_object, "Dialogs"); + new PokeModTreeItem(this, m_object, "Egg Groups"); + new PokeModTreeItem(this, m_object, "Items"); + new PokeModTreeItem(this, m_object, "Item Types"); + new PokeModTreeItem(this, m_object, "Maps"); + new PokeModTreeItem(this, m_object, "Moves"); + new PokeModTreeItem(this, m_object, "Natures"); + new PokeModTreeItem(this, m_object, "Species"); + new PokeModTreeItem(this, m_object, "Stores"); + new PokeModTreeItem(this, m_object, "Tiles"); + new PokeModTreeItem(this, m_object, "Times"); + new PokeModTreeItem(this, m_object, "Trainers"); + new PokeModTreeItem(this, m_object, "Types"); } else if (name == "Species") { - new PokeModTreeItem(this, obj, "Abilities"); - new PokeModTreeItem(this, obj, "Evolutions"); - new PokeModTreeItem(this, obj, "Items"); - new PokeModTreeItem(this, obj, "Moves"); + new PokeModTreeItem(this, m_object, "Abilities"); + new PokeModTreeItem(this, m_object, "Evolutions"); + new PokeModTreeItem(this, m_object, "Items"); + new PokeModTreeItem(this, m_object, "Moves"); } } else { - QString name(obj->getClassName()); + QString name(obj->className()); if (name == "Ability") { - Ability* a = static_cast(obj); - for (int i = 0; i < a->getEffectCount(); ++i) - new PokeModTreeItem(this, a->getEffect(i)); + Ability* ability = static_cast(m_object); + for (int i = 0; i < ability->effectCount(); ++i) + new PokeModTreeItem(this, ability->effect(i)); } else if (name == "CoinList") { - CoinList* c = static_cast(obj); - for (int i = 0; i < c->getItemCount(); ++i) - new PokeModTreeItem(this, c->getItem(i)); + CoinList* coinList = static_cast(m_object); + for (int i = 0; i < coinList->itemCount(); ++i) + new PokeModTreeItem(this, coinList->item(i)); } else if (name == "Item") { - Item* it = static_cast(obj); - for (int i = 0; i < it->getEffectCount(); ++i) - new PokeModTreeItem(this, it->getEffect(i)); + Item* item = static_cast(m_object); + for (int i = 0; i < item->effectCount(); ++i) + new PokeModTreeItem(this, item->effect(i)); } else if (name == "Map") { - Map* m = static_cast(obj); + Map* map = static_cast(m_object); if (text(0) == "Effects") { - for (int i = 0; i < m->getEffectCount(); ++i) - new PokeModTreeItem(this, m->getEffect(i)); + for (int i = 0; i < map->effectCount(); ++i) + new PokeModTreeItem(this, map->effect(i)); } else if (text(0) == "Trainers") { - for (int i = 0; i < m->getTrainerCount(); ++i) - new PokeModTreeItem(this, m->getTrainer(i)); + for (int i = 0; i < map->trainerCount(); ++i) + new PokeModTreeItem(this, map->trainer(i)); } else if (text(0) == "Warps") { - for (int i = 0; i < m->getWarpCount(); ++i) - new PokeModTreeItem(this, m->getWarp(i)); + for (int i = 0; i < m->warpCount(); ++i) + new PokeModTreeItem(this, m->warp(i)); } else if (text(0) == "Wild Lists") { - for (int i = 0; i < m->getWildListCount(); ++i) - new PokeModTreeItem(this, m->getWildList(i)); + for (int i = 0; i < m->wildListCount(); ++i) + new PokeModTreeItem(this, m->wildList(i)); } } else if (name == "MapTrainer") { MapTrainer* t = static_cast(obj); - for (int i = 0; i < t->getTeamMemberCount(); ++i) - new PokeModTreeItem(this, t->getTeamMember(i)); + for (int i = 0; i < t->teamMemberCount(); ++i) + new PokeModTreeItem(this, t->teamMember(i)); } else if (name == "MapWildList") { MapWildList* w = static_cast(obj); - for (int i = 0; i < w->getEncounterCount(); ++i) - new PokeModTreeItem(this, w->getEncounter(i)); + for (int i = 0; i < w->encounterCount(); ++i) + new PokeModTreeItem(this, w->encounter(i)); } else if (name == "Move") { Move* m = static_cast(obj); - for (int i = 0; i < m->getEffectCount(); ++i) - new PokeModTreeItem(this, m->getEffect(i)); + for (int i = 0; i < m->effectCount(); ++i) + new PokeModTreeItem(this, m->effect(i)); } else if (name == "Pokemod") { Pokemod* p = static_cast(obj); if (text(0) == "Abilities") { - for (int i = 0; i < p->getAbilityCount(); ++i) - new PokeModTreeItem(this, p->getAbility(i)); + for (int i = 0; i < p->abilityCount(); ++i) + new PokeModTreeItem(this, p->ability(i)); } else if (text(0) == "Authors") { - for (int i = 0; i < p->getAuthorCount(); ++i) - new PokeModTreeItem(this, p->getAuthor(i)); + for (int i = 0; i < p->authorCount(); ++i) + new PokeModTreeItem(this, p->author(i)); } else if (text(0) == "Badges") { - for (int i = 0; i < p->getBadgeCount(); ++i) - new PokeModTreeItem(this, p->getBadge(i)); + for (int i = 0; i < p->badgeCount(); ++i) + new PokeModTreeItem(this, p->badge(i)); } else if (text(0) == "Coin Lists") { - for (int i = 0; i < p->getCoinListCount(); ++i) - new PokeModTreeItem(this, p->getCoinList(i)); + for (int i = 0; i < p->coinListCount(); ++i) + new PokeModTreeItem(this, p->coinList(i)); } else if (text(0) == "Dialogs") { - for (int i = 0; i < p->getDialogCount(); ++i) - new PokeModTreeItem(this, p->getDialog(i)); + for (int i = 0; i < p->dialogCount(); ++i) + new PokeModTreeItem(this, p->dialog(i)); } else if (text(0) == "Egg Groups") { - for (int i = 0; i < p->getEggGroupCount(); ++i) - new PokeModTreeItem(this, p->getEggGroup(i)); + for (int i = 0; i < p->eggGroupCount(); ++i) + new PokeModTreeItem(this, p->eggGroup(i)); } else if (text(0) == "Items") { - for (int i = 0; i < p->getItemCount(); ++i) - new PokeModTreeItem(this, p->getItem(i)); + for (int i = 0; i < p->itemCount(); ++i) + new PokeModTreeItem(this, p->item(i)); } else if (text(0) == "Item Types") { - for (int i = 0; i < p->getItemTypeCount(); ++i) - new PokeModTreeItem(this, p->getItemType(i)); + for (int i = 0; i < p->itemTypeCount(); ++i) + new PokeModTreeItem(this, p->itemType(i)); } else if (text(0) == "Maps") { - for (int i = 0; i < p->getMapCount(); ++i) - new PokeModTreeItem(this, p->getMap(i)); + for (int i = 0; i < p->mapCount(); ++i) + new PokeModTreeItem(this, p->map(i)); } else if (text(0) == "Moves") { - for (int i = 0; i < p->getMoveCount(); ++i) - new PokeModTreeItem(this, p->getMove(i)); + for (int i = 0; i < p->moveCount(); ++i) + new PokeModTreeItem(this, p->move(i)); } else if (text(0) == "Natures") { - for (int i = 0; i < p->getNatureCount(); ++i) - new PokeModTreeItem(this, p->getNature(i)); + for (int i = 0; i < p->natureCount(); ++i) + new PokeModTreeItem(this, p->nature(i)); } else if (text(0) == "Species") { - for (int i = 0; i < p->getSpeciesCount(); ++i) - new PokeModTreeItem(this, p->getSpecies(i)); + for (int i = 0; i < p->speciesCount(); ++i) + new PokeModTreeItem(this, p->species(i)); } else if (text(0) == "Stores") { - for (int i = 0; i < p->getStoreCount(); ++i) - new PokeModTreeItem(this, p->getStore(i)); + for (int i = 0; i < p->storeCount(); ++i) + new PokeModTreeItem(this, p->store(i)); } else if (text(0) == "Tiles") { - for (int i = 0; i < p->getTileCount(); ++i) - new PokeModTreeItem(this, p->getTile(i)); + for (int i = 0; i < p->tileCount(); ++i) + new PokeModTreeItem(this, p->tile(i)); } else if (text(0) == "Times") { - for (int i = 0; i < p->getTimeCount(); ++i) - new PokeModTreeItem(this, p->getTime(i)); + for (int i = 0; i < p->timeCount(); ++i) + new PokeModTreeItem(this, p->time(i)); } else if (text(0) == "Trainers") { - for (int i = 0; i < p->getTrainerCount(); ++i) - new PokeModTreeItem(this, p->getTrainer(i)); + for (int i = 0; i < p->trainerCount(); ++i) + new PokeModTreeItem(this, p->trainer(i)); } else if (text(0) == "Types") { - for (int i = 0; i < p->getTypeCount(); ++i) - new PokeModTreeItem(this, p->getType(i)); + for (int i = 0; i < p->typeCount(); ++i) + new PokeModTreeItem(this, p->type(i)); } } else if (name == "Species") @@ -307,23 +309,23 @@ void PokeModTreeItem::update() Species* s = static_cast(obj); if (text(0) == "Abilities") { - for (int i = 0; i < s->getAbilityCount(); ++i) - new PokeModTreeItem(this, s->getAbility(i)); + for (int i = 0; i < s->abilityCount(); ++i) + new PokeModTreeItem(this, s->ability(i)); } else if (text(0) == "Evolutions") { - for (int i = 0; i < s->getEvolutionCount(); ++i) - new PokeModTreeItem(this, s->getEvolution(i)); + for (int i = 0; i < s->evolutionCount(); ++i) + new PokeModTreeItem(this, s->evolution(i)); } else if (text(0) == "Items") { - for (int i = 0; i < s->getItemCount(); ++i) - new PokeModTreeItem(this, s->getItem(i)); + for (int i = 0; i < s->itemCount(); ++i) + new PokeModTreeItem(this, s->item(i)); } else if (text(0) == "Moves") { - for (int i = 0; i < s->getMoveCount(); ++i) - new PokeModTreeItem(this, s->getMove(i)); + for (int i = 0; i < s->moveCount(); ++i) + new PokeModTreeItem(this, s->move(i)); } } obj = NULL; @@ -337,7 +339,7 @@ void PokeModTreeItem::init(QWidget* pnt) setChildIndicatorPolicy(QTreeWidgetItem::QTreeWidgetItem::DontShowIndicatorWhenChildless); if (obj) { - QString name(obj->getClassName()); + QString name(obj->className()); #define IF_IS_CLASS(class) if (name == #class) ui = new class##UI(static_cast< ::class* >(obj), pnt); IF_IS_CLASS(Ability) // else IF_IS_CLASS(AbilityEffect) @@ -383,86 +385,86 @@ void PokeModTreeItem::updateName() { if (!obj) return; - QString name(obj->getClassName()); + QString name(obj->className()); QString text; if (name == "Ability") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "AbilityEffect") - text = AbilityEffect::EffectStr.at(static_cast(obj)->getEffect()); + text = AbilityEffect::EffectStr.at(static_cast(obj)->effect()); else if (name == "Author") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "Badge") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "CoinList") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "CoinListObject") { const CoinListObject* o = static_cast(obj); - if (o->getType() == CoinListObject::Item) - text = obj->getPokemod()->getItem(o->getObject())->getName(); + if (o->type() == CoinListObject::Item) + text = obj->pokemod()->item(o->object())->name(); else - text = obj->getPokemod()->getSpecies(o->getObject())->getName(); + text = obj->pokemod()->species(o->object())->name(); } else if (name == "Dialog") - text = static_cast(obj)->getDialog().mid(0, 25); + text = static_cast(obj)->dialog().mid(0, 25); else if (name == "EggGroup") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "Item") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "ItemEffect") - text = ItemEffect::EffectStr.at(static_cast(obj)->getEffect()); + text = ItemEffect::EffectStr.at(static_cast(obj)->effect()); else if (name == "ItemType") - text = static_cast< ::ItemType* >(obj)->getName(); + text = static_cast< ::ItemType* >(obj)->name(); else if (name == "Map") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "MapEffect") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "MapTrainer") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "MapTrainerTeamMember") { const MapTrainerTeamMember* t = static_cast(obj); - text = QString("Lv. %1 %2").arg(t->getLevel()).arg(obj->getPokemod()->getSpecies(t->getSpecies())->getName()); + text = QString("Lv. %1 %2").arg(t->level()).arg(obj->pokemod()->species(t->species())->name()); } else if (name == "MapWarp") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "MapWildList") - text = MapWildList::ControlStr.at(static_cast(obj)->getControl()); + text = MapWildList::ControlStr.at(static_cast(obj)->control()); else if (name == "MapWildListEncounter") { const MapWildListEncounter* e = static_cast(obj); - text = QString("Lv. %1 %2").arg(e->getLevel()).arg(obj->getPokemod()->getSpecies(e->getSpecies())->getName()); + text = QString("Lv. %1 %2").arg(e->level()).arg(obj->pokemod()->species(e->species())->name()); } else if (name == "Move") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "MoveEffect") - text = MoveEffect::EffectStr.at(static_cast(obj)->getEffect()); + text = MoveEffect::EffectStr.at(static_cast(obj)->effect()); else if (name == "Nature") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "Pokemod") - text = static_cast(obj)->getTitle(); + text = static_cast(obj)->title(); else if (name == "Rules") text = "Rules"; else if (name == "Species") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "SpeciesAbility") - text = obj->getPokemod()->getAbility(static_cast(obj)->getAbility())->getName(); + text = obj->pokemod()->ability(static_cast(obj)->ability())->name(); else if (name == "SpeciesEvolution") - text = obj->getPokemod()->getSpecies(static_cast(obj)->getSpecies())->getName(); + text = obj->pokemod()->species(static_cast(obj)->species())->name(); else if (name == "SpeciesItem") - text = obj->getPokemod()->getItem(static_cast(obj)->getItem())->getName(); + text = obj->pokemod()->item(static_cast(obj)->item())->name(); else if (name == "SpeciesMove") - text = obj->getPokemod()->getMove(static_cast(obj)->getMove())->getName(); + text = obj->pokemod()->move(static_cast(obj)->move())->name(); else if (name == "Store") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "Tile") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "Time") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "Trainer") - text = static_cast(obj)->getName(); + text = static_cast(obj)->name(); else if (name == "Type") - text = static_cast< ::Type* >(obj)->getName(); + text = static_cast< ::Type* >(obj)->name(); setText(0, text); } @@ -474,8 +476,8 @@ Object* PokeModTreeItem::copy() { if (obj) { - QString name(obj->getClassName()); -#define IF_IS_CLASS(class) if (name == #class) return new ::class(obj->getPokemod(), *static_cast< ::class* >(obj), obj->getId()); + QString name(obj->className()); +#define IF_IS_CLASS(class) if (name == #class) return new ::class(obj->pokemod(), *static_cast< ::class* >(obj), obj->id()); IF_IS_CLASS(Ability) else IF_IS_CLASS(AbilityEffect) else IF_IS_CLASS(Author) @@ -498,7 +500,7 @@ Object* PokeModTreeItem::copy() else IF_IS_CLASS(MoveEffect) else IF_IS_CLASS(Nature) else if (name == "Pokemod") return new Pokemod(*static_cast(obj)); - else if (name == "Rules") return new Rules(obj->getPokemod()); + else if (name == "Rules") return new Rules(obj->pokemod()); else IF_IS_CLASS(Species) else IF_IS_CLASS(SpeciesAbility) else IF_IS_CLASS(SpeciesEvolution) @@ -519,8 +521,8 @@ Object* PokeModTreeItem::cut() // TODO: actually cut the item if (obj) { - QString name(obj->getClassName()); -#define IF_IS_CLASS(class) if (name == #class) return new ::class(obj->getPokemod(), *static_cast< ::class* >(obj), obj->getId()); + QString name(obj->className()); +#define IF_IS_CLASS(class) if (name == #class) return new ::class(obj->pokemod(), *static_cast< ::class* >(obj), obj->id()); IF_IS_CLASS(Ability) else IF_IS_CLASS(AbilityEffect) else IF_IS_CLASS(Author) @@ -543,7 +545,7 @@ Object* PokeModTreeItem::cut() else IF_IS_CLASS(MoveEffect) else IF_IS_CLASS(Nature) else if (name == "Pokemod") return new Pokemod(*static_cast(obj)); - else if (name == "Rules") return new Rules(obj->getPokemod()); + else if (name == "Rules") return new Rules(obj->pokemod()); else IF_IS_CLASS(Species) else IF_IS_CLASS(SpeciesAbility) else IF_IS_CLASS(SpeciesEvolution) @@ -557,4 +559,4 @@ Object* PokeModTreeItem::cut() #undef IF_IS_CLASS } return NULL; -} +}*/ -- cgit