Changeset 206
- Timestamp:
- 09/06/07 21:27:30 (1 year ago)
- Files:
-
- trunk/SapphireTVDirectory.h (modified) (1 diff)
- trunk/SapphireTVDirectory.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SapphireTVDirectory.h
r203 r206 14 14 } 15 15 - (void)processFile:(SapphireFileMetaData *)file; 16 - (void)removeFile:(SapphireFileMetaData *)file; 16 17 @end 17 18 trunk/SapphireTVDirectory.m
r205 r206 61 61 { 62 62 } 63 64 - (void)removeFile:(SapphireFileMetaData *)file 65 { 66 } 63 67 @end 64 68 … … 71 75 72 76 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileAdded:) name:META_DATA_FILE_ADDED_NOTIFICATION object:nil]; 77 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileRemoved:) name:META_DATA_FILE_REMOVED_NOTIFICATION object:nil]; 78 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileInfoHasChanged:) name:META_DATA_FILE_INFO_HAS_CHANGED_NOTIFICATION object:nil]; 79 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileInfoWillChanged:) name:META_DATA_FILE_INFO_WILL_CHANGE_NOTIFICATION object:nil]; 73 80 74 81 return self; … … 79 86 SapphireFileMetaData *file = [notification object]; 80 87 [self processFile:file]; 88 } 89 90 - (void)fileRemoved:(NSNotification *)notification 91 { 92 SapphireFileMetaData *file = [notification object]; 93 [self removeFile:file]; 94 } 95 96 - (void)fileInfoHasChanged:(NSNotification *)notification 97 { 98 NSDictionary *info = [notification userInfo]; 99 if(![[info objectForKey:META_DATA_FILE_INFO_KIND] isEqualToString:META_TVRAGE_IMPORT_KEY]) 100 return; 101 SapphireFileMetaData *file = [notification object]; 102 [self processFile:file]; 103 } 104 105 - (void)fileInfoWillChanged:(NSNotification *)notification 106 { 107 NSDictionary *info = [notification userInfo]; 108 if(![[info objectForKey:META_DATA_FILE_INFO_KIND] isEqualToString:META_TVRAGE_IMPORT_KEY]) 109 return; 110 SapphireFileMetaData *file = [notification object]; 111 [self removeFile:file]; 81 112 } 82 113 … … 105 136 [showInfo processFile:file]; 106 137 } 138 139 - (void)removeFile:(SapphireFileMetaData *)file 140 { 141 NSString *show = [file showName]; 142 if(show == nil) 143 return; 144 SapphireShowDirectory *showInfo = [directory objectForKey:show]; 145 if(showInfo != nil) 146 { 147 [showInfo removeFile:file]; 148 if([[showInfo directories] count] == 0) 149 { 150 [directory removeObjectForKey:show]; 151 [self setReloadTimer]; 152 } 153 } 154 } 107 155 @end 108 156 … … 132 180 } 133 181 [seasonInfo processFile:file]; 182 } 183 184 - (void)removeFile:(SapphireFileMetaData *)file 185 { 186 int seasonNum = [file seasonNumber]; 187 if(seasonNum == 0) 188 return; 189 NSString *season = [NSString stringWithFormat:BRLocalizedString(@"Season %d", @"Season name"), seasonNum]; 190 SapphireSeasonDirectory *seasonInfo = [directory objectForKey:season]; 191 if(seasonInfo == nil) 192 { 193 [seasonInfo removeFile:file]; 194 if([[seasonInfo directories] count] == 0) 195 { 196 [directory removeObjectForKey:season]; 197 [self setReloadTimer]; 198 } 199 } 134 200 } 135 201 @end … … 165 231 [self setReloadTimer]; 166 232 } 167 @end 233 234 - (void)removeFile:(SapphireFileMetaData *)file 235 { 236 int epNum = [file episodeNumber]; 237 if(epNum == 0) 238 return; 239 NSString *ep = [NSString stringWithFormat:BRLocalizedString(@"Episode %d", @"Episode name"), epNum]; 240 [directory removeObjectForKey:ep]; 241 [self setReloadTimer]; 242 } 243 @end
