VirtualBox

Changeset 81297 in vbox


Ignore:
Timestamp:
Oct 16, 2019 5:03:57 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6248: VM settings / Storage page: Make sure attachment is of allowed device type while trying to d&d it to another controller.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r81296 r81297  
    791791    /** Moves attachment with certain @a uAttId from controller with certain @a uCtrOldId to one with another @a uCtrNewId. */
    792792    void moveAttachment(const QUuid &uAttId, const QUuid &uCtrOldId, const QUuid &uCtrNewId);
     793
     794    /** Returns device type of attachment with certain @a uAttId from controller with certain @a uCtrId. */
     795    KDeviceType attachmentDeviceType(const QUuid &uCtrId, const QUuid &uAttId) const;
    793796
    794797    /** Defines @a uMachineId for reference. */
     
    26142617}
    26152618
     2619KDeviceType StorageModel::attachmentDeviceType(const QUuid &uCtrId, const QUuid &uAttId) const
     2620{
     2621    /* First of all we are looking for top-level (controller) item: */
     2622    AbstractItem *pTopLevelItem = m_pRootItem->childItemById(uCtrId);
     2623    if (pTopLevelItem)
     2624    {
     2625        /* Then we are looking for sub-level (attachment) item: */
     2626        AbstractItem *pSubLevelItem = pTopLevelItem->childItemById(uAttId);
     2627        if (pSubLevelItem)
     2628        {
     2629            /* And make sure this is really an attachment: */
     2630            AttachmentItem *pAttachmentItem = qobject_cast<AttachmentItem*>(pSubLevelItem);
     2631            if (pAttachmentItem)
     2632            {
     2633                /* This way we can acquire actual attachment device type: */
     2634                return pAttachmentItem->deviceType();
     2635            }
     2636        }
     2637    }
     2638
     2639    /* Null by default: */
     2640    return KDeviceType_Null;
     2641}
     2642
    26162643void StorageModel::setMachineId(const QUuid &uMachineId)
    26172644{
     
    43394366        return;
    43404367
    4341     /* Get controller id: */
     4368    /* Get controller/attachment ids: */
    43424369    const QString strControllerId = pMimeData->data(UIMachineSettingsStorage::s_strControllerMimeType);
     4370    const QString strAttachmentId = pMimeData->data(UIMachineSettingsStorage::s_strAttachmentMimeType);
    43434371
    43444372    /* Check what item we are hovering currently: */
     
    43484376    ControllerItem *pItemController = qobject_cast<ControllerItem*>(pItem);
    43494377    if (!pItemController || pItemController->id().toString() == strControllerId)
     4378        return;
     4379    /* Then make sure we support such attachment device type: */
     4380    const DeviceTypeList devicesList(m_pModelStorage->data(index, StorageModel::R_CtrDevices).value<DeviceTypeList>());
     4381    if (!devicesList.contains(m_pModelStorage->attachmentDeviceType(strControllerId, strAttachmentId)))
    43504382        return;
    43514383    /* Also make sure there is enough place for new attachment: */
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