VirtualBox

Changeset 25091 in vbox


Ignore:
Timestamp:
Nov 30, 2009 9:19:48 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
55452
Message:

FE/Qt4: Ask for confirmation when the user try to delete the last CD/DVD device.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r24557 r25091  
    245245    int confirmRunNewHDWzdOrVDM (KDeviceType aDeviceType);
    246246
     247    int confirmRemovingOfLastDVDDevice() const;
     248
    247249    void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
    248250                                      const QString &aLocaiton,
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsHD.h

    r24419 r25091  
    582582    QString generateUniqueName (const QString &aTemplate) const;
    583583
     584    uint32_t deviceCount (KDeviceType aType) const;
     585
    584586    CMachine mMachine;
    585587    QIWidgetValidator *mValidator;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r24775 r25091  
    11441144}
    11451145
     1146int VBoxProblemReporter::confirmRemovingOfLastDVDDevice() const
     1147{
     1148    return messageOkCancel (QApplication::activeWindow(), Info,
     1149                    tr ("<p>Are you sure you want to delete the CDROM device? "
     1150                        "You will not be able to mount any CDs or ISO images "
     1151                        "without it.</p>"),
     1152                    0, /* aAutoConfirmId */
     1153                    tr ("&Remove", "medium"));
     1154}
     1155
    11461156void VBoxProblemReporter::cannotCreateHardDiskStorage (
    11471157    QWidget *aParent, const CVirtualBox &aVBox, const QString &aLocation,
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsHD.cpp

    r24811 r25091  
    19841984{
    19851985    QModelIndex index = mTwStorageTree->currentIndex();
     1986
     1987    KDeviceType device = mStorageModel->data (index, StorageModel::R_AttDevice).value <KDeviceType>();
     1988    /* Check if this would be the last DVD. If so let the user confirm this again. */
     1989    if (   device == KDeviceType_DVD
     1990        && deviceCount (KDeviceType_DVD) == 1)
     1991    {
     1992        if (vboxProblem().confirmRemovingOfLastDVDDevice() != QIMessageBox::Ok)
     1993            return;
     1994    }
     1995
    19861996    QModelIndex parent = index.parent();
    19871997    if (!index.isValid() || !parent.isValid() ||
     
    25402550}
    25412551
     2552uint32_t VBoxVMSettingsHD::deviceCount (KDeviceType aType) const
     2553{
     2554    uint32_t cDevices = 0;
     2555    QModelIndex rootIndex = mStorageModel->root();
     2556    for (int i = 0; i < mStorageModel->rowCount (rootIndex); ++ i)
     2557    {
     2558        QModelIndex ctrIndex = rootIndex.child (i, 0);
     2559        for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j)
     2560        {
     2561            QModelIndex attIndex = ctrIndex.child (j, 0);
     2562            KDeviceType attDevice = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>();
     2563            if (attDevice == aType)
     2564                ++cDevices;
     2565        }
     2566    }
     2567
     2568    return cDevices;
     2569}
     2570
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