Changeset 82385 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Dec 4, 2019 4:19:20 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceImportEditorWidget.cpp
r79365 r82385 253 253 if (m_pMACComboBox) 254 254 { 255 MACAddressImportPolicy macPolicy = static_cast<MACAddressImportPolicy>(m_pMACComboBox->currentIndex());256 switch ( macPolicy)255 const MACAddressImportPolicy enmPolicy = m_pMACComboBox->currentData().value<MACAddressImportPolicy>(); 256 switch (enmPolicy) 257 257 { 258 258 case MACAddressImportPolicy_KeepAllMACs: … … 326 326 /* Translate MAC address policy combo-box: */ 327 327 m_pMACComboBoxLabel->setText(tr("MAC Address &Policy:")); 328 m_pMACComboBox->setItemText(MACAddressImportPolicy_KeepAllMACs, 329 tr("Include all network adapter MAC addresses")); 330 m_pMACComboBox->setItemText(MACAddressImportPolicy_KeepNATMACs, 331 tr("Include only NAT network adapter MAC addresses")); 332 m_pMACComboBox->setItemText(MACAddressImportPolicy_StripAllMACs, 333 tr("Generate new MAC addresses for all network adapters")); 334 m_pMACComboBox->setItemData(MACAddressImportPolicy_KeepAllMACs, 335 tr("Include all network adapter MAC addresses during cloning."), Qt::ToolTipRole); 336 m_pMACComboBox->setItemData(MACAddressImportPolicy_KeepNATMACs, 337 tr("Include only NAT network adapter MAC addresses during cloning."), Qt::ToolTipRole); 338 m_pMACComboBox->setItemData(MACAddressImportPolicy_StripAllMACs, 339 tr("Generate new MAC addresses for all network adapters during cloning."), Qt::ToolTipRole); 328 for (int i = 0; i < m_pMACComboBox->count(); ++i) 329 { 330 const MACAddressImportPolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressImportPolicy>(); 331 switch (enmPolicy) 332 { 333 case MACAddressImportPolicy_KeepAllMACs: 334 { 335 m_pMACComboBox->setItemText(i, tr("Include all network adapter MAC addresses")); 336 m_pMACComboBox->setItemData(i, tr("Include all network adapter MAC addresses during importing."), Qt::ToolTipRole); 337 break; 338 } 339 case MACAddressImportPolicy_KeepNATMACs: 340 { 341 m_pMACComboBox->setItemText(i, tr("Include only NAT network adapter MAC addresses")); 342 m_pMACComboBox->setItemData(i, tr("Include only NAT network adapter MAC addresses during importing."), Qt::ToolTipRole); 343 break; 344 } 345 case MACAddressImportPolicy_StripAllMACs: 346 { 347 m_pMACComboBox->setItemText(i, tr("Generate new MAC addresses for all network adapters")); 348 m_pMACComboBox->setItemData(i, tr("Generate new MAC addresses for all network adapters during importing."), Qt::ToolTipRole); 349 break; 350 } 351 default: 352 break; 353 } 354 } 340 355 341 356 m_pAdditionalOptionsLabel->setText(tr("Additional Options:")); … … 362 377 AssertReturnVoid(m_pMACComboBox->count() == 0); 363 378 364 /* Apply hardcoded policies list: */ 365 for (int i = 0; i < (int)MACAddressImportPolicy_MAX; ++i) 366 { 367 m_pMACComboBox->addItem(QString::number(i)); 368 m_pMACComboBox->setItemData(i, i); 369 } 379 /* Map known import options to known MAC address import policies: */ 380 QMap<KImportOptions, MACAddressImportPolicy> knownOptions; 381 knownOptions[KImportOptions_KeepAllMACs] = MACAddressImportPolicy_KeepAllMACs; 382 knownOptions[KImportOptions_KeepNATMACs] = MACAddressImportPolicy_KeepNATMACs; 383 384 /* Load currently supported import options: */ 385 CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 386 const QVector<KImportOptions> supportedOptions = comProperties.GetSupportedImportOptions(); 387 388 /* Check which of supported options/policies are known: */ 389 QList<MACAddressImportPolicy> supportedPolicies; 390 foreach (const KImportOptions &enmOption, supportedOptions) 391 if (knownOptions.contains(enmOption)) 392 supportedPolicies << knownOptions.value(enmOption); 393 394 /* Add supported policies first: */ 395 foreach (const MACAddressImportPolicy &enmPolicy, supportedPolicies) 396 m_pMACComboBox->addItem(QString(), QVariant::fromValue(enmPolicy)); 397 398 /* Add hardcoded policy finally: */ 399 m_pMACComboBox->addItem(QString(), QVariant::fromValue(MACAddressImportPolicy_StripAllMACs)); 370 400 371 401 /* Set default: */ 372 setMACAddressImportPolicy(MACAddressImportPolicy_KeepNATMACs); 402 if (supportedPolicies.contains(MACAddressImportPolicy_KeepNATMACs)) 403 setMACAddressImportPolicy(MACAddressImportPolicy_KeepNATMACs); 404 else 405 setMACAddressImportPolicy(MACAddressImportPolicy_StripAllMACs); 373 406 } 374 407 375 408 void UIApplianceImportEditorWidget::setMACAddressImportPolicy(MACAddressImportPolicy enmMACAddressImportPolicy) 376 409 { 377 const int iIndex = m_pMACComboBox->findData( (int)enmMACAddressImportPolicy);410 const int iIndex = m_pMACComboBox->findData(enmMACAddressImportPolicy); 378 411 AssertMsg(iIndex != -1, ("Data not found!")); 379 412 m_pMACComboBox->setCurrentIndex(iIndex); … … 388 421 void UIApplianceImportEditorWidget::updateMACAddressImportPolicyComboToolTip() 389 422 { 390 const int iCurrentIndex = m_pMACComboBox->currentIndex(); 391 const QString strCurrentToolTip = m_pMACComboBox->itemData(iCurrentIndex, Qt::ToolTipRole).toString(); 423 const QString strCurrentToolTip = m_pMACComboBox->currentData(Qt::ToolTipRole).toString(); 392 424 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 393 425 m_pMACComboBox->setToolTip(strCurrentToolTip); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceImportEditorWidget.h
r79032 r82385 38 38 MACAddressImportPolicy_MAX 39 39 }; 40 Q_DECLARE_METATYPE(MACAddressImportPolicy); 40 41 41 42 class UIApplianceImportEditorWidget: public UIApplianceEditorWidget
Note:
See TracChangeset
for help on using the changeset viewer.