diff --git a/GUI/coregui/Models/ModelMapper.cpp b/GUI/coregui/Models/ModelMapper.cpp index 0d23f0ee326c62de9895d30b48bd53e219dee41f..3ae037a1342d37b8c050f3828c2fc7bc2987819a 100644 --- a/GUI/coregui/Models/ModelMapper.cpp +++ b/GUI/coregui/Models/ModelMapper.cpp @@ -246,7 +246,7 @@ void ModelMapper::onBeginRemoveRows(const QModelIndex &parent, int first, int /* } if (nestling == 0) { - callOnChildrenChange(oldChild); + callOnChildrenChange(0); // inform siblings about the change if(SessionItem *parent = oldChild->parent()) { diff --git a/GUI/coregui/Models/ParticleLayoutItem.cpp b/GUI/coregui/Models/ParticleLayoutItem.cpp index 62a3ae4d5c159fc39919f83306999818bde5b53d..74dffde80f1a1f38fb9de7706f13b9795dc61e26 100644 --- a/GUI/coregui/Models/ParticleLayoutItem.cpp +++ b/GUI/coregui/Models/ParticleLayoutItem.cpp @@ -38,18 +38,20 @@ ParticleLayoutItem::ParticleLayoutItem() << Constants::InterferenceFunction2DParaCrystalType << Constants::InterferenceFunction1DLatticeType << Constants::InterferenceFunction2DLatticeType); - // FIXME: not updated when child get removed - mapper()->setOnChildPropertyChange( - [this](SessionItem *, const QString &) + mapper()->setOnChildrenChange( + [this](SessionItem* item) { + int count = 0; for (auto child_item : childItems()) { if (child_item->modelType() == Constants::InterferenceFunction2DParaCrystalType || child_item->modelType() == Constants::InterferenceFunction2DLatticeType) { - getItem(P_TOTAL_DENSITY)->setEnabled(false); - return; + count++; } } - getItem(P_TOTAL_DENSITY)->setEnabled(true); + if ((item && count > 0) || (!item && count > 1)) + getItem(P_TOTAL_DENSITY)->setEnabled(false); + else + getItem(P_TOTAL_DENSITY)->setEnabled(true); }); }