diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-05-21 01:44:06 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-05-21 01:44:06 -0400 |
commit | 8efe5af96d26d8663f1be9401d98566c3aff9a65 (patch) | |
tree | cd50baa34b762d24c38c77d2bd1b4b13b0d7c61d /sigmodr/tree/TreeModel.cpp | |
parent | 61e288f0f43f9f506170f3e789a21f8b9c02d18b (diff) | |
download | sigen-8efe5af96d26d8663f1be9401d98566c3aff9a65.tar.gz sigen-8efe5af96d26d8663f1be9401d98566c3aff9a65.tar.xz sigen-8efe5af96d26d8663f1be9401d98566c3aff9a65.zip |
Add game management to the model
Diffstat (limited to 'sigmodr/tree/TreeModel.cpp')
-rw-r--r-- | sigmodr/tree/TreeModel.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sigmodr/tree/TreeModel.cpp b/sigmodr/tree/TreeModel.cpp index c22020d3..3f0884f2 100644 --- a/sigmodr/tree/TreeModel.cpp +++ b/sigmodr/tree/TreeModel.cpp @@ -164,3 +164,24 @@ void TreeModel::addGame(Game* game) m_root->addGame(game); endInsertRows(); } + +void TreeModel::deleteGame(const Game* game) +{ + for (int i = 0; i < m_root->childCount(); ++i) + { + if (m_root->childAt(i)->game() == game) + { + beginRemoveRows(index(-1, -1, QModelIndex()), i, i); + m_root->removeChild(i); + endRemoveRows(); + break; + } + } +} + +const Game* TreeModel::findGame(const QModelIndex& index) const +{ + if (!index.isValid()) + return NULL; + return static_cast<TreeItem*>(index.internalPointer())->game(); +} |