diff --git a/camino/src/bookmarks/BookmarkFolder.h b/camino/src/bookmarks/BookmarkFolder.h index 28cce810812..3c31823c1fe 100644 --- a/camino/src/bookmarks/BookmarkFolder.h +++ b/camino/src/bookmarks/BookmarkFolder.h @@ -119,6 +119,9 @@ enum { // Used for deleting bookmarks/bookmark arrays -(BOOL) deleteChild:(BookmarkItem *)aChild; +// used for batch notifying about changes to this folder's children (and descendants) +-(void) notifyChildrenChanged; + // Smart Folder only methods -(void) insertIntoSmartFolderChild:(BookmarkItem *)aItem; -(void) insertIntoSmartFolderChild:(BookmarkItem *)aItem atIndex:(unsigned)inIndex; diff --git a/camino/src/bookmarks/BookmarkFolder.mm b/camino/src/bookmarks/BookmarkFolder.mm index 78124321fb1..fb194c2e32a 100644 --- a/camino/src/bookmarks/BookmarkFolder.mm +++ b/camino/src/bookmarks/BookmarkFolder.mm @@ -1117,6 +1117,11 @@ static int BookmarkItemSort(id firstItem, id secondItem, void* context) [self itemUpdatedNote:kBookmarkItemChildrenChangedMask]; } +-(void) notifyChildrenChanged +{ + [self itemUpdatedNote:kBookmarkItemChildrenChangedMask]; +} + -(void) dockMenuChanged:(NSNotification *)note { if (([self isDockMenu]) && ([note object] != self)) diff --git a/camino/src/bookmarks/BookmarkViewController.mm b/camino/src/bookmarks/BookmarkViewController.mm index 0c83eeb40c9..6da7b674b91 100644 --- a/camino/src/bookmarks/BookmarkViewController.mm +++ b/camino/src/bookmarks/BookmarkViewController.mm @@ -26,7 +26,7 @@ * Simon Woodside * Josh Aas * Bruce Davidson - * Hakan Waara + * HÃ¥kan Waara * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -442,7 +442,6 @@ static const unsigned int TableViewSolidVerticalGridLineMask = 1; // A cheap way of having to avoid scanning the list to remove children is to have the // outliner collapse all items that are being deleted. This will cull the selection // for us and eliminate any children that happened to be selected. - BOOL allCollapsed = NO; id doomedItem; NSEnumerator* selRows; @@ -458,21 +457,35 @@ static const unsigned int TableViewSolidVerticalGridLineMask = 1; } } - // create array of items we need to delete. - NSArray* itemsToDelete = [mBookmarksOutlineView selectedItems]; - + [[BookmarkManager sharedBookmarkManager] startSuppressingChangeNotifications]; + + // all the parents of the children we need to notify, some may overlap, but in general + // that's pretty uncommon, so this is good enough. + NSMutableSet *parentsToNotify = [NSMutableSet set]; + // delete all bookmarks that are in our array - int count = [itemsToDelete count]; - for (int i = 0; i < count; i++) { - doomedItem = [itemsToDelete objectAtIndex:i]; - [(BookmarkFolder*)[doomedItem parent] deleteChild:doomedItem]; + NSEnumerator *e = [[mBookmarksOutlineView selectedItems] objectEnumerator]; + BookmarkItem *doomedBookmark = nil; + + while ((doomedBookmark = [e nextObject])) { + BookmarkFolder *currentParent = [doomedBookmark parent]; + [parentsToNotify addObject:currentParent]; + [currentParent deleteChild:doomedBookmark]; } - + + [[BookmarkManager sharedBookmarkManager] stopSuppressingChangeNotifications]; + + // notify observers that the parents have changed + e = [parentsToNotify objectEnumerator]; + BookmarkFolder *currentParent = nil; + while ((currentParent = [e nextObject])) + [currentParent notifyChildrenChanged]; + // restore selection to location near last item deleted or last item int total = [mBookmarksOutlineView numberOfRows]; if (index >= total) index = total - 1; - [mBookmarksOutlineView selectRow: index byExtendingSelection: NO]; + [mBookmarksOutlineView selectRow:index byExtendingSelection:NO]; } -(IBAction)openBookmark: (id)aSender