| | 621 | |
|---|
| | 622 | |
|---|
| | 623 | - (void)outlineViewShouldCopyInfo:(NSOutlineView *)outlineView { |
|---|
| | 624 | NSEnumerator *enumerator; |
|---|
| | 625 | NSPasteboard *pasteboard; |
|---|
| | 626 | NSMutableArray *rows; |
|---|
| | 627 | NSMutableString *indentation, *string; |
|---|
| | 628 | NSArray *nodes; |
|---|
| | 629 | TNNode *node; |
|---|
| | 630 | NSInteger level, baseLevel; |
|---|
| | 631 | BOOL showSelf; |
|---|
| | 632 | |
|---|
| | 633 | nodes = [self _selectedNodes]; |
|---|
| | 634 | |
|---|
| | 635 | if([nodes count] > 0) { |
|---|
| | 636 | rows = [NSMutableArray array]; |
|---|
| | 637 | indentation = [NSMutableString string]; |
|---|
| | 638 | baseLevel = [_treeOutlineView levelForItem:[nodes objectAtIndex:0]]; |
|---|
| | 639 | enumerator = [nodes objectEnumerator]; |
|---|
| | 640 | showSelf = [[_treeOutlineView tableColumns] containsObject:_selfTableColumn]; |
|---|
| | 641 | |
|---|
| | 642 | while((node = [enumerator nextObject])) { |
|---|
| | 643 | [indentation setString:@""]; |
|---|
| | 644 | |
|---|
| | 645 | level = [_treeOutlineView levelForItem:node] - baseLevel; |
|---|
| | 646 | |
|---|
| | 647 | while(level > 0) { |
|---|
| | 648 | [indentation appendString:@" "]; |
|---|
| | 649 | level--; |
|---|
| | 650 | } |
|---|
| | 651 | |
|---|
| | 652 | string = [NSMutableString stringWithFormat:@"%@%.1f%% %@ %@", |
|---|
| | 653 | indentation, |
|---|
| | 654 | [node cumulativePercent], |
|---|
| | 655 | [[node function] library], |
|---|
| | 656 | [[node function] symbol]]; |
|---|
| | 657 | |
|---|
| | 658 | if(showSelf) |
|---|
| | 659 | [string insertString:[NSSWF:@"%.1f%% ", [node percent]] atIndex:[indentation length]]; |
|---|
| | 660 | |
|---|
| | 661 | [rows addObject:string]; |
|---|
| | 662 | } |
|---|
| | 663 | |
|---|
| | 664 | pasteboard = [NSPasteboard generalPasteboard]; |
|---|
| | 665 | [pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NULL]; |
|---|
| | 666 | [pasteboard setString:[rows componentsJoinedByString:@"\n"] forType:NSStringPboardType]; |
|---|
| | 667 | } |
|---|
| | 668 | } |
|---|
| | 669 | |
|---|