FavoritePaths

FavoritePaths

#Overview

name: FavoritePaths

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of FavoritePaths is to manage and store a list of favorite folder paths in the Unreal Engine 5 Content Browser. This setting variable is primarily used in the Content Browser’s path view functionality, specifically for the favorite paths feature.

FavoritePaths is primarily used by the Content Browser module, which is part of the Unreal Editor subsystem. It is referenced in the SPathView and SFavoritePathView classes, which are responsible for displaying and managing the folder structure in the Content Browser.

The value of this variable is set and retrieved using the ContentBrowserUtils::GetFavoriteFolders() function. It is stored in the engine’s configuration files (INI files) and loaded/saved when the Content Browser initializes or when changes are made to the favorite paths.

FavoritePaths interacts with other variables and functions within the Content Browser system, such as:

Developers should be aware of the following when using this variable:

  1. FavoritePaths stores paths as strings, which are converted to virtual paths when needed.
  2. Changes to FavoritePaths are persisted in the engine’s configuration files.
  3. The favorite paths feature affects the Content Browser’s filtering and display behavior.

Best practices when using this variable include:

  1. Use the ContentBrowserUtils::GetFavoriteFolders() function to access and modify the favorite paths instead of directly manipulating the variable.
  2. Ensure that path conversions between internal and virtual representations are handled correctly when working with favorite paths.
  3. Update the UI and filters appropriately when changes are made to the favorite paths list.
  4. Consider performance implications when working with large numbers of favorite paths, especially during filtering operations.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEditorPerProjectUserSettings.ini:15, section: [ContentBrowser]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Editor/ContentBrowser/Private/SPathView.cpp:2309

Scope (from outer to inner):

file
function     void SFavoritePathView::Populate

Source code excerpt:

	ClearTreeItems();

	const TArray<FString>& FavoritePaths = ContentBrowserUtils::GetFavoriteFolders();
	if (FavoritePaths.Num() > 0)
	{
		UContentBrowserDataSubsystem* ContentBrowserData = IContentBrowserDataModule::Get().GetSubsystem();
		const FContentBrowserDataCompiledFilter CompiledDataFilter = CreateCompiledFolderFilter();

		for (const FString& InvariantPath : FavoritePaths)
		{
			FName VirtualPath;
			IContentBrowserDataModule::Get().GetSubsystem()->ConvertInternalPathToVirtual(InvariantPath, VirtualPath);
			const FString Path = VirtualPath.ToString();

			// Use the whole path so we deliberately include any children of matched parents in the filtered list

#Loc: <Workspace>/Engine/Source/Editor/ContentBrowser/Private/SPathView.cpp:2360

Scope (from outer to inner):

file
function     void SFavoritePathView::SaveSettings

Source code excerpt:


	FString FavoritePathsString;
	const TArray<FString>& FavoritePaths = ContentBrowserUtils::GetFavoriteFolders();
	for (const FString& PathIt : FavoritePaths)
	{
		if (FavoritePathsString.Len() > 0)
		{
			FavoritePathsString += TEXT(",");
		}

#Loc: <Workspace>/Engine/Source/Editor/ContentBrowser/Private/SPathView.cpp:2371

Scope (from outer to inner):

file
function     void SFavoritePathView::SaveSettings

Source code excerpt:

	}

	GConfig->SetString(*IniSection, TEXT("FavoritePaths"), *FavoritePathsString, IniFilename);
	GConfig->Flush(false, IniFilename);
}

void SFavoritePathView::LoadSettings(const FString& IniFilename, const FString& IniSection, const FString& SettingsString)
{
	SPathView::LoadSettings(IniFilename, IniSection, SettingsString);

#Loc: <Workspace>/Engine/Source/Editor/ContentBrowser/Private/SPathView.cpp:2385

Scope (from outer to inner):

file
function     void SFavoritePathView::LoadSettings

Source code excerpt:

	FString FavoritePathsString;
	TArray<FString> NewFavoritePaths;
	if (GConfig->GetString(*IniSection, TEXT("FavoritePaths"), FavoritePathsString, IniFilename))
	{
		FavoritePathsString.ParseIntoArray(NewFavoritePaths, TEXT(","), /*bCullEmpty*/true);
	}

	if (NewFavoritePaths.Num() > 0)
	{

#Loc: <Workspace>/Engine/Source/Editor/ContentBrowser/Private/SPathView.cpp:2477

Scope (from outer to inner):

file
function     void SFavoritePathView::HandleItemDataUpdated

Source code excerpt:

	}

	TSet<FName> FavoritePaths;
	{
		const TArray<FString>& FavoritePathStrs = ContentBrowserUtils::GetFavoriteFolders();
		for (const FString& InvariantPath : FavoritePathStrs)
		{
			FName VirtualPath;
			IContentBrowserDataModule::Get().GetSubsystem()->ConvertInternalPathToVirtual(InvariantPath, VirtualPath);
			FavoritePaths.Add(VirtualPath);
		}
	}
	if (FavoritePaths.Num() == 0)
	{
		return;
	}

	// Don't allow the selection changed delegate to be fired here
	FScopedPreventTreeItemChangedDelegate DelegatePrevention(SharedThis(this));

#Loc: <Workspace>/Engine/Source/Editor/ContentBrowser/Private/SPathView.cpp:2511

Scope (from outer to inner):

file
function     void SFavoritePathView::HandleItemDataUpdated
lambda-function

Source code excerpt:

	};

	auto DoesItemPassFilter = [this, bFilteringByText, &CompiledDataFilter, &FavoritePaths](const FContentBrowserItemData& InItemData)
	{
		if (!FavoritePaths.Contains(InItemData.GetVirtualPath()))
		{
			return false;
		}

		UContentBrowserDataSource* ItemDataSource = InItemData.GetOwnerDataSource();
		if (!ItemDataSource->DoesItemPassFilter(InItemData, CompiledDataFilter))