Changeset 145
- Timestamp:
- Mar 12, 2006, 2:32:04 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_api/macosx/Controller.m
r143 r145 100 100 101 101 [fTableView setAutosaveTableColumns: YES]; 102 //[fTableView sizeToFit];103 102 104 103 [fTableView registerForDraggedTypes: [NSArray arrayWithObjects: … … 200 199 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender 201 200 { 202 int active = fDownloading + fSeeding; 201 int active = 0; 202 Torrent * torrent; 203 NSEnumerator * enumerator = [fTorrents objectEnumerator]; 204 while( ( torrent = [enumerator nextObject] ) ) 205 { 206 if( [torrent isActive] ) 207 { 208 active++; 209 } 210 } 211 203 212 if (active > 0 && [fDefaults boolForKey: @"CheckQuit"]) 204 213 { … … 411 420 - (void) resumeAllTorrents: (id) sender 412 421 { 422 Torrent * torrent; 413 423 NSEnumerator * enumerator = [fTorrents objectEnumerator]; 414 Torrent * torrent;415 424 while( ( torrent = [enumerator nextObject] ) ) 416 425 { 417 [torrent stop]; 418 } 419 } 420 421 - (void) resumeTorrentWithIndex: (int) idx 422 { 423 [[fTorrents objectAtIndex: idx] start]; 426 [torrent start]; 427 } 424 428 [self updateUI: nil]; 425 429 [self updateTorrentHistory]; 426 430 } 427 431 432 - (void) resumeTorrentWithIndex: (int) idx 433 { 434 Torrent * torrent = [fTorrents objectAtIndex: idx]; 435 [torrent start]; 436 [self updateUI: nil]; 437 [self updateTorrentHistory]; 438 } 439 428 440 - (void) stopTorrent: (id) sender 429 441 { … … 433 445 - (void) stopAllTorrents: (id) sender 434 446 { 447 Torrent * torrent; 435 448 NSEnumerator * enumerator = [fTorrents objectEnumerator]; 436 Torrent * torrent;437 449 while( ( torrent = [enumerator nextObject] ) ) 438 450 { 439 [torrent start]; 440 } 451 [torrent stop]; 452 } 453 [self updateUI: nil]; 454 [self updateTorrentHistory]; 441 455 } 442 456 … … 832 846 return [fTableView selectedRow] >= 0; 833 847 848 Torrent * torrent; 849 NSEnumerator * enumerator; 834 850 835 851 //enable resume all item 836 852 if (action == @selector(resumeAllTorrents:)) 837 return fCount > fDownloading + fSeeding; 853 { 854 enumerator = [fTorrents objectEnumerator]; 855 while( ( torrent = [enumerator nextObject] ) ) 856 if( [torrent isPaused] ) 857 return YES; 858 return NO; 859 } 838 860 839 861 //enable pause all item 840 862 if (action == @selector(stopAllTorrents:)) 841 return fDownloading > 0 || fSeeding > 0; 863 { 864 enumerator = [fTorrents objectEnumerator]; 865 while( ( torrent = [enumerator nextObject] ) ) 866 if( [torrent isActive] ) 867 return YES; 868 return NO; 869 } 842 870 843 871 return YES; … … 846 874 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem 847 875 { 848 #if 0849 876 SEL action = [menuItem action]; 850 877 … … 867 894 } 868 895 896 Torrent * torrent; 897 NSEnumerator * enumerator; 898 869 899 //enable resume all item 870 900 if (action == @selector(resumeAllTorrents:)) 871 return fCount > fDownloading + fSeeding; 901 { 902 enumerator = [fTorrents objectEnumerator]; 903 while( ( torrent = [enumerator nextObject] ) ) 904 if( [torrent isPaused] ) 905 return YES; 906 return NO; 907 } 872 908 873 909 //enable pause all item 874 910 if (action == @selector(stopAllTorrents:)) 875 return fDownloading > 0 || fSeeding > 0; 911 { 912 enumerator = [fTorrents objectEnumerator]; 913 while( ( torrent = [enumerator nextObject] ) ) 914 if( [torrent isActive] ) 915 return YES; 916 return NO; 917 } 876 918 877 919 int row = [fTableView selectedRow]; 920 torrent = ( row < 0 ) ? nil : [fTorrents objectAtIndex: row]; 921 922 if (action == @selector(revealFromMenu:)) 923 { 924 return ( torrent != nil ); 925 } 878 926 879 927 //enable remove items … … 883 931 || action == @selector(removeTorrentDeleteBoth:)) 884 932 { 933 if( !torrent ) 934 return NO; 935 885 936 //append or remove ellipsis when needed 886 if (row >= 0 && fStat[row].status & ( TR_STATUS_CHECK | TR_STATUS_DOWNLOAD) 887 && [[fDefaults stringForKey: @"CheckRemove"] isEqualToString:@"YES"]) 937 if( [torrent isActive] && [fDefaults boolForKey: @"CheckRemove"] ) 888 938 { 889 939 if (![[menuItem title] hasSuffix:NS_ELLIPSIS]) … … 895 945 [menuItem setTitle:[[menuItem title] substringToIndex:[[menuItem title] length]-[NS_ELLIPSIS length]]]; 896 946 } 897 return row >= 0; 898 } 899 900 //enable reveal in finder item 901 if (action == @selector(revealFromMenu:)) 902 return row >= 0; 947 return YES; 948 } 903 949 904 950 //enable and change pause / remove item 905 if (action == @selector(resumeTorrent:) || action == @selector(stopTorrent:)) 906 { 907 if (row >= 0 && fStat[row].status & TR_STATUS_PAUSE) 951 if( action == @selector(resumeTorrent:) || 952 action == @selector(stopTorrent:) ) 953 { 954 if( !torrent ) 955 return NO; 956 957 if( [torrent isActive] ) 958 { 959 [menuItem setTitle: @"Pause"]; 960 [menuItem setAction: @selector( stopTorrent: )]; 961 } 962 else 908 963 { 909 964 [menuItem setTitle: @"Resume"]; 910 965 [menuItem setAction: @selector( resumeTorrent: )]; 911 966 } 912 else 913 { 914 [menuItem setTitle: @"Pause"]; 915 [menuItem setAction: @selector( stopTorrent: )]; 916 } 917 return row >= 0; 918 } 919 #endif 967 } 968 920 969 return YES; 921 970 }
Note: See TracChangeset
for help on using the changeset viewer.