| 81 | } |
| 82 | |
| 83 | std::vector<DocumentObject*> GroupExtension::addObjects(std::vector<DocumentObject*> objs) |
| 84 | { |
| 85 | |
| 86 | std::vector<DocumentObject*> added; |
| 87 | std::vector<DocumentObject*> grp = Group.getValues(); |
| 88 | for (auto obj : objs) { |
| 89 | |
| 90 | if (!allowObject(obj)) { |
| 91 | continue; |
| 92 | } |
| 93 | |
| 94 | if (hasObject(obj)) { |
| 95 | continue; |
| 96 | } |
| 97 | |
| 98 | // only one group per object. Note that it is allowed to be in a group and geofeaturegroup. |
| 99 | // However, getGroupOfObject() returns only normal groups, no GeoFeatureGroups. Hence this |
| 100 | // works. |
| 101 | auto* group = App::GroupExtension::getGroupOfObject(obj); |
| 102 | if (group && group != getExtendedObject()) { |
| 103 | group->getExtensionByType<App::GroupExtension>()->removeObject(obj); |
| 104 | } |
| 105 | |
| 106 | // if we are in a geofeaturegroup we need to ensure the object is too |
| 107 | auto geogrp = GeoFeatureGroupExtension::getGroupOfObject(getExtendedObject()); |
| 108 | auto objgrp = GeoFeatureGroupExtension::getGroupOfObject(obj); |
| 109 | if (geogrp != objgrp) { |
| 110 | // what to do depends on if we are in geofeature group or not |
| 111 | if (geogrp) { |
| 112 | geogrp->getExtensionByType<GeoFeatureGroupExtension>()->addObject(obj); |
| 113 | } |
| 114 | else { |
| 115 | objgrp->getExtensionByType<GeoFeatureGroupExtension>()->removeObject(obj); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | grp.push_back(obj); |
| 120 | added.push_back(obj); |
| 121 | } |
| 122 | |
| 123 | Group.setValues(grp); |
| 124 | |
| 125 | return added; |
| 126 | } |
| 127 | |
| 128 | std::vector<DocumentObject*> GroupExtension::setObjects(std::vector<DocumentObject*> obj) |
| 129 | { |
nothing calls this directly
no test coverage detected