From 7e3bf1853184f96eb5be47dd78ebe21fdc170a01 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 25 May 2008 21:17:56 +0000 Subject: [ADD] More documentation [FIX] Cleaned out some code from the models [FIX] Matrix should now work a lot better now [FIX] Opening/Saving/Closing PokéMods should be much cleaner now [FIX] currentPokemod code is now in the tree class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@173 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/PokemodTree.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'pokemodr/PokemodTree.cpp') diff --git a/pokemodr/PokemodTree.cpp b/pokemodr/PokemodTree.cpp index 9c38663b..35b41017 100644 --- a/pokemodr/PokemodTree.cpp +++ b/pokemodr/PokemodTree.cpp @@ -25,6 +25,10 @@ #include "ObjectUI.h" #include "PokemodTreeModel.h" +// Pokemod includes +#include "../pokemod/Object.h" +#include "../pokemod/Pokemod.h" + // Qt includes #include @@ -43,7 +47,9 @@ QString PokemodTree::description(const QModelIndex& index) ObjectUI* PokemodTree::editorWidget(const QModelIndex& index) { - return static_cast(model()->data(index, BaseModel::WidgetRole).value()); + ObjectUI* widget = static_cast(model()->data(index, BaseModel::WidgetRole).value()); + connect(widget, SIGNAL(changed(bool)), this, SLOT(setDirty())); + return widget; } KMenu* PokemodTree::contextMenu(const QModelIndex& index) @@ -51,6 +57,18 @@ KMenu* PokemodTree::contextMenu(const QModelIndex& index) return static_cast(model()->data(index, BaseModel::ContextMenuRole).value()); } +const Pokemod* PokemodTree::currentPokemod() const +{ + QModelIndex index = currentIndex(); + if (index.isValid()) + { + const Object* object = static_cast(index.internalPointer())->object(); + if (object) + return static_cast(object->pokemod()); + } + return NULL; +} + QDomDocument PokemodTree::cut(const QModelIndex& index) { // TODO: actually cut out the item @@ -69,6 +87,11 @@ void PokemodTree::paste(const QModelIndex& index, const QDomDocument& data) model()->setData(index, data.toString(), BaseModel::XmlRole); } +QList PokemodTree::openedPokemods() const +{ + return m_pokemods.keys(); +} + void PokemodTree::addPokemod(Pokemod* pokemod) { static_cast(model())->addPokemod(pokemod); @@ -115,3 +138,8 @@ void PokemodTree::setDirty(const Pokemod* pokemod, const bool dirty) if (m_pokemods.contains(pokemod)) m_pokemods[pokemod].second = dirty; } + +void PokemodTree::setDirty() +{ + setDirty(currentPokemod(), true); +} -- cgit