From a0da371e2af8e09b9eea9a3fcab8e922fd935620 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 17 Jul 2014 19:53:12 +0200 Subject: [PATCH] Fix a runtime bug The dynamic type of my `model` object is no longer a `Scene`, but that it a proxy model for the scene! --- Polyhedron/demo/Polyhedron/Scene.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index eb63ffc711a..c1f3f388afc 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace { void CGALglcolor(QColor c) @@ -588,7 +589,9 @@ bool SceneDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) { - Scene *scene = static_cast(model); + QAbstractProxyModel* proxyModel = dynamic_cast(model); + Q_ASSERT(proxyModel); + Scene *scene = dynamic_cast(proxyModel->sourceModel()); Q_ASSERT(scene); switch(index.column()) { case Scene::VisibleColumn: @@ -655,8 +658,8 @@ bool SceneDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, else { scene->item_B = index.row(); } - scene->dataChanged(scene->createIndex(Scene::ABColumn, 0), - scene->createIndex(Scene::ABColumn, scene->rowCount())); + scene->dataChanged(scene->createIndex(0, Scene::ABColumn), + scene->createIndex(scene->rowCount() - 1, Scene::ABColumn)); } return false; break;