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/PokemodTreeModel.cpp | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'pokemodr/PokemodTreeModel.cpp') diff --git a/pokemodr/PokemodTreeModel.cpp b/pokemodr/PokemodTreeModel.cpp index fb8aa4f5..8b71a422 100644 --- a/pokemodr/PokemodTreeModel.cpp +++ b/pokemodr/PokemodTreeModel.cpp @@ -62,8 +62,7 @@ QModelIndex PokemodTreeModel::parent(const QModelIndex& index) const { if (!index.isValid()) return QModelIndex(); - BaseModel* object = static_cast(index.internalPointer()); - BaseModel* parent = object->parent(); + BaseModel* parent = static_cast(index.internalPointer())->parent(); if (!parent || (parent == m_root)) return QModelIndex(); return createIndex(parent->indexNumber(), 0, parent); @@ -100,28 +99,6 @@ bool PokemodTreeModel::setData(const QModelIndex& index, const QVariant& value, return success; } -bool PokemodTreeModel::insertRows(int /*position*/, int rows, const QModelIndex& parent) -{ - BaseModel* object = getItem(parent); - if (!object->canInsertRows()) - return false; - emit(layoutAboutToBeChanged()); - bool success = object->insertRows(rows); - emit(layoutChanged()); - return success; -} - -bool PokemodTreeModel::removeRows(int position, int rows, const QModelIndex& parent) -{ - BaseModel* object = getItem(parent); - if (!object->canRemoveRows()) - return false; - emit(layoutAboutToBeChanged()); - bool success = object->removeRows(position, rows); - emit(layoutChanged()); - return success; -} - BaseModel* PokemodTreeModel::getItem(const QModelIndex& index) const { if (index.isValid()) @@ -166,14 +143,12 @@ bool PokemodTreeModel::dropMimeData(const QMimeData* data, Qt::DropAction action void PokemodTreeModel::addPokemod(Pokemod* pokemod) { - emit(layoutAboutToBeChanged()); m_root->addPokemod(pokemod); - emit(layoutChanged()); + emit(reset()); } void PokemodTreeModel::deletePokemod(const Pokemod* pokemod) { - emit(layoutAboutToBeChanged()); m_root->deletePokemod(pokemod); - emit(layoutChanged()); + emit(reset()); } -- cgit