VirtualBox

Changeset 66541 in vbox for trunk/src


Ignore:
Timestamp:
Apr 12, 2017 4:03:58 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings: Storage page: Cache controllers by initial name while attachments by current port/device pair.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

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

    r66460 r66541  
    692692                                KStorageBus aBusType, KStorageControllerType aControllerType)
    693693    : AbstractItem (aParent)
     694    , mOldCtrName (aName)
    694695    , mCtrName (aName)
    695696    , mCtrType (0)
     
    743744{
    744745    return mCtrType->busType();
     746}
     747
     748QString ControllerItem::oldCtrName() const
     749{
     750    return mOldCtrName;
    745751}
    746752
     
    14031409        }
    14041410
     1411        case R_CtrOldName:
     1412        {
     1413            if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer()))
     1414                if (item->rtti() == AbstractItem::Type_ControllerItem)
     1415                    return static_cast <ControllerItem*> (item)->oldCtrName();
     1416            return QString();
     1417        }
    14051418        case R_CtrName:
    14061419        {
     
    21812194    for (int iControllerIndex = 0; iControllerIndex < controllers.size(); ++iControllerIndex)
    21822195    {
    2183         /* Prepare old controller data: */
     2196        /* Prepare old controller data & cache key: */
    21842197        UIDataSettingsMachineStorageController oldControllerData;
     2198        QString strControllerKey = QString::number(iControllerIndex);
    21852199
    21862200        /* Check whether controller is valid: */
     
    21942208            oldControllerData.m_uPortCount = comController.GetPortCount();
    21952209            oldControllerData.m_fUseHostIOCache = comController.GetUseHostIOCache();
     2210            /* Override controller cache key: */
     2211            strControllerKey = oldControllerData.m_strControllerName;
    21962212
    21972213            /* Sort attachments before caching/fetching: */
     
    22102226            for (int iAttachmentIndex = 0; iAttachmentIndex < attachments.size(); ++iAttachmentIndex)
    22112227            {
    2212                 /* Prepare old attachment data: */
     2228                /* Prepare old attachment data & cache key: */
    22132229                UIDataSettingsMachineStorageAttachment oldAttachmentData;
     2230                QString strAttachmentKey = QString::number(iAttachmentIndex);
    22142231
    22152232                /* Check whether attachment is valid: */
     
    22272244                    const CMedium comMedium = comAttachment.GetMedium();
    22282245                    oldAttachmentData.m_strAttachmentMediumId = comMedium.isNull() ? UIMedium::nullID() : comMedium.GetId();
     2246                    /* Override controller cache key: */
     2247                    strAttachmentKey = QString("%1:%2").arg(oldAttachmentData.m_iAttachmentPort).arg(oldAttachmentData.m_iAttachmentDevice);
    22292248                }
    22302249
    22312250                /* Cache old attachment data: */
    2232                 m_pCache->child(iControllerIndex).child(iAttachmentIndex).cacheInitialData(oldAttachmentData);
     2251                m_pCache->child(strControllerKey).child(strAttachmentKey).cacheInitialData(oldAttachmentData);
    22332252            }
    22342253        }
    22352254
    22362255        /* Cache old controller data: */
    2237         m_pCache->child(iControllerIndex).cacheInitialData(oldControllerData);
     2256        m_pCache->child(strControllerKey).cacheInitialData(oldControllerData);
    22382257    }
    22392258
     
    23182337        UIDataSettingsMachineStorageController newControllerData;
    23192338
    2320         /* Gather new controller data from model: */
     2339        /* Gather new controller data & cache key from model: */
    23212340        const QModelIndex controllerIndex = m_pModelStorage->index(iControllerIndex, 0, rootIndex);
    23222341        newControllerData.m_strControllerName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString();
     
    23252344        newControllerData.m_uPortCount = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrPortCount).toUInt();
    23262345        newControllerData.m_fUseHostIOCache = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrIoCache).toBool();
     2346        const QString strControllerKey = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrOldName).toString();
    23272347
    23282348        /* For each attachment: */
     
    23322352            UIDataSettingsMachineStorageAttachment newAttachmentData;
    23332353
    2334             /* Gather new controller data from model: */
     2354            /* Gather new attachment data & cache key from model: */
    23352355            const QModelIndex attachmentIndex = m_pModelStorage->index(iAttachmentIndex, 0, controllerIndex);
    23362356            newAttachmentData.m_attachmentType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>();
     
    23432363            newAttachmentData.m_fAttachmentHotPluggable = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsHotPluggable).toBool();
    23442364            newAttachmentData.m_strAttachmentMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString();
     2365            const QString strAttachmentKey = QString("%1:%2").arg(newAttachmentData.m_iAttachmentPort).arg(newAttachmentData.m_iAttachmentDevice);
    23452366
    23462367            /* Cache new attachment data: */
    2347             m_pCache->child(iControllerIndex).child(iAttachmentIndex).cacheCurrentData(newAttachmentData);
     2368            m_pCache->child(strControllerKey).child(strAttachmentKey).cacheCurrentData(newAttachmentData);
    23482369        }
    23492370
    23502371        /* Cache new controller data: */
    2351         m_pCache->child(iControllerIndex).cacheCurrentData(newControllerData);
     2372        m_pCache->child(strControllerKey).cacheCurrentData(newControllerData);
    23522373    }
    23532374
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r66444 r66541  
    330330
    331331    KStorageBus ctrBusType() const;
     332    QString oldCtrName() const;
    332333    QString ctrName() const;
    333334    KStorageControllerType ctrType() const;
     
    361362    void delChild (AbstractItem *aItem);
    362363
     364    QString mOldCtrName;
    363365    QString mCtrName;
    364366    AbstractControllerType *mCtrType;
     
    468470        R_IsMoreAttachmentsPossible,
    469471
     472        R_CtrOldName,
    470473        R_CtrName,
    471474        R_CtrType,
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