Changeset 81297 in vbox
- Timestamp:
- Oct 16, 2019 5:03:57 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r81296 r81297 791 791 /** Moves attachment with certain @a uAttId from controller with certain @a uCtrOldId to one with another @a uCtrNewId. */ 792 792 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; 793 796 794 797 /** Defines @a uMachineId for reference. */ … … 2614 2617 } 2615 2618 2619 KDeviceType 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 2616 2643 void StorageModel::setMachineId(const QUuid &uMachineId) 2617 2644 { … … 4339 4366 return; 4340 4367 4341 /* Get controller id: */4368 /* Get controller/attachment ids: */ 4342 4369 const QString strControllerId = pMimeData->data(UIMachineSettingsStorage::s_strControllerMimeType); 4370 const QString strAttachmentId = pMimeData->data(UIMachineSettingsStorage::s_strAttachmentMimeType); 4343 4371 4344 4372 /* Check what item we are hovering currently: */ … … 4348 4376 ControllerItem *pItemController = qobject_cast<ControllerItem*>(pItem); 4349 4377 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))) 4350 4382 return; 4351 4383 /* Also make sure there is enough place for new attachment: */
Note:
See TracChangeset
for help on using the changeset viewer.