summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-24 00:32:12 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-24 00:32:12 +0000
commit8178711f67288bf43eeb80dce15eaa65a1d840f7 (patch)
tree73d12d8917c712b69701fc761a4adef9f8993e46
parent35efee2103faadc0aa7fdb42decbdba440a5fbe8 (diff)
[FIX] Old tree handling is gone
[FIX] New tree handling is started git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@104 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog8
-rw-r--r--pokemod/TODO3
-rw-r--r--pokemodr/ObjectModel.cpp20
-rw-r--r--pokemodr/ObjectModel.h487
-rw-r--r--pokemodr/PokeModTreeItem.cpp562
-rw-r--r--pokemodr/PokeModTreeItem.h110
-rw-r--r--pokemodr/PokeModrUI.cpp146
-rw-r--r--pokemodr/PokeModrUI.h4
-rw-r--r--pokemodr/TODO4
-rw-r--r--pokemodr/TilemapModel.cpp3
-rw-r--r--pokemodr/TilemapModel.h4
-rw-r--r--pokemodr/TrainerUI.h2
-rw-r--r--pokemodr/TypechartWidgetItem.h10
-rw-r--r--pokemodr/gui/pokemodr.ui7
-rw-r--r--pokemodr/pokemodr.pro4
15 files changed, 604 insertions, 770 deletions
diff --git a/Changelog b/Changelog
index 21cce5ac..5f3a18ac 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,12 @@
-----------------
+Rev: 104
+Date: 23 April 2008
+User: MathStuf
+-----------------
+[FIX] Old tree handling is gone
+[FIX] New tree handling is started
+
+-----------------
Rev: 103
Date: 22 April 2008
User: MathStuf
diff --git a/pokemod/TODO b/pokemod/TODO
index fe809b94..febfdb29 100644
--- a/pokemod/TODO
+++ b/pokemod/TODO
@@ -5,9 +5,8 @@ Figure out what makes 2 PokéMods incompatable
Validation crap
General cleanup
+
Trainer AI stuff
-Refactor whatever possible
- cleanup of subclasses
Test library
diff --git a/pokemodr/ObjectModel.cpp b/pokemodr/ObjectModel.cpp
new file mode 100644
index 00000000..4f184e56
--- /dev/null
+++ b/pokemodr/ObjectModel.cpp
@@ -0,0 +1,20 @@
+/*
+ * 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"
+
diff --git a/pokemodr/ObjectModel.h b/pokemodr/ObjectModel.h
new file mode 100644
index 00000000..07f4d815
--- /dev/null
+++ b/pokemodr/ObjectModel.h
@@ -0,0 +1,487 @@
+/*
+ * 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__
+
+// Qt includes
+#include <QAbstractItemModel>
+#include <QModelIndex>
+#include <QString>
+#include <QStringList>
+#include <QVariant>
+
+// Pokemod includes
+#include <Ability.h>
+#include <AbilityEffect.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 <Object.h>
+#include <Pokemod.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 <Trainer.h>
+#include <Type.h>
+
+// PokeModr includes
+#include "AbilityUI.h"
+// #include "AbilityEffectUI.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 "SpeciesUI.h"
+#include "SpeciesAbilityUI.h"
+#include "SpeciesEvolutionUI.h"
+#include "SpeciesItemUI.h"
+#include "SpeciesMoveUI.h"
+#include "StoreUI.h"
+#include "TileUI.h"
+#include "TimeUI.h"
+#include "TrainerUI.h"
+#include "TypeUI.h"
+
+class BaseObjectModel
+{
+ public:
+ virtual ~BaseObjectModel();
+
+ virtual QVariant data(const int role = Qt::DisplayRole) const = 0;
+ virtual int rowCount() const = 0;
+
+ virtual Qt::ItemFlags flags() const = 0;
+ virtual bool setData(const QVariant& value, const int role = Qt::EditRole) = 0;
+
+ virtual BaseObjectModel* childItem(const int row) = 0;
+ virtual int indexNumber() const = 0;
+
+ virtual BaseObjectModel* parent() = 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) const = 0;
+
+// virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column) = 0;
+//
+// Qt::DropActions supportedDragActions()
+// {
+// return Qt::CopyAction | Qt::MoveAction;
+// }
+// Qt::DropActions supportedDropActions()
+// {
+// return Qt::CopyAction | Qt::MoveAction;
+// }
+
+ virtual QWidget* editorWidget() = 0;
+ protected:
+ Object* m_object;
+ QString m_name;
+};
+
+class RootModel : public BaseObjectModel
+{
+ public:
+ RootModel();
+ ~RootModel();
+
+ int rowCount() const
+ {
+ return m_pokemods.size();
+ }
+
+ Qt::ItemFlags flags() const
+ {
+ return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
+ }
+ bool setData(const QVariant& value, const int role = Qt::EditRole)
+ {
+ if (role == Qt::UserRole)
+ {
+ if (value.canConvert< QList<QVariant> >())
+ {
+ //TODO: import data list from each item
+ }
+ }
+ return false;
+ }
+
+ QWidget* editorWidget()
+ {
+ return NULL;
+ }
+ private:
+ QList<Pokemod*> m_pokemods;
+};
+
+class GroupModel : public BaseObjectModel
+{
+ public:
+ virtual ~GroupModel();
+
+ QVariant data(int role = Qt::DisplayRole) const
+ {
+ if (role == Qt::DisplayRole)
+ return m_name;
+ return QVariant();
+ }
+ virtual int rowCount() const = 0;
+
+ Qt::ItemFlags flags() const
+ {
+ return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
+ }
+ bool setData(const QVariant& value, int role = Qt::EditRole)
+ {
+ if (role == Qt::DisplayRole)
+ {
+ if (value.canConvert<QString>())
+ {
+ m_name = value.toString();
+ return true;
+ }
+ }
+ if (role == Qt::UserRole)
+ {
+ if (value.canConvert<void*>())
+ {
+ m_object = static_cast<Object*>(value.value<void*>());
+ return true;
+ }
+ }
+ return false;
+ }
+
+// virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column) = 0;
+
+ QWidget* editorWidget()
+ {
+ return NULL;
+ }
+};
+
+class ObjectModel : public BaseObjectModel
+{
+ public:
+ virtual ~ObjectModel();
+
+ virtual QVariant data(int role = Qt::DisplayRole) const = 0;
+ virtual int rowCount() const = 0;
+
+ Qt::ItemFlags flags() const
+ {
+ return Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
+ }
+ virtual bool setData(const QVariant& value, int role = Qt::EditRole) = 0;
+
+ virtual QWidget* editorWidget() = 0;
+};
+
+class AbilityModel : public ObjectModel
+{
+ public:
+ QVariant data(int role = Qt::DisplayRole) const
+ {
+ if (role == Qt::DisplayRole)
+ return static_cast<Ability*>(m_object)->name();
+ if (role == Qt::UserRole)
+ return m_object;
+ return QVariant();
+ }
+ int rowCount() const
+ {
+ return static_cast<Ability*>(m_object)->effectCount();
+ }
+
+ bool setData(const QVariant& value, int role = Qt::EditRole)
+ {
+ if (role == Qt::UserRole)
+ {
+ if (value.canConvert<void*>())
+ {
+ *static_cast<Ability*>(m_object) = *static_cast<Ability*>(value.value<void*>());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ QWidget* editorWidget()
+ {
+ return new AbilityUI(static_cast<Ability*>(m_object), NULL);
+ }
+};
+
+// class AbilityEffectModel : public ObjectModel
+// {
+// public:
+// QVariant data(int role = Qt::DisplayRole) const
+// {
+// if (role == Qt::DisplayRole)
+// return AbilityEffect::EffectStr[static_cast<AbilityEffect*>(m_object)->effect()];
+// if (role == Qt::UserRole)
+// return m_object;
+// return QVariant();
+// }
+// int rowCount() const
+// {
+// return 0;
+// }
+//
+// bool setData(const QVariant& value, int role = Qt::EditRole)
+// {
+// if (role == Qt::UserRole)
+// {
+// if (value.canConvert<void*>())
+// {
+// *static_cast<AbilityEffect*>(m_object) = *static_cast<AbilityEffect*>(value.value<void*>());
+// return true;
+// }
+// }
+// return false;
+// }
+//
+// QWidget* editorWidget()
+// {
+// return new AbilityEffectUI(static_cast<AbilityEffect*>(m_object), NULL);
+// }
+// };
+
+class BadgeModel : public ObjectModel
+{
+ public:
+ QVariant data(int role = Qt::DisplayRole) const
+ {
+ if (role == Qt::DisplayRole)
+ return static_cast<Badge*>(m_object)->name();
+ if (role == Qt::UserRole)
+ return m_object;
+ return QVariant();
+ }
+ int rowCount() const
+ {
+ return 0;
+ }
+
+ bool setData(const QVariant& value, int role = Qt::EditRole)
+ {
+ if (role == Qt::UserRole)
+ {
+ if (value.canConvert<void*>())
+ {
+ *static_cast<Badge*>(m_object) = *static_cast<Badge*>(value.value<void*>());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ QWidget* editorWidget()
+ {
+ return new BadgeUI(static_cast<Badge*>(m_object), NULL);
+ }
+};
+
+class CoinListModel : public ObjectModel
+{
+ public:
+ QVariant data(int role = Qt::DisplayRole) const
+ {
+ if (role == Qt::DisplayRole)
+ return static_cast<CoinList*>(m_object)->name();
+ if (role == Qt::UserRole)
+ return m_object;
+ return QVariant();
+ }
+ int rowCount() const
+ {
+ return static_cast<CoinList*>(m_object)->objectCount();
+ }
+
+ bool setData(const QVariant& value, int role = Qt::EditRole)
+ {
+ if (role == Qt::UserRole)
+ {
+ if (value.canConvert<void*>())
+ {
+ *static_cast<CoinList*>(m_object) = *static_cast<CoinList*>(value.value<void*>());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ QWidget* editorWidget()
+ {
+ return new CoinListUI(static_cast<CoinList*>(m_object), NULL);
+ }
+};
+
+class PokemodTreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+ public:
+ PokemodTreeModel(const QStringList& pokemods, QObject* parent = 0);
+ ~PokemodTreeModel();
+
+ QVariant data(const QModelIndex& index, int role) const
+ {
+ if (!index.isValid())
+ return QVariant();
+ BaseObjectModel* object = static_cast<BaseObjectModel*>(index.internalPointer());
+ return object->data(role);
+ }
+
+ QModelIndex index(int row, int /*column*/, const QModelIndex& parent = QModelIndex()) const
+ {
+ if (!parent.isValid())
+ return QModelIndex();
+ BaseObjectModel* object = getItem(parent)->childItem(row);
+ if (object)
+ return createIndex(row, 0, object);
+ else
+ return QModelIndex();
+ }
+ QModelIndex parent(const QModelIndex& index) const
+ {
+ if (!index.isValid())
+ return QModelIndex();
+ BaseObjectModel* object = static_cast<BaseObjectModel*>(index.internalPointer());
+ BaseObjectModel* parent = object->parent();
+ if (parent == m_root)
+ return QModelIndex();
+ return createIndex(parent->indexNumber(), 0, parent);
+ }
+
+ int rowCount(const QModelIndex& parent = QModelIndex()) const
+ {
+ if (!parent.isValid())
+ return 0;
+ BaseObjectModel* object = static_cast<BaseObjectModel*>(parent.internalPointer());
+ return object->rowCount();
+ }
+ int columnCount(const QModelIndex& /*parent = QModelIndex()*/) const
+ {
+ return 1;
+ }
+
+ Qt::ItemFlags flags(const QModelIndex& index) const
+ {
+ if (!index.isValid())
+ return 0;
+ BaseObjectModel* object = static_cast<BaseObjectModel*>(index.internalPointer());
+ return object->flags();
+ }
+ bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole)
+ {
+ if (!index.isValid())
+ return false;
+ BaseObjectModel* object = static_cast<BaseObjectModel*>(index.internalPointer());
+ return object->setData(value, role);
+ }
+
+ bool insertColumns(int /*position*/, int /*columns*/, const QModelIndex& /*parent = QModelIndex()*/)
+ {
+ return false;
+ }
+ bool removeColumns(int /*position*/, int /*columns*/, const QModelIndex& /*parent = QModelIndex()*/)
+ {
+ return false;
+ }
+ bool insertRows(int /*position*/, int rows, const QModelIndex& parent = QModelIndex())
+ {
+ BaseObjectModel* object = getItem(parent);
+ if (!object->canInsertRows())
+ return false;
+ emit(beginInsertRows(parent, object->rowCount(), object->rowCount() + rows - 1));
+ bool success = object->insertRows(rows);
+ emit(endInsertRows());
+ return success;
+ }
+ bool removeRows(int position, int rows, const QModelIndex& parent = QModelIndex())
+ {
+ BaseObjectModel* object = getItem(parent);
+ if (!object->canRemoveRows())
+ return false;
+ emit(beginRemoveRows(parent, position, position + rows - 1));
+ bool success = object->removeRows(position, rows);
+ emit(endRemoveRows());
+ return success;
+ }
+
+ QWidget* editorWidget(const QModelIndex& index)
+ {
+ if (!index.isValid())
+ return NULL;
+ BaseObjectModel* ptr = static_cast<BaseObjectModel*>(index.internalPointer());
+ return ptr->editorWidget();
+ }
+ private:
+ BaseObjectModel* getItem(const QModelIndex& index) const
+ {
+ if (index.isValid())
+ {
+ BaseObjectModel* object = static_cast<BaseObjectModel*>(index.internalPointer());
+ if (object)
+ return object;
+ }
+ return m_root;
+ }
+
+ RootModel* m_root;
+};
+
+#endif
diff --git a/pokemodr/PokeModTreeItem.cpp b/pokemodr/PokeModTreeItem.cpp
deleted file mode 100644
index bfed8e1b..00000000
--- a/pokemodr/PokeModTreeItem.cpp
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * 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/>.
- */
-
-// KDE includes
-#include <kaction.h>
-#include <kmenu.h>
-
-// Qt includes
-#include <QPoint>
-#include <QString>
-
-// Pokemod includes
-#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 <Trainer.h>
-#include <Type.h>
-
-// PokeModr includes
-#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"
-#include "SpeciesUI.h"
-#include "SpeciesAbilityUI.h"
-#include "SpeciesEvolutionUI.h"
-#include "SpeciesItemUI.h"
-#include "SpeciesMoveUI.h"
-#include "StoreUI.h"
-#include "TileUI.h"
-#include "TimeUI.h"
-#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(m_object->className());
- if (name == "Ability")
- new PokeModTreeItem(this, m_object, "Effects");
- else if (name == "CoinList")
- new PokeModTreeItem(this, m_object, "Objects");
- else if (name == "Item")
- new PokeModTreeItem(this, m_object, "Effects");
- else if (name == "Map")
- {
- 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, m_object, "Team Members");
- else if (name == "MapWildList")
- new PokeModTreeItem(this, m_object, "Encounters");
- else if (name == "Move")
- new PokeModTreeItem(this, m_object, "Effects");
- else if (name == "Pokemod")
- {
- new PokeModTreeItem(this, static_cast<Pokemod*>(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, 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->className());
- if (name == "Ability")
- {
- Ability* ability = static_cast<Ability*>(m_object);
- for (int i = 0; i < ability->effectCount(); ++i)
- new PokeModTreeItem(this, ability->effect(i));
- }
- else if (name == "CoinList")
- {
- CoinList* coinList = static_cast<CoinList*>(m_object);
- for (int i = 0; i < coinList->itemCount(); ++i)
- new PokeModTreeItem(this, coinList->item(i));
- }
- else if (name == "Item")
- {
- Item* item = static_cast<Item*>(m_object);
- for (int i = 0; i < item->effectCount(); ++i)
- new PokeModTreeItem(this, item->effect(i));
- }
- else if (name == "Map")
- {
- Map* map = static_cast<Map*>(m_object);
- if (text(0) == "Effects")
- {
- for (int i = 0; i < map->effectCount(); ++i)
- new PokeModTreeItem(this, map->effect(i));
- }
- else if (text(0) == "Trainers")
- {
- 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->warpCount(); ++i)
- new PokeModTreeItem(this, m->warp(i));
- }
- else if (text(0) == "Wild Lists")
- {
- for (int i = 0; i < m->wildListCount(); ++i)
- new PokeModTreeItem(this, m->wildList(i));
- }
- }
- else if (name == "MapTrainer")
- {
- MapTrainer* t = static_cast<MapTrainer*>(obj);
- for (int i = 0; i < t->teamMemberCount(); ++i)
- new PokeModTreeItem(this, t->teamMember(i));
- }
- else if (name == "MapWildList")
- {
- MapWildList* w = static_cast<MapWildList*>(obj);
- for (int i = 0; i < w->encounterCount(); ++i)
- new PokeModTreeItem(this, w->encounter(i));
- }
- else if (name == "Move")
- {
- Move* m = static_cast<Move*>(obj);
- for (int i = 0; i < m->effectCount(); ++i)
- new PokeModTreeItem(this, m->effect(i));
- }
- else if (name == "Pokemod")
- {
- Pokemod* p = static_cast<Pokemod*>(obj);
- if (text(0) == "Abilities")
- {
- 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->authorCount(); ++i)
- new PokeModTreeItem(this, p->author(i));
- }
- else if (text(0) == "Badges")
- {
- 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->coinListCount(); ++i)
- new PokeModTreeItem(this, p->coinList(i));
- }
- else if (text(0) == "Dialogs")
- {
- 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->eggGroupCount(); ++i)
- new PokeModTreeItem(this, p->eggGroup(i));
- }
- else if (text(0) == "Items")
- {
- 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->itemTypeCount(); ++i)
- new PokeModTreeItem(this, p->itemType(i));
- }
- else if (text(0) == "Maps")
- {
- 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->moveCount(); ++i)
- new PokeModTreeItem(this, p->move(i));
- }
- else if (text(0) == "Natures")
- {
- 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->speciesCount(); ++i)
- new PokeModTreeItem(this, p->species(i));
- }
- else if (text(0) == "Stores")
- {
- 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->tileCount(); ++i)
- new PokeModTreeItem(this, p->tile(i));
- }
- else if (text(0) == "Times")
- {
- 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->trainerCount(); ++i)
- new PokeModTreeItem(this, p->trainer(i));
- }
- else if (text(0) == "Types")
- {
- for (int i = 0; i < p->typeCount(); ++i)
- new PokeModTreeItem(this, p->type(i));
- }
- }
- else if (name == "Species")
- {
- Species* s = static_cast<Species*>(obj);
- if (text(0) == "Abilities")
- {
- 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->evolutionCount(); ++i)
- new PokeModTreeItem(this, s->evolution(i));
- }
- else if (text(0) == "Items")
- {
- 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->moveCount(); ++i)
- new PokeModTreeItem(this, s->move(i));
- }
- }
- obj = NULL;
- }
-}
-
-void PokeModTreeItem::init(QWidget* pnt)
-{
- update();
- setExpanded(true);
- setChildIndicatorPolicy(QTreeWidgetItem::QTreeWidgetItem::DontShowIndicatorWhenChildless);
- if (obj)
- {
- 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)
- else IF_IS_CLASS(Author)
- 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(Trainer)
- else IF_IS_CLASS(Type)
- connect(ui, SIGNAL(changed(bool)), this, SLOT(changed(bool)));
- connect(ui, SIGNAL(changed(bool)), this, SLOT(updateName()));
- }
-#undef IF_IS_CLASS
- updateName();
-}
-
-void PokeModTreeItem::updateName()
-{
- if (!obj)
- return;
- QString name(obj->className());
- QString text;
- if (name == "Ability")
- text = static_cast<Ability*>(obj)->name();
- else if (name == "AbilityEffect")
- text = AbilityEffect::EffectStr.at(static_cast<AbilityEffect*>(obj)->effect());
- else if (name == "Author")
- text = static_cast<Author*>(obj)->name();
- else if (name == "Badge")
- text = static_cast<Badge*>(obj)->name();
- else if (name == "CoinList")
- text = static_cast<CoinList*>(obj)->name();
- else if (name == "CoinListObject")
- {
- const CoinListObject* o = static_cast<CoinListObject*>(obj);
- if (o->type() == CoinListObject::Item)
- text = obj->pokemod()->item(o->object())->name();
- else
- text = obj->pokemod()->species(o->object())->name();
- }
- else if (name == "Dialog")
- text = static_cast<Dialog*>(obj)->dialog().mid(0, 25);
- else if (name == "EggGroup")
- text = static_cast<EggGroup*>(obj)->name();
- else if (name == "Item")
- text = static_cast<Item*>(obj)->name();
- else if (name == "ItemEffect")
- text = ItemEffect::EffectStr.at(static_cast<ItemEffect*>(obj)->effect());
- else if (name == "ItemType")
- text = static_cast< ::ItemType* >(obj)->name();
- else if (name == "Map")
- text = static_cast<Map*>(obj)->name();
- else if (name == "MapEffect")
- text = static_cast<MapEffect*>(obj)->name();
- else if (name == "MapTrainer")
- text = static_cast<MapTrainer*>(obj)->name();
- else if (name == "MapTrainerTeamMember")
- {
- const MapTrainerTeamMember* t = static_cast<MapTrainerTeamMember*>(obj);
- text = QString("Lv. %1 %2").arg(t->level()).arg(obj->pokemod()->species(t->species())->name());
- }
- else if (name == "MapWarp")
- text = static_cast<MapWarp*>(obj)->name();
- else if (name == "MapWildList")
- text = MapWildList::ControlStr.at(static_cast<MapWildList*>(obj)->control());
- else if (name == "MapWildListEncounter")
- {
- const MapWildListEncounter* e = static_cast<MapWildListEncounter*>(obj);
- text = QString("Lv. %1 %2").arg(e->level()).arg(obj->pokemod()->species(e->species())->name());
- }
- else if (name == "Move")
- text = static_cast<Move*>(obj)->name();
- else if (name == "MoveEffect")
- text = MoveEffect::EffectStr.at(static_cast<MoveEffect*>(obj)->effect());
- else if (name == "Nature")
- text = static_cast<Nature*>(obj)->name();
- else if (name == "Pokemod")
- text = static_cast<Pokemod*>(obj)->title();
- else if (name == "Rules")
- text = "Rules";
- else if (name == "Species")
- text = static_cast<Species*>(obj)->name();
- else if (name == "SpeciesAbility")
- text = obj->pokemod()->ability(static_cast<SpeciesAbility*>(obj)->ability())->name();
- else if (name == "SpeciesEvolution")
- text = obj->pokemod()->species(static_cast<SpeciesEvolution*>(obj)->species())->name();
- else if (name == "SpeciesItem")
- text = obj->pokemod()->item(static_cast<SpeciesItem*>(obj)->item())->name();
- else if (name == "SpeciesMove")
- text = obj->pokemod()->move(static_cast<SpeciesMove*>(obj)->move())->name();
- else if (name == "Store")
- text = static_cast<Store*>(obj)->name();
- else if (name == "Tile")
- text = static_cast<Tile*>(obj)->name();
- else if (name == "Time")
- text = static_cast<Time*>(obj)->name();
- else if (name == "Trainer")
- text = static_cast<Trainer*>(obj)->name();
- else if (name == "Type")
- text = static_cast< ::Type* >(obj)->name();
- setText(0, text);
-}
-
-void PokeModTreeItem::makeMenu(const QPoint& pos)
-{
-}
-
-Object* PokeModTreeItem::copy()
-{
- if (obj)
- {
- 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)
- 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") return new Pokemod(*static_cast<Pokemod*>(obj));
- else if (name == "Rules") return new Rules(obj->pokemod());
- 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(Trainer)
- else IF_IS_CLASS(Type)
-#undef IF_IS_CLASS
- }
- return NULL;
-}
-
-Object* PokeModTreeItem::cut()
-{
- // TODO: actually cut the item
- if (obj)
- {
- 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)
- 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") return new Pokemod(*static_cast<Pokemod*>(obj));
- else if (name == "Rules") return new Rules(obj->pokemod());
- 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(Trainer)
- else IF_IS_CLASS(Type)
-#undef IF_IS_CLASS
- }
- return NULL;
-}*/
diff --git a/pokemodr/PokeModTreeItem.h b/pokemodr/PokeModTreeItem.h
deleted file mode 100644
index 8239e277..00000000
--- a/pokemodr/PokeModTreeItem.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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_POKEMODTREEITEM__
-#define __POKEMODR_POKEMODTREEITEM__
-
-// Qt includes
-#include <QColor>
-#include <QObject>
-#include <QTreeWidgetItem>
-
-// Pokemod includes
-#include <Object.h>
-
-// PokeModr includes
-#include "ObjectUI.h"
-
-class PokeModTreeItem : public QObject, public QTreeWidgetItem
-{
- Q_OBJECT
-
- public:
- PokeModTreeItem(QTreeWidget* parentBranch, Object* object, const QString& text = "") :
- QTreeWidgetItem(parentBranch, QTreeWidgetItem::UserType),
- m_object(object),
- m_objectUi(NULL)
- {
- setText(0, text);
- init();
- }
- ~PokeModTreeItem()
- {
- if (m_objectUi)
- delete m_objectUi;
- }
-
- void makeMenu(const QPoint& position);
- void save()
- {
- m_objectUi->on_buttonApply_clicked();
- }
- Object* copy();
- Object* cut();
- void paste(Object* object)
- {
- if (object)
- {
- if (m_object->className() == object->className())
- {
- // FIXME: class determination hell
- m_object = object;
- m_objectUi->on_buttonDiscard_clicked();
- update();
- }
- }
- }
-
- ObjectUI* getUi()
- {
- return m_objectUi;
- }
- QString objectType()
- {
- if (m_object)
- return m_object->className();
- return "";
- }
- const Object* object() const
- {
- return m_object;
- }
- Object* object()
- {
- return m_object;
- }
- const Pokemod* pokemod() const
- {
- if (m_object)
- return m_object->pokemod();
- return static_cast<PokeModTreeItem*>(QTreeWidgetItem::parent())->pokemod();
- }
- public slots:
- void updateName();
- void changed(const bool changed)
- {
- setBackgroundColor(0, QColor(changed ? 255 : 0, 0, 0));
- }
- private:
- void update();
- void init();
-
- Object* m_object;
- ObjectUI* m_objectUi;
-};
-
-#endif
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index 134f5d64..d98729ce 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -123,7 +123,6 @@ PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* paren
// openPokeMod(recent.urls().at(i));
// }
setAutoSaveSettings("MainWindow", true);
- rebuildTree();
}
PokeModrUI::~PokeModrUI()
@@ -131,13 +130,6 @@ PokeModrUI::~PokeModrUI()
on_actionQuit_triggered();
}
-void PokeModrUI::rebuildTree()
-{
- treePokemod->clear();
- foreach (Pokemod* pokemod, m_pokemods)
- new PokeModTreeItem(treePokemod, pokemod);
-}
-
void PokeModrUI::openPokeMod(const KUrl& path)
{
if (path.isLocalFile())
@@ -145,7 +137,6 @@ void PokeModrUI::openPokeMod(const KUrl& path)
// m_pokemods.append(new Pokemod(path.path()));
m_recent.addUrl(path);
m_recent.saveEntries(m_config);
- rebuildTree();
}
}
@@ -157,32 +148,32 @@ void PokeModrUI::savePokeMod()
void PokeModrUI::closePokeMod()
{
- if (formPanel->widget())
- {
- ObjectUI* o = static_cast<ObjectUI*>(formPanel->widget());
- const Pokemod* p = o->original()->pokemod();
- 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(m_pokemods); i.hasNext(); i.next())
- {
- if (i.value() == p)
- {
- i.remove();
- break;
- }
- }
- delete p;
- rebuildTree();
- }
+ // TODO: Close the Pokemod with the current editor open
+// if (formPanel->widget())
+// {
+// ObjectUI* o = static_cast<ObjectUI*>(formPanel->widget());
+// const Pokemod* p = o->original()->pokemod();
+// 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(m_pokemods); i.hasNext(); i.next())
+// {
+// if (i.value() == p)
+// {
+// i.remove();
+// break;
+// }
+// }
+// delete p;
+// }
}
void PokeModrUI::closeEvent(QCloseEvent* event)
@@ -215,16 +206,18 @@ void PokeModrUI::on_actionOpen_triggered()
void PokeModrUI::on_actionSave_triggered()
{
- if (!treePokemod->currentItem())
- return;
- static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
- static_cast<Pokemod*>(static_cast<PokeModTreeItem*>(treePokemod->currentItem())->object())->pokemod()->save();
+ // TODO: Save the current pokemod with the object open
+// if (!treePokemod->currentItem())
+// return;
+// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
+// static_cast<Pokemod*>(static_cast<PokeModTreeItem*>(treePokemod->currentItem())->object())->pokemod()->save();
}
void PokeModrUI::on_actionSaveAs_triggered()
{
- if (!treePokemod->currentItem())
- return;
+ // TODO: Save the current pokemod to a new file
+// if (!treePokemod->currentItem())
+// return;
// QString dir = KFileDialog::existingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("Open PokéMod"));
// if (dir != "")
// {
@@ -244,27 +237,30 @@ void PokeModrUI::on_actionQuit_triggered()
void PokeModrUI::on_actionCut_triggered()
{
- if (!treePokemod->currentItem())
- return;
- if (m_clipboard)
- delete m_clipboard;
- m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->cut();
+ // TODO: cut the item
+// if (!treePokemod->currentItem())
+// return;
+// if (m_clipboard)
+// delete m_clipboard;
+// m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->cut();
}
void PokeModrUI::on_actionCopy_triggered()
{
- if (!treePokemod->currentItem())
- return;
- if (m_clipboard)
- delete m_clipboard;
- m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->copy();
+ // TODO: copy the item
+// if (!treePokemod->currentItem())
+// return;
+// if (m_clipboard)
+// delete m_clipboard;
+// m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->copy();
}
void PokeModrUI::on_actionPaste_triggered()
{
- if (!m_clipboard || !treePokemod->currentItem())
- return;
- static_cast<PokeModTreeItem*>(treePokemod->currentItem())->paste(m_clipboard);
+ // TODO: paste the item
+// if (!m_clipboard || !treePokemod->currentItem())
+// return;
+// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->paste(m_clipboard);
}
void PokeModrUI::on_actionPreferences_triggered()
@@ -277,29 +273,31 @@ void PokeModrUI::on_splitter_splitterMoved()
m_config.writeEntry("panelWidth", splitter->sizes()[1]);
}
-void PokeModrUI::on_treePokemod_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous)
+void PokeModrUI::on_treePokemod_clicked(const QModelIndex& index)
{
- if (!static_cast<PokeModTreeItem*>(current)->getUi())
- {
- if (previous)
- treePokemod->setCurrentItem(previous);
- current->setSelected(false);
- return;
- }
- if (formPanel->widget())
- {
- if (!static_cast<ObjectUI*>(formPanel->widget())->close())
- return;
- }
- formPanel->setWidget(static_cast<PokeModTreeItem*>(current)->getUi());
- formPanel->show();
+ // TODO: update the panel with the new widget needed
+// if (!static_cast<PokeModTreeItem*>(current)->getUi())
+// {
+// if (previous)
+// treePokemod->setCurrentItem(previous);
+// current->setSelected(false);
+// return;
+// }
+// if (formPanel->widget())
+// {
+// if (!static_cast<ObjectUI*>(formPanel->widget())->close())
+// return;
+// }
+// formPanel->setWidget(static_cast<PokeModTreeItem*>(current)->getUi());
+// formPanel->show();
}
void PokeModrUI::on_treePokemod_customContextMenuRequested(const QPoint& position)
{
- if (treePokemod->itemAt(position))
- static_cast<PokeModTreeItem*>(treePokemod->itemAt(position))->makeMenu(position);
- else
- {
- }
+ // TODO: figure out which item was clicked
+// if (treePokemod->itemAt(position))
+// static_cast<PokeModTreeItem*>(treePokemod->itemAt(position))->makeMenu(position);
+// else
+// {
+// }
}
diff --git a/pokemodr/PokeModrUI.h b/pokemodr/PokeModrUI.h
index 5cc1d466..d10a27f7 100644
--- a/pokemodr/PokeModrUI.h
+++ b/pokemodr/PokeModrUI.h
@@ -62,11 +62,9 @@ class PokeModrUI : public KMainWindow, private Ui::formPokeModr
void on_actionPaste_triggered();
void on_actionPreferences_triggered();
void on_splitter_splitterMoved();
- void on_treePokemod_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
+ void on_treePokemod_clicked(const QModelIndex& index);
void on_treePokemod_customContextMenuRequested(const QPoint& position);
private:
- void rebuildTree();
-
KConfigGroup m_config;
KRecentFilesAction m_recent;
QList<Pokemod*> m_pokemods;
diff --git a/pokemodr/TODO b/pokemodr/TODO
index 6d874ac6..b2a88392 100644
--- a/pokemodr/TODO
+++ b/pokemodr/TODO
@@ -7,5 +7,7 @@ MoveEffect
Update GUI to see new methods
+Drag and drop stuff
+
Flag widget
-TilemapModel is wrong
+TilemapModel is (probably) wrong
diff --git a/pokemodr/TilemapModel.cpp b/pokemodr/TilemapModel.cpp
index 22c57aba..6fe1970c 100644
--- a/pokemodr/TilemapModel.cpp
+++ b/pokemodr/TilemapModel.cpp
@@ -56,7 +56,7 @@ QVariant TilemapModel::data(const QModelIndex& index, int role) const
return m_pokemod->tile(idx)->sprite();
}
if (role == Qt::EditRole)
- m_map->at(index.row(), index.column());
+ return m_map->at(index.row(), index.column());
if (role == Qt::ToolTipRole)
{
int idx = m_pokemod->tileIndex(m_map->at(index.row(), index.column()));
@@ -77,6 +77,7 @@ bool TilemapModel::setData(const QModelIndex& index, const QVariant& value, int
{
if (role != Qt::EditRole)
return false;
+// emit(setDataChanged(index, index));
(*m_map)(index.row(), index.column()) = m_pokemod->tile(value.toInt())->id();
emit(dataChanged(index, index));
return true;
diff --git a/pokemodr/TilemapModel.h b/pokemodr/TilemapModel.h
index 26438b41..34d0bf9e 100644
--- a/pokemodr/TilemapModel.h
+++ b/pokemodr/TilemapModel.h
@@ -39,8 +39,8 @@ class TilemapModel : public QAbstractTableModel
void apply();
void discard();
- int rowCount(const QModelIndex& = QModelIndex()) const;
- int columnCount(const QModelIndex& = QModelIndex()) const;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
diff --git a/pokemodr/TrainerUI.h b/pokemodr/TrainerUI.h
index 70087bae..abbbccdb 100644
--- a/pokemodr/TrainerUI.h
+++ b/pokemodr/TrainerUI.h
@@ -43,7 +43,7 @@ class TrainerUI : public ObjectUI, private Ui::formTrainer
void on_varName_textChanged(const QString& name);
void on_varMoneyFactor_valueChaged(const int moneyFactor);
void on_varSkin_pressed();
- void on_varAI_pressed();
+// void on_varAI_pressed();
private:
void setGui();
diff --git a/pokemodr/TypechartWidgetItem.h b/pokemodr/TypechartWidgetItem.h
index a49b268c..51716f52 100644
--- a/pokemodr/TypechartWidgetItem.h
+++ b/pokemodr/TypechartWidgetItem.h
@@ -41,18 +41,16 @@ class TypechartWidgetItem : public QObject, public QTableWidgetItem
QVariant data(const int role)
{
- // FIXME: Fraction in QVariant
- /*if (role == Qt::EditRole)
+ if (role == Qt::EditRole)
return QVariant::fromValue(m_multiplier);
- else*/ if (role == Qt::DisplayRole)
+ else if (role == Qt::DisplayRole)
return QString::number(m_multiplier, 'g', DBL_PREC_SHORT);
return QVariant();
}
void setData(int role, const QVariant& value)
{
- // FIXME: Fraction in QVariant
-// if (role == Qt::EditRole)
-// m_multiplier = value.value<Fraction>();
+ if (role == Qt::EditRole)
+ m_multiplier = value.value<Fraction>();
}
public slots:
void setValue(const Fraction& multiplier)
diff --git a/pokemodr/gui/pokemodr.ui b/pokemodr/gui/pokemodr.ui
index 4f8d64a6..b0d97644 100644
--- a/pokemodr/gui/pokemodr.ui
+++ b/pokemodr/gui/pokemodr.ui
@@ -22,15 +22,10 @@
<property name="childrenCollapsible" >
<bool>false</bool>
</property>
- <widget class="QTreeWidget" name="treePokemod" >
+ <widget class="QTreeView" name="treePokemod" >
<property name="selectionBehavior" >
<enum>QAbstractItemView::SelectItems</enum>
</property>
- <column>
- <property name="text" >
- <string>PokéMod Elements</string>
- </property>
- </column>
</widget>
<widget class="QScrollArea" name="formPanel" />
</widget>
diff --git a/pokemodr/pokemodr.pro b/pokemodr/pokemodr.pro
index a0177807..12bcca97 100644
--- a/pokemodr/pokemodr.pro
+++ b/pokemodr/pokemodr.pro
@@ -82,11 +82,11 @@ SOURCES += AbilityUI.cpp \
MapWildListEncounterUI.cpp \
MoveUI.cpp \
NatureUI.cpp \
+ ObjectModel.cpp \
PointWidget.cpp \
PokemodUI.cpp \
PokeModr.cpp \
PokeModrUI.cpp \
- PokeModTreeItem.cpp \
RulesUI.cpp \
SpeciesUI.cpp \
SpeciesAbilityUI.cpp \
@@ -118,12 +118,12 @@ HEADERS += AbilityUI.h \
MapWildListEncounterUI.h \
MoveUI.h \
NatureUI.h \
+ ObjectModel.h \
ObjectUI.h \
PointWidget.h \
PokemodUI.h \
PokeModr.h \
PokeModrUI.h \
- PokeModTreeItem.h \
RulesUI.h \
SpeciesUI.h \
SpeciesAbilityUI.h \