当前位置: 首页>>代码示例>>C++>>正文


C++ TSharedPtr::CanFilter方法代码示例

本文整理汇总了C++中TSharedPtr::CanFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedPtr::CanFilter方法的具体用法?C++ TSharedPtr::CanFilter怎么用?C++ TSharedPtr::CanFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TSharedPtr的用法示例。


在下文中一共展示了TSharedPtr::CanFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Populate

void SLargeAssetTypeTreeWidget::Populate(const TArray<FString>& InSelectedAssetTypeClassNames)
{
	AssetCategories.Empty();

	TMap<EAssetTypeCategories::Type, FLargeAssetTypeTreeItemPtr> CategoryMap;
	AddCategoriesToCategoryMap(CategoryMap);
	
	FAssetToolsModule& AssetToolsModule = 
		FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
	TArray<FAssetTypeWeakPtr> AssetTypes;
	AssetToolsModule.Get().GetAssetTypeActionsList(AssetTypes);
		
	struct FOrderAssetTypesByNameAsc
	{
		// return true if A should appear before B, false otherwise
		bool operator()(const FAssetTypeWeakPtr& A, const FAssetTypeWeakPtr& B) const
		{
			return A.Pin()->GetName().CompareTo(B.Pin()->GetName()) < 0;
		}
	};

	AssetTypes.Sort(FOrderAssetTypesByNameAsc());

	// assign all the asset types to the corresponding category tree items
	for (const auto AssetTypeWeakPtr : AssetTypes)
	{
		TSharedPtr<IAssetType> AssetType = AssetTypeWeakPtr.Pin();
		// for consistency ignore asset types that can't be filtered by in the content browser,
		// usually this is because the asset type is not fully supported
		if (AssetType.IsValid() && AssetType->CanFilter())
		{
			TArray<FLargeAssetTypeTreeItemWeakPtr> AssetTypeItems;
			for (auto CategoryMapEntry : CategoryMap)
			{
				if (AssetType->GetCategories() & CategoryMapEntry.Key)
				{
					FLargeAssetTypeTreeItemPtr AssetTypeItem = 
						MakeShareable(
							new FLargeAssetTypeTreeItem(*AssetType.Get(), CategoryMapEntry.Value)
						);

					AssetTypeItems.Add(AssetTypeItem);
					CategoryMapEntry.Value->Children.Add(AssetTypeItem);
				}
			}

			if (AssetTypeItems.Num() == 1)
			{
				auto AssetTypeItem = AssetTypeItems[0].Pin();
				AssetTypeItem->SetIsSelected(
					InSelectedAssetTypeClassNames.Contains(AssetTypeItem->AssetTypeClassName)
				);
			}
			else if (AssetTypeItems.Num() > 1)
			{
				auto AssetTypeItem = AssetTypeItems[0].Pin();
				FLargeAssetTypeTreeItem::CreateSharedState(
					AssetTypeItems, 
					InSelectedAssetTypeClassNames.Contains(AssetTypeItem->AssetTypeClassName)
				);
			}
		}
	}

	for (const auto CategoryMapEntry : CategoryMap)
	{
		AssetCategories.Add(CategoryMapEntry.Value);
	}

	TreeView->RequestTreeRefresh();
}
开发者ID:barold,项目名称:ue4-hg-plugin,代码行数:71,代码来源:SLargeAssetTypeTreeWidget.cpp


注:本文中的TSharedPtr::CanFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。