|
From: Geisschaes <gei...@us...> - 2005-07-15 18:30:13
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28554 Modified Files: PlayerList.h PlayerList.m PlayerListsViewController.m PlayerTableController.m Log Message: dragging player into another list works for player table Index: PlayerListsViewController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerListsViewController.m,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PlayerListsViewController.m 3 Jul 2005 19:52:13 -0000 1.1 --- PlayerListsViewController.m 15 Jul 2005 18:29:31 -0000 1.2 *************** *** 38,41 **** --- 38,42 ---- [self setPlayerLists: [[Team currentTeam] userDefinedPlayerLists]]; [NSBundle loadNibNamed:@"PlayerListsView" owner: self]; + [tableView registerForDraggedTypes:[NSArray arrayWithObject:NSDragPboard]]; } return self; *************** *** 73,76 **** --- 74,89 ---- } + // drag & drop + + + - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op { + return NSDragOperationCopy; + } + - (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op { + NSArray *playerIDs = [[info draggingPasteboard] propertyListForType:NSDragPboard]; + PlayerList *toDrop = [playerLists objectAtIndex:row]; + [toDrop addPlayersWithIDs: playerIDs]; + return YES; + } @end Index: PlayerList.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.m,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PlayerList.m 3 Jul 2005 19:52:13 -0000 1.10 --- PlayerList.m 15 Jul 2005 18:29:31 -0000 1.11 *************** *** 28,31 **** --- 28,32 ---- #import "PlayerList.h" + #import "Team.h" @interface PlayerList (Private) *************** *** 106,110 **** } ! - (void) loadStatesFromFormerPlayerList: (PlayerList*) formerPlayerList date: (NSString*) date{ --- 107,129 ---- } ! - (BOOL) addPlayersWithIDs: (NSArray*) ids { ! PlayerList *mainList = [[Team currentTeam] allPlayersList]; ! if(self == mainList) { ! return NO; ! } ! else { ! NSEnumerator *en = [ids objectEnumerator]; ! NSNumber *currentID = nil; ! while(currentID = [en nextObject]) { ! int curId = [currentID intValue]; ! if([self playerWithID:curId] == nil) { ! Player *p = [mainList playerWithID:curId]; ! if(p) { ! [playerList addObject:p] ; ! } ! } ! } ! } ! } - (void) loadStatesFromFormerPlayerList: (PlayerList*) formerPlayerList date: (NSString*) date{ Index: PlayerTableController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableController.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PlayerTableController.m 12 Jun 2005 16:01:13 -0000 1.7 --- PlayerTableController.m 15 Jul 2005 18:29:31 -0000 1.8 *************** *** 46,49 **** --- 46,50 ---- [playerTable setTarget:self]; [playerTable setDoubleAction:@selector(doubleClicked)]; + [playerTable registerForDraggedTypes:[NSArray arrayWithObject:NSDragPboard]]; positiveDifferenceColor = [NSColor greenColor]; differenceFontSize = 9; *************** *** 94,97 **** --- 95,113 ---- } + // drag and drop + - (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray*)row toPasteboard:(NSPasteboard*)pboard { + [pboard declareTypes:[NSArray arrayWithObject:NSDragPboard] owner:self]; + NSArray *draggedPlayers = [playerListController selectedObjects]; + NSMutableArray *playerIDs = [NSMutableArray arrayWithCapacity:[draggedPlayers count]]; + Player *current = nil; + NSEnumerator *en = [draggedPlayers objectEnumerator]; + while(current = [en nextObject]) { + [playerIDs addObject:[NSNumber numberWithInt:[current playerID]]]; + } + + [pboard setPropertyList:playerIDs forType:NSDragPboard]; + return YES; + } + @end Index: PlayerList.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PlayerList.h 3 Jul 2005 19:52:13 -0000 1.8 --- PlayerList.h 15 Jul 2005 18:29:31 -0000 1.9 *************** *** 125,128 **** - (double) averageAge; ! @end --- 125,128 ---- - (double) averageAge; ! - (BOOL) addPlayersWithIDs: (NSArray*) ids; @end |