Adium

Changeset 23645

Show
Ignore:
Timestamp:
05/25/2008 08:06:24 PM (6 months ago)
Author:
eharris
Message:

Adding drag and drop support to expanded contacts within the contact list. Still has some buglets to fix, but pretty much works. Fixes #9397

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/AIListController.m

    r23380 r23645  
    3030#import <Adium/AIListGroup.h> 
    3131#import <Adium/AIListObject.h> 
     32#import <Adium/AIMetaContact.h> 
    3233#import <Adium/AIListOutlineView.h> 
    3334#import <AIUtilities/AIAttributedStringAdditions.h> 
     
    610611                        } 
    611612                         
    612                          
    613613                        retVal = NSDragOperationPrivate; 
    614614                } 
     
    630630{ 
    631631        BOOL            success = YES; 
    632         NSString        *availableType = [[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObject:@"AIListObject"]]; 
     632        NSPasteboard *draggingPasteboard = [info draggingPasteboard]; 
     633        NSString        *availableType = [draggingPasteboard availableTypeFromArray:[NSArray arrayWithObject:@"AIListObject"]]; 
    633634         
    634635    if ([availableType isEqualToString:@"AIListObject"]) { 
     
    652653                        } 
    653654                         
     655                } else if ([item isMemberOfClass:[AIMetaContact class]]) { 
     656                        //Ordering gets implemented here. 
     657                        NSString        *availableType = [[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObject:@"AIListObject"]]; 
     658                         
     659                        //No longer in a drag, so allow tooltips again 
     660                        if ([availableType isEqualToString:@"AIListObject"]) { 
     661                                 
     662                                //If we don't have drag items, we are dragging from another instance; build our own dragItems array 
     663                                //using the supplied internalObjectIDs 
     664                                if (!dragItems) { 
     665                                        if ([[[info draggingPasteboard] availableTypeFromArray:[NSArray arrayWithObject:@"AIListObjectUniqueIDs"]] isEqualToString:@"AIListObjectUniqueIDs"]) { 
     666                                                NSArray                 *dragItemsUniqueIDs; 
     667                                                NSMutableArray  *arrayOfDragItems; 
     668                                                NSString                *uniqueID; 
     669                                                NSEnumerator    *enumerator; 
     670                                                 
     671                                                dragItemsUniqueIDs = [draggingPasteboard propertyListForType:@"AIListObjectUniqueIDs"]; 
     672                                                arrayOfDragItems = [NSMutableArray array]; 
     673                                                 
     674                                                enumerator = [dragItemsUniqueIDs objectEnumerator]; 
     675                                                while ((uniqueID = [enumerator nextObject])) { 
     676                                                        [arrayOfDragItems addObject:[[adium contactController] existingListObjectWithUniqueID:uniqueID]]; 
     677                                                } 
     678                                                 
     679                                                //We will release this when the drag is completed 
     680                                                dragItems = [arrayOfDragItems retain]; 
     681                                        } 
     682                                } 
     683                                 
     684                                //The tree root is not associated with our root contact list group, so we need to make that association here 
     685                                if (item == nil) item = contactList; 
     686                                 
     687                                //Move the list object to its new location 
     688                                if ([item isKindOfClass:[AIMetaContact class]]) { 
     689                                         
     690                                        NSMutableArray  *realDragItems = [NSMutableArray array]; 
     691                                        NSEnumerator    *enumerator; 
     692                                        AIListObject    *aDragItem; 
     693                                         
     694                                        enumerator = [dragItems objectEnumerator]; 
     695                                        while ((aDragItem = [enumerator nextObject])) { 
     696                                                if ([aDragItem isMemberOfClass:[AIListContact class]]) { 
     697                                                        //For listContacts, add all contacts with the same service and UID (on all accounts) 
     698                                                        [realDragItems addObjectsFromArray:[[[adium contactController] allContactsWithService:[aDragItem service]  
     699                                                                                                                                                                                                                          UID:[aDragItem UID] 
     700                                                                                                                                                                                                         existingOnly:YES] allObjects]]; 
     701                                                } else { 
     702                                                        [realDragItems addObject:aDragItem]; 
     703                                                } 
     704                                        } 
     705                                         
     706                                        [[adium contactController] moveListObjects:realDragItems intoObject:item index:index]; 
     707                                        [outlineView reloadData]; 
     708                                } 
     709                        } 
     710                         
     711                        //Call super and return its value 
     712                        return [super outlineView:outlineView acceptDrop:info item:item childIndex:index]; 
     713                         
     714                         
    654715                } else if ([item isKindOfClass:[AIListContact class]]) { 
    655716                        NSString        *promptTitle;