[vlc-commits] macosx: playlist: simplify deletion code
David Fuhrmann
git at videolan.org
Sun Mar 8 17:49:19 CET 2015
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Mar 7 12:05:18 2015 +0100| [07e7944d755d524df15b87020b0ee9483f12ffe7] | committer: David Fuhrmann
macosx: playlist: simplify deletion code
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=07e7944d755d524df15b87020b0ee9483f12ffe7
---
modules/gui/macosx/intf.m | 1 +
modules/gui/macosx/playlist.h | 3 +++
modules/gui/macosx/playlist.m | 53 ++++++++++++-----------------------------
3 files changed, 19 insertions(+), 38 deletions(-)
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 70a51e5..d75d5d7 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1324,6 +1324,7 @@ static bool f_appExit = false;
int i_item = [o_val intValue];
[[[self playlist] model] removeItem:i_item];
+ [[self playlist] deletionCompleted];
}
diff --git a/modules/gui/macosx/playlist.h b/modules/gui/macosx/playlist.h
index 1eb3d44..a89c317 100644
--- a/modules/gui/macosx/playlist.h
+++ b/modules/gui/macosx/playlist.h
@@ -96,6 +96,9 @@
- (BOOL)isSelectionEmpty;
+- (void)deletionCompleted;
+
+
- (IBAction)playItem:(id)sender;
- (IBAction)revealItemInFinder:(id)sender;
- (IBAction)preparseItem:(id)sender;
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index 2de60b7..b1f30b5 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -562,56 +562,33 @@
[[[VLCMain sharedInstance] info] initPanel];
}
+- (void)deletionCompleted
+{
+ // retain selection before deletion
+ [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:retainedRowSelection] byExtendingSelection:NO];
+}
+
- (IBAction)deleteItem:(id)sender
{
- int i_count;
- NSIndexSet *o_selected_indexes;
- intf_thread_t * p_intf = VLCIntf;
- playlist_t * p_playlist = pl_Get(p_intf);
+ playlist_t * p_playlist = pl_Get(VLCIntf);
// check if deletion is allowed
if (![[self model] editAllowed])
return;
- o_selected_indexes = [o_outline_view selectedRowIndexes];
- i_count = [o_selected_indexes count];
+ NSIndexSet *o_selected_indexes = [o_outline_view selectedRowIndexes];
retainedRowSelection = [o_selected_indexes firstIndex];
if (retainedRowSelection == NSNotFound)
retainedRowSelection = 0;
+ [o_selected_indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
+ PLItem *o_item = [o_outline_view itemAtRow: idx];
+ if (!o_item)
+ return;
- NSUInteger indexes[i_count];
-// if (i_count == [o_outline_view numberOfRows]) {
-// PL_LOCK;
-// playlist_NodeDelete(p_playlist, [self currentPlaylistRoot], true, false);
-// PL_UNLOCK;
-// [self playlistUpdated];
-// return;
-// }
- [o_selected_indexes getIndexes:indexes maxCount:i_count inIndexRange:nil];
- for (int i = 0; i < i_count; i++) {
- PLItem *o_item = [o_outline_view itemAtRow: indexes[i]];
- [o_outline_view deselectRow: indexes[i]];
-
- /// TODO
-// if (p_item->i_children != -1) {
-// //is a node and not an item
-// if (playlist_Status(p_playlist) != PLAYLIST_STOPPED &&
-// [self isItem: playlist_CurrentPlayingItem(p_playlist) inNode: ((playlist_item_t *)[o_item pointerValue])
-// checkItemExistence: NO locked:YES] == YES)
-// // if current item is in selected node and is playing then stop playlist
-// playlist_Control(p_playlist, PLAYLIST_STOP, pl_Locked);
-//
-// playlist_NodeDelete(p_playlist, p_item, true, false);
-// } else
-
- playlist_DeleteFromInput(p_playlist, [o_item input], pl_Unlocked);
-// [[o_item parent] deleteChild:o_item];
-//
-// [o_outline_view reloadData];
- }
-
-// [self playlistUpdated];
+ // model deletion is done via callback
+ playlist_DeleteFromInput(p_playlist, [o_item input], pl_Unlocked);
+ }];
}
- (IBAction)sortNodeByName:(id)sender
More information about the vlc-commits
mailing list