- Timestamp:
- Jan 17, 2024 4:43:21 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp
r102924 r102933 3162 3162 oldControllerData.m_enmBus, 3163 3163 oldControllerData.m_enmType); 3164 const QUuid controllerId = QUuid(m_pModelStorage->data(controllerIndex, StorageModel::R_ItemId).toString());3164 const QUuid controllerId = m_pModelStorage->data(controllerIndex, StorageModel::R_ItemId).toUuid(); 3165 3165 m_pModelStorage->setData(controllerIndex, oldControllerData.m_uPortCount, StorageModel::R_CtrPortCount); 3166 3166 m_pModelStorage->setData(controllerIndex, oldControllerData.m_fUseHostIOCache, StorageModel::R_CtrIoCache); … … 3463 3463 return; 3464 3464 3465 m_pModelStorage->delController( QUuid(m_pModelStorage->data(index, StorageModel::R_ItemId).toString()));3465 m_pModelStorage->delController(m_pModelStorage->data(index, StorageModel::R_ItemId).toUuid()); 3466 3466 3467 3467 /* Notify listeners: */ … … 3542 3542 return; 3543 3543 3544 m_pModelStorage->delAttachment( QUuid(m_pModelStorage->data(parentIndex, StorageModel::R_ItemId).toString()),3545 QUuid(m_pModelStorage->data(index, StorageModel::R_ItemId).toString()));3544 m_pModelStorage->delAttachment(m_pModelStorage->data(parentIndex, StorageModel::R_ItemId).toUuid(), 3545 m_pModelStorage->data(index, StorageModel::R_ItemId).toUuid()); 3546 3546 3547 3547 /* Notify listeners: */ … … 4183 4183 4184 4184 /* Check what item we are hovering currently: */ 4185 QModelIndex index = m_pTreeViewStorage->indexAt(lPos);4186 AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer());4187 /* And make sure this is attachment item, we are supporting dragging for this kind only: */4188 AttachmentItem *pItemAttachment = qobject_cast<AttachmentItem*>(pItem);4189 if (pItemAttachment)4185 const QModelIndex index = m_pTreeViewStorage->indexAt(lPos); 4186 const QModelIndex parentIndex = index.parent(); 4187 /* And make sure it is attachment, and parent is controller: */ 4188 if ( m_pModelStorage->data(index, StorageModel::R_IsAttachment).toBool() 4189 && m_pModelStorage->data(parentIndex, StorageModel::R_IsController).toBool()) 4190 4190 { 4191 4191 /* Initialize dragging: */ … … 4195 4195 { 4196 4196 /* Assign pixmap: */ 4197 pDrag->setPixmap( pItem->pixmap());4197 pDrag->setPixmap(m_pModelStorage->data(index, StorageModel::R_ItemPixmapDefault).value<QPixmap>()); 4198 4198 /* Prepare mime: */ 4199 4199 QMimeData *pMimeData = new QMimeData; 4200 4200 if (pMimeData) 4201 4201 { 4202 pMimeData->setData(s_strControllerMimeType, pItemAttachment->parent()->id().toString().toLatin1()); 4203 pMimeData->setData(s_strAttachmentMimeType, pItemAttachment->id().toString().toLatin1()); 4202 const QString parentId = m_pModelStorage->data(parentIndex, StorageModel::R_ItemId).toString(); 4203 const QString id = m_pModelStorage->data(index, StorageModel::R_ItemId).toString(); 4204 pMimeData->setData(s_strControllerMimeType, parentId.toLatin1()); 4205 pMimeData->setData(s_strAttachmentMimeType, id.toLatin1()); 4204 4206 pDrag->setMimeData(pMimeData); 4205 4207 } … … 4317 4319 /* Check what item we are hovering currently: */ 4318 4320 QModelIndex index = m_pTreeViewStorage->indexAt(pEvent->position().toPoint()); 4319 AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer());4320 4321 /* And make sure this is controller item, we are supporting dropping for this kind only: */ 4321 ControllerItem *pItemController = qobject_cast<ControllerItem*>(pItem);4322 if (!pItemController || pItemController->id().toString() == strControllerId)4322 if ( !m_pModelStorage->data(index, StorageModel::R_IsController).toBool() 4323 || m_pModelStorage->data(index, StorageModel::R_ItemId).toString() == strControllerId) 4323 4324 return; 4324 4325 /* Then make sure we support such attachment device type: */ … … 4345 4346 /* Check what item we are hovering currently: */ 4346 4347 QModelIndex index = m_pTreeViewStorage->indexAt(pEvent->position().toPoint()); 4347 AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer());4348 4348 /* And make sure this is controller item, we are supporting dropping for this kind only: */ 4349 ControllerItem *pItemController = qobject_cast<ControllerItem*>(pItem); 4350 if (pItemController) 4349 if (m_pModelStorage->data(index, StorageModel::R_IsController).toBool()) 4351 4350 { 4352 4351 /* Get controller/attachment ids: */ 4353 4352 const QString strControllerId = pMimeData->data(UIStorageSettingsEditor::s_strControllerMimeType); 4354 4353 const QString strAttachmentId = pMimeData->data(UIStorageSettingsEditor::s_strAttachmentMimeType); 4355 m_pModelStorage->moveAttachment(QUuid(strAttachmentId), QUuid(strControllerId), pItemController->id()); 4354 m_pModelStorage->moveAttachment(QUuid(strAttachmentId), QUuid(strControllerId), 4355 m_pModelStorage->data(index, StorageModel::R_ItemId).toUuid()); 4356 4356 } 4357 4357 } … … 5115 5115 return; 5116 5116 5117 m_pModelStorage->addAttachment( QUuid(m_pModelStorage->data(index, StorageModel::R_ItemId).toString()), enmDeviceType, uMediumId);5117 m_pModelStorage->addAttachment(m_pModelStorage->data(index, StorageModel::R_ItemId).toUuid(), enmDeviceType, uMediumId); 5118 5118 m_pModelStorage->sort(); 5119 5119
Note:
See TracChangeset
for help on using the changeset viewer.