~per.j/modazipin/1.0

« back to all changes in this revision

Viewing changes to AddInsList.m

  • Committer: Per Johansson
  • Date: 2010-06-19 17:42:23 UTC
  • Revision ID: per@morth.org-20100619174223-83rnojgd3f54m3u2
Do not reload the details view unless it's necessary

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
        [self addObserver:self forKeyPath:@"randomScreenshotURL" options:0 context:nil];
169
169
}
170
170
 
171
 
- (void)itemsControllerChanged
 
171
- (void)reloadDetails
172
172
{
173
173
        NSArray *objects = [itemsController selectedObjects];
174
174
        
175
175
        if ([objects count] == 1)
176
176
        {
177
 
                NSMutableString *html = [[objects objectAtIndex:0] detailsHTML];
 
177
                detailedItem = [objects objectAtIndex:0];
 
178
                
 
179
                NSMutableString *html = [detailedItem detailsHTML];
178
180
                
179
181
                [html replaceOccurrencesOfString:@"<!--dazip-->" withString:@"<!--" options:0 range:NSMakeRange(0, [html length])];
180
182
                [html replaceOccurrencesOfString:@"<!--/dazip-->" withString:@"-->" options:0 range:NSMakeRange(0, [html length])];
182
184
        }
183
185
        else
184
186
        {
 
187
                detailedItem = nil;
 
188
                
185
189
                [[detailsView mainFrame] loadHTMLString:@"" baseURL:[[NSBundle mainBundle] resourceURL]];
186
190
        }
187
 
 
 
191
}
 
192
 
 
193
- (void)itemsControllerChanged
 
194
{
 
195
        NSArray *objects = [itemsController selectedObjects];
 
196
        
 
197
        if ([objects count] == 1)
 
198
        {
 
199
                Item *item = [objects objectAtIndex:0];
 
200
                
 
201
                if (item != detailedItem)
 
202
                        [self reloadDetails];
 
203
        }
 
204
}
 
205
 
 
206
- (void)reloadItem:(Item*)item
 
207
{
 
208
        [item updateInfo];
 
209
        
 
210
        if (item == detailedItem)
 
211
                [self reloadDetails];
188
212
}
189
213
 
190
214
- (void)selectItemWithUid:(NSString *)uid
367
391
                        if ([missing count])
368
392
                        {
369
393
                                item.missingFiles = [missing componentsJoinedByString:@", "];
370
 
                                [item updateInfo];
371
 
                                if ([[itemsController selectedObjects] indexOfObject:item] != NSNotFound)
372
 
                                        [self performSelectorOnMainThread:@selector(itemsControllerChanged) withObject:nil waitUntilDone:NO];
 
394
                                [self performSelectorOnMainThread:@selector(reloadItem:) withObject:item waitUntilDone:NO];
373
395
                        }
374
396
                }
375
397
        }