Changeset 82563 in vbox
- Timestamp:
- Dec 12, 2019 8:36:15 AM (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/UINetworkAttachmentEditor.cpp
r81422 r82563 29 29 30 30 /* COM includes: */ 31 #ifdef VBOX_WITH_CLOUD_NET 32 # include "CCloudNetwork.h" 33 #endif 31 34 #include "CHostNetworkInterface.h" 32 35 #include "CNATNetwork.h" 33 #ifdef VBOX_WITH_CLOUD_NET 34 #include "CCloudNetwork.h" 35 #endif /* VBOX_WITH_CLOUD_NET */ 36 #include "CSystemProperties.h" 36 37 37 38 … … 43 44 , m_fWithLabels(fWithLabels) 44 45 , m_enmRestrictedNetworkAttachmentTypes(UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid) 46 , m_enmType(KNetworkAttachmentType_Max) 45 47 , m_pLabelType(0) 46 48 , m_pComboType(0) … … 66 68 if (!m_pComboType) 67 69 return; 68 69 /* Search for an item with required data value, choose item to be current if found: */ 70 const int iIndex = m_pComboType->findData(QVariant::fromValue(enmType)); 71 if (iIndex != -1) 72 m_pComboType->setCurrentIndex(iIndex); 70 /* Make sure type is changed: */ 71 if (m_enmType == enmType) 72 return; 73 74 /* Remember requested type: */ 75 m_enmType = enmType; 76 /* Repopulate finally, supported values might change: */ 77 populateTypeCombo(); 73 78 } 74 79 75 80 KNetworkAttachmentType UINetworkAttachmentEditor::valueType() const 76 81 { 77 /* Make sure combo is there: */ 78 if (!m_pComboType) 79 return KNetworkAttachmentType_Null; 80 81 /* Return current item data: */ 82 return m_pComboType->currentData().value<KNetworkAttachmentType>(); 82 return m_pComboType ? m_pComboType->currentData().value<KNetworkAttachmentType>() : m_enmType; 83 83 } 84 84 … … 190 190 { 191 191 const KNetworkAttachmentType enmType = m_pComboType->itemData(i).value<KNetworkAttachmentType>(); 192 m_pComboType->setItemText(i, gpConverter->toString(enmType)); 192 const QString strName = gpConverter->toString(enmType); 193 m_pComboType->setItemData(i, strName, Qt::ToolTipRole); 194 m_pComboType->setItemText(i, strName); 193 195 } 194 196 } … … 338 340 m_pComboType->blockSignals(true); 339 341 340 /* Remember currently selected type index: */341 int iCurrentAttachment = m_pComboType->currentIndex();342 343 342 /* Clear the type combo-box: */ 344 343 m_pComboType->clear(); 345 344 346 /* Populate attachments: */ 345 /* Load currently supported network attachment types (system-properties getter): */ 346 CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 347 QVector<KNetworkAttachmentType> supportedTypes = comProperties.GetSupportedNetworkAttachmentTypes(); 348 /* Take currently requested type into account if it's sane: */ 349 if (!supportedTypes.contains(m_enmType) && m_enmType != KNetworkAttachmentType_Max) 350 supportedTypes.prepend(m_enmType); 351 352 /* Populate attachment types: */ 347 353 int iAttachmentTypeIndex = 0; 348 // WORKAROUND: 349 // We want some hardcoded order, so prepare a list of enum values. 350 QList<KNetworkAttachmentType> attachmentTypes = QList<KNetworkAttachmentType>() << KNetworkAttachmentType_Null 351 << KNetworkAttachmentType_NAT << KNetworkAttachmentType_NATNetwork 352 << KNetworkAttachmentType_Bridged << KNetworkAttachmentType_Internal 353 << KNetworkAttachmentType_HostOnly << KNetworkAttachmentType_Generic; 354 #ifdef VBOX_WITH_CLOUD_NET 355 attachmentTypes.append(KNetworkAttachmentType_Cloud); 356 #endif /* VBOX_WITH_CLOUD_NET */ 357 for (int i = 0; i < attachmentTypes.size(); ++i) 358 { 359 const KNetworkAttachmentType enmType = attachmentTypes.at(i); 354 foreach (const KNetworkAttachmentType &enmType, supportedTypes) 355 { 356 /* Filter currently restricted network attachment types (extra-data getter): */ 360 357 if (m_enmRestrictedNetworkAttachmentTypes & toUiNetworkAdapterEnum(enmType)) 361 358 continue; … … 366 363 } 367 364 368 /* Restore previously selected type index: */ 369 m_pComboType->setCurrentIndex(iCurrentAttachment == -1 ? 0 : iCurrentAttachment); 365 /* Restore previously selected type if possible: */ 366 const int iIndex = m_pComboType->findData(m_enmType); 367 m_pComboType->setCurrentIndex(iIndex != -1 ? iIndex : 0); 370 368 371 369 /* Handle combo item change: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINetworkAttachmentEditor.h
r81422 r82563 134 134 QMap<KNetworkAttachmentType, QString> m_name; 135 135 136 /** Holds the requested type. */ 137 KNetworkAttachmentType m_enmType; 138 136 139 /** Holds the type label instance. */ 137 140 QLabel *m_pLabelType;
Note:
See TracChangeset
for help on using the changeset viewer.