- Timestamp:
- Dec 4, 2019 5:43:48 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp
r82386 r82392 43 43 /* COM includes: */ 44 44 #include "CMachine.h" 45 #include "CSystemProperties.h" 45 46 46 47 … … 134 135 AssertReturnVoid(m_pMACComboBox->count() == 0); 135 136 136 /* Apply hardcoded policies list: */ 137 for (int i = 0; i < (int)MACAddressExportPolicy_MAX; ++i) 138 { 139 m_pMACComboBox->addItem(QString::number(i)); 140 m_pMACComboBox->setItemData(i, i); 141 } 137 /* Map known export options to known MAC address export policies: */ 138 QMap<KExportOptions, MACAddressExportPolicy> knownOptions; 139 knownOptions[KExportOptions_StripAllMACs] = MACAddressExportPolicy_StripAllMACs; 140 knownOptions[KExportOptions_StripAllNonNATMACs] = MACAddressExportPolicy_StripAllNonNATMACs; 141 142 /* Load currently supported export options: */ 143 CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 144 const QVector<KExportOptions> supportedOptions = comProperties.GetSupportedExportOptions(); 145 146 /* Check which of supported options/policies are known: */ 147 QList<MACAddressExportPolicy> supportedPolicies; 148 foreach (const KExportOptions &enmOption, supportedOptions) 149 if (knownOptions.contains(enmOption)) 150 supportedPolicies << knownOptions.value(enmOption); 151 152 /* Add supported policies first: */ 153 foreach (const MACAddressExportPolicy &enmPolicy, supportedPolicies) 154 m_pMACComboBox->addItem(QString(), QVariant::fromValue(enmPolicy)); 155 156 /* Add hardcoded policy finally: */ 157 m_pMACComboBox->addItem(QString(), QVariant::fromValue(MACAddressExportPolicy_KeepAllMACs)); 142 158 143 159 /* Set default: */ 144 setMACAddressExportPolicy(MACAddressExportPolicy_StripAllNonNATMACs); 160 if (supportedPolicies.contains(MACAddressExportPolicy_StripAllNonNATMACs)) 161 setMACAddressExportPolicy(MACAddressExportPolicy_StripAllNonNATMACs); 162 else 163 setMACAddressExportPolicy(MACAddressExportPolicy_KeepAllMACs); 145 164 } 146 165 … … 507 526 void UIWizardExportAppPage2::updateMACAddressExportPolicyComboToolTip() 508 527 { 509 const int iCurrentIndex = m_pMACComboBox->currentIndex(); 510 const QString strCurrentToolTip = m_pMACComboBox->itemData(iCurrentIndex, Qt::ToolTipRole).toString(); 528 const QString strCurrentToolTip = m_pMACComboBox->currentData(Qt::ToolTipRole).toString(); 511 529 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 512 530 m_pMACComboBox->setToolTip(strCurrentToolTip); … … 577 595 void UIWizardExportAppPage2::setMACAddressExportPolicy(MACAddressExportPolicy enmMACAddressExportPolicy) 578 596 { 579 const int iIndex = m_pMACComboBox->findData( (int)enmMACAddressExportPolicy);597 const int iIndex = m_pMACComboBox->findData(enmMACAddressExportPolicy); 580 598 AssertMsg(iIndex != -1, ("Data not found!")); 581 599 m_pMACComboBox->setCurrentIndex(iIndex); … … 584 602 MACAddressExportPolicy UIWizardExportAppPage2::macAddressExportPolicy() const 585 603 { 586 const int iIndex = m_pMACComboBox->currentIndex(); 587 return (MACAddressExportPolicy)m_pMACComboBox->itemData(iIndex).toInt(); 604 return m_pMACComboBox->currentData().value<MACAddressExportPolicy>(); 588 605 } 589 606 … … 1049 1066 /* Translate MAC address policy combo-box: */ 1050 1067 m_pMACComboBoxLabel->setText(UIWizardExportApp::tr("MAC Address &Policy:")); 1051 m_pMACComboBox->setItemText(MACAddressExportPolicy_KeepAllMACs, 1052 UIWizardExportApp::tr("Include all network adapter MAC addresses")); 1053 m_pMACComboBox->setItemText(MACAddressExportPolicy_StripAllNonNATMACs, 1054 UIWizardExportApp::tr("Include only NAT network adapter MAC addresses")); 1055 m_pMACComboBox->setItemText(MACAddressExportPolicy_StripAllMACs, 1056 UIWizardExportApp::tr("Strip all network adapter MAC addresses")); 1057 m_pMACComboBox->setItemData(MACAddressExportPolicy_KeepAllMACs, 1058 UIWizardExportApp::tr("Include all network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 1059 m_pMACComboBox->setItemData(MACAddressExportPolicy_StripAllNonNATMACs, 1060 UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 1061 m_pMACComboBox->setItemData(MACAddressExportPolicy_StripAllMACs, 1062 UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported appliance archive."), Qt::ToolTipRole); 1068 for (int i = 0; i < m_pMACComboBox->count(); ++i) 1069 { 1070 const MACAddressExportPolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressExportPolicy>(); 1071 switch (enmPolicy) 1072 { 1073 case MACAddressExportPolicy_KeepAllMACs: 1074 { 1075 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include all network adapter MAC addresses")); 1076 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include all network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 1077 break; 1078 } 1079 case MACAddressExportPolicy_StripAllNonNATMACs: 1080 { 1081 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses")); 1082 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 1083 break; 1084 } 1085 case MACAddressExportPolicy_StripAllMACs: 1086 { 1087 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses")); 1088 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported appliance archive."), Qt::ToolTipRole); 1089 break; 1090 } 1091 default: 1092 break; 1093 } 1094 } 1063 1095 1064 1096 /* Translate addtional stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp
r82386 r82392 516 516 /* Translate MAC address policy combo-box: */ 517 517 m_pMACComboBoxLabel->setText(UIWizardExportApp::tr("MAC Address &Policy:")); 518 m_pMACComboBox->setItemText(MACAddressExportPolicy_KeepAllMACs, 519 UIWizardExportApp::tr("Include all network adapter MAC addresses")); 520 m_pMACComboBox->setItemText(MACAddressExportPolicy_StripAllNonNATMACs, 521 UIWizardExportApp::tr("Include only NAT network adapter MAC addresses")); 522 m_pMACComboBox->setItemText(MACAddressExportPolicy_StripAllMACs, 523 UIWizardExportApp::tr("Strip all network adapter MAC addresses")); 524 m_pMACComboBox->setItemData(MACAddressExportPolicy_KeepAllMACs, 525 UIWizardExportApp::tr("Include all network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 526 m_pMACComboBox->setItemData(MACAddressExportPolicy_StripAllNonNATMACs, 527 UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 528 m_pMACComboBox->setItemData(MACAddressExportPolicy_StripAllMACs, 529 UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported appliance archive."), Qt::ToolTipRole); 518 for (int i = 0; i < m_pMACComboBox->count(); ++i) 519 { 520 const MACAddressExportPolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressExportPolicy>(); 521 switch (enmPolicy) 522 { 523 case MACAddressExportPolicy_KeepAllMACs: 524 { 525 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include all network adapter MAC addresses")); 526 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include all network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 527 break; 528 } 529 case MACAddressExportPolicy_StripAllNonNATMACs: 530 { 531 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses")); 532 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported appliance archive."), Qt::ToolTipRole); 533 break; 534 } 535 case MACAddressExportPolicy_StripAllMACs: 536 { 537 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses")); 538 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported appliance archive."), Qt::ToolTipRole); 539 break; 540 } 541 default: 542 break; 543 } 544 } 530 545 531 546 /* Translate addtional stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.