Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2722 Modified Files: PlayerList.h PlayerList.m PlayerTableController.h PlayerTableController.m PlayerTableView.m PositionsController.m Team.h Team.m Log Message: implementing the context menu for the tables. add to groups works now Index: PositionsController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PositionsController.m,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PositionsController.m 17 Sep 2005 14:05:48 -0000 1.11 --- PositionsController.m 17 Sep 2005 16:22:27 -0000 1.12 *************** *** 159,162 **** --- 159,166 ---- } + - (void) addSelectedPlayersToPlayerList: (PlayerList*) aPlayerList { + [aPlayerList addPlayers: [self selectedPlayers]]; + } + -(void) doubleClicked { [[MainController mainController] showPlayerDetailsWindowWithPlayer:[self selectedPlayer]]; Index: Team.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Team.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Team.h 18 Jul 2005 19:12:37 -0000 1.16 --- Team.h 17 Sep 2005 16:22:27 -0000 1.17 *************** *** 83,87 **** - (BOOL) saveUserDefinedPlayerLists: (NSString*) filename; ! - (NSMutableArray *) userDefinedPlayerLists; --- 83,87 ---- - (BOOL) saveUserDefinedPlayerLists: (NSString*) filename; ! - (PlayerList*)userDefinedPlayerListWithName: (NSString*) aName; - (NSMutableArray *) userDefinedPlayerLists; *************** *** 155,158 **** --- 155,160 ---- - (Club *) club; + + /*! @method currentTeam Index: Team.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Team.m,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Team.m 14 Sep 2005 15:32:06 -0000 1.30 --- Team.m 17 Sep 2005 16:22:27 -0000 1.31 *************** *** 208,212 **** - (Club *) club { return club; } ! + (Team*) currentTeam { --- 208,221 ---- - (Club *) club { return club; } ! - (PlayerList*)userDefinedPlayerListWithName: (NSString*) aName { ! NSEnumerator *en = [userDefinedPlayerLists objectEnumerator]; ! PlayerList *current; ! while(current=[en nextObject]) { ! if([[current listName] isEqualToString:aName]) { ! return current; ! } ! } ! return nil; ! } + (Team*) currentTeam { Index: PlayerTableView.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableView.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PlayerTableView.m 17 Sep 2005 14:05:48 -0000 1.2 --- PlayerTableView.m 17 Sep 2005 16:22:27 -0000 1.3 *************** *** 57,60 **** --- 57,62 ---- - (IBAction) addToGroup: (id)sender { NSString *groupName = [sender title]; + PlayerList *list = [[Team currentTeam] userDefinedPlayerListWithName: groupName]; + [controller addSelectedPlayersToPlayerList:list]; } - (void) awakeFromNib { Index: PlayerTableController.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableController.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PlayerTableController.h 17 Sep 2005 14:05:48 -0000 1.7 --- PlayerTableController.h 17 Sep 2005 16:22:27 -0000 1.8 *************** *** 52,55 **** -(void) removeSelectedPlayers; ! @end --- 52,55 ---- -(void) removeSelectedPlayers; ! - (void) addSelectedPlayersToPlayerList: (PlayerList*) aPlayerList; @end Index: PlayerList.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PlayerList.h 14 Sep 2005 16:20:08 -0000 1.13 --- PlayerList.h 17 Sep 2005 16:22:27 -0000 1.14 *************** *** 136,139 **** --- 136,141 ---- -(BOOL) addPlayerWithID: (int) aPlayerID; - (BOOL) addPlayersWithIDs: (NSArray*) ids; + -(BOOL) addPlayer: (Player*) aPlayer; + - (BOOL) addPlayers: (NSArray*) players; - (BOOL) removePlayersWithIDs: (NSArray*) ids; - (BOOL) removePlayerWithID: (int) aPlayerID; Index: PlayerList.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.m,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PlayerList.m 14 Sep 2005 16:20:08 -0000 1.15 --- PlayerList.m 17 Sep 2005 16:22:27 -0000 1.16 *************** *** 162,165 **** --- 162,185 ---- return YES; } + - (BOOL) addPlayers: (NSArray*) players { + PlayerList *mainList = [[Team currentTeam] allPlayersList]; + if(self == mainList) { + return NO; + } + else { + NSEnumerator *en = [players objectEnumerator]; + Player *current = nil; + while(current = [en nextObject]) { + int curId = [current playerID]; + if([self playerWithID:curId] == nil) { + Player *p = [mainList playerWithID:curId]; + if(p) { + [playerList addObject:p] ; + } + } + } + } + return YES; + } -(BOOL) addPlayerWithID: (int) aPlayerID { *************** *** 173,176 **** --- 193,208 ---- return NO; } + + -(BOOL) addPlayer: (Player*) aPlayer { + int aPlayerID = [aPlayer playerID]; + if([self playerWithID:aPlayerID] == nil) { + Player *p = [[[Team currentTeam] allPlayersList] playerWithID:aPlayerID]; + if(p) { + [playerList addObject:p]; + return YES; + } + } + return NO; + } - (BOOL) removePlayerWithID: (int) aPlayerID { PlayerList *mainList = [[Team currentTeam] allPlayersList]; Index: PlayerTableController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableController.m,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PlayerTableController.m 17 Sep 2005 14:05:48 -0000 1.11 --- PlayerTableController.m 17 Sep 2005 16:22:27 -0000 1.12 *************** *** 54,58 **** } ! -(void) removeSelectedPlayers { --- 54,61 ---- } ! - (void) addSelectedPlayersToPlayerList: (PlayerList*) aPlayerList { ! NSArray *selectedPlayers = [playerListController selectedObjects]; ! [aPlayerList addPlayers: selectedPlayers]; ! } -(void) removeSelectedPlayers { |