bool FMRUList::VerifyMRUFile(int32 InItem) { check( InItem > -1 && InItem < GetMaxItems() ); const FString filename = Items[InItem]; // If the file doesn't exist, tell the user about it, remove the file from the list if( IFileManager::Get().FileSize( *filename ) == -1 ) { FMessageLog EditorErrors("EditorErrors"); FFormatNamedArguments Arguments; Arguments.Add(TEXT("FileName"), FText::FromString(filename)); EditorErrors.Warning(FText::Format( NSLOCTEXT("MRUList", "Error_FileDoesNotExist", "File does not exist : '{FileName}'. It will be removed from the recent items list."), Arguments ) ); EditorErrors.Notify(NSLOCTEXT("MRUList", "Notification_FileDoesNotExist", "File does not exist! Removed from recent items list!")); RemoveMRUItem( InItem ); WriteToINI(); return false; } // Otherwise, move the file to the top of the list MoveToTop( InItem ); WriteToINI(); return true; }
void FMRUList::AddMRUItem(const FString& InItem) { FString CleanedName = FPaths::ConvertRelativePathToFull(InItem); // See if the item already exists in the list. If so, // move it to the top of the list and leave. const int32 ItemIndex = Items.Find( CleanedName ); if ( ItemIndex != INDEX_NONE ) { MoveToTop( ItemIndex ); } else { // Item is new, so add it to the bottom of the list. if( CleanedName.Len() ) { new(Items) FString( *CleanedName ); MoveToTop( Items.Num()-1 ); } Cull(); } WriteToINI(); }
/** * Moves the specified favorites item to the head of the list * * @param Item Package name of the item to move */ void FMainMRUFavoritesList::MoveFavoritesItemToHead(const FString& Item) { if (ensureMsgf(FPackageName::IsValidLongPackageName(Item), TEXT("Item is not a valid long package name: '%s'"), *Item)) { if ( FavoriteItems.RemoveSingle(Item) == 1 ) { FavoriteItems.Insert( Item, 0 ); WriteToINI(); } } }
/** * Remove an item from the favorites list * * @param Item Package name of the item to remove from the favorites list */ void FMainMRUFavoritesList::RemoveFavoritesItem( const FString& Item ) { if (ensureMsgf(FPackageName::IsValidLongPackageName(Item), TEXT("Item is not a valid long package name: '%s'"), *Item)) { const int32 ItemIndex = FavoriteItems.Find( Item ); if ( ItemIndex != INDEX_NONE ) { FavoriteItems.RemoveAt( ItemIndex ); WriteToINI(); } } }
/** * Add a new item to the favorites list * * @param Item Package name of the item to add to the favorites list */ void FMainMRUFavoritesList::AddFavoritesItem( const FString& Item ) { if (ensureMsgf(FPackageName::IsValidLongPackageName(Item), TEXT("Item is not a valid long package name: '%s'"), *Item)) { // Only add the item if it isn't already a favorite! if ( !FavoriteItems.Contains( Item ) ) { FavoriteItems.Insert( Item, 0 ); WriteToINI(); } } }