Changeset 120

Show
Ignore:
Timestamp:
02/11/08 10:17:18 (1 year ago)
Author:
mike
Message:

[fix] QControlController adapted for smartfolder
[fix] QControlTableView adapted for smartfolder
[fix] QControlTableViewController adapted for smartfolder
[fix] QDocument adapted for smartfolder

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/English.lproj/MainMenu.nib/info.nib

    r119 r120  
    1111        <key>IBOpenObjects</key> 
    1212        <array> 
    13                 <integer>216</integer> 
     13                <integer>218</integer> 
    1414        </array> 
    1515        <key>IBSystem Version</key> 
  • trunk/QControl/QControlController.m

    r119 r120  
    120120 
    121121#pragma mark configurations 
     122NSInteger revCaseInsensitiveCompare(id string1, id string2, void *context) 
     123 
     124{ 
     125    return [[string2 lastPathComponent] caseInsensitiveCompare:[string1 lastPathComponent] ]; 
     126} 
     127 
    122128 
    123129 
     
    126132        Q_DEBUG(@"loadConfigurations"); 
    127133         
     134        NSMutableDictionary *tempVM; 
     135        NSMutableArray *knownVMs; 
     136 
    128137    if (VMs) 
    129138        [VMs release]; 
    130  
    131     VMs = [[NSMutableArray alloc] init]; 
    132         NSMutableDictionary *tempVM; 
    133  
    134         // add knownVMs 
     139        VMs =[[NSMutableArray alloc] init]; 
     140         
     141        // check knownVMs 
    135142        int i; 
    136         NSMutableArray *knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; 
     143        knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; 
     144        [knownVMs sortUsingFunction:revCaseInsensitiveCompare context:nil]; 
    137145        for (i = [knownVMs count] - 1; i > -1; i--) { 
    138                 // does it still exist? 
    139         NSFileManager *fileManager = [NSFileManager defaultManager]; 
    140         if ([fileManager fileExistsAtPath:[knownVMs objectAtIndex:i]]) { 
    141                         tempVM = [[QQvmManager sharedQvmManager] loadVMConfiguration:[knownVMs objectAtIndex:i]]; 
    142                         if (tempVM) { 
    143                                 [VMs addObject:tempVM]; 
    144                         } else { 
    145                                 [knownVMs removeObjectAtIndex:i]; 
    146                         } 
     146                tempVM = [[QQvmManager sharedQvmManager] loadVMConfiguration:[knownVMs objectAtIndex:i]]; 
     147                if (tempVM) { 
     148                        [VMs addObject:tempVM]; 
    147149                } else { 
    148150                        [knownVMs removeObjectAtIndex:i]; 
  • trunk/QControl/QControlTableView.m

    r119 r120  
    3131#define ICON_WIDTH 9.0 
    3232#define ICON_HEIGHT 9.0 
    33 #define ICON_X 45.0 
     33#define ICON_X 3.0 
    3434#define ICON_Y 31.0 
     35#define ICON_SPACE 2.0 
    3536 
    3637@implementation QControlTableView 
     
    6566    NSRect cellRect = [self frameOfCellAtColumn:1 row:row]; 
    6667     
    67     for (i = 1; i < 5; i++) { 
     68    for (i = 0; i < 4; i++) { 
    6869        if (NSPointInRect(pointClicked, NSMakeRect( 
    69             cellRect.origin.x + cellRect.size.width - i * (ICON_WIDTH + 4), 
    70             cellRect.origin.y + cellRect.size.height - ICON_HEIGHT - 4
     70            cellRect.origin.x + ICON_X + i * (ICON_WIDTH), 
     71            cellRect.origin.y + ICON_Y
    7172            ICON_WIDTH, 
    7273            ICON_HEIGHT 
     
    7475            VM = [[qControl VMs] objectAtIndex:row]; 
    7576            switch (i) { 
    76                 case 1: // delete 
    77                     if ([[[VM objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"shutdown"]) 
    78                         clicked = TRUE; 
     77                case 0: // edit 
     78                    clicked = TRUE; 
     79                break; 
     80                case 1: // play/pause 
     81                    clicked = TRUE; 
    7982                break; 
    8083                case 2: // stop 
     
    8285                        clicked = TRUE; 
    8386                break; 
    84                 case 3: // play/pause 
    85                     clicked = TRUE; 
    86                 break; 
    87                 case 4: // edit 
    88                     clicked = TRUE; 
     87                case 3: // delete 
     88                    if ([[[VM objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"shutdown"]) 
     89                        clicked = TRUE; 
    8990                break; 
    9091            } 
     
    118119        document = [[NSDocumentController sharedDocumentController] documentForURL:[[VM objectForKey:@"Temporary"] objectForKey:@"URL"]]; 
    119120         
    120     for (i = 1; i < 5; i++) { 
     121    for (i = 0; i < 4; i++) { 
    121122        if (NSPointInRect(pointClicked, NSMakeRect( 
    122             cellRect.origin.x + cellRect.size.width - i * (ICON_WIDTH + 4), 
    123             cellRect.origin.y + cellRect.size.height - ICON_HEIGHT - 4
     123            cellRect.origin.x + ICON_X + i * (ICON_WIDTH + ICON_SPACE), 
     124            cellRect.origin.y + ICON_Y
    124125            ICON_WIDTH, 
    125126            ICON_HEIGHT 
    126127        ))) { 
    127128            switch (i) { 
    128                 case 1: // delete 
    129                     if (!document) // only allow if VM is not open 
    130                         [qControl deleteVM:VM]; 
    131                                         break; 
    132                 case 2: // stop 
    133                     if (document) { 
    134                                                 if (([document VMState]==QDocumentRunning)||([document VMState]==QDocumentPaused)) { 
    135                                                         [document VMShutDown:self]; 
    136                                                 } 
    137                                         } 
    138                                         break; 
    139                 case 3: // play/pause 
     129                case 0: // edit 
     130                    [qControl editVM:VM]; 
     131                break; 
     132                case 1: // play/pause 
    140133                                        if (document) { 
    141134                                                switch ([document VMState]) { 
     
    155148                                        } 
    156149                                        break; 
    157                 case 4: // edit 
    158                     [qControl editVM:VM]; 
    159                 break; 
     150                case 2: // stop 
     151                    if (document) { 
     152                                                if (([document VMState]==QDocumentRunning)||([document VMState]==QDocumentPaused)) { 
     153                                                        [document VMShutDown:self]; 
     154                                                } 
     155                                        } 
     156                                        break; 
     157                case 3: // delete 
     158                    if (!document) // only allow if VM is not open 
     159                        [qControl deleteVM:VM]; 
     160                                        break; 
    160161            } 
    161162        } 
     
    191192         
    192193        // edit icon 
    193         point = NSMakePoint(cellRect.origin.x + ICON_X + (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); 
     194        point = NSMakePoint(cellRect.origin.x + ICON_X, cellRect.origin.y + ICON_Y); 
    194195        if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { 
    195196            qFraction = 1.0; 
     
    215216 
    216217        // play/pause icon 
    217         point = NSMakePoint(cellRect.origin.x + ICON_X + 2 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); 
     218        point = NSMakePoint(cellRect.origin.x + ICON_X + (ICON_WIDTH + ICON_SPACE), cellRect.origin.y + ICON_Y); 
    218219        if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { 
    219220            qFraction = 1.0; 
     
    252253 
    253254        // stop icon 
    254         point = NSMakePoint(cellRect.origin.x + ICON_X + 3 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); 
     255        point = NSMakePoint(cellRect.origin.x + ICON_X + 2 * (ICON_WIDTH + ICON_SPACE), cellRect.origin.y + ICON_Y); 
    255256        if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) { 
    256257            qFraction = 1.0; 
     
    276277         
    277278        // delete icon 
    278         point = NSMakePoint(cellRect.origin.x + ICON_X + 4 * (ICON_WIDTH + 4), cellRect.origin.y + ICON_Y); 
     279        point = NSMakePoint(cellRect.origin.x + ICON_X + 3 * (ICON_WIDTH + ICON_SPACE), cellRect.origin.y + ICON_Y); 
    279280        if (NSPointInRect(pointClicked, NSMakeRect(point.x, point.y, ICON_WIDTH, ICON_HEIGHT))) 
    280281            qFraction = 1.0; 
  • trunk/QControl/QControlTableViewController.m

    r119 r120  
    137137                paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease]; 
    138138                 
    139                 color = [NSColor colorWithDeviceRed:0.5 green:0.5 blue:0.5 alpha:1.0]; 
     139                color = [NSColor colorWithDeviceRed:0.75 green:0.75 blue:0.75 alpha:1.0]; 
    140140                [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingHead]; 
    141141 
    142142        attrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", name] attributes:[NSDictionary dictionaryWithObject: [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]; 
    143                [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", [path stringByDeletingLastPathComponent]]  attributes:[NSDictionary dictionaryWithObjectsAndKeys: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, color, NSForegroundColorAttributeName, nil]] autorelease]]; 
    144         [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:state attributes:[NSDictionary dictionaryWithObject:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]]; 
     143        [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%@\n", state] attributes:[NSDictionary dictionaryWithObject:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]] autorelease]]; 
     144               [attrString appendAttributedString: [[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"\n%@", [path stringByDeletingLastPathComponent]]  attributes:[NSDictionary dictionaryWithObjectsAndKeys: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, color, NSForegroundColorAttributeName, nil]] autorelease]]; 
    145145 
    146146        return attrString; 
  • trunk/QDocument/QDocument.m

    r118 r120  
    270270         
    271271                        // if outside default path, add to knownVNs 
    272                         if (![[[panel filename] stringByDeletingLastPathComponent] isEqual:[[qApplication userDefaults] objectForKey:@"dataPath"]]) { 
    273                                 if (![[[qApplication userDefaults] objectForKey:@"knownVMs"] containsObject:[panel filename]]) { 
    274                                         knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; 
    275                                         [knownVMs addObject:[panel filename]]; 
    276                                         [[qApplication userDefaults] setObject:knownVMs forKey:@"knownVMs"]; 
    277                                 } 
     272                        if (![[[qApplication userDefaults] objectForKey:@"knownVMs"] containsObject:[panel filename]]) { 
     273                                knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; 
     274                                [knownVMs addObject:[panel filename]]; 
     275                                [[qApplication userDefaults] setObject:knownVMs forKey:@"knownVMs"]; 
    278276                        } 
    279277                         
     
    293291                [savePanel setAllowedFileTypes:[NSArray arrayWithObject:@"qvm"]]; 
    294292                [savePanel setCanSelectHiddenExtension:YES]; 
    295                 [savePanel beginSheetForDirectory:[[qApplication userDefaults] objectForKey:@"dataPath"] file:[self displayName] modalForWindow:[screenView window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:nil]; 
     293                [savePanel beginSheetForDirectory:nil file:[self displayName] modalForWindow:[screenView window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:nil]; 
    296294        } else { 
    297295                [self defaultAlertMessage:@"VM is running" informativeText:@"Please shutdown the VM before saving the VM to a new Name"]; 
  • trunk/changelog.txt

    r119 r120  
     1120 
     2[fix] QControlController adapted for smartfolder 
     3[fix] QControlTableView adapted for smartfolder 
     4[fix] QControlTableViewController adapted for smartfolder 
     5[fix] QDocument adapted for smartfolder 
     6 
    17119 
    2 [new] smartfolder for Q Control (get rid of default folder) 
     8[new] smartfolder for Q Control (ie. show all qvm files using spotlight - get rid of default folder) 
    39 
    410118