From 04345733d942cef95ebecc4bfb3e8b0f57060500 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 18 Jan 2007 03:54:56 +0000 Subject: [PATCH] at creation of file hierarchy determine the state of folders --- macosx/FileBrowserCell.m | 5 +++++ macosx/FileOutlineView.m | 1 - macosx/Torrent.m | 19 ++++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/macosx/FileBrowserCell.m b/macosx/FileBrowserCell.m index 7500272ec..ef529775a 100644 --- a/macosx/FileBrowserCell.m +++ b/macosx/FileBrowserCell.m @@ -4,6 +4,11 @@ @implementation FileBrowserCell +- (void) awakeFromNib +{ + [self setLeaf: YES]; +} + - (void) setImage: (NSImage *) image { [image setFlipped: YES]; diff --git a/macosx/FileOutlineView.m b/macosx/FileOutlineView.m index 894222529..ae08171b1 100644 --- a/macosx/FileOutlineView.m +++ b/macosx/FileOutlineView.m @@ -30,7 +30,6 @@ - (void) awakeFromNib { NSBrowserCell * browserCell = [[[FileBrowserCell alloc] init] autorelease]; - [browserCell setLeaf: YES]; [[self tableColumnWithIdentifier: @"Name"] setDataCell: browserCell]; [self setAutoresizesOutlineColumn: NO]; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 93bd37ff5..0626e6150 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -45,7 +45,8 @@ - (NSArray *) createFileList; - (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; - (void) trashFile: (NSString *) path; @@ -1222,14 +1223,16 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 else 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]; } return files; } - (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]; BOOL isFolder = [components count] > 1; @@ -1258,16 +1261,22 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 if (parent) [dict setObject: parent forKey: @"Parent"]; - [dict setObject: [NSNumber numberWithInt: NSOnState] forKey: @"Check"]; + [dict setObject: [NSNumber numberWithInt: state] forKey: @"Check"]; [siblings addObject: dict]; } + else + { + int dictState = [[dict objectForKey: @"Check"] intValue]; + if (dictState != NSMixedState && dictState != state) + [dict setObject: [NSNumber numberWithInt: NSMixedState] forKey: @"Check"]; + } if (isFolder) { [components removeObjectAtIndex: 0]; [self insertPath: components forSiblings: [dict objectForKey: @"Children"] - withParent: dict previousPath: currentPath fileSize: size]; + withParent: dict previousPath: currentPath fileSize: size state: state]; } }