diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index dccd431e811..5c302479983 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1077,7 +1077,6 @@ void MainWindow::selectSceneItem(int i) sceneView->selectionModel()->select(s, QItemSelectionModel::ClearAndSelect); } - restoreCollapseState(); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_group_plugin.h b/Polyhedron/demo/Polyhedron/Polyhedron_demo_group_plugin.h index 2c9137811d0..12c70049654 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_group_plugin.h +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_group_plugin.h @@ -95,7 +95,7 @@ public : if(selected_group->getChildren().contains(item)) { //selected_group->removeChild(item); - trueScene->check_empty_group(item); + trueScene->remove_item_from_groups(item); item->has_group = 0; } diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 5ea561b13d2..61d0ebbedcc 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -59,7 +59,6 @@ Scene::addItem(Scene_item* item) this, SLOT(callDraw())); if(bbox_before + item->bbox() != bbox_before) { Q_EMIT updated_bbox(); } - QStandardItemModel::beginResetModel(); QList list; for(int i=0; i<5; i++) { @@ -70,9 +69,8 @@ Scene::addItem(Scene_item* item) for(int i=0; i<5; i++){ index_map[list.at(i)->index()] = m_entries.size() -1; } - Q_EMIT restoreCollapsedState(); Q_EMIT updated(); - QStandardItemModel::endResetModel(); + Q_EMIT restoreCollapsedState(); Item_id id = m_entries.size() - 1; Q_EMIT newItem(id); return id; @@ -130,6 +128,7 @@ Scene::erase(int index) QStandardItemModel::beginResetModel(); Q_EMIT updated(); QStandardItemModel::endResetModel(); + Q_EMIT restoreCollapsedState(); if(--index >= 0) return index; if(!m_entries.isEmpty()) @@ -178,6 +177,7 @@ Scene::erase(QList indices) QStandardItemModel::beginResetModel(); Q_EMIT updated(); QStandardItemModel::endResetModel(); + Q_EMIT restoreCollapsedState(); int index = max_index + 1 - indices.size(); if(index >= m_entries.size()) { @@ -191,19 +191,13 @@ Scene::erase(QList indices) } -void Scene::check_empty_group(Scene_item* item) +void Scene::remove_item_from_groups(Scene_item* item) { Q_FOREACH(Scene_group_item* group, m_group_entries) { if(group->getChildren().contains(item)) { group->removeChild(item); - if (group->getChildren().isEmpty()) - { - check_empty_group(group); - m_group_entries.removeOne(group); - m_entries.removeOne(group); - } } } check_first_group(); @@ -496,7 +490,7 @@ Scene::data(const QModelIndex &index, int role) const return QVariant(); } - int id = index_map[index];\ + int id = index_map[index]; if(id < 0 || id >= m_entries.size()) return QVariant(); if(role == ::Qt::ToolTipRole) @@ -972,8 +966,6 @@ QList Scene::item_entries() const void Scene::check_first_group() { - - if(m_group_entries.isEmpty() || m_group_entries.first()->name() != "new group") { m_group_entries.prepend(new Scene_group_item("new group")); @@ -1009,8 +1001,7 @@ void Scene::changeGroup(Scene_item *item, Scene_group_item *target_group) { if(group->getChildren().contains(item)) { - //group->removeChild(item); - check_empty_group(item); + remove_item_from_groups(item); break; } } diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h index a22c6bbf023..4cba0c0a307 100644 --- a/Polyhedron/demo/Polyhedron/Scene.h +++ b/Polyhedron/demo/Polyhedron/Scene.h @@ -118,7 +118,7 @@ public: public Q_SLOTS: //!insures that the groupview and data always has a "new group" in first position. void check_first_group(); - void check_empty_group(Scene_item* item); + void remove_item_from_groups(Scene_item* item); void group_added(); // Notify the scene that an item was modified void itemChanged(); // slots called by items themself