summaryrefslogtreecommitdiffstats
path: root/sigmodr/tree
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-05-21 01:48:11 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-05-21 01:48:11 -0400
commit7c2bb4a47d6fc2bf59e425a6e06c60d53116c0f3 (patch)
tree94002af399f7d1b737e5ec9048619ba83c80656a /sigmodr/tree
parentd64b44e4ddc8a2738e1dfb40446bd94b9e414e7d (diff)
downloadsigen-7c2bb4a47d6fc2bf59e425a6e06c60d53116c0f3.tar.gz
sigen-7c2bb4a47d6fc2bf59e425a6e06c60d53116c0f3.tar.xz
sigen-7c2bb4a47d6fc2bf59e425a6e06c60d53116c0f3.zip
Add game management to the widget
Diffstat (limited to 'sigmodr/tree')
-rw-r--r--sigmodr/tree/TreeWidget.cpp47
-rw-r--r--sigmodr/tree/TreeWidget.h10
2 files changed, 32 insertions, 25 deletions
diff --git a/sigmodr/tree/TreeWidget.cpp b/sigmodr/tree/TreeWidget.cpp
index 85d2973c..dcad6c34 100644
--- a/sigmodr/tree/TreeWidget.cpp
+++ b/sigmodr/tree/TreeWidget.cpp
@@ -77,26 +77,33 @@ const Game* TreeWidget::currentGame() const
// model()->setData(index, data.toString(), BaseModel::XmlRole);
// }
//
-// QList<const Game*> TreeWidget::openedGames() const
-// {
-// return m_games.keys();
-// }
-//
-// void TreeWidget::addGame(Game* game, const KUrl& url)
-// {
-// qobject_cast<TreeWidgetModel*>(model())->addGame(game);
-// m_games[game] = UrlDirty(url, false);
-// }
-//
-// void TreeWidget::deleteGame(const Game* game)
-// {
-// if (m_games.contains(game))
-// {
-// qobject_cast<TreeWidgetModel*>(model())->deleteGame(game);
-// m_games.remove(game);
-// }
-// }
-//
+QList<const Game*> TreeWidget::openedGames() const
+{
+ return m_games.keys();
+}
+
+void TreeWidget::addGame(Game* game, const KUrl& url)
+{
+ qobject_cast<TreeModel*>(model())->addGame(game);
+ m_games[game] = UrlDirty(url, false);
+}
+
+void TreeWidget::deleteGame(const Game* game)
+{
+ if (m_games.contains(game))
+ {
+ qobject_cast<TreeModel*>(model())->deleteGame(game);
+ m_games.remove(game);
+ }
+}
+
+void TreeWidget::deleteAllGames()
+{
+ const QList<const Game*> games = m_games.keys();
+ foreach (const Game* game, games)
+ deleteGame(game);
+}
+
bool TreeWidget::isOpen(const KUrl& url) const
{
if (url.isEmpty())
diff --git a/sigmodr/tree/TreeWidget.h b/sigmodr/tree/TreeWidget.h
index 2f81f7f8..fc2762f7 100644
--- a/sigmodr/tree/TreeWidget.h
+++ b/sigmodr/tree/TreeWidget.h
@@ -60,11 +60,11 @@ class SIGMODRTREE_EXPORT TreeWidget : public QTreeView
// QDomDocument copy(const QModelIndex& index);
// void paste(const QModelIndex& index, const QDomDocument& data);
//
-// QList<const Sigmod::Game*> openedGames() const;
-// void addGame(Sigmod::Game* game, const KUrl& url = KUrl());
-// void deleteGame(const Sigmod::Game* game);
-// void deleteAllGames();
-//
+ QList<const Sigmod::Game*> openedGames() const;
+ void addGame(Sigmod::Game* game, const KUrl& url = KUrl());
+ void deleteGame(const Sigmod::Game* game);
+ void deleteAllGames();
+
bool isOpen(const KUrl& url) const;
KUrl url(const Sigmod::Game* game) const;