From 8efe5af96d26d8663f1be9401d98566c3aff9a65 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 21 May 2009 01:44:06 -0400 Subject: Add game management to the model --- sigmodr/tree/TreeModel.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sigmodr/tree/TreeModel.cpp') 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(index.internalPointer())->game(); +} -- cgit