summaryrefslogtreecommitdiffstats
path: root/sigmodr/tree/TreeModel.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-05-21 01:44:06 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-05-21 01:44:06 -0400
commit8efe5af96d26d8663f1be9401d98566c3aff9a65 (patch)
treecd50baa34b762d24c38c77d2bd1b4b13b0d7c61d /sigmodr/tree/TreeModel.cpp
parent61e288f0f43f9f506170f3e789a21f8b9c02d18b (diff)
downloadsigen-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.cpp21
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();
+}