Changeset 123

Show
Ignore:
Timestamp:
02/29/08 19:59:08 (10 months ago)
Author:
mike
Message:

[new] QDocumentEditVMController populating panel

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/QDocument/QDocumentEditVMController.m

    r121 r123  
    7676{ 
    7777        Q_DEBUG(@"resetPanel"); 
     78 
     79        NSString *diskImageFile; 
     80        NSDirectoryEnumerator *directoryEnumerator; 
     81        NSArray *fileTypes; 
     82         
     83        fileTypes = [[[NSArray alloc] initWithArrayOfAllowedFileTypes] autorelease]; 
    7884         
    7985        // Tab 1 
     86        // -tablet 
    8087        [grabless setState:NSOffState]; 
     88 
     89        // qdrivers 
    8190        [qDrivers setState:NSOffState]; 
     91 
     92        // pause while inactive 
    8293        [pauseWhileInactive setState:NSOffState]; 
     94 
     95        // -smb 
     96        while(![[smb itemAtIndex:2] isSeparatorItem]) 
     97                [smb removeItemAtIndex:2]; 
    8398        [smb selectItemAtIndex:0]; 
    8499         
     
    95110        [nicModel1 selectItemAtIndex:0]; 
    96111        [nicModel2 selectItemAtIndex:0]; 
     112 
     113        // -fda 
     114        while(![[fda itemAtIndex:1] isSeparatorItem]) 
     115                [fda removeItemAtIndex:1]; 
    97116        [fda selectItemAtIndex:0]; 
     117 
     118        // -cdrom 
     119        while(![[cdrom itemAtIndex:2] isSeparatorItem]) 
     120                [cdrom removeItemAtIndex:2]; 
    98121        [cdrom selectItemAtIndex:0]; 
     122 
     123 
     124        // cleanup -hdb and add Harddisks located in Package to Menu 
     125        while(![[hda itemAtIndex:1] isSeparatorItem]) 
     126                [hda removeItemAtIndex:1]; 
     127        if ([hda numberOfItems] > 8) { 
     128                while(![[hda itemAtIndex:2] isSeparatorItem]) 
     129                        [hda removeItemAtIndex:2]; 
     130        } else { 
     131                [[hda menu] insertItem:[NSMenuItem separatorItem] atIndex:2]; 
     132        } 
     133        directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:[[[VM objectForKey:@"Temporary"] objectForKey:@"URL"] path]]; 
     134        while ((diskImageFile = [directoryEnumerator nextObject])) { 
     135                if ([fileTypes containsObject:[diskImageFile pathExtension]]) 
     136                        [hda insertItemWithTitle:[diskImageFile lastPathComponent] atIndex:2]; 
     137        } 
     138        if([[hda itemAtIndex:2] isSeparatorItem]) 
     139                [hda removeItemAtIndex:2]; 
    99140        [hda selectItemAtIndex:0]; 
     141 
     142        // -boot 
    100143        [boot selectItemAtIndex:2]; // c 
     144 
     145 
    101146         
    102147        // Tab 3 
     148 
     149 
    103150         
    104151        // Tab 4 
     152        // cleanup -hdb and add Harddisks located in Package to Menu 
     153        while(![[hdb itemAtIndex:1] isSeparatorItem]) 
     154                [hdb removeItemAtIndex:1]; 
     155        if ([hdb numberOfItems] > 8) { 
     156                while(![[hdb itemAtIndex:2] isSeparatorItem]) 
     157                        [hdb removeItemAtIndex:2]; 
     158        } else { 
     159                [[hdb menu] insertItem:[NSMenuItem separatorItem] atIndex:2]; 
     160        } 
     161        directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:[[[VM objectForKey:@"Temporary"] objectForKey:@"URL"] path]]; 
     162        while ((diskImageFile = [directoryEnumerator nextObject])) { 
     163                if ([fileTypes containsObject:[diskImageFile pathExtension]]) 
     164                        [hdb insertItemWithTitle:[diskImageFile lastPathComponent] atIndex:2]; 
     165        } 
     166        if([[hdb itemAtIndex:2] isSeparatorItem]) 
     167                [hdb removeItemAtIndex:2]; 
    105168        [hdb selectItemAtIndex:0]; 
     169 
     170        // cleanup -hdc and add Harddisks located in Package to Menu 
     171        while(![[hdc itemAtIndex:1] isSeparatorItem]) 
     172                [hdc removeItemAtIndex:1]; 
     173        if ([hdc numberOfItems] > 8) { 
     174                while(![[hdc itemAtIndex:2] isSeparatorItem]) 
     175                        [hdc removeItemAtIndex:2]; 
     176        } else { 
     177                [[hdc menu] insertItem:[NSMenuItem separatorItem] atIndex:2]; 
     178        } 
     179        directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:[[[VM objectForKey:@"Temporary"] objectForKey:@"URL"] path]]; 
     180        while ((diskImageFile = [directoryEnumerator nextObject])) { 
     181                if ([fileTypes containsObject:[diskImageFile pathExtension]]) 
     182                        [hdc insertItemWithTitle:[diskImageFile lastPathComponent] atIndex:2]; 
     183        } 
     184        if([[hdc itemAtIndex:2] isSeparatorItem]) 
     185                [hdc removeItemAtIndex:2]; 
    106186        [hdc selectItemAtIndex:0]; 
     187 
     188        // cleanup -hdd and add Harddisks located in Package to Menu 
     189        while(![[hdd itemAtIndex:1] isSeparatorItem]) 
     190                [hdd removeItemAtIndex:1]; 
     191        if ([hdd numberOfItems] > 8) { 
     192                while(![[hdd itemAtIndex:2] isSeparatorItem]) 
     193                        [hdd removeItemAtIndex:2]; 
     194        } else { 
     195                [[hdd menu] insertItem:[NSMenuItem separatorItem] atIndex:2]; 
     196        } 
     197        directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:[[[VM objectForKey:@"Temporary"] objectForKey:@"URL"] path]]; 
     198        while ((diskImageFile = [directoryEnumerator nextObject])) { 
     199                if ([fileTypes containsObject:[diskImageFile pathExtension]]) 
     200                        [hdd insertItemWithTitle:[diskImageFile lastPathComponent] atIndex:2]; 
     201        } 
     202        if([[hdd itemAtIndex:2] isSeparatorItem]) 
     203                [hdd removeItemAtIndex:2]; 
    107204        [hdd selectItemAtIndex:0]; 
     205 
     206        // -localtime 
    108207        [localtime setState:NSOffState]; 
     208 
     209        // -win2khack 
    109210        [win2kHack setState:NSOffState]; 
     211 
     212        // kernel 
     213        while(![[kernel itemAtIndex:1] isSeparatorItem]) 
     214                [kernel removeItemAtIndex:1]; 
    110215        [kernel selectItemAtIndex:0]; 
     216 
    111217        [append setStringValue:@""]; 
     218 
     219        // initrd 
     220        while(![[initrd itemAtIndex:1] isSeparatorItem]) 
     221                [initrd removeItemAtIndex:1]; 
    112222        [initrd selectItemAtIndex:0]; 
     223 
    113224        [onlyOptional setState:NSOffState]; 
    114225        [optional setStringValue:@""]; 
     
    123234{ 
    124235        Q_DEBUG(@"setOption:%@ withArgument:%@", key, argument); 
    125          
     236 
    126237        // grabless (-usbdevice tablet) 
    127238        if ([key isEqual:@"-usbdevice"] && [argument isEqual:@"tablet"]) { 
     
    144255        } 
    145256                return TRUE; 
    146          
     257 
    147258        // TODO: add other machines 
    148259        // select machine 
     
    177288                [smp setStringValue:argument]; 
    178289                return TRUE; 
    179                  
     290 
    180291        // m 
    181292        } else if ([key isEqual:@"-m"]) { 
     
    190301                [vga selectItemAtIndex:2]; 
    191302                return true; 
    192                  
     303 
    193304        // soundcards 
    194305        } else if ([key isEqual:@"-soundhw"]) { 
     
    202313                        [es1370 setState:NSOnState]; 
    203314                return true; 
    204          
     315 
    205316        // networkcards 
    206         } else if ([key isEqual:@"-nic"]) { 
     317        } else if ([key isEqual:@"-net"]) { 
    207318                // we can only handle the first to nics with the gui 
    208319                niccount++; 
     
    211322                        nicModel = nicModel1; 
    212323                } else if (niccount == 2) { 
    213                         nicModel = nicModel1
     324                        nicModel = nicModel2
    214325                } else { 
    215326                        return false; 
    216327                } 
    217         if ([argument isEqual:@"i82551"]) { 
     328        if ([argument rangeOfString:@"i82551"].location != NSNotFound) { 
    218329            [nicModel selectItemAtIndex:1]; 
    219         } else if ([argument isEqual:@"i82557b"]) { 
     330        } else if ([argument rangeOfString:@"i82557b"].location != NSNotFound) { 
    220331            [nicModel selectItemAtIndex:2]; 
    221         } else if ([argument isEqual:@"i82559er"]) { 
     332        } else if ([argument rangeOfString:@"i82559er"].location != NSNotFound) { 
    222333            [nicModel selectItemAtIndex:3]; 
    223         } else if ([argument isEqual:@"ne2k_pci"]) { 
     334        } else if ([argument rangeOfString:@"ne2k_pci"].location != NSNotFound) { 
    224335            [nicModel selectItemAtIndex:4]; 
    225         } else if ([argument isEqual:@"ne2k_isa"]) { 
     336        } else if ([argument rangeOfString:@"ne2k_isa"].location != NSNotFound) { 
    226337            [nicModel selectItemAtIndex:5]; 
    227         } else if ([argument isEqual:@"rtl8139"]) { 
     338        } else if ([argument rangeOfString:@"rtl8139"].location != NSNotFound) { 
    228339            [nicModel selectItemAtIndex:6]; 
    229         } else if ([argument isEqual:@"smc91c111"]) { 
     340        } else if ([argument rangeOfString:@"smc91c111"].location != NSNotFound) { 
    230341            [nicModel selectItemAtIndex:7]; 
    231         } else if ([argument isEqual:@"lance"]) { 
     342        } else if ([argument rangeOfString:@"lance"].location != NSNotFound) { 
    232343            [nicModel selectItemAtIndex:8]; 
    233         } else if ([argument isEqual:@"mcf_fec"]) { 
     344        } else if ([argument rangeOfString:@"mcf_fec"].location != NSNotFound) { 
    234345            [nicModel selectItemAtIndex:9]; 
    235         } 
     346        } else if ([argument rangeOfString:@"nic"].location != NSNotFound) { // default is rtl8139 
     347            [nicModel selectItemAtIndex:6]; 
     348                } else if ([argument isEqual:@"user"]) { // user networking 
     349            //Todo: what should we do 
     350                } 
    236351                return TRUE; 
    237352 
    238353        // fda 
    239         // TODO: 
    240          
     354        } else if ([key isEqual:@"-fda"]) { 
     355                [fda insertItemWithTitle:[NSString stringWithString:argument] atIndex:1]; 
     356                [fda selectItemAtIndex:1]; 
     357                return TRUE; 
     358 
    241359        // cdrom 
    242         // TODO: 
     360        } else if ([key isEqual:@"-cdrom"]) { 
     361                if ([argument isEqual:@"/dev/cdrom"]) { 
     362                        [cdrom selectItemAtIndex:1]; 
     363                } else { 
     364                        [cdrom insertItemWithTitle:[NSString stringWithString:argument] atIndex:2]; 
     365                        [cdrom selectItemAtIndex:2]; 
     366                } 
     367                return TRUE; 
    243368         
    244369        // hda 
    245         // TODO: 
     370        } else if ([key isEqual:@"-hda"]) { 
     371                if ([hda indexOfItemWithTitle:argument] > -1) { 
     372                        [hda selectItemWithTitle:argument]; 
     373                } else { 
     374/* TODO: new Image 
     375                        int intResult; 
     376                        NSString *stringValue; 
     377                        NSScanner *scanner = [NSScanner scannerWithString: argument]; 
     378                         
     379                        if ([scanner scanString:@"createNew" intoString:&stringValue]) { 
     380                                [scanner scanInt:&intResult]; 
     381                                customImagePopUpButtonTemp = hda; 
     382                                [self setCustomDIType:@"qcow" size:intResult]; 
     383                        } else {*/ 
     384                                [hda insertItemWithTitle:[NSString stringWithString:argument] atIndex:1]; 
     385                                [hda selectItemAtIndex:1]; 
     386//                      } 
     387                } 
     388                return TRUE; 
    246389         
    247390        // hdb 
    248         // TODO: 
    249          
     391        } else if ([key isEqual:@"-hdb"]) { 
     392                 if ([hdb indexOfItemWithTitle:argument] > -1) { 
     393                         [hdb selectItemWithTitle:argument]; 
     394                 } else { 
     395                         [hdb insertItemWithTitle:[NSString stringWithString:argument] atIndex:1]; 
     396                         [hdb selectItemAtIndex:1]; 
     397                 } 
     398                 return TRUE; 
     399 
    250400        // hdc 
    251         // TODO: 
    252          
     401        } else if ([key isEqual:@"-hdc"]) { 
     402                 if ([hdc indexOfItemWithTitle:argument] > -1) { 
     403                         [hdc selectItemWithTitle:argument]; 
     404                 } else { 
     405                         [hdc insertItemWithTitle:[NSString stringWithString:argument] atIndex:1]; 
     406                         [hdc selectItemAtIndex:1]; 
     407                 } 
     408                 return TRUE; 
     409 
    253410        // hdd 
    254         // TODO: 
    255          
     411        } else if ([key isEqual:@"-hdd"]) { 
     412                 if ([hdd indexOfItemWithTitle:argument] > -1) { 
     413                         [hdd selectItemWithTitle:argument]; 
     414                 } else { 
     415                         [hdd insertItemWithTitle:[NSString stringWithString:argument] atIndex:1]; 
     416                         [hdd selectItemAtIndex:1]; 
     417                 } 
     418                 return TRUE; 
     419 
    256420        // boot 
    257421        } else if ([key isEqual:@"-boot"]) { 
     
    266430        } 
    267431                return TRUE; 
    268          
     432 
    269433        // localtime 
    270434        } else if ([key isEqual:@"-localtime"]) { 
    271435                [localtime setState:NSOnState]; 
    272436                return true; 
    273          
     437 
    274438        // win2khack 
    275439        } else if ([key isEqual:@"-win2khack"]) { 
    276440                [win2kHack setState:NSOnState]; 
    277441                return true; 
    278          
     442 
    279443        // kernel 
    280         // TODO: 
    281          
     444        } else if ([key isEqual:@"-kernel"]) { 
     445                [kernel insertItemWithTitle:[NSString stringWithString:argument] atIndex:1]; 
     446                [kernel selectItemAtIndex:1]; 
     447                return TRUE; 
     448 
    282449        // append 
    283450        } else if ([key isEqual:@"-append"]) { 
    284451                [append setStringValue:argument]; 
    285452                return TRUE; 
    286          
     453 
    287454        // initrd 
    288         // TODO: 
     455        } else if ([key isEqual:@"-initrd"]) { 
     456                [initrd insertItemWithTitle:[NSString stringWithString:argument] atIndex:1]; 
     457                [initrd selectItemAtIndex:1]; 
     458                return TRUE; 
    289459 
    290460        } 
  • trunk/changelog.txt

    r122 r123  
     1123 
     2[new] QDocumentEditVMController populating panel 
     3 
    14122 
    25[fix] QControlTableView single click handled as double click