at creation of file hierarchy determine the state of folders

This commit is contained in:
Mitchell Livingston 2007-01-18 03:54:56 +00:00
parent 4b9df2981b
commit 04345733d9
3 changed files with 19 additions and 6 deletions

View File

@ -4,6 +4,11 @@
@implementation FileBrowserCell @implementation FileBrowserCell
- (void) awakeFromNib
{
[self setLeaf: YES];
}
- (void) setImage: (NSImage *) image - (void) setImage: (NSImage *) image
{ {
[image setFlipped: YES]; [image setFlipped: YES];

View File

@ -30,7 +30,6 @@
- (void) awakeFromNib - (void) awakeFromNib
{ {
NSBrowserCell * browserCell = [[[FileBrowserCell alloc] init] autorelease]; NSBrowserCell * browserCell = [[[FileBrowserCell alloc] init] autorelease];
[browserCell setLeaf: YES];
[[self tableColumnWithIdentifier: @"Name"] setDataCell: browserCell]; [[self tableColumnWithIdentifier: @"Name"] setDataCell: browserCell];
[self setAutoresizesOutlineColumn: NO]; [self setAutoresizesOutlineColumn: NO];

View File

@ -45,7 +45,8 @@
- (NSArray *) createFileList; - (NSArray *) createFileList;
- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings - (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath fileSize: (uint64_t) size; withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
fileSize: (uint64_t) size state: (int) state;
- (NSImage *) advancedBar; - (NSImage *) advancedBar;
- (void) trashFile: (NSString *) path; - (void) trashFile: (NSString *) path;
@ -1222,14 +1223,16 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
else else
path = @""; path = @"";
[self insertPath: pathComponents forSiblings: files withParent: nil previousPath: path fileSize: file->length]; [self insertPath: pathComponents forSiblings: files withParent: nil previousPath: path
fileSize: file->length state: NSOnState];
[pathComponents autorelease]; [pathComponents autorelease];
} }
return files; return files;
} }
- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings - (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath fileSize: (uint64_t) size withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
fileSize: (uint64_t) size state: (int) state
{ {
NSString * name = [components objectAtIndex: 0]; NSString * name = [components objectAtIndex: 0];
BOOL isFolder = [components count] > 1; BOOL isFolder = [components count] > 1;
@ -1258,16 +1261,22 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
if (parent) if (parent)
[dict setObject: parent forKey: @"Parent"]; [dict setObject: parent forKey: @"Parent"];
[dict setObject: [NSNumber numberWithInt: NSOnState] forKey: @"Check"]; [dict setObject: [NSNumber numberWithInt: state] forKey: @"Check"];
[siblings addObject: dict]; [siblings addObject: dict];
} }
else
{
int dictState = [[dict objectForKey: @"Check"] intValue];
if (dictState != NSMixedState && dictState != state)
[dict setObject: [NSNumber numberWithInt: NSMixedState] forKey: @"Check"];
}
if (isFolder) if (isFolder)
{ {
[components removeObjectAtIndex: 0]; [components removeObjectAtIndex: 0];
[self insertPath: components forSiblings: [dict objectForKey: @"Children"] [self insertPath: components forSiblings: [dict objectForKey: @"Children"]
withParent: dict previousPath: currentPath fileSize: size]; withParent: dict previousPath: currentPath fileSize: size state: state];
} }
} }