// Copyright Epic Games, Inc. All Rights Reserved. #include "SStatList.h" #include "Internationalization/Text.h" #include "Layout/Children.h" #include "Misc/Attribute.h" #include "SlotBase.h" #include "Widgets/SBoxPanel.h" #include "Widgets/Text/STextBlock.h" #include "Widgets/Views/SListView.h" #include "Widgets/Views/STableRow.h" #define LOCTEXT_NAMESPACE "CSVtoSVG" void SStatList::Construct(const FArguments& Args) { StatListView = SNew(SListView>) .ListItemsSource(&StatList) .OnGenerateRow(this, &SStatList::OnGenerateWidgetForList); ChildSlot [ SNew(SHorizontalBox) + SHorizontalBox::Slot() [ StatListView.ToSharedRef() ] ]; } TSharedRef SStatList::OnGenerateWidgetForList(TSharedPtr InItem, const TSharedRef& OwnerTable) { return SNew(STableRow>, OwnerTable) [ SNew(STextBlock) .Text(FText::FromString(*InItem.Get())) ]; } void SStatList::UpdateStatList(const TArray& StatNames) { StatList.Empty(); for (const auto& StatName : StatNames) { StatList.Add(MakeShared(StatName)); } StatListView->RequestListRefresh(); } TArray SStatList::GetSelectedStats() const { TArray> SelectedItems = StatListView->GetSelectedItems(); TArray SelectedStats; for (const TSharedPtr& Item : SelectedItems) { if (Item.IsValid()) { SelectedStats.Add(*Item); } } return SelectedStats; } #undef LOCTEXT_NAMESPACE