Changeset 81104 in vbox
- Timestamp:
- Oct 3, 2019 12:47:07 PM (5 years ago)
- 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 440 440 /** Returns type. */ 441 441 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; 444 444 445 445 /** Defines current @a uPortCount. */ … … 497 497 /** Updates possible buses. */ 498 498 void updateBusInfo(); 499 /** Updates possible types. */500 void updateTypeInfo();501 499 /** Updates pixmaps of possible buses. */ 502 500 void updatePixmaps(); … … 514 512 /** Holds the possible buses. */ 515 513 ControllerBusList m_buses; 516 /** Holds the possible types. */517 ControllerTypeList m_types;518 514 /** Holds the pixmaps of possible buses. */ 519 515 QList<PixmapType> m_pixmaps; … … 700 696 R_CtrName, 701 697 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, 703 706 R_CtrDevices, 704 707 R_CtrBusType, … … 812 815 /** Returns maximum controller types. */ 813 816 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); 814 822 815 823 private: … … 1240 1248 1241 1249 updateBusInfo(); 1242 updateTypeInfo();1243 1250 updatePixmaps(); 1244 1251 … … 1272 1279 1273 1280 updateBusInfo(); 1274 updateTypeInfo();1275 1281 updatePixmaps(); 1276 1282 } … … 1296 1302 } 1297 1303 1298 ControllerTypeList ControllerItem::types() const 1299 { 1300 return m_types; 1304 ControllerTypeList 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; 1301 1328 } 1302 1329 … … 1453 1480 } 1454 1481 } 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);1493 1482 } 1494 1483 … … 2070 2059 return result; 2071 2060 } 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: 2073 2069 { 2074 2070 QVariant result(QVariant::fromValue(ControllerTypeList())); 2075 2071 if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer())) 2076 2072 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))); 2078 2074 return result; 2079 2075 } … … 2378 2374 /* Push new bus/controller type: */ 2379 2375 pItemController->setBus(enmNewCtrBusType); 2380 pItemController->setType(pItemController->types( ).first());2376 pItemController->setType(pItemController->types(enmNewCtrBusType).first()); 2381 2377 emit dataChanged(index, index); 2382 2378 … … 2743 2739 } 2744 2740 return maximumMap; 2741 } 2742 2743 /* static */ 2744 KStorageBus 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 */ 2759 StorageModel::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); 2745 2771 } 2746 2772 … … 3290 3316 mLbName->setEnabled(isMachineOffline()); 3291 3317 mLeName->setEnabled(isMachineOffline()); 3292 mLbBus->setEnabled(isMachineOffline());3293 mCbBus->setEnabled(isMachineOffline());3294 3318 mLbType->setEnabled(isMachineOffline()); 3295 3319 mCbType->setEnabled(isMachineOffline()); … … 3576 3600 mLeName->setText(strCtrName); 3577 3601 3578 /* Getting Controller Bus type: */ 3579 mCbBus->clear(); 3602 /* Rebuild type combo: */ 3603 mCbType->clear(); 3604 /* Getting controller buses: */ 3580 3605 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 3583 3621 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 3596 3622 mLbPortCount->setVisible(enmBus == KStorageBus_SATA || enmBus == KStorageBus_SAS); 3597 3623 mSbPortCount->setVisible(enmBus == KStorageBus_SATA || enmBus == KStorageBus_SAS); … … 3722 3748 if (pSender == mLeName) 3723 3749 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);3728 3750 /* Setting Controller Sub-Type: */ 3729 3751 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 } 3732 3760 else if (pSender == mSbPortCount) 3733 3761 m_pModelStorage->setData(index, mSbPortCount->value(), StorageModel::R_CtrPortCount); … … 4643 4671 connect(mLeName, &QLineEdit::textEdited, 4644 4672 this, &UIMachineSettingsStorage::sltSetInformation); 4645 connect(mCbBus, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),4646 this, &UIMachineSettingsStorage::sltSetInformation);4647 4673 connect(mCbType, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), 4648 4674 this, &UIMachineSettingsStorage::sltSetInformation); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.ui
r80896 r81104 174 174 </item> 175 175 <item row="2" column="1" > 176 <widget class="QLabel" name="mLbBus" >177 <property name="text" >178 <string>&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" >202 176 <widget class="QLabel" name="mLbType" > 203 177 <property name="text" > … … 212 186 </widget> 213 187 </item> 214 <item row=" 3" column="2" >188 <item row="2" column="2" > 215 189 <widget class="QComboBox" name="mCbType" > 216 190 <property name="whatsThis" > … … 225 199 </widget> 226 200 </item> 227 <item row=" 4" column="1" >201 <item row="3" column="1" > 228 202 <widget class="QLabel" name="mLbPortCount" > 229 203 <property name="text" > … … 238 212 </widget> 239 213 </item> 240 <item row=" 4" column="2" >214 <item row="3" column="2" > 241 215 <widget class="QSpinBox" name="mSbPortCount" > 242 216 <property name="whatsThis" > … … 251 225 </widget> 252 226 </item> 253 <item row=" 5" column="2" >227 <item row="4" column="2" > 254 228 <widget class="QCheckBox" name="mCbIoCache" > 255 229 <property name="whatsThis" > … … 261 235 </widget> 262 236 </item> 263 <item row=" 6" column="0" colspan="3" >237 <item row="5" column="0" colspan="3" > 264 238 <spacer name="mSp3" > 265 239 <property name="orientation" >
Note:
See TracChangeset
for help on using the changeset viewer.