From: Andrew M. <fit...@us...> - 2006-08-29 01:32:05
|
Update of /cvsroot/radmind/radmind-assistant/rte In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv27854 Modified Files: RXTranscript.h RXTranscript.m Log Message: Some additional binding usage. Basic filter support. Audit uses RTEFilter class. Moving from enumerators to index sets where possible. Removed unused drawer code. Index: RXTranscript.m =================================================================== RCS file: /cvsroot/radmind/radmind-assistant/rte/RXTranscript.m,v retrieving revision 1.110 retrieving revision 1.111 diff -C2 -d -r1.110 -r1.111 *** RXTranscript.m 14 Jul 2006 14:28:24 -0000 1.110 --- RXTranscript.m 29 Aug 2006 01:32:00 -0000 1.111 *************** *** 24,30 **** #import "RXTranscript.h" ! #import "RTEAuditor.h" #import "RXPrefs.h" #import "RTEInfoPanelController.h" #import "NSString(RXAdditions).h" --- 24,31 ---- #import "RXTranscript.h" ! #import "RTEFilter.h" #import "RXPrefs.h" #import "RTEInfoPanelController.h" + #import "RXAppController.h" #import "NSString(RXAdditions).h" *************** *** 513,529 **** if ( [[ tWindow firstResponder ] isEqual: tContentsTableView ] ) { NSPasteboard *pb; ! NSMutableArray *copiedlines = [[ NSMutableArray alloc ] init ]; ! NSEnumerator *en = [ tContentsTableView selectedRowEnumerator ]; ! id linenum = nil; ! while (( linenum = [ en nextObject ] ) != nil ) { ! [ copiedlines addObject: ! [[ self displayedTranscriptContents ] ! objectAtIndex: [ linenum intValue ]]]; ! } pb = [ NSPasteboard generalPasteboard ]; ! [ pb declareTypes: [ NSArray arrayWithObject: RTETranscriptContentsPboardType ] owner: self ]; [ pb setPropertyList: copiedlines forType: RTETranscriptContentsPboardType ]; - [ copiedlines release ]; } else { if ( [[ tWindow firstResponder ] respondsToSelector: @selector( copy: ) ] ) { --- 514,530 ---- if ( [[ tWindow firstResponder ] isEqual: tContentsTableView ] ) { NSPasteboard *pb; ! NSMutableArray *copiedlines; ! 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: ) ] ) { *************** *** 556,578 **** { NSPasteboard *pb = [ NSPasteboard generalPasteboard ]; ! NSArray *types = [ pb types ]; ! ! if ( [ types containsObject: RTETranscriptContentsPboardType ] ) { if ( [[ tWindow firstResponder ] isEqual: tContentsTableView ] ) { - NSArray *pastedlines = nil; - NSMutableArray *lines = [[ self transcriptContents ] mutableCopy ]; - if ( mode == SEARCH ) { NSBeep(); return; } ! pastedlines = [ pb propertyListForType: RTETranscriptContentsPboardType ]; ! ! if ( lines == nil ) { lines = [[ NSMutableArray alloc ] init ]; ! } ! [ lines addObjectsFromArray: pastedlines ]; [ lines sortUsingFunction: &pathcompare context: nil ]; [ self setTranscriptContents: lines ]; --- 557,582 ---- { NSPasteboard *pb = [ NSPasteboard generalPasteboard ]; ! NSString *type = [ pb availableTypeFromArray: ! [ NSArray arrayWithObject: ! RTETranscriptContentsPboardType ]]; ! id pasteContents = nil; ! NSMutableArray *lines; ! ! if ( [ type isEqualToString: RTETranscriptContentsPboardType ] ) { if ( [[ tWindow firstResponder ] isEqual: tContentsTableView ] ) { if ( mode == SEARCH ) { NSBeep(); return; } + + pasteContents = [ pb propertyListForType: RTETranscriptContentsPboardType ]; ! if ( [ self transcriptContents ] == nil ) { lines = [[ NSMutableArray alloc ] init ]; ! } else { ! lines = [[ self transcriptContents ] mutableCopy ]; ! } ! [ lines addObjectsFromArray: pasteContents ]; [ lines sortUsingFunction: &pathcompare context: nil ]; [ self setTranscriptContents: lines ]; *************** *** 595,599 **** } ! [ tContentsTableView reloadData ]; [ tWindow setDocumentEdited: YES ]; } --- 599,603 ---- } ! //[ tContentsTableView reloadData ]; [ tWindow setDocumentEdited: YES ]; } *************** *** 728,734 **** if ( [ itemIdent isEqualToString: RTEToolbarInfoIdentifier ] ) { ! [ rxtbarItem setLabel: @"Info" ]; ! [ rxtbarItem setPaletteLabel: @"Info" ]; ! [ rxtbarItem setToolTip: @"Show item information" ]; [ rxtbarItem setImage: [ NSImage imageNamed: @"info.png" ]]; [ rxtbarItem setAction: @selector( showInfo: ) ]; --- 732,740 ---- if ( [ itemIdent isEqualToString: RTEToolbarInfoIdentifier ] ) { ! [ rxtbarItem setLabel: NSLocalizedString( ! @"Inspector", @"Inspector" ) ]; ! [ rxtbarItem setPaletteLabel: NSLocalizedString( ! @"Inspector", @"Inspector" ) ]; ! [ rxtbarItem setToolTip: @"Inspect selected item" ]; [ rxtbarItem setImage: [ NSImage imageNamed: @"info.png" ]]; [ rxtbarItem setAction: @selector( showInfo: ) ]; *************** *** 837,844 **** } else if ( [ transcriptSplitView isSubviewCollapsed: infoTabView ] ) { [ item setAction: @selector( showInfo: ) ]; - [ item setLabel: NSLocalizedString( @"Show Info", @"Show Info" ) ]; } else { [ item setAction: @selector( hideInfo: ) ]; - [ item setLabel: NSLocalizedString( @"Hide Info", @"Hide Info" ) ]; } } else if ( [[ item itemIdentifier ] isEqualToString: RTEToolbarConvertIdentifier ] ) { --- 843,848 ---- *************** *** 923,927 **** - ( void )auditTranscript: ( id )sender { ! RTEAuditor *auditor = [[ RTEAuditor alloc ] init ]; NSMutableArray *auditResults = nil; --- 927,931 ---- - ( void )auditTranscript: ( id )sender { ! RTEFilter *auditor = [[ RTEFilter alloc ] init ]; NSMutableArray *auditResults = nil; *************** *** 934,938 **** NSLocalizedString( @"Auditing...", @"Auditing..." ) ]; [ lineCountField displayIfNeeded ]; ! auditResults = [[ auditor auditTranscriptContents: [ self transcriptContents ]] retain ]; --- 938,942 ---- NSLocalizedString( @"Auditing...", @"Auditing..." ) ]; [ lineCountField displayIfNeeded ]; ! auditResults = [[ auditor auditTranscriptContents: [ self transcriptContents ]] retain ]; *************** *** 969,972 **** --- 973,1004 ---- } + - ( void )applyFilterToTranscript: ( id )sender + { + NSDictionary *filterDictionary = nil; + NSMutableArray *filteredTranscript; + RTEFilter *filter; + + if ( [[ NSApp delegate ] respondsToSelector: + @selector( filterWithTag: ) ] ) { + filterDictionary = [[ NSApp delegate ] filterWithTag: [ sender tag ]]; + } + if ( filterDictionary == nil ) { + return; + } + + 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 ]]; + [ tContentsTableView reloadData ]; + + if ( filteredTranscript ) { + [ filteredTranscript autorelease ]; + } + } + - ( void )showSourceTranscripts: ( id )sender { *************** *** 988,993 **** [ NSString stringWithFormat: @"-U%@", [[ self delegate ] sessionUserName ]], ! @"--", @"/usr/local/bin/twhich", ! @"-a", path, nil ]; [ self executeAuthorizedAction: TWHICH arguments: args ]; --- 1020,1030 ---- [ NSString stringWithFormat: @"-U%@", [[ self delegate ] sessionUserName ]], ! @"--", @"/usr/local/bin/twhich", nil ]; ! if ( [[ NSUserDefaults standardUserDefaults ] integerForKey: ! @"RTECaseSensitive" ] == 0 ) { ! args = [ args arrayByAddingObject: @"-I" ]; ! } ! args = [ args arrayByAddingObjectsFromArray: ! [ NSArray arrayWithObjects: @"-a", path, nil ]]; [ self executeAuthorizedAction: TWHICH arguments: args ]; *************** *** 1395,1400 **** menu = [[ menu itemWithTitle: NSLocalizedString( @"File", @"File" ) ] submenu ]; if (( menuItem = [ menu itemWithTitle: ! NSLocalizedString( @"Show Info", @"Show Info" ) ] ) != nil ) { ! [ menuItem setTitle: NSLocalizedString( @"Hide Info", @"Hide Info" ) ]; [ menuItem setAction: @selector( hideInfo: ) ]; } --- 1432,1436 ---- menu = [[ menu itemWithTitle: NSLocalizedString( @"File", @"File" ) ] submenu ]; if (( menuItem = [ menu itemWithTitle: ! NSLocalizedString( @"Inspector", @"Inspector" ) ] ) != nil ) { [ menuItem setAction: @selector( hideInfo: ) ]; } *************** *** 1443,1447 **** /* set its fields with the right information */ ! [ typeImage setImage: [ NSImage imageForType: type ]]; [ nameField setStringValue: [[ dict objectForKey: @"path" ] lastPathComponent ]]; --- 1479,1483 ---- /* set its fields with the right information */ ! [ typeImage setImage: [ NSImage imageForType: type ]]; [ nameField setStringValue: [[ dict objectForKey: @"path" ] lastPathComponent ]]; *************** *** 1473,1479 **** [ modified setStringValue: [ NSString formattedDateFromTimeInterval: [ dict objectForKey: @"mtime" ]]]; - [ chksum setStringValue: [ dict objectForKey: @"cksum" ]]; - [ owner setStringValue: [ dict objectForKey: @"owner" ]]; - [ group setStringValue: [ dict objectForKey: @"group" ]]; break; case 'D': --- 1509,1512 ---- *************** *** 1496,1502 **** break; } ! ! [ owner setStringValue: [ dict objectForKey: @"owner" ]]; ! [ group setStringValue: [ dict objectForKey: @"group" ]]; [ permissionsField setStringValue: [ NSString stringWithFormat: @"%@ (%@)", [[ dict objectForKey: @"perm" ] stringFromOctal ], --- 1529,1533 ---- break; } ! [ permissionsField setStringValue: [ NSString stringWithFormat: @"%@ (%@)", [[ dict objectForKey: @"perm" ] stringFromOctal ], *************** *** 1504,1508 **** [ size setStringValue: @"-" ]; [ modified setStringValue: @"-" ]; - [ chksum setStringValue: @"-" ]; break; case 'l': --- 1535,1538 ---- *************** *** 1516,1528 **** [ size setStringValue: @"-" ]; [ modified setStringValue: @"-" ]; - [ chksum setStringValue: @"-" ]; - [ owner setStringValue: @"-" ]; - [ group setStringValue: @"-" ]; break; case 'b': case 'c': - /* etc */ - [ owner setStringValue: [ dict objectForKey: @"owner" ]]; - [ group setStringValue: [ dict objectForKey: @"group" ]]; [ permissionsField setStringValue: [ NSString stringWithFormat: @"%@ (%@)", --- 1546,1552 ---- *************** *** 1547,1552 **** menu = [[ menu itemWithTitle: NSLocalizedString( @"File", @"File" ) ] submenu ]; if (( menuItem = [ menu itemWithTitle: ! NSLocalizedString( @"Hide Info", @"Hide Info" ) ] ) != nil ) { ! [ menuItem setTitle: NSLocalizedString( @"Show Info", @"Show Info" ) ]; [ menuItem setAction: @selector( showInfo: ) ]; } --- 1571,1575 ---- menu = [[ menu itemWithTitle: NSLocalizedString( @"File", @"File" ) ] submenu ]; if (( menuItem = [ menu itemWithTitle: ! NSLocalizedString( @"Inspector", @"Inspector" ) ] ) != nil ) { [ menuItem setAction: @selector( showInfo: ) ]; } *************** *** 2030,2045 **** - ( oneway void )addLines: ( NSArray * )lines fromThreadWithID: ( int )ID { if ( ID != [ self helperThreadID ] || [ lines count ] == 0 ) { return; } if ( [ self transcriptContents ] == nil ) { ! parsedLines = [[ NSMutableArray alloc ] initWithArray: lines ]; } else { ! [[ self transcriptContents ] addObjectsFromArray: lines ]; } /* XXXX sort should occur only after all lines have been added */ ! [[ self transcriptContents ] sortUsingFunction: &pathcompare context: NULL ]; [ self setDisplayedTranscriptContents: [ self transcriptContents ]]; [ tContentsTableView reloadData ]; [ loadProgressIndicator setIndeterminate: YES ]; --- 2053,2084 ---- - ( oneway void )addLines: ( NSArray * )lines fromThreadWithID: ( int )ID { + NSMutableArray *newLines; + int i; + if ( ID != [ self helperThreadID ] || [ lines count ] == 0 ) { return; } + + [ lines retain ]; + newLines = [ NSMutableArray arrayWithCapacity: [ lines count ]]; + for ( i = 0; i < [ lines count ]; i++ ) { + NSDictionary *dict; + + dict = [ NSMutableDictionary dictionaryForLine: + [ lines objectAtIndex: i ]]; + [ newLines addObject: dict ]; + } + [ lines release ]; if ( [ self transcriptContents ] == nil ) { ! parsedLines = [[ NSMutableArray alloc ] initWithArray: newLines ]; } else { ! [[ self transcriptContents ] addObjectsFromArray: newLines ]; } + /* XXXX sort should occur only after all lines have been added */ ! //[[ self transcriptContents ] sortUsingFunction: &pathcompare context: NULL ]; [ self setDisplayedTranscriptContents: [ self transcriptContents ]]; + [ tContentsTableView reloadData ]; [ loadProgressIndicator setIndeterminate: YES ]; *************** *** 2192,2196 **** [ parsedLines count ], ( [ parsedLines count ] == 1 ? @"" : @"s" ) ]]; ! //[ tContentsTableView reloadData ]; [[ tContentsTableView window ] makeFirstResponder: tContentsTableView ]; --- 2231,2235 ---- [ parsedLines count ], ( [ parsedLines count ] == 1 ? @"" : @"s" ) ]]; ! [ tContentsTableView reloadData ]; [[ tContentsTableView window ] makeFirstResponder: tContentsTableView ]; *************** *** 2406,2416 **** /* tableview data source methods */ - - ( int )numberOfRowsInTableView: ( NSTableView * )aTableView - { - int count = [[ self displayedTranscriptContents ] count ]; - - return( count ); - } - - ( void )tableView: ( NSTableView * )tableView willDisplayCell: ( id )aCell forTableColumn: ( NSTableColumn * )aTableColumn row: ( int )rowIndex --- 2445,2448 ---- *************** *** 2418,2423 **** NSMutableArray *lines = [ self displayedTranscriptContents ]; ! if ( rowIndex < 0 ) { ! NSLog( @"%d: invalid row.", rowIndex ); return; } --- 2450,2454 ---- NSMutableArray *lines = [ self displayedTranscriptContents ]; ! if ( rowIndex < 0 || rowIndex >= [ lines count] ) { return; } *************** *** 2557,2580 **** } - - ( 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 )tableViewSelectionDidChange: ( NSNotification * )notification { --- 2588,2591 ---- *************** *** 2582,2597 **** [ self showInfo: nil ]; } - - if ( [ transcriptLineDrawer state ] == NSDrawerOpenState ) { - int row = [ tContentsTableView selectedRow ]; - - if ( row >= 0 ) { - [ transcriptLineView setEditable: YES ]; - [ transcriptLineView setString: - [ NSString transcriptLineFromDictionary: - [[ self displayedTranscriptContents ] objectAtIndex: row ]]]; - [ transcriptLineView setEditable: NO ]; - } - } } --- 2593,2596 ---- Index: RXTranscript.h =================================================================== RCS file: /cvsroot/radmind/radmind-assistant/rte/RXTranscript.h,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** RXTranscript.h 10 Jul 2006 20:01:51 -0000 1.43 --- RXTranscript.h 29 Aug 2006 01:32:00 -0000 1.44 *************** *** 68,75 **** @interface RXTranscript : NSDocument { - /* drawer outlets */ - IBOutlet NSDrawer *transcriptLineDrawer; - IBOutlet NSTextView *transcriptLineView; - /* list view outlets */ IBOutlet NSView *tableView; --- 68,71 ---- *************** *** 153,156 **** --- 149,155 ---- RTETwhichDisplay *twhichDisplay; + NSMutableArray *columnContents, *parsedLines; + NSMutableArray *_rteDisplayedTranscriptLines; + @private int viewtype, mode; *************** *** 162,167 **** id _rteTranscriptDelegate; - NSMutableArray *columnContents, *parsedLines; - NSMutableArray *_rteDisplayedTranscriptLines; //NSMutableArray *curColumnItems; //NSView *origSuperView; --- 161,164 ---- |