for the fun of it, replace some variables with @property in the file and tracker nodes

This commit is contained in:
Mitchell Livingston
2012-01-20 02:41:49 +00:00
parent 12dc463e61
commit 63b5979594
5 changed files with 22 additions and 51 deletions

View File

@@ -28,18 +28,20 @@
@interface FileListNode : NSObject <NSCopying>
{
NSString * fName, * fPath;
BOOL fIsFolder;
NSMutableIndexSet * fIndexes;
uint64_t fSize;
NSImage * fIcon;
NSMutableArray * fChildren;
Torrent * fTorrent;
}
@property (nonatomic, readonly) NSString * name;
@property (nonatomic, readonly) NSString * path;
@property (nonatomic, readonly) Torrent * torrent;
@property (nonatomic, readonly) uint64_t size;
@property (nonatomic, readonly) NSImage * icon;
@property (nonatomic, readonly) BOOL isFolder;
- (id) initWithFolderName: (NSString *) name path: (NSString *) path torrent: (Torrent *) torrent;
- (id) initWithFileName: (NSString *) name path: (NSString *) path size: (uint64_t) size index: (NSUInteger) index torrent: (Torrent *) torrent;
@@ -48,16 +50,8 @@
- (NSString *) description;
- (BOOL) isFolder;
- (NSString *) name;
- (NSString *) path;
- (NSIndexSet *) indexes;
- (uint64_t) size;
- (NSImage *) icon;
- (NSMutableArray *) children;
- (Torrent *) torrent;
@end

View File

@@ -32,6 +32,13 @@
@implementation FileListNode
@synthesize name = fName;
@synthesize path = fPath;
@synthesize torrent = fTorrent;
@synthesize size = fSize;
@synthesize icon = fIcon;
@synthesize isFolder = fIsFolder;
- (id) initWithFolderName: (NSString *) name path: (NSString *) path torrent: (Torrent *) torrent
{
if ((self = [self initWithFolder: YES name: name path: path torrent: torrent]))
@@ -96,31 +103,11 @@
return [NSString stringWithFormat: @"%@ (folder: %@)", fName, fIndexes];
}
- (BOOL) isFolder
{
return fIsFolder;
}
- (NSString *) name
{
return fName;
}
- (NSString *) path
{
return fPath;
}
- (NSIndexSet *) indexes
{
return fIndexes;
}
- (uint64_t) size
{
return fSize;
}
- (NSImage *) icon
{
if (!fIcon)
@@ -136,11 +123,6 @@
return fChildren;
}
- (Torrent *) torrent
{
return fTorrent;
}
@end
@implementation FileListNode (Private)

View File

@@ -297,7 +297,7 @@ int trashDataFile(const char * filename)
const BOOL wasStalled = fStat != NULL && [self isStalled];
fStat = tr_torrentStat(fHandle);
//make sure the "active" filter is updated when stalled-ness changes
if (wasStalled != [self isStalled])
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateQueue" object: self];

View File

@@ -30,10 +30,10 @@
@interface TrackerNode : NSObject
{
tr_tracker_stat fStat;
Torrent * fTorrent; //weak reference
}
@property (nonatomic, readonly) Torrent * torrent;
- (id) initWithTrackerStat: (tr_tracker_stat *) stat torrent: (Torrent *) torrent;
- (BOOL) isEqual: (id) object;
@@ -45,8 +45,6 @@
- (NSUInteger) identifier;
- (Torrent *) torrent;
- (NSInteger) totalSeeders;
- (NSInteger) totalLeechers;
- (NSInteger) totalDownloaded;

View File

@@ -27,12 +27,14 @@
@implementation TrackerNode
@synthesize torrent = fTorrent;
- (id) initWithTrackerStat: (tr_tracker_stat *) stat torrent: (Torrent *) torrent
{
if ((self = [super init]))
{
fStat = *stat;
fTorrent = torrent;
fTorrent = torrent; //weak reference
}
return self;
@@ -83,11 +85,6 @@
return fStat.id;
}
- (Torrent *) torrent
{
return fTorrent;
}
- (NSInteger) totalSeeders
{
return fStat.seederCount;