VirtualBox

Ignore:
Timestamp:
Apr 3, 2013 5:30:17 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Message-center cleanup (part 22): Medium Manager stuff.

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

Legend:

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

    r45314 r45315  
    917917
    918918void UIMessageCenter::cannotChangeMediumType(const CMedium &medium, KMediumType oldMediumType, KMediumType newMediumType,
    919                                              QWidget *pParent /*= 0*/)
     919                                             QWidget *pParent /*= 0*/) const
    920920{
    921921    message(pParent ? pParent : mainWindowShown(), MessageType_Error,
     
    925925}
    926926
    927 bool UIMessageCenter::confirmMediumRelease(const UIMedium &medium, const QString &strUsage, QWidget *pParent /*= 0*/)
     927bool UIMessageCenter::confirmMediumRelease(const UIMedium &medium, const QString &strUsage, QWidget *pParent /*= 0*/) const
    928928{
    929929    /* Prepare the message: */
     
    958958}
    959959
    960 bool UIMessageCenter::confirmMediumRemoval(const UIMedium &medium, QWidget *pParent /*= 0*/)
     960bool UIMessageCenter::confirmMediumRemoval(const UIMedium &medium, QWidget *pParent /*= 0*/) const
    961961{
    962962    /* Prepare the message: */
     
    10081008}
    10091009
    1010 int UIMessageCenter::confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent /*= 0*/)
     1010int UIMessageCenter::confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent /*= 0*/) const
    10111011{
    10121012    return message(pParent ? pParent : mainWindowShown(), MessageType_Question,
     
    10291029}
    10301030
    1031 void UIMessageCenter::cannotDeleteHardDiskStorage(const CMedium &medium, const CProgress &progress, QWidget *pParent /*= 0*/)
    1032 {
    1033     /* Preserve error-info: */
    1034     QString strErrorInfo = !medium.isOk() ? formatErrorInfo(medium) :
    1035                            !progress.isOk() ? formatErrorInfo(progress) :
    1036                            formatErrorInfo(progress.GetErrorInfo());
    1037     /* Show the message: */
     1031void UIMessageCenter::cannotDeleteHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent /*= 0*/) const
     1032{
    10381033    message(pParent ? pParent : mainWindowShown(), MessageType_Error,
    10391034            tr("Failed to delete the storage unit of the hard disk <b>%1</b>.")
    1040                .arg(medium.GetLocation()),
    1041             strErrorInfo);
    1042 }
    1043 
    1044 void UIMessageCenter::cannotDetachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent /*= 0*/)
     1035               .arg(strLocation),
     1036            formatErrorInfo(medium));
     1037}
     1038
     1039void UIMessageCenter::cannotDeleteHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent /*= 0*/) const
     1040{
     1041    message(pParent ? pParent : mainWindowShown(), MessageType_Error,
     1042            tr("Failed to delete the storage unit of the hard disk <b>%1</b>.")
     1043               .arg(strLocation),
     1044            !progress.isOk() ? formatErrorInfo(progress) : formatErrorInfo(progress.GetErrorInfo()));
     1045}
     1046
     1047void UIMessageCenter::cannotDetachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent /*= 0*/) const
    10451048{
    10461049    /* Preserve error-info: */
     
    10751078}
    10761079
    1077 int UIMessageCenter::cannotRemountMedium(const CMachine &machine, const UIMedium &medium, bool fMount, bool fRetry, QWidget *pParent /*= 0*/)
     1080int UIMessageCenter::cannotRemountMedium(const CMachine &machine, const UIMedium &medium, bool fMount, bool fRetry, QWidget *pParent /*= 0*/) const
    10781081{
    10791082    /* Preserve error-info: */
     
    11301133}
    11311134
    1132 void UIMessageCenter::cannotOpenMedium(const CVirtualBox &vbox, UIMediumType type, const QString &strLocation, QWidget *pParent /*= 0*/)
     1135void UIMessageCenter::cannotOpenMedium(const CVirtualBox &vbox, UIMediumType type, const QString &strLocation, QWidget *pParent /*= 0*/) const
    11331136{
    11341137    /* Prepare the message: */
     
    11591162}
    11601163
    1161 void UIMessageCenter::cannotCloseMedium(const UIMedium &medium, const COMResult &rc, QWidget *pParent /*= 0*/)
     1164void UIMessageCenter::cannotCloseMedium(const UIMedium &medium, const COMResult &rc, QWidget *pParent /*= 0*/) const
    11621165{
    11631166    /* Prepare the message: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r45314 r45315  
    256256
    257257    /* API: Virtual Medium Manager warnings: */
    258     void cannotChangeMediumType(const CMedium &medium, KMediumType oldMediumType, KMediumType newMediumType, QWidget *pParent = 0);
    259     bool confirmMediumRelease(const UIMedium &medium, const QString &strUsage, QWidget *pParent = 0);
    260     bool confirmMediumRemoval(const UIMedium &medium, QWidget *pParent = 0);
    261     int confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent = 0);
    262     void cannotDeleteHardDiskStorage(const CMedium &medium, const CProgress &progress, QWidget *pParent = 0);
    263     void cannotDetachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0);
    264     int cannotRemountMedium(const CMachine &machine, const UIMedium &medium, bool fMount, bool fRetry, QWidget *pParent = 0);
    265     void cannotOpenMedium(const CVirtualBox &vbox, UIMediumType type, const QString &strLocation, QWidget *pParent = 0);
    266     void cannotCloseMedium(const UIMedium &medium, const COMResult &rc, QWidget *pParent = 0);
     258    void cannotChangeMediumType(const CMedium &medium, KMediumType oldMediumType, KMediumType newMediumType, QWidget *pParent = 0) const;
     259    bool confirmMediumRelease(const UIMedium &medium, const QString &strUsage, QWidget *pParent = 0) const;
     260    bool confirmMediumRemoval(const UIMedium &medium, QWidget *pParent = 0) const;
     261    int confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent = 0) const;
     262    void cannotDeleteHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent = 0) const;
     263    void cannotDeleteHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent = 0) const;
     264    void cannotDetachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0) const;
     265    int cannotRemountMedium(const CMachine &machine, const UIMedium &medium, bool fMount, bool fRetry, QWidget *pParent = 0) const;
     266    void cannotOpenMedium(const CVirtualBox &vbox, UIMediumType type, const QString &strLocation, QWidget *pParent = 0) const;
     267    void cannotCloseMedium(const UIMedium &medium, const COMResult &rc, QWidget *pParent = 0) const;
    267268
    268269    /* API: Wizards warnings: */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r45296 r45315  
    11681168            if (deleteStorage)
    11691169            {
     1170                /* Remember virtual-disk attributes: */
     1171                QString strLocation = hardDisk.GetLocation();
     1172                /* Prepare delete storage progress: */
    11701173                CProgress progress = hardDisk.DeleteStorage();
    11711174                if (hardDisk.isOk())
    11721175                {
     1176                    /* Show delete storage progress: */
    11731177                    msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_delete_90px.png", this);
    1174                     if (!(progress.isOk() && progress.GetResultCode() == S_OK))
     1178                    if (!progress.isOk() || progress.GetResultCode() != 0)
    11751179                    {
    1176                         msgCenter().cannotDeleteHardDiskStorage(hardDisk, progress, this);
     1180                        msgCenter().cannotDeleteHardDiskStorage(progress, strLocation, this);
    11771181                        return;
    11781182                    }
     1183                }
     1184                else
     1185                {
     1186                    msgCenter().cannotDeleteHardDiskStorage(hardDisk, strLocation, this);
     1187                    return;
    11791188                }
    11801189            }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic3.cpp

    r45292 r45315  
    9898void UIWizardNewVMPage3::ensureNewVirtualDiskDeleted()
    9999{
    100     /* Make sure virtual-disk exists: */
     100    /* Make sure virtual-disk valid: */
    101101    if (m_virtualDisk.isNull())
    102102        return;
    103103
    104     /* Remember virtual-disk ID: */
     104    /* Remember virtual-disk attributes: */
    105105    QString strId = m_virtualDisk.GetId();
    106 
    107     /* 1st step: start delete-storage progress: */
     106    QString strLocation = m_virtualDisk.GetLocation();
     107    /* Prepare delete storage progress: */
    108108    CProgress progress = m_virtualDisk.DeleteStorage();
    109     /* Get initial state: */
    110     bool fSuccess = m_virtualDisk.isOk();
    111 
    112     /* 2nd step: show delete-storage progress: */
    113     if (fSuccess)
    114     {
     109    if (m_virtualDisk.isOk())
     110    {
     111        /* Show delete storage progress: */
    115112        msgCenter().showModalProgressDialog(progress, thisImp()->windowTitle(), ":/progress_media_delete_90px.png", thisImp());
    116         fSuccess = progress.isOk() && progress.GetResultCode() == S_OK;
    117     }
    118 
    119     /* 3rd step: notify GUI about virtual-disk was deleted or show error if any: */
    120     if (fSuccess)
    121         vboxGlobal().removeMedium(UIMediumType_HardDisk, strId);
     113        if (!progress.isOk() || progress.GetResultCode() != 0)
     114            msgCenter().cannotDeleteHardDiskStorage(progress, strLocation, thisImp());
     115    }
    122116    else
    123         msgCenter().cannotDeleteHardDiskStorage(m_virtualDisk, progress, thisImp());
    124 
    125     /* Detach virtual-disk finally: */
     117        msgCenter().cannotDeleteHardDiskStorage(m_virtualDisk, strLocation, thisImp());
     118
     119    /* Remove virtual-disk from GUI anyway: */
     120    vboxGlobal().removeMedium(UIMediumType_HardDisk, strId);
     121
     122    /* Detach virtual-disk anyway: */
    126123    m_virtualDisk.detach();
    127124}
Note: See TracChangeset for help on using the changeset viewer.

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