Changeset 45278 in vbox
- Timestamp:
- Apr 2, 2013 8:54:33 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84672
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r45277 r45278 443 443 } 444 444 445 void UIMessageCenter::cannotOpenMachine(QWidget *pParent, const QString &strMachinePath, const CVirtualBox &vbox) 446 { 447 message(pParent ? pParent : mainWindowShown(), 448 MessageType_Error, 449 tr("Failed to open virtual machine located in %1.") 450 .arg(strMachinePath), 445 void UIMessageCenter::cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath) 446 { 447 message(mainWindowShown(), MessageType_Error, 448 tr("Failed to open virtual machine located in %1.").arg(strMachinePath), 451 449 formatErrorInfo(vbox)); 452 450 } 453 451 454 void UIMessageCenter::cannotReregisterMachine(QWidget *pParent, const QString &strMachinePath, const QString &strMachineName) 455 { 456 message(pParent ? pParent : mainWindowShown(), 457 MessageType_Error, 452 void UIMessageCenter::cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName) 453 { 454 message(mainWindowShown(), MessageType_Error, 458 455 tr("Failed to add virtual machine <b>%1</b> located in <i>%2</i> because its already present.") 459 456 .arg(strMachineName).arg(strMachinePath)); … … 462 459 void UIMessageCenter::cannotDeleteMachine(const CMachine &machine) 463 460 { 464 /* preserve the current error info before calling the object again*/461 /* Preserve error-info: */ 465 462 COMResult res(machine); 466 463 /* Show the message: */ 467 464 message(mainWindowShown(), 468 465 MessageType_Error, … … 532 529 } 533 530 534 int UIMessageCenter::confirmMachineDeletion(const QList<CMachine> &machines) 535 { 536 /* Enumerate VMs: */ 537 int cInacessibleVMCount = 0; 538 bool fVMWithHDPresent = false; 539 QString strVMNames; 540 for (int i = 0; i < machines.size(); ++i) 541 { 542 /* Get iterated VM: */ 543 const CMachine &machine = machines[i]; 544 /* Prepare VM name: */ 531 int UIMessageCenter::confirmMachineRemoval(const QList<CMachine> &machines) 532 { 533 /* Enumerate the machines: */ 534 int cInacessibleMachineCount = 0; 535 bool fMachineWithHardDiskPresent = false; 536 QString strMachineNames; 537 foreach (const CMachine &machine, machines) 538 { 539 /* Prepare machine name: */ 545 540 QString strMachineName; 546 541 if (machine.GetAccessible()) 547 542 { 548 /* Get VMname: */543 /* Just get machine name: */ 549 544 strMachineName = machine.GetName(); 550 /* Enumerate attachments: */545 /* Enumerate the attachments: */ 551 546 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 552 for (int i = 0; !fVMWithHDPresent && i < attachments.size(); ++i)547 foreach (const CMediumAttachment &attachment, attachments) 553 548 { 554 /* Get current attachment: */555 const CMediumAttachment &attachment = attachments.at(i);556 549 /* Check if the medium is a hard disk: */ 557 550 if (attachment.GetType() == KDeviceType_HardDisk) … … 559 552 /* Check if that hard disk isn't shared. 560 553 * If hard disk is shared, it will *never* be deleted: */ 561 QVector<QString> ids= attachment.GetMedium().GetMachineIds();562 if ( ids.size() == 1)554 QVector<QString> usedMachineList = attachment.GetMedium().GetMachineIds(); 555 if (usedMachineList.size() == 1) 563 556 { 564 f VMWithHDPresent = true;557 fMachineWithHardDiskPresent = true; 565 558 break; 566 559 } … … 570 563 else 571 564 { 572 /* Get VMname: */565 /* Compose machine name: */ 573 566 QFileInfo fi(machine.GetSettingsFilePath()); 574 567 strMachineName = VBoxGlobal::hasAllowedExtension(fi.completeSuffix(), VBoxFileExts) ? fi.completeBaseName() : fi.fileName(); 575 /* Increment inacessible VMcount: */576 ++cInacessible VMCount;568 /* Increment inacessible machine count: */ 569 ++cInacessibleMachineCount; 577 570 } 578 579 /* Compose VM name list: */ 580 strVMNames += QString(strVMNames.isEmpty() ? "<b>%1</b>" : ", <b>%1</b>").arg(strMachineName); 571 /* Append machine name to the full name string: */ 572 strMachineNames += QString(strMachineNames.isEmpty() ? "<b>%1</b>" : ", <b>%1</b>").arg(strMachineName); 581 573 } 582 574 583 575 /* Prepare message text: */ 584 QString strText = cInacessible VMCount == machines.size() ?576 QString strText = cInacessibleMachineCount == machines.size() ? 585 577 tr("<p>You are about to remove following inaccessible virtual machines from the machine list:</p>" 586 578 "<p>%1</p>" 587 579 "<p>Do you wish to proceed?</p>") 588 .arg(str VMNames) :589 f VMWithHDPresent ?580 .arg(strMachineNames) : 581 fMachineWithHardDiskPresent ? 590 582 tr("<p>You are about to remove following virtual machines from the machine list:</p>" 591 583 "<p>%1</p>" … … 593 585 "Doing this will also remove the files containing the machine's virtual hard disks " 594 586 "if they are not in use by another machine.</p>") 595 .arg(str VMNames) :587 .arg(strMachineNames) : 596 588 tr("<p>You are about to remove following virtual machines from the machine list:</p>" 597 589 "<p>%1</p>" 598 590 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well?</p>") 599 .arg(str VMNames);591 .arg(strMachineNames); 600 592 601 593 /* Prepare message itself: */ 602 return cInacessible VMCount == machines.size() ?603 message( &vboxGlobal().selectorWnd(),594 return cInacessibleMachineCount == machines.size() ? 595 message(mainWindowShown(), 604 596 MessageType_Question, 605 597 strText, … … 609 601 0, 610 602 tr("Remove")) : 611 message( &vboxGlobal().selectorWnd(),603 message(mainWindowShown(), 612 604 MessageType_Question, 613 605 strText, -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r45275 r45278 210 210 211 211 /* API: Selector warnings: */ 212 void cannotOpenMachine( QWidget *pParent, const QString &strMachinePath, const CVirtualBox &vbox);213 void cannotReregister Machine(QWidget *pParent,const QString &strMachinePath, const QString &strMachineName);212 void cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath); 213 void cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName); 214 214 void cannotDeleteMachine(const CMachine &machine); 215 215 void cannotDeleteMachine(const CMachine &machine, const CProgress &progress); … … 218 218 int askAboutCollisionOnGroupRemoving(const QString &strName, const QString &strGroupName); 219 219 int confirmMachineItemRemoval(const QStringList &names); 220 int confirmMachine Deletion(const QList<CMachine> &machines);220 int confirmMachineRemoval(const QList<CMachine> &machines); 221 221 bool confirmDiscardSavedState(const QString &strNames); 222 222 void cannotSetGroups(const CMachine &machine); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r45270 r45278 355 355 if (!vbox.isOk() || newMachine.isNull()) 356 356 { 357 msgCenter().cannotOpenMachine( this, strTmpFile, vbox);357 msgCenter().cannotOpenMachine(vbox, strTmpFile); 358 358 return; 359 359 } … … 363 363 if (!oldMachine.isNull()) 364 364 { 365 msgCenter().cannotReregister Machine(this,strTmpFile, oldMachine.GetName());365 msgCenter().cannotReregisterExistingMachine(strTmpFile, oldMachine.GetName()); 366 366 return; 367 367 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r45273 r45278 1457 1457 } 1458 1458 1459 /* Show machine remove dialog: */ 1460 int rc = msgCenter().confirmMachineDeletion(machines); 1461 if (rc != QIMessageBox::Cancel) 1462 { 1463 /* For every selected item: */ 1464 foreach (CMachine machine, machines) 1459 /* Confirm machine removal: */ 1460 int iResultCode = msgCenter().confirmMachineRemoval(machines); 1461 if (iResultCode == QIMessageBox::Cancel) 1462 return; 1463 1464 /* For every selected item: */ 1465 for (int iMachineIndex = 0; iMachineIndex < machines.size(); ++iMachineIndex) 1466 { 1467 /* Get iterated machine: */ 1468 CMachine &machine = machines[iMachineIndex]; 1469 if (iResultCode == QIMessageBox::Yes) 1465 1470 { 1466 if (rc == QIMessageBox::Yes) 1471 /* Unregister machine first: */ 1472 CMediumVector mediums = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly); 1473 if (!machine.isOk()) 1467 1474 { 1468 /* Unregister and cleanup machine's data & hard-disks: */ 1469 CMediumVector mediums = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly); 1470 if (machine.isOk()) 1471 { 1472 /* Delete machine hard-disks: */ 1473 CProgress progress = machine.DeleteConfig(mediums); 1474 if (machine.isOk()) 1475 { 1476 msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_delete_90px.png", msgCenter().mainWindowShown()); 1477 if (progress.GetResultCode() != 0) 1478 msgCenter().cannotDeleteMachine(machine, progress); 1479 } 1480 } 1481 if (!machine.isOk()) 1482 msgCenter().cannotDeleteMachine(machine); 1475 msgCenter().cannotDeleteMachine(machine); 1476 continue; 1483 1477 } 1484 else 1478 /* Prepare cleanup progress: */ 1479 CProgress progress = machine.DeleteConfig(mediums); 1480 if (!machine.isOk()) 1485 1481 { 1486 /* Just unregister machine: */ 1487 machine.Unregister(KCleanupMode_DetachAllReturnNone); 1488 if (!machine.isOk()) 1489 msgCenter().cannotDeleteMachine(machine); 1482 msgCenter().cannotDeleteMachine(machine); 1483 continue; 1484 } 1485 /* And show cleanup progress finally: */ 1486 msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_delete_90px.png"); 1487 if (progress.GetResultCode() != 0) 1488 { 1489 msgCenter().cannotDeleteMachine(machine, progress); 1490 continue; 1491 } 1492 } 1493 else 1494 { 1495 /* Just unregister machine: */ 1496 machine.Unregister(KCleanupMode_DetachAllReturnNone); 1497 if (!machine.isOk()) 1498 { 1499 msgCenter().cannotDeleteMachine(machine); 1500 continue; 1490 1501 } 1491 1502 }
Note:
See TracChangeset
for help on using the changeset viewer.