Changeset 2010
- Timestamp:
- Jun 9, 2007, 8:44:55 PM (15 years ago)
- Location:
- branches/file_selection
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/file_selection/libtransmission/torrent.c
r2005 r2010 600 600 } 601 601 602 /* !!!!!!!!!! ADD ABILITY TO DO FOR INDIVIDUAL FILES !!!!!!!!!!!!!! */ 602 603 float * tr_torrentCompletion( tr_torrent_t * tor ) 603 604 { -
branches/file_selection/macosx/FileBrowserCell.h
r1644 r2010 27 27 @interface FileBrowserCell : NSBrowserCell 28 28 { 29 float fPercent; 29 30 } 30 31 32 - (void) setProgress: (float) progress; 33 31 34 @end -
branches/file_selection/macosx/FileBrowserCell.m
r1644 r2010 40 40 [image setScalesWhenResized: YES]; 41 41 [super setImage: image]; 42 } 43 44 - (void) setProgress: (float) progress 45 { 46 fPercent = progress * 100.0; 42 47 } 43 48 … … 86 91 87 92 NSString * statusString = [NSString stringWithFormat: NSLocalizedString(@"%.2f%% of %@", 88 "Inspector -> Files tab -> file status string"), 89 100.0 * [[item objectForKey: @"Progress"] floatValue], 93 "Inspector -> Files tab -> file status string"), fPercent, 90 94 [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]]; 91 95 -
branches/file_selection/macosx/InfoWindowController.m
r2008 r2010 24 24 25 25 #import "InfoWindowController.h" 26 #import "FileBrowserCell.h" 26 27 #import "StringAdditions.h" 27 28 … … 429 430 - (void) updateInfoFiles 430 431 { 431 if ([fTorrents count] != 1) 432 return; 433 434 if ([[fTorrents objectAtIndex: 0] updateFileProgress]) 432 if ([fTorrents count] == 1) 435 433 [fFileOutline reloadData]; 436 434 } … … 796 794 797 795 if ([[tableColumn identifier] isEqualToString: @"Check"]) 798 return [ item objectForKey: @"Check"];796 return [NSNumber numberWithInt: [[fTorrents objectAtIndex: 0] shouldDownloadItem: item]]; 799 797 else 800 798 return item; … … 809 807 return; 810 808 811 [cell setImage: [[item objectForKey: @"IsFolder"] boolValue] ? fFolderIcon : [item objectForKey: @"Icon"]]; 809 BOOL isFolder; 810 #warning move folder icon into FileBrowserCell 811 if ((isFolder = [[item objectForKey: @"IsFolder"] boolValue])) 812 [cell setImage: fFolderIcon]; 813 else 814 { 815 [cell setImage: [item objectForKey: @"Icon"]]; 816 [(FileBrowserCell *)cell setProgress: [[fTorrents objectAtIndex: 0] fileProgress: 817 [[item objectForKey: @"Index"] floatValue]]]; 818 } 812 819 } 813 820 else if ([[tableColumn identifier] isEqualToString: @"Check"]) … … 821 828 822 829 [(NSButtonCell *)cell setImagePosition: NSImageOnly]; 823 [cell setEnabled: [[item objectForKey: @"IsFolder"] boolValue] ? [[item objectForKey: @"Remaining"] intValue] > 0 824 : [[item objectForKey: @"Progress"] floatValue] < 1.0]; 830 [cell setEnabled: [[fTorrents objectAtIndex: 0] canChangeDownloadItemCheck: item]]; 825 831 } 826 832 else; … … 834 840 835 841 [torrent setFileCheckState: state forFileItem: item]; 836 NSMutableDictionary * topItem = [torrent resetFileCheckStateForItemParent: item]; 837 838 [fFileOutline reloadItem: topItem reloadChildren: YES]; 842 [fFileOutline reloadData]; 839 843 } 840 844 -
branches/file_selection/macosx/Torrent.h
r1972 r2010 54 54 NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString; 55 55 56 NSArray * fFileList , * fFileFlatList;56 NSArray * fFileList; 57 57 58 58 int fUploadLimit, fDownloadLimit; … … 202 202 - (NSArray *) fileList; 203 203 - (int) fileCount; 204 - (BOOL) updateFileProgress; 205 - (void) setFileCheckState: (int) state forFileItem: (NSMutableDictionary *) item; 206 - (NSMutableDictionary *) resetFileCheckStateForItemParent: (NSMutableDictionary *) originalChild; 204 - (float) fileProgress: (int) index; 205 - (int) shouldDownloadItem: (NSDictionary *) item; 206 - (BOOL) canChangeDownloadItemCheck: (NSDictionary *) item; 207 - (void) setFileCheckState: (int) state forFileItem: (NSDictionary *) item; 207 208 208 209 - (NSDate *) dateAdded; -
branches/file_selection/macosx/Torrent.m
r2008 r2010 49 49 - (void) createFileListShouldDownload: (NSArray *) filesShouldDownload priorities: (NSArray *) filePriorities; 50 50 - (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings 51 withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath52 fileSize: (uint64_t) size state: (int) state flatList: (NSMutableArray *) flatList;51 withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath 52 fileSize: (uint64_t) size index: (int) index; 53 53 - (NSImage *) advancedBar; 54 54 - (void) trashFile: (NSString *) path; … … 175 175 nil]; 176 176 177 NSMutableArray * filesShouldDownload = [NSMutableArray arrayWithCapacity: [fFileFlatList count]]; 178 NSEnumerator * enumerator = [fFileFlatList objectEnumerator]; 179 NSDictionary * file; 180 while ((file = [enumerator nextObject])) 181 [filesShouldDownload addObject: [file objectForKey: @"Check"]]; 177 //set file priorities 178 int fileCount = [self fileCount]; 179 NSMutableArray * filesShouldDownload = [NSMutableArray arrayWithCapacity: fileCount]; 180 181 tr_priority_t * priorities = tr_torrentGetFilePriorities(fHandle); 182 int i; 183 for (i = 0; i < fileCount; i++) 184 [filesShouldDownload addObject: [NSNumber numberWithInt: priorities[i]]]; 185 free(priorities); 182 186 [history setObject: filesShouldDownload forKey: @"FilesShouldDownload"]; 183 187 … … 237 241 238 242 [fFileList release]; 239 [fFileFlatList release];240 243 241 244 [fBitmap release]; … … 1303 1306 } 1304 1307 1305 - ( BOOL) updateFileProgress1306 { 1307 BOOL change = NO;1308 - (float) fileProgress: (int) index 1309 { 1310 #warning redo for single 1308 1311 float * progress = tr_torrentCompletion(fHandle); 1309 NSNumber * progressNum; 1310 NSMutableDictionary * item, * dict; 1311 1312 int i, fileCount = [self fileCount]; 1313 for (i = 0; i < fileCount; i++) 1314 { 1315 if (!(progressNum = [[fFileFlatList objectAtIndex: i] objectForKey: @"Progress"]) 1316 || [progressNum floatValue] != progress[i]) 1317 { 1318 item = [fFileFlatList objectAtIndex: i]; 1319 [item setObject: [NSNumber numberWithFloat: progress[i]] forKey: @"Progress"]; 1320 change = YES; 1321 1322 if (progress[i] == 1.0) 1323 { 1324 dict = item; 1325 while ((dict = [dict objectForKey: @"Parent"])) 1326 [dict setObject: [NSNumber numberWithInt: [[dict objectForKey: @"Remaining"] intValue]-1] 1327 forKey: @"Remaining"]; 1328 1329 [item setObject: [NSNumber numberWithInt: NSOnState] forKey: @"Check"]; 1330 [self resetFileCheckStateForItemParent: item]; 1331 } 1332 } 1333 } 1334 1312 float fileProgress = progress[index]; 1335 1313 free(progress); 1336 1314 1337 return change; 1338 } 1339 1340 - (void) setFileCheckState: (int) state forFileItem: (NSMutableDictionary *) item 1341 { 1342 [item setObject: [NSNumber numberWithInt: state] forKey: @"Check"]; 1343 1315 return fileProgress; 1316 } 1317 1318 - (int) shouldDownloadItem: (NSDictionary *) item 1319 { 1320 if ([[item objectForKey: @"IsFolder"] boolValue]) 1321 { 1322 #warning do 1323 return NSOnState; 1324 } 1325 else 1326 { 1327 int index = [[item objectForKey: @"Index"] intValue]; 1328 return tr_torrentGetFilePriority(fHandle, index) != TR_PRI_DND || [self fileProgress: index] >= 1.0 1329 ? NSOnState : NSOffState; 1330 } 1331 } 1332 1333 - (BOOL) canChangeDownloadItemCheck: (NSDictionary *) item 1334 { 1335 if ([[item objectForKey: @"IsFolder"] boolValue]) 1336 { 1337 #warning do 1338 return YES; 1339 } 1340 else 1341 { 1342 #warning why is this happening? 1343 float progress = [self fileProgress: [[item objectForKey: @"Index"] intValue]]; 1344 if (progress < 1.0) 1345 NSLog(@"hi %f", progress); 1346 else 1347 NSLog(@"asdgagh %f", progress); 1348 return [self fileProgress: [[item objectForKey: @"Index"] intValue]] < 1.0; 1349 } 1350 } 1351 1352 - (void) setFileCheckState: (int) state forFileItem: (NSDictionary *) item 1353 { 1344 1354 if (![[item objectForKey: @"IsFolder"] boolValue]) 1345 return; 1346 1347 NSMutableDictionary * child; 1348 NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator]; 1349 while ((child = [enumerator nextObject])) 1350 if (state != [[child objectForKey: @"Check"] intValue]) 1355 tr_torrentSetFilePriority(fHandle, [[item objectForKey: @"Index"] intValue], 1356 state == NSOnState ? TR_PRI_NORMAL : TR_PRI_DND); 1357 else 1358 { 1359 NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator]; 1360 NSDictionary * child; 1361 while ((child = [enumerator nextObject])) 1351 1362 [self setFileCheckState: state forFileItem: child]; 1352 } 1353 1354 - (NSMutableDictionary *) resetFileCheckStateForItemParent: (NSMutableDictionary *) originalChild 1355 { 1356 NSMutableDictionary * item; 1357 if (!(item = [originalChild objectForKey: @"Parent"])) 1358 return originalChild; 1359 1360 int state = INVALID; 1361 1362 NSMutableDictionary * child; 1363 NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator]; 1364 while ((child = [enumerator nextObject])) 1365 { 1366 if (state == INVALID) 1367 { 1368 state = [[child objectForKey: @"Check"] intValue]; 1369 if (state == NSMixedState) 1370 break; 1371 } 1372 else if (state != [[child objectForKey: @"Check"] intValue]) 1373 { 1374 state = NSMixedState; 1375 break; 1376 } 1377 else; 1378 } 1379 1380 if (state != [[item objectForKey: @"Check"] intValue]) 1381 { 1382 [item setObject: [NSNumber numberWithInt: state] forKey: @"Check"]; 1383 return [self resetFileCheckStateForItemParent: item]; 1384 } 1385 else 1386 return originalChild; 1363 } 1387 1364 } 1388 1365 … … 1575 1552 int shouldDownload; 1576 1553 1577 NSMutableArray * fileList = [[NSMutableArray alloc] init], 1578 * fileFlatList = [[NSMutableArray alloc] initWithCapacity: count]; 1554 NSMutableArray * fileList = [[NSMutableArray alloc] init]; 1579 1555 1580 1556 for (i = 0; i < count; i++) … … 1590 1566 else 1591 1567 path = @""; 1568 1569 [self insertPath: pathComponents forSiblings: fileList withParent: nil previousPath: path 1570 fileSize: file->length index: i]; 1571 [pathComponents autorelease]; 1592 1572 1593 1573 shouldDownload = filesShouldDownload ? [[filesShouldDownload objectAtIndex: i] intValue] : NSOnState; 1594 1574 #warning add priorities 1595 1575 tr_torrentSetFilePriority(fHandle, i, shouldDownload == NSOnState ? TR_PRI_NORMAL : TR_PRI_DND); 1596 1597 [self insertPath: pathComponents forSiblings: fileList withParent: nil previousPath: path1598 fileSize: file->length state: shouldDownload flatList: fileFlatList];1599 [pathComponents autorelease];1600 1576 } 1601 1577 1602 1578 fFileList = [[NSArray alloc] initWithArray: fileList]; 1603 1579 [fileList release]; 1604 fFileFlatList = [[NSArray alloc] initWithArray: fileFlatList];1605 [fileFlatList release];1606 1580 } 1607 1581 1608 1582 - (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings 1609 1583 withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath 1610 fileSize: (uint64_t) size state: (int) state flatList: (NSMutableArray *) flatList1584 fileSize: (uint64_t) size index: (int) index 1611 1585 { 1612 1586 NSString * name = [components objectAtIndex: 0]; … … 1634 1608 { 1635 1609 [dict setObject: [NSMutableArray array] forKey: @"Children"]; 1636 [dict setObject: [NSNumber numberWithInt: 1] forKey: @"Remaining"];1637 1610 } 1638 1611 else 1639 1612 { 1640 [ flatList addObject: dict];1613 [dict setObject: [NSNumber numberWithInt: index] forKey: @"Index"]; 1641 1614 [dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"]; 1642 1615 [dict setObject: [[NSWorkspace sharedWorkspace] iconForFileType: [name pathExtension]] forKey: @"Icon"]; … … 1645 1618 if (parent) 1646 1619 [dict setObject: parent forKey: @"Parent"]; 1647 [dict setObject: [NSNumber numberWithInt: state] forKey: @"Check"];1648 1620 } 1649 1621 else … … 1651 1623 if (isFolder) 1652 1624 [dict setObject: [NSNumber numberWithInt: [[dict objectForKey: @"Remaining"] intValue]+1] forKey: @"Remaining"]; 1653 1654 int dictState = [[dict objectForKey: @"Check"] intValue];1655 if (dictState != NSMixedState && dictState != state)1656 [dict setObject: [NSNumber numberWithInt: NSMixedState] forKey: @"Check"];1657 1625 } 1658 1626 … … 1661 1629 [components removeObjectAtIndex: 0]; 1662 1630 [self insertPath: components forSiblings: [dict objectForKey: @"Children"] 1663 withParent: dict previousPath: currentPath fileSize: size state: state flatList: flatList];1631 withParent: dict previousPath: currentPath fileSize: size index: index]; 1664 1632 } 1665 1633 }
Note: See TracChangeset
for help on using the changeset viewer.