[vlc-commits] [Git][videolan/vlc][master] 4 commits: macosx: Move reloadMediaLibraryFoldersForInputItems to VLCLibraryController
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Jun 5 11:56:15 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
f7d6475b by Claudio Cambra at 2024-06-05T11:32:31+00:00
macosx: Move reloadMediaLibraryFoldersForInputItems to VLCLibraryController
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
fbf88140 by Claudio Cambra at 2024-06-05T11:32:31+00:00
macosx: Reload parent media library folder when deleting media item
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
fbe9fe34 by Claudio Cambra at 2024-06-05T11:32:31+00:00
macosx: Reload parent media library folder when input item moved to trash
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
a2cc2440 by Claudio Cambra at 2024-06-05T11:32:31+00:00
macosx: Use decodedMrls to check if input item is inside monitored folder
Disparities between formatting of the monitored folder non decoded MRL
and the input item's can otherwise cause issues
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
5 changed files:
- modules/gui/macosx/library/VLCInputItem.m
- modules/gui/macosx/library/VLCLibraryController.h
- modules/gui/macosx/library/VLCLibraryController.m
- modules/gui/macosx/library/VLCLibraryDataTypes.m
- modules/gui/macosx/panels/VLCInformationWindowController.m
Changes:
=====================================
modules/gui/macosx/library/VLCInputItem.m
=====================================
@@ -27,6 +27,8 @@
#import "extensions/NSImage+VLCAdditions.h"
#import "extensions/NSString+Helpers.h"
+#import "library/VLCLibraryController.h"
+
#import <vlc_url.h>
NSString *VLCInputItemParsingSucceeded = @"VLCInputItemParsingSucceeded";
@@ -654,7 +656,7 @@ static const struct vlc_metadata_cbs preparseCallbacks = {
return;
}
- NSURL *pathUrl = [NSURL URLWithString:self.path];
+ NSURL * const pathUrl = [NSURL URLWithString:self.path];
if (pathUrl == nil) {
return;
}
@@ -662,6 +664,9 @@ static const struct vlc_metadata_cbs preparseCallbacks = {
[NSFileManager.defaultManager trashItemAtURL:pathUrl
resultingItemURL:nil
error:nil];
+
+ VLCLibraryController * const libraryController = VLCMain.sharedInstance.libraryController;
+ [libraryController reloadMediaLibraryFoldersForInputItems:@[self]];
}
- (void)revealInFinder
=====================================
modules/gui/macosx/library/VLCLibraryController.h
=====================================
@@ -24,6 +24,7 @@
#import <vlc_media_library.h>
+ at class VLCInputItem;
@class VLCLibraryModel;
@class VLCMediaLibraryMediaItem;
@@ -36,6 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
- (int)appendItemToPlaylist:(VLCMediaLibraryMediaItem *)mediaItem playImmediately:(BOOL)playImmediately;
- (int)appendItemsToPlaylist:(NSArray <VLCMediaLibraryMediaItem *> *)mediaItemArray playFirstItemImmediately:(BOOL)playFirstItemImmediately;
+- (void)reloadMediaLibraryFoldersForInputItems:(NSArray<VLCInputItem *> *)inputItems;
+
- (int)addFolderWithFileURL:(NSURL *)fileURL;
- (int)banFolderWithFileURL:(NSURL *)fileURL;
- (int)unbanFolderWithFileURL:(NSURL *)fileURL;
=====================================
modules/gui/macosx/library/VLCLibraryController.m
=====================================
@@ -23,8 +23,11 @@
#import "VLCLibraryController.h"
#import "main/VLCMain.h"
+
#import "playlist/VLCPlaylistController.h"
#import "playlist/VLCPlayerController.h"
+
+#import "library/VLCInputItem.h"
#import "library/VLCLibraryModel.h"
#import "library/VLCLibraryDataTypes.h"
@@ -165,6 +168,32 @@ typedef int (*folder_action_f)(vlc_medialibrary_t*, const char*);
return vlc_ml_reload_folder(_p_libraryInstance, fileURL.absoluteString.UTF8String);
}
+- (void)reloadMediaLibraryFoldersForInputItems:(NSArray<VLCInputItem *> *)inputItems
+{
+ NSArray<VLCMediaLibraryEntryPoint *> * const entryPoints = self.libraryModel.listOfMonitoredFolders;
+ NSMutableSet<NSString *> * const reloadMRLs = NSMutableSet.set;
+ NSMutableSet<VLCInputItem *> * const checkedInputItems = NSMutableSet.set;
+
+ for (VLCMediaLibraryEntryPoint * const entryPoint in entryPoints) {
+ for (VLCInputItem * const inputItem in inputItems) {
+ if ([checkedInputItems containsObject:inputItem]) {
+ continue;
+ }
+
+ if ([inputItem.decodedMRL hasPrefix:entryPoint.decodedMRL]) {
+ [reloadMRLs addObject:entryPoint.MRL];
+ [checkedInputItems addObject:inputItem];
+ break;
+ }
+ }
+ }
+
+ for (NSString * const entryPointMRL in reloadMRLs) {
+ NSURL * const entryPointURL = [NSURL URLWithString:entryPointMRL];
+ [self reloadFolderWithFileURL:entryPointURL];
+ }
+}
+
- (int)clearHistory
{
if (!_p_libraryInstance) {
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -25,6 +25,7 @@
#import "main/VLCMain.h"
#import "extensions/NSString+Helpers.h"
#import "library/VLCInputItem.h"
+#import "library/VLCLibraryController.h"
#import <vlc_media_library.h>
#import <vlc_url.h>
@@ -1354,12 +1355,15 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
- (void)moveToTrash
{
- NSFileManager *fileManager = [NSFileManager defaultManager];
- for (VLCMediaLibraryFile *fileToTrash in _files) {
+ NSFileManager * const fileManager = NSFileManager.defaultManager;
+ for (VLCMediaLibraryFile * const fileToTrash in self.files) {
[fileManager trashItemAtURL:fileToTrash.fileURL
resultingItemURL:nil
error:nil];
}
+
+ VLCLibraryController * const libraryController = VLCMain.sharedInstance.libraryController;
+ [libraryController reloadMediaLibraryFoldersForInputItems:@[self.inputItem]];
}
@end
=====================================
modules/gui/macosx/panels/VLCInformationWindowController.m
=====================================
@@ -489,28 +489,7 @@ settingsChanged = settingsChanged || _##field##TextField.settingChanged;
- (void)reloadMediaLibraryFoldersForInputItems:(NSArray<VLCInputItem *> *)inputItems
{
VLCLibraryController * const libraryController = VLCMain.sharedInstance.libraryController;
- NSArray<VLCMediaLibraryEntryPoint *> * const entryPoints = libraryController.libraryModel.listOfMonitoredFolders;
- NSMutableSet<NSString *> * const reloadMRLs = NSMutableSet.set;
- NSMutableSet<VLCInputItem *> * const checkedInputItems = NSMutableSet.set;
-
- for (VLCMediaLibraryEntryPoint * const entryPoint in entryPoints) {
- for (VLCInputItem * const inputItem in inputItems) {
- if ([checkedInputItems containsObject:inputItem]) {
- continue;
- }
-
- if ([inputItem.MRL hasPrefix:entryPoint.MRL]) {
- [reloadMRLs addObject:entryPoint.MRL];
- [checkedInputItems addObject:inputItem];
- break;
- }
- }
- }
-
- for (NSString * const entryPointMRL in reloadMRLs) {
- NSURL * const entryPointURL = [NSURL URLWithString:entryPointMRL];
- [libraryController reloadFolderWithFileURL:entryPointURL];
- }
+ [libraryController reloadMediaLibraryFoldersForInputItems:inputItems];
}
- (void)saveInputItemsMetadata:(NSArray<VLCInputItem *> *)inputItems
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bcc33a20200f02826abf91da8d9287f41c30d4ac...a2cc24400faee2d93a480fac63883017c4fd9873
--
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bcc33a20200f02826abf91da8d9287f41c30d4ac...a2cc24400faee2d93a480fac63883017c4fd9873
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list