/** * Updates the property editor to contain the properties of the * property owners that are selected for editing in the given * property owner container. */ void RPropertyEditor::updateFromDocument(RDocument* document, bool onlyChanges, RS::EntityType entityTypeFilter) { if (updatesDisabled) { return; } if (document == NULL) { clearEditor(); return; } combinedProperties.clear(); combinedTypes.clear(); propertyOrder.clear(); groupOrder.clear(); updatesDisabled = true; // add all properties of the entities in the given document: QSet<RObject::Id> entityIds = document->querySelectedEntities(); QSet<RObject::Id>::iterator it; for (it = entityIds.begin(); it != entityIds.end(); ++it) { QSharedPointer<REntity> entity = document->queryEntityDirect(*it); if (entity.isNull()) { continue; } if (entityTypeFilter!=RS::EntityAll && entity->getType()!=entityTypeFilter) { continue; } updateEditor(*entity.data(), false, document); } // remove properties that are not shared by all selected entities: for (it = entityIds.begin(); it != entityIds.end(); ++it) { QSharedPointer<REntity> entity = document->queryEntityDirect(*it); if (entity.isNull()) { continue; } QPair<QVariant, RPropertyAttributes> p = entity->getProperty(REntity::PropertyType); RS::EntityType type = (RS::EntityType)p.first.toInt(); if (combinedTypes.contains(type)) { combinedTypes[type]++; } else { combinedTypes.insert(type, 1); } if (entityTypeFilter!=RS::EntityAll && entity->getType()!=entityTypeFilter) { continue; } QSet<RPropertyTypeId> propertyTypeIds = entity->getPropertyTypeIds(); QMultiMap<QString, QString> propertiesToKeep; QSet<RPropertyTypeId>::iterator it; for (it = propertyTypeIds.begin(); it != propertyTypeIds.end(); ++it) { propertiesToKeep.insert(it->getPropertyGroupTitle(), it->getPropertyTitle()); } removeAllButThese(propertiesToKeep); } updateGui(onlyChanges, entityTypeFilter); updatesDisabled = false; }
/** * Updates the property editor to contain the properties of the * objects that are selected for editing in the given document. */ void RPropertyEditor::updateFromDocument(RDocument* document, bool onlyChanges, RS::EntityType entityTypeFilter, bool manual) { if (updatesDisabled) { return; } if (document == NULL) { clearEditor(); return; } combinedProperties.clear(); combinedTypes.clear(); propertyOrder.clear(); groupOrder.clear(); updatesDisabled = true; // add all properties of the selected entities in the given document: QSet<RObject::Id> objectIds = document->queryPropertyEditorObjects(); QSet<RObject::Id>::iterator it; // only block ref and attributes selected: default to filter block ref: if (entityTypeFilter==RS::EntityAll && !manual) { bool foundBlockRef = false; bool foundAttribute = false; bool foundOther = false; for (it = objectIds.begin(); it != objectIds.end(); ++it) { QSharedPointer<RObject> obj = document->queryObjectDirect(*it); if (obj.isNull()) { continue; } if (!foundBlockRef && obj->getType()==RS::EntityBlockRef) { foundBlockRef = true; if (foundAttribute && foundOther) { break; } } if (!foundAttribute && obj->getType()==RS::EntityAttribute) { foundAttribute = true; if (foundBlockRef && foundOther) { break; } } if (!foundOther && obj->getType()!=RS::EntityBlockRef && obj->getType()!=RS::EntityAttribute) { foundOther = true; if (foundBlockRef && foundAttribute) { break; } } } if (foundBlockRef && foundAttribute && !foundOther) { entityTypeFilter = RS::EntityBlockRefAttr; } } for (it = objectIds.begin(); it != objectIds.end(); ++it) { QSharedPointer<RObject> obj = document->queryObjectDirect(*it); if (obj.isNull()) { continue; } if (entityTypeFilter!=RS::EntityAll && !checkType(obj->getType(), entityTypeFilter)) { continue; } updateEditor(*obj.data(), false, document); } RS::EntityType entityTypeFilterProp = entityTypeFilter; if (entityTypeFilterProp==RS::EntityBlockRefAttr) { // only block ref and attributes selected: show only block ref properties: entityTypeFilterProp = RS::EntityBlockRef; } // remove properties that are not shared by all selected entities: for (it = objectIds.begin(); it != objectIds.end(); ++it) { QSharedPointer<RObject> obj = document->queryObjectDirect(*it); if (obj.isNull()) { continue; } QPair<QVariant, RPropertyAttributes> p = obj->getProperty(REntity::PropertyType); RS::EntityType type = (RS::EntityType)p.first.toInt(); if (entityTypeFilterProp==RS::EntityAll || obj->getType()==entityTypeFilterProp) { bool customOnly = false; QSet<RPropertyTypeId> propertyTypeIds; if (combinedTypes.contains(type)) { // already filtered out property type IDs of this type, // only look into custom properties: propertyTypeIds = obj->getCustomPropertyTypeIds(); customOnly = true; } else { // not filtered out this type yet, look into all properties: propertyTypeIds = obj->getPropertyTypeIds(); } if (!propertyTypeIds.isEmpty()) { QMultiMap<QString, QString> propertiesToKeep; QSet<RPropertyTypeId>::iterator it; for (it = propertyTypeIds.begin(); it != propertyTypeIds.end(); ++it) { propertiesToKeep.insert(it->getPropertyGroupTitle(), it->getPropertyTitle()); } removeAllButThese(propertiesToKeep, customOnly); } } if (combinedTypes.contains(type)) { combinedTypes[type]++; } else { combinedTypes.insert(type, 1); } } if (combinedTypes.contains(RS::EntityBlockRef) && combinedTypes.contains(RS::EntityAttribute)) { combinedTypes.insert(RS::EntityBlockRefAttr, combinedTypes[RS::EntityBlockRef] + combinedTypes[RS::EntityBlockRefAttr]); } updateGui(onlyChanges, entityTypeFilter); updatesDisabled = false; }