From 8739da1dee33d276a7be0a2c7644c1f2bfcf45ad Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Wed, 3 Jul 2002 00:38:37 +0000 Subject: [PATCH] Check in an interim fix for bug 154442: warn before deleting bookmarks. --- camino/BookmarksDataSource.mm | 29 ++++++++++++++++++++ camino/src/bookmarks/BookmarksDataSource.mm | 29 ++++++++++++++++++++ chimera/BookmarksDataSource.mm | 29 ++++++++++++++++++++ chimera/src/bookmarks/BookmarksDataSource.mm | 29 ++++++++++++++++++++ 4 files changed, 116 insertions(+) diff --git a/camino/BookmarksDataSource.mm b/camino/BookmarksDataSource.mm index abf34c872103..fbd0be87d634 100644 --- a/camino/BookmarksDataSource.mm +++ b/camino/BookmarksDataSource.mm @@ -283,6 +283,35 @@ if (index == -1) return; + // first, see how many items are selected + BOOL haveBookmarks = NO; + + NSEnumerator* testSelRows = [mOutlineView selectedRowEnumerator]; + for (NSNumber* currIndex = [testSelRows nextObject]; + currIndex != nil; + currIndex = [testSelRows nextObject]) + { + index = [currIndex intValue]; + BookmarkItem* item = [mOutlineView itemAtRow: index]; + if ([mOutlineView isExpandable: item]) { + // dumb check to see if we're deleting an empty folder. Should really + // recurse down + if ([self outlineView:mOutlineView numberOfChildrenOfItem: item] > 0) + haveBookmarks = YES; + } else + haveBookmarks = YES; + } + + // ideally, we should count the number of doomed bookmarks and tell the user + if (haveBookmarks) { + NSString *alert = NSLocalizedString(@"DeteleBookmarksAlert",@""); + NSString *message = NSLocalizedString(@"DeteleBookmarksMsg",@""); + NSString *okButton = NSLocalizedString(@"DeteleBookmarksOKButton",@""); + NSString *cancelButton = NSLocalizedString(@"DeteleBookmarksCancelButton",@""); + if (NSRunAlertPanel(alert, message, okButton, cancelButton, nil) != NSAlertDefaultReturn) + return; + } + // we'll run into problems if a parent item and one if its children are both selected. // 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 diff --git a/camino/src/bookmarks/BookmarksDataSource.mm b/camino/src/bookmarks/BookmarksDataSource.mm index abf34c872103..fbd0be87d634 100644 --- a/camino/src/bookmarks/BookmarksDataSource.mm +++ b/camino/src/bookmarks/BookmarksDataSource.mm @@ -283,6 +283,35 @@ if (index == -1) return; + // first, see how many items are selected + BOOL haveBookmarks = NO; + + NSEnumerator* testSelRows = [mOutlineView selectedRowEnumerator]; + for (NSNumber* currIndex = [testSelRows nextObject]; + currIndex != nil; + currIndex = [testSelRows nextObject]) + { + index = [currIndex intValue]; + BookmarkItem* item = [mOutlineView itemAtRow: index]; + if ([mOutlineView isExpandable: item]) { + // dumb check to see if we're deleting an empty folder. Should really + // recurse down + if ([self outlineView:mOutlineView numberOfChildrenOfItem: item] > 0) + haveBookmarks = YES; + } else + haveBookmarks = YES; + } + + // ideally, we should count the number of doomed bookmarks and tell the user + if (haveBookmarks) { + NSString *alert = NSLocalizedString(@"DeteleBookmarksAlert",@""); + NSString *message = NSLocalizedString(@"DeteleBookmarksMsg",@""); + NSString *okButton = NSLocalizedString(@"DeteleBookmarksOKButton",@""); + NSString *cancelButton = NSLocalizedString(@"DeteleBookmarksCancelButton",@""); + if (NSRunAlertPanel(alert, message, okButton, cancelButton, nil) != NSAlertDefaultReturn) + return; + } + // we'll run into problems if a parent item and one if its children are both selected. // 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 diff --git a/chimera/BookmarksDataSource.mm b/chimera/BookmarksDataSource.mm index abf34c872103..fbd0be87d634 100644 --- a/chimera/BookmarksDataSource.mm +++ b/chimera/BookmarksDataSource.mm @@ -283,6 +283,35 @@ if (index == -1) return; + // first, see how many items are selected + BOOL haveBookmarks = NO; + + NSEnumerator* testSelRows = [mOutlineView selectedRowEnumerator]; + for (NSNumber* currIndex = [testSelRows nextObject]; + currIndex != nil; + currIndex = [testSelRows nextObject]) + { + index = [currIndex intValue]; + BookmarkItem* item = [mOutlineView itemAtRow: index]; + if ([mOutlineView isExpandable: item]) { + // dumb check to see if we're deleting an empty folder. Should really + // recurse down + if ([self outlineView:mOutlineView numberOfChildrenOfItem: item] > 0) + haveBookmarks = YES; + } else + haveBookmarks = YES; + } + + // ideally, we should count the number of doomed bookmarks and tell the user + if (haveBookmarks) { + NSString *alert = NSLocalizedString(@"DeteleBookmarksAlert",@""); + NSString *message = NSLocalizedString(@"DeteleBookmarksMsg",@""); + NSString *okButton = NSLocalizedString(@"DeteleBookmarksOKButton",@""); + NSString *cancelButton = NSLocalizedString(@"DeteleBookmarksCancelButton",@""); + if (NSRunAlertPanel(alert, message, okButton, cancelButton, nil) != NSAlertDefaultReturn) + return; + } + // we'll run into problems if a parent item and one if its children are both selected. // 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 diff --git a/chimera/src/bookmarks/BookmarksDataSource.mm b/chimera/src/bookmarks/BookmarksDataSource.mm index abf34c872103..fbd0be87d634 100644 --- a/chimera/src/bookmarks/BookmarksDataSource.mm +++ b/chimera/src/bookmarks/BookmarksDataSource.mm @@ -283,6 +283,35 @@ if (index == -1) return; + // first, see how many items are selected + BOOL haveBookmarks = NO; + + NSEnumerator* testSelRows = [mOutlineView selectedRowEnumerator]; + for (NSNumber* currIndex = [testSelRows nextObject]; + currIndex != nil; + currIndex = [testSelRows nextObject]) + { + index = [currIndex intValue]; + BookmarkItem* item = [mOutlineView itemAtRow: index]; + if ([mOutlineView isExpandable: item]) { + // dumb check to see if we're deleting an empty folder. Should really + // recurse down + if ([self outlineView:mOutlineView numberOfChildrenOfItem: item] > 0) + haveBookmarks = YES; + } else + haveBookmarks = YES; + } + + // ideally, we should count the number of doomed bookmarks and tell the user + if (haveBookmarks) { + NSString *alert = NSLocalizedString(@"DeteleBookmarksAlert",@""); + NSString *message = NSLocalizedString(@"DeteleBookmarksMsg",@""); + NSString *okButton = NSLocalizedString(@"DeteleBookmarksOKButton",@""); + NSString *cancelButton = NSLocalizedString(@"DeteleBookmarksCancelButton",@""); + if (NSRunAlertPanel(alert, message, okButton, cancelButton, nil) != NSAlertDefaultReturn) + return; + } + // we'll run into problems if a parent item and one if its children are both selected. // 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