void SDetailsViewBase::RestoreExpandedItems(TSharedPtr<FPropertyNode> InitialStartNode) { auto RootPropertyNode = GetRootNode(); check(RootPropertyNode.IsValid()); TSharedPtr<FPropertyNode> StartNode = InitialStartNode; if (!StartNode.IsValid()) { StartNode = RootPropertyNode; } ExpandedDetailNodes.Empty(); TArray<FString> ExpandedPropertyItems; FString ExpandedCustomItems; UStruct* BestBaseStruct = RootPropertyNode->GetBaseStructure(); //while a valid class, and we're either the same as the base class (for multiple actors being selected and base class is AActor) OR we're not down to AActor yet) for (UStruct* Struct = BestBaseStruct; Struct && ((BestBaseStruct == Struct) || (Struct != AActor::StaticClass())); Struct = Struct->GetSuperStruct()) { GConfig->GetSingleLineArray(TEXT("DetailPropertyExpansion"), *Struct->GetName(), ExpandedPropertyItems, GEditorPerProjectIni); SetExpandedItems(StartNode, ExpandedPropertyItems); } if (BestBaseStruct) { GConfig->GetString(TEXT("DetailCustomWidgetExpansion"), *BestBaseStruct->GetName(), ExpandedCustomItems, GEditorPerProjectIni); TArray<FString> ExpandedCustomItemsArray; ExpandedCustomItems.ParseIntoArray(ExpandedCustomItemsArray, TEXT(","), true); ExpandedDetailNodes.Append(ExpandedCustomItemsArray); } }
/** * Recursively sets expanded items for a node * * @param InNode The node to set expanded items on * @param OutExpandedItems List of expanded items to set */ void SetExpandedItems(TSharedPtr<FPropertyNode> InPropertyNode, const TSet<FString>& InExpandedItems) { if (InExpandedItems.Num() > 0) { const bool bWithArrayIndex = true; FString Path; Path.Empty(128); InPropertyNode->GetQualifiedName(Path, bWithArrayIndex); if (InExpandedItems.Contains(Path)) { InPropertyNode->SetNodeFlags(EPropertyNodeFlags::Expanded, true); } for (int32 NodeIndex = 0; NodeIndex < InPropertyNode->GetNumChildNodes(); ++NodeIndex) { SetExpandedItems(InPropertyNode->GetChildNode(NodeIndex), InExpandedItems); } } }