Commit 0b44f559 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Kateryna Kostiuk
Browse files

conversation: filter out folders when chose a file to send

Change-Id: I17a5be0182fdf2f496a44ffb5133af07ed2628bc
parent 72f2a884
......@@ -60,13 +60,29 @@
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
highlight = true;
NSArray* classArray = [NSArray arrayWithObject:[NSURL class]];
NSArray* arrayOfURLs = [[sender draggingPasteboard] readObjectsForClasses:classArray options:nil];
NSMutableArray* files = [self filteredFilesURLSFrom: arrayOfURLs];
highlight = files.count > 0;
[self setNeedsDisplay: true];
return NSDragOperationCopy;
return files.count > 0 ? NSDragOperationCopy : NSDragOperationNone;
}
-(NSArray*)filteredFilesURLSFrom:(NSArray*)urls {
NSMutableArray* files = [[NSMutableArray alloc] init];
for (NSURL* url : urls) {
BOOL isDir = NO;
BOOL isFile = [[NSFileManager defaultManager] fileExistsAtPath:url.path isDirectory:&isDir];
if (isFile && !isDir) {
[files addObject: url];
}
}
return files;
}
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
highlight = false;
[self setNeedsDisplay: true];
}
......@@ -82,8 +98,9 @@
{
NSArray* classArray = [NSArray arrayWithObject:[NSURL class]];
NSArray* arrayOfURLs = [[sender draggingPasteboard] readObjectsForClasses:classArray options:nil];
[self.draggingDestinationDelegate filesDragged: arrayOfURLs];
return true;
NSMutableArray* files = [self filteredFilesURLSFrom: arrayOfURLs];
[self.draggingDestinationDelegate filesDragged: files];
return files.count > 0;
}
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment