mirror of
https://github.com/transmission/transmission
synced 2025-03-10 06:02:57 +00:00
add checks to file table for file selection...disabled until they actually can be used
This commit is contained in:
parent
5f5206a1b1
commit
cf9ccc6c73
3 changed files with 88 additions and 17 deletions
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -53,6 +53,9 @@
|
||||||
- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
|
- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
|
||||||
- (NSArray *) peerSortDescriptors;
|
- (NSArray *) peerSortDescriptors;
|
||||||
|
|
||||||
|
- (void) setFileCheckState: (int) state forItem: (NSMutableDictionary *) item;
|
||||||
|
- (void) resetFileCheckStateForItem: (NSMutableDictionary *) item;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation InfoWindowController
|
@implementation InfoWindowController
|
||||||
|
@ -676,21 +679,85 @@
|
||||||
if ([[tableColumn identifier] isEqualToString: @"Size"])
|
if ([[tableColumn identifier] isEqualToString: @"Size"])
|
||||||
return ![[item objectForKey: @"IsFolder"] boolValue]
|
return ![[item objectForKey: @"IsFolder"] boolValue]
|
||||||
? [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]] : @"";
|
? [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]] : @"";
|
||||||
|
else if ([[tableColumn identifier] isEqualToString: @"Check"])
|
||||||
|
return [item objectForKey: @"Check"];
|
||||||
else
|
else
|
||||||
return [item objectForKey: @"Name"];
|
return [item objectForKey: @"Name"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) outlineView: (NSOutlineView *) outlineView setObjectValue: (id) object
|
||||||
|
forTableColumn: (NSTableColumn *) tableColumn byItem: (id) item
|
||||||
|
{
|
||||||
|
int state = [object intValue] != NSOffState;
|
||||||
|
|
||||||
|
[self setFileCheckState: state forItem: item];
|
||||||
|
[self resetFileCheckStateForItem: [item objectForKey: @"Parent"]];
|
||||||
|
|
||||||
|
[fFileOutline reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setFileCheckState: (int) state forItem: (NSMutableDictionary *) item
|
||||||
|
{
|
||||||
|
[item setObject: [NSNumber numberWithInt: state] forKey: @"Check"];
|
||||||
|
|
||||||
|
if (![[item objectForKey: @"IsFolder"] boolValue])
|
||||||
|
return;
|
||||||
|
|
||||||
|
NSMutableDictionary * child;
|
||||||
|
NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator];
|
||||||
|
while ((child = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
if ([[child objectForKey: @"Check"] intValue] != state)
|
||||||
|
[self setFileCheckState: state forItem: child];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) resetFileCheckStateForItem: (NSMutableDictionary *) item
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int state = INVALID;
|
||||||
|
|
||||||
|
NSMutableDictionary * child;
|
||||||
|
NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator];
|
||||||
|
while ((child = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
if (state == INVALID)
|
||||||
|
{
|
||||||
|
state = [[child objectForKey: @"Check"] intValue];
|
||||||
|
if (state == NSMixedState)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (state != [[child objectForKey: @"Check"] intValue])
|
||||||
|
{
|
||||||
|
state = NSMixedState;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([[item objectForKey: @"Check"] intValue] != state)
|
||||||
|
{
|
||||||
|
[item setObject: [NSNumber numberWithInt: state] forKey: @"Check"];
|
||||||
|
[self resetFileCheckStateForItem: [item objectForKey: @"Parent"]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) outlineView: (NSOutlineView *) outlineView willDisplayCell: (id) cell
|
- (void) outlineView: (NSOutlineView *) outlineView willDisplayCell: (id) cell
|
||||||
forTableColumn: (NSTableColumn *) tableColumn item:(id) item
|
forTableColumn: (NSTableColumn *) tableColumn item:(id) item
|
||||||
{
|
{
|
||||||
if (![[tableColumn identifier] isEqualToString: @"Name"])
|
if ([[tableColumn identifier] isEqualToString: @"Name"])
|
||||||
return;
|
{
|
||||||
|
|
||||||
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFileType: ![[item objectForKey: @"IsFolder"] boolValue]
|
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFileType: ![[item objectForKey: @"IsFolder"] boolValue]
|
||||||
? [[item objectForKey: @"Name"] pathExtension] : NSFileTypeForHFSTypeCode('fldr')];
|
? [[item objectForKey: @"Name"] pathExtension] : NSFileTypeForHFSTypeCode('fldr')];
|
||||||
[icon setScalesWhenResized: YES];
|
[icon setScalesWhenResized: YES];
|
||||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||||
[cell setImage: icon];
|
[cell setImage: icon];
|
||||||
|
}
|
||||||
|
else if ([[tableColumn identifier] isEqualToString: @"Check"])
|
||||||
|
[cell setEnabled: NO];
|
||||||
|
else;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) outlineView: (NSOutlineView *) outlineView toolTipForCell: (NSCell *) cell rect: (NSRectPointer) rect
|
- (NSString *) outlineView: (NSOutlineView *) outlineView toolTipForCell: (NSCell *) cell rect: (NSRectPointer) rect
|
||||||
|
|
|
@ -44,8 +44,8 @@
|
||||||
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
|
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
|
||||||
|
|
||||||
- (NSArray *) createFileList;
|
- (NSArray *) createFileList;
|
||||||
- (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent
|
- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
|
||||||
previousPath: (NSString *) previousPath fileSize: (uint64_t) size;
|
withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath fileSize: (uint64_t) size;
|
||||||
- (NSImage *) advancedBar;
|
- (NSImage *) advancedBar;
|
||||||
- (void) trashFile: (NSString *) path;
|
- (void) trashFile: (NSString *) path;
|
||||||
|
|
||||||
|
@ -1109,7 +1109,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation Torrent (Private)
|
@implementation Torrent (Private)
|
||||||
|
|
||||||
//if a hash is given, attempt to load that; otherwise, attempt to open file at path
|
//if a hash is given, attempt to load that; otherwise, attempt to open file at path
|
||||||
|
@ -1223,14 +1222,14 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
else
|
else
|
||||||
path = @"";
|
path = @"";
|
||||||
|
|
||||||
[self insertPath: pathComponents withParent: files previousPath: path fileSize: file->length];
|
[self insertPath: pathComponents forSiblings: files withParent: nil previousPath: path fileSize: file->length];
|
||||||
[pathComponents autorelease];
|
[pathComponents autorelease];
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent
|
- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
|
||||||
previousPath: (NSString *) previousPath fileSize: (uint64_t) size
|
withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath fileSize: (uint64_t) size
|
||||||
{
|
{
|
||||||
NSString * name = [components objectAtIndex: 0];
|
NSString * name = [components objectAtIndex: 0];
|
||||||
BOOL isFolder = [components count] > 1;
|
BOOL isFolder = [components count] > 1;
|
||||||
|
@ -1238,7 +1237,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
NSMutableDictionary * dict = nil;
|
NSMutableDictionary * dict = nil;
|
||||||
if (isFolder)
|
if (isFolder)
|
||||||
{
|
{
|
||||||
NSEnumerator * enumerator = [parent objectEnumerator];
|
NSEnumerator * enumerator = [siblings objectEnumerator];
|
||||||
while ((dict = [enumerator nextObject]))
|
while ((dict = [enumerator nextObject]))
|
||||||
if ([[dict objectForKey: @"Name"] isEqualToString: name] && [[dict objectForKey: @"IsFolder"] boolValue])
|
if ([[dict objectForKey: @"Name"] isEqualToString: name] && [[dict objectForKey: @"IsFolder"] boolValue])
|
||||||
break;
|
break;
|
||||||
|
@ -1257,13 +1256,18 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
else
|
else
|
||||||
[dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
|
[dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
|
||||||
|
|
||||||
[parent addObject: dict];
|
if (parent)
|
||||||
|
[dict setObject: parent forKey: @"Parent"];
|
||||||
|
[dict setObject: [NSNumber numberWithInt: NSOnState] forKey: @"Check"];
|
||||||
|
|
||||||
|
[siblings addObject: dict];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFolder)
|
if (isFolder)
|
||||||
{
|
{
|
||||||
[components removeObjectAtIndex: 0];
|
[components removeObjectAtIndex: 0];
|
||||||
[self insertPath: components withParent: [dict objectForKey: @"Children"] previousPath: currentPath fileSize: size];
|
[self insertPath: components forSiblings: [dict objectForKey: @"Children"]
|
||||||
|
withParent: dict previousPath: currentPath fileSize: size];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue