Changeset 23223 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 22, 2009 3:50:03 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends
- Files:
-
- 6 deleted
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r22911 r23223 179 179 } 180 180 181 STDMETHOD(OnDVDDriveChange)()182 {183 return S_OK;184 }185 186 STDMETHOD(OnFloppyDriveChange)()187 {188 return S_OK;189 }190 191 181 STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter) 192 182 { … … 215 205 216 206 STDMETHOD(OnStorageControllerChange)() 207 { 208 return S_OK; 209 } 210 211 STDMETHOD(OnMediumChange)(IMediumAttachment * /* aMediumAttachment */) 217 212 { 218 213 return S_OK; … … 916 911 917 912 Event *e; 918 913 919 914 while (gEventQ->waitForEvent (&e) && e) 920 915 gEventQ->handleEvent (e); -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r22982 r23223 1352 1352 if (fRegister) 1353 1353 { 1354 ComPtr<I HardDisk> hardDisk;1354 ComPtr<IMedium> hardDisk; 1355 1355 CHECK_ERROR(aVirtualBox, OpenHardDisk(filename, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1356 1356 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r23222 r23223 1142 1142 break; 1143 1143 } 1144 ComPtr<IDVDDrive> dvdDrive; 1145 sessionMachine->COMGETTER(DVDDrive)(dvdDrive.asOutParam()); 1146 ASSERT(dvdDrive); 1144 1145 ComPtr<IMedium> dvdMedium; 1147 1146 1148 1147 /* unmount? */ 1149 1148 if (!strcmp(a->argv[2], "none")) 1150 1149 { 1151 CHECK_ERROR(dvdDrive, Unmount());1150 /* nothing to do, NULL object will cause unmount */ 1152 1151 } 1153 1152 /* host drive? */ … … 1156 1155 ComPtr<IHost> host; 1157 1156 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 1158 com::SafeIfaceArray <IHostDVDDrive> hostDVDs; 1159 rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs)); 1160 1161 ComPtr<IHostDVDDrive> hostDVDDrive; 1162 rc = host->FindHostDVDDrive(Bstr(a->argv[2] + 5), hostDVDDrive.asOutParam()); 1163 if (!hostDVDDrive) 1164 { 1165 errorArgument("Invalid host DVD drive name"); 1157 1158 rc = host->FindHostDVDDrive(Bstr(a->argv[2] + 5), dvdMedium.asOutParam()); 1159 if (!dvdMedium) 1160 { 1161 errorArgument("Invalid host DVD drive name \"%s\"", 1162 a->argv[2] + 5); 1166 1163 rc = E_FAIL; 1167 1164 break; 1168 1165 } 1169 CHECK_ERROR(dvdDrive, CaptureHostDrive(hostDVDDrive));1170 1166 } 1171 1167 else … … 1173 1169 /* first assume it's a UUID */ 1174 1170 Bstr uuid(a->argv[2]); 1175 ComPtr<IDVDImage> dvdImage; 1176 rc = a->virtualBox->GetDVDImage(uuid, dvdImage.asOutParam()); 1177 if (FAILED(rc) || !dvdImage) 1171 rc = a->virtualBox->GetDVDImage(uuid, dvdMedium.asOutParam()); 1172 if (FAILED(rc) || !dvdMedium) 1178 1173 { 1179 1174 /* must be a filename, check if it's in the collection */ 1180 rc = a->virtualBox->FindDVDImage(Bstr(a->argv[2]), dvd Image.asOutParam());1175 rc = a->virtualBox->FindDVDImage(Bstr(a->argv[2]), dvdMedium.asOutParam()); 1181 1176 /* not registered, do that on the fly */ 1182 if (!dvd Image)1177 if (!dvdMedium) 1183 1178 { 1184 1179 Bstr emptyUUID; 1185 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(a->argv[2]), emptyUUID, dvd Image.asOutParam()));1180 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(a->argv[2]), emptyUUID, dvdMedium.asOutParam())); 1186 1181 } 1187 1182 } 1188 if (!dvd Image)1183 if (!dvdMedium) 1189 1184 { 1190 1185 rc = E_FAIL; 1191 1186 break; 1192 1187 } 1193 dvdImage->COMGETTER(Id)(uuid.asOutParam()); 1194 CHECK_ERROR(dvdDrive, MountImage(uuid)); 1195 } 1188 } 1189 1190 /** @todo generalize this, allow arbitrary number of DVD drives 1191 * and as a consequence multiple attachments and different 1192 * storage controllers. */ 1193 if (dvdMedium) 1194 dvdMedium->COMGETTER(Id)(uuid.asOutParam()); 1195 else 1196 uuid = Guid().toString(); 1197 CHECK_ERROR(machine, MountMedium(Bstr("IDE"), 1, 0, uuid)); 1196 1198 } 1197 1199 else if (!strcmp(a->argv[1], "floppyattach")) … … 1204 1206 } 1205 1207 1206 ComPtr<IFloppyDrive> floppyDrive; 1207 sessionMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam()); 1208 ASSERT(floppyDrive); 1208 ComPtr<IMedium> floppyMedium; 1209 1209 1210 1210 /* unmount? */ 1211 1211 if (!strcmp(a->argv[2], "none")) 1212 1212 { 1213 CHECK_ERROR(floppyDrive, Unmount());1213 /* nothing to do, NULL object will cause unmount */ 1214 1214 } 1215 1215 /* host drive? */ … … 1218 1218 ComPtr<IHost> host; 1219 1219 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 1220 com::SafeIfaceArray <IHostFloppyDrive> hostFloppies; 1221 rc = host->COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(hostFloppies)); 1222 CheckComRCReturnRC (rc); 1223 ComPtr<IHostFloppyDrive> hostFloppyDrive; 1224 host->FindHostFloppyDrive(Bstr(a->argv[2] + 5), hostFloppyDrive.asOutParam()); 1225 if (!hostFloppyDrive) 1226 { 1227 errorArgument("Invalid host floppy drive name"); 1220 host->FindHostFloppyDrive(Bstr(a->argv[2] + 5), floppyMedium.asOutParam()); 1221 if (!floppyMedium) 1222 { 1223 errorArgument("Invalid host floppy drive name \"%s\"", 1224 a->argv[2] + 5); 1228 1225 rc = E_FAIL; 1229 1226 break; 1230 1227 } 1231 CHECK_ERROR(floppyDrive, CaptureHostDrive(hostFloppyDrive));1232 1228 } 1233 1229 else … … 1235 1231 /* first assume it's a UUID */ 1236 1232 Bstr uuid(a->argv[2]); 1237 ComPtr<IFloppyImage> floppyImage; 1238 rc = a->virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam()); 1239 if (FAILED(rc) || !floppyImage) 1233 rc = a->virtualBox->GetFloppyImage(uuid, floppyMedium.asOutParam()); 1234 if (FAILED(rc) || !floppyMedium) 1240 1235 { 1241 1236 /* must be a filename, check if it's in the collection */ 1242 rc = a->virtualBox->FindFloppyImage(Bstr(a->argv[2]), floppy Image.asOutParam());1237 rc = a->virtualBox->FindFloppyImage(Bstr(a->argv[2]), floppyMedium.asOutParam()); 1243 1238 /* not registered, do that on the fly */ 1244 if (!floppy Image)1239 if (!floppyMedium) 1245 1240 { 1246 1241 Bstr emptyUUID; 1247 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(a->argv[2]), emptyUUID, floppy Image.asOutParam()));1242 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(a->argv[2]), emptyUUID, floppyMedium.asOutParam())); 1248 1243 } 1249 1244 } 1250 if (!floppy Image)1245 if (!floppyMedium) 1251 1246 { 1252 1247 rc = E_FAIL; 1253 1248 break; 1254 1249 } 1255 floppyImage->COMGETTER(Id)(uuid.asOutParam());1256 CHECK_ERROR(floppyDrive, MountImage(uuid));1257 }1250 } 1251 floppyMedium->COMGETTER(Id)(uuid.asOutParam()); 1252 CHECK_ERROR(machine, MountMedium(Bstr("FD"), 0, 0, uuid)); 1258 1253 } 1259 1254 #ifdef VBOX_WITH_MEM_BALLOONING -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r22173 r23223 59 59 60 60 61 static int parseDiskVariant(const char *psz, HardDiskVariant_T *pDiskVariant)61 static int parseDiskVariant(const char *psz, MediumVariant_T *pDiskVariant) 62 62 { 63 63 int rc = VINF_SUCCESS; … … 76 76 // variant, whereas the other flags are cumulative. 77 77 if (!RTStrNICmp(psz, "standard", len)) 78 DiskVariant = HardDiskVariant_Standard;78 DiskVariant = MediumVariant_Standard; 79 79 else if ( !RTStrNICmp(psz, "fixed", len) 80 80 || !RTStrNICmp(psz, "static", len)) 81 DiskVariant |= HardDiskVariant_Fixed;81 DiskVariant |= MediumVariant_Fixed; 82 82 else if (!RTStrNICmp(psz, "Diff", len)) 83 DiskVariant |= HardDiskVariant_Diff;83 DiskVariant |= MediumVariant_Diff; 84 84 else if (!RTStrNICmp(psz, "split2g", len)) 85 DiskVariant |= HardDiskVariant_VmdkSplit2G;85 DiskVariant |= MediumVariant_VmdkSplit2G; 86 86 else if ( !RTStrNICmp(psz, "stream", len) 87 87 || !RTStrNICmp(psz, "streamoptimized", len)) 88 DiskVariant |= HardDiskVariant_VmdkStreamOptimized;88 DiskVariant |= MediumVariant_VmdkStreamOptimized; 89 89 else if (!RTStrNICmp(psz, "esx", len)) 90 DiskVariant |= HardDiskVariant_VmdkESX;90 DiskVariant |= MediumVariant_VmdkESX; 91 91 else 92 92 rc = VERR_PARSE_ERROR; … … 99 99 100 100 if (RT_SUCCESS(rc)) 101 *pDiskVariant = ( HardDiskVariant_T)DiskVariant;101 *pDiskVariant = (MediumVariant_T)DiskVariant; 102 102 return rc; 103 103 } 104 104 105 static int parseDiskType(const char *psz, HardDiskType_T *pDiskType)105 static int parseDiskType(const char *psz, MediumType_T *pDiskType) 106 106 { 107 107 int rc = VINF_SUCCESS; 108 HardDiskType_T DiskType = HardDiskType_Normal;108 MediumType_T DiskType = MediumType_Normal; 109 109 if (!RTStrICmp(psz, "normal")) 110 DiskType = HardDiskType_Normal;110 DiskType = MediumType_Normal; 111 111 else if (!RTStrICmp(psz, "immutable")) 112 DiskType = HardDiskType_Immutable;112 DiskType = MediumType_Immutable; 113 113 else if (!RTStrICmp(psz, "writethrough")) 114 DiskType = HardDiskType_Writethrough;114 DiskType = MediumType_Writethrough; 115 115 else 116 116 rc = VERR_PARSE_ERROR; … … 178 178 uint64_t sizeMB = 0; 179 179 Bstr format = "VDI"; 180 HardDiskVariant_T DiskVariant = HardDiskVariant_Standard;180 MediumVariant_T DiskVariant = MediumVariant_Standard; 181 181 Bstr comment; 182 182 bool fRemember = false; 183 HardDiskType_T DiskType = HardDiskType_Normal;183 MediumType_T DiskType = MediumType_Normal; 184 184 185 185 int c; … … 207 207 { 208 208 unsigned uDiskVariant = (unsigned)DiskVariant; 209 uDiskVariant |= HardDiskVariant_Fixed;210 DiskVariant = ( HardDiskVariant_T)uDiskVariant;209 uDiskVariant |= MediumVariant_Fixed; 210 DiskVariant = (MediumVariant_T)uDiskVariant; 211 211 break; 212 212 } … … 229 229 vrc = parseDiskType(ValueUnion.psz, &DiskType); 230 230 if ( RT_FAILURE(vrc) 231 || (DiskType != HardDiskType_Normal && DiskType != HardDiskType_Writethrough))231 || (DiskType != MediumType_Normal && DiskType != MediumType_Writethrough)) 232 232 return errorArgument("Invalid hard disk type '%s'", ValueUnion.psz); 233 233 break; … … 257 257 return errorSyntax(USAGE_CREATEHD, "Parameters --filename and --size are required"); 258 258 259 ComPtr<I HardDisk> hardDisk;259 ComPtr<IMedium> hardDisk; 260 260 CHECK_ERROR(a->virtualBox, CreateHardDisk(format, filename, hardDisk.asOutParam())); 261 261 if (SUCCEEDED(rc) && hardDisk) … … 294 294 CHECK_ERROR(hardDisk, COMGETTER(Id)(uuid.asOutParam())); 295 295 296 if (DiskType == HardDiskType_Writethrough)296 if (DiskType == MediumType_Writethrough) 297 297 { 298 CHECK_ERROR(hardDisk, COMSETTER(Type)( HardDiskType_Writethrough));298 CHECK_ERROR(hardDisk, COMSETTER(Type)(MediumType_Writethrough)); 299 299 } 300 300 … … 346 346 HRESULT rc; 347 347 int vrc; 348 ComPtr<I HardDisk> hardDisk;349 HardDiskType_T DiskType;348 ComPtr<IMedium> hardDisk; 349 MediumType_T DiskType; 350 350 bool AutoReset = false; 351 351 bool fModifyDiskType = false, fModifyAutoReset = false, fModifyCompact = false;; … … 425 425 if (SUCCEEDED(rc) && hardDisk) 426 426 { 427 HardDiskType_T hddType;427 MediumType_T hddType; 428 428 CHECK_ERROR(hardDisk, COMGETTER(Type)(&hddType)); 429 429 … … 518 518 Bstr src, dst; 519 519 Bstr format; 520 HardDiskVariant_T DiskVariant = HardDiskVariant_Standard;520 MediumVariant_T DiskVariant = MediumVariant_Standard; 521 521 bool fExisting = false; 522 522 bool fRemember = false; 523 523 bool fSetDiskType = false; 524 HardDiskType_T DiskType = HardDiskType_Normal;524 MediumType_T DiskType = MediumType_Normal; 525 525 526 526 int c; … … 540 540 { 541 541 unsigned uDiskVariant = (unsigned)DiskVariant; 542 uDiskVariant |= HardDiskVariant_Fixed;543 DiskVariant = ( HardDiskVariant_T)uDiskVariant;542 uDiskVariant |= MediumVariant_Fixed; 543 DiskVariant = (MediumVariant_T)uDiskVariant; 544 544 break; 545 545 } … … 596 596 if (dst.isEmpty()) 597 597 return errorSyntax(USAGE_CLONEHD, "Mandatory output file parameter missing"); 598 if (fExisting && (!format.isEmpty() || DiskVariant != HardDiskType_Normal))598 if (fExisting && (!format.isEmpty() || DiskVariant != MediumType_Normal)) 599 599 return errorSyntax(USAGE_CLONEHD, "Specified options which cannot be used with --existing"); 600 600 601 ComPtr<I HardDisk> srcDisk;602 ComPtr<I HardDisk> dstDisk;601 ComPtr<IMedium> srcDisk; 602 ComPtr<IMedium> dstDisk; 603 603 bool fSrcUnknown = false; 604 604 bool fDstUnknown = false; … … 668 668 { 669 669 /* Perform accessibility check now. */ 670 Medi aState_T state;670 MediumState_T state; 671 671 CHECK_ERROR_BREAK(dstDisk, COMGETTER(State)(&state)); 672 672 } … … 760 760 761 761 case 'm': // --variant 762 HardDiskVariant_T DiskVariant;762 MediumVariant_T DiskVariant; 763 763 rc = parseDiskVariant(ValueUnion.psz, &DiskVariant); 764 764 if (RT_FAILURE(rc)) … … 950 950 Bstr comment; 951 951 bool fIntNet = false; 952 HardDiskType_T DiskType = HardDiskType_Normal;952 MediumType_T DiskType = MediumType_Normal; 953 953 954 954 int c; … … 1029 1029 do 1030 1030 { 1031 ComPtr<I HardDisk> hardDisk;1031 ComPtr<IMedium> hardDisk; 1032 1032 /** @todo move the location stuff to Main, which can use pfnComposeName 1033 1033 * from the disk backends to construct the location properly. Also do … … 1096 1096 ComSafeArrayAsInParam (values))); 1097 1097 1098 if (DiskType != HardDiskType_Normal)1098 if (DiskType != MediumType_Normal) 1099 1099 { 1100 1100 CHECK_ERROR(hardDisk, COMSETTER(Type)(DiskType)); … … 1157 1157 return errorSyntax(USAGE_SHOWHDINFO, "Disk name or UUID required"); 1158 1158 1159 ComPtr<I HardDisk> hardDisk;1159 ComPtr<IMedium> hardDisk; 1160 1160 bool unknown = false; 1161 1161 /* first guess is that it's a UUID */ … … 1200 1200 /// @todo NEWMEDIA check accessibility of all parents 1201 1201 /// @todo NEWMEDIA print the full state value 1202 Medi aState_T state;1202 MediumState_T state; 1203 1203 CHECK_ERROR_BREAK (hardDisk, COMGETTER(State)(&state)); 1204 RTPrintf("Accessible: %s\n", state != Medi aState_Inaccessible ? "yes" : "no");1205 1206 if (state == Medi aState_Inaccessible)1204 RTPrintf("Accessible: %s\n", state != MediumState_Inaccessible ? "yes" : "no"); 1205 1206 if (state == MediumState_Inaccessible) 1207 1207 { 1208 1208 Bstr err; … … 1225 1225 RTPrintf("Current size on disk: %llu MBytes\n", actualSize >> 20); 1226 1226 1227 ComPtr <I HardDisk> parent;1227 ComPtr <IMedium> parent; 1228 1228 hardDisk->COMGETTER(Parent) (parent.asOutParam()); 1229 1229 1230 HardDiskType_T type;1230 MediumType_T type; 1231 1231 hardDisk->COMGETTER(Type)(&type); 1232 1232 const char *typeStr = "unknown"; 1233 1233 switch (type) 1234 1234 { 1235 case HardDiskType_Normal:1235 case MediumType_Normal: 1236 1236 if (!parent.isNull()) 1237 1237 typeStr = "normal (differencing)"; … … 1239 1239 typeStr = "normal (base)"; 1240 1240 break; 1241 case HardDiskType_Immutable:1241 case MediumType_Immutable: 1242 1242 typeStr = "immutable"; 1243 1243 break; 1244 case HardDiskType_Writethrough:1244 case MediumType_Writethrough: 1245 1245 typeStr = "writethrough"; 1246 1246 break; … … 1317 1317 } cmd = CMD_NONE; 1318 1318 const char *Filename = NULL; 1319 HardDiskType_T DiskType = HardDiskType_Normal;1319 MediumType_T DiskType = MediumType_Normal; 1320 1320 bool fDiskType = false; 1321 1321 bool fSetImageId = false; … … 1409 1409 if (cmd == CMD_DISK) 1410 1410 { 1411 ComPtr<I HardDisk> hardDisk;1411 ComPtr<IMedium> hardDisk; 1412 1412 Bstr ImageIdStr = BstrFmt("%RTuuid", &ImageId); 1413 1413 Bstr ParentIdStr = BstrFmt("%RTuuid", &ParentId); … … 1429 1429 { 1430 1430 /* change the type if requested */ 1431 if (DiskType != HardDiskType_Normal)1431 if (DiskType != MediumType_Normal) 1432 1432 { 1433 1433 CHECK_ERROR(hardDisk, COMSETTER(Type)(DiskType)); … … 1439 1439 if (fDiskType || fSetImageId || fSetParentId) 1440 1440 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for DVD images"); 1441 ComPtr<I DVDImage> dvdImage;1441 ComPtr<IMedium> dvdImage; 1442 1442 rc = a->virtualBox->OpenDVDImage(Bstr(Filename), Bstr(), dvdImage.asOutParam()); 1443 1443 if (rc == VBOX_E_FILE_ERROR) … … 1459 1459 if (fDiskType || fSetImageId || fSetParentId) 1460 1460 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for floppy images"); 1461 ComPtr<I FloppyImage> floppyImage;1461 ComPtr<IMedium> floppyImage; 1462 1462 rc = a->virtualBox->OpenFloppyImage(Bstr(Filename), Bstr(), floppyImage.asOutParam()); 1463 1463 if (rc == VBOX_E_FILE_ERROR) … … 1559 1559 if (cmd == CMD_DISK) 1560 1560 { 1561 ComPtr<I HardDisk> hardDisk;1561 ComPtr<IMedium> hardDisk; 1562 1562 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1563 1563 /* not a UUID or not registered? Then it must be a filename */ … … 1574 1574 if (cmd == CMD_DVD) 1575 1575 { 1576 ComPtr<I DVDImage> dvdImage;1576 ComPtr<IMedium> dvdImage; 1577 1577 rc = a->virtualBox->GetDVDImage(uuid, dvdImage.asOutParam()); 1578 1578 /* not a UUID or not registered? Then it must be a filename */ … … 1589 1589 if (cmd == CMD_FLOPPY) 1590 1590 { 1591 ComPtr<I FloppyImage> floppyImage;1591 ComPtr<IMedium> floppyImage; 1592 1592 rc = a->virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam()); 1593 1593 /* not a UUID or not registered? Then it must be a filename */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r23091 r23223 118 118 } 119 119 120 STDMETHOD(OnMedi aRegistered)(IN_BSTR mediaId,121 DeviceType_T mediaType, BOOL registered)120 STDMETHOD(OnMediumRegistered)(IN_BSTR mediaId, 121 DeviceType_T mediaType, BOOL registered) 122 122 { 123 123 NOREF(mediaId); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r23179 r23223 164 164 " [--dvd none|<uuid>|<filename>|host:<drive>]\n" 165 165 " [--dvdpassthrough on|off]\n" 166 " [--floppy disabled| empty|<uuid>|\n"166 " [--floppy disabled|none|<uuid>|\n" 167 167 " <filename>|host:<drive>]\n" 168 168 #if defined(VBOX_WITH_NETFLT) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r23168 r23223 443 443 #endif 444 444 445 ComPtr<IFloppyDrive> floppyDrive; 446 rc = machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam()); 447 if (SUCCEEDED(rc) && floppyDrive) 448 { 449 BOOL fFloppyEnabled; 450 floppyDrive->COMGETTER(Enabled)(&fFloppyEnabled); 451 Utf8Str pszFloppy = "invalid"; 452 if (fFloppyEnabled) 453 { 454 DriveState_T floppyState; 455 floppyDrive->COMGETTER(State)(&floppyState); 456 switch (floppyState) 457 { 458 case DriveState_ImageMounted: 445 /* 446 * Floppy. 447 */ 448 ComPtr<IStorageController> FloppyCtl; 449 bool fFloppyEnabled = false; 450 451 rc = machine->GetStorageControllerByName(Bstr("FD"), FloppyCtl.asOutParam()); 452 if (SUCCEEDED(rc)) 453 fFloppyEnabled = true; 454 455 if (details == VMINFO_MACHINEREADABLE) 456 RTPrintf("floppy=\"%s\"\n", fFloppyEnabled ? "on" : "off"); 457 else 458 RTPrintf("Floppy: %s\n", fFloppyEnabled ? "enabled" : "disabled"); 459 460 /* 461 * Floppy drives and media 462 */ 463 if (fFloppyEnabled) 464 { 465 ComPtr<IMedium> floppyMedium; 466 Bstr filePath; 467 ULONG cFloppyPorts; 468 469 FloppyCtl->COMGETTER(PortCount)(&cFloppyPorts); 470 for (ULONG i = 0; i < cFloppyPorts; ++ i) 471 { 472 rc = machine->GetMedium(Bstr("FD"), 0, i, floppyMedium.asOutParam()); 473 if (SUCCEEDED(rc) && floppyMedium) 474 { 475 floppyMedium->COMGETTER(Location)(filePath.asOutParam()); 476 floppyMedium->COMGETTER(Id)(uuid.asOutParam()); 477 if (details == VMINFO_MACHINEREADABLE) 459 478 { 460 ComPtr<IFloppyImage> floppyImage; 461 rc = floppyDrive->GetImage(floppyImage.asOutParam()); 462 if (SUCCEEDED(rc) && floppyImage) 463 { 464 Bstr imagePath; 465 floppyImage->COMGETTER(Location)(imagePath.asOutParam()); 466 Bstr imageGuid; 467 floppyImage->COMGETTER(Id)(imageGuid.asOutParam()); 468 if (details == VMINFO_MACHINEREADABLE) 469 { 470 RTPrintf("FloppyImageUUID=\"%s\"\n", Utf8Str(imageGuid).raw()); 471 pszFloppy = Utf8StrFmt("%lS", imagePath.raw()); 472 } 473 else 474 pszFloppy = Utf8StrFmt("%lS (UUID: %s)", imagePath.raw(), Utf8Str(imageGuid).raw()); 475 } 476 break; 479 RTPrintf("floppy%d=\"%lS\"\n", i, filePath.raw()); 480 RTPrintf("FloppyImageUUID%d=\"%s\"\n", i, Utf8Str(uuid).raw()); 477 481 } 478 479 case DriveState_HostDriveCaptured: 480 { 481 ComPtr<IHostFloppyDrive> hostFloppyDrive; 482 rc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam()); 483 if (SUCCEEDED(rc) && floppyDrive) 484 { 485 Bstr driveName; 486 hostFloppyDrive->COMGETTER(Name)(driveName.asOutParam()); 487 if (details == VMINFO_MACHINEREADABLE) 488 pszFloppy = Utf8StrFmt("host:%lS", driveName.raw()); 489 else 490 pszFloppy = Utf8StrFmt("Host drive %lS", driveName.raw()); 491 } 492 break; 493 } 494 495 case DriveState_NotMounted: 496 { 497 pszFloppy = "empty"; 498 break; 499 } 500 } 501 } 502 else 503 { 504 pszFloppy = "disabled"; 505 } 506 if (details == VMINFO_MACHINEREADABLE) 507 RTPrintf("floppy=\"%s\"\n", pszFloppy.raw()); 508 else 509 RTPrintf("Floppy: %s\n", pszFloppy.raw()); 482 else 483 RTPrintf("Floppy %d: %lS (UUID: %s)\n", i, filePath.raw(), Utf8Str(uuid).raw()); 484 } 485 else 486 { 487 if (details == VMINFO_MACHINEREADABLE) 488 RTPrintf("floppy%d=\"none\"\n",i); 489 } 490 } 510 491 } 511 492 … … 533 514 if (fSataEnabled) 534 515 { 535 ComPtr<I HardDisk> hardDisk;516 ComPtr<IMedium> hardDisk; 536 517 Bstr filePath; 537 518 ULONG cSataPorts; … … 540 521 for (ULONG i = 0; i < cSataPorts; ++ i) 541 522 { 542 rc = machine->Get HardDisk(Bstr("SATA"), i, 0, hardDisk.asOutParam());523 rc = machine->GetMedium(Bstr("SATA"), i, 0, hardDisk.asOutParam()); 543 524 if (SUCCEEDED(rc) && hardDisk) 544 525 { … … 595 576 } 596 577 597 ComPtr<I HardDisk> hardDisk;578 ComPtr<IMedium> hardDisk; 598 579 Bstr filePath; 599 rc = machine->Get HardDisk(Bstr("IDE"), 0, 0, hardDisk.asOutParam());580 rc = machine->GetMedium(Bstr("IDE"), 0, 0, hardDisk.asOutParam()); 600 581 if (SUCCEEDED(rc) && hardDisk) 601 582 { … … 615 596 RTPrintf("hda=\"none\"\n"); 616 597 } 617 rc = machine->Get HardDisk(Bstr("IDE"), 0, 1, hardDisk.asOutParam());598 rc = machine->GetMedium(Bstr("IDE"), 0, 1, hardDisk.asOutParam()); 618 599 if (SUCCEEDED(rc) && hardDisk) 619 600 { … … 633 614 RTPrintf("hdb=\"none\"\n"); 634 615 } 635 rc = machine->Get HardDisk(Bstr("IDE"), 1, 1, hardDisk.asOutParam());616 rc = machine->GetMedium(Bstr("IDE"), 1, 1, hardDisk.asOutParam()); 636 617 if (SUCCEEDED(rc) && hardDisk) 637 618 { … … 651 632 RTPrintf("hdd=\"none\"\n"); 652 633 } 653 ComPtr<IDVDDrive> dvdDrive; 654 rc = machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam()); 655 if (SUCCEEDED(rc) && dvdDrive) 656 { 657 ComPtr<IDVDImage> dvdImage; 658 rc = dvdDrive->GetImage(dvdImage.asOutParam()); 659 if (SUCCEEDED(rc) && dvdImage) 660 { 661 rc = dvdImage->COMGETTER(Location)(filePath.asOutParam()); 662 if (SUCCEEDED(rc) && filePath) 663 { 664 rc = dvdImage->COMGETTER(Id)(uuid.asOutParam()); 665 if (details == VMINFO_MACHINEREADABLE) 666 { 667 RTPrintf("dvd=\"%lS\"\n", filePath.raw()); 668 RTPrintf("DvdImageUUID=\"%s\"\n", Utf8Str(uuid).raw()); 669 } 670 else 671 RTPrintf("DVD: %lS (UUID: %s)\n", filePath.raw(), Utf8Str(uuid).raw()); 672 } 634 ComPtr<IMedium> dvdMedium; 635 rc = machine->GetMedium(Bstr("IDE"), 1, 0, dvdMedium.asOutParam()); 636 if (SUCCEEDED(rc) && dvdMedium) 637 { 638 dvdMedium->COMGETTER(Location)(filePath.asOutParam()); 639 dvdMedium->COMGETTER(Id)(uuid.asOutParam()); 640 if (details == VMINFO_MACHINEREADABLE) 641 { 642 RTPrintf("dvd=\"%lS\"\n", filePath.raw()); 643 RTPrintf("DvdImageUUID=\"%s\"\n", Utf8Str(uuid).raw()); 673 644 } 674 645 else 675 { 676 ComPtr<IHostDVDDrive> hostDVDDrive; 677 rc = dvdDrive->GetHostDrive(hostDVDDrive.asOutParam()); 678 if (SUCCEEDED(rc) && hostDVDDrive) 679 { 680 Bstr name; 681 hostDVDDrive->COMGETTER(Name)(name.asOutParam()); 682 if (details == VMINFO_MACHINEREADABLE) 683 RTPrintf("dvd=\"host:%lS\"\n", name.raw()); 684 else 685 RTPrintf("DVD: Host drive %lS", name.raw()); 686 } 687 else 688 { 689 if (details == VMINFO_MACHINEREADABLE) 690 RTPrintf("dvd=\"none\"\n"); 691 else 692 RTPrintf("DVD: empty"); 693 } 694 BOOL fPassthrough; 695 dvdDrive->COMGETTER(Passthrough)(&fPassthrough); 696 if (details == VMINFO_MACHINEREADABLE) 697 { 698 RTPrintf("dvdpassthrough=\"%s\"\n", fPassthrough ? "on" : "off"); 699 } 700 else 701 { 702 if (fPassthrough) 703 RTPrintf(" (passthrough enabled)"); 704 RTPrintf("\n"); 705 } 706 } 646 RTPrintf("DVD: %lS (UUID: %s)\n", filePath.raw(), Utf8Str(uuid).raw()); 647 648 BOOL fPassthrough; 649 ComPtr<IMediumAttachment> dvdAttachment; 650 machine->GetMediumAttachment(Bstr("IDE"), 1, 0, dvdAttachment.asOutParam()); 651 dvdAttachment->COMGETTER(Passthrough)(&fPassthrough); 652 if (details == VMINFO_MACHINEREADABLE) 653 { 654 RTPrintf("dvdpassthrough=\"%s\"\n", fPassthrough ? "on" : "off"); 655 } 656 else 657 { 658 if (fPassthrough) 659 RTPrintf(" (passthrough enabled)"); 660 RTPrintf("\n"); 661 } 662 } 663 else 664 { 665 if (details == VMINFO_MACHINEREADABLE) 666 RTPrintf("dvd=\"none\"\n"); 667 else 668 RTPrintf("DVD: empty"); 707 669 } 708 670 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r21734 r23223 97 97 { "hostdvds", LISTHOSTDVDS, RTGETOPT_REQ_NOTHING }, 98 98 { "hostfloppies", LISTHOSTFLOPPIES, RTGETOPT_REQ_NOTHING }, 99 { "hostifs", 100 { "bridgedifs", 99 { "hostifs", LISTBRIDGEDIFS, RTGETOPT_REQ_NOTHING }, /* backward compatibility */ 100 { "bridgedifs", LISTBRIDGEDIFS, RTGETOPT_REQ_NOTHING }, 101 101 #if defined(VBOX_WITH_NETFLT) 102 { "hostonlyifs", 102 { "hostonlyifs", LISTHOSTONLYIFS, RTGETOPT_REQ_NOTHING }, 103 103 #endif 104 104 { "hostinfo", LISTHOSTINFO, RTGETOPT_REQ_NOTHING }, … … 270 270 ComPtr<IHost> host; 271 271 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 272 com::SafeIfaceArray <I HostDVDDrive> coll;272 com::SafeIfaceArray <IMedium> coll; 273 273 CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll))); 274 274 if (SUCCEEDED(rc)) … … 276 276 for (size_t i = 0; i < coll.size(); ++ i) 277 277 { 278 ComPtr<IHostDVDDrive> dvdDrive = coll[i]; 278 ComPtr<IMedium> dvdDrive = coll[i]; 279 Bstr uuid; 280 dvdDrive->COMGETTER(Id)(uuid.asOutParam()); 281 RTPrintf("UUID: %s\n", Utf8Str(uuid).raw()); 279 282 Bstr name; 280 283 dvdDrive->COMGETTER(Name)(name.asOutParam()); 281 RTPrintf("Name: %lS\n\n", name.raw());284 RTPrintf("Name: %lS\n\n", name.raw()); 282 285 } 283 286 } … … 289 292 ComPtr<IHost> host; 290 293 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 291 com::SafeIfaceArray <I HostFloppyDrive> coll;294 com::SafeIfaceArray <IMedium> coll; 292 295 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll))); 293 296 if (SUCCEEDED(rc)) … … 295 298 for (size_t i = 0; i < coll.size(); ++i) 296 299 { 297 ComPtr<IHostFloppyDrive> floppyDrive = coll[i]; 300 ComPtr<IMedium> floppyDrive = coll[i]; 301 Bstr uuid; 302 floppyDrive->COMGETTER(Id)(uuid.asOutParam()); 303 RTPrintf("UUID: %s\n", Utf8Str(uuid).raw()); 298 304 Bstr name; 299 305 floppyDrive->COMGETTER(Name)(name.asOutParam()); 300 RTPrintf("Name: %lS\n\n", name.raw());306 RTPrintf("Name: %lS\n\n", name.raw()); 301 307 } 302 308 } … … 430 436 CHECK_ERROR(a->virtualBox, 431 437 COMGETTER(SystemProperties) (systemProperties.asOutParam())); 432 com::SafeIfaceArray <I HardDiskFormat> hardDiskFormats;438 com::SafeIfaceArray <IMediumFormat> mediumFormats; 433 439 CHECK_ERROR(systemProperties, 434 COMGETTER( HardDiskFormats) (ComSafeArrayAsOutParam (hardDiskFormats)));440 COMGETTER(MediumFormats) (ComSafeArrayAsOutParam (mediumFormats))); 435 441 436 442 RTPrintf("Supported hard disk backends:\n\n"); 437 for (size_t i = 0; i < hardDiskFormats.size(); ++ i)443 for (size_t i = 0; i < mediumFormats.size(); ++ i) 438 444 { 439 445 /* General information */ 440 446 Bstr id; 441 CHECK_ERROR( hardDiskFormats [i],447 CHECK_ERROR(mediumFormats [i], 442 448 COMGETTER(Id) (id.asOutParam())); 443 449 444 450 Bstr description; 445 CHECK_ERROR( hardDiskFormats [i],451 CHECK_ERROR(mediumFormats [i], 446 452 COMGETTER(Id) (description.asOutParam())); 447 453 448 454 ULONG caps; 449 CHECK_ERROR( hardDiskFormats [i],455 CHECK_ERROR(mediumFormats [i], 450 456 COMGETTER(Capabilities) (&caps)); 451 457 … … 455 461 /* File extensions */ 456 462 com::SafeArray <BSTR> fileExtensions; 457 CHECK_ERROR( hardDiskFormats [i],463 CHECK_ERROR(mediumFormats [i], 458 464 COMGETTER(FileExtensions) (ComSafeArrayAsOutParam (fileExtensions))); 459 465 for (size_t a = 0; a < fileExtensions.size(); ++ a) … … 471 477 com::SafeArray <ULONG> propertyFlags; 472 478 com::SafeArray <BSTR> propertyDefaults; 473 CHECK_ERROR( hardDiskFormats [i],479 CHECK_ERROR(mediumFormats [i], 474 480 DescribeProperties (ComSafeArrayAsOutParam (propertyNames), 475 481 ComSafeArrayAsOutParam (propertyDescriptions), … … 504 510 case LISTHDDS: 505 511 { 506 com::SafeIfaceArray<I HardDisk> hdds;512 com::SafeIfaceArray<IMedium> hdds; 507 513 CHECK_ERROR(a->virtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam (hdds))); 508 514 for (size_t i = 0; i < hdds.size(); ++ i) 509 515 { 510 ComPtr<I HardDisk> hdd = hdds[i];516 ComPtr<IMedium> hdd = hdds[i]; 511 517 Bstr uuid; 512 518 hdd->COMGETTER(Id)(uuid.asOutParam()); … … 518 524 hdd->COMGETTER(Location)(filepath.asOutParam()); 519 525 RTPrintf("Location: %lS\n", filepath.raw()); 520 Medi aState_T enmState;526 MediumState_T enmState; 521 527 /// @todo NEWMEDIA check accessibility of all parents 522 528 /// @todo NEWMEDIA print the full state value 523 529 hdd->COMGETTER(State)(&enmState); 524 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no"); 530 RTPrintf("Accessible: %s\n", enmState != MediumState_Inaccessible ? "yes" : "no"); 531 532 MediumType_T type; 533 hdd->COMGETTER(Type)(&type); 534 const char *typeStr = "unknown"; 535 switch (type) 536 { 537 case MediumType_Normal: 538 typeStr = "normal"; 539 break; 540 case MediumType_Immutable: 541 typeStr = "immutable"; 542 break; 543 case MediumType_Writethrough: 544 typeStr = "writethrough"; 545 break; 546 } 547 RTPrintf("Type: %s\n", typeStr); 548 525 549 com::SafeArray<BSTR> machineIds; 526 550 hdd->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds)); … … 547 571 case LISTDVDS: 548 572 { 549 com::SafeIfaceArray<I DVDImage> dvds;573 com::SafeIfaceArray<IMedium> dvds; 550 574 CHECK_ERROR(a->virtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds))); 551 575 for (size_t i = 0; i < dvds.size(); ++ i) 552 576 { 553 ComPtr<I DVDImage> dvdImage = dvds[i];577 ComPtr<IMedium> dvdImage = dvds[i]; 554 578 Bstr uuid; 555 579 dvdImage->COMGETTER(Id)(uuid.asOutParam()); … … 558 582 dvdImage->COMGETTER(Location)(filePath.asOutParam()); 559 583 RTPrintf("Path: %lS\n", filePath.raw()); 560 Medi aState_T enmState;584 MediumState_T enmState; 561 585 dvdImage->COMGETTER(State)(&enmState); 562 RTPrintf("Accessible: %s\n", enmState != Medi aState_Inaccessible ? "yes" : "no");586 RTPrintf("Accessible: %s\n", enmState != MediumState_Inaccessible ? "yes" : "no"); 563 587 /** @todo usage */ 564 588 RTPrintf("\n"); … … 569 593 case LISTFLOPPIES: 570 594 { 571 com::SafeIfaceArray<I FloppyImage> floppies;595 com::SafeIfaceArray<IMedium> floppies; 572 596 CHECK_ERROR(a->virtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies))); 573 597 for (size_t i = 0; i < floppies.size(); ++ i) 574 598 { 575 ComPtr<I FloppyImage> floppyImage = floppies[i];599 ComPtr<IMedium> floppyImage = floppies[i]; 576 600 Bstr uuid; 577 601 floppyImage->COMGETTER(Id)(uuid.asOutParam()); … … 580 604 floppyImage->COMGETTER(Location)(filePath.asOutParam()); 581 605 RTPrintf("Path: %lS\n", filePath.raw()); 582 Medi aState_T enmState;606 MediumState_T enmState; 583 607 floppyImage->COMGETTER(State)(&enmState); 584 RTPrintf("Accessible: %s\n", enmState != Medi aState_Inaccessible ? "yes" : "no");608 RTPrintf("Accessible: %s\n", enmState != MediumState_Inaccessible ? "yes" : "no"); 585 609 /** @todo usage */ 586 610 RTPrintf("\n"); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r23183 r23223 1072 1072 if (!strcmp(firmware, "efi")) 1073 1073 { 1074 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_E fi));1074 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI)); 1075 1075 } 1076 1076 else if (!strcmp(firmware, "bios")) 1077 1077 { 1078 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_B ios));1078 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_BIOS)); 1079 1079 } 1080 1080 else … … 1174 1174 if (!strcmp(hdds[0], "none")) 1175 1175 { 1176 machine->Detach HardDisk(Bstr("IDE"), 0, 0);1176 machine->DetachDevice(Bstr("IDE"), 0, 0); 1177 1177 } 1178 1178 else … … 1180 1180 /* first guess is that it's a UUID */ 1181 1181 Bstr uuid(hdds[0]); 1182 ComPtr<I HardDisk> hardDisk;1182 ComPtr<IMedium> hardDisk; 1183 1183 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1184 1184 /* not successful? Then it must be a filename */ … … 1195 1195 { 1196 1196 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 1197 CHECK_ERROR(machine, Attach HardDisk(uuid, Bstr("IDE"), 0, 0));1197 CHECK_ERROR(machine, AttachDevice(Bstr("IDE"), 0, 0, DeviceType_HardDisk, uuid)); 1198 1198 } 1199 1199 else … … 1207 1207 if (!strcmp(hdds[1], "none")) 1208 1208 { 1209 machine->Detach HardDisk(Bstr("IDE"), 0, 1);1209 machine->DetachDevice(Bstr("IDE"), 0, 1); 1210 1210 } 1211 1211 else … … 1213 1213 /* first guess is that it's a UUID */ 1214 1214 Bstr uuid(hdds[1]); 1215 ComPtr<I HardDisk> hardDisk;1215 ComPtr<IMedium> hardDisk; 1216 1216 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1217 1217 /* not successful? Then it must be a filename */ … … 1228 1228 { 1229 1229 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 1230 CHECK_ERROR(machine, Attach HardDisk(uuid, Bstr("IDE"), 0, 1));1230 CHECK_ERROR(machine, AttachDevice(Bstr("IDE"), 0, 1, DeviceType_HardDisk, uuid)); 1231 1231 } 1232 1232 else … … 1240 1240 if (!strcmp(hdds[2], "none")) 1241 1241 { 1242 machine->Detach HardDisk(Bstr("IDE"), 1, 1);1242 machine->DetachDevice(Bstr("IDE"), 1, 1); 1243 1243 } 1244 1244 else … … 1246 1246 /* first guess is that it's a UUID */ 1247 1247 Bstr uuid(hdds[2]); 1248 ComPtr<I HardDisk> hardDisk;1248 ComPtr<IMedium> hardDisk; 1249 1249 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1250 1250 /* not successful? Then it must be a filename */ … … 1261 1261 { 1262 1262 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 1263 CHECK_ERROR(machine, Attach HardDisk(uuid, Bstr("IDE"), 1, 1));1263 CHECK_ERROR(machine, AttachDevice(Bstr("IDE"), 1, 1, DeviceType_HardDisk, uuid)); 1264 1264 } 1265 1265 else … … 1271 1271 if (dvd) 1272 1272 { 1273 ComPtr<IDVDDrive> dvdDrive; 1274 machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam()); 1275 ASSERT(dvdDrive); 1273 ComPtr<IMedium> dvdMedium; 1276 1274 1277 1275 /* unmount? */ 1278 1276 if (!strcmp(dvd, "none")) 1279 1277 { 1280 CHECK_ERROR(dvdDrive, Unmount());1278 /* nothing to do, NULL object will cause unmount */ 1281 1279 } 1282 1280 /* host drive? */ … … 1285 1283 ComPtr<IHost> host; 1286 1284 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 1287 com::SafeIfaceArray <IHostDVDDrive> hostDVDs; 1288 rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs)); 1289 1290 ComPtr<IHostDVDDrive> hostDVDDrive; 1291 rc = host->FindHostDVDDrive(Bstr(dvd + 5), hostDVDDrive.asOutParam()); 1292 if (!hostDVDDrive) 1285 rc = host->FindHostDVDDrive(Bstr(dvd + 5), dvdMedium.asOutParam()); 1286 if (!dvdMedium) 1293 1287 { 1294 1288 /* 2nd try: try with the real name, important on Linux+libhal */ … … 1296 1290 if (RT_FAILURE(RTPathReal(dvd + 5, szPathReal, sizeof(szPathReal)))) 1297 1291 { 1298 errorArgument("Invalid host DVD drive name ");1292 errorArgument("Invalid host DVD drive name \"%s\"", dvd + 5); 1299 1293 rc = E_FAIL; 1300 1294 break; 1301 1295 } 1302 rc = host->FindHostDVDDrive(Bstr(szPathReal), hostDVDDrive.asOutParam());1303 if (! hostDVDDrive)1304 { 1305 errorArgument("Invalid host DVD drive name ");1296 rc = host->FindHostDVDDrive(Bstr(szPathReal), dvdMedium.asOutParam()); 1297 if (!dvdMedium) 1298 { 1299 errorArgument("Invalid host DVD drive name \"%s\"", dvd + 5); 1306 1300 rc = E_FAIL; 1307 1301 break; 1308 1302 } 1309 1303 } 1310 CHECK_ERROR(dvdDrive, CaptureHostDrive(hostDVDDrive));1311 1304 } 1312 1305 else … … 1314 1307 /* first assume it's a UUID */ 1315 1308 Bstr uuid(dvd); 1316 ComPtr<IDVDImage> dvdImage; 1317 rc = a->virtualBox->GetDVDImage(uuid, dvdImage.asOutParam()); 1318 if (FAILED(rc) || !dvdImage) 1309 rc = a->virtualBox->GetDVDImage(uuid, dvdMedium.asOutParam()); 1310 if (FAILED(rc) || !dvdMedium) 1319 1311 { 1320 1312 /* must be a filename, check if it's in the collection */ 1321 rc = a->virtualBox->FindDVDImage(Bstr(dvd), dvd Image.asOutParam());1313 rc = a->virtualBox->FindDVDImage(Bstr(dvd), dvdMedium.asOutParam()); 1322 1314 /* not registered, do that on the fly */ 1323 if (!dvd Image)1315 if (!dvdMedium) 1324 1316 { 1325 1317 Bstr emptyUUID; 1326 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(dvd), emptyUUID, dvd Image.asOutParam()));1327 } 1328 } 1329 if (!dvd Image)1318 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(dvd), emptyUUID, dvdMedium.asOutParam())); 1319 } 1320 } 1321 if (!dvdMedium) 1330 1322 { 1331 1323 rc = E_FAIL; 1332 1324 break; 1333 1325 } 1334 1335 dvdImage->COMGETTER(Id)(uuid.asOutParam()); 1336 CHECK_ERROR(dvdDrive, MountImage(uuid)); 1337 } 1326 } 1327 1328 /** @todo generalize this, allow arbitrary number of DVD drives 1329 * and as a consequence multiple attachments and different 1330 * storage controllers. */ 1331 dvdMedium->COMGETTER(Id)(uuid.asOutParam()); 1332 CHECK_ERROR(machine, MountMedium(Bstr("IDE"), 1, 0, uuid)); 1338 1333 } 1339 1334 if (dvdpassthrough) 1340 1335 { 1341 ComPtr<I DVDDrive> dvdDrive;1342 machine-> COMGETTER(DVDDrive)(dvdDrive.asOutParam());1343 ASSERT(dvd Drive);1344 1345 CHECK_ERROR(dvd Drive, COMSETTER(Passthrough)(!strcmp(dvdpassthrough, "on")));1336 ComPtr<IMediumAttachment> dvdAttachment; 1337 machine->GetMediumAttachment(Bstr("IDE"), 1, 0, dvdAttachment.asOutParam()); 1338 ASSERT(dvdAttachment); 1339 1340 CHECK_ERROR(dvdAttachment, COMSETTER(Passthrough)(!strcmp(dvdpassthrough, "on"))); 1346 1341 } 1347 1342 if (idecontroller) … … 1371 1366 if (floppy) 1372 1367 { 1373 ComPtr<I FloppyDrive> floppyDrive;1374 machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());1375 ASSERT(floppyDrive);1368 ComPtr<IMedium> floppyMedium; 1369 ComPtr<IMediumAttachment> floppyAttachment; 1370 machine->GetMediumAttachment(Bstr("FD"), 0, 0, floppyAttachment.asOutParam()); 1376 1371 1377 1372 /* disable? */ … … 1379 1374 { 1380 1375 /* disable the controller */ 1381 CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(false)); 1376 if (floppyAttachment) 1377 CHECK_ERROR(machine, DetachDevice(Bstr("FD"), 0, 0)); 1382 1378 } 1383 1379 else 1384 1380 { 1385 1381 /* enable the controller */ 1386 CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(true)); 1382 if (!floppyAttachment) 1383 CHECK_ERROR(machine, AttachDevice(Bstr("FD"), 0, 0, DeviceType_Floppy, NULL)); 1387 1384 1388 1385 /* unmount? */ 1389 if (!strcmp(floppy, "empty")) 1390 { 1391 CHECK_ERROR(floppyDrive, Unmount()); 1386 if ( !strcmp(floppy, "none") 1387 || !strcmp(floppy, "empty")) // deprecated 1388 { 1389 /* nothing to do, NULL object will cause unmount */ 1392 1390 } 1393 1391 /* host drive? */ … … 1396 1394 ComPtr<IHost> host; 1397 1395 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 1398 com::SafeIfaceArray <IHostFloppyDrive> hostFloppies; 1399 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(hostFloppies))); 1400 ComPtr<IHostFloppyDrive> hostFloppyDrive; 1401 rc = host->FindHostFloppyDrive(Bstr(floppy + 5), hostFloppyDrive.asOutParam()); 1402 if (!hostFloppyDrive) 1403 { 1404 errorArgument("Invalid host floppy drive name"); 1396 rc = host->FindHostFloppyDrive(Bstr(floppy + 5), floppyMedium.asOutParam()); 1397 if (!floppyMedium) 1398 { 1399 errorArgument("Invalid host floppy drive name \"%s\"", floppy + 5); 1405 1400 rc = E_FAIL; 1406 1401 break; 1407 1402 } 1408 CHECK_ERROR(floppyDrive, CaptureHostDrive(hostFloppyDrive));1409 1403 } 1410 1404 else … … 1412 1406 /* first assume it's a UUID */ 1413 1407 Bstr uuid(floppy); 1414 ComPtr<IFloppyImage> floppyImage; 1415 rc = a->virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam()); 1416 if (FAILED(rc) || !floppyImage) 1408 rc = a->virtualBox->GetFloppyImage(uuid, floppyMedium.asOutParam()); 1409 if (FAILED(rc) || !floppyMedium) 1417 1410 { 1418 1411 /* must be a filename, check if it's in the collection */ 1419 rc = a->virtualBox->FindFloppyImage(Bstr(floppy), floppy Image.asOutParam());1412 rc = a->virtualBox->FindFloppyImage(Bstr(floppy), floppyMedium.asOutParam()); 1420 1413 /* not registered, do that on the fly */ 1421 if (!floppy Image)1414 if (!floppyMedium) 1422 1415 { 1423 1416 Bstr emptyUUID; 1424 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(floppy), emptyUUID, floppy Image.asOutParam()));1417 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(floppy), emptyUUID, floppyMedium.asOutParam())); 1425 1418 } 1426 1419 } 1427 if (!floppy Image)1420 if (!floppyMedium) 1428 1421 { 1429 1422 rc = E_FAIL; 1430 1423 break; 1431 1424 } 1432 1433 floppyImage->COMGETTER(Id)(uuid.asOutParam()); 1434 CHECK_ERROR(floppyDrive, MountImage(uuid)); 1435 } 1425 } 1426 floppyMedium->COMGETTER(Id)(uuid.asOutParam()); 1427 CHECK_ERROR(machine, MountMedium(Bstr("FD"), 0, 0, uuid)); 1436 1428 } 1437 1429 } … … 1975 1967 if (!strcmp(hdds[i], "none")) 1976 1968 { 1977 machine->Detach HardDisk(Bstr("SATA"), i-4, 0);1969 machine->DetachDevice(Bstr("SATA"), i-4, 0); 1978 1970 } 1979 1971 else … … 1981 1973 /* first guess is that it's a UUID */ 1982 1974 Bstr uuid(hdds[i]); 1983 ComPtr<I HardDisk> hardDisk;1975 ComPtr<IMedium> hardDisk; 1984 1976 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1985 1977 /* not successful? Then it must be a filename */ … … 1996 1988 { 1997 1989 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 1998 CHECK_ERROR(machine, Attach HardDisk(uuid, Bstr("SATA"), i-4, 0));1990 CHECK_ERROR(machine, AttachDevice(Bstr("SATA"), i-4, 0, DeviceType_HardDisk, uuid)); 1999 1991 } 2000 1992 else … … 2062 2054 if (!strcmp(hdds[i], "none")) 2063 2055 { 2064 rc = machine->Detach HardDisk(Bstr("LsiLogic"), i-34, 0);2056 rc = machine->DetachDevice(Bstr("LsiLogic"), i-34, 0); 2065 2057 if (!SUCCEEDED(rc)) 2066 CHECK_ERROR(machine, Detach HardDisk(Bstr("BusLogic"), i-34, 0));2058 CHECK_ERROR(machine, DetachDevice(Bstr("BusLogic"), i-34, 0)); 2067 2059 } 2068 2060 else … … 2070 2062 /* first guess is that it's a UUID */ 2071 2063 Bstr uuid(hdds[i]); 2072 ComPtr<I HardDisk> hardDisk;2064 ComPtr<IMedium> hardDisk; 2073 2065 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 2074 2066 /* not successful? Then it must be a filename */ … … 2085 2077 { 2086 2078 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 2087 rc = machine->Attach HardDisk(uuid, Bstr("LsiLogic"), i-34, 0);2079 rc = machine->AttachDevice(Bstr("LsiLogic"), i-34, 0, DeviceType_HardDisk, uuid); 2088 2080 if (!SUCCEEDED(rc)) 2089 CHECK_ERROR(machine, Attach HardDisk(uuid, Bstr("BusLogic"), i-34, 0));2081 CHECK_ERROR(machine, AttachDevice(Bstr("BusLogic"), i-34, 0, DeviceType_HardDisk, uuid)); 2090 2082 } 2091 2083 else -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r23184 r23223 327 327 } 328 328 329 STDMETHOD(OnMedi aRegistered)(IN_BSTR mediaId, DeviceType_T mediaType,329 STDMETHOD(OnMediumRegistered)(IN_BSTR mediaId, DeviceType_T mediaType, 330 330 BOOL registered) 331 331 { … … 493 493 } 494 494 495 STDMETHOD(OnDVDDriveChange)()496 {497 return S_OK;498 }499 500 STDMETHOD(OnFloppyDriveChange)()501 {502 return S_OK;503 }504 505 495 STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter) 506 496 { … … 540 530 541 531 STDMETHOD(OnStorageControllerChange) () 532 { 533 return S_OK; 534 } 535 536 STDMETHOD(OnMediumChange)(IMediumAttachment * /*aMediumAttachment*/) 542 537 { 543 538 return S_OK; … … 1447 1442 } 1448 1443 } 1449 if (FAILED 1444 if (FAILED(rc)) 1450 1445 break; 1451 1446 … … 1527 1522 */ 1528 1523 Bstr hdaFileBstr = hdaFile; 1529 ComPtr<I HardDisk> hardDisk;1524 ComPtr<IMedium> hardDisk; 1530 1525 virtualBox->FindHardDisk(hdaFileBstr, hardDisk.asOutParam()); 1531 1526 if (!hardDisk) … … 1543 1538 Bstr uuid; 1544 1539 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 1545 gMachine->Detach HardDisk(Bstr("IDE"), 0, 0);1546 gMachine->Attach HardDisk(uuid, Bstr("IDE"), 0, 0);1540 gMachine->DetachDevice(Bstr("IDE"), 0, 0); 1541 gMachine->AttachDevice(Bstr("IDE"), 0, 0, DeviceType_HardDisk, uuid); 1547 1542 /// @todo why is this attachment saved? 1548 1543 } … … 1560 1555 do 1561 1556 { 1562 ComPtr<IFloppyDrive> drive; 1563 CHECK_ERROR_BREAK (gMachine, COMGETTER(FloppyDrive)(drive.asOutParam())); 1564 1565 /* 1566 * First special case 'none' to unmount 1567 */ 1568 if (!strcmp (fdaFile, "none")) 1569 { 1570 CHECK_ERROR_BREAK (drive, Unmount()); 1571 break; 1572 } 1573 1574 Bstr medium = fdaFile; 1575 bool done = false; 1576 1577 /* Assume it's a host drive name */ 1578 { 1557 ComPtr<IMedium> floppyMedium; 1558 1559 /* unmount? */ 1560 if (!strcmp(fdaFile, "none")) 1561 { 1562 /* nothing to do, NULL object will cause unmount */ 1563 } 1564 else 1565 { 1566 Bstr medium = fdaFile; 1567 1568 /* Assume it's a host drive name */ 1579 1569 ComPtr <IHost> host; 1580 CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host)(host.asOutParam())); 1581 com::SafeIfaceArray <IHostFloppyDrive> coll; 1582 CHECK_ERROR_BREAK (host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll))); 1583 ComPtr <IHostFloppyDrive> hostDrive; 1584 rc = host->FindHostFloppyDrive (medium, hostDrive.asOutParam()); 1585 if (SUCCEEDED (rc)) 1586 { 1587 done = true; 1588 CHECK_ERROR_BREAK (drive, CaptureHostDrive (hostDrive)); 1589 } 1590 } 1591 1592 /* Must be an image */ 1593 if (!done) 1594 { 1595 /* try to find an existing one */ 1596 ComPtr<IFloppyImage> image; 1597 rc = virtualBox->FindFloppyImage (medium, image.asOutParam()); 1598 if (FAILED (rc)) 1599 { 1600 /* try to add to the list */ 1601 RTPrintf ("Adding floppy image '%S'...\n", fdaFile); 1602 CHECK_ERROR_BREAK (virtualBox, OpenFloppyImage (medium, Bstr(), 1603 image.asOutParam())); 1604 } 1605 1606 /* attach */ 1607 Bstr uuid; 1608 image->COMGETTER(Id)(uuid.asOutParam()); 1609 CHECK_ERROR_BREAK (drive, MountImage (uuid)); 1610 } 1570 CHECK_ERROR_BREAK(virtualBox, COMGETTER(Host)(host.asOutParam())); 1571 rc = host->FindHostFloppyDrive(medium, floppyMedium.asOutParam()); 1572 if (FAILED(rc)) 1573 { 1574 /* try to find an existing one */ 1575 rc = virtualBox->FindFloppyImage(medium, floppyMedium.asOutParam()); 1576 if (FAILED(rc)) 1577 { 1578 /* try to add to the list */ 1579 RTPrintf("Adding floppy image '%S'...\n", fdaFile); 1580 CHECK_ERROR_BREAK(virtualBox, OpenFloppyImage(medium, Bstr(), 1581 floppyMedium.asOutParam())); 1582 } 1583 } 1584 } 1585 Bstr id; 1586 floppyMedium->COMGETTER(Id)(id.asOutParam()); 1587 CHECK_ERROR(gMachine, MountMedium(Bstr("FD"), 0, 0, id)); 1611 1588 } 1612 1589 while (0); 1613 if (FAILED 1590 if (FAILED(rc)) 1614 1591 goto leave; 1615 1592 … … 1620 1597 do 1621 1598 { 1622 ComPtr<IDVDDrive> drive; 1623 CHECK_ERROR_BREAK (gMachine, COMGETTER(DVDDrive)(drive.asOutParam())); 1624 1625 /* 1626 * First special case 'none' to unmount 1627 */ 1628 if (!strcmp (cdromFile, "none")) 1629 { 1630 CHECK_ERROR_BREAK (drive, Unmount()); 1631 break; 1632 } 1633 1634 Bstr medium = cdromFile; 1635 bool done = false; 1636 1637 /* Assume it's a host drive name */ 1638 { 1599 ComPtr<IMedium> dvdMedium; 1600 1601 /* unmount? */ 1602 if (!strcmp(cdromFile, "none")) 1603 { 1604 /* nothing to do, NULL object will cause unmount */ 1605 } 1606 else 1607 { 1608 Bstr medium = cdromFile; 1609 1610 /* Assume it's a host drive name */ 1639 1611 ComPtr <IHost> host; 1640 CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host)(host.asOutParam())); 1641 SafeIfaceArray <IHostDVDDrive> coll; 1642 CHECK_ERROR_BREAK (host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll))); 1643 ComPtr <IHostDVDDrive> hostDrive; 1644 rc = host->FindHostDVDDrive (medium, hostDrive.asOutParam()); 1645 if (SUCCEEDED (rc)) 1646 { 1647 done = true; 1648 CHECK_ERROR_BREAK (drive, CaptureHostDrive (hostDrive)); 1649 } 1650 } 1651 1652 /* Must be an image */ 1653 if (!done) 1654 { 1655 /* try to find an existing one */ 1656 ComPtr <IDVDImage> image; 1657 rc = virtualBox->FindDVDImage (medium, image.asOutParam()); 1658 if (FAILED (rc)) 1659 { 1660 /* try to add to the list */ 1661 RTPrintf ("Adding ISO image '%S'...\n", cdromFile); 1662 CHECK_ERROR_BREAK (virtualBox, OpenDVDImage (medium, Bstr(), 1663 image.asOutParam())); 1664 } 1665 1666 /* attach */ 1667 Bstr uuid; 1668 image->COMGETTER(Id)(uuid.asOutParam()); 1669 CHECK_ERROR_BREAK (drive, MountImage (uuid)); 1670 } 1612 CHECK_ERROR_BREAK(virtualBox, COMGETTER(Host)(host.asOutParam())); 1613 rc = host->FindHostDVDDrive(medium,dvdMedium.asOutParam()); 1614 if (FAILED(rc)) 1615 { 1616 /* try to find an existing one */ 1617 rc = virtualBox->FindDVDImage(medium, dvdMedium.asOutParam()); 1618 if (FAILED(rc)) 1619 { 1620 /* try to add to the list */ 1621 RTPrintf("Adding ISO image '%S'...\n", cdromFile); 1622 CHECK_ERROR_BREAK(virtualBox, OpenDVDImage(medium, Bstr(), 1623 dvdMedium.asOutParam())); 1624 } 1625 } 1626 } 1627 Bstr id; 1628 dvdMedium->COMGETTER(Id)(id.asOutParam()); 1629 CHECK_ERROR(gMachine, MountMedium(Bstr("IDE"), 1, 0, id)); 1671 1630 } 1672 1631 while (0); 1673 if (FAILED 1632 if (FAILED(rc)) 1674 1633 goto leave; 1675 1634 -
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r22911 r23223 52 52 print "%s: onAdditionsStateChange" %(self.mach.name) 53 53 54 def onDVDDriveChange(self):55 print "%s: onDVDDriveChange" %(self.mach.name)56 57 def onFloppyDriveChange(self):58 print "%s: onFloppyDriveChange" %(self.mach.name)59 60 54 def onNetworkAdapterChange(self, adapter): 61 55 print "%s: onNetworkAdapterChange" %(self.mach.name) … … 69 63 def onStorageControllerChange(self): 70 64 print "%s: onStorageControllerChange" %(self.mach.name) 65 66 def onMediumChange(self, attachment): 67 print "%s: onMediumChange" %(self.mach.name) 71 68 72 69 def onVRDPServerChange(self): -
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r22960 r23223 273 273 include/QIFileDialog.h \ 274 274 include/QIAdvancedSlider.h \ 275 include/QISplitter.h \ 276 include/QITreeView.h \ 275 277 include/VBoxFilePathSelectorWidget.h \ 276 278 include/VBoxOSTypeSelectorButton.h \ … … 307 309 include/VBoxVMSettingsDisplay.h \ 308 310 include/VBoxVMSettingsHD.h \ 309 include/VBoxVMSettingsCD.h \310 include/VBoxVMSettingsFD.h \311 311 include/VBoxVMSettingsAudio.h \ 312 312 include/VBoxVMSettingsNetwork.h \ … … 371 371 src/QILineEdit.cpp \ 372 372 src/QIHelpButton.cpp \ 373 src/QISplitter.cpp \ 374 src/QITreeView.cpp \ 373 375 src/VBoxGuestRAMSlider.cpp \ 374 376 src/VBoxFilePathSelectorWidget.cpp \ … … 406 408 src/VBoxVMSettingsDisplay.cpp \ 407 409 src/VBoxVMSettingsHD.cpp \ 408 src/VBoxVMSettingsCD.cpp \409 src/VBoxVMSettingsFD.cpp \410 410 src/VBoxVMSettingsAudio.cpp \ 411 411 src/VBoxVMSettingsNetwork.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
r23081 r23223 43 43 ui/VBoxVMSettingsDisplay.ui \ 44 44 ui/VBoxVMSettingsHD.ui \ 45 ui/VBoxVMSettingsCD.ui \46 ui/VBoxVMSettingsFD.ui \47 45 ui/VBoxVMSettingsAudio.ui \ 48 46 ui/VBoxVMSettingsNetwork.ui \ -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox.qrc
r20393 r23223 343 343 <file alias="restore_16px.png">images/restore_16px.png</file> 344 344 <file alias="close_16px.png">images/close_16px.png</file> 345 <file alias="plus_10px.png">images/plus_10px.png</file> 346 <file alias="plus_disabled_10px.png">images/plus_disabled_10px.png</file> 347 <file alias="minus_10px.png">images/minus_10px.png</file> 348 <file alias="minus_disabled_10px.png">images/minus_disabled_10px.png</file> 345 349 </qresource> 346 350 </RCC> -
trunk/src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl
r17808 r23223 224 224 <!-- forward declarations --> 225 225 <xsl:text>// forward declarations

</xsl:text> 226 <xsl:for-each select="interface | collection | enumerator">226 <xsl:for-each select="interface"> 227 227 <xsl:text>class C</xsl:text> 228 228 <xsl:value-of select="substring(@name,2)"/> … … 250 250 <xsl:apply-templates select=" 251 251 if | 252 interface[not(@internal='yes')] | 253 collection[not(@internal='yes')] | 254 enumerator[not(@internal='yes')] 252 interface[not(@internal='yes')] 255 253 " 256 254 mode="declare" … … 260 258 <xsl:apply-templates select=" 261 259 if | 262 interface[not(@internal='yes')] | 263 collection[not(@internal='yes')] | 264 enumerator[not(@internal='yes')] 260 interface[not(@internal='yes')] 265 261 " 266 262 mode="define" … … 272 268 * interface declarations 273 269 --> 274 <xsl:template match="interface | collection | enumerator" mode="declare">270 <xsl:template match="interface" mode="declare"> 275 271 276 272 <xsl:text>// </xsl:text> … … 295 291 <xsl:text>> Base;

</xsl:text> 296 292 297 <xsl:if test="name()='collection'"> 298 <xsl:text> // collection stuff

</xsl:text> 299 <xsl:text> ULONG GetCount () const;
</xsl:text> 300 <xsl:text> </xsl:text> 301 <xsl:apply-templates select="@type"/> 302 <xsl:text> GetItemAt (ULONG index) const;
</xsl:text> 303 <xsl:text> </xsl:text> 304 <xsl:apply-templates select="@enumerator"/> 305 <xsl:text> Enumerate () const;

</xsl:text> 306 </xsl:if> 307 308 <xsl:if test="name()='enumerator'"> 309 <xsl:text> // enumerator stuff

</xsl:text> 310 <xsl:text> BOOL HasMore () const;
</xsl:text> 311 <xsl:text> </xsl:text> 312 <xsl:apply-templates select="@type"/> 313 <xsl:text> GetNext () const;

</xsl:text> 314 <xsl:text> // friend wrappers

</xsl:text> 315 <xsl:text> friend class CUnknown;
</xsl:text> 316 <xsl:variable name="name" select="@name"/> 317 <xsl:variable name="parent" select=".."/> 318 <!-- for definitions inside <if> --> 319 <xsl:if test="name(..)='if'"> 320 <xsl:for-each select=" 321 preceding-sibling::collection | following-sibling::collection | 322 ../preceding-sibling::if[@target=$parent/@target]/collection | 323 ../following-sibling::if[@target=$parent/@target]/collection 324 "> 325 <xsl:if test="@enumerator=$name"> 326 <xsl:text> friend class C</xsl:text> 327 <xsl:value-of select="substring(@name,2)"/> 328 <xsl:text>;
</xsl:text> 329 </xsl:if> 330 </xsl:for-each> 331 </xsl:if> 332 <!-- for definitions outside <if> (i.e. inside <library>) --> 333 <xsl:if test="name(..)!='if'"> 334 <xsl:for-each select=" 335 preceding-sibling::collection | following-sibling::collection 336 "> 337 <xsl:if test="@enumerator=$name"> 338 <xsl:text> friend class C</xsl:text> 339 <xsl:value-of select="substring(@name,2)"/> 340 <xsl:text>;
</xsl:text> 341 </xsl:if> 342 </xsl:for-each> 343 </xsl:if> 344 </xsl:if> 345 346 <xsl:if test="name()='interface' or name()='collection'"> 293 <xsl:if test="name()='interface'"> 347 294 <xsl:call-template name="declareMembers"/> 348 295 </xsl:if> … … 368 315 <xsl:with-param name="iface" select=" 369 316 preceding-sibling:: 370 *[ (self::interface or self::collection)and @name=$iface/@extends] |317 *[self::interface and @name=$iface/@extends] | 371 318 following-sibling:: 372 *[ (self::interface or self::collection)and @name=$iface/@extends] |319 *[self::interface and @name=$iface/@extends] | 373 320 ../preceding-sibling::if[@target=../@target]/ 374 *[ (self::interface or self::collection)and @name=$iface/@extends] |321 *[self::interface and @name=$iface/@extends] | 375 322 ../following-sibling::if[@target=../@target]/ 376 *[ (self::interface or self::collection)and @name=$iface/@extends]323 *[self::interface and @name=$iface/@extends] 377 324 "/> 378 325 </xsl:call-template> … … 383 330 <xsl:with-param name="iface" select=" 384 331 preceding-sibling:: 385 *[ (self::interface or self::collection)and @name=$iface/@extends] |332 *[self::interface and @name=$iface/@extends] | 386 333 following-sibling:: 387 *[ (self::interface or self::collection)and @name=$iface/@extends]334 *[self::interface and @name=$iface/@extends] 388 335 "/> 389 336 </xsl:call-template> … … 410 357 <xsl:with-param name="iface" select=" 411 358 preceding-sibling:: 412 *[ (self::interface or self::collection)and @name=$iface/@extends] |359 *[self::interface and @name=$iface/@extends] | 413 360 following-sibling:: 414 *[ (self::interface or self::collection)and @name=$iface/@extends] |361 *[self::interface and @name=$iface/@extends] | 415 362 ../preceding-sibling::if[@target=../@target]/ 416 *[ (self::interface or self::collection)and @name=$iface/@extends] |363 *[self::interface and @name=$iface/@extends] | 417 364 ../following-sibling::if[@target=../@target]/ 418 *[ (self::interface or self::collection)and @name=$iface/@extends]365 *[self::interface and @name=$iface/@extends] 419 366 "/> 420 367 </xsl:call-template> … … 425 372 <xsl:with-param name="iface" select=" 426 373 preceding-sibling:: 427 *[ (self::interface or self::collection)and @name=$iface/@extends] |374 *[self::interface and @name=$iface/@extends] | 428 375 following-sibling:: 429 *[ (self::interface or self::collection)and @name=$iface/@extends]376 *[self::interface and @name=$iface/@extends] 430 377 "/> 431 378 </xsl:call-template> … … 541 488 <xsl:if test="name(..)='if'"> 542 489 <xsl:for-each select=" 543 preceding-sibling::*[self::interface or self::collection or self::enumerator] |544 following-sibling::*[self::interface or self::collection or self::enumerator] |545 ../preceding-sibling::*[self::interface or self::collection or self::enumerator] |546 ../following-sibling::*[self::interface or self::collection or self::enumerator] |547 ../preceding-sibling::if[@target=$parent/@target]/*[self::interface or self::collection or self::enumerator] |548 ../following-sibling::if[@target=$parent/@target]/*[self::interface or self::collection or self::enumerator]490 preceding-sibling::*[self::interface] | 491 following-sibling::*[self::interface] | 492 ../preceding-sibling::*[self::interface] | 493 ../following-sibling::*[self::interface] | 494 ../preceding-sibling::if[@target=$parent/@target]/*[self::interface] | 495 ../following-sibling::if[@target=$parent/@target]/*[self::interface] 549 496 "> 550 497 <xsl:if test=" 551 ((name()='interface' or name()='collection')498 ((name()='interface') 552 499 and 553 500 ((name(..)!='if' and (if[@target=$parent/@target]/method/param[@type=$name] … … 556 503 or 557 504 (.//method/param[@type=$name] or attribute[@type=$name]))) 558 or559 (name(..)='if' and (name()='collection' or name()='enumerator') and @type=$name)560 505 "> 561 506 <xsl:text> friend class C</xsl:text> … … 568 513 <xsl:if test="name(..)!='if'"> 569 514 <xsl:for-each select=" 570 preceding-sibling::*[self::interface or self::collection or self::enumerator] |571 following-sibling::*[self::interface or self::collection or self::enumerator] |572 preceding-sibling::if/*[self::interface or self::collection or self::enumerator] |573 following-sibling::if/*[self::interface or self::collection or self::enumerator]515 preceding-sibling::*[self::interface] | 516 following-sibling::*[self::interface] | 517 preceding-sibling::if/*[self::interface] | 518 following-sibling::if/*[self::interface] 574 519 "> 575 520 <xsl:if test=" 576 ((name()='interface' or name()='collection') 577 and 578 (.//method/param[@type=$name] or attribute[@type=$name])) 579 or 580 ((name()='collection' or name()='enumerator') and @type=$name) 521 name()='interface' and (.//method/param[@type=$name] or attribute[@type=$name]) 581 522 "> 582 523 <xsl:text> friend class C</xsl:text> … … 590 531 591 532 <!-- attribute declarations --> 592 <xsl:template match="interface//attribute | collection//attribute" mode="declare"> 593 <xsl:if test="@array"> 594 <xsl:message terminate="yes"> 595 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/> 596 <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text> 597 </xsl:message> 598 </xsl:if> 533 <xsl:template match="interface//attribute" mode="declare"> 599 534 <xsl:apply-templates select="parent::node()" mode="begin"/> 600 535 <xsl:apply-templates select="@if" mode="begin"/> … … 612 547 613 548 <!-- method declarations --> 614 <xsl:template match="interface//method | collection//method" mode="declare">549 <xsl:template match="interface//method" mode="declare"> 615 550 <xsl:apply-templates select="parent::node()" mode="begin"/> 616 551 <xsl:apply-templates select="@if" mode="begin"/> … … 624 559 * interface definitions 625 560 --> 626 <xsl:template match="interface | collection | enumerator" mode="define">561 <xsl:template match="interface" mode="define"> 627 562 628 563 <xsl:text>// </xsl:text> … … 630 565 <xsl:text> wrapper

</xsl:text> 631 566 632 <xsl:if test="name()='collection'"> 633 <!-- GetCount --> 634 <xsl:text>inline ULONG C</xsl:text> 635 <xsl:value-of select="substring(@name,2)"/> 636 <xsl:text>::GetCount () const
{
</xsl:text> 637 <xsl:text> ULONG count = 0;
</xsl:text> 638 <xsl:text> Assert (mIface);
</xsl:text> 639 <xsl:text> if (!mIface)
 return count;
</xsl:text> 640 <xsl:text> mRC = mIface->COMGETTER(Count) (&count);
</xsl:text> 641 <xsl:call-template name="tryComposeFetchErrorInfo"/> 642 <xsl:text> return count;
</xsl:text> 643 <xsl:text>}

</xsl:text> 644 <!-- GetItemAt --> 645 <xsl:text>inline </xsl:text> 646 <xsl:apply-templates select="@type"/> 647 <xsl:text> C</xsl:text> 648 <xsl:value-of select="substring(@name,2)"/> 649 <xsl:text>::GetItemAt (ULONG index) const
{
</xsl:text> 650 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/> 651 <xsl:text> item;
</xsl:text> 652 <xsl:text> Assert (mIface);
</xsl:text> 653 <xsl:text> if (!mIface)
 return item;
</xsl:text> 654 <xsl:text> mRC = mIface->GetItemAt (index, &item.mIface);
</xsl:text> 655 <xsl:call-template name="tryComposeFetchErrorInfo"/> 656 <xsl:text> return item;
</xsl:text> 657 <xsl:text>}

</xsl:text> 658 <!-- Enumerate --> 659 <xsl:text>inline </xsl:text> 660 <xsl:apply-templates select="@enumerator"/> 661 <xsl:text> C</xsl:text> 662 <xsl:value-of select="substring(@name,2)"/> 663 <xsl:text>::Enumerate () const
{
</xsl:text> 664 <xsl:text> </xsl:text><xsl:apply-templates select="@enumerator"/> 665 <xsl:text> enumerator;
</xsl:text> 666 <xsl:text> Assert (mIface);
</xsl:text> 667 <xsl:text> if (!mIface)
 return enumerator;
</xsl:text> 668 <xsl:text> mRC = mIface->Enumerate (&enumerator.mIface);
</xsl:text> 669 <xsl:call-template name="tryComposeFetchErrorInfo"/> 670 <xsl:text> return enumerator;
</xsl:text> 671 <xsl:text>}

</xsl:text> 672 </xsl:if> 673 674 <xsl:if test="name()='enumerator'"> 675 <!-- HasMore --> 676 <xsl:text>inline BOOL C</xsl:text> 677 <xsl:value-of select="substring(@name,2)"/> 678 <xsl:text>::HasMore () const
{
</xsl:text> 679 <xsl:text> BOOL more = FALSE;
</xsl:text> 680 <xsl:text> Assert (mIface);
</xsl:text> 681 <xsl:text> if (!mIface)
 return more;
</xsl:text> 682 <xsl:text> mRC = mIface->HasMore (&more);
</xsl:text> 683 <xsl:call-template name="tryComposeFetchErrorInfo"/> 684 <xsl:text> return more;
</xsl:text> 685 <xsl:text>}

</xsl:text> 686 <!-- GetNext --> 687 <xsl:text>inline </xsl:text> 688 <xsl:apply-templates select="@type"/> 689 <xsl:text> C</xsl:text> 690 <xsl:value-of select="substring(@name,2)"/> 691 <xsl:text>::GetNext () const
{
</xsl:text> 692 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/> 693 <xsl:text> next;
</xsl:text> 694 <xsl:text> Assert (mIface);
</xsl:text> 695 <xsl:text> if (!mIface)
 return next;
</xsl:text> 696 <xsl:text> mRC = mIface->GetNext (&next.mIface);
</xsl:text> 697 <xsl:call-template name="tryComposeFetchErrorInfo"/> 698 <xsl:text> return next;
</xsl:text> 699 <xsl:text>}

</xsl:text> 700 </xsl:if> 701 702 <xsl:if test="name()='interface' or name()='collection'"> 567 <xsl:if test="name()='interface'"> 703 568 <xsl:call-template name="defineMembers"/> 704 569 </xsl:if> … … 722 587 <xsl:with-param name="iface" select=" 723 588 preceding-sibling:: 724 *[ (self::interface or self::collection)and @name=$iface/@extends] |589 *[self::interface and @name=$iface/@extends] | 725 590 following-sibling:: 726 *[ (self::interface or self::collection)and @name=$iface/@extends] |591 *[self::interface and @name=$iface/@extends] | 727 592 ../preceding-sibling::if[@target=../@target]/ 728 *[ (self::interface or self::collection)and @name=$iface/@extends] |593 *[self::interface and @name=$iface/@extends] | 729 594 ../following-sibling::if[@target=../@target]/ 730 *[ (self::interface or self::collection)and @name=$iface/@extends]595 *[self::interface and @name=$iface/@extends] 731 596 "/> 732 597 </xsl:call-template> … … 737 602 <xsl:with-param name="iface" select=" 738 603 preceding-sibling:: 739 *[ (self::interface or self::collection)and @name=$iface/@extends] |604 *[self::interface and @name=$iface/@extends] | 740 605 following-sibling:: 741 *[ (self::interface or self::collection)and @name=$iface/@extends]606 *[self::interface and @name=$iface/@extends] 742 607 "/> 743 608 </xsl:call-template> … … 764 629 <xsl:with-param name="iface" select=" 765 630 preceding-sibling:: 766 *[ (self::interface or self::collection)and @name=$iface/@extends] |631 *[self::interface and @name=$iface/@extends] | 767 632 following-sibling:: 768 *[ (self::interface or self::collection)and @name=$iface/@extends] |633 *[self::interface and @name=$iface/@extends] | 769 634 ../preceding-sibling::if[@target=../@target]/ 770 *[ (self::interface or self::collection)and @name=$iface/@extends] |635 *[self::interface and @name=$iface/@extends] | 771 636 ../following-sibling::if[@target=../@target]/ 772 *[ (self::interface or self::collection)and @name=$iface/@extends]637 *[self::interface and @name=$iface/@extends] 773 638 "/> 774 639 </xsl:call-template> … … 779 644 <xsl:with-param name="iface" select=" 780 645 preceding-sibling:: 781 *[ (self::interface or self::collection)and @name=$iface/@extends] |646 *[self::interface and @name=$iface/@extends] | 782 647 following-sibling:: 783 *[ (self::interface or self::collection)and @name=$iface/@extends]648 *[self::interface and @name=$iface/@extends] 784 649 "/> 785 650 </xsl:call-template> … … 800 665 801 666 <!-- attribute definitions --> 802 <xsl:template match="interface//attribute | collection//attribute" mode="define">803 804 <xsl:param name="namespace" select=" (ancestor::interface | ancestor::collection)[1]"/>667 <xsl:template match="interface//attribute" mode="define"> 668 669 <xsl:param name="namespace" select="ancestor::interface[1]"/> 805 670 806 671 <xsl:apply-templates select="parent::node()" mode="begin"/> … … 825 690 826 691 <!-- method definitions --> 827 <xsl:template match="interface//method | collection//method" mode="define">828 829 <xsl:param name="namespace" select=" (ancestor::interface | ancestor::collection)[1]"/>692 <xsl:template match="interface//method" mode="define"> 693 694 <xsl:param name="namespace" select="ancestor::interface[1]"/> 830 695 831 696 <xsl:apply-templates select="parent::node()" mode="begin"/> … … 869 734 * actual interface node for which this method is being defined 870 735 * (necessary to properly set a class name for inherited methods). 871 * If not specified, will default to the parent interface /collection736 * If not specified, will default to the parent interface 872 737 * node of the method being defined. 873 738 --> … … 875 740 <xsl:param name="return" select="param[@dir='return']"/> 876 741 <xsl:param name="define" select="''"/> 877 <xsl:param name="namespace" select=" (ancestor::interface | ancestor::collection)[1]"/>742 <xsl:param name="namespace" select="ancestor::interface[1]"/> 878 743 <xsl:choose> 879 744 <!-- no return value --> … … 1111 976 * appropriate base class name that provides error info functionality 1112 977 * (depending on the mode parameter). Does nothing if the current 1113 * entity (interface, collection or enumerator)does not support error info.978 * interface does not support error info. 1114 979 * 1115 980 * @param mode … … 1120 985 <xsl:param name="mode" select="''"/> 1121 986 <xsl:variable name="ifaceSupportsErrorInfo" select=" 1122 (ancestor-or-self::interface | 1123 ancestor-or-self::collection | 1124 ancestor-or-self::enumerator)[1]/@supportsErrorInfo 987 ancestor-or-self::interface[1]/@supportsErrorInfo 1125 988 "/> 1126 989 <xsl:variable name="librarySupportsErrorInfo" select="ancestor::library/@supportsErrorInfo"/> … … 1188 1051 </xsl:when> 1189 1052 <!-- string types --> 1190 <xsl:when test="@type = 'wstring' ">1053 <xsl:when test="@type = 'wstring' or @type = 'uuid'"> 1191 1054 <xsl:choose> 1192 1055 <xsl:when test="$isIn"> … … 1199 1062 <xsl:when test="$isOut"> 1200 1063 <xsl:text>BSTROut (a</xsl:text> 1201 <xsl:call-template name="capitalize">1202 <xsl:with-param name="str" select="@name"/>1203 </xsl:call-template>1204 <xsl:text>)</xsl:text>1205 </xsl:when>1206 </xsl:choose>1207 </xsl:when>1208 <!-- uuid type -->1209 <xsl:when test="@type = 'uuid'">1210 <xsl:choose>1211 <xsl:when test="$isIn">1212 <xsl:text>GUIDIn (a</xsl:text>1213 <xsl:call-template name="capitalize">1214 <xsl:with-param name="str" select="@name"/>1215 </xsl:call-template>1216 <xsl:text>)</xsl:text>1217 </xsl:when>1218 <xsl:when test="$isOut">1219 <xsl:text>GUIDOut (a</xsl:text>1220 1064 <xsl:call-template name="capitalize"> 1221 1065 <xsl:with-param name="str" select="@name"/> … … 1255 1099 <xsl:when test=" 1256 1100 @type='$unknown' or 1257 ((ancestor::library/enumerator[@name=current()/@type]) or1258 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()/@type])1259 ) or1260 1101 ((ancestor::library/interface[@name=current()/@type]) or 1261 1102 (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type]) 1262 ) or1263 ((ancestor::library/collection[@name=current()/@type]) or1264 (ancestor::library/if[@target=$self_target]/collection[@name=current()/@type])1265 1103 ) 1266 1104 "> … … 1328 1166 * attribute/parameter type conversion (returns plain Qt type name) 1329 1167 --> 1330 <xsl:template match=" 1331 attribute/@type | param/@type | 1332 enumerator/@type | collection/@type | collection/@enumerator 1333 "> 1168 <xsl:template match="attribute/@type | param/@type"> 1334 1169 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/> 1335 1170 1336 <xsl:if test="../@array and ../@safearray='yes'">1337 <xsl:message terminate="yes">1338 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>1339 <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>1340 </xsl:message>1341 </xsl:if>1342 1343 <xsl:if test="../@array and ((name(..)='param' and ../@dir='return') or (name(..)='attribute'))">1344 <xsl:message terminate="yes">1345 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>1346 <xsl:text>return 'array' parameters and 'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>1347 </xsl:message>1348 </xsl:if>1349 1350 1171 <xsl:choose> 1351 <!-- modifiers (ignored for 'enumeration' attributes)-->1172 <!-- modifiers --> 1352 1173 <xsl:when test="name(current())='type' and ../@mod"> 1353 <xsl:if test="../@safearray ">1174 <xsl:if test="../@safearray and ../@mod='ptr'"> 1354 1175 <xsl:message terminate="yes"> 1355 1176 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1356 1177 <xsl:text>either 'safearray' or 'mod' attribute is allowed, but not both!</xsl:text> 1357 </xsl:message>1358 </xsl:if>1359 <xsl:if test="../@array">1360 <xsl:message terminate="yes">1361 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>1362 <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>1363 1178 </xsl:message> 1364 1179 </xsl:if> … … 1376 1191 <xsl:when test=".='unsigned long'">ULONG *</xsl:when> 1377 1192 <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when> 1378 <xsl:when test=".='char'">CHAR *</xsl:when>1379 <!--<xsl:when test=".='string'">??</xsl:when-->1380 <xsl:when test=".='wchar'">OLECHAR *</xsl:when>1381 <!--<xsl:when test=".='wstring'">??</xsl:when-->1382 1193 <xsl:otherwise> 1383 1194 <xsl:message terminate="yes"> … … 1390 1201 </xsl:otherwise> 1391 1202 </xsl:choose> 1203 </xsl:when> 1204 <xsl:when test="../@mod='string'"> 1205 <xsl:if test="../@safearray"> 1206 <xsl:text>QVector <</xsl:text> 1207 </xsl:if> 1208 <xsl:choose> 1209 <!-- standard types --> 1210 <!--xsl:when test=".='result'">??</xsl:when--> 1211 <xsl:when test=".='uuid'">QString</xsl:when> 1212 <xsl:otherwise> 1213 <xsl:message terminate="yes"> 1214 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1215 <xsl:text>attribute 'mod=</xsl:text> 1216 <xsl:value-of select="concat('"',../@mod,'"')"/> 1217 <xsl:text>' cannot be used with type </xsl:text> 1218 <xsl:value-of select="concat('"',current(),'"!')"/> 1219 </xsl:message> 1220 </xsl:otherwise> 1221 </xsl:choose> 1222 <xsl:if test="../@safearray"> 1223 <xsl:text>></xsl:text> 1224 </xsl:if> 1392 1225 </xsl:when> 1393 1226 <xsl:otherwise> … … 1435 1268 <!-- custom interface types --> 1436 1269 <xsl:when test=" 1437 (name(current())='enumerator' and1438 ((ancestor::library/enumerator[@name=current()]) or1439 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))1440 ) or1441 1270 ((ancestor::library/interface[@name=current()]) or 1442 1271 (ancestor::library/if[@target=$self_target]/interface[@name=current()]) 1443 ) or1444 ((ancestor::library/collection[@name=current()]) or1445 (ancestor::library/if[@target=$self_target]/collection[@name=current()])1446 1272 ) 1447 1273 "> … … 1471 1297 * types. 1472 1298 --> 1473 <xsl:template match=" 1474 attribute/@type | param/@type | 1475 enumerator/@type | collection/@type | collection/@enumerator 1476 " mode="initializer"> 1299 <xsl:template match="attribute/@type | param/@type" mode="initializer"> 1477 1300 1478 1301 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/> … … 1482 1305 <xsl:when test="../@safearray"> 1483 1306 </xsl:when> 1484 <!-- modifiers (ignored for 'enumeration' attributes)-->1307 <!-- modifiers --> 1485 1308 <xsl:when test="name(current())='type' and ../@mod"> 1486 1309 <xsl:choose> … … 1497 1320 <xsl:when test=".='unsigned long'"> = NULL</xsl:when> 1498 1321 <xsl:when test=".='unsigned long long'"> = NULL</xsl:when> 1499 <xsl:when test=".='char'"> = NULL</xsl:when> 1500 <!--<xsl:when test=".='string'">??</xsl:when--> 1501 <xsl:when test=".='wchar'"> = NULL</xsl:when> 1502 <!--<xsl:when test=".='wstring'">??</xsl:when--> 1322 <xsl:otherwise> 1323 <xsl:message terminate="yes"> 1324 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1325 <xsl:text>attribute 'mod=</xsl:text> 1326 <xsl:value-of select="concat('"',../@mod,'"')"/> 1327 <xsl:text>' cannot be used with type </xsl:text> 1328 <xsl:value-of select="concat('"',current(),'"!')"/> 1329 </xsl:message> 1330 </xsl:otherwise> 1331 </xsl:choose> 1332 </xsl:when> 1333 <xsl:when test="../@mod='string'"> 1334 <xsl:choose> 1335 <!-- standard types --> 1336 <!--xsl:when test=".='result'">??</xsl:when--> 1337 <xsl:when test=".='uuid'"></xsl:when> 1503 1338 <xsl:otherwise> 1504 1339 <xsl:message terminate="yes"> … … 1571 1406 ) or 1572 1407 .='$unknown' or 1573 ((ancestor::library/enumerator[@name=current()]) or1574 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()])1575 ) or1576 1408 ((ancestor::library/interface[@name=current()]) or 1577 1409 (ancestor::library/if[@target=$self_target]/interface[@name=current()]) 1578 ) or1579 ((ancestor::library/collection[@name=current()]) or1580 (ancestor::library/if[@target=$self_target]/collection[@name=current()])1581 1410 ) 1582 1411 "> … … 1616 1445 <!-- <param> context --> 1617 1446 <xsl:when test="name(..)='param'"> 1618 <xsl:choose> 1619 <xsl:when test="../@array"> 1620 <xsl:apply-templates select="."/> 1621 <xsl:text> *</xsl:text> 1622 <xsl:if test="../@dir='out'"> 1623 <xsl:text> &</xsl:text> 1624 </xsl:if> 1625 </xsl:when> 1626 <xsl:otherwise> 1627 <xsl:apply-templates select="."/> 1628 <xsl:if test="../@dir='out'"> 1629 <xsl:text> &</xsl:text> 1630 </xsl:if> 1631 </xsl:otherwise> 1632 </xsl:choose> 1447 <xsl:apply-templates select="."/> 1448 <xsl:if test="../@dir='out'"> 1449 <xsl:text> &</xsl:text> 1450 </xsl:if> 1633 1451 </xsl:when> 1634 1452 </xsl:choose> … … 1642 1460 * (basically, copied from midl.xsl) 1643 1461 --> 1644 <xsl:template match=" 1645 attribute/@type | param/@type | 1646 enumerator/@type | collection/@type | collection/@enumerator 1647 " mode="com"> 1462 <xsl:template match="attribute/@type | param/@type" mode="com"> 1648 1463 1649 1464 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/> 1650 1465 1651 1466 <xsl:choose> 1652 <!-- modifiers (ignored for 'enumeration' attributes)-->1467 <!-- modifiers --> 1653 1468 <xsl:when test="name(current())='type' and ../@mod"> 1654 1469 <xsl:choose> … … 1665 1480 <xsl:when test=".='unsigned long'">ULONG *</xsl:when> 1666 1481 <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when> 1667 <xsl:when test=".='char'">CHAR *</xsl:when> 1668 <!--xsl:when test=".='string'">??</xsl:when--> 1669 <xsl:when test=".='wchar'">OLECHAR *</xsl:when> 1670 <!--xsl:when test=".='wstring'">??</xsl:when--> 1482 <xsl:otherwise> 1483 <xsl:message terminate="yes"> 1484 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1485 <xsl:text>attribute 'mod=</xsl:text> 1486 <xsl:value-of select="concat('"',../@mod,'"')"/> 1487 <xsl:text>' cannot be used with type </xsl:text> 1488 <xsl:value-of select="concat('"',current(),'"!')"/> 1489 </xsl:message> 1490 </xsl:otherwise> 1491 </xsl:choose> 1492 </xsl:when> 1493 <xsl:when test="../@mod='string'"> 1494 <xsl:choose> 1495 <!-- standard types --> 1496 <!--xsl:when test=".='result'">??</xsl:when--> 1497 <xsl:when test=".='uuid'">BSTR</xsl:when> 1671 1498 <xsl:otherwise> 1672 1499 <xsl:message terminate="yes"> … … 1721 1548 <!-- custom interface types --> 1722 1549 <xsl:when test=" 1723 (name(current())='enumerator' and1724 ((ancestor::library/enumerator[@name=current()]) or1725 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))1726 ) or1727 1550 ((ancestor::library/interface[@name=current()]) or 1728 1551 (ancestor::library/if[@target=$self_target]/interface[@name=current()]) 1729 ) or1730 ((ancestor::library/collection[@name=current()]) or1731 (ancestor::library/if[@target=$self_target]/collection[@name=current()])1732 1552 ) 1733 1553 "> … … 1768 1588 1769 1589 <xsl:variable name="is_iface" select="( 1770 ((ancestor::library/enumerator[@name=current()/@type]) or1771 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()/@type])1772 ) or1773 1590 ((ancestor::library/interface[@name=current()/@type]) or 1774 1591 (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type]) 1775 ) or1776 ((ancestor::library/collection[@name=current()/@type]) or1777 (ancestor::library/if[@target=$self_target]/collection[@name=current()/@type])1778 1592 ) 1779 1593 )"/> … … 1806 1620 </xsl:when> 1807 1621 <!-- GUID is special too --> 1808 <xsl:when test="@type='uuid' ">1622 <xsl:when test="@type='uuid' and @mod!='string'"> 1809 1623 <xsl:text> com::SafeGUIDArray </xsl:text> 1810 1624 </xsl:when> -
trunk/src/VBox/Frontends/VirtualBox/include/QILabelSeparator.h
r14398 r23223 24 24 #define __QILabelSeparator_h__ 25 25 26 /* Qtincludes */26 /* Global includes */ 27 27 #include <QWidget> 28 28 29 /* Global forwards */ 29 30 class QLabel; 30 31 … … 35 36 public: 36 37 37 QILabelSeparator (QWidget *aParent = NULL, Qt::WindowFlags aFlags = 0);38 QILabelSeparator (const QString &aText, QWidget *aParent = NULL, Qt::WindowFlags aFlags = 0);38 QILabelSeparator (QWidget *aParent = 0, Qt::WindowFlags aFlags = 0); 39 QILabelSeparator (const QString &aText, QWidget *aParent = 0, Qt::WindowFlags aFlags = 0); 39 40 41 QString text() const; 40 42 void setBuddy (QWidget *aBuddy); 41 43 … … 44 46 void clear(); 45 47 void setText (const QString &aText); 46 QString text() const;47 48 48 49 protected: … … 50 51 virtual void init(); 51 52 52 /* Protected member vars */53 53 QLabel *mLabel; 54 54 }; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r22834 r23223 155 155 void machineStateChanged (KMachineState state); 156 156 void additionsStateChanged (const QString &, bool, bool, bool); 157 void mediaDriveChanged (VBoxDefs::Medi aType aType);157 void mediaDriveChanged (VBoxDefs::MediumType aType); 158 158 void networkStateChange(); 159 159 void usbStateChange(); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r23142 r23223 240 240 void updateNetworkAdaptersState(); 241 241 void updateUsbState(); 242 void updateMediaDriveState (VBoxDefs::Medi aType aType);242 void updateMediaDriveState (VBoxDefs::MediumType aType); 243 243 void updateSharedFoldersState(); 244 244 … … 358 358 bool no_auto_close : 1; 359 359 360 QMap <QAction *, C HostDVDDrive> hostDVDMap;361 QMap <QAction *, C HostFloppyDrive> hostFloppyMap;360 QMap <QAction *, CMedium> hostDVDMap; 361 QMap <QAction *, CMedium> hostFloppyMap; 362 362 363 363 QRect mNormalGeo; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r22816 r23223 69 69 struct VBoxDefs 70 70 { 71 /** Medi atype. */72 enum Medi aType71 /** Medium type. */ 72 enum MediumType 73 73 { 74 Medi aType_Invalid,75 Medi aType_HardDisk,76 Medi aType_DVD,77 Medi aType_Floppy,78 Medi aType_All74 MediumType_Invalid, 75 MediumType_HardDisk, 76 MediumType_DVD, 77 MediumType_Floppy, 78 MediumType_All 79 79 }; 80 80 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r22816 r23223 245 245 }; 246 246 247 struct StorageSlot 248 { 249 StorageSlot() : bus (KStorageBus_Null), port (0), device (0) {} 250 StorageSlot (const StorageSlot &aOther) : bus (aOther.bus), port (aOther.port), device (aOther.device) {} 251 StorageSlot (KStorageBus aBus, LONG aPort, LONG aDevice) : bus (aBus), port (aPort), device (aDevice) {} 252 StorageSlot& operator= (const StorageSlot &aOther) { bus = aOther.bus; port = aOther.port; device = aOther.device; return *this; } 253 bool operator== (const StorageSlot &aOther) const { return bus == aOther.bus && port == aOther.port && device == aOther.device; } 254 bool operator!= (const StorageSlot &aOther) const { return bus != aOther.bus || port != aOther.port || device != aOther.device; } 255 bool isNull() { return bus == KStorageBus_Null; } 256 KStorageBus bus; LONG port; LONG device; 257 }; 258 Q_DECLARE_METATYPE (StorageSlot); 259 247 260 // VBoxGlobal class 248 261 //////////////////////////////////////////////////////////////////////////////// … … 383 396 case KStorageControllerType_LsiLogic: 384 397 case KStorageControllerType_BusLogic: sb = KStorageBus_SCSI; break; 398 case KStorageControllerType_I82078: sb = KStorageBus_Floppy; break; 385 399 default: 386 400 AssertMsgFailed (("toStorageBusType: %d not handled\n", aControllerType)); break; … … 395 409 LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const; 396 410 397 QString toFullString (KStorageBus aBus, LONG aChannel, LONG aDevice) const; 398 399 QString toString (KHardDiskType t) const 411 QString toFullString (StorageSlot aSlot) const; 412 StorageSlot toStorageSlot (const QString &aSlot) const; 413 414 QString toString (KMediumType t) const 400 415 { 401 416 AssertMsg (!mDiskTypes.value (t).isNull(), ("No text for %d", t)); … … 404 419 405 420 /** 406 * Similar to toString (K HardDiskType), but returns 'Differencing' for421 * Similar to toString (KMediumType), but returns 'Differencing' for 407 422 * normal hard disks that have a parent. 408 423 */ 409 QString hardDiskTypeString (const CHardDisk&aHD) const424 QString mediumTypeString (const CMedium &aHD) const 410 425 { 411 426 if (!aHD.GetParent().isNull()) 412 427 { 413 Assert (aHD.GetType() == K HardDiskType_Normal);428 Assert (aHD.GetType() == KMediumType_Normal); 414 429 return mDiskTypes_Differencing; 415 430 } … … 456 471 } 457 472 458 KStorageControllerType to IDEControllerType (const QString &s) const473 KStorageControllerType toControllerType (const QString &s) const 459 474 { 460 475 QULongStringHash::const_iterator it = … … 593 608 /* details generators */ 594 609 595 QString details (const C HardDisk&aHD, bool aPredictDiff);610 QString details (const CMedium &aHD, bool aPredictDiff); 596 611 597 612 QString details (const CUSBDevice &aDevice) const; … … 635 650 void addMedium (const VBoxMedium &); 636 651 void updateMedium (const VBoxMedium &); 637 void removeMedium (VBoxDefs::Medi aType, const QString &);652 void removeMedium (VBoxDefs::MediumType, const QString &); 638 653 639 654 bool findMedium (const CMedium &, VBoxMedium &) const; 655 VBoxMedium findMedium (const QString &aMediumId) const; 640 656 641 657 /** Compact version of #findMediumTo(). Asserts if not found. */ … … 674 690 QString helpFile() const; 675 691 692 static QIcon iconSet (const QPixmap &aNormal, 693 const QPixmap &aDisabled = QPixmap(), 694 const QPixmap &aActive = QPixmap()); 676 695 static QIcon iconSet (const char *aNormal, 677 696 const char *aDisabled = NULL, … … 787 806 788 807 /** Emitted when the media is removed using #removeMedia(). */ 789 void mediumRemoved (VBoxDefs::Medi aType, const QString &);808 void mediumRemoved (VBoxDefs::MediumType, const QString &); 790 809 791 810 /* signals emitted when the VirtualBox callback is called by the server -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxMediaComboBox.h
r19239 r23223 46 46 47 47 void setCurrentItem (const QString &aItemId); 48 void setType (VBoxDefs::Medi aType aMediaType);48 void setType (VBoxDefs::MediumType aMediumType); 49 49 void setMachineId (const QString &aMachineId = QString::null); 50 void setNullItemPresent (bool aNullItemPresent); 50 51 51 52 void setShowDiffs (bool aShowDiffs); … … 59 60 void mediumAdded (const VBoxMedium &); 60 61 void mediumUpdated (const VBoxMedium &); 61 void mediumRemoved (VBoxDefs::Medi aType, const QString &);62 void mediumRemoved (VBoxDefs::MediumType, const QString &); 62 63 63 64 void processActivated (int aIndex); … … 77 78 bool findMediaIndex (const QString &aId, int &aIndex); 78 79 79 VBoxDefs::Medi aType mType;80 VBoxDefs::MediumType mType; 80 81 81 82 /** Obtruncated VBoxMedium structure. */ … … 98 99 99 100 bool mShowDiffs : 1; 101 bool mNullItemPresent : 1; 100 102 101 103 QString mMachineId; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxMediaManagerDlg.h
r22999 r23223 50 50 ~VBoxMediaManagerDlg(); 51 51 52 void setup (VBoxDefs::Medi aType aType, bool aDoSelect,52 void setup (VBoxDefs::MediumType aType, bool aDoSelect, 53 53 bool aRefresh = true, 54 54 const CMachine &aSessionMachine = CMachine(), … … 78 78 void mediumAdded (const VBoxMedium &aMedium); 79 79 void mediumUpdated (const VBoxMedium &aMedium); 80 void mediumRemoved (VBoxDefs::Medi aType aType, const QString &aId);80 void mediumRemoved (VBoxDefs::MediumType aType, const QString &aId); 81 81 82 82 void mediumEnumStarted(); … … 103 103 private: 104 104 105 QTreeWidget* treeWidget (VBoxDefs::Medi aType aType) const;106 VBoxDefs::Medi aType currentTreeWidgetType() const;105 QTreeWidget* treeWidget (VBoxDefs::MediumType aType) const; 106 VBoxDefs::MediumType currentTreeWidgetType() const; 107 107 QTreeWidget* currentTreeWidget() const; 108 108 … … 112 112 void setCurrentItem (QTreeWidget *aTree, QTreeWidgetItem *aItem); 113 113 114 void addMediumToList (const QString &aLocation, VBoxDefs::Medi aType aType);114 void addMediumToList (const QString &aLocation, VBoxDefs::MediumType aType); 115 115 116 116 MediaItem* createHardDiskItem (QTreeWidget *aTree, const VBoxMedium &aMedium) const; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxMedium.h
r19239 r23223 24 24 #define __VBoxMedium_h__ 25 25 26 #include "COMDefs.h" 27 28 /* Qt includes */ 26 /* Global includes */ 29 27 #include <QPixmap> 30 28 #include <QLinkedList> 29 30 /* Local includes */ 31 #include "COMDefs.h" 31 32 32 33 /** … … 45 46 * the medium itself. 46 47 * 47 * Note that this class "abuses" the KMedi aState_NotCreated state value to48 * Note that this class "abuses" the KMediumState_NotCreated state value to 48 49 * indicate that the accessibility check of the given medium (see 49 50 * #blockAndQueryState()) has not been done yet and therefore some parameters 50 51 * such as #size() are meaningless because they can be read only from the 51 * accessible medium. The real KMedi aState_NotCreated state is not necessary52 * accessible medium. The real KMediumState_NotCreated state is not necessary 52 53 * because this class is only used with created (existing) media. 53 54 */ … … 58 59 /** 59 60 * Creates a null medium descriptor which is not associated with any medium. 60 * The state field is set to KMedi aState_NotCreated.61 * The state field is set to KMediumState_NotCreated. 61 62 */ 62 63 VBoxMedium() 63 : mType (VBoxDefs::MediaType_Invalid) 64 , mState (KMediaState_NotCreated) 65 , mIsReadOnly (false), mIsUsedInSnapshots (false) 66 , mParent (NULL) {} 64 : mType (VBoxDefs::MediumType_Invalid) 65 , mState (KMediumState_NotCreated) 66 , mIsReadOnly (false) 67 , mIsUsedInSnapshots (false) 68 , mParent (0) { refresh(); } 67 69 68 70 /** 69 71 * Creates a media descriptor associated with the given medium. 70 72 * 71 * The state field remain KMedi aState_NotCreated until #blockAndQueryState()73 * The state field remain KMediumState_NotCreated until #blockAndQueryState() 72 74 * is called. All precomposed strings are filled up by implicitly calling 73 75 * #refresh(), see the #refresh() details for more info. … … 77 79 * disk media. 78 80 */ 79 VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType, 80 VBoxMedium *aParent = NULL) 81 : mMedium (aMedium), mType (aType) 82 , mState (KMediaState_NotCreated) 83 , mIsReadOnly (false), mIsUsedInSnapshots (false) 84 , mParent (aParent) { init(); } 81 VBoxMedium (const CMedium &aMedium, VBoxDefs::MediumType aType, VBoxMedium *aParent = 0) 82 : mMedium (aMedium) 83 , mType (aType) 84 , mState (KMediumState_NotCreated) 85 , mIsReadOnly (false) 86 , mIsUsedInSnapshots (false) 87 , mParent (aParent) { refresh(); } 85 88 86 89 /** … … 89 92 * creation. 90 93 */ 91 VBoxMedium (const CMedium &aMedium, VBoxDefs::Medi aType aType,92 KMediaState aState)93 : mMedium (aMedium), mType (aType)94 VBoxMedium (const CMedium &aMedium, VBoxDefs::MediumType aType, KMediumState aState) 95 : mMedium (aMedium) 96 , mType (aType) 94 97 , mState (aState) 95 , mIsReadOnly (false), mIsUsedInSnapshots (false) 96 , mParent (NULL) { init(); } 98 , mIsReadOnly (false) 99 , mIsUsedInSnapshots (false) 100 , mParent (0) { refresh(); } 97 101 98 102 void blockAndQueryState(); 99 103 void refresh(); 100 104 101 const CMedium &medium() const { return mMedium; } ;102 103 VBoxDefs::Medi aType type() const { return mType; }105 const CMedium &medium() const { return mMedium; } 106 107 VBoxDefs::MediumType type() const { return mType; } 104 108 105 109 /** … … 109 113 * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode. 110 114 */ 111 KMedi aState state (bool aNoDiffs = false) const115 KMediumState state (bool aNoDiffs = false) const 112 116 { 113 117 unconst (this)->checkNoDiffs (aNoDiffs); … … 131 135 } 132 136 133 const CHardDisk &hardDisk() const { return mHardDisk; }134 const CDVDImage &dvdImage() const { return mDVDImage; }135 const CFloppyImage &floppyImage() const { return mFloppyImage; }136 137 137 QString id() const { return mId; } 138 139 QString location (bool aNoDiffs = false) const 140 { return aNoDiffs ? root().mLocation : mLocation; } 141 QString name (bool aNoDiffs = false) const 142 { return aNoDiffs ? root().mName : mName; } 143 144 QString size (bool aNoDiffs = false) const 145 { return aNoDiffs ? root().mSize : mSize; } 146 147 QString hardDiskFormat (bool aNoDiffs = false) const 148 { return aNoDiffs ? root().mHardDiskFormat : mHardDiskFormat; } 149 QString hardDiskType (bool aNoDiffs = false) const 150 { return aNoDiffs ? root().mHardDiskType : mHardDiskType; } 151 QString logicalSize (bool aNoDiffs = false) const 152 { return aNoDiffs ? root().mLogicalSize : mLogicalSize; } 153 154 QString usage (bool aNoDiffs = false) const 155 { return aNoDiffs ? root().mUsage : mUsage; } 138 QString name (bool aNoDiffs = false) const { return aNoDiffs ? root().mName : mName; } 139 QString location (bool aNoDiffs = false) const { return aNoDiffs ? root().mLocation : mLocation; } 140 QString size (bool aNoDiffs = false) const { return aNoDiffs ? root().mSize : mSize; } 141 QString logicalSize (bool aNoDiffs = false) const { return aNoDiffs ? root().mLogicalSize : mLogicalSize; } 142 QString hardDiskFormat (bool aNoDiffs = false) const { return aNoDiffs ? root().mHardDiskFormat : mHardDiskFormat; } 143 QString hardDiskType (bool aNoDiffs = false) const { return aNoDiffs ? root().mHardDiskType : mHardDiskType; } 144 QString usage (bool aNoDiffs = false) const { return aNoDiffs ? root().mUsage : mUsage; } 156 145 157 146 /** … … 171 160 /** 172 161 * Returns @c true if this medium is attached to any VM in any snapshot. 173 * which case #usage() will contain a string with comma-sparated VM names.174 162 */ 175 163 bool isUsedInSnapshots() const { return mIsUsedInSnapshots; } 176 164 177 165 /** 178 * Returns @c true if this medium is attached to the given machine in the 179 * current state. 180 */ 181 bool isAttachedInCurStateTo (const QString &aMachineId) const 182 { return mCurStateMachineIds.indexOf (aMachineId) >= 0; } 166 * Returns @c true if this medium corresponds to real host drive. 167 */ 168 bool isHostDrive() const { return mIsHostDrive; } 169 170 /** 171 * Returns @c true if this medium is attached to the given machine in the current state. 172 */ 173 bool isAttachedInCurStateTo (const QString &aMachineId) const { return mCurStateMachineIds.indexOf (aMachineId) >= 0; } 183 174 184 175 /** … … 186 177 * to in their current state (i.e. excluding snapshots). 187 178 */ 188 const QList <QString> &curStateMachineIds() const 189 { return mCurStateMachineIds; } 179 const QList <QString> &curStateMachineIds() const { return mCurStateMachineIds; } 190 180 191 181 /** … … 196 186 VBoxMedium &root() const; 197 187 198 QString toolTip (bool aNoDiffs = false, bool aCheckRO = false) const;188 QString toolTip (bool aNoDiffs = false, bool aCheckRO = false) const; 199 189 QPixmap icon (bool aNoDiffs = false, bool aCheckRO = false) const; 200 190 201 191 /** Shortcut to <tt>#toolTip (aNoDiffs, true)</tt>. */ 202 QString toolTipCheckRO (bool aNoDiffs = false) const 203 { return toolTip (aNoDiffs, true); } 192 QString toolTipCheckRO (bool aNoDiffs = false) const { return toolTip (aNoDiffs, true); } 204 193 205 194 /** Shortcut to <tt>#icon (aNoDiffs, true)</tt>. */ 206 QPixmap iconCheckRO (bool aNoDiffs = false) const 207 { return icon (aNoDiffs, true); } 208 209 QString details (bool aNoDiffs = false, bool aPredictDiff = false, 210 bool aUseHTML = false) const; 195 QPixmap iconCheckRO (bool aNoDiffs = false) const { return icon (aNoDiffs, true); } 196 197 QString details (bool aNoDiffs = false, bool aPredictDiff = false, bool aUseHTML = false) const; 211 198 212 199 /** Shortcut to <tt>#details (aNoDiffs, aPredictDiff, true)</tt>. */ 213 QString detailsHTML (bool aNoDiffs = false, bool aPredictDiff = false) const 214 { return details (aNoDiffs, aPredictDiff, true); } 200 QString detailsHTML (bool aNoDiffs = false, bool aPredictDiff = false) const { return details (aNoDiffs, aPredictDiff, true); } 215 201 216 202 /** Returns @c true if this media descriptor is a null object. */ … … 219 205 private: 220 206 221 void init();222 223 207 void checkNoDiffs (bool aNoDiffs); 224 208 225 209 CMedium mMedium; 226 210 227 VBoxDefs::Medi aType mType;228 229 KMedi aState mState;211 VBoxDefs::MediumType mType; 212 213 KMediumState mState; 230 214 QString mLastAccessError; 231 215 COMResult mResult; 232 233 CHardDisk mHardDisk;234 CDVDImage mDVDImage;235 CFloppyImage mFloppyImage;236 216 237 217 QString mId; … … 249 229 bool mIsReadOnly : 1; 250 230 bool mIsUsedInSnapshots : 1; 231 bool mIsHostDrive : 1; 251 232 252 233 QList <QString> mCurStateMachineIds; … … 260 241 struct NoDiffs 261 242 { 262 NoDiffs() : isSet (false), state (KMedi aState_NotCreated) {}243 NoDiffs() : isSet (false), state (KMediumState_NotCreated) {} 263 244 264 245 bool isSet : 1; 265 246 266 KMedi aState state;247 KMediumState state; 267 248 COMResult result; 268 249 QString toolTip; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxNewHDWzd.h
r16867 r23223 39 39 VBoxNewHDWzd (QWidget *aParent = 0); 40 40 41 C HardDiskhardDisk() { return mHD; }41 CMedium hardDisk() { return mHD; } 42 42 void setRecommendedFileName (const QString &aName); 43 43 void setRecommendedSize (quint64 aSize); … … 66 66 67 67 QIWidgetValidator *mWValNameAndSize; 68 C HardDiskmHD;68 CMedium mHD; 69 69 int mSliderScale; 70 70 quint64 mMaxVDISize; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxNewVMWzd.h
r18080 r23223 69 69 QIWidgetValidator *mWvalMemory; 70 70 QIWidgetValidator *mWvalHDD; 71 C HardDiskmHardDisk;71 CMedium mHardDisk; 72 72 CMachine mMachine; 73 73 }; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r22434 r23223 239 239 int confirmDeleteHardDiskStorage (QWidget *aParent, 240 240 const QString &aLocation); 241 void cannotDeleteHardDiskStorage (QWidget *aParent, const C HardDisk&aHD,241 void cannotDeleteHardDiskStorage (QWidget *aParent, const CMedium &aHD, 242 242 const CProgress &aProgress); 243 243 244 244 int confirmDetachAddControllerSlots (QWidget *aParent) const; 245 245 int confirmChangeAddControllerSlots (QWidget *aParent) const; 246 int confirmRunNewHDWzdOrVDM ( QWidget* aParent);246 int confirmRunNewHDWzdOrVDM (KDeviceType aDeviceType); 247 247 248 248 void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox, 249 249 const QString &aLocaiton, 250 const C HardDisk&aHD,250 const CMedium &aHD, 251 251 const CProgress &aProgress); 252 252 void cannotAttachHardDisk (QWidget *aParent, const CMachine &aMachine, … … 262 262 const VBoxMedium &aMedium, const COMResult &aResult); 263 263 void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox, 264 VBoxDefs::Medi aType aType, const QString &aLocation);264 VBoxDefs::MediumType aType, const QString &aLocation); 265 265 void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium, 266 266 const COMResult &aResult); … … 358 358 const QString &errorMsg) const; 359 359 360 static QString toAccusative (VBoxDefs::Medi aType aType);360 static QString toAccusative (VBoxDefs::MediumType aType); 361 361 362 362 static QString formatRC (HRESULT aRC); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxToolBar.h
r20052 r23223 26 26 #include <QGlobalStatic> /* for Q_WS_MAC */ 27 27 #ifdef Q_WS_MAC 28 # 28 #include "VBoxUtils.h" 29 29 #endif 30 30 … … 49 49 VBoxToolBar (QWidget *aParent) 50 50 : QToolBar (aParent) 51 , mMainWindow (qobject_cast <QMainWindow*> (aParent))51 , mMainWindow (qobject_cast <QMainWindow*> (aParent)) 52 52 { 53 53 setFloatable (false); 54 54 setMovable (false); 55 56 /* Remove that ugly frame panel around the toolbar. 57 * Doing that currently for Cleanlooks & Windows styles. */ 58 if (qobject_cast <QCleanlooksStyle*> (QToolBar::style()) || 59 qobject_cast <QWindowsStyle*> (QToolBar::style())) 60 setStyleSheet ("QToolBar { border: 0px none black; }"); 61 55 62 if (layout()) 56 63 layout()->setContentsMargins (0, 0, 0, 0);; 57 64 58 65 setContextMenuPolicy (Qt::NoContextMenu); 59 60 /* Remove that ugly frame panel around the toolbar. */61 /* I'm not sure if we should do this generally on linux for that mass62 * of KDE styles. But maybe some of them are based on CleanLooks so63 * they are looking ok also. */64 QStyle *style = NULL;65 if (!style)66 /* Check for cleanlooks style */67 style = qobject_cast<QCleanlooksStyle*> (QToolBar::style());68 if (!style)69 /* Check for windows style */70 style = qobject_cast<QWindowsStyle*> (QToolBar::style());71 if (style)72 setStyleSheet ("QToolBar { border: 0px none black; }");73 66 } 74 67 75 void setMacToolbar () 68 #ifdef Q_WS_MAC 69 void setMacToolbar() 76 70 { 77 #ifdef Q_WS_MAC78 71 if (mMainWindow) 79 72 { 80 73 mMainWindow->setUnifiedTitleAndToolBarOnMac (true); 81 # 74 #ifndef QT_MAC_USE_COCOA 82 75 WindowRef window = ::darwinToNativeWindow (this); 83 76 EventHandlerUPP eventHandler = ::NewEventHandlerUPP (VBoxToolBar::macEventFilter); … … 90 83 RT_ELEMENTS (eventTypes), eventTypes, 91 84 NULL, NULL); 92 # 85 #endif /* !QT_MAC_USE_COCOA */ 93 86 } 94 #endif /* Q_WS_MAC */95 87 } 96 88 97 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)89 #ifndef QT_MAC_USE_COCOA 98 90 static pascal OSStatus macEventFilter (EventHandlerCallRef aNextHandler, 99 91 EventRef aEvent, void * /* aUserData */) … … 117 109 return CallNextEventHandler (aNextHandler, aEvent); 118 110 } 119 #endif /* Q_WS_MAC &&!QT_MAC_USE_COCOA */111 #endif /* !QT_MAC_USE_COCOA */ 120 112 121 113 void setShowToolBarButton (bool aShow) 122 114 { 123 #ifdef Q_WS_MAC124 115 ::darwinSetShowsToolbarButton (this, aShow); 125 #else /* Q_WS_MAC */126 Q_UNUSED (aShow);127 #endif /* !Q_WS_MAC */128 116 } 117 #endif /* Q_WS_MAC */ 129 118 130 void setUsesTextLabel (bool enable)119 void setUsesTextLabel (bool aEnable) 131 120 { 132 121 Qt::ToolButtonStyle tbs = Qt::ToolButtonTextUnderIcon; 133 if (! enable)122 if (!aEnable) 134 123 tbs = Qt::ToolButtonIconOnly; 135 124 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMFirstRunWzd.h
r13580 r23223 57 57 QIWidgetValidator *mWvalType; 58 58 CMachine mMachine; 59 QVector <C HostDVDDrive>mHostDVDs;60 QVector <C HostFloppyDrive>mHostFloppys;59 QVector <CMedium> mHostDVDs; 60 QVector <CMedium> mHostFloppys; 61 61 }; 62 62 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsHD.h
r19837 r23223 6 6 7 7 /* 8 * Copyright (C) 2006-200 8Sun Microsystems, Inc.8 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 #define __VBoxVMSettingsHD_h__ 25 25 26 /* Global includes */ 27 #include <QItemDelegate> 28 #include <QPointer> 29 30 /* Local includes */ 26 31 #include "VBoxSettingsPage.h" 27 32 #include "VBoxVMSettingsHD.gen.h" 28 33 #include "COMDefs.h" 29 #include "VBoxMediaComboBox.h" 30 31 /* Qt includes */ 32 #include <QComboBox> 33 34 /** Register type to store slot data */ 35 class SlotValue 36 { 37 public: 38 SlotValue() 39 : bus (KStorageBus_Null), channel (0), device (0) 40 , name (QString::null) {} 41 SlotValue (KStorageBus aBus, LONG aChannel, LONG aDevice) 42 : bus (aBus), channel (aChannel), device (aDevice) 43 , name (vboxGlobal().toFullString (aBus, aChannel, aDevice)) {} 44 SlotValue (const SlotValue &aOther) 45 : bus (aOther.bus), channel (aOther.channel), device (aOther.device) 46 , name (aOther.name) {} 47 48 SlotValue& operator= (const SlotValue &aOther) 34 35 /* Local forwardes */ 36 class AttachmentItem; 37 class ControllerItem; 38 39 /* Internal Types */ 40 typedef QList <StorageSlot> SlotsList; 41 typedef QList <KDeviceType> DeviceTypeList; 42 typedef QList <KStorageControllerType> ControllerTypeList; 43 Q_DECLARE_METATYPE (SlotsList); 44 Q_DECLARE_METATYPE (DeviceTypeList); 45 Q_DECLARE_METATYPE (ControllerTypeList); 46 47 /* Pixmap Storage Pool */ 48 class PixmapPool : public QObject 49 { 50 Q_OBJECT; 51 52 public: 53 54 enum PixmapType 49 55 { 50 bus = aOther.bus; 51 channel = aOther.channel; 52 device = aOther.device; 53 name = aOther.name; 54 return *this; 55 } 56 57 bool operator== (const SlotValue &aOther) 56 InvalidPixmap = -1, 57 58 AddControllerEn = 0, 59 AddControllerDis = 1, 60 DelControllerEn = 2, 61 DelControllerDis = 3, 62 63 AddAttachmentEn = 4, 64 AddAttachmentDis = 5, 65 DelAttachmentEn = 6, 66 DelAttachmentDis = 7, 67 68 IDEController = 8, 69 SATAController = 9, 70 SCSIController = 10, 71 FloppyController = 11, 72 73 HDAttachmentEn = 12, 74 HDAttachmentDis = 13, 75 CDAttachmentEn = 14, 76 CDAttachmentDis = 15, 77 FDAttachmentEn = 16, 78 FDAttachmentDis = 17, 79 80 PlusEn = 18, 81 PlusDis = 19, 82 MinusEn = 20, 83 MinusDis = 21, 84 85 UnknownEn = 22, 86 87 VMMEn = 23, 88 VMMDis = 24, 89 90 MaxIndex 91 }; 92 93 static PixmapPool* pool (QObject *aParent = 0); 94 95 QPixmap pixmap (PixmapType aType) const; 96 97 protected: 98 99 PixmapPool (QObject *aParent); 100 101 static QPointer <PixmapPool> mThis; 102 103 private: 104 105 QVector <QPixmap> mPool; 106 }; 107 108 /* Abstract Controller Type */ 109 class AbstractControllerType 110 { 111 public: 112 113 AbstractControllerType (KStorageBus aBusType, KStorageControllerType aCtrType); 114 virtual ~AbstractControllerType() {} 115 116 KStorageBus busType() const; 117 KStorageControllerType ctrType() const; 118 ControllerTypeList ctrTypes() const; 119 PixmapPool::PixmapType pixmap() const; 120 121 void setCtrType (KStorageControllerType aCtrType); 122 123 virtual DeviceTypeList deviceTypeList() const = 0; 124 125 protected: 126 127 virtual KStorageControllerType first() const = 0; 128 virtual uint size() const = 0; 129 130 KStorageBus mBusType; 131 KStorageControllerType mCtrType; 132 PixmapPool::PixmapType mPixmap; 133 }; 134 135 /* IDE Controller Type */ 136 class IDEControllerType : public AbstractControllerType 137 { 138 public: 139 140 IDEControllerType (KStorageControllerType aSubType); 141 142 private: 143 144 DeviceTypeList deviceTypeList() const; 145 146 KStorageControllerType first() const; 147 uint size() const; 148 }; 149 150 /* SATA Controller Type */ 151 class SATAControllerType : public AbstractControllerType 152 { 153 public: 154 155 SATAControllerType (KStorageControllerType aSubType); 156 157 private: 158 159 DeviceTypeList deviceTypeList() const; 160 161 KStorageControllerType first() const; 162 uint size() const; 163 }; 164 165 /* SCSI Controller Type */ 166 class SCSIControllerType : public AbstractControllerType 167 { 168 public: 169 170 SCSIControllerType (KStorageControllerType aSubType); 171 172 private: 173 174 DeviceTypeList deviceTypeList() const; 175 176 KStorageControllerType first() const; 177 uint size() const; 178 }; 179 180 /* Floppy Controller Type */ 181 class FloppyControllerType : public AbstractControllerType 182 { 183 public: 184 185 FloppyControllerType (KStorageControllerType aSubType); 186 187 private: 188 189 DeviceTypeList deviceTypeList() const; 190 191 KStorageControllerType first() const; 192 uint size() const; 193 }; 194 195 /* Abstract Item */ 196 class AbstractItem 197 { 198 public: 199 200 enum ItemType 58 201 { 59 return bus == aOther.bus && 60 channel == aOther.channel && 61 device == aOther.device; 62 } 63 64 bool operator!= (const SlotValue &aOther) 202 Type_InvalidItem = 0, 203 Type_RootItem = 1, 204 Type_ControllerItem = 2, 205 Type_AttachmentItem = 3 206 }; 207 208 AbstractItem (AbstractItem *aParent = 0); 209 virtual ~AbstractItem(); 210 211 AbstractItem* parent(); 212 QUuid id(); 213 214 virtual ItemType rtti() const = 0; 215 virtual AbstractItem* childByPos (int aIndex) = 0; 216 virtual AbstractItem* childById (const QUuid &aId) = 0; 217 virtual int posOfChild (AbstractItem *aItem) const = 0; 218 virtual int childCount() const = 0; 219 virtual QString text() const = 0; 220 virtual QString tip() const = 0; 221 virtual QPixmap pixmap() = 0; 222 223 protected: 224 225 virtual void addChild (AbstractItem *aItem) = 0; 226 virtual void delChild (AbstractItem *aItem) = 0; 227 228 AbstractItem *mParent; 229 QUuid mId; 230 }; 231 Q_DECLARE_METATYPE (AbstractItem::ItemType); 232 233 /* Root Item */ 234 class RootItem : public AbstractItem 235 { 236 public: 237 238 RootItem(); 239 ~RootItem(); 240 241 ItemType rtti() const; 242 AbstractItem* childByPos (int aIndex); 243 AbstractItem* childById (const QUuid &aId); 244 int posOfChild (AbstractItem *aItem) const; 245 int childCount() const; 246 QString text() const; 247 QString tip() const; 248 QPixmap pixmap(); 249 250 private: 251 252 void addChild (AbstractItem *aItem); 253 void delChild (AbstractItem *aItem); 254 255 QList <AbstractItem*> mControllers; 256 }; 257 258 /* Controller Item */ 259 class ControllerItem : public AbstractItem 260 { 261 public: 262 263 ControllerItem (AbstractItem *aParent, const QString &aName, KStorageBus aBusType, 264 KStorageControllerType aControllerType); 265 ~ControllerItem(); 266 267 ItemType rtti() const; 268 AbstractItem* childByPos (int aIndex); 269 AbstractItem* childById (const QUuid &aId); 270 int posOfChild (AbstractItem *aItem) const; 271 int childCount() const; 272 QString text() const; 273 QString tip() const; 274 QPixmap pixmap(); 275 276 KStorageBus ctrBusType() const; 277 QString ctrName() const; 278 KStorageControllerType ctrType() const; 279 ControllerTypeList ctrTypes() const; 280 281 void setCtrName (const QString &aCtrName); 282 void setCtrType (KStorageControllerType aCtrType); 283 284 SlotsList ctrAllSlots() const; 285 SlotsList ctrUsedSlots() const; 286 DeviceTypeList ctrDeviceTypeList() const; 287 QStringList ctrAllMediumIds() const; 288 QStringList ctrUsedMediumIds() const; 289 290 private: 291 292 void addChild (AbstractItem *aItem); 293 void delChild (AbstractItem *aItem); 294 295 QString mCtrName; 296 AbstractControllerType *mCtrType; 297 QList <AbstractItem*> mAttachments; 298 }; 299 300 /* Attachment Item */ 301 class AttachmentItem : public AbstractItem 302 { 303 public: 304 305 AttachmentItem (AbstractItem *aParent, KDeviceType aDeviceType); 306 307 ItemType rtti() const; 308 AbstractItem* childByPos (int aIndex); 309 AbstractItem* childById (const QUuid &aId); 310 int posOfChild (AbstractItem *aItem) const; 311 int childCount() const; 312 QString text() const; 313 QString tip() const; 314 QPixmap pixmap(); 315 316 StorageSlot attSlot() const; 317 SlotsList attSlots() const; 318 KDeviceType attDeviceType() const; 319 DeviceTypeList attDeviceTypes() const; 320 QString attMediumId() const; 321 QStringList attMediumIds (bool aFilter = true) const; 322 bool attIsHostDrive() const; 323 bool attIsPassthrough() const; 324 325 void setAttSlot (const StorageSlot &aAttSlot); 326 void setAttDevice (KDeviceType aAttDeviceType); 327 void setAttMediumId (const QString &aAttMediumId); 328 void setAttIsPassthrough (bool aPassthrough); 329 330 QString attSize() const; 331 QString attLogicalSize() const; 332 QString attLocation() const; 333 QString attFormat() const; 334 QString attUsage() const; 335 336 private: 337 338 void cache (const VBoxMedium &aMedium); 339 340 void addChild (AbstractItem *aItem); 341 void delChild (AbstractItem *aItem); 342 343 KDeviceType mAttDeviceType; 344 345 StorageSlot mAttSlot; 346 QString mAttMediumId; 347 bool mAttIsHostDrive; 348 bool mAttIsPassthrough; 349 350 QString mAttName; 351 QString mAttTip; 352 QPixmap mAttPixmap; 353 354 QString mAttSize; 355 QString mAttLogicalSize; 356 QString mAttLocation; 357 QString mAttFormat; 358 QString mAttUsage; 359 }; 360 361 /* Storage Model */ 362 class StorageModel : public QAbstractItemModel 363 { 364 Q_OBJECT; 365 366 public: 367 368 enum DataRole 65 369 { 66 return ! (*this == aOther); 67 } 68 69 KStorageBus bus; 70 LONG channel; 71 LONG device; 72 QString name; 73 }; 74 Q_DECLARE_METATYPE (SlotValue); 75 76 /** Register type to store disk data */ 77 class DiskValue 78 { 79 public: 80 DiskValue() 81 : id (QString::null) 82 , name (QString::null), tip (QString::null), pix (QPixmap()) {} 83 DiskValue (const QString &aId); 84 DiskValue (const DiskValue &aOther) 85 : id (aOther.id) 86 , name (aOther.name), tip (aOther.tip), pix (aOther.pix) {} 87 88 DiskValue& operator= (const DiskValue &aOther) 89 { 90 id = aOther.id; 91 name = aOther.name; 92 tip = aOther.tip; 93 pix = aOther.pix; 94 return *this; 95 } 96 97 bool operator== (const DiskValue &aOther) 98 { 99 return id == aOther.id; 100 } 101 102 bool operator!= (const DiskValue &aOther) 103 { 104 return ! (*this == aOther); 105 } 106 107 QString id; 108 QString name; 109 QString tip; 110 QPixmap pix; 111 }; 112 Q_DECLARE_METATYPE (DiskValue); 113 114 /** Declare type to store both slot&disk data */ 115 class Attachment 116 { 117 public: 118 Attachment (SlotValue aSlot, DiskValue aDisk) 119 : slot (aSlot), disk (aDisk) {} 120 121 /* Define sorting rules */ 122 bool operator< (const Attachment &aOther) const 123 { 124 return (slot.bus < aOther.slot.bus) || 125 (slot.bus == aOther.slot.bus && slot.channel < aOther.slot.channel) || 126 (slot.bus == aOther.slot.bus && slot.channel == aOther.slot.channel && slot.device < aOther.slot.device); 127 } 128 129 SlotValue slot; 130 DiskValue disk; 131 }; 132 133 /** 134 * QAbstractTableModel class reimplementation. 135 * Used to feat slot/disk selection mechanism. 136 */ 137 class AttachmentsModel : public QAbstractTableModel 370 R_ItemId = Qt::UserRole + 1, 371 R_ItemPixmap, 372 R_ItemPixmapRect, 373 R_ItemName, 374 R_ItemNamePoint, 375 R_ItemType, 376 R_IsController, 377 R_IsAttachment, 378 379 R_IsMoreControllersPossible, 380 R_IsMoreAttachmentsPossible, 381 382 R_CtrName, 383 R_CtrType, 384 R_CtrTypes, 385 R_CtrDevices, 386 R_CtrBusType, 387 388 R_AttSlot, 389 R_AttSlots, 390 R_AttDevice, 391 R_AttDevices, 392 R_AttMediumId, 393 R_AttIsHostDrive, 394 R_AttIsPassthrough, 395 R_AttSize, 396 R_AttLogicalSize, 397 R_AttLocation, 398 R_AttFormat, 399 R_AttUsage, 400 401 R_Margin, 402 R_Spacing, 403 R_IconSize, 404 405 R_HDPixmapEn, 406 R_HDPixmapDis, 407 R_CDPixmapEn, 408 R_CDPixmapDis, 409 R_FDPixmapEn, 410 R_FDPixmapDis, 411 R_HDPixmapRect, 412 R_CDPixmapRect, 413 R_FDPixmapRect, 414 415 R_PlusPixmapEn, 416 R_PlusPixmapDis, 417 R_MinusPixmapEn, 418 R_MinusPixmapDis, 419 R_AdderPoint 420 }; 421 422 StorageModel (QObject *aParent); 423 ~StorageModel(); 424 425 int rowCount (const QModelIndex &aParent = QModelIndex()) const; 426 int columnCount (const QModelIndex &aParent = QModelIndex()) const; 427 428 QModelIndex root() const; 429 QModelIndex index (int aRow, int aColumn, const QModelIndex &aParent = QModelIndex()) const; 430 QModelIndex parent (const QModelIndex &aIndex) const; 431 432 QVariant data (const QModelIndex &aIndex, int aRole) const; 433 bool setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole); 434 435 QModelIndex addController (const QString &aCtrName, KStorageBus aBusType, KStorageControllerType aCtrType); 436 void delController (const QUuid &aCtrId); 437 438 QModelIndex addAttachment (const QUuid &aCtrId, KDeviceType aDeviceType); 439 void delAttachment (const QUuid &aCtrId, const QUuid &aAttId); 440 441 private: 442 443 Qt::ItemFlags flags (const QModelIndex &aIndex) const; 444 445 AbstractItem *mRootItem; 446 447 QPixmap mPlusPixmapEn; 448 QPixmap mPlusPixmapDis; 449 450 QPixmap mMinusPixmapEn; 451 QPixmap mMinusPixmapDis; 452 }; 453 454 /* Storage Delegate */ 455 class StorageDelegate : public QItemDelegate 138 456 { 139 457 Q_OBJECT; … … 141 459 public: 142 460 143 AttachmentsModel (QITableView *aParent, int aSlotId, int aDiskId) 144 : QAbstractTableModel (aParent), mParent (aParent) 145 , mSlotId (aSlotId), mDiskId (aDiskId) {} 146 147 Qt::ItemFlags flags (const QModelIndex &aIndex) const; 148 149 int columnCount (const QModelIndex &aParent = QModelIndex()) const 150 { NOREF (aParent); return 2; } 151 int rowCount (const QModelIndex &aParent = QModelIndex()) const 152 { NOREF (aParent); return mUsedSlotsList.count() + 1; } 153 154 QVariant data (const QModelIndex &aIndex, 155 int aRole = Qt::DisplayRole) const; 156 bool setData (const QModelIndex &aIndex, 157 const QVariant &aValue, 158 int aRole = Qt::EditRole); 159 QVariant headerData (int aSection, 160 Qt::Orientation aOrientation, 161 int aRole = Qt::DisplayRole) const; 162 163 void addItem (const SlotValue &aSlot = SlotValue(), 164 const DiskValue &aDisk = DiskValue()); 165 void delItem (int aIndex); 166 167 const QList<SlotValue>& usedSlotsList() { return mUsedSlotsList; } 168 const QList<DiskValue>& usedDisksList() { return mUsedDisksList; } 169 QList<Attachment> fullUsedList(); 170 171 void removeAddController(); 172 void updateDisks(); 173 174 private: 175 176 QITableView *mParent; 177 QList<SlotValue> mUsedSlotsList; 178 QList<DiskValue> mUsedDisksList; 179 int mSlotId; 180 int mDiskId; 181 }; 182 183 /** 184 * QComboBox class reimplementation. 185 * Used as editor for HD Attachment SLOT field. 186 */ 187 class SlotEditor : public QComboBox 188 { 189 Q_OBJECT; 190 Q_PROPERTY (QVariant slot READ slot WRITE setSlot USER true); 191 192 public: 193 194 SlotEditor (QWidget *aParent); 195 196 QVariant slot() const; 197 void setSlot (QVariant aSlot); 198 199 signals: 200 201 void readyToCommit (QWidget *aThis); 202 203 private slots: 204 205 void onActivate(); 206 207 private: 208 209 #if 0 /* F2 key binding left for future releases... */ 210 void keyPressEvent (QKeyEvent *aEvent); 211 #endif 212 213 void populate (const SlotValue &aIncluding); 214 215 QList<SlotValue> mList; 216 }; 217 218 /** 219 * VBoxMediaComboBox class reimplementation. 220 * Used as editor for HD Attachment DISK field. 221 */ 222 class DiskEditor : public VBoxMediaComboBox 223 { 224 Q_OBJECT; 225 Q_PROPERTY (QVariant disk READ disk WRITE setDisk USER true); 226 227 public: 228 229 static DiskEditor* activeEditor(); 230 231 DiskEditor (QWidget *aParent); 232 ~DiskEditor(); 233 234 QVariant disk() const; 235 void setDisk (QVariant aDisk); 236 237 signals: 238 239 void readyToCommit (QWidget *aThis); 240 241 protected: 242 243 void paintEvent (QPaintEvent *aEvent); 244 void initStyleOption (QStyleOptionComboBox *aOption) const; 245 246 private slots: 247 248 void onActivate(); 249 250 private: 251 252 #if 0 /* F2 key binding left for future releases... */ 253 void keyPressEvent (QKeyEvent *aEvent); 254 #endif 255 256 static DiskEditor *mInstance; 257 }; 258 259 /** 260 * Singleton QObject class reimplementation. 261 * Used to make selected HD Attachments slots unique & 262 * stores some specific data used for HD Settings. 263 */ 264 class HDSettings : public QObject 265 { 266 Q_OBJECT; 267 268 public: 269 270 static HDSettings* instance (QWidget *aParent = 0, 271 AttachmentsModel *aWatched = 0); 272 273 QList<SlotValue> slotsList (const SlotValue &aIncluding = SlotValue(), 274 bool aFilter = false) const; 275 QList<DiskValue> disksList() const; 276 277 bool tryToChooseUniqueDisk (DiskValue &aResult) const; 278 279 const CMachine& machine() const { return mMachine; } 280 void setMachine (const CMachine &aMachine) { mMachine = aMachine; } 281 282 int addCount() const { return mAddCount; } 283 void setAddCount (int aAddCount, KStorageBus aAddBus) 284 { 285 if (mAddCount != aAddCount || 286 aAddBus != mAddBus) 287 { 288 mAddCount = aAddCount; 289 mAddBus = aAddBus; 290 makeAddControllerList(); 291 } 292 } 293 294 bool showDiffs() const { return mShowDiffs; } 295 void setShowDiffs (bool aShowDiffs) 296 { 297 mShowDiffs = aShowDiffs; 298 update(); 299 } 300 301 protected: 302 303 HDSettings (QWidget *aParent, AttachmentsModel *aWatched); 304 virtual ~HDSettings(); 305 306 private slots: 307 308 void update() 309 { 310 makeMediumList(); 311 mModel->updateDisks(); 312 } 313 314 private: 315 316 void makeIDEList(); 317 void makeAddControllerList(); 318 void makeMediumList(); 319 320 321 static HDSettings *mInstance; 322 323 AttachmentsModel *mModel; 324 CMachine mMachine; 325 326 QList<SlotValue> mIDEList; 327 QList<SlotValue> mAddControllerList; 328 QList<DiskValue> mDisksList; 329 330 int mAddCount; 331 KStorageBus mAddBus; 332 bool mShowDiffs; 461 StorageDelegate (QObject *aParent); 462 463 private: 464 465 void paint (QPainter *aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const; 333 466 }; 334 467 … … 348 481 signals: 349 482 350 void hdChanged();483 void mediumChanged(); 351 484 352 485 protected: … … 358 491 bool revalidate (QString &aWarning, QString &aTitle); 359 492 360 void setOrderAfter (QWidget *aWidget);361 362 493 void retranslateUi(); 363 494 495 void showEvent (QShowEvent *aEvent); 496 364 497 private slots: 365 498 366 void addAttachment(); 499 void addController(); 500 void addIDEController(); 501 void addSATAController(); 502 void addSCSIController(); 503 void addFloppyController(); 504 void delController(); 505 506 void addAttachment (KDeviceType aDeviceType = KDeviceType_Null); 367 507 void delAttachment(); 368 void showMediaManager(); 369 370 void onAddControllerCheckToggled (int); 371 void onAddControllerTypeChanged (int aIndex); 372 bool checkAddControllers (int aWhat); 373 void onShowDiffsCheckToggled (int); 374 375 void updateActions (const QModelIndex &aIndex); 376 377 private: 378 379 /* events */ 380 bool eventFilter (QObject *aObj, QEvent *aEvent); 381 void showEvent (QShowEvent *aEvent); 382 383 /* private functions */ 384 QString getWithMediaManager (const QString &aInitialId = QString::null); 508 509 void getInformation(); 510 void setInformation(); 511 512 void onVmmInvoked(); 513 514 void updateActionsState(); 515 516 void onRowInserted (const QModelIndex &aParent, int aIndex); 517 void onRowRemoved(); 518 519 void onCurrentItemChanged(); 520 521 void onContextMenuRequested (const QPoint &aPosition); 522 523 void onDrawItemBranches (QPainter *aPainter, const QRect &aRect, const QModelIndex &aIndex); 524 525 void onMouseClicked (QMouseEvent *aEvent); 526 527 private: 528 385 529 QString getWithNewHDWizard(); 386 int maxNameLength() const; 387 void removeFocus(); 388 KStorageControllerType currentControllerType() const 389 { 390 return static_cast<KStorageControllerType> (mCbControllerType->itemData (mCbControllerType->currentIndex()).toInt()); 391 } 392 KStorageBus currentBusType() const 393 { 394 return vboxGlobal().toStorageBusType (currentControllerType()); 395 } 396 int currentMaxPortCount() const 397 { 398 int c = 0; 399 switch (currentBusType()) 400 { 401 case KStorageBus_IDE: c = 2; break; 402 case KStorageBus_SATA: c = 30; break; 403 case KStorageBus_SCSI: c = 16; break; 404 default: break; 405 } 406 return c; 407 } 408 409 /* variables */ 530 QString getWithMediaManager (VBoxDefs::MediumType aMediumType); 531 532 void updateAdditionalObjects (KDeviceType aType); 533 410 534 CMachine mMachine; 411 AttachmentsModel *mModel;412 535 QIWidgetValidator *mValidator; 413 536 414 QAction *mNewAction; 415 QAction *mDelAction; 416 QAction *mVdmAction; 417 418 bool mWasTableSelected; 419 bool mPolished; 420 421 int mLastSelAddControllerIndex; 537 StorageModel *mStorageModel; 538 539 QAction *mAddCtrAction; 540 QAction *mAddIDECtrAction; 541 QAction *mAddSATACtrAction; 542 QAction *mAddSCSICtrAction; 543 QAction *mAddFloppyCtrAction; 544 QAction *mDelCtrAction; 545 QAction *mAddAttAction; 546 QAction *mDelAttAction; 547 548 bool mIsLoadingInProgress; 549 bool mIsPolished; 422 550 }; 423 551 -
trunk/src/VBox/Frontends/VirtualBox/src/QILabelSeparator.cpp
r14398 r23223 6 6 7 7 /* 8 * Copyright (C) 2008 Sun Microsystems, Inc.8 * Copyright (C) 2008-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 */ 22 22 23 /* Global includes */ 24 #include <QLabel> 25 #include <QHBoxLayout> 26 27 /* Local includes */ 23 28 #include "QILabelSeparator.h" 24 29 #include "VBoxGlobal.h" 25 30 26 /* Qt includes */27 #include <QLabel>28 #include <QHBoxLayout>29 30 31 QILabelSeparator::QILabelSeparator (QWidget *aParent /* = NULL */, Qt::WindowFlags aFlags /* = 0 */) 31 32 : QWidget (aParent, aFlags) 32 , mLabel ( NULL)33 , mLabel (0) 33 34 { 34 35 init(); … … 37 38 QILabelSeparator::QILabelSeparator (const QString &aText, QWidget *aParent /* = NULL */, Qt::WindowFlags aFlags /* = 0 */) 38 39 : QWidget (aParent, aFlags) 39 , mLabel ( NULL)40 , mLabel (0) 40 41 { 41 42 init(); 42 43 setText (aText); 44 } 45 46 QString QILabelSeparator::text() const 47 { 48 return mLabel->text(); 43 49 } 44 50 … … 58 64 } 59 65 60 QString QILabelSeparator::text() const61 {62 return mLabel->text();63 }64 65 66 void QILabelSeparator::init() 66 67 { … … 71 72 separator->setEnabled (false); 72 73 separator->setContentsMargins (0, 0, 0, 0); 73 //separator->setStyleSheet ("QFrame {border: 1px outset black; }");74 // separator->setStyleSheet ("QFrame {border: 1px outset black; }"); 74 75 separator->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); 75 76 … … 79 80 layout->addWidget (separator, Qt::AlignBottom); 80 81 } 82 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r22834 r23223 343 343 { 344 344 public: 345 MediaDriveChangeEvent (VBoxDefs::Medi aType aType)345 MediaDriveChangeEvent (VBoxDefs::MediumType aType) 346 346 : QEvent ((QEvent::Type) VBoxDefs::MediaDriveChangeEventType) 347 347 , mType (aType) {} 348 VBoxDefs::Medi aType type() const { return mType; }348 VBoxDefs::MediumType type() const { return mType; } 349 349 private: 350 VBoxDefs::Medi aType mType;350 VBoxDefs::MediumType mType; 351 351 }; 352 352 … … 516 516 } 517 517 518 STDMETHOD(OnDVDDriveChange)()519 {520 LogFlowFunc (("DVD Drive changed\n"));521 QApplication::postEvent (mView,522 new MediaDriveChangeEvent (VBoxDefs::MediaType_DVD));523 return S_OK;524 }525 526 STDMETHOD(OnFloppyDriveChange)()527 {528 LogFlowFunc (("Floppy Drive changed\n"));529 QApplication::postEvent (mView,530 new MediaDriveChangeEvent (VBoxDefs::MediaType_Floppy));531 return S_OK;532 }533 534 518 STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter) 535 519 { … … 544 528 //QApplication::postEvent (mView, 545 529 // new StorageControllerChangeEvent ()); 530 return S_OK; 531 } 532 533 STDMETHOD(OnMediumChange)(IMediumAttachment *aMediumAttachment) 534 { 535 CMediumAttachment att(aMediumAttachment); 536 switch (att.GetType()) 537 { 538 case KDeviceType_Floppy: 539 QApplication::postEvent(mView, 540 new MediaDriveChangeEvent(VBoxDefs::MediumType_Floppy)); 541 break; 542 case KDeviceType_DVD: 543 QApplication::postEvent(mView, 544 new MediaDriveChangeEvent(VBoxDefs::MediumType_DVD)); 545 break; 546 default: 547 /* @todo later add hard disk change as well */ 548 break; 549 } 546 550 return S_OK; 547 551 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r23142 r23223 962 962 connect (console, SIGNAL (additionsStateChanged (const QString&, bool, bool, bool)), 963 963 this, SLOT (updateAdditionsState (const QString &, bool, bool, bool))); 964 connect (console, SIGNAL (mediaDriveChanged (VBoxDefs::Medi aType)),965 this, SLOT (updateMediaDriveState (VBoxDefs::Medi aType)));964 connect (console, SIGNAL (mediaDriveChanged (VBoxDefs::MediumType)), 965 this, SLOT (updateMediaDriveState (VBoxDefs::MediumType))); 966 966 connect (console, SIGNAL (usbStateChange()), 967 967 this, SLOT (updateUsbState())); … … 1860 1860 { 1861 1861 mDevicesMountFloppyMenu->setEnabled (isRunningOrPaused); 1862 CFloppyDrive floppy = cmachine.GetFloppyDrive(); 1863 KDriveState state = floppy.GetState(); 1864 bool mounted = state != KDriveState_NotMounted; 1862 CMedium floppy = cmachine.GetMedium("FD", 0, 0); 1863 bool mounted = !floppy.isNull(); 1865 1864 mDevicesUnmountFloppyAction->setEnabled (isRunningOrPaused && mounted); 1866 1865 fd_light->setState (mounted ? KDeviceActivity_Idle : KDeviceActivity_Null); … … 1868 1867 "%1</qt>", 1869 1868 "Floppy tooltip"); 1869 #if 0 1870 /// @todo MEDIUM resurrect host dvd/floppy stuff deleted in r51247 1871 #endif 1870 1872 QString name; 1871 switch (state) 1872 { 1873 case KDriveState_HostDriveCaptured: 1874 { 1875 CHostFloppyDrive drv = floppy.GetHostDrive(); 1876 QString drvName = drv.GetName(); 1877 QString description = drv.GetDescription(); 1878 QString fullName = description.isEmpty() ? 1879 drvName : 1880 QString ("%1 (%2)").arg (description, drvName); 1881 name = tr ("<br><nobr><b>Host Drive</b>: %1</nobr>", 1882 "Floppy tooltip").arg (fullName); 1883 break; 1884 } 1885 case KDriveState_ImageMounted: 1886 { 1887 name = tr ("<br><nobr><b>Image</b>: %1</nobr>", 1888 "Floppy tooltip") 1889 .arg (QDir::toNativeSeparators (floppy.GetImage().GetLocation())); 1890 break; 1891 } 1892 case KDriveState_NotMounted: 1893 { 1894 name = tr ("<br><nobr><b>No media mounted</b></nobr>", 1895 "Floppy tooltip"); 1896 break; 1897 } 1898 default: 1899 AssertMsgFailed (("Invalid floppy drive state: %d\n", state)); 1900 } 1873 if (mounted) 1874 name = tr ("<br><nobr><b>Image</b>: %1</nobr>", 1875 "Floppy tooltip") 1876 .arg (QDir::toNativeSeparators (floppy.GetLocation())); 1877 else 1878 name = tr ("<br><nobr><b>No media mounted</b></nobr>", 1879 "Floppy tooltip"); 1901 1880 fd_light->setToolTip (tip.arg (name)); 1902 1881 } … … 1904 1883 { 1905 1884 mDevicesMountDVDMenu->setEnabled (isRunningOrPaused); 1906 CDVDDrive dvd = cmachine.GetDVDDrive(); 1907 KDriveState state = dvd.GetState(); 1908 bool mounted = state != KDriveState_NotMounted; 1885 CMedium dvd = cmachine.GetMedium("IDE", 1, 0); 1886 bool mounted = !dvd.isNull(); 1909 1887 mDevicesUnmountDVDAction->setEnabled (isRunningOrPaused && mounted); 1910 1888 cd_light->setState (mounted ? KDeviceActivity_Idle : KDeviceActivity_Null); … … 1912 1890 "%1</qt>", 1913 1891 "DVD-ROM tooltip"); 1892 #if 0 1893 /// @todo MEDIUM resurrect host dvd/floppy stuff deleted in r51247 1894 #endif 1914 1895 QString name; 1915 switch (state) 1916 { 1917 case KDriveState_HostDriveCaptured: 1918 { 1919 CHostDVDDrive drv = dvd.GetHostDrive(); 1920 QString drvName = drv.GetName(); 1921 QString description = drv.GetDescription(); 1922 QString fullName = description.isEmpty() ? 1923 drvName : 1924 QString ("%1 (%2)").arg (description, drvName); 1925 name = tr ("<br><nobr><b>Host Drive</b>: %1</nobr>", 1926 "DVD-ROM tooltip").arg (fullName); 1927 break; 1928 } 1929 case KDriveState_ImageMounted: 1930 { 1931 name = tr ("<br><nobr><b>Image</b>: %1</nobr>", 1932 "DVD-ROM tooltip") 1933 .arg (QDir::toNativeSeparators (dvd.GetImage().GetLocation())); 1934 break; 1935 } 1936 case KDriveState_NotMounted: 1937 { 1938 name = tr ("<br><nobr><b>No media mounted</b></nobr>", 1939 "DVD-ROM tooltip"); 1940 break; 1941 } 1942 default: 1943 AssertMsgFailed (("Invalid DVD drive state: %d\n", state)); 1944 } 1896 if (mounted) 1897 name = tr ("<br><nobr><b>Image</b>: %1</nobr>", 1898 "DVD-ROM tooltip") 1899 .arg (QDir::toNativeSeparators (dvd.GetLocation())); 1900 else 1901 name = tr ("<br><nobr><b>No media mounted</b></nobr>", 1902 "DVD-ROM tooltip"); 1945 1903 cd_light->setToolTip (tip.arg (name)); 1946 1904 } … … 1952 1910 QString data; 1953 1911 bool hasDisks = false; 1954 C HardDiskAttachmentVector vec = cmachine.GetHardDiskAttachments();1955 for (C HardDiskAttachmentVector::ConstIterator hda = vec.begin();1912 CMediumAttachmentVector vec = cmachine.GetMediumAttachments(); 1913 for (CMediumAttachmentVector::ConstIterator hda = vec.begin(); 1956 1914 hda != vec.end(); ++ hda) 1957 1915 { 1958 CHardDisk hd = hda->GetHardDisk(); 1916 if (hda->GetType() != KDeviceType_HardDisk) 1917 continue; 1918 1919 CMedium hd = hda->GetMedium(); 1959 1920 const QString ctlName = hda->GetController(); 1960 1921 CStorageController ctl = cmachine.GetStorageControllerByName(ctlName); … … 2830 2791 VBoxMediaManagerDlg dlg (this); 2831 2792 2832 dlg.setup (VBoxDefs::Medi aType_Floppy, true /* aDoSelect */,2793 dlg.setup (VBoxDefs::MediumType_Floppy, true /* aDoSelect */, 2833 2794 true /* aRefresh */, csession.GetMachine()); 2834 2795 2835 2796 if (dlg.exec() == QDialog::Accepted) 2836 2797 { 2837 C FloppyDrive drv = csession.GetMachine().GetFloppyDrive();2838 2839 drv.MountImage (dlg.selectedId());2840 2841 AssertWrapperOk ( drv);2842 if ( drv.isOk())2798 CMachine m = csession.GetMachine(); 2799 2800 m.MountMedium ("FD", 0, 0, dlg.selectedId()); 2801 2802 AssertWrapperOk (m); 2803 if (m.isOk()) 2843 2804 { 2844 2805 if (mIsAutoSaveMedia) 2845 2806 { 2846 CMachine m = csession.GetMachine();2847 2807 m.SaveSettings(); 2848 2808 if (!m.isOk()) … … 2857 2817 if (!console) return; 2858 2818 2859 C FloppyDrive drv = csession.GetMachine().GetFloppyDrive();2860 drv.Unmount();2861 if ( drv.isOk())2819 CMachine m = csession.GetMachine(); 2820 m.MountMedium ("FD", 0, 0, NULL); 2821 if (m.isOk()) 2862 2822 { 2863 2823 if (mIsAutoSaveMedia) 2864 2824 { 2865 CMachine m = csession.GetMachine();2866 2825 m.SaveSettings(); 2867 2826 if (!m.isOk()) … … 2870 2829 } 2871 2830 2872 if ( drv.GetState() != KDriveState_NotMounted)2831 if (!m.GetMedium ("FD", 0, 0).isNull()) 2873 2832 { 2874 2833 /* Looks like Main make no force unmounting here … … 2890 2849 VBoxMediaManagerDlg dlg (this); 2891 2850 2892 dlg.setup (VBoxDefs::Medi aType_DVD, true /* aDoSelect */,2851 dlg.setup (VBoxDefs::MediumType_DVD, true /* aDoSelect */, 2893 2852 true /* aRefresh */, csession.GetMachine()); 2894 2853 2895 2854 if (dlg.exec() == QDialog::Accepted) 2896 2855 { 2897 C DVDDrive drv = csession.GetMachine().GetDVDDrive();2898 2899 drv.MountImage (dlg.selectedId());2900 2901 AssertWrapperOk ( drv);2902 if ( drv.isOk())2856 CMachine m = csession.GetMachine(); 2857 2858 m.MountMedium ("IDE", 1, 0, dlg.selectedId()); 2859 2860 AssertWrapperOk (m); 2861 if (m.isOk()) 2903 2862 { 2904 2863 if (mIsAutoSaveMedia) 2905 2864 { 2906 CMachine m = csession.GetMachine();2907 2865 m.SaveSettings(); 2908 2866 if (!m.isOk()) … … 2918 2876 if (!console) return; 2919 2877 2920 C DVDDrive drv = csession.GetMachine().GetDVDDrive();2921 drv.Unmount();2922 AssertWrapperOk ( drv);2923 if ( drv.isOk())2878 CMachine m = csession.GetMachine(); 2879 m.MountMedium ("IDE", 1, 0, NULL); 2880 AssertWrapperOk (m); 2881 if (m.isOk()) 2924 2882 { 2925 2883 if (mIsAutoSaveMedia) 2926 2884 { 2927 CMachine m = csession.GetMachine();2928 2885 m.SaveSettings(); 2929 2886 if (!m.isOk()) … … 2932 2889 } 2933 2890 2934 if ( drv.GetState() != KDriveState_NotMounted)2891 if (!m.GetMedium("IDE", 1, 0).isNull()) 2935 2892 { 2936 2893 /* Looks like Main make no force unmounting here … … 2999 2956 .arg (vbox.GetVersion().remove ("_OSE")); 3000 2957 3001 C DVDImageVector vec = vbox.GetDVDImages();3002 for (C DVDImageVector::ConstIterator it = vec.begin();2958 CMediumVector vec = vbox.GetDVDImages(); 2959 for (CMediumVector::ConstIterator it = vec.begin(); 3003 2960 it != vec.end(); ++ it) 3004 2961 { … … 3032 2989 QString uuid; 3033 2990 3034 C DVDImageimage = vbox.FindDVDImage (aSource);2991 CMedium image = vbox.FindDVDImage (aSource); 3035 2992 if (image.isNull()) 3036 2993 { … … 3044 3001 if (!vbox.isOk()) 3045 3002 return vboxProblem().cannotOpenMedium (this, vbox, 3046 VBoxDefs::Medi aType_DVD, aSource);3003 VBoxDefs::MediumType_DVD, aSource); 3047 3004 3048 3005 Assert (!uuid.isNull()); 3049 C DVDDrive drv = csession.GetMachine().GetDVDDrive();3050 drv.MountImage (uuid);3051 AssertWrapperOk ( drv);3052 if ( drv.isOk())3006 CMachine m = csession.GetMachine(); 3007 m.MountMedium ("IDE", 1, 0, uuid); 3008 AssertWrapperOk (m); 3009 if (m.isOk()) 3053 3010 { 3054 3011 if (mIsAutoSaveMedia) 3055 3012 { 3056 CMachine m = csession.GetMachine();3057 3013 m.SaveSettings(); 3058 3014 if (!m.isOk()) … … 3164 3120 mDevicesMountFloppyMenu->clear(); 3165 3121 3166 C HostFloppyDrive selected = csession.GetMachine().GetFloppyDrive().GetHostDrive();3122 CMedium selected = csession.GetMachine().GetMedium("FD", 0, 0); 3167 3123 3168 3124 hostFloppyMap.clear(); 3169 C HostFloppyDriveVector drvvec =3125 CMediumVector drvvec = 3170 3126 vboxGlobal().virtualBox().GetHost().GetFloppyDrives(); 3171 3127 for (int i = 0; i < drvvec.size(); ++i) 3172 3128 { 3173 C HostFloppyDrivehostFloppy = drvvec[i];3129 CMedium hostFloppy = drvvec[i]; 3174 3130 /** @todo set icon */ 3175 3131 QString drvName = hostFloppy.GetName(); … … 3211 3167 mDevicesMountDVDMenu->clear(); 3212 3168 3213 C HostDVDDrive selected = csession.GetMachine().GetDVDDrive().GetHostDrive();3169 CMedium selected = csession.GetMachine().GetMedium("IDE", 2, 0); 3214 3170 3215 3171 hostDVDMap.clear(); 3216 C HostDVDDriveVector drvvec =3172 CMediumVector drvvec = 3217 3173 vboxGlobal().virtualBox().GetHost().GetDVDDrives(); 3218 3174 for (int i = 0; i < drvvec.size(); ++i) 3219 3175 { 3220 C HostDVDDrivehostDVD = drvvec[i];3176 CMedium hostDVD = drvvec[i]; 3221 3177 /** @todo set icon */ 3222 3178 QString drvName = hostDVD.GetName(); … … 3280 3236 if (!console) return; 3281 3237 3282 C HostFloppyDrived = hostFloppyMap [aAction];3238 CMedium d = hostFloppyMap [aAction]; 3283 3239 /* if null then some other item but host drive is selected */ 3284 3240 if (d.isNull()) return; 3285 3241 3286 C FloppyDrive drv = csession.GetMachine().GetFloppyDrive();3287 drv.CaptureHostDrive (d);3288 AssertWrapperOk ( drv);3289 3290 if ( drv.isOk())3242 CMachine m = csession.GetMachine(); 3243 m.MountMedium ("FD", 0, 0, d.GetId()); 3244 AssertWrapperOk (m); 3245 3246 if (m.isOk()) 3291 3247 { 3292 3248 if (mIsAutoSaveMedia) 3293 3249 { 3294 CMachine m = csession.GetMachine();3295 3250 m.SaveSettings(); 3296 3251 if (!m.isOk()) … … 3307 3262 if (!console) return; 3308 3263 3309 C HostDVDDrived = hostDVDMap [aAction];3264 CMedium d = hostDVDMap [aAction]; 3310 3265 /* if null then some other item but host drive is selected */ 3311 3266 if (d.isNull()) return; 3312 3267 3313 C DVDDrive drv = csession.GetMachine().GetDVDDrive();3314 drv.CaptureHostDrive (d);3315 AssertWrapperOk ( drv);3316 3317 if ( drv.isOk())3268 CMachine m = csession.GetMachine(); 3269 m.MountMedium ("IDE", 1, 0, d.GetId()); 3270 AssertWrapperOk (m); 3271 3272 if (m.isOk()) 3318 3273 { 3319 3274 if (mIsAutoSaveMedia) 3320 3275 { 3321 CMachine m = csession.GetMachine();3322 3276 m.SaveSettings(); 3323 3277 if (!m.isOk()) … … 3638 3592 } 3639 3593 3640 void VBoxConsoleWnd::updateMediaDriveState (VBoxDefs::Medi aType aType)3641 { 3642 Assert (aType == VBoxDefs::Medi aType_DVD || aType == VBoxDefs::MediaType_Floppy);3643 updateAppearanceOf (aType == VBoxDefs::Medi aType_DVD ? DVDStuff :3644 aType == VBoxDefs::Medi aType_Floppy ? FloppyStuff :3594 void VBoxConsoleWnd::updateMediaDriveState (VBoxDefs::MediumType aType) 3595 { 3596 Assert (aType == VBoxDefs::MediumType_DVD || aType == VBoxDefs::MediumType_Floppy); 3597 updateAppearanceOf (aType == VBoxDefs::MediumType_DVD ? DVDStuff : 3598 aType == VBoxDefs::MediumType_Floppy ? FloppyStuff : 3645 3599 AllStuff); 3646 3600 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r22816 r23223 389 389 } 390 390 391 STDMETHOD(OnMedi aRegistered) (IN_BSTR id, DeviceType_T type,392 BOOL registered)391 STDMETHOD(OnMediumRegistered) (IN_BSTR id, DeviceType_T type, 392 BOOL registered) 393 393 { 394 394 /** @todo */ … … 953 953 954 954 /** 955 * Returns a string representation of the given channel number on the given 956 * storage bus. Complementary to #toStorageChannel (KStorageBus, const 957 * QString &) const. 955 * Returns a string representation of the given channel number on the given storage bus. 956 * Complementary to #toStorageChannel (KStorageBus, const QString &) const. 958 957 */ 959 958 QString VBoxGlobal::toString (KStorageBus aBus, LONG aChannel) const … … 970 969 break; 971 970 } 972 973 AssertMsgFailedBreak (("Invalid channel %d\n", aChannel));971 AssertMsgFailed (("Invalid IDE channel %d\n", aChannel)); 972 break; 974 973 } 975 974 case KStorageBus_SATA: 975 case KStorageBus_SCSI: 976 976 { 977 977 channel = mStorageBusChannels [2].arg (aChannel); 978 978 break; 979 979 } 980 case KStorageBus_ SCSI:981 { 982 channel = mStorageBusChannels [2].arg (aChannel);980 case KStorageBus_Floppy: 981 { 982 AssertMsgFailed (("Floppy have no channels, only devices\n")); 983 983 break; 984 984 } 985 985 default: 986 AssertFailedBreak(); 986 { 987 AssertMsgFailed (("Invalid bus type %d\n", aBus)); 988 break; 989 } 987 990 } 988 991 … … 992 995 993 996 /** 994 * Returns a channel number on the given storage bus corresponding to the given 995 * string representation.Complementary to #toString (KStorageBus, LONG) const.997 * Returns a channel number on the given storage bus corresponding to the given string representation. 998 * Complementary to #toString (KStorageBus, LONG) const. 996 999 */ 997 1000 LONG VBoxGlobal::toStorageChannel (KStorageBus aBus, const QString &aChannel) const … … 1003 1006 case KStorageBus_IDE: 1004 1007 { 1005 QLongStringHash::const_iterator it = 1006 qFind (mStorageBusChannels.begin(), mStorageBusChannels.end(), 1007 aChannel); 1008 AssertMsgBreak (it != mStorageBusChannels.end(), 1009 ("No value for {%s}\n", aChannel.toLatin1().constData())); 1008 QLongStringHash::const_iterator it = qFind (mStorageBusChannels.begin(), mStorageBusChannels.end(), aChannel); 1009 AssertMsgBreak (it != mStorageBusChannels.end(), ("No value for {%s}\n", aChannel.toLatin1().constData())); 1010 1010 channel = it.key(); 1011 1011 break; … … 1014 1014 case KStorageBus_SCSI: 1015 1015 { 1016 /// @todo use regexp to properly extract the %1 text1017 1016 QString tpl = mStorageBusChannels [2].arg (""); 1018 1017 if (aChannel.startsWith (tpl)) … … 1021 1020 break; 1022 1021 } 1023 1024 AssertMsgFailedBreak (("Invalid channel {%s}\n", aChannel.toLatin1().constData())); 1022 AssertMsgFailed (("Invalid channel {%s}\n", aChannel.toLatin1().constData())); 1025 1023 break; 1026 1024 } 1025 case KStorageBus_Floppy: 1026 { 1027 channel = 0; 1028 break; 1029 } 1027 1030 default: 1028 AssertFailedBreak(); 1031 { 1032 AssertMsgFailed (("Invalid bus type %d\n", aBus)); 1033 break; 1034 } 1029 1035 } 1030 1036 … … 1033 1039 1034 1040 /** 1035 * Returns a string representation of the given device number of the given 1036 * channel on the given storage bus. Complementary to #toStorageDevice 1037 * (KStorageBus, LONG, const QString &) const. 1041 * Returns a string representation of the given device number of the given channel on the given storage bus. 1042 * Complementary to #toStorageDevice (KStorageBus, LONG, const QString &) const. 1038 1043 */ 1039 1044 QString VBoxGlobal::toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const … … 1052 1057 break; 1053 1058 } 1054 1055 AssertMsgFailedBreak (("Invalid device %d\n", aDevice));1059 AssertMsgFailed (("Invalid device %d\n", aDevice)); 1060 break; 1056 1061 } 1057 1062 case KStorageBus_SATA: 1058 1063 case KStorageBus_SCSI: 1059 1064 { 1060 AssertMsgBreak (aDevice == 0, ("Invalid device %d\n", aDevice)); 1061 /* always empty so far for SATA */ 1062 device = ""; 1065 AssertMsgFailed (("SATA & SCSI have no devices, only channels\n")); 1063 1066 break; 1064 1067 } 1068 case KStorageBus_Floppy: 1069 { 1070 AssertMsgBreak (aChannel == 0, ("Invalid channel %d\n", aChannel)); 1071 device = mStorageBusDevices [2].arg (aDevice); 1072 break; 1073 } 1065 1074 default: 1066 AssertFailedBreak(); 1075 { 1076 AssertMsgFailed (("Invalid bus type %d\n", aBus)); 1077 break; 1078 } 1067 1079 } 1068 1080 … … 1072 1084 1073 1085 /** 1074 * Returns a device number of the given channel on the given storage bus 1075 * corresponding to the given string representation. Complementary to #toString 1076 * (KStorageBus, LONG, LONG) const. 1077 */ 1078 LONG VBoxGlobal::toStorageDevice (KStorageBus aBus, LONG aChannel, 1079 const QString &aDevice) const 1086 * Returns a device number of the given channel on the given storage bus corresponding to the given string representation. 1087 * Complementary to #toString (KStorageBus, LONG, LONG) const. 1088 */ 1089 LONG VBoxGlobal::toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const 1080 1090 { 1081 1091 NOREF (aChannel); … … 1087 1097 case KStorageBus_IDE: 1088 1098 { 1089 QLongStringHash::const_iterator it = 1090 qFind (mStorageBusDevices.begin(), mStorageBusDevices.end(), 1091 aDevice); 1092 AssertMsg (it != mStorageBusDevices.end(), 1093 ("No value for {%s}", aDevice.toLatin1().constData())); 1099 QLongStringHash::const_iterator it = qFind (mStorageBusDevices.begin(), mStorageBusDevices.end(), aDevice); 1100 AssertMsgBreak (it != mStorageBusDevices.end(), ("No value for {%s}", aDevice.toLatin1().constData())); 1094 1101 device = it.key(); 1095 1102 break; … … 1098 1105 case KStorageBus_SCSI: 1099 1106 { 1100 AssertMsgBreak(aDevice.isEmpty(), ("Invalid device {%s}\n", aDevice.toLatin1().constData())); 1101 /* always zero for SATA so far. */ 1107 device = 0; 1102 1108 break; 1103 1109 } 1110 case KStorageBus_Floppy: 1111 { 1112 AssertMsgBreak (aChannel == 0, ("Invalid channel %d\n", aChannel)); 1113 QString tpl = mStorageBusDevices [2].arg (""); 1114 if (aDevice.startsWith (tpl)) 1115 { 1116 device = aDevice.right (aDevice.length() - tpl.length()).toLong(); 1117 break; 1118 } 1119 AssertMsgFailed (("Invalid device {%s}\n", aDevice.toLatin1().constData())); 1120 break; 1121 } 1104 1122 default: 1105 AssertFailedBreak(); 1123 { 1124 AssertMsgFailed (("Invalid bus type %d\n", aBus)); 1125 break; 1126 } 1106 1127 } 1107 1128 … … 1110 1131 1111 1132 /** 1112 * Returns a full string representation of the given device of the given channel 1113 * on the given storage bus. Complementary to #toStorageParams (KStorageBus, 1114 * LONG, LONG) const. 1115 */ 1116 QString VBoxGlobal::toFullString (KStorageBus aBus, LONG aChannel, 1117 LONG aDevice) const 1118 { 1119 QString device; 1120 1121 switch (aBus) 1133 * Returns a full string representation of the given device of the given channel on the given storage bus. 1134 * Complementary to #toStorageSlot (const QString &) const. 1135 */ 1136 QString VBoxGlobal::toFullString (StorageSlot aSlot) const 1137 { 1138 QString device (vboxGlobal().toString (aSlot.bus) + ' '); 1139 1140 switch (aSlot.bus) 1122 1141 { 1123 1142 case KStorageBus_IDE: 1124 1143 { 1125 device = QString ("%1 %2 %3") 1126 .arg (vboxGlobal().toString (aBus)) 1127 .arg (vboxGlobal().toString (aBus, aChannel)) 1128 .arg (vboxGlobal().toString (aBus, aChannel, aDevice)); 1144 device += vboxGlobal().toString (aSlot.bus, aSlot.port) + ' ' + 1145 vboxGlobal().toString (aSlot.bus, aSlot.port, aSlot.device); 1129 1146 break; 1130 1147 } … … 1132 1149 case KStorageBus_SCSI: 1133 1150 { 1134 /* we only have one SATA/SCSI device so far which is always zero */ 1135 device = QString ("%1 %2") 1136 .arg (vboxGlobal().toString (aBus)) 1137 .arg (vboxGlobal().toString (aBus, aChannel)); 1151 device += vboxGlobal().toString (aSlot.bus, aSlot.port); 1138 1152 break; 1139 1153 } 1154 case KStorageBus_Floppy: 1155 { 1156 device += vboxGlobal().toString (aSlot.bus, aSlot.port, aSlot.device); 1157 break; 1158 } 1140 1159 default: 1141 AssertFailedBreak(); 1160 { 1161 AssertMsgFailed (("Invalid bus type %d\n", aSlot.bus)); 1162 break; 1163 } 1142 1164 } 1143 1165 1144 1166 return device; 1167 } 1168 1169 /** 1170 * Returns a StorageSlot based on the given device of the given channel on the given storage bus. 1171 * Complementary to #toFullString (StorageSlot) const. 1172 */ 1173 StorageSlot VBoxGlobal::toStorageSlot (const QString &aSlot) const 1174 { 1175 StorageSlot result; 1176 1177 result.bus = toStorageBusType (aSlot.section (' ', 0, 0)); 1178 QString other (aSlot.section (' ', 1)); 1179 1180 switch (result.bus) 1181 { 1182 case KStorageBus_IDE: 1183 { 1184 result.port = toStorageChannel (result.bus, other.section (' ', 0, 0)); 1185 result.device = toStorageDevice (result.bus, result.port, other.section (' ', 1)); 1186 break; 1187 } 1188 case KStorageBus_SATA: 1189 case KStorageBus_SCSI: 1190 { 1191 result.port = toStorageChannel (result.bus, other); 1192 result.device = toStorageDevice (result.bus, result.port, QString::null); 1193 break; 1194 } 1195 case KStorageBus_Floppy: 1196 { 1197 result.port = toStorageChannel (result.bus, QString::null); 1198 result.device = toStorageDevice (result.bus, result.port, other); 1199 break; 1200 } 1201 default: 1202 { 1203 AssertMsgFailed (("Invalid bus type %d\n", result.bus)); 1204 break; 1205 } 1206 } 1207 1208 return result; 1145 1209 } 1146 1210 … … 1291 1355 * @todo in VBoxMedium::details()). 1292 1356 */ 1293 QString VBoxGlobal::details (const CHardDisk &aHD, 1294 bool aPredictDiff) 1295 { 1296 CMedium cmedium (aHD); 1357 QString VBoxGlobal::details (const CMedium &aMedium, bool aPredictDiff) 1358 { 1359 CMedium cmedium (aMedium); 1297 1360 VBoxMedium medium; 1298 1361 1299 1362 if (!findMedium (cmedium, medium)) 1300 1363 { 1301 /* media may be new and not alredy in the media list, request refresh */1364 /* Medium may be new and not already in the media list, request refresh */ 1302 1365 startEnumeratingMedia(); 1303 1366 if (!findMedium (cmedium, medium)) 1304 { 1305 /// @todo Still not found. Means that we are trying to get details 1306 /// of a hard disk that was deleted by a third party before we got a 1307 /// chance to complete the task. Returning null in this case should 1308 /// be OK, For more information, see *** in VBoxMedium::etails(). 1309 return QString::null; 1310 } 1367 /* Medium might be deleted already, return null string */ 1368 return QString(); 1311 1369 } 1312 1370 … … 1597 1655 } 1598 1656 1599 /* Hard Disks*/1657 /* Storage */ 1600 1658 { 1601 1659 /* Rows including section header and footer */ … … 1604 1662 QString item; 1605 1663 1606 C HardDiskAttachmentVector vec = aMachine.GetHardDiskAttachments();1664 CMediumAttachmentVector vec = aMachine.GetMediumAttachments(); 1607 1665 for (int i = 0; i < vec.size(); ++ i) 1608 1666 { 1609 C HardDiskAttachment hda = vec [i];1610 C HardDisk hd = hda.GetHardDisk();1667 CMediumAttachment ma = vec [i]; 1668 CMedium medium = ma.GetMedium(); 1611 1669 1612 1670 /// @todo for the explaination of the below isOk() checks, see *** 1613 1671 /// in VBoxMedium::details(). 1614 if ( hda.isOk())1672 if (ma.isOk()) 1615 1673 { 1616 const QString controller = hda.GetController();1674 const QString controller = ma.GetController(); 1617 1675 KStorageBus bus; 1618 1676 1619 CStorageController ctrl = aMachine.GetStorageControllerByName (controller);1677 CStorageController ctrl = aMachine.GetStorageControllerByName (controller); 1620 1678 bus = ctrl.GetBus(); 1621 1679 1622 LONG port = hda.GetPort();1623 LONG device = hda.GetDevice();1680 LONG port = ma.GetPort(); 1681 LONG device = ma.GetDevice(); 1624 1682 item += QString (sSectionItemTpl2) 1625 .arg (toFullString ( bus, port, device))1626 .arg (details ( hd, false));1683 .arg (toFullString (StorageSlot (bus, port, device))) 1684 .arg (details (medium, false)); 1627 1685 ++ rows; 1628 1686 } … … 1632 1690 { 1633 1691 item = QString (sSectionItemTpl1) 1634 .arg (tr ("Not Attached", "details report ( HDDs)"));1692 .arg (tr ("Not Attached", "details report (Storage)")); 1635 1693 ++ rows; 1636 1694 } … … 1639 1697 .arg (rows) /* rows */ 1640 1698 .arg (":/hd_16px.png", /* icon */ 1641 "#hdds", /* link */ 1642 tr ("Hard Disks", "details report"), /* title */ 1643 item); /* items */ 1644 } 1645 1646 /* DVD */ 1647 { 1648 QString item; 1649 1650 CDVDDrive dvd = aMachine.GetDVDDrive(); 1651 switch (dvd.GetState()) 1652 { 1653 case KDriveState_NotMounted: 1654 item = QString (sSectionItemTpl1) 1655 .arg (tr ("Not mounted", "details report (DVD)")); 1656 break; 1657 case KDriveState_ImageMounted: 1658 { 1659 CDVDImage img = dvd.GetImage(); 1660 item = QString (sSectionItemTpl2) 1661 .arg (tr ("Image", "details report (DVD)"), 1662 locationForHTML (img.GetName())); 1663 break; 1664 } 1665 case KDriveState_HostDriveCaptured: 1666 { 1667 CHostDVDDrive drv = dvd.GetHostDrive(); 1668 QString drvName = drv.GetName(); 1669 QString description = drv.GetDescription(); 1670 QString fullName = description.isEmpty() ? 1671 drvName : 1672 QString ("%1 (%2)").arg (description, drvName); 1673 item = QString (sSectionItemTpl2) 1674 .arg (tr ("Host Drive", "details report (DVD)"), 1675 fullName); 1676 break; 1677 } 1678 default: 1679 AssertMsgFailed (("Invalid DVD state: %d", dvd.GetState())); 1680 } 1681 1682 report += sectionTpl 1683 .arg (2 + 1) /* rows */ 1684 .arg (":/cd_16px.png", /* icon */ 1685 "#dvd", /* link */ 1686 tr ("CD/DVD-ROM", "details report"), /* title */ 1687 item); // items 1688 } 1689 1690 /* Floppy */ 1691 { 1692 QString item; 1693 1694 CFloppyDrive floppy = aMachine.GetFloppyDrive(); 1695 switch (floppy.GetState()) 1696 { 1697 case KDriveState_NotMounted: 1698 item = QString (sSectionItemTpl1) 1699 .arg (tr ("Not mounted", "details report (floppy)")); 1700 break; 1701 case KDriveState_ImageMounted: 1702 { 1703 CFloppyImage img = floppy.GetImage(); 1704 item = QString (sSectionItemTpl2) 1705 .arg (tr ("Image", "details report (floppy)"), 1706 locationForHTML (img.GetName())); 1707 break; 1708 } 1709 case KDriveState_HostDriveCaptured: 1710 { 1711 CHostFloppyDrive drv = floppy.GetHostDrive(); 1712 QString drvName = drv.GetName(); 1713 QString description = drv.GetDescription(); 1714 QString fullName = description.isEmpty() ? 1715 drvName : 1716 QString ("%1 (%2)").arg (description, drvName); 1717 item = QString (sSectionItemTpl2) 1718 .arg (tr ("Host Drive", "details report (floppy)"), 1719 fullName); 1720 break; 1721 } 1722 default: 1723 AssertMsgFailed (("Invalid floppy state: %d", floppy.GetState())); 1724 } 1725 1726 report += sectionTpl 1727 .arg (2 + 1) /* rows */ 1728 .arg (":/fd_16px.png", /* icon */ 1729 "#floppy", /* link */ 1730 tr ("Floppy", "details report"), /* title */ 1699 "#storage", /* link */ 1700 tr ("Storage", "details report"), /* title */ 1731 1701 item); /* items */ 1732 1702 } … … 2179 2149 2180 2150 /** 2181 * Appends the given list of hard disks and all their children to the media 2182 * list. To be called only from VBoxGlobal::startEnumeratingMedia(). 2183 */ 2184 static 2185 void AddHardDisksToList (const CHardDiskVector &aVector, 2186 VBoxMediaList &aList, 2187 VBoxMediaList::iterator aWhere, 2188 VBoxMedium *aParent = 0) 2151 * Appends the NULL medium to the media list. 2152 * For using with VBoxGlobal::startEnumeratingMedia() only. 2153 */ 2154 static void addNullMediumToList (VBoxMediaList &aList, VBoxMediaList::iterator aWhere) 2155 { 2156 VBoxMedium medium; 2157 aList.insert (aWhere, medium); 2158 } 2159 2160 /** 2161 * Appends the given list of mediums to the media list. 2162 * For using with VBoxGlobal::startEnumeratingMedia() only. 2163 */ 2164 static void addMediumsToList (const CMediumVector &aVector, 2165 VBoxMediaList &aList, 2166 VBoxMediaList::iterator aWhere, 2167 VBoxDefs::MediumType aType, 2168 VBoxMedium *aParent = 0) 2189 2169 { 2190 2170 VBoxMediaList::iterator first = aWhere; 2191 2171 2192 /* First pass: Add siblings sorted */ 2193 for (CHardDiskVector::ConstIterator it = aVector.begin(); 2194 it != aVector.end(); ++ it) 2172 for (CMediumVector::ConstIterator it = aVector.begin(); it != aVector.end(); ++ it) 2195 2173 { 2196 2174 CMedium cmedium (*it); 2197 VBoxMedium medium (cmedium, VBoxDefs::MediaType_HardDisk, aParent);2175 VBoxMedium medium (cmedium, aType, aParent); 2198 2176 2199 2177 /* Search for a proper alphabetic position */ … … 2209 2187 -- first; 2210 2188 } 2189 } 2190 2191 /** 2192 * Appends the given list of hard disks and all their children to the media list. 2193 * For using with VBoxGlobal::startEnumeratingMedia() only. 2194 */ 2195 static void addHardDisksToList (const CMediumVector &aVector, 2196 VBoxMediaList &aList, 2197 VBoxMediaList::iterator aWhere, 2198 VBoxMedium *aParent = 0) 2199 { 2200 VBoxMediaList::iterator first = aWhere; 2201 2202 /* First pass: Add siblings sorted */ 2203 for (CMediumVector::ConstIterator it = aVector.begin(); it != aVector.end(); ++ it) 2204 { 2205 CMedium cmedium (*it); 2206 VBoxMedium medium (cmedium, VBoxDefs::MediumType_HardDisk, aParent); 2207 2208 /* Search for a proper alphabetic position */ 2209 VBoxMediaList::iterator jt = first; 2210 for (; jt != aWhere; ++ jt) 2211 if ((*jt).name().localeAwareCompare (medium.name()) > 0) 2212 break; 2213 2214 aList.insert (jt, medium); 2215 2216 /* Adjust the first item if inserted before it */ 2217 if (jt == first) 2218 -- first; 2219 } 2211 2220 2212 2221 /* Second pass: Add children */ 2213 2222 for (VBoxMediaList::iterator it = first; it != aWhere;) 2214 2223 { 2215 C HardDiskVector children = (*it).hardDisk().GetChildren();2224 CMediumVector children = (*it).medium().GetChildren(); 2216 2225 VBoxMedium *parent = &(*it); 2217 2226 2218 2227 ++ it; /* go to the next sibling before inserting children */ 2219 AddHardDisksToList (children, aList, it, parent);2228 addHardDisksToList (children, aList, it, parent); 2220 2229 } 2221 2230 } … … 2264 2273 /* composes a list of all currently known media & their children */ 2265 2274 mMediaList.clear(); 2266 { 2267 AddHardDisksToList (mVBox.GetHardDisks(), mMediaList, mMediaList.end()); 2268 } 2269 { 2270 VBoxMediaList::iterator first = mMediaList.end(); 2271 2272 CDVDImageVector vec = mVBox.GetDVDImages(); 2273 for (CDVDImageVector::ConstIterator it = vec.begin(); 2274 it != vec.end(); ++ it) 2275 { 2276 CMedium cmedium (*it); 2277 VBoxMedium medium (cmedium, VBoxDefs::MediaType_DVD); 2278 2279 /* Search for a proper alphabetic position */ 2280 VBoxMediaList::iterator jt = first; 2281 for (; jt != mMediaList.end(); ++ jt) 2282 if ((*jt).name().localeAwareCompare (medium.name()) > 0) 2283 break; 2284 2285 mMediaList.insert (jt, medium); 2286 2287 /* Adjust the first item if inserted before it */ 2288 if (jt == first) 2289 -- first; 2290 } 2291 } 2292 { 2293 VBoxMediaList::iterator first = mMediaList.end(); 2294 2295 CFloppyImageVector vec = mVBox.GetFloppyImages(); 2296 for (CFloppyImageVector::ConstIterator it = vec.begin(); 2297 it != vec.end(); ++ it) 2298 { 2299 CMedium cmedium (*it); 2300 VBoxMedium medium (cmedium, VBoxDefs::MediaType_Floppy); 2301 2302 /* Search for a proper alphabetic position */ 2303 VBoxMediaList::iterator jt = first; 2304 for (; jt != mMediaList.end(); ++ jt) 2305 if ((*jt).name().localeAwareCompare (medium.name()) > 0) 2306 break; 2307 2308 mMediaList.insert (jt, medium); 2309 2310 /* Adjust the first item if inserted before it */ 2311 if (jt == first) 2312 -- first; 2313 } 2314 } 2275 addNullMediumToList (mMediaList, mMediaList.end()); 2276 addHardDisksToList (mVBox.GetHardDisks(), mMediaList, mMediaList.end()); 2277 addMediumsToList (mVBox.GetHost().GetDVDDrives(), mMediaList, mMediaList.end(), VBoxDefs::MediumType_DVD); 2278 addMediumsToList (mVBox.GetDVDImages(), mMediaList, mMediaList.end(), VBoxDefs::MediumType_DVD); 2279 addMediumsToList (mVBox.GetHost().GetFloppyDrives(), mMediaList, mMediaList.end(), VBoxDefs::MediumType_Floppy); 2280 addMediumsToList (mVBox.GetFloppyImages(), mMediaList, mMediaList.end(), VBoxDefs::MediumType_Floppy); 2315 2281 2316 2282 /* enumeration thread class */ … … 2382 2348 VBoxMediaList::iterator it = mMediaList.begin(); 2383 2349 2384 if (aMedium.type() == VBoxDefs::Medi aType_HardDisk)2350 if (aMedium.type() == VBoxDefs::MediumType_HardDisk) 2385 2351 { 2386 2352 VBoxMediaList::iterator parent = mMediaList.end(); … … 2388 2354 for (; it != mMediaList.end(); ++ it) 2389 2355 { 2390 if ((*it).type() != VBoxDefs::Medi aType_HardDisk)2356 if ((*it).type() != VBoxDefs::MediumType_HardDisk) 2391 2357 break; 2392 2358 … … 2417 2383 { 2418 2384 /* skip HardDisks that come first */ 2419 if ((*it).type() == VBoxDefs::Medi aType_HardDisk)2385 if ((*it).type() == VBoxDefs::MediumType_HardDisk) 2420 2386 continue; 2421 2387 2422 2388 /* skip DVD when inserting Floppy */ 2423 if (aMedium.type() == VBoxDefs::Medi aType_Floppy &&2424 (*it).type() == VBoxDefs::Medi aType_DVD)2389 if (aMedium.type() == VBoxDefs::MediumType_Floppy && 2390 (*it).type() == VBoxDefs::MediumType_DVD) 2425 2391 continue; 2426 2392 2427 2393 if ((*it).name().localeAwareCompare (aMedium.name()) > 0 || 2428 (aMedium.type() == VBoxDefs::Medi aType_DVD &&2429 (*it).type() == VBoxDefs::Medi aType_Floppy))2394 (aMedium.type() == VBoxDefs::MediumType_DVD && 2395 (*it).type() == VBoxDefs::MediumType_Floppy)) 2430 2396 break; 2431 2397 } … … 2464 2430 * @sa #currentMediaList() 2465 2431 */ 2466 void VBoxGlobal::removeMedium (VBoxDefs::Medi aType aType, const QString &aId)2432 void VBoxGlobal::removeMedium (VBoxDefs::MediumType aType, const QString &aId) 2467 2433 { 2468 2434 VBoxMediaList::Iterator it; … … 2506 2472 bool VBoxGlobal::findMedium (const CMedium &aObj, VBoxMedium &aMedium) const 2507 2473 { 2508 for (VBoxMediaList::ConstIterator it = mMediaList.begin(); 2509 it != mMediaList.end(); ++ it)2510 {2511 if ((*it).medium() == aObj)2474 for (VBoxMediaList::ConstIterator it = mMediaList.begin(); it != mMediaList.end(); ++ it) 2475 { 2476 if (((*it).medium().isNull() && aObj.isNull()) || 2477 (!(*it).medium().isNull() && !aObj.isNull() && (*it).medium().GetId() == aObj.GetId())) 2512 2478 { 2513 2479 aMedium = (*it); … … 2515 2481 } 2516 2482 } 2517 2518 2483 return false; 2484 } 2485 2486 /** 2487 * Searches for a VBoxMedum object with the given medium id attribute. 2488 * 2489 * @return VBoxMedum if found which is invalid otherwise. 2490 */ 2491 VBoxMedium VBoxGlobal::findMedium (const QString &aMediumId) const 2492 { 2493 for (VBoxMediaList::ConstIterator it = mMediaList.begin(); it != mMediaList.end(); ++ it) 2494 if ((*it).id() == aMediumId) 2495 return *it; 2496 return VBoxMedium(); 2519 2497 } 2520 2498 … … 2623 2601 mDeviceTypes [KDeviceType_SharedFolder] = tr ("Shared Folder", "DeviceType"); 2624 2602 2625 mStorageBuses [KStorageBus_IDE] = tr ("IDE", "StorageBus"); 2626 mStorageBuses [KStorageBus_SATA] = tr ("SATA", "StorageBus"); 2627 mStorageBuses [KStorageBus_SCSI] = tr ("SCSI", "StorageBus"); 2603 mStorageBuses [KStorageBus_IDE] = tr ("IDE", "StorageBus"); 2604 mStorageBuses [KStorageBus_SATA] = tr ("SATA", "StorageBus"); 2605 mStorageBuses [KStorageBus_SCSI] = tr ("SCSI", "StorageBus"); 2606 mStorageBuses [KStorageBus_Floppy] = tr ("Floppy", "StorageBus"); 2628 2607 2629 2608 mStorageBusChannels [0] = tr ("Primary", "StorageBusChannel"); … … 2633 2612 mStorageBusDevices [0] = tr ("Master", "StorageBusDevice"); 2634 2613 mStorageBusDevices [1] = tr ("Slave", "StorageBusDevice"); 2635 2636 mDiskTypes [KHardDiskType_Normal] = tr ("Normal", "DiskType"); 2637 mDiskTypes [KHardDiskType_Immutable] = tr ("Immutable", "DiskType"); 2638 mDiskTypes [KHardDiskType_Writethrough] = tr ("Writethrough", "DiskType"); 2614 mStorageBusDevices [2] = tr ("Device %1", "StorageBusDevice"); 2615 2616 mDiskTypes [KMediumType_Normal] = tr ("Normal", "DiskType"); 2617 mDiskTypes [KMediumType_Immutable] = tr ("Immutable", "DiskType"); 2618 mDiskTypes [KMediumType_Writethrough] = tr ("Writethrough", "DiskType"); 2639 2619 mDiskTypes_Differencing = tr ("Differencing", "DiskType"); 2640 2620 … … 2718 2698 mStorageControllerTypes [KStorageControllerType_BusLogic] = 2719 2699 tr ("BusLogic", "StorageControllerType"); 2700 mStorageControllerTypes [KStorageControllerType_I82078] = 2701 tr ("I82078", "StorageControllerType"); 2720 2702 2721 2703 mUSBDeviceStates [KUSBDeviceState_NotSupported] = … … 3013 2995 .arg (suffix); 3014 2996 return manual; 2997 } 2998 2999 QIcon VBoxGlobal::iconSet (const QPixmap &aNormal, 3000 const QPixmap &aDisabled, 3001 const QPixmap &aActive) 3002 { 3003 QIcon iconSet; 3004 3005 Assert (aNormal); 3006 iconSet.addPixmap (aNormal, QIcon::Normal); 3007 3008 if (!aDisabled.isNull()) 3009 iconSet.addPixmap (aDisabled, QIcon::Disabled); 3010 3011 if (!aActive.isNull()) 3012 iconSet.addPixmap (aActive, QIcon::Active); 3013 3014 return iconSet; 3015 3015 } 3016 3016 … … 4035 4035 { 4036 4036 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 4037 QVector<C HardDiskFormat> hardDiskFormats = systemProperties.GetHardDiskFormats();4037 QVector<CMediumFormat> mediumFormats = systemProperties.GetMediumFormats(); 4038 4038 QList< QPair<QString, QString> > backendPropList; 4039 for (int i = 0; i < hardDiskFormats.size(); ++ i)4039 for (int i = 0; i < mediumFormats.size(); ++ i) 4040 4040 { 4041 4041 /* File extensions */ 4042 QVector <QString> fileExtensions = hardDiskFormats [i].GetFileExtensions();4042 QVector <QString> fileExtensions = mediumFormats [i].GetFileExtensions(); 4043 4043 QStringList f; 4044 4044 for (int a = 0; a < fileExtensions.size(); ++ a) … … 4046 4046 /* Create a pair out of the backend description and all suffix's. */ 4047 4047 if (!f.isEmpty()) 4048 backendPropList << QPair<QString, QString> ( hardDiskFormats [i].GetName(), f.join(" "));4048 backendPropList << QPair<QString, QString> (mediumFormats [i].GetName(), f.join(" ")); 4049 4049 } 4050 4050 return backendPropList; … … 4231 4231 if (!ev->mLast) 4232 4232 { 4233 if (ev->mMedium.state() == KMedi aState_Inaccessible &&4233 if (ev->mMedium.state() == KMediumState_Inaccessible && 4234 4234 !ev->mMedium.result().isOk()) 4235 4235 vboxProblem().cannotGetMediaAccessibility (ev->mMedium); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaComboBox.cpp
r19256 r23223 29 29 VBoxMediaComboBox::VBoxMediaComboBox (QWidget *aParent) 30 30 : QComboBox (aParent) 31 , mType (VBoxDefs::Medi aType_Invalid)31 , mType (VBoxDefs::MediumType_Invalid) 32 32 , mLastId (QString::null) 33 33 , mShowDiffs (false) 34 , mNullItemPresent (false) 34 35 , mMachineId (QString::null) 35 36 { … … 51 52 connect (&vboxGlobal(), SIGNAL (mediumUpdated (const VBoxMedium &)), 52 53 this, SLOT (mediumUpdated (const VBoxMedium &))); 53 connect (&vboxGlobal(), SIGNAL (mediumRemoved (VBoxDefs::Medi aType, const QString &)),54 this, SLOT (mediumRemoved (VBoxDefs::Medi aType, const QString &)));54 connect (&vboxGlobal(), SIGNAL (mediumRemoved (VBoxDefs::MediumType, const QString &)), 55 this, SLOT (mediumRemoved (VBoxDefs::MediumType, const QString &))); 55 56 56 57 /* Setup other connections */ … … 134 135 } 135 136 136 void VBoxMediaComboBox::setType (VBoxDefs::Medi aType aType)137 void VBoxMediaComboBox::setType (VBoxDefs::MediumType aType) 137 138 { 138 139 mType = aType; … … 142 143 { 143 144 mMachineId = aMachineId; 145 } 146 147 void VBoxMediaComboBox::setNullItemPresent (bool aNullItemPresent) 148 { 149 mNullItemPresent = aNullItemPresent; 150 refresh(); 144 151 } 145 152 … … 180 187 void VBoxMediaComboBox::mediumAdded (const VBoxMedium &aMedium) 181 188 { 182 if (mType != aMedium.type()) 183 return; 184 185 if (!mShowDiffs && aMedium.type() == VBoxDefs::MediaType_HardDisk) 189 if ((aMedium.isNull() && mNullItemPresent && mType != VBoxDefs::MediumType_HardDisk) || 190 (aMedium.type() == mType)) 186 191 { 187 if ( aMedium.parent() != NULL)192 if (!mShowDiffs && aMedium.type() == VBoxDefs::MediumType_HardDisk) 188 193 { 189 /* In !mShowDiffs mode, we ignore all diffs except ones that are 190 * directly attached to the related VM in the current state */ 191 if (!aMedium.isAttachedInCurStateTo (mMachineId)) 192 return; 194 if (aMedium.parent() != NULL) 195 { 196 /* In !mShowDiffs mode, we ignore all diffs except ones that are 197 * directly attached to the related VM in the current state */ 198 if (!aMedium.isAttachedInCurStateTo (mMachineId)) 199 return; 200 } 193 201 } 202 203 appendItem (aMedium); 204 205 /* Activate the required item if there is any */ 206 if (aMedium.id() == mLastId) 207 setCurrentItem (aMedium.id()); 208 /* Select last added item if there is no item selected */ 209 else if (currentText().isEmpty()) 210 QComboBox::setCurrentIndex (count() - 1); 194 211 } 195 196 appendItem (aMedium);197 198 /* Activate the required item if there is any */199 if (aMedium.id() == mLastId)200 setCurrentItem (aMedium.id());201 /* Select last added item if there is no item selected */202 else if (currentText().isEmpty())203 QComboBox::setCurrentIndex (count() - 1);204 212 } 205 213 206 214 void VBoxMediaComboBox::mediumUpdated (const VBoxMedium &aMedium) 207 215 { 208 if (mType != aMedium.type()) 209 return; 210 211 int index; 212 if (!findMediaIndex (aMedium.id(), index)) 213 return; 214 215 replaceItem (index, aMedium); 216 217 /* Emit the signal to ensure the parent dialog handles the change of 218 * the selected item's data */ 219 emit activated (currentIndex()); 220 } 221 222 void VBoxMediaComboBox::mediumRemoved (VBoxDefs::MediaType aType, 216 if ((aMedium.isNull() && mNullItemPresent && mType != VBoxDefs::MediumType_HardDisk) || 217 (aMedium.type() == mType)) 218 { 219 int index; 220 if (!findMediaIndex (aMedium.id(), index)) 221 return; 222 223 replaceItem (index, aMedium); 224 225 /* Emit the signal to ensure the parent dialog handles the change of 226 * the selected item's data */ 227 emit activated (currentIndex()); 228 } 229 } 230 231 void VBoxMediaComboBox::mediumRemoved (VBoxDefs::MediumType aType, 223 232 const QString &aId) 224 233 { -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r22999 r23223 88 88 void refreshAll(); 89 89 90 VBoxDefs::Medi aType type() const { return mMedium.type(); }91 92 KMedi aState state() const { return mMedium.state (!mManager->showDiffs()); }90 VBoxDefs::MediumType type() const { return mMedium.type(); } 91 92 KMediumState state() const { return mMedium.state (!mManager->showDiffs()); } 93 93 94 94 QString id() const { return mMedium.id(); } … … 126 126 // { 127 127 // QColorGroup cGroup (aColorGroup); 128 // if (mStatus == KMedi aState_NotCreated)128 // if (mStatus == KMediumState_NotCreated) 129 129 // cGroup.setColor (QColorGroup::Text, cGroup.mid()); 130 130 // Q3ListViewItem::paintCell (aPainter, cGroup, aColumn, aWidth, aSlign); … … 234 234 Qt::WindowFlags aFlags /* = Qt::Dialog */) 235 235 : QIWithRetranslateUI2 <QIMainDialog> (aParent, aFlags) 236 , mType (VBoxDefs::Medi aType_Invalid)236 , mType (VBoxDefs::MediumType_Invalid) 237 237 , mShowDiffs (true) 238 238 , mSetupMode (false) … … 456 456 * a machine from its settings dialog. 457 457 * @param aSelectId Which medium to make selected? (ignored when @a 458 * aType is VBoxDefs::Medi aType_All)458 * aType is VBoxDefs::MediumType_All) 459 459 * @param aShowDiffs @c true to show differencing hard disks initially 460 460 * (ignored if @a aSessionMachine is null assuming 461 461 * @c true). 462 462 */ 463 void VBoxMediaManagerDlg::setup (VBoxDefs::Medi aType aType, bool aDoSelect,463 void VBoxMediaManagerDlg::setup (VBoxDefs::MediumType aType, bool aDoSelect, 464 464 bool aRefresh /* = true */, 465 465 const CMachine &aSessionMachine /* = CMachine() */, … … 479 479 switch (aType) 480 480 { 481 case VBoxDefs::Medi aType_HardDisk: mHDSelectedId = aSelectId; break;482 case VBoxDefs::Medi aType_DVD: mDVDSelectedId = aSelectId; break;483 case VBoxDefs::Medi aType_Floppy: mFloppySelectedId = aSelectId; break;484 case VBoxDefs::Medi aType_All: break;481 case VBoxDefs::MediumType_HardDisk: mHDSelectedId = aSelectId; break; 482 case VBoxDefs::MediumType_DVD: mDVDSelectedId = aSelectId; break; 483 case VBoxDefs::MediumType_Floppy: mFloppySelectedId = aSelectId; break; 484 case VBoxDefs::MediumType_All: break; 485 485 default: 486 486 AssertFailedReturnVoid(); … … 488 488 489 489 mTwImages->setTabEnabled (HDTab, 490 aType == VBoxDefs::Medi aType_All ||491 aType == VBoxDefs::Medi aType_HardDisk);490 aType == VBoxDefs::MediumType_All || 491 aType == VBoxDefs::MediumType_HardDisk); 492 492 mTwImages->setTabEnabled (CDTab, 493 aType == VBoxDefs::Medi aType_All ||494 aType == VBoxDefs::Medi aType_DVD);493 aType == VBoxDefs::MediumType_All || 494 aType == VBoxDefs::MediumType_DVD); 495 495 mTwImages->setTabEnabled (FDTab, 496 aType == VBoxDefs::Medi aType_All ||497 aType == VBoxDefs::Medi aType_Floppy);496 aType == VBoxDefs::MediumType_All || 497 aType == VBoxDefs::MediumType_Floppy); 498 498 499 499 mDoSelect = aDoSelect; … … 518 518 this, SLOT (mediumUpdated (const VBoxMedium &))); 519 519 /* Listen to "media remove" signals */ 520 connect (&vboxGlobal(), SIGNAL (mediumRemoved (VBoxDefs::Medi aType, const QString &)),521 this, SLOT (mediumRemoved (VBoxDefs::Medi aType, const QString &)));520 connect (&vboxGlobal(), SIGNAL (mediumRemoved (VBoxDefs::MediumType, const QString &)), 521 this, SLOT (mediumRemoved (VBoxDefs::MediumType, const QString &))); 522 522 523 523 if (aRefresh && !vboxGlobal().isMediaEnumerationStarted()) … … 533 533 { 534 534 mediumAdded (*it); 535 if ((*it).state() != KMedi aState_NotCreated)535 if ((*it).state() != KMediumState_NotCreated) 536 536 mProgressBar->setValue (++ index); 537 537 } … … 569 569 connect (vboxGlobal().mainWindow(), SIGNAL (closing()), mModelessDialog, SLOT (close())); 570 570 mModelessDialog->setAttribute (Qt::WA_DeleteOnClose); 571 mModelessDialog->setup (VBoxDefs::Medi aType_All,571 mModelessDialog->setup (VBoxDefs::MediumType_All, 572 572 false /* aDoSelect */, aRefresh); 573 573 … … 754 754 { 755 755 /* Ignore non-interesting aMedium */ 756 if (mType != VBoxDefs::MediaType_All && mType != aMedium.type()) 756 if ((aMedium.isNull()) || 757 (mType != VBoxDefs::MediumType_All && mType != aMedium.type()) || 758 (aMedium.isHostDrive())) 757 759 return; 758 760 759 if (!mShowDiffs && aMedium.type() == VBoxDefs::Medi aType_HardDisk)761 if (!mShowDiffs && aMedium.type() == VBoxDefs::MediumType_HardDisk) 760 762 { 761 763 if (aMedium.parent() && !mSessionMachineId.isNull()) … … 782 784 switch (aMedium.type()) 783 785 { 784 case VBoxDefs::Medi aType_HardDisk:786 case VBoxDefs::MediumType_HardDisk: 785 787 { 786 788 item = createHardDiskItem (mHardDiskView, aMedium); … … 799 801 break; 800 802 } 801 case VBoxDefs::Medi aType_DVD:803 case VBoxDefs::MediumType_DVD: 802 804 { 803 805 item = new MediaItem (mDVDView, aMedium, this); … … 816 818 break; 817 819 } 818 case VBoxDefs::Medi aType_Floppy:820 case VBoxDefs::MediumType_Floppy: 819 821 { 820 822 item = new MediaItem (mFloppyView, aMedium, this); … … 855 857 { 856 858 /* Ignore non-interesting aMedium */ 857 if (mType != VBoxDefs::MediaType_All && mType != aMedium.type()) 859 if ((aMedium.isNull()) || 860 (mType != VBoxDefs::MediumType_All && mType != aMedium.type()) || 861 (aMedium.isHostDrive())) 858 862 return; 859 863 … … 862 866 switch (aMedium.type()) 863 867 { 864 case VBoxDefs::Medi aType_HardDisk:868 case VBoxDefs::MediumType_HardDisk: 865 869 { 866 870 item = searchItem (mHardDiskView, aMedium.id()); 867 871 break; 868 872 } 869 case VBoxDefs::Medi aType_DVD:873 case VBoxDefs::MediumType_DVD: 870 874 { 871 875 item = searchItem (mDVDView, aMedium.id()); 872 876 break; 873 877 } 874 case VBoxDefs::Medi aType_Floppy:878 case VBoxDefs::MediumType_Floppy: 875 879 { 876 880 item = searchItem (mFloppyView, aMedium.id()); … … 896 900 } 897 901 898 void VBoxMediaManagerDlg::mediumRemoved (VBoxDefs::Medi aType aType,902 void VBoxMediaManagerDlg::mediumRemoved (VBoxDefs::MediumType aType, 899 903 const QString &aId) 900 904 { 901 905 /* Ignore non-interesting aMedium */ 902 if (mType != VBoxDefs::Medi aType_All && mType != aType)906 if (mType != VBoxDefs::MediumType_All && mType != aType) 903 907 return; 904 908 … … 963 967 void VBoxMediaManagerDlg::mediumEnumerated (const VBoxMedium &aMedium) 964 968 { 965 AssertReturnVoid (aMedium.state() != KMediaState_NotCreated);966 967 969 mediumUpdated (aMedium); 968 970 … … 982 984 void VBoxMediaManagerDlg::doNewMedium() 983 985 { 984 AssertReturnVoid (currentTreeWidgetType() == VBoxDefs::Medi aType_HardDisk);986 AssertReturnVoid (currentTreeWidgetType() == VBoxDefs::MediumType_HardDisk); 985 987 986 988 VBoxNewHDWzd dlg (this); … … 988 990 if (dlg.exec() == QDialog::Accepted) 989 991 { 990 C HardDiskhd = dlg.hardDisk();992 CMedium hd = dlg.hardDisk(); 991 993 /* Select the newly created hard disk */ 992 994 MediaItem *item = searchItem (mHardDiskView, hd.GetId()); … … 1003 1005 QString title; 1004 1006 QString filter; 1005 VBoxDefs::Medi aType type = currentTreeWidgetType();1007 VBoxDefs::MediumType type = currentTreeWidgetType(); 1006 1008 1007 1009 QString dir; 1008 if (item && item->state() != KMedi aState_Inaccessible1009 && item->state() != KMedi aState_NotCreated)1010 if (item && item->state() != KMediumState_Inaccessible 1011 && item->state() != KMediumState_NotCreated) 1010 1012 dir = QFileInfo (item->location().trimmed()).absolutePath(); 1011 1013 1012 1014 if (dir.isEmpty()) 1013 if (type == VBoxDefs::Medi aType_HardDisk)1015 if (type == VBoxDefs::MediumType_HardDisk) 1014 1016 dir = mVBox.GetSystemProperties().GetDefaultHardDiskFolder(); 1015 1017 … … 1019 1021 switch (type) 1020 1022 { 1021 case VBoxDefs::Medi aType_HardDisk:1023 case VBoxDefs::MediumType_HardDisk: 1022 1024 { 1023 1025 /// @todo NEWMEDIA use CSystemProperties::GetHardDIskFormats to detect … … 1042 1044 break; 1043 1045 } 1044 case VBoxDefs::Medi aType_DVD:1046 case VBoxDefs::MediumType_DVD: 1045 1047 { 1046 1048 filter = tr ("CD/DVD-ROM images (*.iso);;" … … 1049 1051 break; 1050 1052 } 1051 case VBoxDefs::Medi aType_Floppy:1053 case VBoxDefs::MediumType_Floppy: 1052 1054 { 1053 1055 filter = tr ("Floppy images (*.img);;" … … 1057 1059 } 1058 1060 default: 1059 AssertMsgFailed (("Selected tree should be equal to one item in VBoxDefs::Medi aType.\n"));1061 AssertMsgFailed (("Selected tree should be equal to one item in VBoxDefs::MediumType.\n")); 1060 1062 break; 1061 1063 } … … 1080 1082 QString id = item->id(); 1081 1083 AssertReturnVoid (!id.isNull()); 1082 VBoxDefs::Medi aType type = item->type();1084 VBoxDefs::MediumType type = item->type(); 1083 1085 1084 1086 if (!vboxProblem().confirmRemoveMedium (this, item->medium())) … … 1089 1091 switch (type) 1090 1092 { 1091 case VBoxDefs::Medi aType_HardDisk:1093 case VBoxDefs::MediumType_HardDisk: 1092 1094 { 1093 1095 bool deleteStorage = false; … … 1101 1103 * will give a corresponding hint. Therefore, once the code is 1102 1104 * changed below, the hint should be re-checked for validity. */ 1103 if (item->state() != KMedi aState_Inaccessible)1105 if (item->state() != KMediumState_Inaccessible) 1104 1106 { 1105 1107 int rc = vboxProblem(). … … 1110 1112 } 1111 1113 1112 C HardDisk hardDisk = item->medium().hardDisk();1114 CMedium hardDisk = item->medium().medium(); 1113 1115 1114 1116 if (deleteStorage) … … 1126 1128 1127 1129 if (success) 1128 vboxGlobal().removeMedium (VBoxDefs::Medi aType_HardDisk, id);1130 vboxGlobal().removeMedium (VBoxDefs::MediumType_HardDisk, id); 1129 1131 else 1130 1132 vboxProblem().cannotDeleteHardDiskStorage (this, hardDisk, … … 1141 1143 break; 1142 1144 } 1143 case VBoxDefs::Medi aType_DVD:1144 { 1145 C DVDImage image = item->medium().dvdImage();1145 case VBoxDefs::MediumType_DVD: 1146 { 1147 CMedium image = item->medium().medium(); 1146 1148 image.Close(); 1147 1149 result = image; 1148 1150 break; 1149 1151 } 1150 case VBoxDefs::Medi aType_Floppy:1151 { 1152 C FloppyImage image = item->medium().floppyImage();1152 case VBoxDefs::MediumType_Floppy: 1153 { 1154 CMedium image = item->medium().medium(); 1153 1155 image.Close(); 1154 1156 result = image; … … 1246 1248 switch (aMedium.type()) 1247 1249 { 1248 case VBoxDefs::Medi aType_HardDisk:1249 { 1250 C HardDiskAttachmentVector vec =machine.GetHardDiskAttachments();1250 case VBoxDefs::MediumType_HardDisk: 1251 { 1252 CMediumAttachmentVector vec = machine.GetMediumAttachments(); 1251 1253 for (int i = 0; i < vec.size(); ++ i) 1252 1254 { 1253 C HardDiskAttachment hda = vec [i];1254 if (hda.Get HardDisk().GetId() == aMedium.id())1255 CMediumAttachment hda = vec [i]; 1256 if (hda.GetMedium().GetId() == aMedium.id()) 1255 1257 { 1256 machine.Detach HardDisk(hda.GetController(),1257 1258 1258 machine.DetachDevice(hda.GetController(), 1259 hda.GetPort(), 1260 hda.GetDevice()); 1259 1261 if (!machine.isOk()) 1260 1262 { … … 1271 1273 break; 1272 1274 } 1273 case VBoxDefs::MediaType_DVD: 1274 { 1275 CDVDDrive drive = machine.GetDVDDrive(); 1276 drive.Unmount(); 1277 if (!drive.isOk()) 1275 case VBoxDefs::MediumType_DVD: 1276 { 1277 machine.MountMedium ("IDE", 1, 0, NULL); 1278 if (!machine.isOk()) 1278 1279 { 1279 1280 vboxProblem().cannotUnmountMedium (this, machine, aMedium, 1280 COMResult ( drive));1281 COMResult (machine)); 1281 1282 success = false; 1282 1283 } 1283 1284 break; 1284 1285 } 1285 case VBoxDefs::MediaType_Floppy: 1286 { 1287 CFloppyDrive drive = machine.GetFloppyDrive(); 1288 drive.Unmount(); 1289 if (!drive.isOk()) 1286 case VBoxDefs::MediumType_Floppy: 1287 { 1288 machine.MountMedium ("FD", 0, 0, NULL); 1289 if (!machine.isOk()) 1290 1290 { 1291 1291 vboxProblem().cannotUnmountMedium (this, machine, aMedium, 1292 COMResult ( drive));1292 COMResult (machine)); 1293 1293 success = false; 1294 1294 } … … 1316 1316 } 1317 1317 1318 QTreeWidget* VBoxMediaManagerDlg::treeWidget (VBoxDefs::Medi aType aType) const1318 QTreeWidget* VBoxMediaManagerDlg::treeWidget (VBoxDefs::MediumType aType) const 1319 1319 { 1320 1320 QTreeWidget* tree = 0; 1321 1321 switch (aType) 1322 1322 { 1323 case VBoxDefs::Medi aType_HardDisk:1323 case VBoxDefs::MediumType_HardDisk: 1324 1324 tree = mHardDiskView; 1325 1325 break; 1326 case VBoxDefs::Medi aType_DVD:1326 case VBoxDefs::MediumType_DVD: 1327 1327 tree = mDVDView; 1328 1328 break; 1329 case VBoxDefs::Medi aType_Floppy:1329 case VBoxDefs::MediumType_Floppy: 1330 1330 tree = mFloppyView; 1331 1331 break; … … 1337 1337 } 1338 1338 1339 VBoxDefs::Medi aType VBoxMediaManagerDlg::currentTreeWidgetType() const1340 { 1341 VBoxDefs::Medi aType type = VBoxDefs::MediaType_Invalid;1339 VBoxDefs::MediumType VBoxMediaManagerDlg::currentTreeWidgetType() const 1340 { 1341 VBoxDefs::MediumType type = VBoxDefs::MediumType_Invalid; 1342 1342 switch (mTwImages->currentIndex ()) 1343 1343 { 1344 1344 case HDTab: 1345 type = VBoxDefs::Medi aType_HardDisk;1345 type = VBoxDefs::MediumType_HardDisk; 1346 1346 break; 1347 1347 case CDTab: 1348 type = VBoxDefs::Medi aType_DVD;1348 type = VBoxDefs::MediumType_DVD; 1349 1349 break; 1350 1350 case FDTab: 1351 type = VBoxDefs::Medi aType_Floppy;1351 type = VBoxDefs::MediumType_Floppy; 1352 1352 break; 1353 1353 default: … … 1424 1424 1425 1425 /* New and Add are now enabled even when enumerating since it should be safe */ 1426 bool newEnabled = currentTreeWidgetType() == VBoxDefs::Medi aType_HardDisk;1426 bool newEnabled = currentTreeWidgetType() == VBoxDefs::MediumType_HardDisk; 1427 1427 bool addEnabled = true; 1428 1428 // bool editEnabled = notInEnum && item && checkMediumFor (item, Action_Edit); … … 1551 1551 1552 1552 void VBoxMediaManagerDlg::addMediumToList (const QString &aLocation, 1553 VBoxDefs::Medi aType aType)1553 VBoxDefs::MediumType aType) 1554 1554 { 1555 1555 AssertReturnVoid (!aLocation.isEmpty()); … … 1560 1560 switch (aType) 1561 1561 { 1562 case VBoxDefs::Medi aType_HardDisk:1563 { 1564 C HardDiskhd = mVBox.OpenHardDisk(aLocation, KAccessMode_ReadWrite, false, "", false, "");1562 case VBoxDefs::MediumType_HardDisk: 1563 { 1564 CMedium hd = mVBox.OpenHardDisk(aLocation, KAccessMode_ReadWrite, false, "", false, ""); 1565 1565 if (mVBox.isOk()) 1566 1566 { 1567 1567 medium = VBoxMedium (CMedium (hd), 1568 VBoxDefs::Medi aType_HardDisk,1569 KMedi aState_Created);1568 VBoxDefs::MediumType_HardDisk, 1569 KMediumState_Created); 1570 1570 } 1571 1571 break; 1572 1572 } 1573 case VBoxDefs::Medi aType_DVD:1574 { 1575 C DVDImageimage = mVBox.OpenDVDImage (aLocation, uuid);1573 case VBoxDefs::MediumType_DVD: 1574 { 1575 CMedium image = mVBox.OpenDVDImage (aLocation, uuid); 1576 1576 if (mVBox.isOk()) 1577 1577 { 1578 1578 medium = VBoxMedium (CMedium (image), 1579 VBoxDefs::Medi aType_DVD,1580 KMedi aState_Created);1579 VBoxDefs::MediumType_DVD, 1580 KMediumState_Created); 1581 1581 } 1582 1582 break; 1583 1583 } 1584 case VBoxDefs::Medi aType_Floppy:1585 { 1586 C FloppyImageimage = mVBox.OpenFloppyImage (aLocation, uuid);1584 case VBoxDefs::MediumType_Floppy: 1585 { 1586 CMedium image = mVBox.OpenFloppyImage (aLocation, uuid); 1587 1587 if (mVBox.isOk()) 1588 1588 { 1589 1589 medium = VBoxMedium (CMedium (image), 1590 VBoxDefs::Medi aType_Floppy,1591 KMedi aState_Created);1590 VBoxDefs::MediumType_Floppy, 1591 KMediumState_Created); 1592 1592 } 1593 1593 break; … … 1606 1606 const VBoxMedium &aMedium) const 1607 1607 { 1608 AssertReturn (!aMedium. hardDisk().isNull(), 0);1608 AssertReturn (!aMedium.medium().isNull(), 0); 1609 1609 1610 1610 MediaItem *item = 0; 1611 1611 1612 C HardDisk parent = aMedium.hardDisk().GetParent();1612 CMedium parent = aMedium.medium().GetParent(); 1613 1613 if (parent.isNull()) 1614 1614 { … … 1635 1635 switch (aItem->type()) 1636 1636 { 1637 case VBoxDefs::Medi aType_HardDisk:1637 case VBoxDefs::MediumType_HardDisk: 1638 1638 tab = HDTab; 1639 1639 icon = &mHardDiskIcon; 1640 1640 inaccessible = &mHardDisksInaccessible; 1641 1641 break; 1642 case VBoxDefs::Medi aType_DVD:1642 case VBoxDefs::MediumType_DVD: 1643 1643 tab = CDTab; 1644 1644 icon = &mDVDImageIcon; 1645 1645 inaccessible = &mDVDImagesInaccessible; 1646 1646 break; 1647 case VBoxDefs::Medi aType_Floppy:1647 case VBoxDefs::MediumType_Floppy: 1648 1648 tab = FDTab; 1649 1649 icon = &mFloppyImageIcon; … … 1662 1662 /* Does it change the overall state? */ 1663 1663 if (*inaccessible || 1664 aItem->state() != KMedi aState_Inaccessible)1664 aItem->state() != KMediumState_Inaccessible) 1665 1665 break; /* no */ 1666 1666 … … 1679 1679 { 1680 1680 /* Does it change the overall state? */ 1681 if ((*inaccessible && aItem->state() == KMedi aState_Inaccessible) ||1682 (!*inaccessible && aItem->state() != KMedi aState_Inaccessible))1681 if ((*inaccessible && aItem->state() == KMediumState_Inaccessible) || 1682 (!*inaccessible && aItem->state() != KMediumState_Inaccessible)) 1683 1683 break; /* no */ 1684 1684 1685 1685 /* Is the given item in charge? */ 1686 if (!*inaccessible && aItem->state() == KMedi aState_Inaccessible)1686 if (!*inaccessible && aItem->state() == KMediumState_Inaccessible) 1687 1687 *inaccessible = true; /* yes */ 1688 1688 else … … 1703 1703 { 1704 1704 if (*it != aItem && 1705 (*it)->state() == KMedi aState_Inaccessible)1705 (*it)->state() == KMediumState_Inaccessible) 1706 1706 { 1707 1707 *inaccessible = true; … … 1765 1765 switch (aItem->state()) 1766 1766 { 1767 case KMedi aState_NotCreated:1768 case KMedi aState_Inaccessible:1769 case KMedi aState_LockedRead:1770 case KMedi aState_LockedWrite:1767 case KMediumState_NotCreated: 1768 case KMediumState_Inaccessible: 1769 case KMediumState_LockedRead: 1770 case KMediumState_LockedWrite: 1771 1771 return false; 1772 1772 default: … … 1804 1804 switch (currentTreeWidgetType()) 1805 1805 { 1806 case VBoxDefs::Medi aType_HardDisk:1806 case VBoxDefs::MediumType_HardDisk: 1807 1807 { 1808 1808 QList < QPair <QString, QString> > filterList = vboxGlobal().HDDBackends(); … … 1820 1820 break; 1821 1821 } 1822 case VBoxDefs::Medi aType_DVD:1822 case VBoxDefs::MediumType_DVD: 1823 1823 err |= (suffix != "iso"); 1824 1824 break; 1825 case VBoxDefs::Medi aType_Floppy:1825 case VBoxDefs::MediumType_Floppy: 1826 1826 err |= (suffix != "img"); 1827 1827 break; 1828 1828 default: 1829 AssertMsgFailed (("Selected tree should be equal to one item in VBoxDefs::Medi aType.\n"));1829 AssertMsgFailed (("Selected tree should be equal to one item in VBoxDefs::MediumType.\n")); 1830 1830 break; 1831 1831 } … … 1839 1839 { 1840 1840 QString file = u.toLocalFile(); 1841 VBoxDefs::Medi aType type = currentTreeWidgetType();1841 VBoxDefs::MediumType type = currentTreeWidgetType(); 1842 1842 addMediumToList (file, type); 1843 1843 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMedium.cpp
r19239 r23223 21 21 */ 22 22 23 /* Global includes */ 24 #include <QDir> 25 26 /* Local includes */ 23 27 #include "VBoxMedium.h" 24 28 #include "VBoxGlobal.h" 25 29 #include "VBoxProblemReporter.h" 26 27 /* Qt includes */28 #include <QDir>29 30 void VBoxMedium::init()31 {32 AssertReturnVoid (!mMedium.isNull());33 34 switch (mType)35 {36 case VBoxDefs::MediaType_HardDisk:37 {38 mHardDisk = mMedium;39 AssertReturnVoid (!mHardDisk.isNull());40 break;41 }42 case VBoxDefs::MediaType_DVD:43 {44 mDVDImage = mMedium;45 AssertReturnVoid (!mDVDImage.isNull());46 Assert (mParent == NULL);47 break;48 }49 case VBoxDefs::MediaType_Floppy:50 {51 mFloppyImage = mMedium;52 AssertReturnVoid (!mFloppyImage.isNull());53 Assert (mParent == NULL);54 break;55 }56 default:57 AssertFailed();58 }59 60 refresh();61 }62 30 63 31 /** … … 77 45 void VBoxMedium::blockAndQueryState() 78 46 { 47 if (mMedium.isNull()) return; 48 79 49 mState = mMedium.GetState(); 80 50 81 /* save the result to distinguish between inaccessible and e.g. 82 * uninitialized objects */ 51 /* Save the result to distinguish between inaccessible and e.g. uninitialized objects */ 83 52 mResult = COMResult (mMedium); 84 53 85 54 if (!mResult.isOk()) 86 55 { 87 mState = KMedi aState_Inaccessible;56 mState = KMediumState_Inaccessible; 88 57 mLastAccessError = QString::null; 89 58 } … … 100 69 * 101 70 * Note that some string such as #size() are meaningless if the media state is 102 * KMedi aState_NotCreated (i.e. the medium has not yet been checked for71 * KMediumState_NotCreated (i.e. the medium has not yet been checked for 103 72 * accessibility). 104 73 */ 105 74 void VBoxMedium::refresh() 106 75 { 107 mId = mMedium.GetId(); 108 mLocation = mMedium.GetLocation(); 109 mName = mMedium.GetName(); 110 111 if (mType == VBoxDefs::MediaType_HardDisk) 112 { 113 /// @todo NEWMEDIA use CSystemProperties::GetHardDIskFormats to see if the 114 /// given hard disk format is a file 115 mLocation = QDir::toNativeSeparators (mLocation); 116 mHardDiskFormat = mHardDisk.GetFormat(); 117 mHardDiskType = vboxGlobal().hardDiskTypeString (mHardDisk); 118 119 mIsReadOnly = mHardDisk.GetReadOnly(); 120 121 /* adjust the parent if necessary (note that mParent must always point 76 /* Detect basic parameters */ 77 mId = mMedium.isNull() ? QUuid().toString().remove ('{').remove ('}') : mMedium.GetId(); 78 79 mIsHostDrive = mMedium.isNull() ? false : mMedium.GetHostDrive(); 80 81 mName = mMedium.isNull() ? VBoxGlobal::tr ("Not Set", "medium") : 82 !mIsHostDrive ? mMedium.GetName() : 83 VBoxGlobal::tr ("Host Drive '%1'", "medium").arg (QDir::toNativeSeparators (mMedium.GetLocation())); 84 85 mLocation = mMedium.isNull() || mIsHostDrive ? QString ("--") : 86 QDir::toNativeSeparators (mMedium.GetLocation()); 87 88 if (mType == VBoxDefs::MediumType_HardDisk) 89 { 90 mHardDiskFormat = mMedium.GetFormat(); 91 mHardDiskType = vboxGlobal().mediumTypeString (mMedium); 92 mIsReadOnly = mMedium.GetReadOnly(); 93 94 /* Adjust the parent if necessary (note that mParent must always point 122 95 * to an item from VBoxGlobal::currentMediaList()) */ 123 124 CHardDisk parent = mHardDisk.GetParent(); 96 CMedium parent = mMedium.GetParent(); 125 97 Assert (!parent.isNull() || mParent == NULL); 126 98 127 if (!parent.isNull() && 128 (mParent == NULL || mParent->mHardDisk != parent)) 129 { 130 /* search for the parent (must be there) */ 99 if (!parent.isNull() && (mParent == NULL || mParent->mMedium != parent)) 100 { 101 /* Search for the parent (must be there) */ 131 102 const VBoxMediaList &list = vboxGlobal().currentMediaList(); 132 for (VBoxMediaList::const_iterator it = list.begin(); 133 it != list.end(); ++ it) 103 for (VBoxMediaList::const_iterator it = list.begin(); it != list.end(); ++ it) 134 104 { 135 if ((*it).mType != VBoxDefs::Medi aType_HardDisk)105 if ((*it).mType != VBoxDefs::MediumType_HardDisk) 136 106 break; 137 107 138 if ((*it).m HardDisk== parent)108 if ((*it).mMedium == parent) 139 109 { 140 /* we unconst here because by the const list we don't mean141 * const items */142 110 mParent = unconst (&*it); 143 111 break; … … 145 113 } 146 114 147 Assert (mParent != NULL && mParent->m HardDisk== parent);115 Assert (mParent != NULL && mParent->mMedium == parent); 148 116 } 149 117 } 150 118 else 151 119 { 152 mLocation = QDir::toNativeSeparators (mLocation);153 120 mHardDiskFormat = QString::null; 154 121 mHardDiskType = QString::null; 155 156 122 mIsReadOnly = false; 157 123 } 158 124 159 if (mState != KMediaState_Inaccessible &&160 mState != KMediaState_NotCreated)125 /* Detect sizes */ 126 if (mState != KMediumState_Inaccessible && mState != KMediumState_NotCreated && !mIsHostDrive) 161 127 { 162 128 mSize = vboxGlobal().formatSize (mMedium.GetSize()); 163 if (mType == VBoxDefs::MediaType_HardDisk) 164 mLogicalSize = vboxGlobal() 165 .formatSize (mHardDisk.GetLogicalSize() * _1M); 129 if (mType == VBoxDefs::MediumType_HardDisk) 130 mLogicalSize = vboxGlobal().formatSize (mMedium.GetLogicalSize() * _1M); 166 131 else 167 132 mLogicalSize = mSize; … … 172 137 } 173 138 174 /* detect usage */ 175 176 mUsage = QString::null; /* important: null means not used! */ 177 178 mCurStateMachineIds.clear(); 179 180 QVector <QString> machineIds = mMedium.GetMachineIds(); 181 if (machineIds.size() > 0) 182 { 183 QString usage; 184 185 CVirtualBox vbox = vboxGlobal().virtualBox(); 186 187 for (QVector <QString>::ConstIterator it = machineIds.begin(); 188 it != machineIds.end(); ++ it) 189 { 190 CMachine machine = vbox.GetMachine (*it); 191 192 QString name = machine.GetName(); 193 QString snapshots; 194 195 QVector <QString> snapIds = mMedium.GetSnapshotIds (*it); 196 for (QVector <QString>::ConstIterator jt = snapIds.begin(); 197 jt != snapIds.end(); ++ jt) 139 /* Detect usage */ 140 mUsage = QString::null; 141 if (!mMedium.isNull()) 142 { 143 mCurStateMachineIds.clear(); 144 QVector <QString> machineIds = mMedium.GetMachineIds(); 145 if (machineIds.size() > 0) 146 { 147 QString usage; 148 149 CVirtualBox vbox = vboxGlobal().virtualBox(); 150 151 for (QVector <QString>::ConstIterator it = machineIds.begin(); it != machineIds.end(); ++ it) 198 152 { 199 if (*jt == *it) 153 CMachine machine = vbox.GetMachine (*it); 154 155 QString name = machine.GetName(); 156 QString snapshots; 157 158 QVector <QString> snapIds = mMedium.GetSnapshotIds (*it); 159 for (QVector <QString>::ConstIterator jt = snapIds.begin(); jt != snapIds.end(); ++ jt) 200 160 { 201 /* the medium is attached to the machine in the current 202 * state, we don't distinguish this for now by always 203 * giving the VM name in front of snapshot names. */ 204 205 mCurStateMachineIds.push_back (*jt); 206 continue; 161 if (*jt == *it) 162 { 163 /* the medium is attached to the machine in the current 164 * state, we don't distinguish this for now by always 165 * giving the VM name in front of snapshot names. */ 166 167 mCurStateMachineIds.push_back (*jt); 168 continue; 169 } 170 171 CSnapshot snapshot = machine.GetSnapshot (*jt); 172 if (!snapshots.isNull()) 173 snapshots += ", "; 174 snapshots += snapshot.GetName(); 207 175 } 208 176 209 CSnapshot snapshot = machine.GetSnapshot (*jt); 177 if (!usage.isNull()) 178 usage += ", "; 179 180 usage += name; 181 210 182 if (!snapshots.isNull()) 211 snapshots += ", "; 212 snapshots += snapshot.GetName(); 183 { 184 usage += QString (" (%2)").arg (snapshots); 185 mIsUsedInSnapshots = true; 186 } 187 else 188 mIsUsedInSnapshots = false; 213 189 } 214 190 215 if (!usage.isNull()) 216 usage += ", "; 217 218 usage += name; 219 220 if (!snapshots.isNull()) 191 Assert (!usage.isEmpty()); 192 mUsage = usage; 193 } 194 } 195 196 /* Compose the tooltip */ 197 if (mMedium.isNull()) 198 { 199 mToolTip = VBoxGlobal::tr ("<nobr><b>Null Medium</b></nobr><br>" 200 "This medium corresponds to empty device " 201 "which could be mounted at runtime."); 202 } 203 else 204 { 205 mToolTip = QString ("<nobr><b>%1</b></nobr>").arg (mIsHostDrive ? mName : mLocation); 206 207 if (mType == VBoxDefs::MediumType_HardDisk) 208 { 209 mToolTip += VBoxGlobal::tr ( 210 "<br><nobr>Type (Format): %2 (%3)</nobr>", "hard disk") 211 .arg (mHardDiskType).arg (mHardDiskFormat); 212 } 213 214 mToolTip += VBoxGlobal::tr ( 215 "<br><nobr>Attached to: %1</nobr>", "medium") 216 .arg (mUsage.isNull() ? VBoxGlobal::tr ("<i>Not Attached</i>", "medium") : mUsage); 217 218 switch (mState) 219 { 220 case KMediumState_NotCreated: 221 221 { 222 usage += QString (" (%2)").arg (snapshots);223 mIsUsedInSnapshots = true;222 mToolTip += VBoxGlobal::tr ("<br><i>Checking accessibility...</i>", "medium"); 223 break; 224 224 } 225 else 226 mIsUsedInSnapshots = false; 227 } 228 229 Assert (!usage.isEmpty()); 230 mUsage = usage; 231 } 232 233 /* compose the tooltip (makes sense to keep the format in sync with 234 * VBoxMediaManagerDlg::languageChangeImp() and 235 * VBoxMediaManagerDlg::processCurrentChanged()) */ 236 237 mToolTip = QString ("<nobr><b>%1</b></nobr>").arg (mLocation); 238 239 if (mType == VBoxDefs::MediaType_HardDisk) 240 { 241 mToolTip += VBoxGlobal::tr ( 242 "<br><nobr>Type (Format): %2 (%3)</nobr>", 243 "hard disk") 244 .arg (mHardDiskType) 245 .arg (mHardDiskFormat); 246 } 247 248 mToolTip += VBoxGlobal::tr ( 249 "<br><nobr>Attached to: %1</nobr>", "medium") 250 .arg (mUsage.isNull() ? 251 VBoxGlobal::tr ("<i>Not Attached</i>", "medium") : 252 mUsage); 253 254 switch (mState) 255 { 256 case KMediaState_NotCreated: 257 { 258 mToolTip += VBoxGlobal::tr ("<br><i>Checking accessibility...</i>", 259 "medium"); 260 break; 261 } 262 case KMediaState_Inaccessible: 263 { 264 if (mResult.isOk()) 225 case KMediumState_Inaccessible: 265 226 { 266 /* not accessibile */ 267 mToolTip += QString ("<hr>%1"). 268 arg (VBoxGlobal::highlight (mLastAccessError, 269 true /* aToolTip */)); 227 if (mResult.isOk()) 228 { 229 /* not accessibile */ 230 mToolTip += QString ("<hr>%1"). 231 arg (VBoxGlobal::highlight (mLastAccessError, 232 true /* aToolTip */)); 233 } 234 else 235 { 236 /* accessibility check (eg GetState()) itself failed */ 237 mToolTip = VBoxGlobal::tr ( 238 "<hr>Failed to check media accessibility.<br>%1.", "medium"). 239 arg (VBoxProblemReporter::formatErrorInfo (mResult)); 240 } 241 break; 270 242 } 271 else 272 { 273 /* accessibility check (eg GetState()) itself failed */ 274 mToolTip = VBoxGlobal::tr ( 275 "<hr>Failed to check media accessibility.<br>%1.", 276 "medium"). 277 arg (VBoxProblemReporter::formatErrorInfo (mResult)); 278 } 279 break; 280 } 281 default: 282 break; 243 default: 244 break; 245 } 283 246 } 284 247 … … 312 275 * accordingly. 313 276 */ 314 QString VBoxMedium::toolTip (bool aNoDiffs /*= false*/, 315 bool aCheckRO /*= false*/) const 277 QString VBoxMedium::toolTip (bool aNoDiffs /*= false*/, bool aCheckRO /*= false*/) const 316 278 { 317 279 unconst (this)->checkNoDiffs (aNoDiffs); … … 323 285 "<hr><img src=%1/> Attaching this hard disk will " 324 286 "be performed indirectly using a newly created " 325 "differencing hard disk.", 326 "medium"). 327 arg (":/new_16px.png"); 287 "differencing hard disk.", "medium").arg (":/new_16px.png"); 328 288 329 289 return tip; … … 349 309 QPixmap icon; 350 310 351 if (state (aNoDiffs) == KMediaState_Inaccessible) 352 icon = result (aNoDiffs).isOk() ? 353 vboxGlobal().warningIcon() : vboxGlobal().errorIcon(); 311 if (state (aNoDiffs) == KMediumState_Inaccessible) 312 icon = result (aNoDiffs).isOk() ? vboxGlobal().warningIcon() : vboxGlobal().errorIcon(); 354 313 355 314 if (aCheckRO && mIsReadOnly) 356 icon = VBoxGlobal:: 357 joinPixmaps (icon, QPixmap (":/new_16px.png")); 315 icon = VBoxGlobal::joinPixmaps (icon, QPixmap (":/new_16px.png")); 358 316 359 317 return icon; … … 402 360 // exceptions everywhere (or check the result after every method call). See 403 361 // also Defect #2149. 362 363 if (mMedium.isNull() || mIsHostDrive) 364 return mName; 365 404 366 if (!mMedium.isOk()) 405 367 return QString::null; … … 408 370 409 371 VBoxMedium *root = unconst (this); 410 KMedi aState state = mState;411 412 if (mType == VBoxDefs::Medi aType_HardDisk)372 KMediumState state = mState; 373 374 if (mType == VBoxDefs::MediumType_HardDisk) 413 375 { 414 376 if (aNoDiffs) … … 416 378 root = &this->root(); 417 379 418 bool isDiff = 419 (!aPredictDiff && mParent != NULL) || 420 (aPredictDiff && mIsReadOnly); 380 bool isDiff = (!aPredictDiff && mParent != NULL) || (aPredictDiff && mIsReadOnly); 421 381 422 382 details = isDiff && aUseHTML ? … … 428 388 429 389 /* we cannot get the logical size if the root is not checked yet */ 430 if (root->mState == KMedi aState_NotCreated)431 state = KMedi aState_NotCreated;390 if (root->mState == KMediumState_NotCreated) 391 state = KMediumState_NotCreated; 432 392 } 433 393 else … … 442 402 switch (state) 443 403 { 444 case KMedi aState_NotCreated:404 case KMediumState_NotCreated: 445 405 str = VBoxGlobal::tr ("Checking...", "medium"); 446 406 details += aUseHTML ? QString ("<i>%1</i>").arg (str) : str; 447 407 break; 448 case KMedi aState_Inaccessible:408 case KMediumState_Inaccessible: 449 409 str = VBoxGlobal::tr ("Inaccessible", "medium"); 450 410 details += aUseHTML ? QString ("<b>%1</b>").arg (str) : str; 451 411 break; 452 412 default: 453 details += mType == VBoxDefs::Medi aType_HardDisk ?413 details += mType == VBoxDefs::MediumType_HardDisk ? 454 414 root->mLogicalSize : root->mSize; 455 415 break; … … 481 441 /* detect the overall (worst) state of the given hard disk chain */ 482 442 mNoDiffs.state = mState; 483 for (VBoxMedium *cur = mParent; cur != NULL; 484 cur = cur->mParent) 485 { 486 if (cur->mState == KMediaState_Inaccessible) 443 for (VBoxMedium *cur = mParent; cur != NULL; cur = cur->mParent) 444 { 445 if (cur->mState == KMediumState_Inaccessible) 487 446 { 488 447 mNoDiffs.state = cur->mState; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxNewHDWzd.cpp
r17970 r23223 148 148 149 149 /* Name and Size page */ 150 /// @todo NEWMEDIA use extension as reported by C HardDiskFormat150 /// @todo NEWMEDIA use extension as reported by CMediumFormat 151 151 static ulong HDNumber = 0; 152 152 mLeName->setText (QString ("NewHardDisk%1.vdi").arg (++ HDNumber)); … … 375 375 bool VBoxNewHDWzd::createHardDisk() 376 376 { 377 K HardDiskVariant variant = KHardDiskVariant_Standard;377 KMediumVariant variant = KMediumVariant_Standard; 378 378 QString loc = location(); 379 379 … … 385 385 CProgress progress; 386 386 387 C HardDiskhd = vbox.CreateHardDisk(QString ("VDI"), loc);387 CMedium hd = vbox.CreateHardDisk(QString ("VDI"), loc); 388 388 389 389 if (!vbox.isOk()) … … 395 395 396 396 if (!isDynamicStorage()) 397 variant = (K HardDiskVariant)(KHardDiskVariant_Standard | KHardDiskVariant_Fixed);397 variant = (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_Fixed); 398 398 399 399 progress = hd.CreateBaseStorage (mCurrentSize, variant); … … 417 417 /* Inform everybody there is a new medium */ 418 418 vboxGlobal().addMedium (VBoxMedium (CMedium (hd), 419 VBoxDefs::Medi aType_HardDisk,420 KMedi aState_Created));419 VBoxDefs::MediumType_HardDisk, 420 KMediumState_Created)); 421 421 422 422 mHD = hd; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxNewVMWzd.cpp
r21305 r23223 68 68 QSpacerItem *spacer = new QSpacerItem (wid, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 69 69 hdLayout->addItem (spacer, 2, 0); 70 mHDCombo->setType (VBoxDefs::Medi aType_HardDisk);70 mHDCombo->setType (VBoxDefs::MediumType_HardDisk); 71 71 mHDCombo->repopulate(); 72 72 mTbVmm->setIcon (VBoxGlobal::iconSet (":/select_file_16px.png", … … 168 168 { 169 169 VBoxMediaManagerDlg dlg (this); 170 dlg.setup (VBoxDefs::Medi aType_HardDisk, true);170 dlg.setup (VBoxDefs::MediumType_HardDisk, true); 171 171 172 172 if (dlg.exec() == QDialog::Accepted) … … 369 369 { 370 370 CMachine m = session.GetMachine(); 371 m.Attach HardDisk (mHDCombo->id(), QString("IDE"), 0, 0);371 m.AttachDevice ("IDE", 0, 0, KDeviceType_HardDisk, mHDCombo->id()); 372 372 if (m.isOk()) 373 373 { … … 419 419 420 420 if (success) 421 vboxGlobal().removeMedium (VBoxDefs::Medi aType_HardDisk, id);421 vboxGlobal().removeMedium (VBoxDefs::MediumType_HardDisk, id); 422 422 else 423 423 vboxProblem().cannotDeleteHardDiskStorage (this, mHardDisk, -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r22434 r23223 1011 1011 .arg (aMedium.location()); 1012 1012 1013 if (aMedium.type() == VBoxDefs::Medi aType_HardDisk)1014 { 1015 if (aMedium.state() == KMedi aState_Inaccessible)1013 if (aMedium.type() == VBoxDefs::MediumType_HardDisk) 1014 { 1015 if (aMedium.state() == KMediumState_Inaccessible) 1016 1016 msg += 1017 1017 tr ("Note that this hard disk is inaccessible so that its " … … 1069 1069 1070 1070 void VBoxProblemReporter::cannotDeleteHardDiskStorage (QWidget *aParent, 1071 const C HardDisk&aHD,1071 const CMedium &aHD, 1072 1072 const CProgress &aProgress) 1073 1073 { 1074 /* below, we use C HardDisk(aHD) to preserve current error info1074 /* below, we use CMedium (aHD) to preserve current error info 1075 1075 * for formatErrorInfo() */ 1076 1076 1077 1077 message (aParent, Error, 1078 1078 tr ("Failed to delete the storage unit of the hard disk <b>%1</b>.") 1079 .arg (C HardDisk(aHD).GetLocation()),1079 .arg (CMedium (aHD).GetLocation()), 1080 1080 !aHD.isOk() ? formatErrorInfo (aHD) : 1081 1081 !aProgress.isOk() ? formatErrorInfo (aProgress) : … … 1107 1107 } 1108 1108 1109 int VBoxProblemReporter::confirmRunNewHDWzdOrVDM (QWidget* aParent) 1110 { 1111 return message (aParent, Info, 1112 tr ("<p>There are no unused hard disks available for the newly created " 1113 "attachment.</p>" 1114 "<p>Press the <b>Create</b> button to start the <i>New Virtual " 1115 "Disk</i> wizard and create a new hard disk, or press the " 1116 "<b>Select</b> button to open the <i>Virtual Media Manager</i> " 1117 "and select what to do.</p>"), 1118 0, /* aAutoConfirmId */ 1119 QIMessageBox::Yes, 1120 QIMessageBox::No | QIMessageBox::Default, 1121 QIMessageBox::Cancel | QIMessageBox::Escape, 1122 tr ("&Create", "hard disk"), 1123 tr ("Select", "hard disk")); 1109 int VBoxProblemReporter::confirmRunNewHDWzdOrVDM (KDeviceType aDeviceType) 1110 { 1111 switch (aDeviceType) 1112 { 1113 case KDeviceType_HardDisk: 1114 return message (QApplication::activeWindow(), Info, 1115 tr ("<p>There are no unused mediums available for the newly " 1116 "created attachment.</p>" 1117 "<p>Press the <b>Create</b> button to start the <i>New " 1118 "Virtual Disk</i> wizard and create a new medium, " 1119 "or press the <b>Select</b> button to open the <i>Virtual " 1120 "Media Manager</i> and select what to do.</p>"), 1121 0, /* aAutoConfirmId */ 1122 QIMessageBox::Yes, 1123 QIMessageBox::No | QIMessageBox::Default, 1124 QIMessageBox::Cancel | QIMessageBox::Escape, 1125 tr ("&Create", "medium"), 1126 tr ("&Select", "medium")); 1127 default: 1128 return message (QApplication::activeWindow(), Info, 1129 tr ("<p>There are no unused mediums available for the newly " 1130 "created attachment.</p>" 1131 "<p>Press the <b>Select</b> button to open the <i>Virtual " 1132 "Media Manager</i> and select what to do.</p>"), 1133 0, /* aAutoConfirmId */ 1134 QIMessageBox::No | QIMessageBox::Default, 1135 QIMessageBox::Cancel | QIMessageBox::Escape, 1136 0, 1137 tr ("&Select", "medium")); 1138 } 1139 return QIMessageBox::Cancel; 1124 1140 } 1125 1141 1126 1142 void VBoxProblemReporter::cannotCreateHardDiskStorage ( 1127 1143 QWidget *aParent, const CVirtualBox &aVBox, const QString &aLocation, 1128 const C HardDisk&aHD, const CProgress &aProgress)1144 const CMedium &aHD, const CProgress &aProgress) 1129 1145 { 1130 1146 message (aParent, Error, … … 1145 1161 "to the slot <i>%2</i> of the machine <b>%3</b>.") 1146 1162 .arg (aLocation) 1147 .arg (vboxGlobal().toFullString ( aBus, aChannel, aDevice))1163 .arg (vboxGlobal().toFullString (StorageSlot (aBus, aChannel, aDevice))) 1148 1164 .arg (CMachine (aMachine).GetName()), 1149 1165 formatErrorInfo (aMachine)); … … 1158 1174 "from the slot <i>%2</i> of the machine <b>%3</b>.") 1159 1175 .arg (aLocation) 1160 .arg (vboxGlobal().toFullString ( aBus, aChannel, aDevice))1176 .arg (vboxGlobal().toFullString (StorageSlot (aBus, aChannel, aDevice))) 1161 1177 .arg (CMachine (aMachine).GetName()), 1162 1178 formatErrorInfo (aMachine)); … … 1195 1211 void VBoxProblemReporter::cannotOpenMedium ( 1196 1212 QWidget *aParent, const CVirtualBox &aVBox, 1197 VBoxDefs::Medi aType aType, const QString &aLocation)1213 VBoxDefs::MediumType aType, const QString &aLocation) 1198 1214 { 1199 1215 /** @todo (translation-related): the gender of "the" in translations … … 2171 2187 2172 2188 /* static */ 2173 QString VBoxProblemReporter::toAccusative (VBoxDefs::Medi aType aType)2189 QString VBoxProblemReporter::toAccusative (VBoxDefs::MediumType aType) 2174 2190 { 2175 2191 QString type = 2176 aType == VBoxDefs::Medi aType_HardDisk ?2192 aType == VBoxDefs::MediumType_HardDisk ? 2177 2193 tr ("hard disk", "failed to close ...") : 2178 aType == VBoxDefs::Medi aType_DVD ?2194 aType == VBoxDefs::MediumType_DVD ? 2179 2195 tr ("CD/DVD image", "failed to close ...") : 2180 aType == VBoxDefs::Medi aType_Floppy ?2196 aType == VBoxDefs::MediumType_Floppy ? 2181 2197 tr ("floppy image", "failed to close ...") : 2182 2198 QString::null; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r22823 r23223 907 907 CMachine machine = session.GetMachine(); 908 908 /* Detach all attached Hard Disks */ 909 C HardDiskAttachmentVector vec = machine.GetHardDiskAttachments();909 CMediumAttachmentVector vec = machine.GetMediumAttachments(); 910 910 for (int i = 0; i < vec.size(); ++ i) 911 911 { 912 C HardDiskAttachment hda = vec [i];912 CMediumAttachment hda = vec [i]; 913 913 const QString ctlName = hda.GetController(); 914 914 915 machine.Detach HardDisk(ctlName, hda.GetPort(), hda.GetDevice());915 machine.DetachDevice(ctlName, hda.GetPort(), hda.GetDevice()); 916 916 if (!machine.isOk()) 917 917 { 918 918 CStorageController ctl = machine.GetStorageControllerByName(ctlName); 919 919 vboxProblem().cannotDetachHardDisk (this, machine, 920 vboxGlobal().getMedium (CMedium (hda.Get HardDisk())).location(),920 vboxGlobal().getMedium (CMedium (hda.GetMedium())).location(), 921 921 ctl.GetBus(), hda.GetPort(), hda.GetDevice()); 922 922 } … … 1604 1604 VBoxMediaList::const_iterator it; 1605 1605 for (it = list.begin(); it != list.end(); ++ it) 1606 if ((*it).state() == KMedi aState_Inaccessible)1606 if ((*it).state() == KMediumState_Inaccessible) 1607 1607 break; 1608 1608 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsDialogSpecific.cpp
r21446 r23223 39 39 #include "VBoxVMSettingsDisplay.h" 40 40 #include "VBoxVMSettingsHD.h" 41 #include "VBoxVMSettingsCD.h"42 #include "VBoxVMSettingsFD.h"43 41 #include "VBoxVMSettingsAudio.h" 44 42 #include "VBoxVMSettingsNetwork.h" … … 271 269 if (isAvailable (StorageId)) 272 270 { 271 prefPage = new VBoxVMSettingsHD(); 272 connect (prefPage, SIGNAL (storageChanged()), this, SLOT (resetFirstRunFlag())); 273 273 addItem (":/hd_32px.png", ":/hd_disabled_32px.png", 274 274 ":/hd_16px.png", ":/hd_disabled_16px.png", 275 StorageId, "#storage"); 276 277 /* HD page */ 278 if (isAvailable (HDId)) 279 { 280 prefPage = new VBoxVMSettingsHD(); 281 connect (prefPage, SIGNAL (hdChanged()), this, SLOT (resetFirstRunFlag())); 282 addItem (":/hd_32px.png", ":/hd_disabled_32px.png", 283 ":/hd_16px.png", ":/hd_disabled_16px.png", 284 HDId, "#hdds", prefPage, StorageId); 285 } 286 287 /* CD page */ 288 if (isAvailable (CDId)) 289 { 290 prefPage = new VBoxVMSettingsCD(); 291 connect (prefPage, SIGNAL (cdChanged()), this, SLOT (resetFirstRunFlag())); 292 addItem (":/cd_32px.png", ":/cd_disabled_32px.png", 293 ":/cd_16px.png", ":/cd_disabled_16px.png", 294 CDId, "#dvd", prefPage, StorageId); 295 } 296 297 /* FD page */ 298 if (isAvailable (FDId)) 299 { 300 prefPage = new VBoxVMSettingsFD(); 301 connect (prefPage, SIGNAL (fdChanged()), this, SLOT (resetFirstRunFlag())); 302 addItem (":/fd_32px.png", ":/fd_disabled_32px.png", 303 ":/fd_16px.png", ":/fd_disabled_16px.png", 304 FDId, "#floppy", prefPage, StorageId); 305 } 275 StorageId, "#storage", prefPage, StorageId); 306 276 } 307 277 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsSelector.cpp
r21804 r23223 368 368 mTbSelector->setUsesTextLabel (true); 369 369 mTbSelector->setIconSize (QSize (32, 32)); 370 #ifdef Q_WS_MAC 370 371 mTbSelector->setShowToolBarButton (false); 372 #endif /* Q_WS_MAC */ 371 373 /* Init the action group for house keeping */ 372 374 mActionGroup = new QActionGroup (this); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMFirstRunWzd.cpp
r17255 r23223 36 36 37 37 /* Hide unnecessary text labels */ 38 C HardDiskAttachmentVector vec = mMachine.GetHardDiskAttachments();38 CMediumAttachmentVector vec = mMachine.GetMediumAttachments(); 39 39 if (vec.size() != 0) 40 40 { … … 119 119 if (mRbHost->isChecked()) 120 120 { 121 C HostDVDDrivehostDrive = mHostDVDs [mCbHost->currentIndex()];121 CMedium hostDrive = mHostDVDs [mCbHost->currentIndex()]; 122 122 if (!hostDrive.isNull()) 123 { 124 CDVDDrive virtualDrive = mMachine.GetDVDDrive(); 125 virtualDrive.CaptureHostDrive (hostDrive); 126 } 123 mMachine.MountMedium ("IDE", 1, 0, hostDrive.GetId()); 127 124 } 128 125 else if (mRbImage->isChecked()) 129 { 130 CDVDDrive virtualDrive = mMachine.GetDVDDrive(); 131 virtualDrive.MountImage (mCbImage->id()); 132 } 126 mMachine.MountMedium ("IDE", 1, 0, mCbImage->id()); 133 127 } 134 128 /* Floppy Media selected */ … … 137 131 if (mRbHost->isChecked()) 138 132 { 139 C HostFloppyDrivehostDrive = mHostFloppys [mCbHost->currentIndex()];133 CMedium hostDrive = mHostFloppys [mCbHost->currentIndex()]; 140 134 if (!hostDrive.isNull()) 141 { 142 CFloppyDrive virtualDrive = mMachine.GetFloppyDrive(); 143 virtualDrive.CaptureHostDrive (hostDrive); 144 } 135 mMachine.MountMedium ("IDE", 1, 0, hostDrive.GetId()); 145 136 } 146 137 else if (mRbImage->isChecked()) 147 { 148 CFloppyDrive virtualDrive = mMachine.GetFloppyDrive(); 149 virtualDrive.MountImage (mCbImage->id()); 150 } 138 mMachine.MountMedium ("IDE", 1, 0, mCbImage->id()); 151 139 } 152 140 … … 176 164 { 177 165 /* Search for the host dvd-drives */ 178 C HostDVDDriveVector coll =166 CMediumVector coll = 179 167 vboxGlobal().virtualBox().GetHost().GetDVDDrives(); 180 168 mHostDVDs.resize (coll.size()); … … 182 170 for (int id = 0; id < coll.size(); ++id) 183 171 { 184 C HostDVDDrivehostDVD = coll[id];172 CMedium hostDVD = coll[id]; 185 173 QString name = hostDVD.GetName(); 186 174 QString description = hostDVD.GetDescription(); … … 192 180 193 181 /* Switch media images type to DVD */ 194 mCbImage->setType (VBoxDefs::Medi aType_DVD);182 mCbImage->setType (VBoxDefs::MediumType_DVD); 195 183 } 196 184 /* Floppy media type selected */ … … 198 186 { 199 187 /* Search for the host floppy-drives */ 200 C HostFloppyDriveVector coll =188 CMediumVector coll = 201 189 vboxGlobal().virtualBox().GetHost().GetFloppyDrives(); 202 190 mHostFloppys.resize (coll.size()); … … 204 192 for (int id = 0; id < coll.size(); ++id) 205 193 { 206 C HostFloppyDrivehostFloppy = coll[id];194 CMedium hostFloppy = coll[id]; 207 195 QString name = hostFloppy.GetName(); 208 196 QString description = hostFloppy.GetDescription(); … … 214 202 215 203 /* Switch media images type to FD */ 216 mCbImage->setType (VBoxDefs::Medi aType_Floppy);204 mCbImage->setType (VBoxDefs::MediumType_Floppy); 217 205 } 218 206 … … 236 224 void VBoxVMFirstRunWzd::openMediaManager() 237 225 { 238 VBoxDefs::Medi aType type =239 mRbCdType->isChecked() ? VBoxDefs::Medi aType_DVD :240 mRbFdType->isChecked() ? VBoxDefs::Medi aType_Floppy :241 VBoxDefs::Medi aType_Invalid;242 243 AssertReturnVoid (type != VBoxDefs::Medi aType_Invalid);226 VBoxDefs::MediumType type = 227 mRbCdType->isChecked() ? VBoxDefs::MediumType_DVD : 228 mRbFdType->isChecked() ? VBoxDefs::MediumType_Floppy : 229 VBoxDefs::MediumType_Invalid; 230 231 AssertReturnVoid (type != VBoxDefs::MediumType_Invalid); 244 232 245 233 VBoxMediaManagerDlg dlg (this); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.cpp
r20977 r23223 488 488 489 489 /* IDE Hard Disk (Primary Master) */ 490 if (!m.Get HardDisk(ideCtl, 0, 0).isNull())490 if (!m.GetMedium(ideCtl, 0, 0).isNull()) 491 491 { 492 492 hdStat += formatHardDisk (ideCtl, 0, 0, "IDE00"); … … 495 495 496 496 /* IDE Hard Disk (Primary Slave) */ 497 if (!m.Get HardDisk(ideCtl, 0, 1).isNull())497 if (!m.GetMedium(ideCtl, 0, 1).isNull()) 498 498 { 499 499 hdStat += formatHardDisk (ideCtl, 0, 1, "IDE01"); … … 502 502 503 503 /* IDE Hard Disk (Secondary Slave) */ 504 if (!m.Get HardDisk(ideCtl, 1, 1).isNull())504 if (!m.GetMedium(ideCtl, 1, 1).isNull()) 505 505 { 506 506 hdStat += formatHardDisk (ideCtl, 1, 1, "IDE11"); … … 511 511 for (int i = 0; i < 30; ++ i) 512 512 { 513 if (!m.Get HardDisk(sataCtl, i, 0).isNull())513 if (!m.GetMedium(sataCtl, i, 0).isNull()) 514 514 { 515 515 hdStat += formatHardDisk (sataCtl, i, 0, … … 529 529 for (int i = 0; i < 16; ++ i) 530 530 { 531 if (!m.Get HardDisk(scsiCtl, i, 0).isNull())531 if (!m.GetMedium(scsiCtl, i, 0).isNull()) 532 532 { 533 533 hdStat += formatHardDisk (scsiCtl, i, 0, … … 614 614 return QString::null; 615 615 616 CStorageController ctl = mSession.GetMachine().GetStorageControllerByName (ctlName);617 618 C HardDisk hd = mSession.GetMachine().GetHardDisk(ctlName, aChannel, aDevice);616 CStorageController ctl = mSession.GetMachine().GetStorageControllerByName (ctlName); 617 618 CMedium hd = mSession.GetMachine().GetMedium (ctlName, aChannel, aDevice); 619 619 QString header = "<tr><td></td><td colspan=2><nobr><u>%1</u></nobr></td></tr>"; 620 QString name = vboxGlobal().toFullString ( ctl.GetBus(), aChannel, aDevice);620 QString name = vboxGlobal().toFullString (StorageSlot (ctl.GetBus(), aChannel, aDevice)); 621 621 QString result = hd.isNull() ? QString::null : header.arg (name); 622 622 result += composeArticle (aBelongsTo); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsHD.cpp
r19837 r23223 6 6 7 7 /* 8 * Copyright (C) 2006-200 8Sun Microsystems, Inc.8 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 */ 22 22 23 23 /* Global Includes */ 24 #include <QHeaderView> 25 #include <QItemEditorFactory> 26 #include <QMetaProperty> 27 #include <QMouseEvent> 28 #include <QScrollBar> 29 #include <QStylePainter> 30 #include <QTimer> 31 32 /* Local Includes */ 24 33 #include "VBoxVMSettingsHD.h" 25 34 #include "VBoxGlobal.h" … … 30 39 #include "VBoxNewHDWzd.h" 31 40 32 /* Qt includes */ 33 #include <QHeaderView> 34 #include <QItemEditorFactory> 35 #include <QMetaProperty> 36 #include <QScrollBar> 37 #include <QStylePainter> 38 39 /** 40 * Clear the focus from the current focus owner on guard creation. 41 * And put it into the desired object on guard deletion. 42 * 43 * Here this is used to temporary remove the focus from the attachments 44 * table to close the temporary editor of this table to prevent 45 * any side-process (enumeration) influencing model's data. 46 */ 47 class FocusGuardBlock 48 { 49 public: 50 FocusGuardBlock (QWidget *aReturnTo) : mReturnTo (aReturnTo) 51 { 52 if (QApplication::focusWidget()) 53 { 54 QApplication::focusWidget()->clearFocus(); 55 qApp->processEvents(); 56 } 57 } 58 ~FocusGuardBlock() 59 { 60 mReturnTo->setFocus(); 61 qApp->processEvents(); 62 } 63 64 private: 65 QWidget *mReturnTo; 66 }; 67 68 /** Type to store disk data */ 69 DiskValue::DiskValue (const QString &aId) 70 : id (aId) 71 , name (QString::null), tip (QString::null), pix (QPixmap()) 72 { 73 if (aId.isNull()) 74 return; 75 76 VBoxMedium medium = vboxGlobal().getMedium ( 77 CMedium (vboxGlobal().virtualBox().GetHardDisk(aId))); 78 medium.refresh(); 79 bool noDiffs = !HDSettings::instance()->showDiffs(); 80 name = medium.details (noDiffs); 81 tip = medium.toolTipCheckRO (noDiffs); 82 pix = medium.iconCheckRO (noDiffs); 83 } 84 85 /** 86 * QAbstractTableModel class reimplementation. 87 * Used to feat slot/disk selection mechanism. 88 */ 89 Qt::ItemFlags AttachmentsModel::flags (const QModelIndex &aIndex) const 90 { 91 return aIndex.row() == rowCount() - 1 ? 92 QAbstractItemModel::flags (aIndex) ^ Qt::ItemIsSelectable : 93 QAbstractItemModel::flags (aIndex) | Qt::ItemIsEditable; 94 } 95 96 QVariant AttachmentsModel::data (const QModelIndex &aIndex, int aRole) const 41 /* String Tags */ 42 const char *firstAvailable = "first available"; 43 44 /* Type converters */ 45 VBoxDefs::MediumType typeToLocal (KDeviceType aType) 46 { 47 VBoxDefs::MediumType result = VBoxDefs::MediumType_Invalid; 48 switch (aType) 49 { 50 case KDeviceType_HardDisk: 51 result = VBoxDefs::MediumType_HardDisk; 52 break; 53 case KDeviceType_DVD: 54 result = VBoxDefs::MediumType_DVD; 55 break; 56 case KDeviceType_Floppy: 57 result = VBoxDefs::MediumType_Floppy; 58 break; 59 default: 60 AssertMsgFailed (("Incorrect medium type!\n")); 61 break; 62 } 63 return result; 64 } 65 66 67 KDeviceType typeToGlobal (VBoxDefs::MediumType aType) 68 { 69 KDeviceType result = KDeviceType_Null; 70 switch (aType) 71 { 72 case VBoxDefs::MediumType_HardDisk: 73 result = KDeviceType_HardDisk; 74 break; 75 case VBoxDefs::MediumType_DVD: 76 result = KDeviceType_DVD; 77 break; 78 case VBoxDefs::MediumType_Floppy: 79 result = KDeviceType_Floppy; 80 break; 81 default: 82 AssertMsgFailed (("Incorrect device type!\n")); 83 break; 84 } 85 return result; 86 } 87 88 QString compressText (const QString &aText) 89 { 90 return QString ("<nobr><compact elipsis=\"end\">%1</compact></nobr>").arg (aText); 91 } 92 93 94 /* Pixmap Storage */ 95 QPointer <PixmapPool> PixmapPool::mThis = 0; 96 97 PixmapPool* PixmapPool::pool (QObject *aParent) 98 { 99 if (!mThis) 100 { 101 AssertMsg (aParent, ("This object must have parent!\n")); 102 mThis = new PixmapPool (aParent); 103 } 104 else 105 { 106 AssertMsg (!aParent, ("Parent already set!\n")); 107 } 108 return mThis; 109 } 110 111 PixmapPool::PixmapPool (QObject *aParent) 112 : QObject (aParent) 113 { 114 mPool.resize (MaxIndex); 115 116 mPool [AddControllerEn] = QPixmap (":/add_host_iface_16px.png"); // TODO Update Icon!!! 117 mPool [AddControllerDis] = QPixmap (":/add_host_iface_disabled_16px.png"); // TODO Update Icon!!! 118 mPool [DelControllerEn] = QPixmap (":/remove_host_iface_16px.png"); // TODO Update Icon!!! 119 mPool [DelControllerDis] = QPixmap (":/remove_host_iface_disabled_16px.png"); // TODO Update Icon!!! 120 121 mPool [AddAttachmentEn] = QPixmap (":/vdm_add_16px.png"); // TODO Update Icon!!! 122 mPool [AddAttachmentDis] = QPixmap (":/vdm_add_disabled_16px.png"); // TODO Update Icon!!! 123 mPool [DelAttachmentEn] = QPixmap (":/vdm_remove_16px.png"); // TODO Update Icon!!! 124 mPool [DelAttachmentDis] = QPixmap (":/vdm_remove_disabled_16px.png"); // TODO Update Icon!!! 125 126 mPool [IDEController] = QPixmap (":/ide_16px.png"); 127 mPool [SATAController] = QPixmap (":/sata_16px.png"); 128 mPool [SCSIController] = QPixmap (":/scsi_16px.png"); 129 mPool [FloppyController] = QPixmap (":/fd_16px.png"); // TODO Update Icon!!! 130 131 mPool [HDAttachmentEn] = QPixmap (":/hd_16px.png"); // TODO Update Icon!!! 132 mPool [HDAttachmentDis] = QPixmap (":/hd_disabled_16px.png"); // TODO Update Icon!!! 133 mPool [CDAttachmentEn] = QPixmap (":/cd_16px.png"); 134 mPool [CDAttachmentDis] = QPixmap (":/cd_disabled_16px.png"); 135 mPool [FDAttachmentEn] = QPixmap (":/fd_16px.png"); 136 mPool [FDAttachmentDis] = QPixmap (":/fd_disabled_16px.png"); 137 138 mPool [PlusEn] = QPixmap (":/plus_10px.png"); 139 mPool [PlusDis] = QPixmap (":/plus_disabled_10px.png"); 140 mPool [MinusEn] = QPixmap (":/minus_10px.png"); 141 mPool [MinusDis] = QPixmap (":/minus_disabled_10px.png"); 142 143 mPool [UnknownEn] = QPixmap (":/help_16px.png"); 144 145 mPool [VMMEn] = QPixmap (":/select_file_16px.png"); 146 mPool [VMMDis] = QPixmap (":/select_file_dis_16px.png"); 147 } 148 149 QPixmap PixmapPool::pixmap (PixmapType aType) const 150 { 151 return aType > InvalidPixmap && aType < MaxIndex ? mPool [aType] : 0; 152 } 153 154 /* Abstract Controller Type */ 155 AbstractControllerType::AbstractControllerType (KStorageBus aBusType, KStorageControllerType aCtrType) 156 : mBusType (aBusType) 157 , mCtrType (aCtrType) 158 , mPixmap (PixmapPool::InvalidPixmap) 159 { 160 AssertMsg (mBusType != KStorageBus_Null, ("Wrong Bus Type {%d}!\n", mBusType)); 161 AssertMsg (mCtrType != KStorageControllerType_Null, ("Wrong Controller Type {%d}!\n", mCtrType)); 162 163 switch (mBusType) 164 { 165 case KStorageBus_IDE: 166 mPixmap = PixmapPool::IDEController; 167 break; 168 case KStorageBus_SATA: 169 mPixmap = PixmapPool::SATAController; 170 break; 171 case KStorageBus_SCSI: 172 mPixmap = PixmapPool::SCSIController; 173 break; 174 case KStorageBus_Floppy: 175 mPixmap = PixmapPool::FloppyController; 176 break; 177 default: 178 break; 179 } 180 181 AssertMsg (mPixmap != PixmapPool::InvalidPixmap, ("Bus pixmap was not set!\n")); 182 } 183 184 KStorageBus AbstractControllerType::busType() const 185 { 186 return mBusType; 187 } 188 189 KStorageControllerType AbstractControllerType::ctrType() const 190 { 191 return mCtrType; 192 } 193 194 ControllerTypeList AbstractControllerType::ctrTypes() const 195 { 196 ControllerTypeList result; 197 for (uint i = first(); i < first() + size(); ++ i) 198 result << (KStorageControllerType) i; 199 return result; 200 } 201 202 PixmapPool::PixmapType AbstractControllerType::pixmap() const 203 { 204 return mPixmap; 205 } 206 207 void AbstractControllerType::setCtrType (KStorageControllerType aCtrType) 208 { 209 mCtrType = aCtrType; 210 } 211 212 /* IDE Controller Type */ 213 IDEControllerType::IDEControllerType (KStorageControllerType aSubType) 214 : AbstractControllerType (KStorageBus_IDE, aSubType) 215 { 216 } 217 218 DeviceTypeList IDEControllerType::deviceTypeList() const 219 { 220 return DeviceTypeList() << KDeviceType_HardDisk << KDeviceType_DVD; 221 } 222 223 KStorageControllerType IDEControllerType::first() const 224 { 225 return KStorageControllerType_PIIX3; 226 } 227 228 uint IDEControllerType::size() const 229 { 230 return 3; 231 } 232 233 /* SATA Controller Type */ 234 SATAControllerType::SATAControllerType (KStorageControllerType aSubType) 235 : AbstractControllerType (KStorageBus_SATA, aSubType) 236 { 237 } 238 239 DeviceTypeList SATAControllerType::deviceTypeList() const 240 { 241 return DeviceTypeList() << KDeviceType_HardDisk << KDeviceType_DVD; 242 } 243 244 KStorageControllerType SATAControllerType::first() const 245 { 246 return KStorageControllerType_IntelAhci; 247 } 248 249 uint SATAControllerType::size() const 250 { 251 return 1; 252 } 253 254 /* SCSI Controller Type */ 255 SCSIControllerType::SCSIControllerType (KStorageControllerType aSubType) 256 : AbstractControllerType (KStorageBus_SCSI, aSubType) 257 { 258 } 259 260 DeviceTypeList SCSIControllerType::deviceTypeList() const 261 { 262 return DeviceTypeList() << KDeviceType_HardDisk << KDeviceType_DVD; 263 } 264 265 KStorageControllerType SCSIControllerType::first() const 266 { 267 return KStorageControllerType_LsiLogic; 268 } 269 270 uint SCSIControllerType::size() const 271 { 272 return 2; 273 } 274 275 /* Floppy Controller Type */ 276 FloppyControllerType::FloppyControllerType (KStorageControllerType aSubType) 277 : AbstractControllerType (KStorageBus_Floppy, aSubType) 278 { 279 } 280 281 DeviceTypeList FloppyControllerType::deviceTypeList() const 282 { 283 return DeviceTypeList() << KDeviceType_Floppy; 284 } 285 286 KStorageControllerType FloppyControllerType::first() const 287 { 288 return KStorageControllerType_I82078; 289 } 290 291 uint FloppyControllerType::size() const 292 { 293 return 1; 294 } 295 296 /* Abstract Item */ 297 AbstractItem::AbstractItem (AbstractItem *aParent) 298 : mParent (aParent) 299 , mId (QUuid::createUuid()) 300 { 301 if (mParent) mParent->addChild (this); 302 } 303 304 AbstractItem::~AbstractItem() 305 { 306 if (mParent) mParent->delChild (this); 307 } 308 309 AbstractItem* AbstractItem::parent() 310 { 311 return mParent; 312 } 313 314 QUuid AbstractItem::id() 315 { 316 return mId; 317 } 318 319 /* Root Item */ 320 RootItem::RootItem() 321 : AbstractItem (0) 322 { 323 } 324 325 RootItem::~RootItem() 326 { 327 while (!mControllers.isEmpty()) 328 delete mControllers.first(); 329 } 330 331 AbstractItem::ItemType RootItem::rtti() const 332 { 333 return Type_RootItem; 334 } 335 336 AbstractItem* RootItem::childByPos (int aIndex) 337 { 338 return mControllers [aIndex]; 339 } 340 341 AbstractItem* RootItem::childById (const QUuid &aId) 342 { 343 for (int i = 0; i < childCount(); ++ i) 344 if (mControllers [i]->id() == aId) 345 return mControllers [i]; 346 return 0; 347 } 348 349 int RootItem::posOfChild (AbstractItem *aItem) const 350 { 351 return mControllers.indexOf (aItem); 352 } 353 354 int RootItem::childCount() const 355 { 356 return mControllers.size(); 357 } 358 359 QString RootItem::text() const 360 { 361 return QString(); 362 } 363 364 QString RootItem::tip() const 365 { 366 return QString(); 367 } 368 369 QPixmap RootItem::pixmap() 370 { 371 return QPixmap(); 372 } 373 374 void RootItem::addChild (AbstractItem *aItem) 375 { 376 mControllers << aItem; 377 } 378 379 void RootItem::delChild (AbstractItem *aItem) 380 { 381 mControllers.removeAll (aItem); 382 } 383 384 /* Controller Item */ 385 ControllerItem::ControllerItem (AbstractItem *aParent, const QString &aName, 386 KStorageBus aBusType, KStorageControllerType aControllerType) 387 : AbstractItem (aParent) 388 , mCtrName (aName) 389 , mCtrType (0) 390 { 391 /* Check for proper parent type */ 392 AssertMsg (mParent->rtti() == AbstractItem::Type_RootItem, ("Incorrect parent type!\n")); 393 394 /* Select default type */ 395 switch (aBusType) 396 { 397 case KStorageBus_IDE: 398 mCtrType = new IDEControllerType (aControllerType); 399 break; 400 case KStorageBus_SATA: 401 mCtrType = new SATAControllerType (aControllerType); 402 break; 403 case KStorageBus_SCSI: 404 mCtrType = new SCSIControllerType (aControllerType); 405 break; 406 case KStorageBus_Floppy: 407 mCtrType = new FloppyControllerType (aControllerType); 408 break; 409 default: 410 AssertMsgFailed (("Wrong Controller Type {%d}!\n", aBusType)); 411 break; 412 } 413 } 414 415 ControllerItem::~ControllerItem() 416 { 417 delete mCtrType; 418 while (!mAttachments.isEmpty()) 419 delete mAttachments.first(); 420 } 421 422 AbstractItem::ItemType ControllerItem::rtti() const 423 { 424 return Type_ControllerItem; 425 } 426 427 AbstractItem* ControllerItem::childByPos (int aIndex) 428 { 429 return mAttachments [aIndex]; 430 } 431 432 AbstractItem* ControllerItem::childById (const QUuid &aId) 433 { 434 for (int i = 0; i < childCount(); ++ i) 435 if (mAttachments [i]->id() == aId) 436 return mAttachments [i]; 437 return 0; 438 } 439 440 int ControllerItem::posOfChild (AbstractItem *aItem) const 441 { 442 return mAttachments.indexOf (aItem); 443 } 444 445 int ControllerItem::childCount() const 446 { 447 return mAttachments.size(); 448 } 449 450 QString ControllerItem::text() const 451 { 452 return ctrName(); 453 } 454 455 QString ControllerItem::tip() const 456 { 457 return QString(); 458 } 459 460 QPixmap ControllerItem::pixmap() 461 { 462 return PixmapPool::pool()->pixmap (mCtrType->pixmap()); 463 } 464 465 KStorageBus ControllerItem::ctrBusType() const 466 { 467 return mCtrType->busType(); 468 } 469 470 QString ControllerItem::ctrName() const 471 { 472 return mCtrName; 473 } 474 475 KStorageControllerType ControllerItem::ctrType() const 476 { 477 return mCtrType->ctrType(); 478 } 479 480 ControllerTypeList ControllerItem::ctrTypes() const 481 { 482 return mCtrType->ctrTypes(); 483 } 484 485 void ControllerItem::setCtrName (const QString &aCtrName) 486 { 487 mCtrName = aCtrName; 488 } 489 490 void ControllerItem::setCtrType (KStorageControllerType aCtrType) 491 { 492 mCtrType->setCtrType (aCtrType); 493 } 494 495 SlotsList ControllerItem::ctrAllSlots() const 496 { 497 SlotsList allSlots; 498 CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties(); 499 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus (mCtrType->busType()); ++ i) 500 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus (mCtrType->busType()); ++ j) 501 allSlots << StorageSlot (mCtrType->busType(), i, j); 502 return allSlots; 503 } 504 505 SlotsList ControllerItem::ctrUsedSlots() const 506 { 507 SlotsList usedSlots; 508 for (int i = 0; i < mAttachments.size(); ++ i) 509 usedSlots << static_cast <AttachmentItem*> (mAttachments [i])->attSlot(); 510 return usedSlots; 511 } 512 513 DeviceTypeList ControllerItem::ctrDeviceTypeList() const 514 { 515 return mCtrType->deviceTypeList(); 516 } 517 518 QStringList ControllerItem::ctrAllMediumIds() const 519 { 520 QStringList allImages; 521 for (VBoxMediaList::const_iterator it = vboxGlobal().currentMediaList().begin(); 522 it != vboxGlobal().currentMediaList().end(); ++ it) 523 { 524 foreach (KDeviceType deviceType, mCtrType->deviceTypeList()) 525 { 526 if ((*it).isNull() || typeToGlobal ((*it).type()) == deviceType) 527 { 528 allImages << (*it).id(); 529 break; 530 } 531 } 532 } 533 return allImages; 534 } 535 536 QStringList ControllerItem::ctrUsedMediumIds() const 537 { 538 QStringList usedImages; 539 for (int i = 0; i < mAttachments.size(); ++ i) 540 usedImages << static_cast <AttachmentItem*> (mAttachments [i])->attMediumId(); 541 return usedImages; 542 } 543 544 void ControllerItem::addChild (AbstractItem *aItem) 545 { 546 mAttachments << aItem; 547 } 548 549 void ControllerItem::delChild (AbstractItem *aItem) 550 { 551 mAttachments.removeAll (aItem); 552 } 553 554 /* Attachment Item */ 555 AttachmentItem::AttachmentItem (AbstractItem *aParent, KDeviceType aDeviceType) 556 : AbstractItem (aParent) 557 , mAttDeviceType (aDeviceType) 558 , mAttIsHostDrive (false) 559 , mAttIsPassthrough (false) 560 { 561 /* Check for proper parent type */ 562 AssertMsg (mParent->rtti() == AbstractItem::Type_ControllerItem, ("Incorrect parent type!\n")); 563 564 /* Select default slot */ 565 AssertMsg (!attSlots().isEmpty(), ("There should be at least one available slot!\n")); 566 mAttSlot = attSlots() [0]; 567 568 /* Try to select unique medium */ 569 QStringList freeMediumIds (attMediumIds()); 570 switch (mAttDeviceType) 571 { 572 case KDeviceType_HardDisk: 573 if (freeMediumIds.size() > 0) 574 setAttMediumId (freeMediumIds [0]); 575 break; 576 case KDeviceType_DVD: 577 case KDeviceType_Floppy: 578 if (freeMediumIds.size() > 1) 579 setAttMediumId (freeMediumIds [1]); 580 break; 581 default: 582 break; 583 } 584 } 585 586 AbstractItem::ItemType AttachmentItem::rtti() const 587 { 588 return Type_AttachmentItem; 589 } 590 591 AbstractItem* AttachmentItem::childByPos (int /* aIndex */) 592 { 593 return 0; 594 } 595 596 AbstractItem* AttachmentItem::childById (const QUuid& /* aId */) 597 { 598 return 0; 599 } 600 601 int AttachmentItem::posOfChild (AbstractItem* /* aItem */) const 602 { 603 return 0; 604 } 605 606 int AttachmentItem::childCount() const 607 { 608 return 0; 609 } 610 611 QString AttachmentItem::text() const 612 { 613 return mAttName; 614 } 615 616 QString AttachmentItem::tip() const 617 { 618 return mAttTip; 619 } 620 621 QPixmap AttachmentItem::pixmap() 622 { 623 if (mAttPixmap.isNull()) 624 { 625 switch (mAttDeviceType) 626 { 627 case KDeviceType_HardDisk: 628 mAttPixmap = PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentEn); 629 break; 630 case KDeviceType_DVD: 631 mAttPixmap = PixmapPool::pool()->pixmap (PixmapPool::CDAttachmentEn); 632 break; 633 case KDeviceType_Floppy: 634 mAttPixmap = PixmapPool::pool()->pixmap (PixmapPool::FDAttachmentEn); 635 break; 636 default: 637 break; 638 } 639 } 640 return mAttPixmap; 641 } 642 643 StorageSlot AttachmentItem::attSlot() const 644 { 645 return mAttSlot; 646 } 647 648 SlotsList AttachmentItem::attSlots() const 649 { 650 ControllerItem *ctr = static_cast <ControllerItem*> (mParent); 651 652 /* Filter list from used slots */ 653 SlotsList allSlots (ctr->ctrAllSlots()); 654 SlotsList usedSlots (ctr->ctrUsedSlots()); 655 foreach (StorageSlot usedSlot, usedSlots) 656 if (usedSlot != mAttSlot) 657 allSlots.removeAll (usedSlot); 658 659 return allSlots; 660 } 661 662 KDeviceType AttachmentItem::attDeviceType() const 663 { 664 return mAttDeviceType; 665 } 666 667 DeviceTypeList AttachmentItem::attDeviceTypes() const 668 { 669 return static_cast <ControllerItem*> (mParent)->ctrDeviceTypeList(); 670 } 671 672 QString AttachmentItem::attMediumId() const 673 { 674 return mAttMediumId; 675 } 676 677 QStringList AttachmentItem::attMediumIds (bool aFilter) const 678 { 679 ControllerItem *ctr = static_cast <ControllerItem*> (mParent); 680 QStringList allMediumIds; 681 682 /* Populate list of suitable medium ids */ 683 foreach (QString mediumId, ctr->ctrAllMediumIds()) 684 { 685 VBoxMedium medium = vboxGlobal().findMedium (mediumId); 686 if ((medium.isNull() && mAttDeviceType != KDeviceType_HardDisk) || 687 (!medium.isNull() && typeToGlobal (medium.type()) == mAttDeviceType)) 688 allMediumIds << mediumId; 689 } 690 691 if (aFilter) 692 { 693 /* Filter list from used medium ids */ 694 QStringList usedMediumIds (ctr->ctrUsedMediumIds()); 695 foreach (QString usedMediumId, usedMediumIds) 696 if (usedMediumId != mAttMediumId) 697 allMediumIds.removeAll (usedMediumId); 698 } 699 700 return allMediumIds; 701 } 702 703 bool AttachmentItem::attIsHostDrive() const 704 { 705 return mAttIsHostDrive; 706 } 707 708 bool AttachmentItem::attIsPassthrough() const 709 { 710 return mAttIsPassthrough; 711 } 712 713 void AttachmentItem::setAttSlot (const StorageSlot &aAttSlot) 714 { 715 mAttSlot = aAttSlot; 716 } 717 718 void AttachmentItem::setAttDevice (KDeviceType aAttDeviceType) 719 { 720 mAttDeviceType = aAttDeviceType; 721 } 722 723 void AttachmentItem::setAttMediumId (const QString &aAttMediumId) 724 { 725 VBoxMedium medium; 726 727 /* Caching first available medium */ 728 if (aAttMediumId == firstAvailable && !attMediumIds (false).isEmpty()) 729 medium = vboxGlobal().findMedium (attMediumIds (false) [0]); 730 /* Caching passed medium */ 731 else if (!aAttMediumId.isEmpty()) 732 medium = vboxGlobal().findMedium (aAttMediumId); 733 734 cache (medium); 735 } 736 737 void AttachmentItem::setAttIsPassthrough (bool aIsAttPassthrough) 738 { 739 mAttIsPassthrough = aIsAttPassthrough; 740 } 741 742 QString AttachmentItem::attSize() const 743 { 744 return mAttSize; 745 } 746 747 QString AttachmentItem::attLogicalSize() const 748 { 749 return mAttLogicalSize; 750 } 751 752 QString AttachmentItem::attLocation() const 753 { 754 return mAttLocation; 755 } 756 757 QString AttachmentItem::attFormat() const 758 { 759 return mAttFormat; 760 } 761 762 QString AttachmentItem::attUsage() const 763 { 764 return mAttUsage; 765 } 766 767 void AttachmentItem::cache (const VBoxMedium &aMedium) 768 { 769 mAttMediumId = aMedium.id(); 770 771 /* Cache medium information */ 772 mAttName = aMedium.name (true); 773 mAttTip = aMedium.toolTipCheckRO (true); 774 mAttPixmap = aMedium.iconCheckRO (true); 775 mAttIsHostDrive = aMedium.isHostDrive(); 776 777 /* Cache additional information */ 778 mAttSize = aMedium.size(); 779 mAttLogicalSize = aMedium.logicalSize(); 780 mAttLocation = aMedium.location(); 781 mAttFormat = QString ("%1 (%2)").arg (aMedium.hardDiskType()).arg (aMedium.hardDiskFormat()); 782 mAttUsage = aMedium.usage(); 783 784 /* Fill empty attributes */ 785 if (mAttUsage.isEmpty()) 786 mAttUsage = QString ("--"); 787 } 788 789 void AttachmentItem::addChild (AbstractItem* /* aItem */) 790 { 791 } 792 793 void AttachmentItem::delChild (AbstractItem* /* aItem */) 794 { 795 } 796 797 /* Storage model */ 798 StorageModel::StorageModel (QObject *aParent) 799 : QAbstractItemModel (aParent) 800 , mRootItem (new RootItem) 801 { 802 } 803 804 StorageModel::~StorageModel() 805 { 806 delete mRootItem; 807 } 808 809 int StorageModel::rowCount (const QModelIndex &aParent) const 810 { 811 return !aParent.isValid() ? 1 /* only root item has invalid parent */ : 812 static_cast <AbstractItem*> (aParent.internalPointer())->childCount(); 813 } 814 815 int StorageModel::columnCount (const QModelIndex &aParent) const 816 { 817 return 1; 818 } 819 820 QModelIndex StorageModel::root() const 821 { 822 return index (0, 0); 823 } 824 825 QModelIndex StorageModel::index (int aRow, int aColumn, const QModelIndex &aParent) const 826 { 827 if (!hasIndex (aRow, aColumn, aParent)) 828 return QModelIndex(); 829 830 AbstractItem *item = !aParent.isValid() ? mRootItem : 831 static_cast <AbstractItem*> (aParent.internalPointer())->childByPos (aRow); 832 833 return item ? createIndex (aRow, aColumn, item) : QModelIndex(); 834 } 835 836 QModelIndex StorageModel::parent (const QModelIndex &aIndex) const 837 { 838 if (!aIndex.isValid()) 839 return QModelIndex(); 840 841 AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer()); 842 AbstractItem *parentOfItem = item->parent(); 843 AbstractItem *parentOfParent = parentOfItem ? parentOfItem->parent() : 0; 844 int position = parentOfParent ? parentOfParent->posOfChild (parentOfItem) : 0; 845 846 if (parentOfItem) 847 return createIndex (position, 0, parentOfItem); 848 else 849 return QModelIndex(); 850 } 851 852 QVariant StorageModel::data (const QModelIndex &aIndex, int aRole) const 97 853 { 98 854 if (!aIndex.isValid()) 99 855 return QVariant(); 100 856 101 if (aIndex.row() < 0 || aIndex.row() >= rowCount())102 return QVariant();103 104 857 switch (aRole) 105 858 { 106 case Qt::DisplayRole: 107 { 108 if (aIndex.row() == rowCount() - 1) 109 return QVariant(); 110 else if (aIndex.column() == 0) 111 return QVariant (mUsedSlotsList [aIndex.row()].name); 112 else if (aIndex.column() == 1) 113 return QVariant (mUsedDisksList [aIndex.row()].name); 114 115 Assert (0); 116 return QVariant(); 117 } 118 case Qt::DecorationRole: 119 { 120 return aIndex.row() != rowCount() - 1 && 121 aIndex.column() == 1 && 122 (aIndex != mParent->currentIndex() || 123 !DiskEditor::activeEditor()) 124 ? QVariant (mUsedDisksList [aIndex.row()].pix) : QVariant(); 125 } 126 case Qt::EditRole: 127 { 128 if (aIndex.column() == 0) 129 return QVariant (mSlotId, &mUsedSlotsList [aIndex.row()]); 130 else if (aIndex.column() == 1) 131 return QVariant (mDiskId, &mUsedDisksList [aIndex.row()]); 132 133 Assert (0); 134 return QVariant(); 859 /* Basic Attributes: */ 860 case Qt::FontRole: 861 { 862 return QVariant (qApp->font()); 863 } 864 case Qt::SizeHintRole: 865 { 866 QFontMetrics fm (data (aIndex, Qt::FontRole).value <QFont>()); 867 int minimumHeight = qMax (fm.height(), data (aIndex, R_IconSize).toInt()); 868 int margin = data (aIndex, R_Margin).toInt(); 869 return QSize (1 /* ignoring width */, 2 * margin + minimumHeight); 135 870 } 136 871 case Qt::ToolTipRole: 137 872 { 138 if (aIndex.row() == rowCount() - 1) 139 return QVariant (tr ("Double-click to add a new attachment")); 140 141 return QVariant (mUsedDisksList [aIndex.row()].tip); 873 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 874 return item->tip(); 875 return QString(); 876 } 877 878 /* Advanced Attributes: */ 879 case R_ItemId: 880 { 881 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 882 return item->id().toString(); 883 return QUuid().toString(); 884 } 885 case R_ItemPixmap: 886 { 887 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 888 return item->pixmap(); 889 return QPixmap(); 890 } 891 case R_ItemPixmapRect: 892 { 893 int margin = data (aIndex, R_Margin).toInt(); 894 int width = data (aIndex, R_IconSize).toInt(); 895 return QRect (margin, margin, width, width); 896 } 897 case R_ItemName: 898 { 899 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 900 return item->text(); 901 return QString(); 902 } 903 case R_ItemNamePoint: 904 { 905 int margin = data (aIndex, R_Margin).toInt(); 906 int spacing = data (aIndex, R_Spacing).toInt(); 907 int width = data (aIndex, R_IconSize).toInt(); 908 QFontMetrics fm (data (aIndex, Qt::FontRole).value <QFont>()); 909 QSize sizeHint = data (aIndex, Qt::SizeHintRole).toSize(); 910 return QPoint (margin + width + 2 * spacing, 911 sizeHint.height() / 2 + fm.ascent() / 2 - 1 /* base line */); 912 } 913 case R_ItemType: 914 { 915 QVariant result (QVariant::fromValue (AbstractItem::Type_InvalidItem)); 916 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 917 result.setValue (item->rtti()); 918 return result; 919 } 920 case R_IsController: 921 { 922 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 923 return item->rtti() == AbstractItem::Type_ControllerItem; 924 return false; 925 } 926 case R_IsAttachment: 927 { 928 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 929 return item->rtti() == AbstractItem::Type_AttachmentItem; 930 return false; 931 } 932 933 case R_IsMoreControllersPossible: 934 { 935 return rowCount (root()) < 16; 936 } 937 case R_IsMoreAttachmentsPossible: 938 { 939 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 940 { 941 if (item->rtti() == AbstractItem::Type_ControllerItem) 942 { 943 ControllerItem *ctr = static_cast <ControllerItem*> (item); 944 CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties(); 945 return (uint) rowCount (aIndex) < sp.GetMaxPortCountForStorageBus (ctr->ctrBusType()) * 946 sp.GetMaxDevicesPerPortForStorageBus (ctr->ctrBusType()); 947 } 948 } 949 return false; 950 } 951 952 case R_CtrName: 953 { 954 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 955 if (item->rtti() == AbstractItem::Type_ControllerItem) 956 return static_cast <ControllerItem*> (item)->ctrName(); 957 return QString(); 958 } 959 case R_CtrType: 960 { 961 QVariant result (QVariant::fromValue (KStorageControllerType_Null)); 962 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 963 if (item->rtti() == AbstractItem::Type_ControllerItem) 964 result.setValue (static_cast <ControllerItem*> (item)->ctrType()); 965 return result; 966 } 967 case R_CtrTypes: 968 { 969 QVariant result (QVariant::fromValue (ControllerTypeList())); 970 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 971 if (item->rtti() == AbstractItem::Type_ControllerItem) 972 result.setValue (static_cast <ControllerItem*> (item)->ctrTypes()); 973 return result; 974 } 975 case R_CtrDevices: 976 { 977 QVariant result (QVariant::fromValue (DeviceTypeList())); 978 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 979 if (item->rtti() == AbstractItem::Type_ControllerItem) 980 result.setValue (static_cast <ControllerItem*> (item)->ctrDeviceTypeList()); 981 return result; 982 } 983 case R_CtrBusType: 984 { 985 QVariant result (QVariant::fromValue (KStorageBus_Null)); 986 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 987 if (item->rtti() == AbstractItem::Type_ControllerItem) 988 result.setValue (static_cast <ControllerItem*> (item)->ctrBusType()); 989 return result; 990 } 991 992 case R_AttSlot: 993 { 994 QVariant result (QVariant::fromValue (StorageSlot())); 995 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 996 if (item->rtti() == AbstractItem::Type_AttachmentItem) 997 result.setValue (static_cast <AttachmentItem*> (item)->attSlot()); 998 return result; 999 } 1000 case R_AttSlots: 1001 { 1002 QVariant result (QVariant::fromValue (SlotsList())); 1003 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1004 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1005 result.setValue (static_cast <AttachmentItem*> (item)->attSlots()); 1006 return result; 1007 } 1008 case R_AttDevice: 1009 { 1010 QVariant result (QVariant::fromValue (KDeviceType_Null)); 1011 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1012 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1013 result.setValue (static_cast <AttachmentItem*> (item)->attDeviceType()); 1014 return result; 1015 } 1016 case R_AttDevices: 1017 { 1018 QVariant result (QVariant::fromValue (DeviceTypeList())); 1019 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1020 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1021 result.setValue (static_cast <AttachmentItem*> (item)->attDeviceTypes()); 1022 return result; 1023 } 1024 case R_AttMediumId: 1025 { 1026 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1027 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1028 return static_cast <AttachmentItem*> (item)->attMediumId(); 1029 return QString(); 1030 } 1031 case R_AttIsHostDrive: 1032 { 1033 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1034 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1035 return static_cast <AttachmentItem*> (item)->attIsHostDrive(); 1036 return false; 1037 } 1038 case R_AttIsPassthrough: 1039 { 1040 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1041 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1042 return static_cast <AttachmentItem*> (item)->attIsPassthrough(); 1043 return false; 1044 } 1045 case R_AttSize: 1046 { 1047 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1048 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1049 return static_cast <AttachmentItem*> (item)->attSize(); 1050 return QString(); 1051 } 1052 case R_AttLogicalSize: 1053 { 1054 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1055 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1056 return static_cast <AttachmentItem*> (item)->attLogicalSize(); 1057 return QString(); 1058 } 1059 case R_AttLocation: 1060 { 1061 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1062 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1063 return static_cast <AttachmentItem*> (item)->attLocation(); 1064 return QString(); 1065 } 1066 case R_AttFormat: 1067 { 1068 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1069 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1070 return static_cast <AttachmentItem*> (item)->attFormat(); 1071 return QString(); 1072 } 1073 case R_AttUsage: 1074 { 1075 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1076 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1077 return static_cast <AttachmentItem*> (item)->attUsage(); 1078 return QString(); 1079 } 1080 case R_Margin: 1081 { 1082 return 4; 1083 } 1084 case R_Spacing: 1085 { 1086 return 4; 1087 } 1088 case R_IconSize: 1089 { 1090 return 16; 1091 } 1092 1093 case R_HDPixmapEn: 1094 { 1095 return PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentEn); 1096 } 1097 case R_HDPixmapDis: 1098 { 1099 return PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentDis); 1100 } 1101 case R_CDPixmapEn: 1102 { 1103 return PixmapPool::pool()->pixmap (PixmapPool::CDAttachmentEn); 1104 } 1105 case R_CDPixmapDis: 1106 { 1107 return PixmapPool::pool()->pixmap (PixmapPool::CDAttachmentDis); 1108 } 1109 case R_FDPixmapEn: 1110 { 1111 return PixmapPool::pool()->pixmap (PixmapPool::FDAttachmentEn); 1112 } 1113 case R_FDPixmapDis: 1114 { 1115 return PixmapPool::pool()->pixmap (PixmapPool::FDAttachmentDis); 1116 } 1117 case R_HDPixmapRect: 1118 { 1119 int margin = data (aIndex, R_Margin).toInt(); 1120 int spacing = data (aIndex, R_Spacing).toInt(); 1121 int width = data (aIndex, R_IconSize).toInt(); 1122 return QRect (0 - width - spacing - width - margin, margin, width, width); 1123 } 1124 case R_CDPixmapRect: 1125 { 1126 int margin = data (aIndex, R_Margin).toInt(); 1127 int width = data (aIndex, R_IconSize).toInt(); 1128 return QRect (0 - width - margin, margin, width, width); 1129 } 1130 case R_FDPixmapRect: 1131 { 1132 int margin = data (aIndex, R_Margin).toInt(); 1133 int width = data (aIndex, R_IconSize).toInt(); 1134 return QRect (0 - width - margin, margin, width, width); 1135 } 1136 1137 case R_PlusPixmapEn: 1138 { 1139 return PixmapPool::pool()->pixmap (PixmapPool::PlusEn); 1140 } 1141 case R_PlusPixmapDis: 1142 { 1143 return PixmapPool::pool()->pixmap (PixmapPool::PlusDis); 1144 } 1145 case R_MinusPixmapEn: 1146 { 1147 return PixmapPool::pool()->pixmap (PixmapPool::MinusEn); 1148 } 1149 case R_MinusPixmapDis: 1150 { 1151 return PixmapPool::pool()->pixmap (PixmapPool::MinusDis); 1152 } 1153 case R_AdderPoint: 1154 { 1155 int margin = data (aIndex, R_Margin).toInt(); 1156 return QPoint (margin + 6, margin + 6); 142 1157 } 143 1158 default: 144 { 145 return QVariant(); 146 } 147 } 148 } 149 150 bool AttachmentsModel::setData (const QModelIndex &aIndex, 151 const QVariant &aValue, 152 int /* aRole = Qt::EditRole */) 1159 break; 1160 } 1161 return QVariant(); 1162 } 1163 1164 bool StorageModel::setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole) 153 1165 { 154 1166 if (!aIndex.isValid()) 155 return false; 156 157 if (aIndex.row() < 0 || aIndex.row() >= rowCount()) 158 return false; 159 160 if (aIndex.column() == 0) 161 { 162 SlotValue newSlot = aValue.isValid() ? 163 aValue.value <SlotValue>() : SlotValue(); 164 if (mUsedSlotsList [aIndex.row()] != newSlot) 165 { 166 mUsedSlotsList [aIndex.row()] = newSlot; 167 emit dataChanged (aIndex, aIndex); 168 return true; 169 } 170 return false; 171 } else 172 if (aIndex.column() == 1) 173 { 174 DiskValue newDisk = aValue.isValid() ? 175 aValue.value <DiskValue>() : DiskValue(); 176 if (mUsedDisksList [aIndex.row()] != newDisk) 177 { 178 mUsedDisksList [aIndex.row()] = newDisk; 179 emit dataChanged (aIndex, aIndex); 180 return true; 181 } 182 return false; 183 } 184 Assert (0); 1167 return QAbstractItemModel::setData (aIndex, aValue, aRole); 1168 1169 switch (aRole) 1170 { 1171 case R_CtrName: 1172 { 1173 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1174 if (item->rtti() == AbstractItem::Type_ControllerItem) 1175 { 1176 static_cast <ControllerItem*> (item)->setCtrName (aValue.toString()); 1177 emit dataChanged (aIndex, aIndex); 1178 return true; 1179 } 1180 return false; 1181 } 1182 case R_CtrType: 1183 { 1184 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1185 if (item->rtti() == AbstractItem::Type_ControllerItem) 1186 { 1187 static_cast <ControllerItem*> (item)->setCtrType (aValue.value <KStorageControllerType>()); 1188 emit dataChanged (aIndex, aIndex); 1189 return true; 1190 } 1191 return false; 1192 } 1193 case R_AttSlot: 1194 { 1195 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1196 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1197 { 1198 static_cast <AttachmentItem*> (item)->setAttSlot (aValue.value <StorageSlot>()); 1199 emit dataChanged (aIndex, aIndex); 1200 return true; 1201 } 1202 return false; 1203 } 1204 case R_AttDevice: 1205 { 1206 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1207 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1208 { 1209 static_cast <AttachmentItem*> (item)->setAttDevice (aValue.value <KDeviceType>()); 1210 emit dataChanged (aIndex, aIndex); 1211 return true; 1212 } 1213 return false; 1214 } 1215 case R_AttMediumId: 1216 { 1217 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1218 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1219 { 1220 static_cast <AttachmentItem*> (item)->setAttMediumId (aValue.toString()); 1221 emit dataChanged (aIndex, aIndex); 1222 return true; 1223 } 1224 return false; 1225 } 1226 case R_AttIsPassthrough: 1227 { 1228 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 1229 if (item->rtti() == AbstractItem::Type_AttachmentItem) 1230 { 1231 static_cast <AttachmentItem*> (item)->setAttIsPassthrough (aValue.toBool()); 1232 emit dataChanged (aIndex, aIndex); 1233 return true; 1234 } 1235 return false; 1236 } 1237 default: 1238 break; 1239 } 1240 185 1241 return false; 186 1242 } 187 1243 188 QVariant AttachmentsModel::headerData (int aSection, 189 Qt::Orientation aOrientation, 190 int aRole) const 191 { 192 if (aRole != Qt::DisplayRole) 193 return QVariant(); 194 195 if (aOrientation == Qt::Horizontal) 196 return aSection ? tr ("Hard Disk") : tr ("Slot"); 197 else 198 return QVariant(); 199 } 200 201 void AttachmentsModel::addItem (const SlotValue &aSlot, const DiskValue &aDisk) 202 { 203 beginInsertRows (QModelIndex(), rowCount() - 1, rowCount() - 1); 204 mUsedSlotsList.append (aSlot); 205 mUsedDisksList.append (aDisk); 1244 QModelIndex StorageModel::addController (const QString &aCtrName, KStorageBus aBusType, KStorageControllerType aCtrType) 1245 { 1246 beginInsertRows (root(), mRootItem->childCount(), mRootItem->childCount()); 1247 new ControllerItem (mRootItem, aCtrName, aBusType, aCtrType); 206 1248 endInsertRows(); 207 } 208 209 void AttachmentsModel::delItem (int aIndex) 210 { 211 beginRemoveRows (QModelIndex(), aIndex, aIndex); 212 mUsedSlotsList.removeAt (aIndex); 213 mUsedDisksList.removeAt (aIndex); 214 endRemoveRows(); 215 } 216 217 QList <Attachment> AttachmentsModel::fullUsedList() 218 { 219 QList <Attachment> list; 220 QList <SlotValue> slts = usedSlotsList(); 221 QList <DiskValue> dsks = usedDisksList(); 222 for (int i = 0; i < slts.size(); ++ i) 223 list << Attachment (slts [i], dsks [i]); 224 qSort (list.begin(), list.end()); 225 return list; 226 } 227 228 void AttachmentsModel::removeAddController() 229 { 230 int i=0; 231 while (i < mUsedSlotsList.size()) 232 { 233 if (mUsedSlotsList.at (i).bus == KStorageBus_SATA || 234 mUsedSlotsList.at (i).bus == KStorageBus_SCSI) 235 /* We have to use delItem cause then all views are informed about 236 the update */ 237 delItem (i); 238 else 239 ++i; 240 } 241 } 242 243 void AttachmentsModel::updateDisks() 244 { 245 QList <DiskValue> newDisks (HDSettings::instance()->disksList()); 246 for (int i = 0; i < mUsedDisksList.size(); ++ i) 247 { 248 if (newDisks.isEmpty()) 249 mUsedDisksList [i] = DiskValue(); 250 else if (newDisks.contains (mUsedDisksList [i])) 251 mUsedDisksList [i] = DiskValue (mUsedDisksList [i].id); 252 else 253 mUsedDisksList [i] = DiskValue (newDisks [0].id); 254 } 255 emit dataChanged (index (0, 1), index (rowCount() - 1, 1)); 256 } 257 258 /** 259 * QComboBox class reimplementation. 260 * Used as editor for HD Attachment SLOT field. 261 */ 262 SlotEditor::SlotEditor (QWidget *aParent) 263 : QComboBox (aParent) 264 { 265 connect (this, SIGNAL (currentIndexChanged (int)), this, SLOT (onActivate())); 266 connect (this, SIGNAL (readyToCommit (QWidget*)), 267 parent()->parent(), SLOT (commitData (QWidget*))); 268 } 269 270 QVariant SlotEditor::slot() const 271 { 272 int current = currentIndex(); 273 QVariant result; 274 if (current >= 0 && current < mList.size()) 275 result.setValue (mList [current]); 276 return result; 277 } 278 279 void SlotEditor::setSlot (QVariant aSlot) 280 { 281 SlotValue val (aSlot.value <SlotValue>()); 282 populate (val); 283 int current = findText (val.name); 284 setCurrentIndex (current == -1 ? 0 : current); 285 } 286 287 void SlotEditor::onActivate() 288 { 289 emit readyToCommit (this); 290 } 291 292 #if 0 /* F2 key binding left for future releases... */ 293 void SlotEditor::keyPressEvent (QKeyEvent *aEvent) 294 { 295 /* Make F2 key to show the popup. */ 296 if (aEvent->key() == Qt::Key_F2) 297 { 298 aEvent->accept(); 299 showPopup(); 300 } 301 else 302 aEvent->ignore(); 303 QComboBox::keyPressEvent (aEvent); 304 } 305 #endif 306 307 void SlotEditor::populate (const SlotValue &aIncluding) 308 { 309 clear(), mList.clear(); 310 QList <SlotValue> list (HDSettings::instance()->slotsList (aIncluding, true)); 311 for (int i = 0; i < list.size() ; ++ i) 312 { 313 insertItem (i, list [i].name); 314 mList << list [i]; 315 } 316 } 317 318 /** 319 * VBoxMediaComboBox class reimplementation. 320 * Used as editor for HD Attachment DISK field. 321 */ 322 DiskEditor* DiskEditor::mInstance = 0; 323 DiskEditor* DiskEditor::activeEditor() 324 { 325 return mInstance; 326 } 327 328 DiskEditor::DiskEditor (QWidget *aParent) 329 : VBoxMediaComboBox (aParent) 330 { 331 mInstance = this; 332 setIconSize (QSize (iconSize().width() * 2 + 2, iconSize().height())); 333 Assert (!HDSettings::instance()->machine().isNull()); 334 setType (VBoxDefs::MediaType_HardDisk); 335 setMachineId (HDSettings::instance()->machine().GetId()); 336 setShowDiffs (HDSettings::instance()->showDiffs()); 337 connect (this, SIGNAL (currentIndexChanged (int)), this, SLOT (onActivate())); 338 connect (this, SIGNAL (readyToCommit (QWidget *)), 339 parent()->parent(), SLOT (commitData (QWidget *))); 340 refresh(); 341 } 342 DiskEditor::~DiskEditor() 343 { 344 if (mInstance == this) 345 mInstance = 0; 346 } 347 348 QVariant DiskEditor::disk() const 349 { 350 int current = currentIndex(); 351 QVariant result; 352 if (current >= 0 && current < count()) 353 result.setValue (DiskValue (id (current))); 354 return result; 355 } 356 357 void DiskEditor::setDisk (QVariant aDisk) 358 { 359 setCurrentItem (DiskValue (aDisk.value <DiskValue>()).id); 360 } 361 362 void DiskEditor::paintEvent (QPaintEvent*) 363 { 364 /* Create the style painter to paint the elements. */ 365 QStylePainter painter (this); 366 painter.setPen (palette().color (QPalette::Text)); 367 /* Initialize combo-box options and draw the elements. */ 368 QStyleOptionComboBox options; 369 initStyleOption (&options); 370 painter.drawComplexControl (QStyle::CC_ComboBox, options); 371 painter.drawControl (QStyle::CE_ComboBoxLabel, options); 372 } 373 374 void DiskEditor::initStyleOption (QStyleOptionComboBox *aOption) const 375 { 376 /* The base version of Qt4::QComboBox ignores the fact what each 377 * combo-box item can have the icon of different size and uses the 378 * maximum possible icon-size to draw the icon then performing 379 * paintEvent(). As a result, stand-alone icons are painted using 380 * the same huge region as the merged paired icons, so we have to 381 * perform the size calculation ourself... */ 382 383 /* Init all style option by default... */ 384 VBoxMediaComboBox::initStyleOption (aOption); 385 /* But calculate the icon size ourself. */ 386 QIcon currentItemIcon (itemIcon (currentIndex())); 387 QPixmap realPixmap (currentItemIcon.pixmap (iconSize())); 388 aOption->iconSize = realPixmap.size(); 389 } 390 391 void DiskEditor::onActivate() 392 { 393 emit readyToCommit (this); 394 } 395 396 #if 0 /* F2 key binding left for future releases... */ 397 void DiskEditor::keyPressEvent (QKeyEvent *aEvent) 398 { 399 /* Make F2 key to show the popup. */ 400 if (aEvent->key() == Qt::Key_F2) 401 { 402 aEvent->accept(); 403 showPopup(); 404 } 405 else 406 aEvent->ignore(); 407 VBoxMediaComboBox::keyPressEvent (aEvent); 408 } 409 #endif 410 411 /** 412 * Singleton QObject class reimplementation. 413 * Used to make selected HD Attachments slots unique & 414 * stores some local data used for HD Settings. 415 */ 416 HDSettings* HDSettings::mInstance = 0; 417 HDSettings* HDSettings::instance (QWidget *aParent, 418 AttachmentsModel *aWatched) 419 { 420 if (!mInstance) 421 { 422 Assert (aParent && aWatched); 423 mInstance = new HDSettings (aParent, aWatched); 424 } 425 return mInstance; 426 } 427 428 HDSettings::HDSettings (QWidget *aParent, AttachmentsModel *aWatched) 429 : QObject (aParent) 430 , mModel (aWatched) 431 , mAddCount (0) 432 , mAddBus (KStorageBus_Null) 433 , mShowDiffs (false) 434 { 435 makeIDEList(); 436 makeAddControllerList(); 437 } 438 439 HDSettings::~HDSettings() 440 { 441 mInstance = 0; 442 } 443 444 QList <SlotValue> HDSettings::slotsList (const SlotValue &aIncluding, 445 bool aFilter /* = false */) const 446 { 447 /* Compose the full slots list */ 448 QList <SlotValue> list (mIDEList + mAddControllerList); 449 if (!aFilter) 450 return list; 451 452 /* Current used list */ 453 QList <SlotValue> usedList (mModel->usedSlotsList()); 454 455 /* Filter the list */ 456 foreach (SlotValue value, usedList) 457 if (value != aIncluding) 458 list.removeAll (value); 459 460 return list; 461 } 462 463 QList <DiskValue> HDSettings::disksList() const 464 { 465 return mDisksList; 466 } 467 468 bool HDSettings::tryToChooseUniqueDisk (DiskValue &aResult) const 469 { 470 bool status = false; 471 472 /* Current used list */ 473 QList <DiskValue> usedList (mModel->usedDisksList()); 474 475 /* Select the first available disk initially */ 476 aResult = mDisksList.isEmpty() ? DiskValue() : mDisksList [0]; 477 478 /* Search for first not busy disk */ 479 for (int i = 0; i < mDisksList.size(); ++ i) 480 if (!usedList.contains (mDisksList [i])) 481 { 482 aResult = mDisksList [i]; 483 status = true; 484 break; 485 } 486 487 return status; 488 } 489 490 void HDSettings::makeIDEList() 491 { 492 mIDEList.clear(); 493 494 /* IDE Primary Master */ 495 mIDEList << SlotValue (KStorageBus_IDE, 0, 0); 496 /* IDE Primary Slave */ 497 mIDEList << SlotValue (KStorageBus_IDE, 0, 1); 498 /* IDE Secondary Slave */ 499 mIDEList << SlotValue (KStorageBus_IDE, 1, 1); 500 } 501 502 void HDSettings::makeAddControllerList() 503 { 504 mAddControllerList.clear(); 505 506 for (int i = 0; i < mAddCount; ++ i) 507 mAddControllerList << SlotValue (mAddBus, i, 0); 508 } 509 510 void HDSettings::makeMediumList() 511 { 512 mDisksList.clear(); 513 VBoxMediaList list (vboxGlobal().currentMediaList()); 514 foreach (VBoxMedium medium, list) 515 { 516 /* Filter out unnecessary mediums */ 517 if (medium.type() != VBoxDefs::MediaType_HardDisk) 518 continue; 519 520 /* If !mShowDiffs we ignore all diffs except ones that are 521 * directly attached to the related VM in the current state */ 522 if (!mShowDiffs && medium.parent() && 523 !medium.isAttachedInCurStateTo (mMachine.GetId())) 524 continue; 525 526 /* If !mShowDiffs we have to replace the root medium with his 527 * differencing child which is directly used if the parent is found. */ 528 if (!mShowDiffs && medium.parent()) 529 { 530 int index = mDisksList.indexOf (DiskValue (medium.root().id())); 531 if (index != -1) 1249 return index (mRootItem->childCount() - 1, 0, root()); 1250 } 1251 1252 void StorageModel::delController (const QUuid &aCtrId) 1253 { 1254 if (AbstractItem *item = mRootItem->childById (aCtrId)) 1255 { 1256 int itemPosition = mRootItem->posOfChild (item); 1257 beginRemoveRows (root(), itemPosition, itemPosition); 1258 delete item; 1259 endRemoveRows(); 1260 } 1261 } 1262 1263 QModelIndex StorageModel::addAttachment (const QUuid &aCtrId, KDeviceType aDeviceType) 1264 { 1265 if (AbstractItem *parent = mRootItem->childById (aCtrId)) 1266 { 1267 int parentPosition = mRootItem->posOfChild (parent); 1268 QModelIndex parentIndex = index (parentPosition, 0, root()); 1269 beginInsertRows (parentIndex, parent->childCount(), parent->childCount()); 1270 new AttachmentItem (parent, aDeviceType); 1271 endInsertRows(); 1272 return index (parent->childCount() - 1, 0, parentIndex); 1273 } 1274 return QModelIndex(); 1275 } 1276 1277 void StorageModel::delAttachment (const QUuid &aCtrId, const QUuid &aAttId) 1278 { 1279 if (AbstractItem *parent = mRootItem->childById (aCtrId)) 1280 { 1281 int parentPosition = mRootItem->posOfChild (parent); 1282 if (AbstractItem *item = parent->childById (aAttId)) 1283 { 1284 int itemPosition = parent->posOfChild (item); 1285 beginRemoveRows (index (parentPosition, 0, root()), itemPosition, itemPosition); 1286 delete item; 1287 endRemoveRows(); 1288 } 1289 } 1290 } 1291 1292 Qt::ItemFlags StorageModel::flags (const QModelIndex &aIndex) const 1293 { 1294 return !aIndex.isValid() ? QAbstractItemModel::flags (aIndex) : 1295 Qt::ItemIsEnabled | Qt::ItemIsSelectable; 1296 } 1297 1298 /* Storage Delegate */ 1299 StorageDelegate::StorageDelegate (QObject *aParent) 1300 : QItemDelegate (aParent) 1301 { 1302 } 1303 1304 void StorageDelegate::paint (QPainter *aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const 1305 { 1306 if (!aIndex.isValid()) return; 1307 1308 /* Initialize variables */ 1309 QStyle::State state = aOption.state; 1310 QRect rect = aOption.rect; 1311 const StorageModel *model = qobject_cast <const StorageModel*> (aIndex.model()); 1312 Assert (model); 1313 1314 aPainter->save(); 1315 1316 /* Draw selection backgroung */ 1317 if (state & QStyle::State_Selected) 1318 { 1319 QPalette::ColorGroup cg = (state & QStyle::State_Enabled && state & QStyle::State_Active) ? QPalette::Normal : 1320 (state & QStyle::State_Enabled) ? QPalette::Inactive : QPalette::Disabled; 1321 aPainter->fillRect (rect, aOption.palette.brush (cg, QPalette::Highlight)); 1322 } 1323 1324 aPainter->translate (rect.x(), rect.y()); 1325 1326 /* Draw Item Pixmap */ 1327 aPainter->drawPixmap (model->data (aIndex, StorageModel::R_ItemPixmapRect).toRect().topLeft(), 1328 model->data (aIndex, StorageModel::R_ItemPixmap).value <QPixmap>()); 1329 1330 /* Draw expand/collapse Pixmap */ 1331 if (model->hasChildren (aIndex)) 1332 { 1333 QPixmap expander = state & QStyle::State_Open ? 1334 model->data (aIndex, StorageModel::R_MinusPixmapEn).value <QPixmap>() : 1335 model->data (aIndex, StorageModel::R_PlusPixmapEn).value <QPixmap>(); 1336 aPainter->drawPixmap (model->data (aIndex, StorageModel::R_AdderPoint).toPoint(), expander); 1337 } 1338 1339 /* Draw compressed item name */ 1340 int margin = model->data (aIndex, StorageModel::R_Margin).toInt(); 1341 int iconWidth = model->data (aIndex, StorageModel::R_IconSize).toInt(); 1342 int spacing = model->data (aIndex, StorageModel::R_Spacing).toInt(); 1343 QPoint textPosition = model->data (aIndex, StorageModel::R_ItemNamePoint).toPoint(); 1344 int textWidth = rect.width() - textPosition.x(); 1345 if (model->data (aIndex, StorageModel::R_IsController).toBool() && state & QStyle::State_Selected) 1346 { 1347 textWidth -= (2 * spacing + iconWidth + margin); 1348 if (model->data (aIndex, StorageModel::R_CtrBusType).value <KStorageBus>() != KStorageBus_Floppy) 1349 textWidth -= (spacing + iconWidth); 1350 } 1351 QString text (model->data (aIndex, StorageModel::R_ItemName).toString()); 1352 QString shortText (text); 1353 QFont font = model->data (aIndex, Qt::FontRole).value <QFont>(); 1354 QFontMetrics fm (font); 1355 while ((shortText.size() > 1) && (fm.width (shortText) + fm.width ("...") > textWidth)) 1356 shortText.truncate (shortText.size() - 1); 1357 if (shortText != text) 1358 shortText += "..."; 1359 aPainter->setFont (font); 1360 aPainter->drawText (textPosition, shortText); 1361 1362 /* Draw Controller Additions */ 1363 if (model->data (aIndex, StorageModel::R_IsController).toBool() && state & QStyle::State_Selected) 1364 { 1365 DeviceTypeList devicesList (model->data (aIndex, StorageModel::R_CtrDevices).value <DeviceTypeList>()); 1366 for (int i = 0; i < devicesList.size(); ++ i) 1367 { 1368 KDeviceType deviceType = devicesList [i]; 1369 1370 QRect deviceRect; 1371 QPixmap devicePixmap; 1372 switch (deviceType) 532 1373 { 533 mDisksList.replace (index, DiskValue (medium.id())); 534 continue; 1374 case KDeviceType_HardDisk: 1375 { 1376 deviceRect = model->data (aIndex, StorageModel::R_HDPixmapRect).value <QRect>(); 1377 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 1378 model->data (aIndex, StorageModel::R_HDPixmapEn).value <QPixmap>() : 1379 model->data (aIndex, StorageModel::R_HDPixmapDis).value <QPixmap>(); 1380 break; 1381 } 1382 case KDeviceType_DVD: 1383 { 1384 deviceRect = model->data (aIndex, StorageModel::R_CDPixmapRect).value <QRect>(); 1385 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 1386 model->data (aIndex, StorageModel::R_CDPixmapEn).value <QPixmap>() : 1387 model->data (aIndex, StorageModel::R_CDPixmapDis).value <QPixmap>(); 1388 break; 1389 } 1390 case KDeviceType_Floppy: 1391 { 1392 deviceRect = model->data (aIndex, StorageModel::R_FDPixmapRect).value <QRect>(); 1393 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 1394 model->data (aIndex, StorageModel::R_FDPixmapEn).value <QPixmap>() : 1395 model->data (aIndex, StorageModel::R_FDPixmapDis).value <QPixmap>(); 1396 break; 1397 } 1398 default: 1399 break; 535 1400 } 536 } 537 538 mDisksList.append (DiskValue (medium.id())); 539 } 1401 QPixmap adderPixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 1402 model->data (aIndex, StorageModel::R_PlusPixmapEn).value <QPixmap>() : 1403 model->data (aIndex, StorageModel::R_PlusPixmapDis).value <QPixmap>(); 1404 1405 aPainter->drawPixmap (QPoint (rect.width() + deviceRect.x(), deviceRect.y()), devicePixmap); 1406 aPainter->drawPixmap (QPoint (rect.width() + deviceRect.x() + 6, deviceRect.y() + 6), adderPixmap); 1407 } 1408 } 1409 1410 aPainter->restore(); 1411 1412 drawFocus (aPainter, aOption, rect); 540 1413 } 541 1414 … … 546 1419 VBoxVMSettingsHD::VBoxVMSettingsHD() 547 1420 : mValidator (0) 548 , mWasTableSelected (false) 549 , mPolished (false) 550 , mLastSelAddControllerIndex (0) 1421 , mIsPolished (false) 551 1422 { 552 1423 /* Apply UI decorations */ 553 1424 Ui::VBoxVMSettingsHD::setupUi (this); 554 1425 555 /* Setup model/view factory */ 556 int idHDSlot = qRegisterMetaType <SlotValue>(); 557 int idHDDisk = qRegisterMetaType <DiskValue>(); 558 QItemEditorFactory *factory = new QItemEditorFactory; 559 QItemEditorCreatorBase *slotCreator = 560 new QStandardItemEditorCreator <SlotEditor>(); 561 QItemEditorCreatorBase *diskCreator = 562 new QStandardItemEditorCreator <DiskEditor>(); 563 factory->registerEditor ((QVariant::Type)idHDSlot, slotCreator); 564 factory->registerEditor ((QVariant::Type)idHDDisk, diskCreator); 565 QItemEditorFactory::setDefaultFactory (factory); 566 567 /* Setup view-model */ 568 mModel = new AttachmentsModel (mTwAts, idHDSlot, idHDDisk); 569 connect (mModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), 570 this, SIGNAL (hdChanged())); 571 572 /* Initialize HD Settings */ 573 HDSettings::instance (mTwAts, mModel); 574 575 /* Setup table-view */ 576 mTwAts->setMinimumHeight (100); 577 mTwAts->verticalHeader()->setDefaultSectionSize ( 578 (int) (mTwAts->fontMetrics().height() * 1.30 /* 130% of font height */)); 579 mTwAts->verticalHeader()->hide(); 580 mTwAts->horizontalHeader()->setStretchLastSection (true); 581 mTwAts->setModel (mModel); 582 mTwAts->setToolTip (mModel->data (mModel->index (mModel->rowCount() - 1, 0), 583 Qt::ToolTipRole).toString()); 584 585 /* Prepare actions */ 586 mNewAction = new QAction (mTwAts); 587 mDelAction = new QAction (mTwAts); 588 mVdmAction = new QAction (mTwAts); 589 590 mTwAts->addAction (mNewAction); 591 mTwAts->addAction (mDelAction); 592 mTwAts->addAction (mVdmAction); 593 594 mNewAction->setShortcut (QKeySequence ("Ins")); 595 mDelAction->setShortcut (QKeySequence ("Del")); 596 mVdmAction->setShortcut (QKeySequence ("Ctrl+Space")); 597 598 mNewAction->setIcon (VBoxGlobal::iconSet (":/vdm_add_16px.png", 599 ":/vdm_add_disabled_16px.png")); 600 mDelAction->setIcon (VBoxGlobal::iconSet (":/vdm_remove_16px.png", 601 ":/vdm_remove_disabled_16px.png")); 602 mVdmAction->setIcon (VBoxGlobal::iconSet (":/select_file_16px.png", 603 ":/select_file_dis_16px.png")); 604 605 /* Prepare toolbar */ 606 VBoxToolBar *toolBar = new VBoxToolBar (mGbAts); 607 toolBar->setUsesTextLabel (false); 608 toolBar->setIconSize (QSize (16, 16)); 609 toolBar->setOrientation (Qt::Vertical); 610 toolBar->addAction (mNewAction); 611 toolBar->addAction (mDelAction); 612 toolBar->addAction (mVdmAction); 613 mGbAts->layout()->addWidget (toolBar); 1426 /* Enumerate Mediums */ 1427 vboxGlobal().startEnumeratingMedia(); 1428 1429 /* Initialize pixmap pool */ 1430 PixmapPool::pool (this); 1431 1432 /* Controller Actions */ 1433 mAddCtrAction = new QAction (this); 1434 mAddCtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::AddControllerEn), 1435 PixmapPool::pool()->pixmap (PixmapPool::AddControllerDis))); 1436 1437 mAddIDECtrAction = new QAction (this); 1438 mAddIDECtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::IDEController))); 1439 1440 mAddSATACtrAction = new QAction (this); 1441 mAddSATACtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::SATAController))); 1442 1443 mAddSCSICtrAction = new QAction (this); 1444 mAddSCSICtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::SCSIController))); 1445 1446 mAddFloppyCtrAction = new QAction (this); 1447 mAddFloppyCtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::FloppyController))); 1448 1449 mDelCtrAction = new QAction (this); 1450 mDelCtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::DelControllerEn), 1451 PixmapPool::pool()->pixmap (PixmapPool::DelControllerDis))); 1452 1453 /* Attachment Actions */ 1454 mAddAttAction = new QAction (this); 1455 mAddAttAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::AddAttachmentEn), 1456 PixmapPool::pool()->pixmap (PixmapPool::AddAttachmentDis))); 1457 1458 mDelAttAction = new QAction (this); 1459 mDelAttAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::DelAttachmentEn), 1460 PixmapPool::pool()->pixmap (PixmapPool::DelAttachmentDis))); 1461 1462 /* Storage Model/View */ 1463 mStorageModel = new StorageModel (mTwStorageTree); 1464 StorageDelegate *storageDelegate = new StorageDelegate (mTwStorageTree); 1465 mTwStorageTree->setContextMenuPolicy (Qt::CustomContextMenu); 1466 mTwStorageTree->setModel (mStorageModel); 1467 mTwStorageTree->setItemDelegate (storageDelegate); 1468 mTwStorageTree->setRootIndex (mStorageModel->root()); 1469 mTwStorageTree->setCurrentIndex (mStorageModel->root()); 1470 1471 /* Storage ToolBar */ 1472 mTbStorageBar->setIconSize (QSize (16, 16)); 1473 mTbStorageBar->addAction (mAddAttAction); 1474 mTbStorageBar->addAction (mDelAttAction); 1475 mTbStorageBar->addAction (mAddCtrAction); 1476 mTbStorageBar->addAction (mDelCtrAction); 1477 1478 /* Vdi Combo */ 1479 mCbVdi->setNullItemPresent (true); 1480 1481 /* Vmm Button */ 1482 mTbVmm->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::VMMEn), 1483 PixmapPool::pool()->pixmap (PixmapPool::VMMDis))); 1484 1485 /* Info Pane initialization */ 1486 mLbHDVirtualSizeValue->setFullSizeSelection (true); 1487 mLbHDActualSizeValue->setFullSizeSelection (true); 1488 mLbSizeValue->setFullSizeSelection (true); 1489 mLbLocationValue->setFullSizeSelection (true); 1490 mLbHDFormatValue->setFullSizeSelection (true); 1491 mLbUsageValue->setFullSizeSelection (true); 614 1492 615 1493 /* Setup connections */ 616 connect (mNewAction, SIGNAL (triggered (bool)), 617 this, SLOT (addAttachment())); 618 connect (mDelAction, SIGNAL (triggered (bool)), 619 this, SLOT (delAttachment())); 620 connect (mVdmAction, SIGNAL (triggered (bool)), 621 this, SLOT (showMediaManager())); 622 623 connect (mAddControllerCheck, SIGNAL (stateChanged (int)), 624 this, SLOT (onAddControllerCheckToggled (int))); 625 connect (mCbControllerType, SIGNAL (currentIndexChanged (int)), 626 this, SLOT (onAddControllerTypeChanged (int))); 627 connect (mShowDiffsCheck, SIGNAL (stateChanged (int)), 628 this, SLOT (onShowDiffsCheckToggled (int))); 629 630 connect (mTwAts, SIGNAL (currentChanged (const QModelIndex &)), 631 this, SLOT (updateActions (const QModelIndex &))); 632 633 connect (&vboxGlobal(), SIGNAL (mediumAdded (const VBoxMedium &)), 634 HDSettings::instance(), SLOT (update())); 635 connect (&vboxGlobal(), SIGNAL (mediumUpdated (const VBoxMedium &)), 636 HDSettings::instance(), SLOT (update())); 637 connect (&vboxGlobal(), SIGNAL (mediumRemoved (VBoxDefs::MediaType, const QString &)), 638 HDSettings::instance(), SLOT (update())); 639 640 /* IDE Controller Type */ 641 mCbIDEController->addItem (""); /* KIDEControllerType_PIIX3 */ 642 mCbIDEController->addItem (""); /* KIDEControllerType_PIIX4 */ 643 mCbIDEController->addItem (""); /* KIDEControllerType_ICH6 */ 644 645 646 /* Additional Controller Type */ 647 mCbControllerType->addItem ("", KStorageControllerType_IntelAhci); 648 mCbControllerType->addItem ("", KStorageControllerType_LsiLogic); 649 mCbControllerType->addItem ("", KStorageControllerType_BusLogic); 650 651 /* Install global event filter */ 652 qApp->installEventFilter (this); 1494 connect (mAddCtrAction, SIGNAL (triggered (bool)), this, SLOT (addController())); 1495 connect (mAddIDECtrAction, SIGNAL (triggered (bool)), this, SLOT (addIDEController())); 1496 connect (mAddSATACtrAction, SIGNAL (triggered (bool)), this, SLOT (addSATAController())); 1497 connect (mAddSCSICtrAction, SIGNAL (triggered (bool)), this, SLOT (addSCSIController())); 1498 connect (mAddFloppyCtrAction, SIGNAL (triggered (bool)), this, SLOT (addFloppyController())); 1499 connect (mDelCtrAction, SIGNAL (triggered (bool)), this, SLOT (delController())); 1500 connect (mAddAttAction, SIGNAL (triggered (bool)), this, SLOT (addAttachment())); 1501 connect (mDelAttAction, SIGNAL (triggered (bool)), this, SLOT (delAttachment())); 1502 connect (mStorageModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)), 1503 this, SLOT (onRowInserted (const QModelIndex&, int))); 1504 connect (mStorageModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)), 1505 this, SLOT (onRowRemoved())); 1506 connect (mTwStorageTree, SIGNAL (currentItemChanged (const QModelIndex&, const QModelIndex&)), 1507 this, SLOT (onCurrentItemChanged())); 1508 connect (mTwStorageTree, SIGNAL (customContextMenuRequested (const QPoint&)), 1509 this, SLOT (onContextMenuRequested (const QPoint&))); 1510 connect (mTwStorageTree, SIGNAL (drawItemBranches (QPainter*, const QRect&, const QModelIndex&)), 1511 this, SLOT (onDrawItemBranches (QPainter *, const QRect &, const QModelIndex &))); 1512 connect (mTwStorageTree, SIGNAL (mousePressed (QMouseEvent*)), 1513 this, SLOT (onMouseClicked (QMouseEvent*))); 1514 connect (mTwStorageTree, SIGNAL (mouseDoubleClicked (QMouseEvent*)), 1515 this, SLOT (onMouseClicked (QMouseEvent*))); 1516 connect (mLeName, SIGNAL (textEdited (const QString&)), this, SLOT (setInformation())); 1517 connect (mCbType, SIGNAL (activated (int)), this, SLOT (setInformation())); 1518 connect (mCbSlot, SIGNAL (activated (int)), this, SLOT (setInformation())); 1519 connect (mCbDevice, SIGNAL (activated (int)), this, SLOT (setInformation())); 1520 connect (mCbVdi, SIGNAL (activated (int)), this, SLOT (setInformation())); 1521 connect (mTbVmm, SIGNAL (clicked (bool)), this, SLOT (onVmmInvoked())); 1522 connect (mCbPassthrough, SIGNAL (stateChanged (int)), this, SLOT (setInformation())); 1523 1524 /* Update actions */ 1525 updateActionsState(); 653 1526 654 1527 /* Applying language settings */ 655 1528 retranslateUi(); 1529 1530 /* Initial setup */ 1531 setMinimumWidth (500); 1532 mSplitter->setSizes (QList<int>() << 0.45 * minimumWidth() << 0.55 * minimumWidth()); 656 1533 } 657 1534 … … 659 1536 { 660 1537 mMachine = aMachine; 661 HDSettings::instance()->setMachine (mMachine); 662 663 /* IDE controller type */ 664 const QString ideName = QString ("IDE"); 665 CStorageController ideCtl = aMachine.GetStorageControllerByName (ideName); 666 mCbIDEController->setCurrentIndex (mCbIDEController-> 667 findText (vboxGlobal().toString (ideCtl.GetControllerType()))); 668 669 /* For now we search for the first one which isn't IDE */ 670 CStorageController addController; 671 QVector<CStorageController> scs = mMachine.GetStorageControllers(); 672 foreach (const CStorageController &sc, scs) 673 if (sc.GetBus() != KStorageBus_IDE) 674 { 675 addController = sc; 676 break; 677 } 678 if (!addController.isNull()) 679 mCbControllerType->setCurrentIndex (mCbControllerType->findData (addController.GetControllerType())); 680 else 681 mCbControllerType->setCurrentIndex (0); 682 683 mAddControllerCheck->setChecked (!addController.isNull()); 684 685 onAddControllerCheckToggled (mAddControllerCheck->checkState()); 686 onShowDiffsCheckToggled (mShowDiffsCheck->checkState()); 687 688 /* Load attachments list */ 689 CHardDiskAttachmentVector vec = mMachine.GetHardDiskAttachments(); 690 for (int i = 0; i < vec.size(); ++ i) 691 { 692 CHardDiskAttachment hda = vec [i]; 693 CStorageController ctl = mMachine.GetStorageControllerByName(hda.GetController()); 694 695 SlotValue slot (ctl.GetBus(), hda.GetPort(), hda.GetDevice()); 696 DiskValue disk (hda.GetHardDisk().GetId()); 697 mModel->addItem (slot, disk); 698 } 699 700 /* Initially select the first table item & update the actions */ 701 mTwAts->setCurrentIndex (mModel->index (0, 1)); 702 updateActions (mTwAts->currentIndex()); 703 704 /* Validate if possible */ 705 if (mValidator) 706 mValidator->revalidate(); 1538 1539 /* Load currently present controllers & attachments */ 1540 CStorageControllerVector controllers = mMachine.GetStorageControllers(); 1541 foreach (const CStorageController &controller, controllers) 1542 { 1543 QString controllerName = controller.GetName(); 1544 QModelIndex ctrIndex = mStorageModel->addController (controllerName, controller.GetBus(), controller.GetControllerType()); 1545 QUuid ctrId = QUuid (mStorageModel->data (ctrIndex, StorageModel::R_ItemId).toString()); 1546 1547 CMediumAttachmentVector attachments = mMachine.GetMediumAttachmentsOfController (controllerName); 1548 foreach (const CMediumAttachment &attachment, attachments) 1549 { 1550 QModelIndex attIndex = mStorageModel->addAttachment (ctrId, attachment.GetType()); 1551 mStorageModel->setData (attIndex, QVariant::fromValue (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice())), StorageModel::R_AttSlot); 1552 CMedium medium (attachment.GetMedium()); 1553 VBoxMedium vboxMedium; 1554 vboxGlobal().findMedium (medium, vboxMedium); 1555 mStorageModel->setData (attIndex, vboxMedium.id(), StorageModel::R_AttMediumId); 1556 mStorageModel->setData (attIndex, attachment.GetPassthrough(), StorageModel::R_AttIsPassthrough); 1557 } 1558 } 707 1559 } 708 1560 709 1561 void VBoxVMSettingsHD::putBackTo() 710 1562 { 711 /* IDE controller type */ 712 const QString ideName = QString ("IDE"); 713 CStorageController ideCtl = mMachine.GetStorageControllerByName(ideName); 714 ideCtl.SetControllerType (vboxGlobal().toIDEControllerType (mCbIDEController->currentText())); 715 716 /* Detach all attached Hard Disks */ 717 CHardDiskAttachmentVector vec = mMachine.GetHardDiskAttachments(); 718 for (int i = 0; i < vec.size(); ++ i) 719 { 720 CHardDiskAttachment hda = vec [i]; 721 722 mMachine.DetachHardDisk(hda.GetController(), hda.GetPort(), hda.GetDevice()); 723 724 /* [dsen] check this */ 725 if (!mMachine.isOk()) 726 { 727 CStorageController ctl = mMachine.GetStorageControllerByName (hda.GetController()); 728 vboxProblem().cannotDetachHardDisk (this, mMachine, 729 vboxGlobal().getMedium (CMedium (hda.GetHardDisk())).location(), 730 ctl.GetBus(), hda.GetPort(), hda.GetDevice()); 731 } 732 } 733 734 /* Clear all storage controllers beside the IDE one */ 735 CStorageController addController; 736 QVector <CStorageController> scs = mMachine.GetStorageControllers(); 737 foreach (const CStorageController &sc, scs) 738 if (sc.GetBus() != KStorageBus_IDE) 739 mMachine.RemoveStorageController (sc.GetName()); 740 741 /* Now add an additional controller if the user has enabled this */ 742 CStorageController addCtl; 743 if (mAddControllerCheck->isChecked()) 744 { 745 KStorageControllerType sct = currentControllerType(); 746 KStorageBus sv = currentBusType(); 747 addCtl = mMachine.AddStorageController (vboxGlobal().toString (sv), sv); 748 addCtl.SetControllerType (sct); 749 } 750 751 /* On SATA it is possible to set the max port count. We want not wasting resources 752 * so we try to find the port with the highest number & set it as max port count. 753 * But first set it to the maximum because we get errors if there are more hard 754 * disks than currently activated ports. */ 755 if (!addCtl.isNull() && 756 addCtl.GetBus() == KStorageBus_SATA) 757 addCtl.SetPortCount (30); 758 759 /* Attach all listed Hard Disks */ 760 LONG maxSATAPort = 1; 761 QString ctrlName; 762 QList <Attachment> list (mModel->fullUsedList()); 763 for (int i = 0; i < list.size(); ++ i) 764 { 765 ctrlName = vboxGlobal().toString (list [i].slot.bus); 766 if (list [i].slot.bus == KStorageBus_SATA) 767 { 768 maxSATAPort = maxSATAPort < (list [i].slot.channel + 1) ? 769 (list [i].slot.channel + 1) : maxSATAPort; 770 } 771 772 mMachine.AttachHardDisk (list [i].disk.id, 773 ctrlName, list [i].slot.channel, list [i].slot.device); 774 /* [dsen] check this */ 775 if (!mMachine.isOk()) 776 vboxProblem().cannotAttachHardDisk (this, mMachine, 777 vboxGlobal().getMedium (CMedium (vboxGlobal().virtualBox() 778 .GetHardDisk (list [i].disk.id))).location(), 779 list [i].slot.bus, list [i].slot.channel, list [i].slot.device); 780 } 781 782 /* Set the maximum port count if the additional controller is a SATA controller. */ 783 if (!addCtl.isNull() && 784 addCtl.GetBus() == KStorageBus_SATA) 785 addCtl.SetPortCount (maxSATAPort); 1563 /* Remove currently present controllers & attachments */ 1564 CStorageControllerVector controllers = mMachine.GetStorageControllers(); 1565 foreach (const CStorageController &controller, controllers) 1566 { 1567 QString controllerName (controller.GetName()); 1568 CMediumAttachmentVector attachments = mMachine.GetMediumAttachmentsOfController (controllerName); 1569 foreach (const CMediumAttachment &attachment, attachments) 1570 mMachine.DetachDevice (controllerName, attachment.GetPort(), attachment.GetDevice()); 1571 mMachine.RemoveStorageController (controllerName); 1572 } 1573 1574 /* Save created controllers & attachments */ 1575 QModelIndex rootIndex = mStorageModel->root(); 1576 for (int i = 0; i < mStorageModel->rowCount (rootIndex); ++ i) 1577 { 1578 QModelIndex ctrIndex = rootIndex.child (i, 0); 1579 QString ctrName = mStorageModel->data (ctrIndex, StorageModel::R_CtrName).toString(); 1580 KStorageBus ctrBusType = mStorageModel->data (ctrIndex, StorageModel::R_CtrBusType).value <KStorageBus>(); 1581 KStorageControllerType ctrType = mStorageModel->data (ctrIndex, StorageModel::R_CtrType).value <KStorageControllerType>(); 1582 CStorageController ctr = mMachine.AddStorageController (ctrName, ctrBusType); 1583 ctr.SetControllerType (ctrType); 1584 for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j) 1585 { 1586 QModelIndex attIndex = ctrIndex.child (j, 0); 1587 StorageSlot attStorageSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>(); 1588 KDeviceType attDeviceType = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 1589 QString attMediumId = mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString(); 1590 mMachine.AttachDevice (ctrName, attStorageSlot.port, attStorageSlot.device, attDeviceType, attMediumId); 1591 CMediumAttachment attachment = mMachine.GetMediumAttachment (ctrName, attStorageSlot.port, attStorageSlot.device); 1592 attachment.SetPassthrough (mStorageModel->data (attIndex, StorageModel::R_AttIsHostDrive).toBool() && 1593 mStorageModel->data (attIndex, StorageModel::R_AttIsPassthrough).toBool()); 1594 } 1595 } 786 1596 } 787 1597 … … 789 1599 { 790 1600 mValidator = aVal; 791 connect (mModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), 792 mValidator, SLOT (revalidate())); 1601 // TODO Setup Validation! 793 1602 } 794 1603 795 1604 bool VBoxVMSettingsHD::revalidate (QString &aWarning, QString &) 796 1605 { 797 QList <SlotValue> slotList (mModel->usedSlotsList()); 798 QList <DiskValue> diskList (mModel->usedDisksList()); 799 for (int i = 0; i < diskList.size(); ++ i) 800 { 801 /* Check for emptiness */ 802 if (diskList [i].id.isNull()) 803 { 804 aWarning = tr ("No hard disk is selected for <i>%1</i>") 805 .arg (slotList [i].name); 806 break; 807 } 808 809 /* Check for coincidence */ 810 if (diskList.count (diskList [i]) > 1) 811 { 812 int first = diskList.indexOf (diskList [i]); 813 int second = diskList.indexOf (diskList [i], first + 1); 814 Assert (first != -1 && second != -1); 815 aWarning = tr ("<i>%1</i> uses the hard disk that is " 816 "already attached to <i>%2</i>") 817 .arg (slotList [second].name, 818 slotList [first].name); 819 break; 820 } 821 } 822 1606 // TODO Perform Validation! 823 1607 return aWarning.isNull(); 824 }825 826 void VBoxVMSettingsHD::setOrderAfter (QWidget *aWidget)827 {828 setTabOrder (aWidget, mCbIDEController);829 setTabOrder (mCbIDEController, mAddControllerCheck);830 setTabOrder (mAddControllerCheck, mCbControllerType);831 setTabOrder (mCbControllerType, mTwAts);832 setTabOrder (mTwAts, mShowDiffsCheck);833 1608 } 834 1609 … … 838 1613 Ui::VBoxVMSettingsHD::retranslateUi (this); 839 1614 840 /* IDE Controller Type */ 841 mCbIDEController->setItemText (0, vboxGlobal().toString (KStorageControllerType_PIIX3)); 842 mCbIDEController->setItemText (1, vboxGlobal().toString (KStorageControllerType_PIIX4)); 843 mCbIDEController->setItemText (2, vboxGlobal().toString (KStorageControllerType_ICH6)); 844 845 /* Additional Controller Type */ 846 mCbControllerType->setItemText (0, QString ("%1 (%2)").arg (vboxGlobal().toString (KStorageBus_SATA)) 847 .arg (vboxGlobal().toString (KStorageControllerType_IntelAhci))); 848 mCbControllerType->setItemText (1, QString ("%1 (%2)").arg (vboxGlobal().toString (KStorageBus_SCSI)) 849 .arg (vboxGlobal().toString (KStorageControllerType_LsiLogic))); 850 mCbControllerType->setItemText (2, QString ("%1 (%2)").arg (vboxGlobal().toString (KStorageBus_SCSI)) 851 .arg (vboxGlobal().toString (KStorageControllerType_BusLogic))); 852 853 /* Attachments List */ 854 mNewAction->setText (tr ("&Add Attachment")); 855 mDelAction->setText (tr ("&Remove Attachment")); 856 mVdmAction->setText (tr ("&Select Hard Disk")); 857 858 mNewAction->setToolTip (mNewAction->text().remove ('&') + 859 QString (" (%1)").arg (mNewAction->shortcut().toString())); 860 mDelAction->setToolTip (mDelAction->text().remove ('&') + 861 QString (" (%1)").arg (mDelAction->shortcut().toString())); 862 mVdmAction->setToolTip (mVdmAction->text().remove ('&') + 863 QString (" (%1)").arg (mVdmAction->shortcut().toString())); 864 865 mNewAction->setWhatsThis (tr ("Adds a new hard disk attachment.")); 866 mDelAction->setWhatsThis (tr ("Removes the highlighted hard disk attachment.")); 867 mVdmAction->setWhatsThis (tr ("Invokes the Virtual Media Manager to select " 868 "a hard disk to attach to the currently " 869 "highlighted slot.")); 870 } 871 872 void VBoxVMSettingsHD::addAttachment() 873 { 874 /* Temporary disable corresponding action now to prevent calling it again 875 * before it will be disabled by current-changed processing. This can 876 * happens if the user just pressed & hold the shortcut combination. */ 877 mNewAction->setEnabled (false); 878 879 QString newId; 880 881 { /* Clear the focus */ 882 FocusGuardBlock guard (mTwAts); 883 884 bool uniqueDiskSelected = false; 885 HDSettings *hds = HDSettings::instance(); 886 887 { /* Add new item with default values */ 888 SlotValue slot (hds->slotsList (SlotValue(), true) [0]); 889 DiskValue disk; 890 uniqueDiskSelected = hds->tryToChooseUniqueDisk (disk); 891 mModel->addItem (slot, disk); 892 } /* Add new item with default values */ 893 894 /* If there are not enough unique disks */ 895 if (!uniqueDiskSelected) 896 { 897 /* Ask the user for method to add new disk */ 898 int confirm = vboxProblem().confirmRunNewHDWzdOrVDM (this); 899 newId = confirm == QIMessageBox::Yes ? getWithNewHDWizard() : 900 confirm == QIMessageBox::No ? getWithMediaManager() : QString::null; 901 } 902 } /* Clear the focus */ 903 904 /* Set the right column of new index to be the current */ 905 mTwAts->setCurrentIndex (mModel->index (mModel->rowCount() - 2, 1)); 906 907 if (!newId.isNull()) 908 { 909 /* Compose & apply resulting disk */ 910 QVariant newValue; 911 newValue.setValue (DiskValue (newId)); 912 mModel->setData (mTwAts->currentIndex(), newValue); 913 } 914 915 /* Validate if possible */ 916 if (mValidator) 917 mValidator->revalidate(); 918 emit hdChanged(); 1615 mAddCtrAction->setShortcut (QKeySequence ("Ins")); 1616 mDelCtrAction->setShortcut (QKeySequence ("Del")); 1617 mAddAttAction->setShortcut (QKeySequence ("+")); 1618 mDelAttAction->setShortcut (QKeySequence ("-")); 1619 1620 mAddCtrAction->setText (tr ("Add Controller")); 1621 mAddIDECtrAction->setText (tr ("Add IDE Controller")); 1622 mAddSATACtrAction->setText (tr ("Add SATA Controller")); 1623 mAddSCSICtrAction->setText (tr ("Add SCSI Controller")); 1624 mAddFloppyCtrAction->setText (tr ("Add Floppy Controller")); 1625 mDelCtrAction->setText (tr ("Remove Controller")); 1626 mAddAttAction->setText (tr ("Add Attachment")); 1627 mDelAttAction->setText (tr ("Remove Attachment")); 1628 1629 mAddCtrAction->setWhatsThis (tr ("Adds a new controller to the end of Storage Tree.")); 1630 mDelCtrAction->setWhatsThis (tr ("Removes controller highlighted in Storage Tree.")); 1631 mAddAttAction->setWhatsThis (tr ("Adds a new attachment to the Storage Tree using " 1632 "currently selected controller as parent.")); 1633 mDelAttAction->setWhatsThis (tr ("Removes attachment highlighted in Storage Tree.")); 1634 1635 mAddCtrAction->setToolTip (mAddCtrAction->text().remove ('&') + 1636 QString (" (%1)").arg (mAddCtrAction->shortcut().toString())); 1637 mDelCtrAction->setToolTip (mDelCtrAction->text().remove ('&') + 1638 QString (" (%1)").arg (mDelCtrAction->shortcut().toString())); 1639 mAddAttAction->setToolTip (mAddAttAction->text().remove ('&') + 1640 QString (" (%1)").arg (mAddAttAction->shortcut().toString())); 1641 mDelAttAction->setToolTip (mDelAttAction->text().remove ('&') + 1642 QString (" (%1)").arg (mDelAttAction->shortcut().toString())); 1643 } 1644 1645 void VBoxVMSettingsHD::showEvent (QShowEvent *aEvent) 1646 { 1647 if (!mIsPolished) 1648 { 1649 mIsPolished = true; 1650 1651 /* First column indent */ 1652 mLtEmpty->setColumnMinimumWidth (0, 10); 1653 mLtController->setColumnMinimumWidth (0, 10); 1654 mLtAttachment->setColumnMinimumWidth (0, 10); 1655 1656 /* Second column indent minimum width */ 1657 QList <QLabel*> labelsList; 1658 labelsList << mLbSlot << mLbDevice << mLbVdi 1659 << mLbHDVirtualSize << mLbHDActualSize << mLbSize 1660 << mLbLocation << mLbHDFormat << mLbUsage; 1661 int maxWidth = 0; 1662 QFontMetrics metrics (font()); 1663 foreach (QLabel *label, labelsList) 1664 { 1665 int width = metrics.width (label->text()); 1666 maxWidth = width > maxWidth ? width : maxWidth; 1667 } 1668 mLtAttachment->setColumnMinimumWidth (1, maxWidth); 1669 } 1670 VBoxSettingsPage::showEvent (aEvent); 1671 } 1672 1673 void VBoxVMSettingsHD::addController() 1674 { 1675 QMenu menu; 1676 menu.addAction (mAddIDECtrAction); 1677 menu.addAction (mAddSATACtrAction); 1678 menu.addAction (mAddSCSICtrAction); 1679 menu.addAction (mAddFloppyCtrAction); 1680 menu.exec (QCursor::pos()); 1681 } 1682 1683 void VBoxVMSettingsHD::addIDEController() 1684 { 1685 // TODO Generate Unique Name! 1686 mStorageModel->addController (tr ("IDE Controller"), KStorageBus_IDE, KStorageControllerType_PIIX3); 1687 } 1688 1689 void VBoxVMSettingsHD::addSATAController() 1690 { 1691 // TODO Generate Unique Name! 1692 mStorageModel->addController (tr ("SATA Controller"), KStorageBus_SATA, KStorageControllerType_IntelAhci); 1693 } 1694 1695 void VBoxVMSettingsHD::addSCSIController() 1696 { 1697 // TODO Generate Unique Name! 1698 mStorageModel->addController (tr ("SCSI Controller"), KStorageBus_SCSI, KStorageControllerType_LsiLogic); 1699 } 1700 1701 void VBoxVMSettingsHD::addFloppyController() 1702 { 1703 // TODO Generate Unique Name! 1704 mStorageModel->addController (tr ("Floppy Controller"), KStorageBus_Floppy, KStorageControllerType_I82078); 1705 } 1706 1707 void VBoxVMSettingsHD::delController() 1708 { 1709 QModelIndex index = mTwStorageTree->currentIndex(); 1710 if (!mStorageModel->data (index, StorageModel::R_IsController).toBool()) return; 1711 1712 mStorageModel->delController (QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString())); 1713 } 1714 1715 void VBoxVMSettingsHD::addAttachment (KDeviceType aDeviceType) 1716 { 1717 QModelIndex index = mTwStorageTree->currentIndex(); 1718 if (!mStorageModel->data (index, StorageModel::R_IsController).toBool()) return; 1719 1720 if (aDeviceType == KDeviceType_Null) 1721 aDeviceType = mStorageModel->data (index, StorageModel::R_CtrDevices).value <DeviceTypeList>() [0]; 1722 1723 mStorageModel->addAttachment (QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString()), aDeviceType); 919 1724 } 920 1725 921 1726 void VBoxVMSettingsHD::delAttachment() 922 1727 { 923 Assert (mTwAts->currentIndex().isValid()); 924 925 /* Temporary disable corresponding action now to prevent calling it again 926 * before it will be disabled by current-changed processing. This can 927 * happens if the user just pressed & hold the shortcut combination. */ 928 mDelAction->setEnabled (false); 929 930 /* Clear the focus */ 931 FocusGuardBlock guard (mTwAts); 932 933 /* Storing current attributes */ 934 int row = mTwAts->currentIndex().row(); 935 int col = mTwAts->currentIndex().column(); 936 937 /* Erase current index */ 938 mTwAts->setCurrentIndex (QModelIndex()); 939 940 /* Calculate new current index */ 941 int newRow = row < mModel->rowCount() - 2 ? row : 942 row > 0 ? row - 1 : -1; 943 QModelIndex next = newRow == -1 ? mModel->index (0, col) : 944 mModel->index (newRow, col); 945 946 /* Delete current index */ 947 mModel->delItem (row); 948 949 /* Set the new index to be the current */ 950 mTwAts->setCurrentIndex (next); 951 updateActions (next); 952 953 if (mValidator) 954 mValidator->revalidate(); 955 emit hdChanged(); 956 } 957 958 void VBoxVMSettingsHD::showMediaManager() 959 { 960 Assert (mTwAts->currentIndex().isValid()); 961 962 /* Clear the focus */ 963 FocusGuardBlock guard (mTwAts); 964 965 DiskValue current (mModel->data (mTwAts->currentIndex(), Qt::EditRole) 966 .value <DiskValue>()); 967 968 QString id = getWithMediaManager (current.id); 969 1728 QModelIndex index = mTwStorageTree->currentIndex(); 1729 QModelIndex parent = index.parent(); 1730 if (!index.isValid() || !parent.isValid() || 1731 !mStorageModel->data (index, StorageModel::R_IsAttachment).toBool() || 1732 !mStorageModel->data (parent, StorageModel::R_IsController).toBool()) 1733 return; 1734 1735 mStorageModel->delAttachment (QUuid (mStorageModel->data (parent, StorageModel::R_ItemId).toString()), 1736 QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString())); 1737 } 1738 1739 void VBoxVMSettingsHD::getInformation() 1740 { 1741 mIsLoadingInProgress = true; 1742 1743 QModelIndex index = mTwStorageTree->currentIndex(); 1744 if (!index.isValid() || index == mStorageModel->root()) 1745 { 1746 /* Showing Initial Page */ 1747 mSwRightPane->setCurrentIndex (0); 1748 } 1749 else 1750 { 1751 switch (mStorageModel->data (index, StorageModel::R_ItemType).value <AbstractItem::ItemType>()) 1752 { 1753 case AbstractItem::Type_ControllerItem: 1754 { 1755 /* Getting Controller Name */ 1756 mLeName->setText (mStorageModel->data (index, StorageModel::R_CtrName).toString()); 1757 1758 /* Getting Controller Sub type */ 1759 mCbType->clear(); 1760 ControllerTypeList controllerTypeList (mStorageModel->data (index, StorageModel::R_CtrTypes).value <ControllerTypeList>()); 1761 for (int i = 0; i < controllerTypeList.size(); ++ i) 1762 mCbType->insertItem (mCbType->count(), vboxGlobal().toString (controllerTypeList [i])); 1763 KStorageControllerType type = mStorageModel->data (index, StorageModel::R_CtrType).value <KStorageControllerType>(); 1764 int ctrPos = mCbType->findText (vboxGlobal().toString (type)); 1765 mCbType->setCurrentIndex (ctrPos == -1 ? 0 : ctrPos); 1766 1767 /* Showing Controller Page */ 1768 mSwRightPane->setCurrentIndex (1); 1769 break; 1770 } 1771 case AbstractItem::Type_AttachmentItem: 1772 { 1773 /* Getting Attachment Slot */ 1774 mCbSlot->clear(); 1775 SlotsList slotsList (mStorageModel->data (index, StorageModel::R_AttSlots).value <SlotsList>()); 1776 for (int i = 0; i < slotsList.size(); ++ i) 1777 mCbSlot->insertItem (mCbSlot->count(), vboxGlobal().toFullString (slotsList [i])); 1778 StorageSlot slt = mStorageModel->data (index, StorageModel::R_AttSlot).value <StorageSlot>(); 1779 int attSlotPos = mCbSlot->findText (vboxGlobal().toFullString (slt)); 1780 mCbSlot->setCurrentIndex (attSlotPos == -1 ? 0 : attSlotPos); 1781 1782 /* Getting Attachment Device */ 1783 mCbDevice->clear(); 1784 DeviceTypeList deviceTypeList (mStorageModel->data (index, StorageModel::R_AttDevices).value <DeviceTypeList>()); 1785 for (int i = 0; i < deviceTypeList.size(); ++ i) 1786 mCbDevice->insertItem (mCbDevice->count(), vboxGlobal().toString (deviceTypeList [i])); 1787 KDeviceType device = mStorageModel->data (index, StorageModel::R_AttDevice).value <KDeviceType>(); 1788 int attDevicePos = mCbDevice->findText (vboxGlobal().toString (device)); 1789 mCbDevice->setCurrentIndex (attDevicePos == -1 ? 0 : attDevicePos); 1790 1791 /* Getting Attachment Medium */ 1792 mCbVdi->setType (typeToLocal (device)); 1793 mCbVdi->setCurrentItem (mStorageModel->data (index, StorageModel::R_AttMediumId).toString()); 1794 mCbVdi->refresh(); 1795 1796 /* Getting Passthrough state */ 1797 bool isHostDrive = mStorageModel->data (index, StorageModel::R_AttIsHostDrive).toBool(); 1798 mCbPassthrough->setEnabled (isHostDrive); 1799 mCbPassthrough->setChecked (isHostDrive && mStorageModel->data (index, StorageModel::R_AttIsPassthrough).toBool()); 1800 1801 /* Update optional widgets visibility */ 1802 updateAdditionalObjects (device); 1803 1804 /* Getting Other Information */ 1805 mLbHDVirtualSizeValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttLogicalSize).toString())); 1806 mLbHDActualSizeValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttSize).toString())); 1807 mLbSizeValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttSize).toString())); 1808 mLbLocationValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttLocation).toString())); 1809 mLbHDFormatValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttFormat).toString())); 1810 mLbUsageValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttUsage).toString())); 1811 1812 /* Showing Attachment Page */ 1813 mSwRightPane->setCurrentIndex (2); 1814 break; 1815 } 1816 default: 1817 break; 1818 } 1819 } 1820 1821 mIsLoadingInProgress = false; 1822 } 1823 1824 void VBoxVMSettingsHD::setInformation() 1825 { 1826 QModelIndex index = mTwStorageTree->currentIndex(); 1827 if (mIsLoadingInProgress || !index.isValid() || index == mStorageModel->root()) return; 1828 1829 QObject *sdr = sender(); 1830 switch (mStorageModel->data (index, StorageModel::R_ItemType).value <AbstractItem::ItemType>()) 1831 { 1832 case AbstractItem::Type_ControllerItem: 1833 { 1834 /* Setting Controller Name */ 1835 if (sdr == mLeName) 1836 mStorageModel->setData (index, mLeName->text(), StorageModel::R_CtrName); 1837 /* Setting Controller Sub-Type */ 1838 else if (sdr == mCbType) 1839 { 1840 KStorageControllerType type = vboxGlobal().toControllerType (mCbType->currentText()); 1841 mStorageModel->setData (index, QVariant::fromValue (type), StorageModel::R_CtrType); 1842 } 1843 break; 1844 } 1845 case AbstractItem::Type_AttachmentItem: 1846 { 1847 /* Setting Attachment Slot */ 1848 if (sdr == mCbSlot) 1849 { 1850 StorageSlot slt = vboxGlobal().toStorageSlot (mCbSlot->currentText()); 1851 mStorageModel->setData (index, QVariant::fromValue (slt), StorageModel::R_AttSlot); 1852 } 1853 /* Setting Attachment Device-Type */ 1854 else if (sdr == mCbDevice) 1855 { 1856 KDeviceType device = vboxGlobal().toDeviceType (mCbDevice->currentText()); 1857 mStorageModel->setData (index, QVariant::fromValue (device), StorageModel::R_AttDevice); 1858 mCbVdi->setType (typeToLocal (device)); 1859 mCbVdi->refresh(); 1860 } 1861 /* Setting Attachment Medium */ 1862 else if (sdr == mCbVdi) 1863 mStorageModel->setData (index, mCbVdi->id(), StorageModel::R_AttMediumId); 1864 else if (sdr == mCbPassthrough) 1865 { 1866 if (mStorageModel->data (index, StorageModel::R_AttIsHostDrive).toBool()) 1867 mStorageModel->setData (index, mCbPassthrough->isChecked(), StorageModel::R_AttIsPassthrough); 1868 } 1869 break; 1870 } 1871 default: 1872 break; 1873 } 1874 1875 getInformation(); 1876 } 1877 1878 void VBoxVMSettingsHD::onVmmInvoked() 1879 { 1880 QString id = getWithMediaManager (typeToLocal (vboxGlobal().toDeviceType (mCbDevice->currentText()))); 970 1881 if (!id.isNull()) 971 { 972 /* Compose & apply resulting disk */ 973 QVariant newValue; 974 newValue.setValue (DiskValue (id)); 975 mModel->setData (mTwAts->currentIndex(), newValue); 976 } 977 } 978 979 void VBoxVMSettingsHD::updateActions (const QModelIndex& /* aIndex */) 980 { 981 mNewAction->setEnabled (mModel->rowCount() - 1 < 982 HDSettings::instance()->slotsList().count()); 983 mDelAction->setEnabled (mTwAts->currentIndex().row() != mModel->rowCount() - 1); 984 mVdmAction->setEnabled (mTwAts->currentIndex().row() != mModel->rowCount() - 1 && 985 mTwAts->currentIndex().column() == 1); 986 } 987 988 void VBoxVMSettingsHD::onAddControllerCheckToggled (int aState) 989 { 990 removeFocus(); 991 if (mAddControllerCheck->checkState() == Qt::Unchecked) 992 if (checkAddControllers (0)) 993 { 994 /* Switch check-box back to "Qt::Checked" */ 995 mAddControllerCheck->blockSignals (true); 996 mAddControllerCheck->setCheckState (Qt::Checked); 997 mAddControllerCheck->blockSignals (false); 998 /* The user cancel the request so do nothing */ 1882 mCbVdi->setCurrentItem (id); 1883 } 1884 1885 void VBoxVMSettingsHD::updateActionsState() 1886 { 1887 QModelIndex index = mTwStorageTree->currentIndex(); 1888 1889 mAddCtrAction->setEnabled (mStorageModel->data (index, StorageModel::R_IsMoreControllersPossible).toBool()); 1890 mAddIDECtrAction->setEnabled (mStorageModel->data (index, StorageModel::R_IsMoreControllersPossible).toBool()); 1891 mAddSATACtrAction->setEnabled (mStorageModel->data (index, StorageModel::R_IsMoreControllersPossible).toBool()); 1892 mAddSCSICtrAction->setEnabled (mStorageModel->data (index, StorageModel::R_IsMoreControllersPossible).toBool()); 1893 mAddFloppyCtrAction->setEnabled (mStorageModel->data (index, StorageModel::R_IsMoreControllersPossible).toBool()); 1894 mAddAttAction->setEnabled (mStorageModel->data (index, StorageModel::R_IsController).toBool() && 1895 mStorageModel->data (index, StorageModel::R_IsMoreAttachmentsPossible).toBool()); 1896 1897 mDelCtrAction->setEnabled (mStorageModel->data (index, StorageModel::R_IsController).toBool()); 1898 mDelAttAction->setEnabled (mStorageModel->data (index, StorageModel::R_IsAttachment).toBool()); 1899 } 1900 1901 void VBoxVMSettingsHD::onRowInserted (const QModelIndex &aParent, int aPosition) 1902 { 1903 QModelIndex index = mStorageModel->index (aPosition, 0, aParent); 1904 1905 switch (mStorageModel->data (index, StorageModel::R_ItemType).value <AbstractItem::ItemType>()) 1906 { 1907 case AbstractItem::Type_ControllerItem: 1908 { 1909 /* Select the newly created Controller Item */ 1910 mTwStorageTree->setCurrentIndex (index); 1911 break; 1912 } 1913 case AbstractItem::Type_AttachmentItem: 1914 { 1915 /* Expand parent if it is not expanded yet */ 1916 if (!mTwStorageTree->isExpanded (aParent)) 1917 mTwStorageTree->setExpanded (aParent, true); 1918 1919 /* Check if no medium was selected for this attachment */ 1920 if (mStorageModel->data (index, StorageModel::R_AttMediumId).toString().isEmpty()) 1921 { 1922 /* Ask the user for the method to select medium */ 1923 KDeviceType deviceType = mStorageModel->data (index, StorageModel::R_AttDevice).value <KDeviceType>(); 1924 int askResult = vboxProblem().confirmRunNewHDWzdOrVDM (deviceType); 1925 QString mediumId = askResult == QIMessageBox::Yes ? getWithNewHDWizard() : 1926 askResult == QIMessageBox::No ? getWithMediaManager (typeToLocal (deviceType)) : QString(); 1927 if (mediumId.isNull()) 1928 mediumId = firstAvailable; 1929 mStorageModel->setData (index, mediumId, StorageModel::R_AttMediumId); 1930 } 1931 break; 1932 } 1933 default: 1934 break; 1935 } 1936 1937 updateActionsState(); 1938 getInformation(); 1939 } 1940 1941 void VBoxVMSettingsHD::onRowRemoved() 1942 { 1943 updateActionsState(); 1944 getInformation(); 1945 } 1946 1947 void VBoxVMSettingsHD::onCurrentItemChanged() 1948 { 1949 updateActionsState(); 1950 getInformation(); 1951 } 1952 1953 void VBoxVMSettingsHD::onContextMenuRequested (const QPoint &aPosition) 1954 { 1955 QModelIndex index = mTwStorageTree->indexAt (aPosition); 1956 if (!index.isValid()) return addController(); 1957 1958 QMenu menu; 1959 switch (mStorageModel->data (index, StorageModel::R_ItemType).value <AbstractItem::ItemType>()) 1960 { 1961 case AbstractItem::Type_ControllerItem: 1962 { 1963 menu.addAction (mAddAttAction); 1964 menu.addAction (mDelCtrAction); 1965 break; 1966 } 1967 case AbstractItem::Type_AttachmentItem: 1968 { 1969 menu.addAction (mDelAttAction); 1970 break; 1971 } 1972 default: 1973 break; 1974 } 1975 if (!menu.isEmpty()) 1976 menu.exec (mTwStorageTree->viewport()->mapToGlobal (aPosition)); 1977 } 1978 1979 void VBoxVMSettingsHD::onDrawItemBranches (QPainter *aPainter, const QRect &aRect, const QModelIndex &aIndex) 1980 { 1981 if (!aIndex.parent().isValid() || !aIndex.parent().parent().isValid()) return; 1982 1983 aPainter->save(); 1984 aPainter->translate (aRect.x(), aRect.y()); 1985 1986 int rows = mStorageModel->rowCount (aIndex.parent()); 1987 1988 // TODO Draw Correct Braches! 1989 1990 if (aIndex.row() == 0) 1991 aPainter->drawLine (QPoint (aRect.width() / 2, 2), QPoint (aRect.width() / 2, aRect.height() / 2)); 1992 else 1993 aPainter->drawLine (QPoint (aRect.width() / 2, 0), QPoint (aRect.width() / 2, aRect.height() / 2)); 1994 1995 if (aIndex.row() < rows - 1) 1996 aPainter->drawLine (QPoint (aRect.width() / 2, aRect.height() / 2), QPoint (aRect.width() / 2, aRect.height())); 1997 1998 aPainter->drawLine (QPoint (aRect.width() / 2, aRect.height() / 2), QPoint (aRect.width() - 2, aRect.height() / 2)); 1999 2000 aPainter->restore(); 2001 } 2002 2003 void VBoxVMSettingsHD::onMouseClicked (QMouseEvent *aEvent) 2004 { 2005 QModelIndex index = mTwStorageTree->indexAt (aEvent->pos()); 2006 QRect indexRect = mTwStorageTree->visualRect (index); 2007 2008 /* Process expander icon */ 2009 if (mStorageModel->data (index, StorageModel::R_IsController).toBool()) 2010 { 2011 QRect expanderRect = mStorageModel->data (index, StorageModel::R_ItemPixmapRect).toRect(); 2012 expanderRect.translate (indexRect.x(), indexRect.y()); 2013 if (expanderRect.contains (aEvent->pos())) 2014 { 2015 aEvent->setAccepted (true); 2016 mTwStorageTree->setExpanded (index, !mTwStorageTree->isExpanded (index)); 999 2017 return; 1000 2018 } 1001 1002 mCbControllerType->setEnabled (aState == Qt::Checked); 1003 HDSettings::instance()->setAddCount (mAddControllerCheck->checkState() == Qt::Checked ? 1004 currentMaxPortCount() : 0, 1005 currentBusType()); 1006 updateActions (mTwAts->currentIndex()); 1007 } 1008 1009 void VBoxVMSettingsHD::onAddControllerTypeChanged (int aIndex) 1010 { 1011 removeFocus(); 1012 if (checkAddControllers (1)) 1013 { 1014 /* Switch check-box back to "Qt::Checked" */ 1015 mCbControllerType->blockSignals (true); 1016 mCbControllerType->setCurrentIndex (mLastSelAddControllerIndex); 1017 mCbControllerType->blockSignals (false); 1018 /* The user cancel the request so do nothing */ 1019 return; 1020 } 1021 1022 /* Save the new index for later roll back */ 1023 mLastSelAddControllerIndex = aIndex; 1024 1025 HDSettings::instance()->setAddCount (mAddControllerCheck->checkState() == Qt::Checked ? 1026 currentMaxPortCount() : 0, 1027 currentBusType()); 1028 updateActions (mTwAts->currentIndex()); 1029 } 1030 1031 bool VBoxVMSettingsHD::checkAddControllers (int aWhat) 1032 { 1033 /* Search the list for at least one SATA/SCSI port in */ 1034 QList <SlotValue> list (mModel->usedSlotsList()); 1035 int firstAddPort = 0; 1036 for (; firstAddPort < list.size(); ++ firstAddPort) 1037 if (list [firstAddPort].bus == KStorageBus_SATA || 1038 list [firstAddPort].bus == KStorageBus_SCSI) 1039 break; 1040 1041 /* If list contains at least one SATA/SCSI port */ 1042 if (firstAddPort < list.size()) 1043 { 1044 int result = 0; 1045 if (aWhat == 0) 1046 result = vboxProblem().confirmDetachAddControllerSlots (this); 1047 else 1048 result = vboxProblem().confirmChangeAddControllerSlots (this); 1049 if (result != QIMessageBox::Ok) 1050 return true; 1051 else 1052 { 1053 removeFocus(); 1054 /* Delete additional controller items */ 1055 mModel->removeAddController(); 1056 1057 /* Set column #1 of first index to be the current */ 1058 mTwAts->setCurrentIndex (mModel->index (0, 1)); 1059 1060 if (mValidator) 1061 mValidator->revalidate(); 1062 } 1063 } 1064 return false; 1065 } 1066 1067 void VBoxVMSettingsHD::onShowDiffsCheckToggled (int aState) 1068 { 1069 removeFocus(); 1070 HDSettings::instance()->setShowDiffs (aState == Qt::Checked); 1071 } 1072 1073 bool VBoxVMSettingsHD::eventFilter (QObject *aObject, QEvent *aEvent) 1074 { 1075 if (!aObject->isWidgetType()) 1076 return QWidget::eventFilter (aObject, aEvent); 1077 1078 QWidget *widget = static_cast <QWidget*> (aObject); 1079 if (widget->inherits ("SlotEditor") || 1080 widget->inherits ("DiskEditor")) 1081 { 1082 if (aEvent->type() == QEvent::KeyPress) 1083 { 1084 QKeyEvent *e = static_cast <QKeyEvent*> (aEvent); 1085 QModelIndex cur = mTwAts->currentIndex(); 1086 switch (e->key()) 2019 } 2020 2021 /* Process add-attachment icons */ 2022 if (mStorageModel->data (index, StorageModel::R_IsController).toBool() && 2023 mTwStorageTree->currentIndex() == index) 2024 { 2025 DeviceTypeList devicesList (mStorageModel->data (index, StorageModel::R_CtrDevices).value <DeviceTypeList>()); 2026 for (int i = 0; i < devicesList.size(); ++ i) 2027 { 2028 KDeviceType deviceType = devicesList [i]; 2029 2030 QRect deviceRect; 2031 switch (deviceType) 1087 2032 { 1088 case Qt::Key_Up:2033 case KDeviceType_HardDisk: 1089 2034 { 1090 if (cur.row() > 0) 1091 mTwAts->setCurrentIndex (mModel->index (cur.row() - 1, 1092 cur.column())); 1093 return true; 2035 deviceRect = mStorageModel->data (index, StorageModel::R_HDPixmapRect).toRect(); 2036 break; 1094 2037 } 1095 case Qt::Key_Down:2038 case KDeviceType_DVD: 1096 2039 { 1097 if (cur.row() < mModel->rowCount() - 1) 1098 mTwAts->setCurrentIndex (mModel->index (cur.row() + 1, 1099 cur.column())); 1100 return true; 2040 deviceRect = mStorageModel->data (index, StorageModel::R_CDPixmapRect).toRect(); 2041 break; 1101 2042 } 1102 case Qt::Key_Right:2043 case KDeviceType_Floppy: 1103 2044 { 1104 if (cur.column() == 0) 1105 mTwAts->setCurrentIndex (mModel->index (cur.row(), 1)); 1106 return true; 1107 } 1108 case Qt::Key_Left: 1109 { 1110 if (cur.column() == 1) 1111 mTwAts->setCurrentIndex (mModel->index (cur.row(), 0)); 1112 return true; 1113 } 1114 case Qt::Key_Tab: 1115 { 1116 focusNextPrevChild (true); 1117 return true; 1118 } 1119 case Qt::Key_Backtab: 1120 { 1121 /* Due to table on getting focus back from the child 1122 * put it instantly to this child again, make a hack 1123 * to put focus to the real previous owner. */ 1124 mAddControllerCheck->setFocus(); 1125 return true; 2045 deviceRect = mStorageModel->data (index, StorageModel::R_FDPixmapRect).toRect(); 2046 break; 1126 2047 } 1127 2048 default: 1128 2049 break; 1129 2050 } 1130 } else 1131 if (aEvent->type() == QEvent::WindowDeactivate) 1132 { 1133 /* Store focus state if it is on temporary editor. */ 1134 if (widget->hasFocus()) 1135 mWasTableSelected = true; 1136 } 1137 } else 1138 if (widget == mTwAts->viewport() && 1139 aEvent->type() == QEvent::MouseButtonDblClick) 1140 { 1141 QMouseEvent *e = static_cast <QMouseEvent*> (aEvent); 1142 QModelIndex index = mTwAts->indexAt (e->pos()); 1143 if (mNewAction->isEnabled() && 1144 (index.row() == mModel->rowCount() - 1 || !index.isValid())) 1145 addAttachment(); 1146 } else 1147 if (aEvent->type() == QEvent::WindowActivate) 1148 { 1149 if (mWasTableSelected) 1150 { 1151 /* Restore focus state if it was on temporary editor. */ 1152 mWasTableSelected = false; 1153 mTwAts->setFocus(); 1154 } 1155 } 1156 1157 return QWidget::eventFilter (aObject, aEvent); 1158 } 1159 1160 void VBoxVMSettingsHD::showEvent (QShowEvent *aEvent) 1161 { 1162 QWidget::showEvent (aEvent); 1163 1164 if (mPolished) 1165 return; 1166 mPolished = true; 1167 1168 /* Some delayed polishing */ 1169 mTwAts->horizontalHeader()->resizeSection (0, 1170 style()->pixelMetric (QStyle::PM_ScrollBarExtent, 0, this) + 1171 maxNameLength() + 9 * 2 /* 2 margins */); 1172 1173 /* Activate edit triggers only now to avoid influencing 1174 * HD Attachments table during data loading. */ 1175 mTwAts->setEditTriggers (QAbstractItemView::CurrentChanged | 1176 QAbstractItemView::SelectedClicked | 1177 QAbstractItemView::EditKeyPressed); 1178 1179 /* That little hack allows avoid one of qt4 children focusing bug */ 1180 QWidget *current = QApplication::focusWidget(); 1181 mTwAts->setFocus (Qt::TabFocusReason); 1182 if (current) 1183 current->setFocus (Qt::TabFocusReason); 1184 } 1185 1186 QString VBoxVMSettingsHD::getWithMediaManager (const QString &aInitialId) 2051 deviceRect.translate (indexRect.x() + indexRect.width(), indexRect.y()); 2052 2053 if (deviceRect.contains (aEvent->pos())) 2054 { 2055 aEvent->setAccepted (true); 2056 if (mAddAttAction->isEnabled()) 2057 addAttachment (deviceType); 2058 return; 2059 } 2060 } 2061 } 2062 } 2063 2064 QString VBoxVMSettingsHD::getWithNewHDWizard() 2065 { 2066 /* Run New HD Wizard */ 2067 VBoxNewHDWzd dlg (this); 2068 2069 return dlg.exec() == QDialog::Accepted ? dlg.hardDisk().GetId() : QString(); 2070 } 2071 2072 QString VBoxVMSettingsHD::getWithMediaManager (VBoxDefs::MediumType aMediumType) 1187 2073 { 1188 2074 /* Run Media Manager */ 1189 2075 VBoxMediaManagerDlg dlg (this); 1190 dlg.setup ( VBoxDefs::MediaType_HardDisk,2076 dlg.setup (aMediumType, 1191 2077 true /* do select? */, 1192 2078 false /* do refresh? */, 1193 2079 mMachine, 1194 aInitialId, 1195 HDSettings::instance()->showDiffs()); 1196 1197 return dlg.exec() == QDialog::Accepted ? dlg.selectedId() : QString::null; 1198 } 1199 1200 QString VBoxVMSettingsHD::getWithNewHDWizard() 1201 { 1202 /* Run New HD Wizard */ 1203 VBoxNewHDWzd dlg (this); 1204 1205 return dlg.exec() == QDialog::Accepted ? dlg.hardDisk().GetId() : QString::null; 1206 } 1207 1208 int VBoxVMSettingsHD::maxNameLength() const 1209 { 1210 QList <SlotValue> slts (HDSettings::instance()->slotsList()); 1211 int nameLength = 0; 1212 for (int i = 0; i < slts.size(); ++ i) 1213 { 1214 int length = mTwAts->fontMetrics().width (slts [i].name); 1215 nameLength = length > nameLength ? length : nameLength; 1216 } 1217 return nameLength; 1218 } 1219 1220 void VBoxVMSettingsHD::removeFocus() 1221 { 1222 #ifdef Q_WS_MAC 1223 /* On the Mac checkboxes aren't focus aware. Therewith a editor widget get 1224 * not closed by clicking on the checkbox. As a result the content of the 1225 * currently used editor (QComboBox) isn't updated. So manually remove the 1226 * focus to force the closing of any open editor widget. */ 1227 QWidget *focusWidget = qApp->focusWidget(); 1228 if (focusWidget) 1229 focusWidget->clearFocus(); 1230 #endif /* Q_WS_MAC */ 1231 } 1232 2080 QString(), 2081 false); 2082 2083 return dlg.exec() == QDialog::Accepted ? dlg.selectedId() : QString(); 2084 } 2085 2086 void VBoxVMSettingsHD::updateAdditionalObjects (KDeviceType aType) 2087 { 2088 mCbShowDiffs->setVisible (aType == KDeviceType_HardDisk); 2089 mCbPassthrough->setVisible (aType == KDeviceType_DVD); 2090 2091 mLbHDVirtualSize->setVisible (aType == KDeviceType_HardDisk); 2092 mLbHDVirtualSizeValue->setVisible (aType == KDeviceType_HardDisk); 2093 2094 mLbHDActualSize->setVisible (aType == KDeviceType_HardDisk); 2095 mLbHDActualSizeValue->setVisible (aType == KDeviceType_HardDisk); 2096 2097 mLbSize->setVisible (aType != KDeviceType_HardDisk); 2098 mLbSizeValue->setVisible (aType != KDeviceType_HardDisk); 2099 2100 mLbHDFormat->setVisible (aType == KDeviceType_HardDisk); 2101 mLbHDFormatValue->setVisible (aType == KDeviceType_HardDisk); 2102 } 2103 -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxMediaManagerDlg.ui
r13583 r23223 116 116 </widget> 117 117 </item> 118 <item row="0" column="1" colspan="2">118 <item row="0" column="1" > 119 119 <widget class="QILabel" name="mHdsPane1" > 120 120 <property name="sizePolicy" > -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsHD.ui
r19837 r23223 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <ui version="4.0" >2 <ui version="4.0" > 3 3 <comment> 4 4 VBox frontends: Qt4 GUI ("VirtualBox"): … … 19 19 </comment> 20 20 <class>VBoxVMSettingsHD</class> 21 <widget class="QWidget" name="VBoxVMSettingsHD" >22 <property name="geometry" >21 <widget class="QWidget" name="VBoxVMSettingsHD" > 22 <property name="geometry" > 23 23 <rect> 24 24 <x>0</x> 25 25 <y>0</y> 26 <width> 352</width>27 <height> 335</height>26 <width>800</width> 27 <height>700</height> 28 28 </rect> 29 29 </property> 30 <layout class="QVBoxLayout" name="mLtMain" >30 <layout class="QVBoxLayout" name="mLtMain" > 31 31 <item> 32 <widget class="QLabel" name="mLbIDEController" > 33 <property name="sizePolicy" > 34 <sizepolicy vsizetype="Fixed" hsizetype="Minimum" > 35 <horstretch>0</horstretch> 36 <verstretch>0</verstretch> 37 </sizepolicy> 32 <widget class="QISplitter" native="1" name="mSplitter" > 33 <property name="orientation" > 34 <enum>Qt::Horizontal</enum> 38 35 </property> 39 <property name=" text" >40 < string>IDE &Controller Type</string>36 <property name="handleWidth" > 37 <number>4</number> 41 38 </property> 42 <property name="buddy" > 43 <cstring>mCbIDEController</cstring> 44 </property> 45 </widget> 46 </item> 47 <item> 48 <layout class="QHBoxLayout" name="mLtIDEControllers"> 49 <item> 50 <spacer name="mSpIDEController"> 51 <property name="orientation"> 52 <enum>Qt::Horizontal</enum> 39 <widget class="QWidget" native="1" name="mWtLeftPane" > 40 <layout class="QVBoxLayout" name="mLtLeftPane" > 41 <property name="leftMargin" > 42 <number>0</number> 53 43 </property> 54 <property name=" sizeType">55 < enum>QSizePolicy::Fixed</enum>44 <property name="topMargin" > 45 <number>0</number> 56 46 </property> 57 <property name="sizeHint" stdset="0"> 58 <size> 59 <width>20</width> 60 <height>0</height> 61 </size> 47 <property name="rightMargin" > 48 <number>10</number> 62 49 </property> 63 </spacer> 64 </item> 65 <item> 66 <widget class="QComboBox" name="mCbIDEController" > 67 <property name="sizePolicy" > 68 <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" > 69 <horstretch>0</horstretch> 70 <verstretch>0</verstretch> 71 </sizepolicy> 50 <property name="bottomMargin" > 51 <number>0</number> 72 52 </property> 73 <property name="whatsThis" > 74 <string>Defines the type of the virtual IDE controller. Depending on this value, VirtualBox will provide different virtual IDE hardware devices to the guest OS.</string> 75 </property> 53 <item> 54 <widget class="QILabelSeparator" native="1" name="mLsLeftPane" > 55 <property name="text" > 56 <string>&Storage Tree</string> 57 </property> 58 <property name="buddy" > 59 <cstring>mTwStorageTree</cstring> 60 </property> 61 </widget> 62 </item> 63 <item> 64 <layout class="QVBoxLayout" name="mLtStorage" > 65 <property name="spacing" > 66 <number>0</number> 67 </property> 68 <property name="margin" > 69 <number>0</number> 70 </property> 71 <item> 72 <widget class="QITreeView" native="1" name="mTwStorageTree" > 73 <property name="whatsThis" > 74 <string>Contains all the created storage controllers and all the attached mediums representing virtual images and real host-drives.</string> 75 </property> 76 </widget> 77 </item> 78 <item> 79 <layout class="QHBoxLayout" name="mLtStorageBar" > 80 <item> 81 <spacer name="mSp1" > 82 <property name="orientation" > 83 <enum>Qt::Horizontal</enum> 84 </property> 85 <property name="sizeHint" stdset="0" > 86 <size> 87 <width>0</width> 88 <height>0</height> 89 </size> 90 </property> 91 </spacer> 92 </item> 93 <item> 94 <widget class="VBoxToolBar" native="1" name="mTbStorageBar" /> 95 </item> 96 </layout> 97 </item> 98 </layout> 99 </item> 100 </layout> 101 </widget> 102 <widget class="QStackedWidget" name="mSwRightPane" > 103 <widget class="QWidget" name="mWtEmpty"> 104 <layout class="QGridLayout" name="mLtEmpty" > 105 <property name="leftMargin" > 106 <number>10</number> 107 </property> 108 <property name="topMargin" > 109 <number>0</number> 110 </property> 111 <property name="rightMargin" > 112 <number>0</number> 113 </property> 114 <property name="bottomMargin" > 115 <number>0</number> 116 </property> 117 <item row="0" column="0" colspan="2" > 118 <widget class="QILabelSeparator" native="1" name="mLsEmpty" > 119 <property name="text" > 120 <string>Information</string> 121 </property> 122 </widget> 123 </item> 124 <item row="1" column="1" > 125 <widget class="QLabel" name="mLbInfo" > 126 <property name="text" > 127 <string>Storage Tree supports multiple storage controllers of any type. Currently there are no storage controllers created.</string> 128 </property> 129 <property name="wordWrap"> 130 <bool>true</bool> 131 </property> 132 </widget> 133 </item> 134 <item row="2" column="0" colspan="2" > 135 <spacer name="mSp2" > 136 <property name="orientation" > 137 <enum>Qt::Vertical</enum> 138 </property> 139 <property name="sizeHint" stdset="0" > 140 <size> 141 <width>0</width> 142 <height>0</height> 143 </size> 144 </property> 145 </spacer> 146 </item> 147 </layout> 76 148 </widget> 77 </item> 78 </layout> 79 </item> 80 <item> 81 <widget class="QCheckBox" name="mAddControllerCheck"> 82 <property name="whatsThis"> 83 <string>When checked, enables an additional virtual controller (either SATA or SCSI) of this machine.</string> 84 </property> 85 <property name="text"> 86 <string>&Enable Additional Controller</string> 87 </property> 88 </widget> 89 </item> 90 <item> 91 <layout class="QHBoxLayout" name="mLtAddControllers"> 92 <item> 93 <spacer name="mSpAddControllers"> 94 <property name="orientation"> 95 <enum>Qt::Horizontal</enum> 96 </property> 97 <property name="sizeType"> 98 <enum>QSizePolicy::Fixed</enum> 99 </property> 100 <property name="sizeHint" stdset="0"> 101 <size> 102 <width>20</width> 103 <height>0</height> 104 </size> 105 </property> 106 </spacer> 107 </item> 108 <item> 109 <widget class="QComboBox" name="mCbControllerType"> 110 <property name="enabled"> 111 <bool>false</bool> 112 </property> 149 <widget class="QWidget" name="mWtController" > 150 <layout class="QGridLayout" name="mLtController" > 151 <property name="leftMargin" > 152 <number>10</number> 153 </property> 154 <property name="topMargin" > 155 <number>0</number> 156 </property> 157 <property name="rightMargin" > 158 <number>0</number> 159 </property> 160 <property name="bottomMargin" > 161 <number>0</number> 162 </property> 163 <item row="0" column="0" colspan="3" > 164 <widget class="QILabelSeparator" native="1" name="mLsParameters" > 165 <property name="text" > 166 <string>Attributes</string> 167 </property> 168 </widget> 169 </item> 170 <item row="1" column="1" > 171 <widget class="QLabel" name="mLbName" > 172 <property name="text" > 173 <string>&Name:</string> 174 </property> 175 <property name="buddy" > 176 <cstring>mLeName</cstring> 177 </property> 178 <property name="alignment" > 179 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 180 </property> 181 </widget> 182 </item> 183 <item row="1" column="2" > 184 <widget class="QLineEdit" name="mLeName" > 185 <property name="whatsThis" > 186 <string>Allows to edit the name of the storage controller currently selected in the Storage Tree.</string> 187 </property> 188 </widget> 189 </item> 190 <item row="2" column="1" > 191 <widget class="QLabel" name="mLbType" > 192 <property name="text" > 193 <string>&Type:</string> 194 </property> 195 <property name="buddy" > 196 <cstring>mCbType</cstring> 197 </property> 198 <property name="alignment" > 199 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 200 </property> 201 </widget> 202 </item> 203 <item row="2" column="2" > 204 <widget class="QComboBox" name="mCbType" > 205 <property name="whatsThis" > 206 <string>Allows to select the sub-type of the storage controller currently selected in the Storage Tree.</string> 207 </property> 208 <property name="sizePolicy" > 209 <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > 210 <horstretch>0</horstretch> 211 <verstretch>0</verstretch> 212 </sizepolicy> 213 </property> 214 </widget> 215 </item> 216 <item row="3" column="0" colspan="3" > 217 <spacer name="mSp3" > 218 <property name="orientation" > 219 <enum>Qt::Vertical</enum> 220 </property> 221 <property name="sizeHint" stdset="0" > 222 <size> 223 <width>0</width> 224 <height>0</height> 225 </size> 226 </property> 227 </spacer> 228 </item> 229 </layout> 113 230 </widget> 114 </item> 115 </layout> 116 </item> 117 <item> 118 <widget class="QILabelSeparator" name="label"> 119 <property name="sizePolicy"> 120 <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> 121 <horstretch>0</horstretch> 122 <verstretch>0</verstretch> 123 </sizepolicy> 124 </property> 125 <property name="text"> 126 <string>&Attachments</string> 127 </property> 128 <property name="buddy"> 129 <cstring>mTwAts</cstring> 130 </property> 131 </widget> 132 </item> 133 <item> 134 <widget class="QWidget" name="mGbAts" native="true"> 135 <layout class="QHBoxLayout"> 136 <property name="margin"> 137 <number>0</number> 138 </property> 139 <item> 140 <widget class="QITableView" name="mTwAts"> 141 <property name="contextMenuPolicy"> 142 <enum>Qt::ActionsContextMenu</enum> 143 </property> 144 <property name="whatsThis"> 145 <string>Lists all hard disks attached to this machine. Use a mouse click or the <tt>Space</tt> key on the highlighted item to activate the drop-down list and choose the desired value. Use the context menu or buttons to the right to add or remove hard disk attachments.</string> 146 </property> 147 <property name="horizontalScrollBarPolicy"> 148 <enum>Qt::ScrollBarAlwaysOff</enum> 149 </property> 150 <property name="editTriggers"> 151 <set>QAbstractItemView::NoEditTriggers</set> 152 </property> 153 <property name="tabKeyNavigation"> 154 <bool>false</bool> 155 </property> 156 <property name="selectionMode"> 157 <enum>QAbstractItemView::SingleSelection</enum> 158 </property> 159 <property name="showGrid"> 160 <bool>false</bool> 161 </property> 162 <property name="gridStyle"> 163 <enum>Qt::NoPen</enum> 164 </property> 165 <property name="cornerButtonEnabled"> 166 <bool>false</bool> 167 </property> 168 </widget> 169 </item> 170 </layout> 171 </widget> 172 </item> 173 <item> 174 <widget class="QCheckBox" name="mShowDiffsCheck"> 175 <property name="whatsThis"> 176 <string>If checked, it will show differencing hard disks actually attached to the slots instead of their base hard disks (shown in case of indirect attachments) and will also let attach other differencing hard disks explicitly. Check this only if you need a complex hard disk setup.</string> 177 </property> 178 <property name="text"> 179 <string>&Show Differencing Hard Disks</string> 180 </property> 231 <widget class="QWidget" name="mWtAttachment" > 232 <layout class="QGridLayout" name="mLtAttachment" > 233 <property name="leftMargin" > 234 <number>10</number> 235 </property> 236 <property name="topMargin" > 237 <number>0</number> 238 </property> 239 <property name="rightMargin" > 240 <number>0</number> 241 </property> 242 <property name="bottomMargin" > 243 <number>0</number> 244 </property> 245 <item row="0" column="0" colspan="4" > 246 <widget class="QILabelSeparator" native="1" name="mLsAttributes" > 247 <property name="text" > 248 <string>Attributes</string> 249 </property> 250 </widget> 251 </item> 252 <item row="1" column="1" > 253 <widget class="QLabel" name="mLbSlot" > 254 <property name="text" > 255 <string>S&lot:</string> 256 </property> 257 <property name="buddy" > 258 <cstring>mCbSlot</cstring> 259 </property> 260 <property name="alignment" > 261 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 262 </property> 263 </widget> 264 </item> 265 <item row="1" column="2" colspan="2" > 266 <widget class="QComboBox" name="mCbSlot" > 267 <property name="whatsThis" > 268 <string>Allows to select the slot of the storage attachment currently selected in the Storage Tree. The list of the currently available slots depends on parent controller type of this attachment and takes into account slots already used by the other attachments of the same parent.</string> 269 </property> 270 <property name="sizePolicy" > 271 <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > 272 <horstretch>0</horstretch> 273 <verstretch>0</verstretch> 274 </sizepolicy> 275 </property> 276 </widget> 277 </item> 278 <item row="2" column="1" > 279 <widget class="QLabel" name="mLbDevice" > 280 <property name="text" > 281 <string>&Device:</string> 282 </property> 283 <property name="buddy" > 284 <cstring>mCbDevice</cstring> 285 </property> 286 <property name="alignment" > 287 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 288 </property> 289 </widget> 290 </item> 291 <item row="2" column="2" colspan="2" > 292 <widget class="QComboBox" name="mCbDevice" > 293 <property name="whatsThis" > 294 <string>Allows to select the type of the device represented by the currently selected attachment. The list of possible device types depends on parent controller type.</string> 295 </property> 296 <property name="sizePolicy" > 297 <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > 298 <horstretch>0</horstretch> 299 <verstretch>0</verstretch> 300 </sizepolicy> 301 </property> 302 </widget> 303 </item> 304 <item row="3" column="1" > 305 <widget class="QLabel" name="mLbVdi" > 306 <property name="text" > 307 <string>&Medium:</string> 308 </property> 309 <property name="buddy" > 310 <cstring>mCbVdi</cstring> 311 </property> 312 <property name="alignment" > 313 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 314 </property> 315 </widget> 316 </item> 317 <item row="3" column="2" > 318 <widget class="VBoxMediaComboBox" native="1" name="mCbVdi" > 319 <property name="whatsThis" > 320 <string>Allows to select the medium assigned for the currently selected attachment according to device type of this attachment. Available mediums list could contain virtual images and real host drives corresponding to device type currently chosen for this attachment.</string> 321 </property> 322 <property name="sizePolicy" > 323 <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > 324 <horstretch>0</horstretch> 325 <verstretch>0</verstretch> 326 </sizepolicy> 327 </property> 328 </widget> 329 </item> 330 <item row="3" column="3" > 331 <widget class="QToolButton" name="mTbVmm" > 332 <property name="whatsThis" > 333 <string>Invokes the Virtual Media Manager to select a medium to mount.</string> 334 </property> 335 <property name="toolTip" > 336 <string>Open Virtual Media Manager</string> 337 </property> 338 <property name="text" > 339 <string/> 340 </property> 341 <property name="autoRaise" > 342 <bool>true</bool> 343 </property> 344 </widget> 345 </item> 346 <item row="4" column="2" colspan="2" > 347 <widget class="QCheckBox" name="mCbShowDiffs"> 348 <property name="sizePolicy" > 349 <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" > 350 <horstretch>0</horstretch> 351 <verstretch>0</verstretch> 352 </sizepolicy> 353 </property> 354 <property name="whatsThis"> 355 <string>If checked, it will show differencing hard disks actually attached to the slots instead of their base hard disks (shown in case of indirect attachments) and will also let attach other differencing hard disks explicitly. Check this only if you need a complex hard disk setup.</string> 356 </property> 357 <property name="text"> 358 <string>D&ifferencing Disks</string> 359 </property> 360 </widget> 361 </item> 362 <item row="5" column="2" colspan="2" > 363 <widget class="QCheckBox" name="mCbPassthrough" > 364 <property name="sizePolicy" > 365 <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" > 366 <horstretch>0</horstretch> 367 <verstretch>0</verstretch> 368 </sizepolicy> 369 </property> 370 <property name="whatsThis" > 371 <string>When checked, allows the guest to send ATAPI commands directly to the host drive which makes it possible to use CD/DVD writers connected to the host inside the VM. Note that writing audio CD inside the VM is not yet supported.</string> 372 </property> 373 <property name="text" > 374 <string>&Passthrough</string> 375 </property> 376 </widget> 377 </item> 378 <item row="6" column="0" colspan="4" > 379 <widget class="QILabelSeparator" native="1" name="mLsInformation" > 380 <property name="text" > 381 <string>Information</string> 382 </property> 383 </widget> 384 </item> 385 <item row="7" column="1" > 386 <widget class="QLabel" name="mLbHDVirtualSize" > 387 <property name="text" > 388 <string>Virtual Size:</string> 389 </property> 390 <property name="alignment" > 391 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 392 </property> 393 </widget> 394 </item> 395 <item row="7" column="2" colspan="2" > 396 <widget class="QILabel" name="mLbHDVirtualSizeValue" > 397 <property name="sizePolicy" > 398 <sizepolicy vsizetype="Preferred" hsizetype="Ignored" > 399 <horstretch>0</horstretch> 400 <verstretch>0</verstretch> 401 </sizepolicy> 402 </property> 403 </widget> 404 </item> 405 <item row="8" column="1" > 406 <widget class="QLabel" name="mLbHDActualSize" > 407 <property name="text" > 408 <string>Actual Size:</string> 409 </property> 410 <property name="alignment" > 411 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 412 </property> 413 </widget> 414 </item> 415 <item row="8" column="2" colspan="2" > 416 <widget class="QILabel" name="mLbHDActualSizeValue" > 417 <property name="sizePolicy" > 418 <sizepolicy vsizetype="Preferred" hsizetype="Ignored" > 419 <horstretch>0</horstretch> 420 <verstretch>0</verstretch> 421 </sizepolicy> 422 </property> 423 </widget> 424 </item> 425 <item row="9" column="1" > 426 <widget class="QLabel" name="mLbSize" > 427 <property name="text" > 428 <string>Size:</string> 429 </property> 430 <property name="alignment" > 431 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 432 </property> 433 </widget> 434 </item> 435 <item row="9" column="2" colspan="2" > 436 <widget class="QILabel" name="mLbSizeValue" > 437 <property name="sizePolicy" > 438 <sizepolicy vsizetype="Preferred" hsizetype="Ignored" > 439 <horstretch>0</horstretch> 440 <verstretch>0</verstretch> 441 </sizepolicy> 442 </property> 443 </widget> 444 </item> 445 <item row="10" column="1" > 446 <widget class="QLabel" name="mLbLocation" > 447 <property name="text" > 448 <string>Location:</string> 449 </property> 450 <property name="alignment" > 451 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 452 </property> 453 </widget> 454 </item> 455 <item row="10" column="2" colspan="2" > 456 <widget class="QILabel" name="mLbLocationValue" > 457 <property name="sizePolicy" > 458 <sizepolicy vsizetype="Preferred" hsizetype="Ignored" > 459 <horstretch>0</horstretch> 460 <verstretch>0</verstretch> 461 </sizepolicy> 462 </property> 463 </widget> 464 </item> 465 <item row="11" column="1" > 466 <widget class="QLabel" name="mLbHDFormat" > 467 <property name="text" > 468 <string>Type (Format):</string> 469 </property> 470 <property name="alignment" > 471 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 472 </property> 473 </widget> 474 </item> 475 <item row="11" column="2" colspan="2" > 476 <widget class="QILabel" name="mLbHDFormatValue" > 477 <property name="sizePolicy" > 478 <sizepolicy vsizetype="Preferred" hsizetype="Ignored" > 479 <horstretch>0</horstretch> 480 <verstretch>0</verstretch> 481 </sizepolicy> 482 </property> 483 </widget> 484 </item> 485 <item row="12" column="1" > 486 <widget class="QLabel" name="mLbUsage" > 487 <property name="text" > 488 <string>Attached To:</string> 489 </property> 490 <property name="alignment" > 491 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 492 </property> 493 </widget> 494 </item> 495 <item row="12" column="2" colspan="2" > 496 <widget class="QILabel" name="mLbUsageValue" > 497 <property name="sizePolicy" > 498 <sizepolicy vsizetype="Preferred" hsizetype="Ignored" > 499 <horstretch>0</horstretch> 500 <verstretch>0</verstretch> 501 </sizepolicy> 502 </property> 503 </widget> 504 </item> 505 <item row="13" column="0" colspan="4" > 506 <spacer name="mSp6" > 507 <property name="orientation" > 508 <enum>Qt::Vertical</enum> 509 </property> 510 <property name="sizeHint" stdset="0" > 511 <size> 512 <width>0</width> 513 <height>0</height> 514 </size> 515 </property> 516 </spacer> 517 </item> 518 </layout> 519 </widget> 520 </widget> 181 521 </widget> 182 522 </item> … … 185 525 <customwidgets> 186 526 <customwidget> 187 <class>QITableView</class> 188 <extends>QTableView</extends> 189 <header>VBoxSettingsUtils.h</header> 527 <class>QISplitter</class> 528 <extends>QSplitter</extends> 529 <header>QISplitter.h</header> 530 <container>1</container> 190 531 </customwidget> 191 532 <customwidget> … … 193 534 <extends>QLabel</extends> 194 535 <header>QILabelSeparator.h</header> 536 <container>1</container> 537 </customwidget> 538 <customwidget> 539 <class>QITreeView</class> 540 <extends>QTreeView</extends> 541 <header>QITreeView.h</header> 542 <container>1</container> 543 </customwidget> 544 <customwidget> 545 <class>VBoxToolBar</class> 546 <extends>QWidget</extends> 547 <header>VBoxToolBar.h</header> 548 <container>1</container> 549 </customwidget> 550 <customwidget> 551 <class>VBoxMediaComboBox</class> 552 <extends>QComboBox</extends> 553 <header>VBoxMediaComboBox.h</header> 554 <container>1</container> 555 </customwidget> 556 <customwidget> 557 <class>QILabel</class> 558 <extends>QLabel</extends> 559 <header>QILabel.h</header> 195 560 </customwidget> 196 561 </customwidgets> 197 562 <resources/> 563 <connections/> 198 564 </ui>
Note:
See TracChangeset
for help on using the changeset viewer.