VirtualBox

Changeset 81104 in vbox


Ignore:
Timestamp:
Oct 3, 2019 12:47:07 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9582: VM settings / Storage page: Removing controller bus combo, all controller types are now enumerated in type combo, more fluent type changes.

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

    r81101 r81104  
    440440    /** Returns type. */
    441441    KStorageControllerType type() const;
    442     /** Returns possible types to switch from current one. */
    443     ControllerTypeList types() const;
     442    /** Returns possible types for specified @a enmBus to switch from current one. */
     443    ControllerTypeList types(KStorageBus enmBus) const;
    444444
    445445    /** Defines current @a uPortCount. */
     
    497497    /** Updates possible buses. */
    498498    void updateBusInfo();
    499     /** Updates possible types. */
    500     void updateTypeInfo();
    501499    /** Updates pixmaps of possible buses. */
    502500    void updatePixmaps();
     
    514512    /** Holds the possible buses. */
    515513    ControllerBusList   m_buses;
    516     /** Holds the possible types. */
    517     ControllerTypeList  m_types;
    518514    /** Holds the pixmaps of possible buses. */
    519515    QList<PixmapType>   m_pixmaps;
     
    700696        R_CtrName,
    701697        R_CtrType,
    702         R_CtrTypes,
     698        R_CtrTypesForIDE,
     699        R_CtrTypesForSATA,
     700        R_CtrTypesForSCSI,
     701        R_CtrTypesForFloppy,
     702        R_CtrTypesForSAS,
     703        R_CtrTypesForUSB,
     704        R_CtrTypesForPCIe,
     705        R_CtrTypesForVirtioSCSI,
    703706        R_CtrDevices,
    704707        R_CtrBusType,
     
    812815    /** Returns maximum controller types. */
    813816    QMap<KStorageBus, int> maximumControllerTypes() const;
     817
     818    /** Returns bus corresponding to passed enmRole. */
     819    static KStorageBus roleToBus(StorageModel::DataRole enmRole);
     820    /** Returns role corresponding to passed enmBus. */
     821    static StorageModel::DataRole busToRole(KStorageBus enmBus);
    814822
    815823private:
     
    12401248
    12411249    updateBusInfo();
    1242     updateTypeInfo();
    12431250    updatePixmaps();
    12441251
     
    12721279
    12731280    updateBusInfo();
    1274     updateTypeInfo();
    12751281    updatePixmaps();
    12761282}
     
    12961302}
    12971303
    1298 ControllerTypeList ControllerItem::types() const
    1299 {
    1300     return m_types;
     1304ControllerTypeList ControllerItem::types(KStorageBus enmBus) const
     1305{
     1306    ControllerTypeList types;
     1307
     1308    KStorageControllerType enmFirstType = KStorageControllerType_Null;
     1309    uint cAmount = 0;
     1310    switch (enmBus)
     1311    {
     1312        case KStorageBus_IDE:        enmFirstType = KStorageControllerType_PIIX3; cAmount = 3; break;
     1313        case KStorageBus_SATA:       enmFirstType = KStorageControllerType_IntelAhci; cAmount = 1; break;
     1314        case KStorageBus_SCSI:       enmFirstType = KStorageControllerType_LsiLogic; cAmount = 2; break;
     1315        case KStorageBus_Floppy:     enmFirstType = KStorageControllerType_I82078; cAmount = 1; break;
     1316        case KStorageBus_SAS:        enmFirstType = KStorageControllerType_LsiLogicSas; cAmount = 1; break;
     1317        case KStorageBus_USB:        enmFirstType = KStorageControllerType_USB; cAmount = 1; break;
     1318        case KStorageBus_PCIe:       enmFirstType = KStorageControllerType_NVMe; cAmount = 1; break;
     1319        case KStorageBus_VirtioSCSI: enmFirstType = KStorageControllerType_VirtioSCSI; cAmount = 1; break;
     1320        default:                     break;
     1321    }
     1322    AssertMsgReturn(enmFirstType != KStorageControllerType_Null, ("Invalid bus: %d!\n", (int)enmBus), types);
     1323
     1324    for (uint i = enmFirstType; i < enmFirstType + cAmount; ++i)
     1325        types << static_cast<KStorageControllerType>(i);
     1326
     1327    return types;
    13011328}
    13021329
     
    14531480        }
    14541481    }
    1455 }
    1456 
    1457 void ControllerItem::updateTypeInfo()
    1458 {
    1459     m_types.clear();
    1460 
    1461     KStorageControllerType enmFirstType = KStorageControllerType_Null;
    1462     switch (m_enmBus)
    1463     {
    1464         case KStorageBus_IDE:        enmFirstType = KStorageControllerType_PIIX3; break;
    1465         case KStorageBus_SATA:       enmFirstType = KStorageControllerType_IntelAhci; break;
    1466         case KStorageBus_SCSI:       enmFirstType = KStorageControllerType_LsiLogic; break;
    1467         case KStorageBus_Floppy:     enmFirstType = KStorageControllerType_I82078; break;
    1468         case KStorageBus_SAS:        enmFirstType = KStorageControllerType_LsiLogicSas; break;
    1469         case KStorageBus_USB:        enmFirstType = KStorageControllerType_USB; break;
    1470         case KStorageBus_PCIe:       enmFirstType = KStorageControllerType_NVMe; break;
    1471         case KStorageBus_VirtioSCSI: enmFirstType = KStorageControllerType_VirtioSCSI; break;
    1472         default:                     break;
    1473     }
    1474     AssertMsg(enmFirstType != KStorageControllerType_Null, ("Invalid item type!\n"));
    1475 
    1476     uint uTypeAmount = 0;
    1477     switch (m_enmBus)
    1478     {
    1479         case KStorageBus_IDE:        uTypeAmount = 3; break;
    1480         case KStorageBus_SATA:       uTypeAmount = 1; break;
    1481         case KStorageBus_SCSI:       uTypeAmount = 2; break;
    1482         case KStorageBus_Floppy:     uTypeAmount = 1; break;
    1483         case KStorageBus_SAS:        uTypeAmount = 1; break;
    1484         case KStorageBus_USB:        uTypeAmount = 1; break;
    1485         case KStorageBus_PCIe:       uTypeAmount = 1; break;
    1486         case KStorageBus_VirtioSCSI: uTypeAmount = 1; break;
    1487         default:                     break;
    1488     }
    1489     AssertMsg(uTypeAmount != 0, ("Invalid item type count!\n"));
    1490 
    1491     for (uint i = enmFirstType; i < enmFirstType + uTypeAmount; ++i)
    1492         m_types << static_cast<KStorageControllerType>(i);
    14931482}
    14941483
     
    20702059            return result;
    20712060        }
    2072         case R_CtrTypes:
     2061        case R_CtrTypesForIDE:
     2062        case R_CtrTypesForSATA:
     2063        case R_CtrTypesForSCSI:
     2064        case R_CtrTypesForFloppy:
     2065        case R_CtrTypesForSAS:
     2066        case R_CtrTypesForUSB:
     2067        case R_CtrTypesForPCIe:
     2068        case R_CtrTypesForVirtioSCSI:
    20732069        {
    20742070            QVariant result(QVariant::fromValue(ControllerTypeList()));
    20752071            if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
    20762072                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    2077                     result.setValue(qobject_cast<ControllerItem*>(pItem)->types());
     2073                    result.setValue(qobject_cast<ControllerItem*>(pItem)->types(roleToBus((StorageModel::DataRole)iRole)));
    20782074            return result;
    20792075        }
     
    23782374                    /* Push new bus/controller type: */
    23792375                    pItemController->setBus(enmNewCtrBusType);
    2380                     pItemController->setType(pItemController->types().first());
     2376                    pItemController->setType(pItemController->types(enmNewCtrBusType).first());
    23812377                    emit dataChanged(index, index);
    23822378
     
    27432739    }
    27442740    return maximumMap;
     2741}
     2742
     2743/* static */
     2744KStorageBus StorageModel::roleToBus(StorageModel::DataRole enmRole)
     2745{
     2746    QMap<StorageModel::DataRole, KStorageBus> typeRoles;
     2747    typeRoles[StorageModel::R_CtrTypesForIDE]        = KStorageBus_IDE;
     2748    typeRoles[StorageModel::R_CtrTypesForSATA]       = KStorageBus_SATA;
     2749    typeRoles[StorageModel::R_CtrTypesForSCSI]       = KStorageBus_SCSI;
     2750    typeRoles[StorageModel::R_CtrTypesForFloppy]     = KStorageBus_Floppy;
     2751    typeRoles[StorageModel::R_CtrTypesForSAS]        = KStorageBus_SAS;
     2752    typeRoles[StorageModel::R_CtrTypesForUSB]        = KStorageBus_USB;
     2753    typeRoles[StorageModel::R_CtrTypesForPCIe]       = KStorageBus_PCIe;
     2754    typeRoles[StorageModel::R_CtrTypesForVirtioSCSI] = KStorageBus_VirtioSCSI;
     2755    return typeRoles.value(enmRole);
     2756}
     2757
     2758/* static */
     2759StorageModel::DataRole StorageModel::busToRole(KStorageBus enmBus)
     2760{
     2761    QMap<KStorageBus, StorageModel::DataRole> typeRoles;
     2762    typeRoles[KStorageBus_IDE]        = StorageModel::R_CtrTypesForIDE;
     2763    typeRoles[KStorageBus_SATA]       = StorageModel::R_CtrTypesForSATA;
     2764    typeRoles[KStorageBus_SCSI]       = StorageModel::R_CtrTypesForSCSI;
     2765    typeRoles[KStorageBus_Floppy]     = StorageModel::R_CtrTypesForFloppy;
     2766    typeRoles[KStorageBus_SAS]        = StorageModel::R_CtrTypesForSAS;
     2767    typeRoles[KStorageBus_USB]        = StorageModel::R_CtrTypesForUSB;
     2768    typeRoles[KStorageBus_PCIe]       = StorageModel::R_CtrTypesForPCIe;
     2769    typeRoles[KStorageBus_VirtioSCSI] = StorageModel::R_CtrTypesForVirtioSCSI;
     2770    return typeRoles.value(enmBus);
    27452771}
    27462772
     
    32903316    mLbName->setEnabled(isMachineOffline());
    32913317    mLeName->setEnabled(isMachineOffline());
    3292     mLbBus->setEnabled(isMachineOffline());
    3293     mCbBus->setEnabled(isMachineOffline());
    32943318    mLbType->setEnabled(isMachineOffline());
    32953319    mCbType->setEnabled(isMachineOffline());
     
    35763600                    mLeName->setText(strCtrName);
    35773601
    3578                 /* Getting Controller Bus type: */
    3579                 mCbBus->clear();
     3602                /* Rebuild type combo: */
     3603                mCbType->clear();
     3604                /* Getting controller buses: */
    35803605                const ControllerBusList controllerBusList(m_pModelStorage->data(index, StorageModel::R_CtrBusTypes).value<ControllerBusList>());
    3581                 for (int i = 0; i < controllerBusList.size(); ++i)
    3582                     mCbBus->insertItem(mCbBus->count(), gpConverter->toString(controllerBusList[i]));
     3606                foreach (const KStorageBus &enmCurrentBus, controllerBusList)
     3607                {
     3608                    /* Getting controller types: */
     3609                    const ControllerTypeList controllerTypeList(m_pModelStorage->data(index, m_pModelStorage->busToRole(enmCurrentBus)).value<ControllerTypeList>());
     3610                    foreach (const KStorageControllerType &enmCurrentType, controllerTypeList)
     3611                    {
     3612                        mCbType->addItem(gpConverter->toString(enmCurrentType));
     3613                        mCbType->setItemData(mCbType->count() - 1, QVariant::fromValue(enmCurrentBus), StorageModel::R_CtrBusType);
     3614                        mCbType->setItemData(mCbType->count() - 1, QVariant::fromValue(enmCurrentType), StorageModel::R_CtrType);
     3615                    }
     3616                }
     3617                const KStorageControllerType enmType = m_pModelStorage->data(index, StorageModel::R_CtrType).value<KStorageControllerType>();
     3618                const int iCtrPos = mCbType->findData(enmType, StorageModel::R_CtrType);
     3619                mCbType->setCurrentIndex(iCtrPos == -1 ? 0 : iCtrPos);
     3620
    35833621                const KStorageBus enmBus = m_pModelStorage->data(index, StorageModel::R_CtrBusType).value<KStorageBus>();
    3584                 const int iBusPos = mCbBus->findText(gpConverter->toString(enmBus));
    3585                 mCbBus->setCurrentIndex(iBusPos == -1 ? 0 : iBusPos);
    3586 
    3587                 /* Getting Controller Sub type: */
    3588                 mCbType->clear();
    3589                 const ControllerTypeList controllerTypeList(m_pModelStorage->data(index, StorageModel::R_CtrTypes).value<ControllerTypeList>());
    3590                 for (int i = 0; i < controllerTypeList.size(); ++i)
    3591                     mCbType->insertItem(mCbType->count(), gpConverter->toString(controllerTypeList[i]));
    3592                 const KStorageControllerType enmType = m_pModelStorage->data(index, StorageModel::R_CtrType).value<KStorageControllerType>();
    3593                 const int iCtrPos = mCbType->findText(gpConverter->toString(enmType));
    3594                 mCbType->setCurrentIndex(iCtrPos == -1 ? 0 : iCtrPos);
    3595 
    35963622                mLbPortCount->setVisible(enmBus == KStorageBus_SATA || enmBus == KStorageBus_SAS);
    35973623                mSbPortCount->setVisible(enmBus == KStorageBus_SATA || enmBus == KStorageBus_SAS);
     
    37223748            if (pSender == mLeName)
    37233749                m_pModelStorage->setData(index, mLeName->text(), StorageModel::R_CtrName);
    3724             /* Setting Controller Bus-Type: */
    3725             else if (pSender == mCbBus)
    3726                 m_pModelStorage->setData(index, QVariant::fromValue(gpConverter->fromString<KStorageBus>(mCbBus->currentText())),
    3727                                          StorageModel::R_CtrBusType);
    37283750            /* Setting Controller Sub-Type: */
    37293751            else if (pSender == mCbType)
    3730                 m_pModelStorage->setData(index, QVariant::fromValue(gpConverter->fromString<KStorageControllerType>(mCbType->currentText())),
    3731                                         StorageModel::R_CtrType);
     3752            {
     3753                m_pModelStorage->setData(index,
     3754                                         QVariant::fromValue(mCbType->currentData(StorageModel::R_CtrBusType).value<KStorageBus>()),
     3755                                         StorageModel::R_CtrBusType);
     3756                m_pModelStorage->setData(index,
     3757                                         QVariant::fromValue(mCbType->currentData(StorageModel::R_CtrType).value<KStorageControllerType>()),
     3758                                         StorageModel::R_CtrType);
     3759            }
    37323760            else if (pSender == mSbPortCount)
    37333761                m_pModelStorage->setData(index, mSbPortCount->value(), StorageModel::R_CtrPortCount);
     
    46434671    connect(mLeName, &QLineEdit::textEdited,
    46444672            this, &UIMachineSettingsStorage::sltSetInformation);
    4645     connect(mCbBus, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
    4646             this, &UIMachineSettingsStorage::sltSetInformation);
    46474673    connect(mCbType, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
    46484674            this, &UIMachineSettingsStorage::sltSetInformation);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.ui

    r80896 r81104  
    174174        </item>
    175175        <item row="2" column="1" >
    176          <widget class="QLabel" name="mLbBus" >
    177           <property name="text" >
    178            <string>&amp;Bus:</string>
    179           </property>
    180           <property name="buddy" >
    181            <cstring>mCbBus</cstring>
    182           </property>
    183           <property name="alignment" >
    184            <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    185           </property>
    186          </widget>
    187         </item>
    188         <item row="2" column="2" >
    189          <widget class="QComboBox" name="mCbBus" >
    190           <property name="whatsThis" >
    191            <string>Selects the bus type of the storage controller currently selected in the Storage Tree.</string>
    192           </property>
    193           <property name="sizePolicy" >
    194            <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
    195             <horstretch>0</horstretch>
    196             <verstretch>0</verstretch>
    197            </sizepolicy>
    198           </property>
    199          </widget>
    200         </item>
    201         <item row="3" column="1" >
    202176         <widget class="QLabel" name="mLbType" >
    203177          <property name="text" >
     
    212186         </widget>
    213187        </item>
    214         <item row="3" column="2" >
     188        <item row="2" column="2" >
    215189         <widget class="QComboBox" name="mCbType" >
    216190          <property name="whatsThis" >
     
    225199         </widget>
    226200        </item>
    227         <item row="4" column="1" >
     201        <item row="3" column="1" >
    228202         <widget class="QLabel" name="mLbPortCount" >
    229203          <property name="text" >
     
    238212         </widget>
    239213        </item>
    240         <item row="4" column="2" >
     214        <item row="3" column="2" >
    241215         <widget class="QSpinBox" name="mSbPortCount" >
    242216          <property name="whatsThis" >
     
    251225         </widget>
    252226        </item>
    253         <item row="5" column="2" >
     227        <item row="4" column="2" >
    254228         <widget class="QCheckBox" name="mCbIoCache" >
    255229          <property name="whatsThis" >
     
    261235         </widget>
    262236        </item>
    263         <item row="6" column="0" colspan="3" >
     237        <item row="5" column="0" colspan="3" >
    264238         <spacer name="mSp3" >
    265239          <property name="orientation" >
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