Changeset 2088
- Timestamp:
- Jun 16, 2007, 3:19:55 AM (15 years ago)
- Location:
- branches/file_selection/macosx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/file_selection/macosx/InfoWindowController.m
r2086 r2088 604 604 NSDictionary * item; 605 605 NSIndexSet * indexSet = [fFileOutline selectedRowIndexes], * itemIndexes; 606 NSMutableIndexSet * usedIndexes = [NSMutableIndexSet indexSet]; 606 607 int i, index, state = (menuItem == fFileCheckItem) ? NSOnState : NSOffState; 607 608 for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i]) 608 609 { 609 item = [fFileOutline itemAtRow: i];610 if ( [[item objectForKey: @"IsFolder"] boolValue])610 itemIndexes = [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"]; 611 if (![usedIndexes containsIndexes: itemIndexes]) 611 612 { 612 itemIndexes = [item objectForKey: @"Indexes"]; 613 if ([torrent checkForFileFolder: itemIndexes] != state 614 && [torrent canChangeDownloadCheckForFileFolder: itemIndexes]) 613 if ([torrent checkForFiles: itemIndexes] != state && [torrent canChangeDownloadCheckForFiles: itemIndexes]) 615 614 return YES; 616 } 617 else 618 { 619 index = [[item objectForKey: @"Index"] intValue]; 620 if ([torrent checkForFile: index] != state && [torrent canChangeDownloadCheckFile: index]) 621 return YES; 615 [usedIndexes addIndexes: itemIndexes]; 622 616 } 623 617 } … … 648 642 for (i = [indexSet firstIndex]; i != NSNotFound && (!current || !other); i = [indexSet indexGreaterThanIndex: i]) 649 643 { 650 if ([torrent hasFilePriority: priority forI tem: [fFileOutline itemAtRow: i]])644 if ([torrent hasFilePriority: priority forIndexes: [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"]]) 651 645 current = YES; 652 646 else … … 852 846 { 853 847 if ([[tableColumn identifier] isEqualToString: @"Check"]) 854 { 855 Torrent * torrent = [fTorrents objectAtIndex: 0]; 856 if ([[item objectForKey: @"IsFolder"] boolValue]) 857 return [NSNumber numberWithInt: [torrent checkForFileFolder: [item objectForKey: @"Indexes"]]]; 858 else 859 return [NSNumber numberWithInt: [torrent checkForFile: [[item objectForKey: @"Index"] intValue]]]; 860 } 848 return [NSNumber numberWithInt: [[fTorrents objectAtIndex: 0] checkForFiles: [item objectForKey: @"Indexes"]]]; 861 849 else 862 850 return item; … … 875 863 [cell setImage: [item objectForKey: @"Icon"]]; 876 864 [(FileBrowserCell *)cell setProgress: [[fTorrents objectAtIndex: 0] fileProgress: 877 [[item objectForKey: @"Index "] intValue]]];865 [[item objectForKey: @"Indexes"] firstIndex]]]; 878 866 } 879 867 } 880 868 else if ([identifier isEqualToString: @"Check"]) 869 [cell setEnabled: [[fTorrents objectAtIndex: 0] canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]]]; 870 else if ([identifier isEqualToString: @"Priority"]) 881 871 { 882 872 Torrent * torrent = [fTorrents objectAtIndex: 0]; 883 if ([[item objectForKey: @"IsFolder"] boolValue]) 884 [cell setEnabled: [torrent canChangeDownloadCheckForFileFolder: [item objectForKey: @"Indexes"]]]; 885 else 886 [cell setEnabled: [torrent canChangeDownloadCheckFile: [[item objectForKey: @"Index"] intValue]]]; 887 } 888 else if ([identifier isEqualToString: @"Priority"]) 889 { 890 Torrent * torrent = [fTorrents objectAtIndex: 0]; 891 [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_LOW forItem: item] forSegment: 0]; 892 [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_NORMAL forItem: item] forSegment: 1]; 893 [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_HIGH forItem: item] forSegment: 2]; 873 NSIndexSet * indexeSet = [item objectForKey: @"Indexes"]; 874 [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_LOW forIndexes: indexeSet] forSegment: 0]; 875 [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_NORMAL forIndexes: indexeSet] forSegment: 1]; 876 [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_HIGH forIndexes: indexeSet] forSegment: 2]; 894 877 } 895 878 else; … … 904 887 Torrent * torrent = [fTorrents objectAtIndex: 0]; 905 888 [torrent setFileCheckState: [object intValue] != NSOffState ? NSOnState : NSOffState 906 for FileItem: item];889 forIndexes: [item objectForKey: @"Indexes"]]; 907 890 908 891 [torrent update]; … … 920 903 actualPriority = PRIORITY_NORMAL; 921 904 922 [[fTorrents objectAtIndex: 0] setFilePriority: actualPriority for FileItem: item];905 [[fTorrents objectAtIndex: 0] setFilePriority: actualPriority forIndexes: [item objectForKey: @"Indexes"]]; 923 906 [fFileOutline reloadData]; 924 907 } … … 945 928 { 946 929 Torrent * torrent = [fTorrents objectAtIndex: 0]; 947 BOOL low = [torrent hasFilePriority: PRIORITY_LOW forItem: item], 948 normal = [torrent hasFilePriority: PRIORITY_NORMAL forItem: item], 949 high = [torrent hasFilePriority: PRIORITY_HIGH forItem: item]; 930 NSIndexSet * indexSet = [item objectForKey: @"Indexes"]; 931 BOOL low = [torrent hasFilePriority: PRIORITY_LOW forIndexes: indexSet], 932 normal = [torrent hasFilePriority: PRIORITY_NORMAL forIndexes: indexSet], 933 high = [torrent hasFilePriority: PRIORITY_HIGH forIndexes: indexSet]; 950 934 951 935 if (low && !normal && !high) … … 1027 1011 1028 1012 Torrent * torrent = [fTorrents objectAtIndex: 0]; 1029 NSIndexSet * indexSet = [fFileOutline selectedRowIndexes]; 1013 NSIndexSet * indexSet = [fFileOutline selectedRowIndexes], * itemIndexes; 1014 NSMutableIndexSet * usedIndexes = [NSMutableIndexSet indexSet]; 1030 1015 int i; 1031 1016 for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i]) 1032 [torrent setFileCheckState: state forFileItem: [fFileOutline itemAtRow: i]]; 1017 { 1018 itemIndexes = [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"]; 1019 if (![usedIndexes containsIndexes: itemIndexes]) 1020 { 1021 [torrent setFileCheckState: state forIndexes: itemIndexes]; 1022 [usedIndexes addIndexes: itemIndexes]; 1023 } 1024 } 1033 1025 1034 1026 [fFileOutline reloadData]; … … 1049 1041 int i; 1050 1042 for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i]) 1051 [torrent setFilePriority: priority for FileItem: [fFileOutline itemAtRow: i]];1043 [torrent setFilePriority: priority forIndexes: [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"]]; 1052 1044 1053 1045 [fFileOutline reloadData]; -
branches/file_selection/macosx/Torrent.h
r2080 r2088 58 58 NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString; 59 59 60 NSArray * fFileList ;60 NSArray * fFileList, * fFlatFileList; 61 61 62 62 int fUploadLimit, fDownloadLimit; … … 205 205 - (int) fileCount; 206 206 - (float) fileProgress: (int) index; 207 - (int) checkForFile: (int) index; 208 - (int) checkForFileFolder: (NSIndexSet *) indexSet; 209 - (BOOL) canChangeDownloadCheckFile: (int) index; 210 - (BOOL) canChangeDownloadCheckForFileFolder: (NSIndexSet *) indexSet; 211 - (void) setFileCheckState: (int) state forFileItem: (NSDictionary *) item; 212 - (void) setFilePriority: (int) priority forFileItem: (NSMutableDictionary *) item; 213 - (BOOL) hasFilePriority: (int) priority forItem: (NSDictionary *) item; 207 - (int) checkForFiles: (NSIndexSet *) indexSet; 208 - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet; 209 - (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet; 210 - (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet; 211 - (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet; 214 212 215 213 - (NSDate *) dateAdded; -
branches/file_selection/macosx/Torrent.m
r2087 r2088 51 51 - (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings 52 52 withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath 53 f ileSize: (uint64_t) size index: (int) index priority: (int) priority;53 flatList: (NSMutableArray *) flatList fileSize: (uint64_t) size index: (int) index priority: (int) priority; 54 54 - (NSImage *) advancedBar; 55 55 - (void) trashFile: (NSString *) path; … … 1318 1318 } 1319 1319 1320 - (int) checkForFile: (int) index 1321 { 1322 return (tr_torrentGetFilePriority(fHandle, index) != TR_PRI_DND || [self fileProgress: index] >= 1.0) 1323 ? NSOnState : NSOffState; 1324 } 1325 1326 - (int) checkForFileFolder: (NSIndexSet *) indexSet 1320 - (int) checkForFiles: (NSIndexSet *) indexSet 1327 1321 { 1328 1322 BOOL onState = NO, offState = NO; … … 1330 1324 for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) 1331 1325 { 1332 if ( [self checkForFile: index] == NSOnState)1326 if (tr_torrentGetFilePriority(fHandle, index) != TR_PRI_DND || [self fileProgress: index] >= 1.0) 1333 1327 onState = YES; 1334 1328 else … … 1341 1335 } 1342 1336 1343 - (BOOL) canChangeDownloadCheckFile: (int) index 1344 { 1345 return [self fileProgress: index] < 1.0; 1346 } 1347 1348 - (BOOL) canChangeDownloadCheckForFileFolder: (NSIndexSet *) indexSet 1337 - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet 1349 1338 { 1350 1339 int index; 1351 1340 for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) 1352 if ([self canChangeDownloadCheckFile: index])1341 if ([self fileProgress: index] < 1.0) 1353 1342 return YES; 1354 1343 return NO; 1355 1344 } 1356 1345 1357 - (void) setFileCheckState: (int) state forFileItem: (NSDictionary *) item 1358 { 1359 if (![[item objectForKey: @"IsFolder"] boolValue]) 1346 - (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet 1347 { 1348 int index; 1349 for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) 1360 1350 { 1361 1351 tr_priority_t actualPriority; 1362 1352 if (state == NSOnState) 1363 1353 { 1364 int priority = [[ itemobjectForKey: @"Priority"] intValue];1354 int priority = [[[fFlatFileList objectAtIndex: index] objectForKey: @"Priority"] intValue]; 1365 1355 if (priority == PRIORITY_HIGH) 1366 1356 actualPriority = TR_PRI_HIGH; … … 1373 1363 actualPriority = TR_PRI_DND; 1374 1364 1375 tr_torrentSetFilePriority(fHandle, [[item objectForKey: @"Index"] intValue], actualPriority); 1376 } 1377 else 1378 { 1379 NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator]; 1380 NSDictionary * child; 1381 while ((child = [enumerator nextObject])) 1382 [self setFileCheckState: state forFileItem: child]; 1383 } 1384 } 1385 1386 - (void) setFilePriority: (int) priority forFileItem: (NSMutableDictionary *) item 1387 { 1388 if (![[item objectForKey: @"IsFolder"] boolValue]) 1389 { 1390 [item setObject: [NSNumber numberWithInt: priority] forKey: @"Priority"]; 1391 1392 int index = [[item objectForKey: @"Index"] intValue]; 1393 if ([self checkForFile: index] == NSOnState) 1365 tr_torrentSetFilePriority(fHandle, index, actualPriority); 1366 } 1367 } 1368 1369 - (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet 1370 { 1371 NSNumber * priorityValue = [NSNumber numberWithInt: priority]; 1372 1373 int index; 1374 for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) 1375 { 1376 [[fFlatFileList objectAtIndex: index] setObject: priorityValue forKey: @"Priority"]; 1377 1378 if ([self checkForFiles: [NSIndexSet indexSetWithIndex: index]] == NSOnState) 1394 1379 { 1395 1380 tr_priority_t actualPriority; … … 1403 1388 } 1404 1389 } 1405 else 1406 { 1407 NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator]; 1408 NSMutableDictionary * child; 1409 while ((child = [enumerator nextObject])) 1410 [self setFilePriority: priority forFileItem: child]; 1411 } 1412 } 1413 1414 - (BOOL) hasFilePriority: (int) priority forItem: (NSDictionary *) item 1415 { 1416 if (![[item objectForKey: @"IsFolder"] boolValue]) 1417 return priority == [[item objectForKey: @"Priority"] intValue]; 1418 else 1419 { 1420 NSEnumerator * enumerator = [[item objectForKey: @"Children"] objectEnumerator]; 1421 NSDictionary * child; 1422 while ((child = [enumerator nextObject])) 1423 if ([self hasFilePriority: priority forItem: child]) 1424 return YES; 1425 return NO; 1426 } 1390 } 1391 1392 - (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet 1393 { 1394 int index; 1395 for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) 1396 if (priority == [[[fFlatFileList objectAtIndex: index] objectForKey: @"Priority"] intValue]) 1397 return YES; 1398 return NO; 1427 1399 } 1428 1400 … … 1616 1588 tr_priority_t actualPriority; 1617 1589 1618 NSMutableArray * fileList = [[NSMutableArray alloc] init]; 1590 NSMutableArray * fileList = [[NSMutableArray alloc] init], 1591 * flatFileList = [[NSMutableArray alloc] initWithCapacity: count]; 1619 1592 1620 1593 for (i = 0; i < count; i++) … … 1633 1606 priority = filePriorities ? [[filePriorities objectAtIndex: i] intValue] : PRIORITY_NORMAL; 1634 1607 [self insertPath: pathComponents forSiblings: fileList withParent: nil previousPath: path 1635 f ileSize: file->length index: i priority: priority];1608 flatList: flatFileList fileSize: file->length index: i priority: priority]; 1636 1609 [pathComponents autorelease]; 1637 1610 … … 1653 1626 fFileList = [[NSArray alloc] initWithArray: fileList]; 1654 1627 [fileList release]; 1628 fFlatFileList = [[NSArray alloc] initWithArray: flatFileList]; 1629 [flatFileList release]; 1655 1630 } 1656 1631 1657 1632 - (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings 1658 1633 withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath 1659 f ileSize: (uint64_t) size index: (int) index priority: (int) priority1634 flatList: (NSMutableArray *) flatList fileSize: (uint64_t) size index: (int) index priority: (int) priority 1660 1635 { 1661 1636 NSString * name = [components objectAtIndex: 0]; … … 1687 1662 else 1688 1663 { 1689 [dict setObject: [NS Number numberWithInt: index] forKey: @"Index"];1664 [dict setObject: [NSIndexSet indexSetWithIndex: index] forKey: @"Indexes"]; 1690 1665 [dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"]; 1691 1666 [dict setObject: [[NSWorkspace sharedWorkspace] iconForFileType: [name pathExtension]] forKey: @"Icon"]; 1692 1667 [dict setObject: [NSNumber numberWithInt: priority] forKey: @"Priority"]; 1668 1669 [flatList addObject: dict]; 1693 1670 } 1694 1671 … … 1697 1674 } 1698 1675 else 1699 { 1700 if (isFolder) 1701 [[dict objectForKey: @"Indexes"] addIndex: index]; 1702 } 1676 [[dict objectForKey: @"Indexes"] addIndex: index]; 1703 1677 1704 1678 if (isFolder) … … 1706 1680 [components removeObjectAtIndex: 0]; 1707 1681 [self insertPath: components forSiblings: [dict objectForKey: @"Children"] 1708 withParent: dict previousPath: currentPath f ileSize: size index: index priority: priority];1682 withParent: dict previousPath: currentPath flatList: flatList fileSize: size index: index priority: priority]; 1709 1683 } 1710 1684 } -
branches/file_selection/macosx/TorrentCell.m
r2087 r2088 118 118 } 119 119 120 121 122 120 [[NSColor colorWithDeviceWhite: 0.0 alpha: 0.2] set]; 123 121 [NSBezierPath strokeRect: NSInsetRect(barBounds, 0.5, 0.5)];
Note: See TracChangeset
for help on using the changeset viewer.