VirtualBox

Changeset 82267 in vbox


Ignore:
Timestamp:
Nov 28, 2019 2:54:36 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135085
Message:

FE/Qt: bugref:9611: UIMachineSettingsStorage: Rework controller items to cache possible controller types instead of calculating them every time; Check whether storage controller type is supported as well before adding related types to bus selection combo (s.a. r135064).

File:
1 edited

Legend:

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

    r82250 r82267  
    497497    /** Updates possible buses. */
    498498    void updateBusInfo();
     499    /** Updates possible types. */
     500    void updateTypeInfo();
    499501    /** Updates pixmaps of possible buses. */
    500502    void updatePixmaps();
     
    511513
    512514    /** Holds the possible buses. */
    513     ControllerBusList   m_buses;
     515    ControllerBusList                      m_buses;
     516    /** Holds the possible types on per bus basis. */
     517    QMap<KStorageBus, ControllerTypeList>  m_types;
    514518    /** Holds the pixmaps of possible buses. */
    515     QList<PixmapType>   m_pixmaps;
     519    QList<PixmapType>                      m_pixmaps;
    516520
    517521    /** Holds the current port count. */
     
    12511255
    12521256    updateBusInfo();
     1257    updateTypeInfo();
    12531258    updatePixmaps();
    12541259
     
    12821287
    12831288    updateBusInfo();
     1289    updateTypeInfo();
    12841290    updatePixmaps();
    12851291}
     
    12981304{
    12991305    m_enmType = enmType;
     1306
     1307    updateTypeInfo();
    13001308}
    13011309
     
    13071315ControllerTypeList ControllerItem::types(KStorageBus enmBus) const
    13081316{
    1309     ControllerTypeList types;
    1310 
    1311     KStorageControllerType enmFirstType = KStorageControllerType_Null;
    1312     uint cAmount = 0;
    1313     switch (enmBus)
    1314     {
    1315         case KStorageBus_IDE:        enmFirstType = KStorageControllerType_PIIX3; cAmount = 3; break;
    1316         case KStorageBus_SATA:       enmFirstType = KStorageControllerType_IntelAhci; cAmount = 1; break;
    1317         case KStorageBus_SCSI:       enmFirstType = KStorageControllerType_LsiLogic; cAmount = 2; break;
    1318         case KStorageBus_Floppy:     enmFirstType = KStorageControllerType_I82078; cAmount = 1; break;
    1319         case KStorageBus_SAS:        enmFirstType = KStorageControllerType_LsiLogicSas; cAmount = 1; break;
    1320         case KStorageBus_USB:        enmFirstType = KStorageControllerType_USB; cAmount = 1; break;
    1321         case KStorageBus_PCIe:       enmFirstType = KStorageControllerType_NVMe; cAmount = 1; break;
    1322         case KStorageBus_VirtioSCSI: enmFirstType = KStorageControllerType_VirtioSCSI; cAmount = 1; break;
    1323         default:                     break;
    1324     }
    1325     AssertMsgReturn(enmFirstType != KStorageControllerType_Null, ("Invalid bus: %d!\n", (int)enmBus), types);
    1326 
    1327     for (uint i = enmFirstType; i < enmFirstType + cAmount; ++i)
    1328         types << static_cast<KStorageControllerType>(i);
    1329 
    1330     return types;
     1317    return m_types.value(enmBus);
    13311318}
    13321319
     
    14781465    /* And prepend current bus finally: */
    14791466    m_buses.prepend(m_enmBus);
     1467}
     1468
     1469void ControllerItem::updateTypeInfo()
     1470{
     1471    /* Clear the types initially: */
     1472    m_types.clear();
     1473
     1474    /* Load currently supported storage buses & types: */
     1475    CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     1476    const QVector<KStorageBus> supportedBuses = comProperties.GetSupportedStorageBuses();
     1477    const QVector<KStorageControllerType> supportedTypes = comProperties.GetSupportedStorageControllerTypes();
     1478
     1479    /* We update the list with all supported buses
     1480     * and remove the current one from that list. */
     1481    ControllerBusList possibleBuses = supportedBuses.toList();
     1482    possibleBuses.removeAll(m_enmBus);
     1483
     1484    /* And prepend current bus finally: */
     1485    possibleBuses.prepend(m_enmBus);
     1486
     1487    /* Enumerate possible buses: */
     1488    foreach (const KStorageBus &enmBus, possibleBuses)
     1489    {
     1490        /* This is hardcoded hell, we will get rid of it one day .. */
     1491        KStorageControllerType enmFirstType = KStorageControllerType_Null;
     1492        uint cAmount = 0;
     1493        switch (enmBus)
     1494        {
     1495            case KStorageBus_IDE:        enmFirstType = KStorageControllerType_PIIX3; cAmount = 3; break;
     1496            case KStorageBus_SATA:       enmFirstType = KStorageControllerType_IntelAhci; cAmount = 1; break;
     1497            case KStorageBus_SCSI:       enmFirstType = KStorageControllerType_LsiLogic; cAmount = 2; break;
     1498            case KStorageBus_Floppy:     enmFirstType = KStorageControllerType_I82078; cAmount = 1; break;
     1499            case KStorageBus_SAS:        enmFirstType = KStorageControllerType_LsiLogicSas; cAmount = 1; break;
     1500            case KStorageBus_USB:        enmFirstType = KStorageControllerType_USB; cAmount = 1; break;
     1501            case KStorageBus_PCIe:       enmFirstType = KStorageControllerType_NVMe; cAmount = 1; break;
     1502            case KStorageBus_VirtioSCSI: enmFirstType = KStorageControllerType_VirtioSCSI; cAmount = 1; break;
     1503            default:                     break;
     1504        }
     1505
     1506        /* Check whether type is supported or already selected before adding it: */
     1507        for (uint i = enmFirstType; i < enmFirstType + cAmount; ++i)
     1508        {
     1509            const KStorageControllerType enmType = static_cast<KStorageControllerType>(i);
     1510            if (supportedTypes.contains(enmType) || enmType == m_enmType)
     1511                m_types[enmBus] << enmType;
     1512        }
     1513    }
    14801514}
    14811515
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette