A2725B6E0DE5C4F5003445E7 /* FileListNode.m in Sources */ = {isa = PBXBuildFile; fileRef = A2725B6D0DE5C4F5003445E7 /* FileListNode.m */; };
A2725D5D0DE7507C003445E7 /* TrackerTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = A2725D5C0DE7507C003445E7 /* TrackerTableView.m */; };
A277DA0B0C693D9C00DA2CD4 /* ActionOn.png in Resources */ = {isa = PBXBuildFile; fileRef = A277DA090C693D9C00DA2CD4 /* ActionOn.png */; };
+ A27F0F330E19AD9800B2DB97 /* TorrentGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = A27F0F320E19AD9800B2DB97 /* TorrentGroup.m */; };
A28F4F770E085BDC003A3882 /* ColorTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = A28F4F760E085BDC003A3882 /* ColorTextField.m */; };
A292A6E80DFB45FC004B9C0A /* webseed.c in Sources */ = {isa = PBXBuildFile; fileRef = A292A6E50DFB45EC004B9C0A /* webseed.c */; };
A29576030D11D63C0093B167 /* Creator.xib in Resources */ = {isa = PBXBuildFile; fileRef = A29576010D11D63C0093B167 /* Creator.xib */; };
A27476FF0CC38EE6003CC76D /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = macosx/es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
A27477010CC38EE6003CC76D /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = macosx/es.lproj/Localizable.strings; sourceTree = "<group>"; };
A277DA090C693D9C00DA2CD4 /* ActionOn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ActionOn.png; path = macosx/Images/ActionOn.png; sourceTree = "<group>"; };
+ A27F0F310E19AD9800B2DB97 /* TorrentGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TorrentGroup.h; path = macosx/TorrentGroup.h; sourceTree = "<group>"; };
+ A27F0F320E19AD9800B2DB97 /* TorrentGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TorrentGroup.m; path = macosx/TorrentGroup.m; sourceTree = "<group>"; };
A28AFE050DA1C47A00673957 /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = zh_TW; path = macosx/zh_TW.lproj/AddWindow.xib; sourceTree = "<group>"; };
A28AFE060DA1C47A00673957 /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = zh_TW; path = macosx/zh_TW.lproj/Creator.xib; sourceTree = "<group>"; };
A28AFE070DA1C47A00673957 /* zh_TW */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = zh_TW; path = macosx/zh_TW.lproj/InfoPlist.strings; sourceTree = "<group>"; };
4DF0C5A90899190500DD8943 /* Controller.m */,
4DFBC2DD09C0970D00D5C571 /* Torrent.h */,
4DFBC2DE09C0970D00D5C571 /* Torrent.m */,
+ A27F0F310E19AD9800B2DB97 /* TorrentGroup.h */,
+ A27F0F320E19AD9800B2DB97 /* TorrentGroup.m */,
4D364D9E091FBB2C00377D12 /* TorrentTableView.h */,
4D364D9F091FBB2C00377D12 /* TorrentTableView.m */,
4DCCBB3D09C3D71100D3CABF /* TorrentCell.h */,
A2725B6E0DE5C4F5003445E7 /* FileListNode.m in Sources */,
A2725D5D0DE7507C003445E7 /* TrackerTableView.m in Sources */,
A28F4F770E085BDC003A3882 /* ColorTextField.m in Sources */,
+ A27F0F330E19AD9800B2DB97 /* TorrentGroup.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
long long fExpectedSize;
}
-+ (void) downloadWithPrefsController: (PrefsController *) prefsController; //only use when no other blocklist downloads
++ (void) downloadWithPrefsController: (PrefsController *) prefsController; //only use when no other blocklist is downloading
- (void) cancelDownload: (id) sender;
#import "Controller.h"
#import "Torrent.h"
+#import "TorrentGroup.h"
#import "TorrentCell.h"
#import "TorrentTableView.h"
#import "CreatorWindowController.h"
if ([fDefaults boolForKey: @"SortByGroup"] && [NSApp isOnLeopardOrBetter])
{
NSEnumerator * enumerator = [fDisplayedTorrents objectEnumerator];
- NSDictionary * dict;
- while ((dict = [enumerator nextObject]))
- [[dict objectForKey: @"Torrents"] sortUsingDescriptors: descriptors];
+ TorrentGroup * group;
+ while ((group = [enumerator nextObject]))
+ [[group torrents] sortUsingDescriptors: descriptors];
}
else
[fDisplayedTorrents sortUsingDescriptors: descriptors];
previousTorrents = [NSMutableArray array];
NSEnumerator * enumerator = [fDisplayedTorrents objectEnumerator];
- NSDictionary * dict;
- while ((dict = [enumerator nextObject]))
- [previousTorrents addObjectsFromArray: [dict objectForKey: @"Torrents"]];
+ TorrentGroup * group;
+ while ((group = [enumerator nextObject]))
+ [previousTorrents addObjectsFromArray: [group torrents]];
}
else
previousTorrents = fDisplayedTorrents;
int groupValue = [torrent groupValue];
if (groupValue != oldGroupValue)
{
- groupTorrents = [NSMutableArray array];
- NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: groupValue], @"Group",
- groupTorrents, @"Torrents", nil];
- [fDisplayedTorrents addObject: dict];
+ TorrentGroup * group = [TorrentGroup groupForIndex: groupValue];
+ [fDisplayedTorrents addObject: group];
+ groupTorrents = [group torrents];
oldGroupValue = groupValue;
}
if (groupRows)
{
enumerator = [fDisplayedTorrents objectEnumerator];
- NSDictionary * dict;
- while ((dict = [enumerator nextObject]))
+ TorrentGroup * group;
+ while ((group = [enumerator nextObject]))
{
- if ([fTableView isGroupCollapsed: [[dict objectForKey: @"Group"] intValue]])
- [fTableView collapseItem: dict];
+ if ([fTableView isGroupCollapsed: [group groupIndex]])
+ [fTableView collapseItem: group];
else
- [fTableView expandItem: dict];
+ [fTableView expandItem: group];
}
}
- (NSInteger) outlineView: (NSOutlineView *) outlineView numberOfChildrenOfItem: (id) item
{
if (item)
- return [[item objectForKey: @"Torrents"] count];
+ return [[item torrents] count];
else
return [fDisplayedTorrents count];
}
- (id) outlineView: (NSOutlineView *) outlineView child: (NSInteger) index ofItem: (id) item
{
if (item)
- return [[item objectForKey: @"Torrents"] objectAtIndex: index];
+ return [[item torrents] objectAtIndex: index];
else
return [fDisplayedTorrents objectAtIndex: index];
}
NSString * ident = [tableColumn identifier];
if ([ident isEqualToString: @"Group"])
{
- int group = [[item objectForKey: @"Group"] intValue];
+ int group = [item groupIndex];
return group != -1 ? [[GroupsController groups] nameForIndex: group]
: NSLocalizedString(@"No Group", "Group table row");
}
else if ([ident isEqualToString: @"Color"])
{
- int group = [[item objectForKey: @"Group"] intValue];
+ int group = [item groupIndex];
return [[GroupsController groups] imageForIndex: group];
}
else if ([ident isEqualToString: @"DL Image"])
if ([fDefaults boolForKey: @"DisplayGroupRowRatio"])
{
uint64_t uploaded = 0, downloaded = 0;
- NSEnumerator * enumerator = [[item objectForKey: @"Torrents"] objectEnumerator];
+ NSEnumerator * enumerator = [[item torrents] objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
BOOL upload = [ident isEqualToString: @"UL"];
float rate = 0.0;
- NSEnumerator * enumerator = [[item objectForKey: @"Torrents"] objectEnumerator];
+ NSEnumerator * enumerator = [[item torrents] objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
rate += upload ? [torrent uploadRate] : [torrent downloadRate];
{
if ([item isKindOfClass: [Torrent class]])
{
- NSDictionary * group = [fTableView parentForItem: item];
- index = [[group objectForKey: @"Torrents"] indexOfObject: item] + 1;
+ TorrentGroup * group = [fTableView parentForItem: item];
+ index = [[group torrents] indexOfObject: item] + 1;
item = group;
}
}
if (item)
{
//change groups
- int groupValue = [[item objectForKey: @"Group"] intValue];
+ int groupValue = [item groupIndex];
NSEnumerator * enumerator = [movingTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
//have to reset objects here to avoid weird crash
- [[[fTableView parentForItem: torrent] objectForKey: @"Torrent"] removeObject: torrent];
- [[item objectForKey: @"Torrent"] addObject: torrent];
+ [[[fTableView parentForItem: torrent] torrents] removeObject: torrent];
+ [[item torrents] addObject: torrent];
[torrent setGroupValue: groupValue];
}
if (newRow != NSOutlineViewDropOnItemIndex)
{
//find torrent to place under
- NSArray * groupTorrents = item ? [item objectForKey: @"Torrents"] : fDisplayedTorrents;
+ NSArray * groupTorrents = item ? [item torrents] : fDisplayedTorrents;
Torrent * topTorrent = nil;
for (i = newRow-1; i >= 0; i--)
{
--- /dev/null
+/******************************************************************************
+ * $Id$
+ *
+ * Copyright (c) 2008 Transmission authors and contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+@interface TorrentGroup : NSObject
+{
+ NSInteger fGroup;
+ NSMutableArray * fTorrents;
+}
+
++ (id) groupForIndex: (int) group;
+
+- (NSInteger) groupIndex;
+- (NSMutableArray *) torrents;
+
+@end
--- /dev/null
+/******************************************************************************
+ * $Id$
+ *
+ * Copyright (c) 2008 Transmission authors and contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+#import "TorrentGroup.h"
+
+@interface TorrentGroup (Private)
+
+- (id) initWithGroup: (int) group;
+
+@end
+
+@implementation TorrentGroup
+
++ (id) groupForIndex: (int) group
+{
+ return [[[self alloc] initWithGroup: group] autorelease];
+}
+
+- (void) dealloc
+{
+ [fTorrents release];
+ [super dealloc];
+}
+
+- (NSInteger) groupIndex
+{
+ return fGroup;
+}
+
+- (NSMutableArray *) torrents
+{
+ return fTorrents;
+}
+
+@end
+
+@implementation TorrentGroup (Private)
+
+- (id) initWithGroup: (int) group
+{
+ if ((self = [super init]))
+ {
+ fGroup = group;
+ fTorrents = [[NSMutableArray alloc] init];
+ }
+ return self;
+}
+
+@end
#import "TorrentTableView.h"
#import "TorrentCell.h"
#import "Torrent.h"
+#import "TorrentGroup.h"
#import "FileListNode.h"
#import "QuickLookController.h"
#import "NSApplicationAdditions.h"
: NSLocalizedString(@"Upload speed", "Torrent table -> group row -> tooltip");
else if (ident)
{
- int count = [[item objectForKey: @"Torrents"] count];
+ int count = [[item torrents] count];
if (count == 1)
return NSLocalizedString(@"1 transfer", "Torrent table -> group row -> tooltip");
else
- (void) outlineViewItemDidExpand: (NSNotification *) notification
{
- int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue];
+ int value = [[[notification userInfo] objectForKey: @"NSObject"] groupIndex];
if (value < 0)
value = MAX_GROUP;
- (void) outlineViewItemDidCollapse: (NSNotification *) notification
{
- int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue];
+ int value = [[[notification userInfo] objectForKey: @"NSObject"] groupIndex];
if (value < 0)
value = MAX_GROUP;
}
else
{
- NSNumber * group = [item objectForKey: @"Group"];
- int i;
+ int i, group = [item groupIndex];
for (i = 0; i < [self numberOfRows]; i++)
{
if ([indexSet containsIndex: i])
continue;
id tableItem = [self itemAtRow: i];
- if (![tableItem isKindOfClass: [Torrent class]] && [group isEqualToNumber: [tableItem objectForKey: @"Group"]])
+ if (![tableItem isKindOfClass: [Torrent class]] && group == [tableItem groupIndex])
{
[indexSet addIndex: i];
break;
[torrents addObject: item];
else
{
- NSArray * groupTorrents = [item objectForKey: @"Torrents"];
+ NSArray * groupTorrents = [item torrents];
[torrents addObjectsFromArray: groupTorrents];
i += [groupTorrents count];
}