Tree: Adopt to special GeoFeatureGroup behaviours

This commit is contained in:
Stefan Tröger
2017-07-28 07:39:49 +02:00
committed by wmayer
parent b6f361b62b
commit 81572d4a14
3 changed files with 29 additions and 3 deletions

View File

@@ -1172,6 +1172,10 @@ void DocumentItem::populateItem(DocumentObjectItem *item, bool refresh) {
item->insertChild(i,childItem);
}
}
App::GeoFeatureGroupExtension* grp = nullptr;
if (item->object()->getObject()->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId()))
grp = item->object()->getObject()->getExtensionByType<App::GeoFeatureGroupExtension>();
for(++i;item->childCount()>i;) {
QTreeWidgetItem *childItem = item->child(i);
item->removeChild(childItem);
@@ -1183,8 +1187,14 @@ void DocumentItem::populateItem(DocumentObjectItem *item, bool refresh) {
// other parents not expanded yet. We don't want to traverse the
// whole tree to confirm that. Just let it be. If the other
// parent(s) later expanded, this child item will be moved from
// root to its parent.
// root to its parent.
if(obj->myselves->size()==1) {
// We only make a difference for geofeaturegroups,
// as otherwise it comes to confusing behavior to the user when things
// get claimed within the group (e.g. pad/sketch, or group)
if(grp && grp->hasObject(obj->object()->getObject(), true))
continue;
this->addChild(childItem);
continue;
}
@@ -1198,8 +1208,17 @@ void DocumentItem::slotChangeObject(const Gui::ViewProviderDocumentObject& view)
QString displayName = QString::fromUtf8(view.getObject()->Label.getValue());
FOREACH_ITEM(item,view)
item->setText(0, displayName);
populateItem(item,true);
populateItem(item, true);
END_FOREACH_ITEM
//if the item is in a GeoFeatureGroup we may need to update that too, as the claim children
//of the geofeaturegroup depends on what the childs claim
auto grp = App::GeoFeatureGroupExtension::getGroupOfObject(view.getObject());
if(grp) {
FOREACH_ITEM_NAME(item, grp->getNameInDocument())
populateItem(item, true);
END_FOREACH_ITEM
}
}
void DocumentItem::slotRenameObject(const Gui::ViewProviderDocumentObject& obj)

View File

@@ -76,9 +76,13 @@ std::vector<App::DocumentObject*> ViewProviderGeoFeatureGroupExtension::extensio
//object in the tree
std::vector<App::DocumentObject*> claim;
auto objs = ext->Group.getValues();
Base::Console().Message("Claim children GeoFatureGroup:\n");
for(auto obj : objs) {
if(obj->getInList().size()<=1)
if(obj->getInList().size()<=1) {
Base::Console().Message("%s\n", obj->getNameInDocument());
claim.push_back(obj);
}
}
return claim;
}

View File

@@ -111,6 +111,9 @@ void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) {
std::vector< App::DocumentObject* > ViewProviderGroupExtension::extensionClaimChildren(void) const {
auto* group = getExtendedViewProvider()->getObject()->getExtensionByType<App::GroupExtension>();
Base::Console().Message("Claim children group:\n");
for(auto obj : group->Group.getValues())
Base::Console().Message("%s\n", obj->getNameInDocument());
return std::vector<App::DocumentObject*>(group->Group.getValues());
}