Going to SCM status has the groups expanded

Previously these would not initially be expanded but the expansion state remembered. Now that we regularly clear cache of expanded URLs, it’s more tedious regularly having to expand these two groups.

It also introduce new API for having data sources return what items should be initially expanded, which probably makes sense for some data sources.
This commit is contained in:
Allan Odgaard
2013-01-25 13:48:55 +01:00
parent b78cf9035a
commit a935aff340
4 changed files with 13 additions and 0 deletions

View File

@@ -188,6 +188,8 @@ static NSSet* VisibleItems (NSOutlineView* outlineView, FSItem* root, NSMutableS
if(dataSource = aDataSource)
{
if(NSArray* expandedByDefault = [dataSource expandedURLs])
[expandedURLs addObjectsFromArray:expandedByDefault];
[outlineView setDataSource:dataSource];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidReload:) name:FSItemDidReloadNotification object:dataSource];
[self expandAndSelectChildren:dataSource.rootItem expandAll:NO];

View File

@@ -11,6 +11,7 @@ extern NSString* const FSItemDidReloadNotification;
@property (nonatomic, retain) FSItem* rootItem;
- (BOOL)reloadItem:(FSItem*)anItem; // Returns YES if reload happens in the background. An FSItemDidReloadNotification is posted when reload has completed.
- (BOOL)unloadItem:(FSItem*)anItem;
- (NSArray*)expandedURLs;
@end
static NSUInteger const kFSDataSourceOptionGroupsFirst = (1 << 0);

View File

@@ -60,6 +60,11 @@ FSDataSource* DataSourceForURL (NSURL* anURL, NSUInteger someOptions)
return NO;
}
- (NSArray*)expandedURLs
{
return nil;
}
// =====================================
// = NSOutlineView Data Source Methods =
// =====================================

View File

@@ -148,6 +148,11 @@ _Iter prune_path_children (_Iter it, _Iter last)
return self;
}
- (NSArray*)expandedURLs
{
return @[ URLAppend(self.rootItem.url, @".unstaged/"), URLAppend(self.rootItem.url, @".untracked/") ];
}
- (void)dealloc
{
if(scmInfo && scmCallback)