Changeset 81

Show
Ignore:
Timestamp:
06/29/07 15:39:16 (2 years ago)
Author:
pmerrill
Message:

-- Added verbose progress indicator to the import tool

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SapphireMediaPreview.h

    r37 r81  
    1717 
    1818- (void)setText:(NSAttributedString *)text; 
     19- (void)setFileProgress:(NSAttributedString *)fileProgress ; 
    1920- (void)setImage:(CGImageRef)image; 
    2021 
  • trunk/SapphireMediaPreview.m

    r37 r81  
    3737{ 
    3838        [textLayer setAttributedString:text]; 
     39        [self setFrame:[self frame]]; 
     40} 
     41 
     42 
     43- (void)setFileProgress:(NSAttributedString *)fileProgress 
     44{ 
     45        [textLayer setAttributedString:fileProgress]; 
    3946        [self setFrame:[self frame]]; 
    4047} 
  • trunk/SapphireMetaData.h

    r78 r81  
    8686} 
    8787 
    88 - (void) updateMetaData; 
     88- (BOOL) updateMetaData; 
    8989 
    9090- (int)modified; 
  • trunk/SapphireMetaData.m

    r78 r81  
    614614@implementation SapphireFileMetaData : SapphireMetaData 
    615615 
    616 - (void) updateMetaData 
     616- (BOOL) updateMetaData 
    617617{ 
    618618        NSDictionary *props = [[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES]; 
    619619        int modTime = [[props objectForKey:NSFileModificationDate] timeIntervalSince1970]; 
     620        BOOL updated =FALSE; 
    620621         
    621622        if(props == nil) 
    622623                //No file 
    623                 return
     624                return FALSE
    624625         
    625626        if(modTime != [self modified] || [[metaData objectForKey:META_VERSION_KEY] intValue] != META_VERSION) 
    626627        { 
     628                updated=TRUE ; 
    627629                NSMutableDictionary *fileMeta = [NSMutableDictionary dictionary]; 
    628630                 
     
    685687                [metaData addEntriesFromDictionary:fileMeta]; 
    686688        } 
     689        return updated ; 
    687690} 
    688691 
  • trunk/SapphirePopulateDataMenu.h

    r36 r81  
    1818{ 
    1919        BRHeaderControl                         *title; 
    20         BRButtonControl                         *button; 
    21         BRTextControl                           *text; 
     20        BRButtonControl                                 *button; 
     21        BRTextControl                                   *text; 
     22        BRTextControl                                   *fileProgress; 
    2223        BRProgressBarWidget                     *bar; 
    2324 
    24         SapphireDirectoryMetaData       *meta; 
    25         NSMutableArray                          *importItems; 
     25        SapphireDirectoryMetaData              *meta; 
     26        NSMutableArray                                 *importItems; 
    2627        NSTimer                                         *importTimer; 
    27         float                                           max; 
    28         float                                           current; 
     28        float                                                   max; 
     29        float                                                   current; 
     30        float                                                   updated ; 
    2931} 
    3032- (id) initWithScene: (BRRenderScene *) scene metaData:(SapphireDirectoryMetaData *)metaData; 
  • trunk/SapphirePopulateDataMenu.m

    r46 r81  
    1313@interface SapphirePopulateDataMenu (private) 
    1414- (void)setText:(NSString *)theText; 
     15- (void)setFileProgress:(NSString *)updateFileProgress; 
    1516- (void)resetUIElements; 
    1617@end 
     
    3031        [title setFrame: frame]; 
    3132         
    32          
    3333        // Setup the Header Control with default contents 
    34 //      _warning = [[BRTextWithSpinnerController alloc] initWithScene: scene title:@"Test" text:@"Body" showBack:TRUE]; 
    35 //      [_warning setTitle: @"Depending on the size of your TV show collection, this could take several minutes."]; 
    36 //      [_warning setTitle:@"This can take several minutes"]; 
    37 //      [_warning showProgress:TRUE ] ; 
    38 //      NSRect frame = [[self masterLayer] frame]; 
    3934        frame.origin.y = frame.size.height * 0.80f; 
    4035        frame.size.height = [[BRThemeInfo sharedTheme] listIconHeight]; 
    41 //      [_warning setFrame: frame]; 
    42          
    43          
    4436 
    4537        // setup the button control 
     
    5042        // setup the text entry control 
    5143        text = [[BRTextControl alloc] initWithScene: scene]; 
     44        fileProgress = [[BRTextControl alloc] initWithScene: scene]; 
    5245         
    5346        bar = [[BRProgressBarWidget alloc] initWithScene: scene]; 
     
    6558        [self addControl: title]; 
    6659        [self addControl: text]; 
     60        [self addControl: fileProgress] ; 
    6761        [[self masterLayer] addSublayer:bar]; 
    6862        [self addControl: button]; 
     
    8781} 
    8882 
     83- (void)setFileProgress:(NSString *)theFileProgress 
     84{ 
     85        [fileProgress setTextAttributes:[[BRThemeInfo sharedTheme] paragraphTextAttributes]]; 
     86        [fileProgress setText:theFileProgress]; 
     87         
     88        NSRect master = [[self masterLayer] frame]; 
     89        [fileProgress setMaximumSize:NSMakeSize(master.size.width * 1.0f/2.0f, master.size.height * 0.3f)]; 
     90        NSSize progressSize = [fileProgress renderedSize]; 
     91         
     92        NSRect frame; 
     93//      frame.origin.x =  (master.size.width - progressSize.width) * 0.2f; 
     94        frame.origin.x =  (master.size.width) * 0.2f; 
     95        frame.origin.y = (master.size.height * 0.00f - progressSize.height) + master.size.height * 0.25f/0.8f; 
     96        frame.size = progressSize; 
     97        [fileProgress setFrame:frame]; 
     98} 
     99 
    89100- (void) dealloc 
    90101{ 
    91     [title release]; 
    92     [text release]; 
     102        [title release]; 
     103        [text release]; 
     104        [fileProgress release] ; 
    93105        [bar release]; 
    94     [button release]; 
     106       [button release]; 
    95107        [meta release]; 
    96108        [importTimer invalidate]; 
    97  
    98     [super dealloc]; 
     109        [super dealloc]; 
    99110} 
    100111 
     
    103114        [button setTitle:@"Cancel Import"]; 
    104115        [button setAction:@selector(cancel)]; 
     116        [self setFileProgress:@"Initializing..."]; 
    105117        [[self scene] renderScene]; 
    106118        importItems = [[meta subFileMetas] mutableCopy]; 
     119        updated = 0 ; 
    107120        current = 0; 
     121//      [self setFileProgress:@"File Progress:  <Checking> "]; 
     122//      [[self scene] renderScene]; 
    108123        max = [importItems count]; 
    109124        importTimer = [NSTimer scheduledTimerWithTimeInterval:0.0f target:self selector:@selector(importNextItem:) userInfo:nil repeats:YES]; 
     
    113128{ 
    114129        SapphireFileMetaData *fileMeta = [importItems objectAtIndex:0]; 
    115         [fileMeta updateMetaData]
     130        if([fileMeta updateMetaData])updated++
    116131        [importItems removeObjectAtIndex:0]; 
    117         current++; 
     132        current++ ; 
     133        [self setFileProgress:[NSString stringWithFormat:@"File Progress: %0.0f / %0.0f", current, max,updated]]; 
    118134        [bar setPercentage:current/max * 100.0f]; 
    119135         
     
    126142                [button setTarget:nil]; 
    127143                [title setTitle: @"Import Complete"]; 
     144                [self setFileProgress:[NSString stringWithFormat:@"Updated %0.0f Entries.", updated]]; 
    128145                [self setText:@"Sapphire will continue to import new files as it encounters them.  You may initiate this import again at any time, and any new or changed files will be imported"]; 
    129146                [[self scene] renderScene]; 
     
    143160        [title setTitle: @"Populate Show Data"]; 
    144161        [self setText:@"This will populate Sapphire's Meta data.  This proceedure may take a while, but you may cancel at any time"]; 
     162//      [self setFileProgress:@"File Progress:  ? / ? "]; 
    145163        [bar setPercentage:0.0f]; 
    146164        [button setTitle: @"Import Meta Data"];