diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-25 21:17:56 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-25 21:17:56 +0000 |
| commit | 7e3bf1853184f96eb5be47dd78ebe21fdc170a01 (patch) | |
| tree | 7c937aa87fa165fc62bb49d71983e1512f2371c2 /pokemodr/PokemodTree.cpp | |
| parent | dec252e25fc63fe1bb321dd87772181fc76e998f (diff) | |
| download | sigen-7e3bf1853184f96eb5be47dd78ebe21fdc170a01.tar.gz sigen-7e3bf1853184f96eb5be47dd78ebe21fdc170a01.tar.xz sigen-7e3bf1853184f96eb5be47dd78ebe21fdc170a01.zip | |
[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
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@173 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/PokemodTree.cpp')
| -rw-r--r-- | pokemodr/PokemodTree.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
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 <QHeaderView> @@ -43,7 +47,9 @@ QString PokemodTree::description(const QModelIndex& index) ObjectUI* PokemodTree::editorWidget(const QModelIndex& index) { - return static_cast<ObjectUI*>(model()->data(index, BaseModel::WidgetRole).value<QWidget*>()); + ObjectUI* widget = static_cast<ObjectUI*>(model()->data(index, BaseModel::WidgetRole).value<QWidget*>()); + 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<KMenu*>(model()->data(index, BaseModel::ContextMenuRole).value<void*>()); } +const Pokemod* PokemodTree::currentPokemod() const +{ + QModelIndex index = currentIndex(); + if (index.isValid()) + { + const Object* object = static_cast<BaseModel*>(index.internalPointer())->object(); + if (object) + return static_cast<const Pokemod*>(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<const Pokemod*> PokemodTree::openedPokemods() const +{ + return m_pokemods.keys(); +} + void PokemodTree::addPokemod(Pokemod* pokemod) { static_cast<PokemodTreeModel*>(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); +} |
