Revision: 2921
http://skim-app.svn.sourceforge.net/skim-app/?rev=2921&view=rev
Author: hofman
Date: 2007-09-13 14:14:39 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
Allow multiple selection of bookmarks. Requires some more complex dragging
behavior.
Modified Paths:
--------------
trunk/Dutch.lproj/BookmarksWindow.nib/keyedobjects.nib
trunk/English.lproj/BookmarksWindow.nib/keyedobjects.nib
trunk/French.lproj/BookmarksWindow.nib/keyedobjects.nib
trunk/Italian.lproj/BookmarksWindow.nib/keyedobjects.nib
trunk/SKBookmarkController.h
trunk/SKBookmarkController.m
trunk/SKOutlineView.h
trunk/SKOutlineView.m
Modified: trunk/Dutch.lproj/BookmarksWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)
Modified: trunk/English.lproj/BookmarksWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)
Modified: trunk/French.lproj/BookmarksWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)
Modified: trunk/Italian.lproj/BookmarksWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)
Modified: trunk/SKBookmarkController.h
===================================================================
--- trunk/SKBookmarkController.h 2007-09-13 19:36:58 UTC (rev 2920)
+++ trunk/SKBookmarkController.h 2007-09-13 21:14:39 UTC (rev 2921)
@@ -38,7 +38,7 @@
#import <Cocoa/Cocoa.h>
[EMAIL PROTECTED] SKOutlineView, SKTableView, SKStatusBar;
[EMAIL PROTECTED] SKOutlineView, SKStatusBar;
enum {
SKBookmarkTypeBookmark,
@@ -51,6 +51,7 @@
NSMutableArray *bookmarks;
NSMutableArray *recentDocuments;
NSUndoManager *undoManager;
+ NSArray *draggedBookmarks;
}
+ (id)sharedBookmarkController;
@@ -118,5 +119,6 @@
- (void)removeChild:(SKBookmark *)child;
- (BOOL)isDescendantOf:(SKBookmark *)bookmark;
+- (BOOL)isDescendantOfArray:(NSArray *)bookmarks;
@end
Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m 2007-09-13 19:36:58 UTC (rev 2920)
+++ trunk/SKBookmarkController.m 2007-09-13 21:14:39 UTC (rev 2921)
@@ -42,7 +42,6 @@
#import "SKMainWindowController.h"
#import "Files_SKExtensions.h"
#import "SKOutlineView.h"
-#import "SKTableView.h"
#import "SKTypeSelectHelper.h"
#import "SKStatusBar.h"
#import "SKTextWithIconCell.h"
@@ -108,6 +107,7 @@
- (void)dealloc {
[bookmarks release];
[recentDocuments release];
+ [draggedBookmarks release];
[super dealloc];
}
@@ -187,6 +187,32 @@
[[self mutableArrayValueForKey:@"bookmarks"] removeObject:bookmark];
}
+- (NSArray *)minimumCoverForBookmarks:(NSArray *)items {
+ NSEnumerator *bmEnum = [items objectEnumerator];
+ SKBookmark *bm;
+ SKBookmark *lastBm = nil;
+ NSMutableArray *minimalCover = [NSMutableArray array];
+
+ while (bm = [bmEnum nextObject]) {
+ if ([bm isDescendantOf:lastBm] == NO) {
+ [minimalCover addObject:bm];
+ lastBm = bm;
+ }
+ }
+ return minimalCover;
+}
+
+- (NSArray *)draggedBookmarks {
+ return draggedBookmarks;
+}
+
+- (void)setDraggedBookmarks:(NSArray *)items {
+ if (draggedBookmarks != items) {
+ [draggedBookmarks release];
+ draggedBookmarks = [items retain];
+ }
+}
+
#pragma mark Recent Documents
- (NSArray *)recentDocuments {
@@ -381,9 +407,9 @@
}
- (BOOL)outlineView:(NSOutlineView *)ov writeItems:(NSArray *)items
toPasteboard:(NSPasteboard *)pboard {
- SKBookmark *item = [items objectAtIndex:0];
+ [self setDraggedBookmarks:[self minimumCoverForBookmarks:items]];
[pboard declareTypes:[NSArray arrayWithObjects:SKBookmarkRowsPboardType,
nil] owner:nil];
- [pboard setPropertyList:[NSNumber numberWithUnsignedInt:[outlineView
rowForItem:item]] forType:SKBookmarkRowsPboardType];
+ [pboard setData:[NSData data] forType:SKBookmarkRowsPboardType];
return YES;
}
@@ -403,7 +429,7 @@
[ov setDropItem:nil dropChildIndex:[bookmarks count]];
}
}
- return NSDragOperationMove;
+ return [item isDescendantOfArray:[self draggedBookmarks]] ?
NSDragOperationNone : NSDragOperationMove;
}
return NSDragOperationNone;
}
@@ -413,27 +439,24 @@
NSString *type = [pboard availableTypeFromArray:[NSArray
arrayWithObjects:SKBookmarkRowsPboardType, nil]];
if (type) {
- int draggedRow = [[pboard
propertyListForType:SKBookmarkRowsPboardType] intValue];
- SKBookmark *bookmark = [outlineView itemAtRow:draggedRow];
- if ([(SKBookmark *)item isDescendantOf:bookmark])
- return NO;
- if ([bookmark parent] == item) {
- int draggedIndex = [self indexOfChildBookmark:bookmark];
- if (index > draggedIndex)
+ NSEnumerator *bmEnum = [[self draggedBookmarks] objectEnumerator];
+ SKBookmark *bookmark;
+
+ while (bookmark = [bmEnum nextObject]) {
+ if (item == [bookmark parent] && index > (int)[self
indexOfChildBookmark:bookmark])
index--;
- if (index == draggedIndex)
- return NO;
- }
- [bookmark retain];
- [self removeChildBookmark:bookmark];
- [self bookmark:item insertChildBookmark:bookmark atIndex:index];
- [bookmark release];
- [outlineView selectRowIndexes:[NSIndexSet
indexSetWithIndex:[outlineView rowForItem:bookmark]] byExtendingSelection:NO];
+ [self removeChildBookmark:bookmark];
+ [self bookmark:item insertChildBookmark:bookmark atIndex:index++];
+ }
return YES;
}
return NO;
}
+- (void)outlineView:(NSOutlineView *)ov
dragEndedWithOperation:(NSDragOperation)operation {
+ [self setDraggedBookmarks:nil];
+}
+
#pragma mark NSOutlineView delegate methods
- (NSString *)outlineView:(NSOutlineView *)ov toolTipForCell:(NSCell *)cell
rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item
mouseLocation:(NSPoint)mouseLocation {
@@ -450,8 +473,10 @@
}
- (void)outlineView:(NSOutlineView *)ov deleteItems:(NSArray *)items {
- SKBookmark *item = [items objectAtIndex:0];
- [self removeChildBookmark:item];
+ NSEnumerator *itemEnum = [[self minimumCoverForBookmarks:items]
reverseObjectEnumerator];
+ SKBookmark *item;
+ while (item = [itemEnum nextObject])
+ [self removeChildBookmark:item];
}
- (BOOL)outlineView:(NSOutlineView *)ov canDeleteItems:(NSArray *)items {
@@ -687,4 +712,13 @@
return NO;
}
+- (BOOL)isDescendantOfArray:(NSArray *)bookmarks {
+ NSEnumerator *bmEnum = [bookmarks objectEnumerator];
+ SKBookmark *bm = nil;
+ while (bm = [bmEnum nextObject]) {
+ if ([self isDescendantOf:bm]) return YES;
+ }
+ return NO;
+}
+
@end
Modified: trunk/SKOutlineView.h
===================================================================
--- trunk/SKOutlineView.h 2007-09-13 19:36:58 UTC (rev 2920)
+++ trunk/SKOutlineView.h 2007-09-13 21:14:39 UTC (rev 2921)
@@ -68,3 +68,7 @@
- (BOOL)outlineView:(NSOutlineView *)anOutlineView canCopyItems:(NSArray
*)items;
- (NSMenu *)outlineView:(NSOutlineView *)anOutlineView
menuForTableColumn:(NSTableColumn *)tableColumn item:(id)item;
@end
+
[EMAIL PROTECTED] NSObject (SKOutlineViewDataSource)
+- (void)outlineView:(NSOutlineView *)anOutlineView
dragEndedWithOperation:(NSDragOperation)operation;
[EMAIL PROTECTED]
Modified: trunk/SKOutlineView.m
===================================================================
--- trunk/SKOutlineView.m 2007-09-13 19:36:58 UTC (rev 2920)
+++ trunk/SKOutlineView.m 2007-09-13 21:14:39 UTC (rev 2921)
@@ -179,4 +179,11 @@
return menu;
}
+- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint
operation:(NSDragOperation)operation {
+ if ([[SKOutlineView superclass] instancesRespondToSelector:_cmd])
+ [super draggedImage:anImage endedAt:aPoint operation:operation];
+ if ([[self dataSource]
respondsToSelector:@selector(outlineView:dragEndedWithOperation:)])
+ [[self dataSource] outlineView:self dragEndedWithOperation:operation];
+}
+
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit