summaryrefslogtreecommitdiffstats
path: root/pokemodr/PokemodTreeModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemodr/PokemodTreeModel.cpp')
-rw-r--r--pokemodr/PokemodTreeModel.cpp31
1 files changed, 3 insertions, 28 deletions
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<BaseModel*>(index.internalPointer());
- BaseModel* parent = object->parent();
+ BaseModel* parent = static_cast<BaseModel*>(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());
}