VirtualBox

Changeset 31385 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 5, 2010 9:29:59 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64444
Message:

FE/Qt4: implemented new deletion possibilities in the GUI

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp

    r30997 r31385  
    10511051}
    10521052
    1053 bool VBoxProblemReporter::confirmMachineDeletion (const CMachine &machine)
     1053int VBoxProblemReporter::confirmMachineDeletion(const CMachine &machine)
    10541054{
    10551055    QString msg;
     
    10591059    if (machine.GetAccessible())
    10601060    {
    1061         name = machine.GetName();
    1062         msg = tr ("<p>Are you sure you want to permanently delete "
    1063                   "the virtual machine <b>%1</b>?</p>"
    1064                   "<p>This operation cannot be undone.</p>")
    1065                   .arg (name);
    1066         button = tr ("Delete", "machine");
     1061        return message(&vboxGlobal().selectorWnd(), Question,
     1062        tr("<p>Are you sure you want to permanently delete the virtual "
     1063           "machine <b>%1</b>?</p>"
     1064           "<p>This operation <i>cannot</i> be undone.</p>"
     1065           "<p>If you select <b>Delete All</b> everything gets removed. This "
     1066           "includes the machine itself, but also all virtual disks attached "
     1067           "to it. If you want preserve the virtual disks for later use, "
     1068           "select <b>Keep Harddisks</b>.</p>")
     1069        .arg(machine.GetName()),
     1070        0, /* aAutoConfirmId */
     1071        QIMessageBox::No,
     1072        QIMessageBox::Yes,
     1073        QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default,
     1074        tr("Keep Harddisks", "machine"),
     1075        tr("Delete All", "machine"));
    10671076    }
    10681077    else
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h

    r30996 r31385  
    236236    int cannotEnterSeamlessMode();
    237237
    238     bool confirmMachineDeletion (const CMachine &machine);
     238    int confirmMachineDeletion(const CMachine &machine);
    239239    bool confirmDiscardSavedState (const CMachine &machine);
    240240
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp

    r31333 r31385  
    638638    AssertMsgReturnVoid (item, ("Item must be always selected here"));
    639639
    640     if (vboxProblem().confirmMachineDeletion (item->machine()))
    641     {
    642         CVirtualBox vbox = vboxGlobal().virtualBox();
    643         QString id = item->id();
    644         bool ok = false;
    645         if (item->accessible())
    646         {
    647             /* Open a direct session to modify VM settings */
    648             CSession session = vboxGlobal().openSession (id);
    649             if (session.isNull())
    650                 return;
    651             CMachine machine = session.GetMachine();
    652             /* Detach all attached Hard Disks */
    653             CMediumAttachmentVector vec = machine.GetMediumAttachments();
    654             for (int i = 0; i < vec.size(); ++ i)
     640    int rc = vboxProblem().confirmMachineDeletion(item->machine());
     641    if (rc != QIMessageBox::Cancel)
     642    {
     643        CMachine machine = item->machine();
     644        QVector<CMedium> aMedia = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);          //  @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
     645        if (machine.isOk() && item->accessible())
     646        {
     647            /* If not Yes, we don't want touch the harddisks */
     648            if (rc == QIMessageBox::No)
     649                aMedia.clear();
     650            /* delete machine settings */
     651            CProgress progress = machine.Delete(aMedia);
     652            if (machine.isOk())
    655653            {
    656                 CMediumAttachment hda = vec [i];
    657                 const QString ctlName = hda.GetController();
    658 
    659                 machine.DetachDevice(ctlName, hda.GetPort(), hda.GetDevice());
    660                 if (!machine.isOk())
    661                 {
    662                     CStorageController ctl = machine.GetStorageControllerByName(ctlName);
    663                     vboxProblem().cannotDetachDevice (this, machine, VBoxDefs::MediumType_HardDisk,
    664                         vboxGlobal().getMedium (CMedium (hda.GetMedium())).location(),
    665                         ctl.GetBus(), hda.GetPort(), hda.GetDevice());
    666                 }
     654                vboxProblem().showModalProgressDialog(progress, item->name(), 0, 0);
     655                if (progress.GetResultCode() != 0)
     656                    vboxProblem().cannotDeleteMachine(machine);
    667657            }
    668             /* Commit changes */
    669             machine.SaveSettings();
    670             if (!machine.isOk())
    671                 vboxProblem().cannotSaveMachineSettings (machine);
    672             else
    673                 ok = true;
    674             session.UnlockMachine();
    675         }
    676         else
    677             ok = true;
    678 
    679         if (ok)
    680         {
    681             CMachine machine = item->machine();
    682             QVector<CMedium> aMedia = machine.Unregister(KCleanupMode_UnregisterOnly);          //  @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
    683             if (machine.isOk() && item->accessible())
    684             {
    685                 /* delete machine settings */
    686                 CProgress progress = machine.Delete(aMedia);
    687                 progress.WaitForCompletion(-1);         // @todo do this nicely with a progress dialog, this can delete many files!
    688 
    689                 /* remove the item shortly: cmachine it refers to is no longer valid! */
    690                 int row = mVMModel->rowById (item->id());
    691                 mVMModel->removeItem (item);
    692                 delete item;
    693                 mVMListView->ensureSomeRowSelected (row);
    694             }
    695             if (!machine.isOk())
    696                 vboxProblem().cannotDeleteMachine(machine);
    697         }
     658        }
     659        if (!machine.isOk())
     660            vboxProblem().cannotDeleteMachine(machine);
    698661    }
    699662}
     
    12051168        /* enable/disable modify actions */
    12061169        mVmConfigAction->setEnabled (modifyEnabled);
    1207         mVmDeleteAction->setEnabled (modifyEnabled);
     1170        mVmDeleteAction->setEnabled (!running);
    12081171        mVmDiscardAction->setEnabled (state == KMachineState_Saved && !running);
    12091172        mVmPauseAction->setEnabled (   state == KMachineState_Running
     
    16271590
    16281591        /* Delete */
    1629         mVmDeleteAction->setEnabled (modifyEnabled);
     1592        mVmDeleteAction->setEnabled (!running);
    16301593
    16311594        /* Discard */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette