|
From: Andrew M. <fit...@us...> - 2007-06-24 23:11:48
|
Update of /cvsroot/radmind/radmind-assistant/rte In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv4792 Modified Files: RXTranscript.m Log Message: Copy/paste works again. Restored tableview data source methods until I have time to work on version using bindings. Index: RXTranscript.m =================================================================== RCS file: /cvsroot/radmind/radmind-assistant/rte/RXTranscript.m,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** RXTranscript.m 29 Aug 2006 01:32:00 -0000 1.111 --- RXTranscript.m 24 Jun 2007 23:11:43 -0000 1.112 *************** *** 423,426 **** --- 423,428 ---- NSMutableArray *transcriptObjects = transcriptLines; NSMutableArray *searchCopy = nil; + NSMutableIndexSet *searchIndexes; + unsigned int i; if ( searchResults != nil ) { *************** *** 443,448 **** return; } ! ! [[ self transcriptContents ] removeObjectsInArray: transcriptObjects ]; transcriptObjects = searchResults; } --- 445,459 ---- return; } ! ! searchIndexes = [[ NSMutableIndexSet alloc ] init ]; ! for ( i = 0; i < [ transcriptObjects count ]; i++ ) { ! [ searchIndexes addIndex: [[[ transcriptObjects objectAtIndex: i ] ! objectForKey: @"tindex" ] intValue ]]; ! } ! if ( [ searchIndexes count ] > 0 ) { ! [[ self transcriptContents ] removeObjectsAtIndexes: searchIndexes ]; ! } ! [ searchIndexes release ]; ! transcriptObjects = searchResults; } *************** *** 517,530 **** NSIndexSet *indexes = [ tContentsTableView selectedRowIndexes ]; ! copiedlines = [ NSMutableArray arrayWithCapacity: [ indexes count ]]; [ copiedlines addObjectsFromArray: [[ self displayedTranscriptContents ] objectsAtIndexes: indexes ]]; ! pb = [ NSPasteboard generalPasteboard ]; [ pb declareTypes: [ NSArray arrayWithObject: RTETranscriptContentsPboardType ] owner: self ]; ! [ pb setPropertyList: copiedlines forType: RTETranscriptContentsPboardType ]; } else { if ( [[ tWindow firstResponder ] respondsToSelector: @selector( copy: ) ] ) { --- 528,544 ---- NSIndexSet *indexes = [ tContentsTableView selectedRowIndexes ]; ! copiedlines = [[ NSMutableArray alloc ] initWithCapacity: [ indexes count ]]; [ copiedlines addObjectsFromArray: [[ self displayedTranscriptContents ] objectsAtIndexes: indexes ]]; ! pb = [ NSPasteboard generalPasteboard ]; [ pb declareTypes: [ NSArray arrayWithObject: RTETranscriptContentsPboardType ] owner: self ]; ! ! [ pb setData: [ NSArchiver archivedDataWithRootObject: copiedlines ] ! forType: RTETranscriptContentsPboardType ]; ! [ copiedlines release ]; } else { if ( [[ tWindow firstResponder ] respondsToSelector: @selector( copy: ) ] ) { *************** *** 560,564 **** [ NSArray arrayWithObject: RTETranscriptContentsPboardType ]]; ! id pasteContents = nil; NSMutableArray *lines; --- 574,579 ---- [ NSArray arrayWithObject: RTETranscriptContentsPboardType ]]; ! NSData *pasteData; ! id pasteContents; NSMutableArray *lines; *************** *** 570,574 **** } ! pasteContents = [ pb propertyListForType: RTETranscriptContentsPboardType ]; if ( [ self transcriptContents ] == nil ) { --- 585,594 ---- } ! pasteData = [ pb dataForType: type ]; ! pasteContents = [ NSUnarchiver unarchiveObjectWithData: pasteData ]; ! if ( pasteContents == nil ) { ! NSBeep(); ! return; ! } if ( [ self transcriptContents ] == nil ) { *************** *** 599,603 **** } ! //[ tContentsTableView reloadData ]; [ tWindow setDocumentEdited: YES ]; } --- 619,623 ---- } ! [ tContentsTableView reloadData ]; [ tWindow setDocumentEdited: YES ]; } *************** *** 988,995 **** filter = [[[ RTEFilter alloc ] init ] autorelease ]; filteredTranscript = [ filter filterTranscript: [ self transcriptContents ] withFilterPatterns: [ NSArray arrayWithObject: filterDictionary ]]; ! /* XXX add undo invocation */ [ self setTranscriptContents: filteredTranscript ]; [ self setDisplayedTranscriptContents: [ self transcriptContents ]]; --- 1008,1018 ---- filter = [[[ RTEFilter alloc ] init ] autorelease ]; + /* XXX faster to do with NSIndexSet? */ filteredTranscript = [ filter filterTranscript: [ self transcriptContents ] withFilterPatterns: [ NSArray arrayWithObject: filterDictionary ]]; ! [[ self undoManager ] registerUndoWithTarget: self ! selector: @selector( setTranscriptContents: ) ! object: [ self transcriptContents ]]; [ self setTranscriptContents: filteredTranscript ]; [ self setDisplayedTranscriptContents: [ self transcriptContents ]]; *************** *** 2445,2448 **** --- 2468,2498 ---- /* tableview data source methods */ + - ( int )numberOfRowsInTableView: ( NSTableView * )aTableView + { + int count = [[ self displayedTranscriptContents ] count ]; + + return( count ); + } + + - ( id )tableView: ( NSTableView * )aTableView + objectValueForTableColumn: ( NSTableColumn * )aTableColumn + row: ( int )rowIndex + { + NSMutableArray *lines = [ self displayedTranscriptContents ]; + + if ( [[ aTableColumn identifier ] isEqualToString: @"Path" ] ) { + NSString *path = [[ lines objectAtIndex: rowIndex ] objectForKey: @"path" ]; + NSAttributedString *attrString = [[[ NSAttributedString alloc ] initWithString: path ] autorelease ]; + double width = [ aTableColumn width ]; + + attrString = [ attrString ellipsisAbbreviatedStringForWidth: width ]; + + return( attrString ); + } + + /* rest handled by willDisplayCell: */ + return( @"" ); + } + - ( void )tableView: ( NSTableView * )tableView willDisplayCell: ( id )aCell forTableColumn: ( NSTableColumn * )aTableColumn row: ( int )rowIndex |