Changeset 7189


Ignore:
Timestamp:
Nov 29, 2008, 9:29:06 PM (10 years ago)
Author:
livings124
Message:

fix a whoops with group row removal; when removing a row, select the row below it

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/GroupsController.m

    r7187 r7189  
    197197{
    198198    NSInteger index = [[[fGroups objectAtIndex: row] objectForKey: @"Index"] intValue];
    199     [fGroups removeObjectAtIndex: index];
     199    [fGroups removeObjectAtIndex: row];
    200200   
    201201    [[NSNotificationCenter defaultCenter] postNotificationName: @"GroupValueRemoved" object: self userInfo:
  • trunk/macosx/GroupsWindowController.m

    r7188 r7189  
    5858    [fAddRemoveControl setEnabled: NO forSegment: REMOVE_TAG];
    5959    [fSelectedColorView addObserver: self forKeyPath: @"color" options: 0 context: NULL];
    60     [self updateSelectedColor];
     60   
     61    if ([fTableView numberOfRows] > 0)
     62        [fTableView selectRow: 0 byExtendingSelection: NO];
     63    else
     64        [self updateSelectedColor]; //make sure all fields are disabled
    6165}
    6266
     
    8185{
    8286    [self updateSelectedColor];
    83 }
    84 
    85 - (void) updateSelectedColor
    86 {
    87     [fAddRemoveControl setEnabled: [fTableView numberOfSelectedRows] > 0 forSegment: REMOVE_TAG];
    88     if ([fTableView numberOfSelectedRows] == 1)
    89     {
    90         NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
    91         [fSelectedColorView setColor: [[GroupsController groups] colorForIndex: index]];
    92         [fSelectedColorView setEnabled: YES];
    93         [fSelectedColorNameField setStringValue: [[GroupsController groups] nameForIndex: index]];
    94         [fSelectedColorNameField setEnabled: YES];
    95     }
    96     else
    97     {
    98         [fSelectedColorView setColor: [NSColor whiteColor]];
    99         [fSelectedColorView setEnabled: NO];
    100         [fSelectedColorNameField setStringValue: @""];
    101         [fSelectedColorNameField setEnabled: NO];
    102     }
    10387}
    10488
     
    172156           
    173157            row = [fTableView numberOfRows]-1;
    174             [fTableView selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
     158            [fTableView selectRow: row byExtendingSelection: NO];
    175159            [fTableView scrollRowToVisible: row];
    176160           
     
    185169                [[NSColorPanel sharedColorPanel] close];
    186170           
    187             [[GroupsController groups] removeGroupWithRowIndex: row];
    188            
    189             [fTableView deselectAll: self];
     171            [[GroupsController groups] removeGroupWithRowIndex: row];           
     172                       
    190173            [fTableView reloadData];
    191174           
     175            //select the next row
     176            if (row == [fTableView numberOfRows])
     177                row--;
     178            if (row >= 0)
     179                [fTableView selectRow: row byExtendingSelection: NO];
     180           
    192181            break;
    193182    }
     
    195184
    196185@end
     186
     187@implementation GroupsWindowController (Private)
     188
     189- (void) updateSelectedColor
     190{
     191    [fAddRemoveControl setEnabled: [fTableView numberOfSelectedRows] > 0 forSegment: REMOVE_TAG];
     192    if ([fTableView numberOfSelectedRows] == 1)
     193    {
     194        NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
     195        [fSelectedColorView setColor: [[GroupsController groups] colorForIndex: index]];
     196        [fSelectedColorView setEnabled: YES];
     197        [fSelectedColorNameField setStringValue: [[GroupsController groups] nameForIndex: index]];
     198        [fSelectedColorNameField setEnabled: YES];
     199    }
     200    else
     201    {
     202        [fSelectedColorView setColor: [NSColor whiteColor]];
     203        [fSelectedColorView setEnabled: NO];
     204        [fSelectedColorNameField setStringValue: @""];
     205        [fSelectedColorNameField setEnabled: NO];
     206    }
     207}
     208
     209@end
Note: See TracChangeset for help on using the changeset viewer.