Changeset 1484
- Timestamp:
- 08/12/04 22:12:19 (4 years ago)
- Files:
-
- WiredClient/trunk/WCAccounts.h (modified) (3 diffs)
- WiredClient/trunk/WCAccounts.m (modified) (6 diffs)
- WiredClient/trunk/WCFile.m (modified) (2 diffs)
- WiredClient/trunk/WCFiles.h (modified) (2 diffs)
- WiredClient/trunk/WCFiles.m (modified) (24 diffs)
- WiredClient/trunk/WCSearch.h (modified) (2 diffs)
- WiredClient/trunk/WCSearch.m (modified) (15 diffs)
- WiredClient/trunk/WCTrackers.h (modified) (2 diffs)
- WiredClient/trunk/WCTrackers.m (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredClient/trunk/WCAccounts.h
r1383 r1484 1 /* $Id: WCAccounts.h,v 1. 5 2004/07/28 08:00:26morris Exp $ */1 /* $Id: WCAccounts.h,v 1.6 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 29 29 #import "WCWindowController.h" 30 30 31 @class WCConnection ;31 @class WCConnection, WCTableView; 32 32 33 33 @interface WCAccounts : WCWindowController { 34 IBOutlet NSTableView *_accountsTableView;34 IBOutlet WCTableView *_accountsTableView; 35 35 36 36 IBOutlet NSProgressIndicator *_progressIndicator; … … 46 46 NSImage *_userImage, *_groupImage; 47 47 int _users, _groups; 48 49 NSImage *_sortUpImage, *_sortDownImage;50 NSTableColumn *_lastTableColumn;51 BOOL _sortDescending;52 48 } 53 49 WiredClient/trunk/WCAccounts.m
r1435 r1484 1 /* $Id: WCAccounts.m,v 1.1 7 2004/08/06 19:54:21morris Exp $ */1 /* $Id: WCAccounts.m,v 1.18 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 37 37 #import "WCPreferences.h" 38 38 #import "WCSettings.h" 39 #import "WCTableView.h" 39 40 40 41 @implementation WCAccounts … … 128 129 [_accountsTableView setDoubleAction:@selector(edit:)]; 129 130 130 // --- get the sort images131 _sortUpImage = [[NSImage imageNamed:@"SortUp"] retain];132 _sortDownImage = [[NSImage imageNamed:@"SortDown"] retain];133 134 131 // --- window position 135 132 [self setShouldCascadeWindows:NO]; 136 133 [self setWindowFrameAutosaveName:@"Accounts"]; 137 134 138 // --- simulate a click on the name column to sort by name139 [ self tableView:_accountsTableView didClickTableColumn:140 [_accountsTableView tableColumnWithIdentifier:@"Name"]];135 // --- table view position 136 [_accountsTableView setAutosaveName:@"Accounts"]; 137 [_accountsTableView setAutosaveTableColumns:YES]; 141 138 142 139 // --- start off in the table view … … 339 336 340 337 // --- get identifier 341 identifier = [ _lastTableColumnidentifier];338 identifier = [[_accountsTableView highlightedTableColumn] identifier]; 342 339 343 340 // --- sort the list … … 569 566 570 567 - (void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn { 571 NSImage *sortImage;572 568 NSString *identifier; 573 569 574 if(_lastTableColumn == tableColumn) { 575 // --- invert sorting 576 _sortDescending = !_sortDescending; 577 } else { 578 _sortDescending = NO; 579 580 if(_lastTableColumn) 581 [tableView setIndicatorImage:NULL inTableColumn:_lastTableColumn]; 582 583 // --- set the new sorting selector 584 _lastTableColumn = tableColumn; 585 586 // --- get identifier 587 identifier = [tableColumn identifier]; 588 589 if([identifier isEqualToString:@"Name"]) 590 [_shownAccounts sortUsingSelector:@selector(nameSort:)]; 591 else if([identifier isEqualToString:@"Type"]) 592 [_shownAccounts sortUsingSelector:@selector(typeSort:)]; 593 594 [tableView setHighlightedTableColumn:tableColumn]; 595 } 596 597 // --- set the image for the new column header 598 sortImage = _sortDescending ? _sortDownImage : _sortUpImage; 599 [tableView setIndicatorImage:sortImage inTableColumn:tableColumn]; 600 [tableView reloadData]; 570 // --- get identifier 571 identifier = [tableColumn identifier]; 572 573 // --- re-sort 574 if([identifier isEqualToString:@"Name"]) 575 [_shownAccounts sortUsingSelector:@selector(nameSort:)]; 576 else if([identifier isEqualToString:@"Type"]) 577 [_shownAccounts sortUsingSelector:@selector(typeSort:)]; 578 579 // --- select new column header 580 [_accountsTableView setHighlightedTableColumn:tableColumn]; 581 [_accountsTableView reloadData]; 601 582 } 602 583 … … 609 590 610 591 // --- get account 611 i = _sortDescending ? [_shownAccounts count] - (unsigned int) row - 1 : (unsigned int) row; 612 account = [_shownAccounts objectAtIndex:i]; 613 identifier = [tableColumn identifier]; 592 i = [_accountsTableView sortDescending] 593 ? [_shownAccounts count] - (unsigned int) row - 1 594 : (unsigned int) row; 595 account = [_shownAccounts objectAtIndex:i]; 596 identifier = [tableColumn identifier]; 614 597 615 598 // --- populate columns WiredClient/trunk/WCFile.m
r1415 r1484 1 /* $Id: WCFile.m,v 1. 9 2004/08/03 19:30:55morris Exp $ */1 /* $Id: WCFile.m,v 1.10 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 378 378 if(_type == WCFileTypeFile && [other type] != WCFileTypeFile) 379 379 return NSOrderedAscending; 380 else if(_type == WCFileTypeDirectory && [other type] != WCFileTypeDirectory)380 else if(_type != WCFileTypeFile && [other type] == WCFileTypeFile) 381 381 return NSOrderedDescending; 382 382 WiredClient/trunk/WCFiles.h
r1413 r1484 1 /* $Id: WCFiles.h,v 1.1 1 2004/08/03 19:28:27morris Exp $ */1 /* $Id: WCFiles.h,v 1.12 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 68 68 NSMutableArray *_pathHistory; 69 69 unsigned int _currentPath; 70 71 NSImage *_sortUpImage, *_sortDownImage;72 NSTableColumn *_lastTableColumn;73 BOOL _sortDescending;74 70 } 75 71 WiredClient/trunk/WCFiles.m
r1469 r1484 1 /* $Id: WCFiles.m,v 1.4 3 2004/08/10 18:24:55morris Exp $ */1 /* $Id: WCFiles.m,v 1.44 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 113 113 [[NSNotificationCenter defaultCenter] removeObserver:self]; 114 114 115 [_sortUpImage release];116 [_sortDownImage release];117 118 115 [_folderIcon release]; 119 116 [_uploadsIcon release]; … … 154 151 [_filesTableView setDoubleAction:@selector(open:)]; 155 152 156 // --- get the sort images157 _sortUpImage = [[NSImage imageNamed:@"SortUp"] retain];158 _sortDownImage = [[NSImage imageNamed:@"SortDown"] retain];159 160 153 // --- window title 161 154 [[self window] setTitle:[NSString stringWithFormat:@"%@ %C %@", … … 172 165 // --- set up window 173 166 [self updateButtons]; 174 175 // --- simulate a click on the name column to sort by name176 [self tableView:_filesTableView didClickTableColumn:177 [_filesTableView tableColumnWithIdentifier:@"Name"]];178 167 179 168 // --- start off in the table view … … 452 441 453 442 // --- get identifier 454 identifier = [ _lastTableColumnidentifier];443 identifier = [[_filesTableView highlightedTableColumn] identifier]; 455 444 456 445 // --- sort the list … … 471 460 // --- select parent 472 461 if(_selectPath) { 473 enumerator = _sortDescending462 enumerator = [_filesTableView sortDescending] 474 463 ? [_shownFiles objectEnumerator] 475 464 : [_shownFiles objectEnumerator]; … … 482 471 } 483 472 484 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 473 i = [_filesTableView sortDescending] 474 ? [_shownFiles count] - (unsigned int) row - 1 475 : (unsigned int) row; 485 476 [_filesTableView selectRow:i >= 0 ? i : 0 byExtendingSelection:NO]; 486 477 [_filesTableView scrollRowToVisible:row >= 0 ? i : 0]; … … 576 567 } else { 577 568 // --- get file 578 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 569 i = [_filesTableView sortDescending] 570 ? [_shownFiles count] - (unsigned int) row - 1 571 : (unsigned int) row; 579 572 file = [_shownFiles objectAtIndex:i]; 580 573 extension = [[[file path] pathExtension] lowercaseString]; … … 686 679 687 680 // --- get file 688 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 681 i = [_filesTableView sortDescending] 682 ? [_shownFiles count] - (unsigned int) row - 1 683 : (unsigned int) row; 689 684 file = [_shownFiles objectAtIndex:i]; 690 685 … … 780 775 781 776 // --- get file 782 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 777 i = [_filesTableView sortDescending] ? 778 [_shownFiles count] - (unsigned int) row - 1 779 : (unsigned int) row; 783 780 file = [_shownFiles objectAtIndex:i]; 784 781 … … 822 819 823 820 // --- get file 824 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 821 i = [_filesTableView sortDescending] 822 ? [_shownFiles count] - (unsigned int) row - 1 823 : (unsigned int) row; 825 824 file = [_shownFiles objectAtIndex:i]; 826 825 … … 842 841 843 842 // --- get file 844 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 843 i = [_filesTableView sortDescending] 844 ? [_shownFiles count] - (unsigned int) row - 1 845 : (unsigned int) row; 845 846 file = [_shownFiles objectAtIndex:i]; 846 847 … … 869 870 // --- save selection 870 871 if(row >= 0) { 871 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 872 i = [_filesTableView sortDescending] 873 ? [_shownFiles count] - (unsigned int) row - 1 874 : (unsigned int) row; 872 875 _selectPath = [[[_shownFiles objectAtIndex:i] path] retain]; 873 876 } … … 894 897 895 898 // --- get file 896 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 899 i = [_filesTableView sortDescending] 900 ? [_shownFiles count] - (unsigned int) row - 1 901 : (unsigned int) row; 897 902 file = [_shownFiles objectAtIndex:i]; 898 903 … … 938 943 939 944 - (void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn { 940 NSImage *sortImage;941 945 NSString *identifier; 942 946 943 if(_lastTableColumn == tableColumn) { 944 // --- invert sorting 945 _sortDescending = !_sortDescending; 946 } else { 947 _sortDescending = NO; 948 949 if(_lastTableColumn) 950 [tableView setIndicatorImage:NULL inTableColumn:_lastTableColumn]; 951 952 // --- set the new sorting selector 953 _lastTableColumn = tableColumn; 954 955 // --- get identifier 956 identifier = [tableColumn identifier]; 957 958 if([identifier isEqualToString:@"Name"]) 959 [_shownFiles sortUsingSelector:@selector(nameSort:)]; 960 else if([identifier isEqualToString:@"Kind"]) 961 [_shownFiles sortUsingSelector:@selector(kindSort:)]; 962 else if([identifier isEqualToString:@"Created"]) 963 [_shownFiles sortUsingSelector:@selector(createdSort:)]; 964 else if([identifier isEqualToString:@"Modified"]) 965 [_shownFiles sortUsingSelector:@selector(modifiedSort:)]; 966 else if([identifier isEqualToString:@"Size"]) 967 [_shownFiles sortUsingSelector:@selector(sizeSort:)]; 968 969 [tableView setHighlightedTableColumn:tableColumn]; 970 } 971 972 // --- set the image for the new column header 973 sortImage = _sortDescending ? _sortDownImage : _sortUpImage; 974 [tableView setIndicatorImage:sortImage inTableColumn:tableColumn]; 975 [tableView reloadData]; 947 // --- get identifier 948 identifier = [tableColumn identifier]; 949 950 // --- re-sort 951 if([identifier isEqualToString:@"Name"]) 952 [_shownFiles sortUsingSelector:@selector(nameSort:)]; 953 else if([identifier isEqualToString:@"Kind"]) 954 [_shownFiles sortUsingSelector:@selector(kindSort:)]; 955 else if([identifier isEqualToString:@"Created"]) 956 [_shownFiles sortUsingSelector:@selector(createdSort:)]; 957 else if([identifier isEqualToString:@"Modified"]) 958 [_shownFiles sortUsingSelector:@selector(modifiedSort:)]; 959 else if([identifier isEqualToString:@"Size"]) 960 [_shownFiles sortUsingSelector:@selector(sizeSort:)]; 961 962 // --- select new column header 963 [_filesTableView setHighlightedTableColumn:tableColumn]; 964 [_filesTableView reloadData]; 976 965 } 977 966 … … 991 980 992 981 // --- get file 993 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 994 file = [_shownFiles objectAtIndex:i]; 995 identifier = [tableColumn identifier]; 982 i = [_filesTableView sortDescending] 983 ? [_shownFiles count] - (unsigned int) row - 1 984 : (unsigned int) row; 985 file = [_shownFiles objectAtIndex:i]; 986 identifier = [tableColumn identifier]; 996 987 997 988 // --- populate columns … … 1068 1059 int i; 1069 1060 1070 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1071 file = [_shownFiles objectAtIndex:i]; 1061 i = [_filesTableView sortDescending] 1062 ? [_shownFiles count] - (unsigned int) row - 1 1063 : (unsigned int) row; 1064 file = [_shownFiles objectAtIndex:i]; 1072 1065 1073 1066 return [file name]; … … 1080 1073 int i; 1081 1074 1082 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1083 file = [_shownFiles objectAtIndex:i]; 1075 i = [_filesTableView sortDescending] 1076 ? [_shownFiles count] - (unsigned int) row - 1 1077 : (unsigned int) row; 1078 file = [_shownFiles objectAtIndex:i]; 1084 1079 1085 1080 return [file name]; … … 1099 1094 1100 1095 // --- get file 1101 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1096 i = [_filesTableView sortDescending] 1097 ? [_shownFiles count] - (unsigned int) row - 1 1098 : (unsigned int) row; 1102 1099 file = [_shownFiles objectAtIndex:i]; 1103 1100 … … 1125 1122 1126 1123 // --- get destination 1127 i = _sortDescending1124 i = [_filesTableView sortDescending] 1128 1125 ? [_shownFiles count] - (unsigned int) proposedRow - 1 1129 1126 : (unsigned int) proposedRow; … … 1144 1141 if(operation == NSTableViewDropAbove) { 1145 1142 if(destination == _path) 1146 [ tableView setDropRow:-1 dropOperation:NSTableViewDropOn];1143 [_filesTableView setDropRow:-1 dropOperation:NSTableViewDropOn]; 1147 1144 else 1148 1145 return NSDragOperationNone; … … 1151 1148 // --- turn drops on files into drops to the window 1152 1149 if([destination type] == WCFileTypeFile) 1153 [ tableView setDropRow:-1 dropOperation:NSTableViewDropOn];1150 [_filesTableView setDropRow:-1 dropOperation:NSTableViewDropOn]; 1154 1151 1155 1152 return NSDragOperationGeneric; … … 1171 1168 1172 1169 // --- get destination 1173 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1170 i = [_filesTableView sortDescending] 1171 ? [_shownFiles count] - (unsigned int) row - 1 1172 : (unsigned int) row; 1174 1173 destination = row >= 0 && row < (int) [_shownFiles count] 1175 1174 ? [_shownFiles objectAtIndex:i] … … 1270 1269 1271 1270 // --- get file 1272 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1271 i = [_filesTableView sortDescending] 1272 ? [_shownFiles count] - (unsigned int) row - 1 1273 : (unsigned int) row; 1273 1274 file = [_shownFiles objectAtIndex:i]; 1274 1275 WiredClient/trunk/WCSearch.h
r1413 r1484 1 /* $Id: WCSearch.h,v 1. 8 2004/08/03 19:28:27morris Exp $ */1 /* $Id: WCSearch.h,v 1.9 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 56 56 57 57 NSArray *_audioExtensions, *_imageExtensions, *_movieExtensions; 58 59 NSImage *_sortUpImage, *_sortDownImage;60 NSTableColumn *_lastTableColumn;61 BOOL _sortDescending;62 58 } 63 59 WiredClient/trunk/WCSearch.m
r1435 r1484 1 /* $Id: WCSearch.m,v 1.3 0 2004/08/06 19:54:21morris Exp $ */1 /* $Id: WCSearch.m,v 1.31 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 66 66 _dropBoxImage = [[NSImage imageNamed:@"DropBox16"] retain]; 67 67 68 // --- get the sort images69 _sortUpImage = [[NSImage imageNamed:@"SortUp"] retain];70 _sortDownImage = [[NSImage imageNamed:@"SortDown"] retain];71 72 68 // --- get arrays of file extensions 73 69 _audioExtensions = [[WCSearchTypeAudioExtensions componentsSeparatedByString:@" "] retain]; … … 107 103 [_connection release]; 108 104 109 [_sortUpImage release];110 [_sortDownImage release];111 112 105 [_iconPool release]; 113 106 [_folderImage release]; … … 145 138 // --- double-click 146 139 [_searchTableView setDoubleAction:@selector(open:)]; 147 148 // --- simulate a click on the name column to sort by name149 [self tableView:_searchTableView didClickTableColumn:150 [_searchTableView tableColumnWithIdentifier:@"Name"]];151 140 152 141 // --- window position … … 325 314 326 315 // --- get identifier 327 identifier = [ _lastTableColumnidentifier];316 identifier = [[_searchTableView highlightedTableColumn] identifier]; 328 317 329 318 // --- sort the list … … 366 355 367 356 // --- get file 368 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 357 i = [_searchTableView sortDescending] 358 ? [_shownFiles count] - (unsigned int) row - 1 359 : (unsigned int) row; 369 360 file = [_shownFiles objectAtIndex:i]; 370 361 … … 464 455 465 456 // --- get file 466 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 457 i = [_searchTableView sortDescending] 458 ? [_shownFiles count] - (unsigned int) row - 1 459 : (unsigned int) row; 467 460 file = [_shownFiles objectAtIndex:i]; 468 461 … … 503 496 504 497 // --- get file 505 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 498 i = [_searchTableView sortDescending] 499 ? [_shownFiles count] - (unsigned int) row - 1 500 : (unsigned int) row; 506 501 file = [_shownFiles objectAtIndex:i]; 507 502 … … 523 518 524 519 // --- get file 525 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 520 i = [_searchTableView sortDescending] 521 ? [_shownFiles count] - (unsigned int) row - 1 522 : (unsigned int) row; 526 523 file = [_shownFiles objectAtIndex:i]; 527 524 … … 543 540 544 541 // --- get file 545 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 542 i = [_searchTableView sortDescending] 543 ? [_shownFiles count] - (unsigned int) row - 1 544 : (unsigned int) row; 546 545 file = [_shownFiles objectAtIndex:i]; 547 546 … … 567 566 568 567 - (void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn { 569 NSImage *sortImage;570 568 NSString *identifier; 571 569 572 if(_lastTableColumn == tableColumn) { 573 // --- invert sorting 574 _sortDescending = !_sortDescending; 575 } else { 576 _sortDescending = NO; 577 578 if(_lastTableColumn) 579 [tableView setIndicatorImage:NULL inTableColumn:_lastTableColumn]; 580 581 // --- get identifier 582 identifier = [_lastTableColumn identifier]; 583 584 // --- set the new sorting selector 585 _lastTableColumn = tableColumn; 586 587 if([identifier isEqualToString:@"Name"]) 588 [_shownFiles sortUsingSelector:@selector(nameSort:)]; 589 else if([identifier isEqualToString:@"Kind"]) 590 [_shownFiles sortUsingSelector:@selector(kindSort:)]; 591 else if([identifier isEqualToString:@"Created"]) 592 [_shownFiles sortUsingSelector:@selector(createdSort:)]; 593 else if([identifier isEqualToString:@"Modified"]) 594 [_shownFiles sortUsingSelector:@selector(modifiedSort:)]; 595 else if([identifier isEqualToString:@"Size"]) 596 [_shownFiles sortUsingSelector:@selector(sizeSort:)]; 597 598 [tableView setHighlightedTableColumn:tableColumn]; 599 } 600 601 // --- set the image for the new column header 602 sortImage = _sortDescending ? _sortDownImage : _sortUpImage; 603 [tableView setIndicatorImage:sortImage inTableColumn:tableColumn]; 604 [tableView reloadData]; 570 // --- get identifier 571 identifier = [tableColumn identifier]; 572 573 // --- re-sort 574 if([identifier isEqualToString:@"Name"]) 575 [_shownFiles sortUsingSelector:@selector(nameSort:)]; 576 else if([identifier isEqualToString:@"Kind"]) 577 [_shownFiles sortUsingSelector:@selector(kindSort:)]; 578 else if([identifier isEqualToString:@"Created"]) 579 [_shownFiles sortUsingSelector:@selector(createdSort:)]; 580 else if([identifier isEqualToString:@"Modified"]) 581 [_shownFiles sortUsingSelector:@selector(modifiedSort:)]; 582 else if([identifier isEqualToString:@"Size"]) 583 [_shownFiles sortUsingSelector:@selector(sizeSort:)]; 584 585 // --- select new column header 586 [_searchTableView setHighlightedTableColumn:tableColumn]; 587 [_searchTableView reloadData]; 605 588 } 606 589 … … 614 597 615 598 // --- get file 616 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 599 i = [_searchTableView sortDescending] 600 ? [_shownFiles count] - (unsigned int) row - 1 601 : (unsigned int) row; 617 602 file = [_shownFiles objectAtIndex:i]; 618 603 identifier = [tableColumn identifier]; … … 689 674 int i; 690 675 691 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 692 file = [_shownFiles objectAtIndex:i]; 676 i = [_searchTableView sortDescending] 677 ? [_shownFiles count] - (unsigned int) row - 1 678 : (unsigned int) row; 679 file = [_shownFiles objectAtIndex:i]; 693 680 694 681 return [file name]; … … 701 688 int i; 702 689 703 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 704 file = [_shownFiles objectAtIndex:i]; 690 i = [_searchTableView sortDescending] 691 ? [_shownFiles count] - (unsigned int) row - 1 692 : (unsigned int) row; 693 file = [_shownFiles objectAtIndex:i]; 705 694 706 695 return [file name]; … … 721 710 722 711 // --- get file 723 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 712 i = [_searchTableView sortDescending] 713 ? [_shownFiles count] - (unsigned int) row - 1 714 : (unsigned int) row; 724 715 file = [_shownFiles objectAtIndex:i]; 725 716 WiredClient/trunk/WCTrackers.h
r1413 r1484 1 /* $Id: WCTrackers.h,v 1.1 1 2004/08/03 19:28:27morris Exp $ */1 /* $Id: WCTrackers.h,v 1.12 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 48 48 WCTracker *_rendezvousTracker; 49 49 NSImage *_rendezvousImage; 50 51 NSImage *_sortUpImage, *_sortDownImage;52 NSTableColumn *_lastTableColumn;53 BOOL _sortDescending;54 50 } 55 51 WiredClient/trunk/WCTrackers.m
r1398 r1484 1 /* $Id: WCTrackers.m,v 1.2 4 2004/07/30 12:43:40morris Exp $ */1 /* $Id: WCTrackers.m,v 1.25 2004/08/12 20:12:19 morris Exp $ */ 2 2 3 3 /* … … 106 106 [_rendezvousImage release]; 107 107 108 [_sortUpImage release];109 [_sortDownImage release];110 111 108 [_trackers release]; 112 109 [_browser release]; … … 132 129 [self updateTrackers]; 133 130 134 // --- get the sort images135 _sortUpImage = [[NSImage imageNamed:@"SortUp"] retain];136 _sortDownImage = [[NSImage imageNamed:@"SortDown"] retain];137 138 131 // --- connect on double-click 139 132 [_trackersOutlineView setDoubleAction:@selector(open:)]; … … 150 143 [_trackersOutlineView setAutosaveTableColumns:YES]; 151 144 152 // --- table columns153 // [_trackersOutlineView updateViewOptions];154 155 // --- simulate a click on the name column to sort by name156 [self outlineView:_trackersOutlineView shouldSelectTableColumn:157 [_trackersOutlineView tableColumnWithIdentifier:@"Name"]];158 159 145 // --- start off in the table view 160 146 [[self window] makeFirstResponder:_trackersOutlineView]; … … 325 311 326 312 // --- get identifier 327 identifier = [ _lastTableColumnidentifier];313 identifier = [[_trackersOutlineView highlightedTableColumn] identifier]; 328 314 329 315 // --- sort children … … 635 621 - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectTableColumn:(NSTableColumn *)tableColumn { 636 622 NSEnumerator *enumerator; 637 NSImage *sortImage;638 623 NSString *identifier; 639 624 WCTracker *tracker; 640 625 SEL selector; 641 626 642 if(_lastTableColumn == tableColumn) { 643 // --- invert sorting 644 _sortDescending = !_sortDescending; 645 } else { 646 _sortDescending = NO; 647 648 if(_lastTableColumn) 649 [_trackersOutlineView setIndicatorImage:NULL inTableColumn:_lastTableColumn]; 650 651 // --- get identifier 652 identifier = [tableColumn identifier]; 653 654 // --- get sort selector 655 if([identifier isEqualToString:@"Name"]) 656 selector = @selector(nameSort:); 657 else if([identifier isEqualToString:@"Users"]) 658 selector = @selector(usersSort:); 659 else if([identifier isEqualToString:@"Speed"]) 660 selector = @selector(speedSort:); 661 else if([identifier isEqualToString:@"Guest"]) 662 selector = @selector(guestSort:); 663 else if([identifier isEqualToString:@"Download"]) 664 selector = @selector(downloadSort:); 665 else if([identifier isEqualToString:@"Files"]) 666 selector = @selector(filesSort:); 667 else if([identifier isEqualToString:@"Size"]) 668 selector = @selector(sizeSort:); 669 else if([identifier isEqualToString:@"Description"]) 670 selector = @selector(descriptionSort:); 671 else 672 selector = @selector(nameSort:); 673 674 // --- loop over trackers 675 enumerator = [_trackers objectEnumerator]; 676 677 while((tracker = [enumerator nextObject])) 678 [tracker sortChildrenUsingSelector:selector]; 679 680 // --- set the new sorting selector 681 _lastTableColumn = tableColumn; 682 683 [_trackersOutlineView setHighlightedTableColumn:tableColumn]; 684 } 685 686 // --- set the image for the new column header 687 sortImage = _sortDescending ? _sortDownImage : _sortUpImage; 688 [_trackersOutlineView setIndicatorImage:sortImage inTableColumn:tableColumn]; 627 // --- get identifier 628 identifier = [tableColumn identifier]; 629 630 // --- get sort selector 631 if([identifier isEqualToString:@"Name"]) 632 selector = @selector(nameSort:); 633 else if([identifier isEqualToString:@"Users"]) 634 selector = @selector(usersSort:); 635 else if([identifier isEqualToString:@"Speed"]) 636 selector = @selector(speedSort:); 637 else if([identifier isEqualToString:@"Guest"]) 638 selector = @selector(guestSort:); 639 else if([identifier isEqualToString:@"Download"]) 640 selector = @selector(downloadSort:); 641 else if([identifier isEqualToString:@"Files"]) 642 selector = @selector(filesSort:); 643 else if([identifier isEqualToString:@"Size"]) 644 selector = @selector(sizeSort:); 645 else if([identifier isEqualToString:@"Description"]) 646 selector = @selector(descriptionSort:); 647 else 648 selector = @selector(nameSort:); 649 650 // --- loop over trackers 651 enumerator = [_trackers objectEnumerator]; 652 653 while((tracker = [enumerator nextObject])) 654 [tracker sortChildrenUsingSelector:selector]; 655 656 // --- select new column header 657 [_trackersOutlineView setHighlightedTableColumn:tableColumn]; 689 658 [_trackersOutlineView reloadData]; 690 659 … … 719 688 720 689 children = [item filteredChildren:_filter]; 721 index = _sortDescending ? (int) [children count] - index - 1 : index; 690 index = [_trackersOutlineView sortDescending] 691 ? [children count] - (unsigned int) index - 1 692 : (unsigned int) index; 722 693 723 694 return [children objectAtIndex:index];
