Permalink
Browse files

MetadataFilter works again, and now also with drag-drop and delete su…

…pport
  • Loading branch information...
1 parent 4815755 commit 6a354cab22d802c2402a15570319130a43fb37f8 @pieteromvlee pieteromvlee committed Feb 8, 2011
@@ -1,10 +1,5 @@
-//
-// BCCollectionView+Dragging.h
-// Fontcase
-//
// Created by Pieter Omvlee on 13/12/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import "BCCollectionView.h"
@@ -1,10 +1,5 @@
-//
-// BCCollectionView+Dragging.m
-// Fontcase
-//
// Created by Pieter Omvlee on 13/12/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import "BCCollectionView+Dragging.h"
@@ -29,7 +24,7 @@ - (void)initiateDraggingSessionWithEvent:(NSEvent *)anEvent
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[self delegateWriteIndexes:selectionIndexes toPasteboard:pasteboard];
-
+ [self retain];
[self dragImage:[dragImage autorelease]
at:NSMakePoint(NSMinX(itemRect), NSMaxY(itemRect))
offset:NSMakeSize(0, 0)
@@ -39,22 +34,43 @@ - (void)initiateDraggingSessionWithEvent:(NSEvent *)anEvent
slideBack:YES];
}
+- (void)draggedImage:(NSImage *)anImage beganAt:(NSPoint)aPoint
+{
+ [self retain];
+}
+
+- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
+{
+ [self autorelease];
+}
+
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
+{
+ return [self draggingUpdated:sender];
+}
+
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
if (dragHoverIndex != NSNotFound)
[self setNeedsDisplayInRect:[self rectOfItemAtIndex:dragHoverIndex]];
NSPoint mouse = [self convertPoint:[sender draggingLocation] fromView:nil];
NSUInteger index = [self indexOfItemAtPoint:mouse];
-
NSDragOperation operation = NSDragOperationNone;
- if ([selectionIndexes containsIndex:index])
- [self setDragHoverIndex:NSNotFound];
- else if ([self delegateCanDrop:sender onIndex:index]) {
- [self setDragHoverIndex:index];
- operation = NSDragOperationMove;
- } else
- [self setDragHoverIndex:NSNotFound];
+ if ([sender draggingSource] == self) {
+ if ([selectionIndexes containsIndex:index])
+ [self setDragHoverIndex:NSNotFound];
+ else if ([self delegateCanDrop:sender onIndex:index]) {
+ [self setDragHoverIndex:index];
+ operation = NSDragOperationMove;
+ } else
+ [self setDragHoverIndex:NSNotFound];
+ } else {
+ if ([self delegateCanDrop:sender onIndex:index]) {
+ [self setDragHoverIndex:index];
+ operation = NSDragOperationCopy;
+ }
+ }
if (dragHoverIndex != NSNotFound)
[self setNeedsDisplayInRect:[self rectOfItemAtIndex:dragHoverIndex]];
@@ -86,11 +102,12 @@ - (void)draggingExited:(id<NSDraggingInfo>)sender
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
+ id item = nil;
+ if (dragHoverIndex >= 0 && dragHoverIndex <[contentArray count])
+ item = [contentArray objectAtIndex:dragHoverIndex];
+
if ([delegate respondsToSelector:@selector(collectionView:performDragOperation:onViewController:forItem:)])
- return [delegate collectionView:self
- performDragOperation:sender
- onViewController:[self viewControllerForItemAtIndex:dragHoverIndex]
- forItem:[contentArray objectAtIndex:dragHoverIndex]];
+ return [delegate collectionView:self performDragOperation:sender onViewController:[self viewControllerForItemAtIndex:dragHoverIndex] forItem:item];
else
return NO;
}
@@ -1,10 +1,5 @@
-//
-// BCCollectionView+Keyboard.h
-// Fontcase
-//
// Created by Pieter Omvlee on 25/11/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import "BCCollectionView.h"
@@ -1,10 +1,5 @@
-//
-// BCCollectionView+Keyboard.m
-// Fontcase
-//
// Created by Pieter Omvlee on 25/11/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import "BCCollectionView+Keyboard.h"
View
@@ -1,10 +1,5 @@
-//
-// BCCollectionView+Mouse.h
-// Fontcase
-//
// Created by Pieter Omvlee on 25/11/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import "BCCollectionView.h"
View
@@ -1,10 +1,5 @@
-//
-// BCCollectionView+Mouse.m
-// Fontcase
-//
// Created by Pieter Omvlee on 25/11/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import "BCCollectionView+Mouse.h"
#import "BCGeometryExtensions.h"
View
@@ -1,10 +1,5 @@
-//
-// BCCollectionView.h
-// Fontcase
-//
// Created by Pieter Omvlee on 24/11/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import <Cocoa/Cocoa.h>
#import "BCCollectionViewDelegate.h"
View
@@ -1,10 +1,5 @@
-//
-// BCCollectionView.m
-// Fontcase
-//
// Created by Pieter Omvlee on 24/11/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import "BCCollectionView.h"
#import "BCGeometryExtensions.h"
@@ -1,10 +1,5 @@
-//
-// BCCollectionViewDelegate.h
-// Fontcase
-//
// Created by Pieter Omvlee on 25/11/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import <Cocoa/Cocoa.h>
View
@@ -1,10 +1,5 @@
-//
-// BCGeometryExtensions.h
-// BCCollectionViewTest
-//
// Created by Pieter Omvlee on 25/11/2010.
// Copyright 2010 Bohemian Coding. All rights reserved.
-//
#import <Foundation/Foundation.h>

0 comments on commit 6a354ca

Please sign in to comment.