// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "IReflectionDataProvider.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Widgets/SCompoundWidget.h" #include "Widgets/Views/STreeView.h" #include "Misc/TextFilter.h" class UNDOHISTORY_API SUndoHistoryDetails : public SCompoundWidget { public: SLATE_BEGIN_ARGS(SUndoHistoryDetails) {} SLATE_END_ARGS() public: /** * Construct this widget * * @param InArgs The declaration data for this widget. */ void Construct(const FArguments& InArgs, TSharedRef InReflectionData = UE::UndoHistory::CreateDefaultReflectionProvider()); /** * Set the transaction to be displayed in the details panel. */ void SetSelectedTransaction(const struct FTransactionDiff& InTransactionDiff); /** * Clear the details panel. */ void Reset(); /** SWidget interface */ virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override; private: struct FUndoDetailsTreeNode; using FUndoDetailsTreeNodePtr = TSharedPtr; using FTreeItemTextFilter = TTextFilter; /** Tree node representing a changed object and its changed properties as children. */ struct FUndoDetailsTreeNode { FString Name; FString Type; FText ToolTip; TSharedPtr TransactionEvent; TArray Children; int32 PathDepth = 0; FUndoDetailsTreeNode(FString InName, FString InType, FText InToolTip, TSharedPtr InTransactionEvent = nullptr, int32 InPathDepth = 0) : Name(MoveTemp(InName)) , Type(MoveTemp(InType)) , ToolTip(MoveTemp(InToolTip)) , TransactionEvent(MoveTemp(InTransactionEvent)) , PathDepth(InPathDepth) {} }; private: /** Create a changed object node. */ FUndoDetailsTreeNodePtr CreateTreeNode(const FString& InObjectPathName, const FSoftClassPath& InObjectClass, const TSharedPtr& InEvent) const; /** Create a tooltip text for a property. */ FText CreateToolTipText(EPropertyFlags InFlags) const; /** Whether the type row will be generated */ bool SupportsTypeRow() const; /** Callback to handle a change in the filter box. */ void OnFilterTextChanged(const FText& InFilterText); /** Refresh the details tree view. */ void FullRefresh(); /** Populate the search strings for the filter. */ void PopulateSearchStrings(const FString&, TArray& OutSearchStrings) const; /** Populate the details tree. */ void Populate(); /** Callback for generating a UndoHistoryDetailsRow */ TSharedRef HandleGenerateRow(FUndoDetailsTreeNodePtr InNode, const TSharedRef& OwnerTable) const; /** Callback for getting the filter highlight text. */ FText HandleGetFilterHighlightText() const; /** Callback for getting the details visibility. */ EVisibility HandleDetailsVisibility() const; /** Callback for getting the transaction name. */ FText HandleTransactionName() const; /* Callback for getting the transaction id. */ FText HandleTransactionId() const; /** Callback for handling a click on the transaction id. */ void HandleTransactionIdNavigate(); private: /** Gives us information about property data (gives programs the opportunity to inject custom handler since not all reflection data is available in programs). */ TSharedPtr ReflectionData; /** Holds the ChangedObjects TreeView. */ TSharedPtr > ChangedObjectsTreeView; /** Holds the ChangedObjects to be used as an ItemSource to the TreeView. */ TArray ChangedObjects; /** Holds the ChangedObjects to be displayed. */ TArray FilteredChangedObjects; /** Holds the search box. */ TSharedPtr FilterTextBoxWidget; /** Holds the TransactionName. */ FText TransactionName; /** Holds the TransactionId. */ FText TransactionId; /** The TextFilter attached to the SearchBox widget of the UndoHistoryDetails panel. */ TSharedPtr SearchBoxFilter; /** If the details tree needs to be refreshed. */ bool bNeedsRefresh; /** If the tree items need to be expanded (ie. When the filter text changes). */ bool bNeedsExpansion; };