summaryrefslogtreecommitdiffstats
path: root/pokemodr/PokemodTreeModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemodr/PokemodTreeModel.cpp')
-rw-r--r--pokemodr/PokemodTreeModel.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/pokemodr/PokemodTreeModel.cpp b/pokemodr/PokemodTreeModel.cpp
index 8b71a422..fbb0c707 100644
--- a/pokemodr/PokemodTreeModel.cpp
+++ b/pokemodr/PokemodTreeModel.cpp
@@ -50,11 +50,16 @@ QVariant PokemodTreeModel::headerData(int /*section*/, Qt::Orientation /*orienta
return QVariant();
}
-QModelIndex PokemodTreeModel::index(int row, int /*column*/, const QModelIndex& parent) const
+QModelIndex PokemodTreeModel::index(int row, int column, const QModelIndex& parent) const
{
- if (row < 0)
+ if ((row < -1) || (column < -1))
+ return QModelIndex();
+ if (row == -1)
return createIndex(row, 0, m_root);
- BaseModel* object = getItem(parent)->childItem(row);
+ BaseModel* model = getItem(parent);
+ if ((model->rowCount() <= row) || (1 <= column))
+ return QModelIndex();
+ BaseModel* object = model->childItem(row);
return createIndex(row, 0, object);
}