Skip to content

Commit

Permalink
added some outline view extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsneed committed Jan 17, 2011
1 parent 4a000bb commit e731ba8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
17 changes: 17 additions & 0 deletions NSOutlineView+Additions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// NSOutlineView+Additions.h
// gitty
//
// Created by brandon on 1/17/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>


@interface NSOutlineView(Additions)

- (void)expandParentsOfItem:(id)item;
- (void)selectItem:(id)item;

@end
41 changes: 41 additions & 0 deletions NSOutlineView+Additions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// NSOutlineView+Additions.m
// gitty
//
// Created by brandon on 1/17/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "NSOutlineView+Additions.h"


@implementation NSOutlineView(Additions)

- (void)expandParentsOfItem:(id)item
{
while (item != nil)
{
id parent = [self parentForItem: item];
if (![self isExpandable: parent])
break;
if (![self isItemExpanded: parent])
[self expandItem: parent];
item = parent;
}
}

- (void)selectItem:(id)item
{
NSInteger itemIndex = [self rowForItem:item];
if (itemIndex < 0)
{
[self expandParentsOfItem: item];
itemIndex = [self rowForItem:item];
if (itemIndex < 0)
return;
}

[self selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO];
}

@end

0 comments on commit e731ba8

Please sign in to comment.