Revision: 6478
http://skim-app.svn.sourceforge.net/skim-app/?rev=6478&view=rev
Author: hofman
Date: 2010-04-21 11:28:38 +0000 (Wed, 21 Apr 2010)
Log Message:
-----------
implement kvo dependent keys in main method
Modified Paths:
--------------
trunk/SKDownload.m
Modified: trunk/SKDownload.m
===================================================================
--- trunk/SKDownload.m 2010-04-21 09:34:24 UTC (rev 6477)
+++ trunk/SKDownload.m 2010-04-21 11:28:38 UTC (rev 6478)
@@ -44,7 +44,12 @@
NSString *SKDownloadStatusKey = @"status";
NSString *SKDownloadProgressIndicatorKey = @"progressIndicator";
-#define SKFilePathKey @"filePath"
+#define SKFilePathKey @"filePath"
+#define SKFileIconKey @"fileIcon"
+#define SKCanCancelKey @"canCancel"
+#define SKCanRemoveKey @"canRemove"
+#define SKCanResumeKey @"canResume"
+#define SKInfoKey @"info"
@interface SKDownload ()
@property (nonatomic) SKDownloadStatus status;
@@ -60,34 +65,32 @@
@synthesize URL, URLDownload, filePath, fileIcon, expectedContentLength,
receivedContentLength, status, delegate;
@dynamic fileName, info, canCancel, canRemove, canResume;
-+ (NSSet *)infoKeys {
- return [NSSet setWithObjects:SKDownloadFileNameKey, SKDownloadStatusKey,
SKDownloadProgressIndicatorKey, nil];
-}
+static NSSet *keysAffectedByFilePath = nil;
+static NSSet *keysAffectedByDownloadStatus = nil;
+static NSSet *filePathSet = nil;
+static NSSet *downloadStatusSet = nil;
+static NSSet *infoKeys = nil;
-+ (NSSet *)keyPathsForValuesAffectingFileName {
- return [NSSet setWithObjects:SKFilePathKey, nil];
++ (void)initialize {
+ SKINITIALIZE;
+ keysAffectedByFilePath = [[NSSet alloc]
initWithObjects:SKDownloadFileNameKey, SKFileIconKey, nil];
+ keysAffectedByDownloadStatus = [[NSSet alloc]
initWithObjects:SKCanCancelKey, SKCanRemoveKey, SKCanResumeKey, nil];
+ filePathSet = [[NSSet alloc] initWithObjects:SKFilePathKey, nil];
+ downloadStatusSet = [[NSSet alloc] initWithObjects:SKDownloadStatusKey,
nil];
+ infoKeys = [[NSSet alloc] initWithObjects:SKDownloadFileNameKey,
SKDownloadStatusKey, SKDownloadProgressIndicatorKey, nil];
}
-+ (NSSet *)keyPathsForValuesAffectingFileIcon {
- return [NSSet setWithObjects:SKFilePathKey, nil];
++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
+ NSSet *set = [super keyPathsForValuesAffectingValueForKey:key];
+ if ([keysAffectedByDownloadStatus containsObject:key])
+ return [set count] > 0 ? [set setByAddingObjectsFromSet:filePathSet] :
filePathSet;
+ if ([keysAffectedByDownloadStatus containsObject:key])
+ return [set count] > 0 ? [set
setByAddingObjectsFromSet:downloadStatusSet] : downloadStatusSet;
+ if ([SKInfoKey isEqualToString:key])
+ return [set count] > 0 ? [set setByAddingObjectsFromSet:infoKeys] :
infoKeys;
+ return set;
}
-+ (NSSet *)keyPathsForValuesAffectingCanCancel {
- return [NSSet setWithObjects:SKDownloadStatusKey, nil];
-}
-
-+ (NSSet *)keyPathsForValuesAffectingCanRemove {
- return [NSSet setWithObjects:SKDownloadStatusKey, nil];
-}
-
-+ (NSSet *)keyPathsForValuesAffectingCanResume {
- return [NSSet setWithObjects:SKDownloadStatusKey, nil];
-}
-
-+ (NSSet *)keyPathsForValuesAffectingInfo {
- return [self infoKeys];
-}
-
- (id)initWithURL:(NSURL *)aURL delegate:(id <SKDownloadDelegate>)aDelegate {
if (self = [super init]) {
URL = [aURL retain];
@@ -202,7 +205,7 @@
- (NSDictionary *)info {
NSMutableDictionary *info = [NSMutableDictionary dictionary];
- for (NSString *key in [[self class] infoKeys])
+ for (NSString *key in infoKeys)
[info setValue:[self valueForKey:key] forKey:key];
return info;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit