Changeset 1316
- Timestamp:
- 05/23/04 05:29:02 (5 years ago)
- Files:
-
- WiredClient/trunk/WCChat.h (modified) (3 diffs)
- WiredClient/trunk/WCChat.m (modified) (2 diffs)
- WiredClient/trunk/WCFiles.h (modified) (2 diffs)
- WiredClient/trunk/WCFiles.m (modified) (27 diffs)
- WiredClient/trunk/WCSearch.h (modified) (2 diffs)
- WiredClient/trunk/WCSearch.m (modified) (15 diffs)
- WiredClient/trunk/WCTableView.h (modified) (3 diffs)
- WiredClient/trunk/WCTableView.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredClient/trunk/WCChat.h
r1308 r1316 1 /* $Id: WCChat.h,v 1.1 3 2004/05/22 10:05:18morris Exp $ */1 /* $Id: WCChat.h,v 1.14 2004/05/23 03:29:02 morris Exp $ */ 2 2 3 3 /* … … 31 31 @class WCConnection, WCSplitView, WCTextView, WCTableView; 32 32 33 @protocol WCTableViewMenuValidation, WCTableViewInfoCopying; 33 @protocol WCTableViewMenuValidation, WCTableViewInfoCopying, WCTableViewToolTipDisplaying; 34 @protocol WCTableViewTypingAhead; 34 35 35 36 @protocol WCGetInfoValidation … … 41 42 @end 42 43 43 @interface WCChat : WCWindowController <WCGetInfoValidation, WCTableViewInfoCopying > {44 @interface WCChat : WCWindowController <WCGetInfoValidation, WCTableViewInfoCopying, WCTableViewToolTipDisplaying, WCTableViewTypingAhead> { 44 45 IBOutlet WCSplitView *_chatSplitView; 45 46 IBOutlet NSScrollView *_chatOutputScrollView; WiredClient/trunk/WCChat.m
r1308 r1316 1 /* $Id: WCChat.m,v 1.4 6 2004/05/22 10:05:18morris Exp $ */1 /* $Id: WCChat.m,v 1.47 2004/05/23 03:29:02 morris Exp $ */ 2 2 3 3 /* … … 1746 1746 1747 1747 1748 - (NSString *)tableView:(NSTableView *)tableView stringValueForRow:(int)row { 1749 NSNumber *key; 1750 WCUser *user; 1751 1752 // --- get user 1753 key = [_sortedUsers objectAtIndex:row]; 1754 user = [_shownUsers objectForKey:key]; 1755 1756 return [user nick]; 1757 } 1758 1759 1760 1761 - (NSString *)tableView:(NSTableView *)tableView toolTipForRow:(int)row { 1762 NSNumber *key; 1763 WCUser *user; 1764 1765 // --- get user 1766 key = [_sortedUsers objectAtIndex:row]; 1767 user = [_shownUsers objectForKey:key]; 1768 1769 return [NSString stringWithFormat:@"%@\n%@", [user nick], [user status]]; 1770 } 1771 1772 1773 1748 1774 - (BOOL)tableView:(NSTableView *)tableView writeRows:(NSArray *)items toPasteboard:(NSPasteboard *)pasteboard { 1749 1775 NSNumber *key; WiredClient/trunk/WCFiles.h
r1308 r1316 1 /* $Id: WCFiles.h,v 1. 7 2004/05/22 10:05:18morris Exp $ */1 /* $Id: WCFiles.h,v 1.8 2004/05/23 03:29:02 morris Exp $ */ 2 2 3 3 /* … … 32 32 33 33 @protocol WCGetInfoValidation, WCTableViewInfoCopying, WCTableViewOptionsSelection; 34 @protocol WCTableViewTypingAhead ;34 @protocol WCTableViewTypingAhead, WCTableViewToolTipDisplaying; 35 35 36 @interface WCFiles : WCWindowController <WCGetInfoValidation, WCTableViewInfoCopying, WCTableViewOptionsSelection, WCTableViewTypingAhead > {36 @interface WCFiles : WCWindowController <WCGetInfoValidation, WCTableViewInfoCopying, WCTableViewOptionsSelection, WCTableViewTypingAhead, WCTableViewToolTipDisplaying> { 37 37 IBOutlet WCTableView *_filesTableView; 38 38 IBOutlet NSScrollView *_filesScrollView; WiredClient/trunk/WCFiles.m
r1308 r1316 1 /* $Id: WCFiles.m,v 1.3 4 2004/05/22 10:05:18morris Exp $ */1 /* $Id: WCFiles.m,v 1.35 2004/05/23 03:29:02 morris Exp $ */ 2 2 3 3 /* … … 149 149 [_filesTableView setDoubleAction:@selector(open:)]; 150 150 151 // --- type-ahead152 [_filesTableView setTypeAhead:YES];153 154 151 // --- get the sort images 155 152 _sortUpImage = [[NSImage imageNamed:@"SortUp"] retain]; … … 454 451 else if([identifier isEqualToString:@"Kind"]) 455 452 [_shownFiles sortUsingSelector:@selector(kindSort:)]; 453 else if([identifier isEqualToString:@"Created"]) 454 [_shownFiles sortUsingSelector:@selector(createdSort:)]; 455 else if([identifier isEqualToString:@"Modified"]) 456 [_shownFiles sortUsingSelector:@selector(modifiedSort:)]; 456 457 else if([identifier isEqualToString:@"Size"]) 457 458 [_shownFiles sortUsingSelector:@selector(sizeSort:)]; … … 462 463 // --- select parent 463 464 if(_selectPath) { 464 enumerator = [_shownFiles objectEnumerator]; 465 enumerator = _sortDescending 466 ? [_shownFiles objectEnumerator] 467 : [_shownFiles objectEnumerator]; 465 468 466 469 while((file = [enumerator nextObject])) { … … 471 474 } 472 475 473 [_filesTableView selectRow:row >= 0 ? row : 0 byExtendingSelection:NO]; 474 [_filesTableView scrollRowToVisible:row >= 0 ? row : 0]; 476 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 477 [_filesTableView selectRow:i >= 0 ? i : 0 byExtendingSelection:NO]; 478 [_filesTableView scrollRowToVisible:row >= 0 ? i : 0]; 475 479 476 480 [_selectPath release]; … … 552 556 NSString *extension; 553 557 WCFile *file; 554 int row;558 int i, row; 555 559 556 560 // --- get row number … … 564 568 } else { 565 569 // --- get file 566 file = [_shownFiles objectAtIndex:row]; 570 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 571 file = [_shownFiles objectAtIndex:i]; 567 572 extension = [[[file path] pathExtension] lowercaseString]; 568 573 … … 660 665 WCFile *file; 661 666 BOOL optionKey, newWindows; 662 int row;667 int i, row; 663 668 664 669 // --- get row number … … 669 674 670 675 // --- get file 671 file = [_shownFiles objectAtIndex:row]; 676 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 677 file = [_shownFiles objectAtIndex:i]; 672 678 673 679 switch([file type]) { … … 753 759 - (IBAction)download:(id)sender { 754 760 WCFile *file; 755 int row;761 int i, row; 756 762 757 763 // --- get row number … … 762 768 763 769 // --- get file 764 file = [_shownFiles objectAtIndex:row]; 770 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 771 file = [_shownFiles objectAtIndex:i]; 765 772 766 773 // --- queue a transfer … … 795 802 - (IBAction)info:(id)sender { 796 803 WCFile *file; 797 int row;804 int i, row; 798 805 799 806 // --- get row number … … 804 811 805 812 // --- get file 806 file = [_shownFiles objectAtIndex:row]; 813 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 814 file = [_shownFiles objectAtIndex:i]; 807 815 808 816 // --- create an info window … … 814 822 - (IBAction)preview:(id)sender { 815 823 WCFile *file; 816 int row;824 int i, row; 817 825 818 826 // --- get row number … … 823 831 824 832 // --- get file 825 file = [_shownFiles objectAtIndex:row]; 833 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 834 file = [_shownFiles objectAtIndex:i]; 826 835 827 836 // --- queue a transfer … … 842 851 843 852 - (IBAction)reload:(id)sender { 844 int row;853 int i, row; 845 854 846 855 // --- get row number … … 848 857 849 858 // --- save selection 850 if(row >= 0) 851 _selectPath = [[[_shownFiles objectAtIndex:row] path] retain]; 859 if(row >= 0) { 860 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 861 _selectPath = [[[_shownFiles objectAtIndex:i] path] retain]; 862 } 852 863 853 864 // --- drop cache … … 863 874 NSString *title, *description; 864 875 WCFile *file; 865 int row;876 int i, row; 866 877 867 878 // --- get row number … … 872 883 873 884 // --- get file 874 file = [_shownFiles objectAtIndex:row]; 885 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 886 file = [_shownFiles objectAtIndex:i]; 875 887 876 888 // --- check if we can delete … … 1053 1065 1054 1066 1067 - (NSString *)tableView:(NSTableView *)tableView toolTipForRow:(int)row { 1068 WCFile *file; 1069 int i; 1070 1071 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1072 file = [_shownFiles objectAtIndex:i]; 1073 1074 return [file name]; 1075 } 1076 1077 1078 1055 1079 - (BOOL)tableView:(NSTableView *)tableView writeRows:(NSArray *)items toPasteboard:(NSPasteboard *)pasteboard { 1056 1080 WCFile *file; 1057 int row;1081 int i, row; 1058 1082 1059 1083 // --- get row … … 1064 1088 1065 1089 // --- get file 1066 file = [_shownFiles objectAtIndex:row]; 1090 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1091 file = [_shownFiles objectAtIndex:i]; 1067 1092 1068 1093 // --- put path in pasteboard … … 1082 1107 NSArray *types; 1083 1108 WCFile *destination; 1109 int i; 1084 1110 1085 1111 // --- get pasteboard … … 1088 1114 1089 1115 // --- get destination 1090 destination = proposedRow >= 0 && proposedRow < (int) [_shownFiles count] 1091 ? [_shownFiles objectAtIndex:proposedRow] 1116 i = _sortDescending 1117 ? [_shownFiles count] - (unsigned int) proposedRow - 1 1118 : (unsigned int) proposedRow; 1119 destination = i >= 0 && i < (int) [_shownFiles count] 1120 ? [_shownFiles objectAtIndex:i] 1092 1121 : _path; 1093 1122 … … 1123 1152 NSArray *types; 1124 1153 WCFile *destination; 1154 int i; 1125 1155 1126 1156 // --- get pasteboard … … 1129 1159 1130 1160 // --- get destination 1161 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1131 1162 destination = row >= 0 && row < (int) [_shownFiles count] 1132 ? [_shownFiles objectAtIndex: row]1163 ? [_shownFiles objectAtIndex:i] 1133 1164 : _path; 1134 1165 … … 1213 1244 NSPasteboard *pasteboard; 1214 1245 WCFile *file; 1215 int row;1246 int i, row; 1216 1247 1217 1248 // --- get row number … … 1222 1253 1223 1254 // --- get file 1224 file = [_shownFiles objectAtIndex:row]; 1255 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 1256 file = [_shownFiles objectAtIndex:i]; 1225 1257 1226 1258 // --- put it on the pasteboard WiredClient/trunk/WCSearch.h
r1313 r1316 1 /* $Id: WCSearch.h,v 1. 4 2004/05/22 10:15:50morris Exp $ */1 /* $Id: WCSearch.h,v 1.5 2004/05/23 03:29:02 morris Exp $ */ 2 2 3 3 /* … … 32 32 33 33 @protocol WCGetInfoValidation, WCTableViewInfoCopying, WCTableViewOptionsSelection; 34 @protocol WCTableViewTypingAhead ;34 @protocol WCTableViewTypingAhead, WCTableViewToolTipDisplaying; 35 35 36 @interface WCSearch : WCWindowController <WCGetInfoValidation, WCTableViewInfoCopying, WCTableViewOptionsSelection, WCTableViewTypingAhead > {36 @interface WCSearch : WCWindowController <WCGetInfoValidation, WCTableViewInfoCopying, WCTableViewOptionsSelection, WCTableViewTypingAhead, WCTableViewToolTipDisplaying> { 37 37 IBOutlet WCTableView *_searchTableView; 38 38 WiredClient/trunk/WCSearch.m
r1313 r1316 1 /* $Id: WCSearch.m,v 1.2 3 2004/05/22 10:15:50morris Exp $ */1 /* $Id: WCSearch.m,v 1.24 2004/05/23 03:29:02 morris Exp $ */ 2 2 3 3 /* … … 147 147 [_searchTableView setDoubleAction:@selector(open:)]; 148 148 149 // --- type-ahead150 [_searchTableView setTypeAhead:YES];151 152 149 // --- simulate a click on the name column to sort by name 153 150 [self tableView:_searchTableView didClickTableColumn: … … 364 361 - (BOOL)validateMenuItem:(id <NSMenuItem>)item { 365 362 WCFile *file; 366 int row;363 int i, row; 367 364 368 365 // --- get row number … … 373 370 374 371 // --- get file 375 file = [_shownFiles objectAtIndex:row]; 372 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 373 file = [_shownFiles objectAtIndex:i]; 376 374 377 375 if(item == _openMenuItem) … … 455 453 - (IBAction)open:(id)sender { 456 454 WCFile *file; 457 int row;455 int i, row; 458 456 459 457 // --- get row number … … 464 462 465 463 // --- get file 466 file = [_shownFiles objectAtIndex:row]; 464 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 465 file = [_shownFiles objectAtIndex:i]; 467 466 468 467 switch([file type]) { … … 493 492 - (IBAction)download:(id)sender { 494 493 WCFile *file; 495 int row;494 int i, row; 496 495 497 496 // --- get row number … … 502 501 503 502 // --- get file 504 file = [_shownFiles objectAtIndex:row]; 503 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 504 file = [_shownFiles objectAtIndex:i]; 505 505 506 506 // --- queue a transfer … … 513 513 - (IBAction)info:(id)sender { 514 514 WCFile *file; 515 int row;515 int i, row; 516 516 517 517 // --- get row number … … 522 522 523 523 // --- get file 524 file = [_shownFiles objectAtIndex:row]; 524 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 525 file = [_shownFiles objectAtIndex:i]; 525 526 526 527 // --- create an info window … … 532 533 - (IBAction)revealInFiles:(id)sender { 533 534 WCFile *file, *parent; 534 int row;535 int i, row; 535 536 536 537 // --- get row number … … 541 542 542 543 // --- get file 543 file = [_shownFiles objectAtIndex:row]; 544 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 545 file = [_shownFiles objectAtIndex:i]; 544 546 545 547 // --- create parent … … 682 684 683 685 686 - (NSString *)tableView:(NSTableView *)tableView stringValueForRow:(int)row { 687 WCFile *file; 688 int i; 689 690 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 691 file = [_shownFiles objectAtIndex:i]; 692 693 return [file name]; 694 } 695 696 697 698 - (NSString *)tableView:(NSTableView *)tableView toolTipForRow:(int)row { 699 WCFile *file; 700 int i; 701 702 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 703 file = [_shownFiles objectAtIndex:i]; 704 705 return [file name]; 706 } 707 708 709 684 710 - (void)tableViewShouldCopyInfo:(NSTableView *)tableView { 685 711 NSPasteboard *pasteboard; 686 712 WCFile *file; 687 int row;713 int i, row; 688 714 689 715 // --- get row number … … 694 720 695 721 // --- get file 696 file = [_shownFiles objectAtIndex:row]; 722 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row; 723 file = [_shownFiles objectAtIndex:i]; 697 724 698 725 // --- put it on the pasteboard … … 702 729 } 703 730 704 705 706 - (NSString *)tableView:(NSTableView *)tableView stringValueForRow:(int)row {707 WCFile *file;708 int i;709 710 i = _sortDescending ? [_shownFiles count] - (unsigned int) row - 1 : (unsigned int) row;711 file = [_shownFiles objectAtIndex:i];712 713 return [file name];714 }715 716 731 @end WiredClient/trunk/WCTableView.h
r1308 r1316 1 /* $Id: WCTableView.h,v 1. 4 2004/05/22 10:05:18morris Exp $ */1 /* $Id: WCTableView.h,v 1.5 2004/05/23 03:29:02 morris Exp $ */ 2 2 3 3 /* … … 40 40 @end 41 41 42 @protocol WCTableViewToolTipDisplaying 43 44 - (NSString *) tableView:(NSTableView *)tableView toolTipForRow:(int)row; 45 46 @end 47 42 48 43 49 @interface WCTableView : NSTableView { … … 45 51 NSCharacterSet *_typeAheadCharacterSet; 46 52 BOOL _typeAhead; 53 54 NSMutableDictionary *_regions; 47 55 } 48 56 49 50 - (void) setTypeAhead:(BOOL)value;51 - (BOOL) typeAhead;52 53 57 @end WiredClient/trunk/WCTableView.m
r1312 r1316 1 /* $Id: WCTableView.m,v 1. 6 2004/05/22 10:11:16morris Exp $ */1 /* $Id: WCTableView.m,v 1.7 2004/05/23 03:29:02 morris Exp $ */ 2 2 3 3 /* … … 48 48 [characterSet release]; 49 49 50 // --- create dictionary for tooltips 51 _regions = [[NSMutableDictionary alloc] init]; 52 50 53 return self; 51 54 } … … 64 67 #pragma mark - 65 68 69 - (void)reloadData { 70 [_regions removeAllObjects]; 71 [self removeAllToolTips]; 72 73 [super reloadData]; 74 } 75 76 77 78 #pragma mark - 79 66 80 - (NSMenu *)menuForEvent:(NSEvent *)event { 67 81 int row; … … 89 103 if(key == NSEnterCharacter || key == NSCarriageReturnCharacter) 90 104 [super doCommandBySelector:[super doubleAction]]; 91 else if(_typeAhead && [_typeAheadCharacterSet characterIsMember:key]) 105 else if([[self dataSource] conformsToProtocol:@protocol(WCTableViewTypingAhead)] && 106 [_typeAheadCharacterSet characterIsMember:key]) 92 107 [self interpretKeyEvents:[NSArray arrayWithObject:event]]; 93 108 else 94 109 [super keyDown:event]; 95 96 110 } 97 111 … … 154 168 155 169 170 #pragma mark - 171 156 172 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)local { 157 173 if(local) … … 163 179 164 180 165 #pragma mark - 166 167 - (void)setTypeAhead:(BOOL)value { 168 if([[self delegate] conformsToProtocol:@protocol(WCTableViewTypingAhead)]) 169 _typeAhead = value; 170 } 171 172 173 174 - (BOOL)typeAhead { 175 return _typeAhead; 181 - (NSRect)frameOfCellAtColumn:(int)columnIndex row:(int)rowIndex { 182 NSNumber *tag; 183 NSString *key; 184 NSRect frame; 185 186 frame = [super frameOfCellAtColumn:columnIndex row:rowIndex]; 187 key = [NSString stringWithFormat:@"%d,%d", columnIndex, rowIndex]; 188 tag = [_regions objectForKey:key]; 189 190 if(tag) 191 [self removeToolTip:[tag intValue]]; 192 193 tag = [NSNumber numberWithInt:[self addToolTipRect:frame owner:self userData:NULL]]; 194 [_regions setObject:tag forKey:key]; 195 196 return frame; 197 } 198 199 200 201 - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)data { 202 int row; 203 204 row = [self rowAtPoint:point]; 205 206 if(row >= 0 && [[self dataSource] conformsToProtocol:@protocol(WCTableViewToolTipDisplaying)]) 207 return [[self dataSource] tableView:self toolTipForRow:row]; 208 209 return NULL; 176 210 } 177 211
