VirtualBox

Changeset 102933 in vbox for trunk/src


Ignore:
Timestamp:
Jan 17, 2024 4:43:21 PM (13 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: VM settings / Storage page: Get rid of unwanted QModelIndex::internalPointer references while it's possible to use official public API; This is necessary to work with proxy/filter model without changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp

    r102924 r102933  
    31623162                                                                           oldControllerData.m_enmBus,
    31633163                                                                           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();
    31653165        m_pModelStorage->setData(controllerIndex, oldControllerData.m_uPortCount, StorageModel::R_CtrPortCount);
    31663166        m_pModelStorage->setData(controllerIndex, oldControllerData.m_fUseHostIOCache, StorageModel::R_CtrIoCache);
     
    34633463        return;
    34643464
    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());
    34663466
    34673467    /* Notify listeners: */
     
    35423542        return;
    35433543
    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());
    35463546
    35473547    /* Notify listeners: */
     
    41834183
    41844184        /* 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())
    41904190        {
    41914191            /* Initialize dragging: */
     
    41954195            {
    41964196                /* Assign pixmap: */
    4197                 pDrag->setPixmap(pItem->pixmap());
     4197                pDrag->setPixmap(m_pModelStorage->data(index, StorageModel::R_ItemPixmapDefault).value<QPixmap>());
    41984198                /* Prepare mime: */
    41994199                QMimeData *pMimeData = new QMimeData;
    42004200                if (pMimeData)
    42014201                {
    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());
    42044206                    pDrag->setMimeData(pMimeData);
    42054207                }
     
    43174319    /* Check what item we are hovering currently: */
    43184320    QModelIndex index = m_pTreeViewStorage->indexAt(pEvent->position().toPoint());
    4319     AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer());
    43204321    /* 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)
    43234324        return;
    43244325    /* Then make sure we support such attachment device type: */
     
    43454346    /* Check what item we are hovering currently: */
    43464347    QModelIndex index = m_pTreeViewStorage->indexAt(pEvent->position().toPoint());
    4347     AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer());
    43484348    /* 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())
    43514350    {
    43524351        /* Get controller/attachment ids: */
    43534352        const QString strControllerId = pMimeData->data(UIStorageSettingsEditor::s_strControllerMimeType);
    43544353        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());
    43564356    }
    43574357}
     
    51155115        return;
    51165116
    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);
    51185118    m_pModelStorage->sort();
    51195119
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