summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-02-24 09:10:35 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-02-24 09:10:35 +0000
commit09ffeef4fd962c5635cafc89df88296e9c6bfd5f (patch)
tree52598cf3ce5abebd98dff82acc2b288ec9071911
parentfc3046a7e917458e024d76fd37ec531ce7efe217 (diff)
[FIX] Macro fun with the repetitive class checking for determining class types with the tree
[FIX] KDE classes used in PokeModr UI form now [FIX] Includes in the file, only commented for ease of adding [FIX] Simpler KMessageBox used in ObjectUI [ADD] PokemodTreeItem.cpp git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@80 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog11
-rw-r--r--pokemodr/ObjectUI.h31
-rw-r--r--pokemodr/PokeModTreeItem.cpp142
-rw-r--r--pokemodr/PokeModrUI.cpp307
-rw-r--r--pokemodr/PokeModrUI.h14
-rw-r--r--pokemodr/TODO2
-rw-r--r--pokemodr/gui/pokemodr.ui30
7 files changed, 411 insertions, 126 deletions
diff --git a/Changelog b/Changelog
index 3e20848f..6865dafb 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,15 @@
-----------------
+Rev: 80
+Date: 24 February 2008
+User: MathStuf
+-----------------
+[FIX] Macro fun with the repetitive class checking for determining class types with the tree
+[FIX] KDE classes used in PokeModr UI form now
+[FIX] Includes in the file, only commented for ease of adding
+[FIX] Simpler KMessageBox used in ObjectUI
+[ADD] PokemodTreeItem.cpp
+
+-----------------
Rev: 79
Date: 23 February 2008
User: MathStuf
diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h
index 1901c1de..5ea41d76 100644
--- a/pokemodr/ObjectUI.h
+++ b/pokemodr/ObjectUI.h
@@ -23,7 +23,7 @@
#ifndef __POKEMODR_OBJECTUI__
#define __POKEMODR_OBJECTUI__
-#include <kdialog.h>
+#include <kmessagebox.h>
#include <ktoolbar.h>
#include <QCloseEvent>
@@ -32,6 +32,7 @@
#include <QWidget>
#include <Object.h>
+#include <Pokemod.h>
#define DBL_PREC 15
@@ -53,20 +54,22 @@ class ObjectUI : public QWidget
{
}
- void closeEvent (QCloseEvent* event)
+ void closeEvent(QCloseEvent* event)
{
- KDialog* dialog = new KDialog(this, Qt::Dialog);
- dialog->setModal(true);
- dialog->setCaption("My title");
- dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel);
- QLabel* label = new QLabel("You have unsaved changes, would you like to save them?", dialog);
- dialog->setMainWidget(label);
- connect(dialog, SIGNAL(yesClicked()), this, SLOT(on_buttonApply_clicked()));
- connect(dialog, SIGNAL(noClicked()), this, SLOT(on_buttonDiscard_clicked()));
- if (dialog->exec() == QDialog::Rejected)
- event->ignore();
- else
- event->accept();
+ switch (KMessageBox::questionYesNoCancel(this, "You have unsaved changes, would you like to save them?", "Unsaved PokéMod"))
+ {
+ case KMessageBox::Yes:
+ event->accept();
+ on_buttonApply_clicked();
+ break;
+ case KMessageBox::No:
+ event->accept();
+ on_buttonDiscard_clicked();
+ break;
+ case KMessageBox::Cancel:
+ event->ignore();
+ break;
+ }
}
// virtual KToolBar getToolbar(QWidget* parent) = 0;
diff --git a/pokemodr/PokeModTreeItem.cpp b/pokemodr/PokeModTreeItem.cpp
new file mode 100644
index 00000000..a3788cea
--- /dev/null
+++ b/pokemodr/PokeModTreeItem.cpp
@@ -0,0 +1,142 @@
+/////////////////////////////////////////////////////////////////////////////
+// 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 <http://www.gnu.org/licenses/>.
+/////////////////////////////////////////////////////////////////////////////
+
+#include <QString>
+
+#include <Ability.h>
+#include <AbilityEffect.h>
+#include <Author.h>
+#include <Badge.h>
+#include <CoinList.h>
+#include <CoinListObject.h>
+#include <Dialog.h>
+#include <EggGroup.h>
+#include <Item.h>
+#include <ItemEffect.h>
+#include <ItemType.h>
+#include <Map.h>
+#include <MapEffect.h>
+#include <MapTrainer.h>
+#include <MapTrainerTeamMember.h>
+#include <MapWarp.h>
+#include <MapWildList.h>
+#include <MapWildListEncounter.h>
+#include <Move.h>
+#include <MoveEffect.h>
+#include <Nature.h>
+#include <Pokemod.h>
+#include <Rules.h>
+#include <Species.h>
+#include <SpeciesAbility.h>
+#include <SpeciesEvolution.h>
+#include <SpeciesItem.h>
+#include <SpeciesMove.h>
+#include <Store.h>
+#include <Tile.h>
+#include <Time.h>
+#include <Type.h>
+
+#include "PokeModTreeItem.h"
+
+void PokeModTreeItem::updateName()
+{
+ QString name(obj->getClassName());
+ QString text;
+ if (name == "Ability")
+ text = static_cast<Ability*>(obj)->getName();
+ else if (name == "AbilityEffect")
+ text = static_cast<AbilityEffect*>(obj)->getEffect();
+ else if (name == "Author")
+ text = static_cast<Author*>(obj)->getName();
+ else if (name == "Badge")
+ text = static_cast<Badge*>(obj)->getName();
+ else if (name == "CoinList")
+ text = static_cast<CoinList*>(obj)->getName();
+ else if (name == "CoinListObject")
+ {
+ const CoinListObject* o = static_cast<CoinListObject*>(obj);
+ if (o->getType() == CoinListObject::Item)
+ text = obj->getPokemod()->getItem(o->getObject())->getName();
+ else
+ text = obj->getPokemod()->getSpecies(o->getObject())->getName();
+ }
+ else if (name == "Dialog")
+ text = static_cast<Dialog*>(obj)->getDialog().mid(0, 25);
+ else if (name == "EggGroup")
+ text = static_cast<EggGroup*>(obj)->getName();
+ else if (name == "Item")
+ text = static_cast<Item*>(obj)->getName();
+ else if (name == "ItemEffect")
+ text = ItemEffect::EffectStr.at(static_cast<ItemEffect*>(obj)->getEffect());
+ else if (name == "ItemType")
+ text = static_cast< ::ItemType* >(obj)->getName();
+ else if (name == "Map")
+ text = static_cast<Map*>(obj)->getName();
+ else if (name == "MapEffect")
+ text = static_cast<MapEffect*>(obj)->getName();
+ else if (name == "MapTrainer")
+ text = static_cast<MapTrainer*>(obj)->getName();
+ else if (name == "MapTrainerTeamMember")
+ {
+ const MapTrainerTeamMember* t = static_cast<MapTrainerTeamMember*>(obj);
+ text = QString("Lv. %1 %2").arg(t->getLevel()).arg(obj->getPokemod()->getSpecies(t->getSpecies())->getName());
+ }
+ else if (name == "MapWarp")
+ text = static_cast<MapWarp*>(obj)->getName();
+ else if (name == "MapWildList")
+ text = MapWildList::ControlStr.at(static_cast<MapWildList*>(obj)->getControl());
+ else if (name == "MapWildListEncounter")
+ {
+ const MapWildListEncounter* e = static_cast<MapWildListEncounter*>(obj);
+ text = QString("Lv. %1 %2").arg(e->getLevel()).arg(obj->getPokemod()->getSpecies(e->getSpecies())->getName());
+ }
+ else if (name == "Move")
+ text = static_cast<Move*>(obj)->getName();
+ else if (name == "MoveEffect")
+ text = MoveEffect::EffectStr.at(static_cast<MoveEffect*>(obj)->getEffect());
+ else if (name == "Nature")
+ text = static_cast<Nature*>(obj)->getName();
+ else if (name == "Pokemod")
+ text = static_cast<Pokemod*>(obj)->getTitle();
+ else if (name == "Rules")
+ text = "Rules";
+ else if (name == "Species")
+ text = static_cast<Species*>(obj)->getName();
+ else if (name == "SpeciesAbility")
+ text = obj->getPokemod()->getAbility(static_cast<SpeciesAbility*>(obj)->getAbility())->getName();
+ else if (name == "SpeciesEvolution")
+ text = obj->getPokemod()->getSpecies(static_cast<SpeciesEvolution*>(obj)->getSpecies())->getName();
+ else if (name == "SpeciesItem")
+ text = obj->getPokemod()->getItem(static_cast<SpeciesItem*>(obj)->getItem())->getName();
+ else if (name == "SpeciesMove")
+ text = obj->getPokemod()->getMove(static_cast<SpeciesMove*>(obj)->getMove())->getName();
+ else if (name == "Store")
+ text = static_cast<Store*>(obj)->getName();
+ else if (name == "Tile")
+ text = static_cast<Tile*>(obj)->getName();
+ else if (name == "Time")
+ text = static_cast<Time*>(obj)->getName();
+ else if (name == "Type")
+ text = static_cast< ::Type* >(obj)->getName();
+ setText(0, text);
+}
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index a8490551..4159d4e4 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -23,8 +23,11 @@
#include <klocalizedstring.h>
#include <kmenu.h>
#include <kmenubar.h>
+#include <kmessagebox.h>
+#include <QListIterator>
#include <QMetaObject>
+#include <QMutableListIterator>
#include <BugCatcher.h>
#include <Exception.h>
@@ -33,19 +36,25 @@
#include "PokeModTreeItem.h"
#include "AbilityUI.h"
+// #include "AbilityEffectUI.h"
#include "AuthorUI.h"
#include "BadgeUI.h"
#include "CoinListUI.h"
#include "CoinListObjectUI.h"
+// #include "DialogUI.h"
#include "EggGroupUI.h"
#include "ItemUI.h"
+// #include "ItemEffectUI.h"
#include "ItemTypeUI.h"
#include "MapUI.h"
+// #include "MapEffectUI.h"
+// #include "MapTrainerUI.h"
#include "MapTrainerTeamMemberUI.h"
#include "MapWarpUI.h"
#include "MapWildListUI.h"
#include "MapWildListEncounterUI.h"
#include "MoveUI.h"
+// #include "MoveEffectUI.h"
#include "NatureUI.h"
#include "PokemodUI.h"
#include "RulesUI.h"
@@ -69,50 +78,78 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent)
recent.loadEntries(history);
menuBar()->addMenu(customHelpMenu(false));
restoreWindowSize(cfg);
- cfg.readEntry("splitterPos", 100);
-// if (cfg.readEntry("reloadOnStart", false).toBool())
-// open(recent.urls().at(0));
-
- // Testing
- pokemod = new Pokemod();
- pokemod->newTile()->setName("foo");
- pokemod->newTile()->setName("bar");
- pokemod->newTile()->setName("baz");
-// formPanel->setWidget(new PokemodUI(pokemod, formPanel));
-// formPanel->setWidget(new AbilityUI(pokemod->newAbility(), formPanel));
-// formPanel->setWidget(new AuthorUI(pokemod->newAuthor(), formPanel));
-// formPanel->setWidget(new BadgeUI(pokemod->newBadge(), formPanel));
-// formPanel->setWidget(new CoinListUI(pokemod->newCoinList(), formPanel));
-// formPanel->setWidget(new CoinListObjectUI(pokemod->newCoinList()->newItem(), formPanel));
-// formPanel->setWidget(new EggGroupUI(pokemod->newEggGroup(), formPanel));
-// formPanel->setWidget(new ItemUI(pokemod->newItem(), formPanel));
-// formPanel->setWidget(new ItemTypeUI(pokemod->newItemType(), formPanel));
- formPanel->setWidget(new MapUI(pokemod->newMap(), formPanel));
-// formPanel->setWidget(new MapWarpUI(pokemod->newMap()->newWarp(), formPanel));
-// formPanel->setWidget(new MoveUI(pokemod->newMove(), formPanel));
-// formPanel->setWidget(new NatureUI(pokemod->newNature(), formPanel));
-// formPanel->setWidget(new SpeciesUI(pokemod->newSpecies(), formPanel));
-// formPanel->setWidget(new SpeciesAbilityUI(pokemod->newSpecies()->newAbility(), formPanel));
-// formPanel->setWidget(new SpeciesEvolutionUI(pokemod->newSpecies()->newEvolution(), formPanel));
-// formPanel->setWidget(new SpeciesItemUI(pokemod->newSpecies()->newItem(), formPanel));
-// formPanel->setWidget(new SpeciesMoveUI(pokemod->newSpecies()->newMove(), formPanel));
-// formPanel->setWidget(new StoreUI(pokemod->newStore(), formPanel));
-// formPanel->setWidget(new RulesUI(pokemod->getRules(), formPanel));
-// formPanel->setWidget(new TileUI(pokemod->newTile(), formPanel));
-// formPanel->setWidget(new TimeUI(pokemod->newTime(), formPanel));
-// formPanel->setWidget(new TypeUI(pokemod->newType(), formPanel));
+ splitter->setSizes(QList<int>() << cfg.readEntry("treeWidth", 100) << cfg.readEntry("panelWidth", 100));
+ if (cfg.readEntry("reloadOnStart", false))
+ {
+ for (int i = 0; i < cfg.readEntry("openedFiles", 0); ++i)
+ openPokeMod(recent.urls().at(i));
+ }
+ rebuildTree();
}
PokeModrUI::~PokeModrUI()
{
- delete pokemod;
+ on_actionQuit_triggered();
+}
+
+void PokeModrUI::rebuildTree()
+{
+}
+
+void PokeModrUI::openPokeMod(const KUrl& path)
+{
+ if (path.isLocalFile())
+ {
+ pokemods.append(new Pokemod(path.path()));
+ rebuildTree();
+ }
+}
+
+void PokeModrUI::savePokeMod()
+{
+ if (formPanel->widget())
+ static_cast<ObjectUI*>(formPanel->widget())->getOriginal()->getPokemod()->save();
}
-void PokeModrUI::PokeModrUI::setChangedTitle(const bool c)
+void PokeModrUI::closePokeMod()
{
+ if (formPanel->widget())
+ {
+ ObjectUI* o = static_cast<ObjectUI*>(formPanel->widget());
+ const Pokemod* p = o->getOriginal()->getPokemod();
+ if (!o->close())
+ return;
+ switch (KMessageBox::questionYesNoCancel(this, "You have unsaved changes, would you like to save them?", "Unsaved PokéMod"))
+ {
+ case KMessageBox::Yes:
+ on_actionSave_triggered();
+ case KMessageBox::No:
+ break;
+ case KMessageBox::Cancel:
+ return;
+ }
+ for (QMutableListIterator<Pokemod*> i(pokemods); i.hasNext(); i.next())
+ {
+ if (i.value() == p)
+ {
+ i.remove();
+ break;
+ }
+ }
+ delete p;
+ rebuildTree();
+ }
}
-void PokeModrUI::PokeModrUI::on_actionNew_triggered()
+void PokeModrUI::setChangedTitle(const bool c)
+{
+ if (formPanel->widget())
+ setWindowTitle(QString("%1%2 - PokéModr").arg(static_cast<ObjectUI*>(formPanel->widget())->getOriginal()->getPokemod()->getTitle()).arg(c ? "" : "*"));
+ else
+ setWindowTitle("PokéModr");
+}
+
+void PokeModrUI::on_actionNew_triggered()
{
}
@@ -123,6 +160,11 @@ void PokeModrUI::on_actionOpen_triggered()
void PokeModrUI::on_actionSave_triggered()
{
+ if (formPanel->widget())
+ {
+ static_cast<ObjectUI*>(formPanel->widget())->on_buttonApply_clicked();
+ static_cast<ObjectUI*>(formPanel->widget())->getOriginal()->getPokemod()->save();
+ }
}
void PokeModrUI::on_actionSaveAs_triggered()
@@ -131,101 +173,164 @@ void PokeModrUI::on_actionSaveAs_triggered()
void PokeModrUI::on_actionSaveAll_triggered()
{
+ if (formPanel->widget())
+ static_cast<ObjectUI*>(formPanel->widget())->on_buttonApply_clicked();
+ for (QListIterator<Pokemod*> i(pokemods); i.hasNext(); )
+ i.next()->save();
}
void PokeModrUI::on_actionQuit_triggered()
{
+ while (pokemods.size())
+ closePokeMod();
+ if (clipboard)
+ delete clipboard;
}
void PokeModrUI::on_actionCopy_triggered()
{
+ if (!formPanel->widget())
+ return;
+ if (clipboard)
+ delete clipboard;
+ Object* o = static_cast<ObjectUI*>(formPanel->widget())->getOriginal();
+ QString name(o->getClassName());
+#define IF_IS_CLASS(class) if (name == "class") clipboard = new class(o->getPokemod(), *static_cast<class*>(o), o->getId())
+ IF_IS_CLASS(Ability);
+ else IF_IS_CLASS(AbilityEffect);
+ else IF_IS_CLASS(Badge);
+ else IF_IS_CLASS(CoinList);
+ else IF_IS_CLASS(CoinListObject);
+ else IF_IS_CLASS(Dialog);
+ else IF_IS_CLASS(EggGroup);
+ else IF_IS_CLASS(Item);
+ else IF_IS_CLASS(ItemEffect);
+ else IF_IS_CLASS(ItemType);
+ else IF_IS_CLASS(Map);
+ else IF_IS_CLASS(MapEffect);
+ else IF_IS_CLASS(MapTrainer);
+ else IF_IS_CLASS(MapTrainerTeamMember);
+ else IF_IS_CLASS(MapWarp);
+ else IF_IS_CLASS(MapWildList);
+ else IF_IS_CLASS(MapWildListEncounter);
+ else IF_IS_CLASS(Move);
+ else IF_IS_CLASS(MoveEffect);
+ else IF_IS_CLASS(Nature);
+ else if (name == "Pokemod") clipboard = new Pokemod(*static_cast<Pokemod*>(o));
+ else if (name == "Rules") clipboard = new Rules(o->getPokemod());
+ else IF_IS_CLASS(Species);
+ else IF_IS_CLASS(SpeciesAbility);
+ else IF_IS_CLASS(SpeciesEvolution);
+ else IF_IS_CLASS(SpeciesItem);
+ else IF_IS_CLASS(SpeciesMove);
+ else IF_IS_CLASS(Store);
+ else IF_IS_CLASS(Tile);
+ else IF_IS_CLASS(Time);
+ else IF_IS_CLASS(Type);
+#undef IF_IS_CLASS
}
void PokeModrUI::on_actionPaste_triggered()
{
+ if (!clipboard || !formPanel->widget())
+ return;
+ Object* o = static_cast<ObjectUI*>(formPanel->widget())->getOriginal();
+ if (clipboard->getClassName() != o->getClassName())
+ return;
+ QString name(clipboard->getClassName());
+#define IF_IS_CLASS(class) if (name == "class") *static_cast<class*>(static_cast<ObjectUI*>(formPanel->widget())->getOriginal()) = *static_cast<class*>(clipboard)
+ IF_IS_CLASS(Ability);
+ else IF_IS_CLASS(AbilityEffect);
+ else IF_IS_CLASS(Badge);
+ else IF_IS_CLASS(CoinList);
+ else IF_IS_CLASS(CoinListObject);
+ else IF_IS_CLASS(Dialog);
+ else IF_IS_CLASS(EggGroup);
+ else IF_IS_CLASS(Item);
+ else IF_IS_CLASS(ItemEffect);
+ else IF_IS_CLASS(ItemType);
+ else IF_IS_CLASS(Map);
+ else IF_IS_CLASS(MapEffect);
+ else IF_IS_CLASS(MapTrainer);
+ else IF_IS_CLASS(MapTrainerTeamMember);
+ else IF_IS_CLASS(MapWarp);
+ else IF_IS_CLASS(MapWildList);
+ else IF_IS_CLASS(MapWildListEncounter);
+ else IF_IS_CLASS(Move);
+ else IF_IS_CLASS(MoveEffect);
+ else IF_IS_CLASS(Nature);
+ else IF_IS_CLASS(Pokemod);
+ else IF_IS_CLASS(Rules);
+ else IF_IS_CLASS(Species);
+ else IF_IS_CLASS(SpeciesAbility);
+ else IF_IS_CLASS(SpeciesEvolution);
+ else IF_IS_CLASS(SpeciesItem);
+ else IF_IS_CLASS(SpeciesMove);
+ else IF_IS_CLASS(Store);
+ else IF_IS_CLASS(Tile);
+ else IF_IS_CLASS(Time);
+ else IF_IS_CLASS(Type);
+#undef IF_IS_CLASS
+ rebuildTree();
}
void PokeModrUI::on_actionPreferences_triggered()
{
}
-void PokeModrUI::on_splitter_splitterMoved(const int pos)
+void PokeModrUI::on_splitter_splitterMoved()
{
+ config.writeEntry("treeWidth", splitter->sizes()[0]);
+ config.writeEntry("panelWidth", splitter->sizes()[1]);
}
void PokeModrUI::on_treePokemod_itemSelectionChanged()
{
QTreeWidgetItem* cur = treePokemod->currentItem();
PokeModTreeItem* selected = static_cast<PokeModTreeItem*>(treePokemod->selectedItems()[0]);
- if (selected->getObject() || static_cast<ObjectUI*>(formPanel->widget())->close())
+ if (selected->getObject())
{
+ if (formPanel->widget())
+ {
+ if (!static_cast<ObjectUI*>(formPanel->widget())->close())
+ return;
+ }
Object* o = selected->getObject();
QString name(o->getClassName());
ObjectUI* widget = NULL;
- if (name == "Ability")
- widget = new AbilityUI(static_cast<Ability*>(o), formPanel);
-// else if (name == "AbilityEffect")
-// widget = new AbilityEffectUI(static_cast<AbilityEffect*>(o), formPanel);
- else if (name == "Author")
- widget = new AuthorUI(static_cast<Author*>(o), formPanel);
- else if (name == "Badge")
- widget = new BadgeUI(static_cast<Badge*>(o), formPanel);
- else if (name == "CoinList")
- widget = new CoinListUI(static_cast<CoinList*>(o), formPanel);
- else if (name == "CoinListObject")
- widget = new CoinListObjectUI(static_cast<CoinListObject*>(o), formPanel);
-// else if (name == "Dialog")
-// widget = new DialogUI(static_cast<Dialog*>(o), formPanel);
- else if (name == "EggGroup")
- widget = new EggGroupUI(static_cast<EggGroup*>(o), formPanel);
- else if (name == "Item")
- widget = new ItemUI(static_cast<Item*>(o), formPanel);
-// else if (name == "ItemEffect")
-// widget = new ItemEffectUI(static_cast<ItemEffect*>(o), formPanel);
- else if (name == "ItemType")
- widget = new ItemTypeUI(static_cast<ItemType*>(o), formPanel);
- else if (name == "Map")
- widget = new MapUI(static_cast<Map*>(o), formPanel);
-// else if (name == "MapEffect")
-// widget = new MapEffectUI(static_cast<MapEffect*>(o), formPanel);
-// else if (name == "MapTrainer")
-// widget = new MapTrainerUI(static_cast<MapTrainer*>(o), formPanel);
- else if (name == "MapTrainerTeamMember")
- widget = new MapTrainerTeamMemberUI(static_cast<MapTrainerTeamMember*>(o), formPanel);
- else if (name == "MapWarp")
- widget = new MapWarpUI(static_cast<MapWarp*>(o), formPanel);
- else if (name == "MapWildList")
- widget = new MapWildListUI(static_cast<MapWildList*>(o), formPanel);
- else if (name == "MapWildListEncounter")
- widget = new MapWildListEncounterUI(static_cast<MapWildListEncounter*>(o), formPanel);
- else if (name == "Move")
- widget = new MoveUI(static_cast<Move*>(o), formPanel);
-// else if (name == "MoveEffect")
-// widget = new MoveEffectUI(static_cast<MoveEffect*>(o), formPanel);
- else if (name == "Nature")
- widget = new NatureUI(static_cast<Nature*>(o), formPanel);
- else if (name == "Pokemod")
- widget = new PokemodUI(static_cast<Pokemod*>(o), formPanel);
- else if (name == "Rules")
- widget = new RulesUI(static_cast<Rules*>(o), formPanel);
- else if (name == "Species")
- widget = new SpeciesUI(static_cast<Species*>(o), formPanel);
- else if (name == "SpeciesAbility")
- widget = new SpeciesAbilityUI(static_cast<SpeciesAbility*>(o), formPanel);
- else if (name == "SpeciesEvolution")
- widget = new SpeciesEvolutionUI(static_cast<SpeciesEvolution*>(o), formPanel);
- else if (name == "SpeciesItem")
- widget = new SpeciesItemUI(static_cast<SpeciesItem*>(o), formPanel);
- else if (name == "SpeciesMove")
- widget = new SpeciesMoveUI(static_cast<SpeciesMove*>(o), formPanel);
- else if (name == "Store")
- widget = new StoreUI(static_cast<Store*>(o), formPanel);
- else if (name == "Tile")
- widget = new TileUI(static_cast<Tile*>(o), formPanel);
- else if (name == "Time")
- widget = new TimeUI(static_cast<Time*>(o), formPanel);
- else if (name == "Type")
- widget = new TypeUI(static_cast<Type*>(o), formPanel);
+#define IF_IS_CLASS(class) if (name == "class") widget = new class##UI(static_cast<class*>(o), formPanel)
+ IF_IS_CLASS(Ability);
+// else IF_IS_CLASS(AbilityEffect);
+ else IF_IS_CLASS(Badge);
+ else IF_IS_CLASS(CoinList);
+ else IF_IS_CLASS(CoinListObject);
+// else IF_IS_CLASS(Dialog);
+ else IF_IS_CLASS(EggGroup);
+ else IF_IS_CLASS(Item);
+// else IF_IS_CLASS(ItemEffect);
+ else IF_IS_CLASS(ItemType);
+ else IF_IS_CLASS(Map);
+// else IF_IS_CLASS(MapEffect);
+// else IF_IS_CLASS(MapTrainer);
+ else IF_IS_CLASS(MapTrainerTeamMember);
+ else IF_IS_CLASS(MapWarp);
+ else IF_IS_CLASS(MapWildList);
+ else IF_IS_CLASS(MapWildListEncounter);
+ else IF_IS_CLASS(Move);
+// else IF_IS_CLASS(MoveEffect);
+ else IF_IS_CLASS(Nature);
+ else IF_IS_CLASS(Pokemod);
+ else IF_IS_CLASS(Rules);
+ else IF_IS_CLASS(Species);
+ else IF_IS_CLASS(SpeciesAbility);
+ else IF_IS_CLASS(SpeciesEvolution);
+ else IF_IS_CLASS(SpeciesItem);
+ else IF_IS_CLASS(SpeciesMove);
+ else IF_IS_CLASS(Store);
+ else IF_IS_CLASS(Tile);
+ else IF_IS_CLASS(Time);
+ else IF_IS_CLASS(Type);
+#undef IF_IS_CLASS
formPanel->setWidget(widget);
connect(widget, SIGNAL(changed(bool)), selected, SLOT(updateName()));
formPanel->show();
diff --git a/pokemodr/PokeModrUI.h b/pokemodr/PokeModrUI.h
index 137c2c21..41e91e6c 100644
--- a/pokemodr/PokeModrUI.h
+++ b/pokemodr/PokeModrUI.h
@@ -26,8 +26,9 @@
#include <kconfiggroup.h>
#include <kmainwindow.h>
#include <krecentfilesaction.h>
+#include <kurl.h>
-#include <QMainWindow>
+#include <QList>
#include <QObject>
#include <QWidget>
@@ -42,6 +43,10 @@ class PokeModrUI : public KMainWindow, private Ui::formPokeModr
public:
PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent = 0);
~PokeModrUI();
+
+ void openPokeMod(const KUrl& path);
+ void savePokeMod();
+ void closePokeMod();
public slots:
void setChangedTitle(const bool c);
@@ -54,12 +59,15 @@ class PokeModrUI : public KMainWindow, private Ui::formPokeModr
void on_actionCopy_triggered();
void on_actionPaste_triggered();
void on_actionPreferences_triggered();
- void on_splitter_splitterMoved(const int pos);
+ void on_splitter_splitterMoved();
void on_treePokemod_itemSelectionChanged();
private:
+ void rebuildTree();
+
KConfigGroup config;
KRecentFilesAction recent;
- Pokemod* pokemod;
+ QList<Pokemod*> pokemods;
+ Object* clipboard;
};
#endif
diff --git a/pokemodr/TODO b/pokemodr/TODO
index b38e904f..df4ee1f2 100644
--- a/pokemodr/TODO
+++ b/pokemodr/TODO
@@ -9,5 +9,3 @@ TypeChart
Tree Handling
Toolbar loading
-Menu stuff
-Help Menu
diff --git a/pokemodr/gui/pokemodr.ui b/pokemodr/gui/pokemodr.ui
index 5ef9c1c2..4d589e24 100644
--- a/pokemodr/gui/pokemodr.ui
+++ b/pokemodr/gui/pokemodr.ui
@@ -38,7 +38,7 @@
</item>
</layout>
</widget>
- <widget class="QMenuBar" name="menubar" >
+ <widget class="KMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
@@ -47,7 +47,7 @@
<height>29</height>
</rect>
</property>
- <widget class="QMenu" name="menuFile" >
+ <widget class="KMenu" name="menuFile" >
<property name="title" >
<string>&amp;File</string>
</property>
@@ -60,7 +60,7 @@
<addaction name="separator" />
<addaction name="actionQuit" />
</widget>
- <widget class="QMenu" name="menuEdit" >
+ <widget class="KMenu" name="menuEdit" >
<property name="title" >
<string>&amp;Edit</string>
</property>
@@ -72,7 +72,7 @@
<addaction name="menuFile" />
<addaction name="menuEdit" />
</widget>
- <widget class="QToolBar" name="toolbar" >
+ <widget class="KToolBar" name="toolbar" >
<property name="windowTitle" >
<string/>
</property>
@@ -160,7 +160,7 @@
<string>Copy the current object</string>
</property>
<property name="shortcut" >
- <string>Ctrl+C</string>
+ <string>Ctrl+Shift+C</string>
</property>
</action>
<action name="actionPaste" >
@@ -171,7 +171,7 @@
<string>Paste an object</string>
</property>
<property name="shortcut" >
- <string>Ctrl+V</string>
+ <string>Ctrl+Shift+V</string>
</property>
</action>
<action name="actionPreferences" >
@@ -202,6 +202,24 @@
<header>kmainwindow.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>KMenuBar</class>
+ <extends>QMenuBar</extends>
+ <header>kmenubar.h</header>
+ <container>1</container>
+ </customwidget>
+ <customwidget>
+ <class>KMenu</class>
+ <extends>QMenu</extends>
+ <header>kmenu.h</header>
+ <container>1</container>
+ </customwidget>
+ <customwidget>
+ <class>KToolBar</class>
+ <extends>QToolBar</extends>
+ <header>ktoolbar.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>