Skip to content

Commit

Permalink
Use modern NSIndexSet row selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
K8TIY committed Dec 5, 2012
1 parent d235464 commit 8892074
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions TerminusEstDocument.m
Expand Up @@ -656,8 +656,15 @@ -(IBAction)delete:(id)sender
NSInteger i;
for (i = [_table numberOfRows]; i > 0; i--)
if ([_table isRowSelected:i-1]) [self _deleteMachineAtIndex:i-1 withActionName:NSLocalizedString(@"__UNDO_DELETE__", @"Delete Machine")];
if ([_table isRowSelected:i-1])
[self _deleteMachineAtIndex:i-1 withActionName:NSLocalizedString(@"__UNDO_DELETE__", @"Delete Machine")];
if ([_table selectedRow] == -1)
[_table selectRow:[_table numberOfRows]-1 byExtendingSelection:NO];
{
NSIndexSet* rows = [[NSIndexSet alloc] initWithIndex:[_table numberOfRows]-1];
[_table selectRowIndexes:rows byExtendingSelection:NO];
[rows release];
}
}

-(IBAction)machineOp:(id)sender
Expand Down Expand Up @@ -923,8 +930,12 @@ -(BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
dropRow = [self _moveRows:array to:dropRow copying:isCopy];
[table deselectAll:self];
NSMutableIndexSet* rows = [[NSMutableIndexSet alloc] init];
for (id blah in array)
[table selectRow:(dropRow++) byExtendingSelection:YES];
[rows addIndex:dropRow++];
[table selectRowIndexes:rows byExtendingSelection:YES];
[rows release];
accepted = YES;
}
}
Expand Down Expand Up @@ -1021,6 +1032,7 @@ -(void)_insertMachine:(TEMachine*)m atIndex:(NSUInteger)i withActionName:(NSStri
{
[_table reloadData];
[_table selectRow:i byExtendingSelection:NO];
[_table selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO];
[_table scrollRowToVisible:i];
[[[self undoManager] prepareWithInvocationTarget:self] _deleteMachineAtIndex:i withActionName:action];
[[self undoManager] setActionName:action];
Expand Down

0 comments on commit 8892074

Please sign in to comment.