summaryrefslogtreecommitdiffstats
path: root/sigmodr/tree
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-05-21 01:46:56 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-05-21 01:47:42 -0400
commitd64b44e4ddc8a2738e1dfb40446bd94b9e414e7d (patch)
treef921f8229b2045fc06f0a2e8d622968d2aa8b6e6 /sigmodr/tree
parent8efe5af96d26d8663f1be9401d98566c3aff9a65 (diff)
downloadsigen-d64b44e4ddc8a2738e1dfb40446bd94b9e414e7d.tar.gz
sigen-d64b44e4ddc8a2738e1dfb40446bd94b9e414e7d.tar.xz
sigen-d64b44e4ddc8a2738e1dfb40446bd94b9e414e7d.zip
Get the current game from the currently selected index
Diffstat (limited to 'sigmodr/tree')
-rw-r--r--sigmodr/tree/TreeWidget.cpp17
-rw-r--r--sigmodr/tree/TreeWidget.h4
2 files changed, 7 insertions, 14 deletions
diff --git a/sigmodr/tree/TreeWidget.cpp b/sigmodr/tree/TreeWidget.cpp
index 383f473a..85d2973c 100644
--- a/sigmodr/tree/TreeWidget.cpp
+++ b/sigmodr/tree/TreeWidget.cpp
@@ -60,18 +60,11 @@ ObjectUI* TreeWidget::editorWidget(const QModelIndex& index)
return widget;
}
-// const Game* TreeWidget::currentGame() const
-// {
-// QModelIndex index = currentIndex();
-// if (index.isValid())
-// {
-// const Object* object = static_cast<BaseModel*>(index.internalPointer())->object();
-// if (object)
-// return object->game();
-// }
-// return NULL;
-// }
-//
+const Game* TreeWidget::currentGame() const
+{
+ return qobject_cast<TreeModel*>(model())->findGame(currentIndex());
+}
+
// QDomDocument TreeWidget::copy(const QModelIndex& index)
// {
// QDomDocument xml;
diff --git a/sigmodr/tree/TreeWidget.h b/sigmodr/tree/TreeWidget.h
index 3898f4b2..2f81f7f8 100644
--- a/sigmodr/tree/TreeWidget.h
+++ b/sigmodr/tree/TreeWidget.h
@@ -55,8 +55,8 @@ class SIGMODRTREE_EXPORT TreeWidget : public QTreeView
QStringList dropTypes(const QModelIndex& index) const;
Widgets::ObjectUI* editorWidget(const QModelIndex& index);
-// const Sigmod::Game* currentGame() const;
-//
+ const Sigmod::Game* currentGame() const;
+
// QDomDocument copy(const QModelIndex& index);
// void paste(const QModelIndex& index, const QDomDocument& data);
//