Changeset 103905 in vbox
- Timestamp:
- Mar 18, 2024 6:22:07 PM (13 months ago)
- svn:sync-xref-src-repo-rev:
- 162278
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp
r103904 r103905 183 183 bool UINameAndSystemEditor::setGuestOSTypeByTypeId(const QString &strTypeId) 184 184 { 185 /* Sanity check: */ 185 /* Cache passed values locally, they will be required for the final result check: */ 186 const QString strFamilyId = gpGlobalSession->guestOSTypeManager().getFamilyId(strTypeId); 187 const QString strDistribution = gpGlobalSession->guestOSTypeManager().getSubtype(strTypeId); 188 189 /* Save passed values, but they can be overridden 190 * in the below populateFamilyCombo() call: */ 191 m_strFamilyId = strFamilyId; 192 if (!strDistribution.isEmpty()) 193 m_familyToDistribution[familyId()] = strDistribution; 194 if (distribution().isEmpty()) 195 m_familyToType[familyId()] = strTypeId; 196 else 197 m_distributionToType[distribution()] = strTypeId; 198 199 /* Repopulate VM OS family/distribution/type combo(s): */ 200 populateFamilyCombo(); 201 202 /* Family check: */ 186 203 AssertPtrReturn(m_pComboFamily, false); 187 188 int iFamilyComboIndex = -1; 189 /* We already have to have an item in the family combo box for this family id: */ 190 for (int i = 0; i < m_pComboFamily->count() && iFamilyComboIndex == -1; ++i) 191 { 192 QString strComboFamilyId = m_pComboFamily->itemData(i).toString(); 193 if (!strComboFamilyId.isEmpty() && strComboFamilyId == gpGlobalSession->guestOSTypeManager().getFamilyId(strTypeId)) 194 iFamilyComboIndex = i; 195 } 196 /* Bail out if family combo has no such item: */ 197 if (iFamilyComboIndex == -1) 204 if (m_pComboFamily->currentData().toString() != strFamilyId) 198 205 return false; 199 /* Set the family combo's index. This will cause distribution combo to be populated accordingly: */ 200 m_pComboFamily->setCurrentIndex(iFamilyComboIndex); 201 202 /* If distribution is not empty then try to select correct index. This will populate type combo: */ 203 QString strDistribution = gpGlobalSession->guestOSTypeManager().getSubtype(strTypeId); 204 if (!strDistribution.isEmpty()) 205 { 206 int index = -1; 207 for (int i = 0; i < m_pComboDistribution->count() && index == -1; ++i) 208 { 209 if (strDistribution == m_pComboDistribution->itemText(i)) 210 index = i; 211 } 212 if (index != -1) 213 m_pComboDistribution->setCurrentIndex(index); 214 else 215 return false; 216 } 217 218 /* At this point type combo should include the type we want to select: */ 219 int iTypeIndex = -1; 220 for (int i = 0; i < m_pComboType->count() && iTypeIndex == -1; ++i) 221 { 222 if (strTypeId == m_pComboType->itemData(i)) 223 iTypeIndex = i; 224 } 225 if (iTypeIndex != -1) 226 m_pComboType->setCurrentIndex(iTypeIndex); 206 /* Distribution check: */ 207 AssertPtrReturn(m_pComboDistribution, false); 208 if (m_pComboDistribution->currentText() != strDistribution) 209 return false; 210 /* Type check: */ 211 AssertPtrReturn(m_pComboType, false); 212 if (m_pComboType->currentData().toString() != strTypeId) 213 return false; 214 215 /* Success by default: */ 227 216 return true; 228 217 } … … 368 357 const UIGuestOSTypeManager::UIGuestOSTypeInfo types 369 358 = strDistribution.isEmpty() 370 ? gpGlobalSession->guestOSTypeManager().getTypesForFamilyId(familyId(), false /* including restricted? */, enmArch) 371 : gpGlobalSession->guestOSTypeManager().getTypesForSubtype(distribution(), false /* including restricted? */, enmArch); 359 ? gpGlobalSession->guestOSTypeManager().getTypesForFamilyId(familyId(), 360 false /* including restricted? */, 361 enmArch) 362 : gpGlobalSession->guestOSTypeManager().getTypesForSubtype(distribution(), 363 false /* including restricted? */, 364 enmArch); 372 365 373 366 /* Populate type combo: */ … … 649 642 /* Acquire family IDs: */ 650 643 const UIGuestOSTypeManager::UIGuestOSFamilyInfo families 651 = gpGlobalSession->guestOSTypeManager().getFamilies(false /* including restricted? */, enmArch); 644 = gpGlobalSession->guestOSTypeManager().getFamilies(false /* including restricted? */, 645 enmArch); 652 646 653 647 /* Block signals initially and clear the combo: */ … … 685 679 /* Acquire a list of suitable distributions: */ 686 680 const UIGuestOSTypeManager::UIGuestOSSubtypeInfo distributions 687 = gpGlobalSession->guestOSTypeManager().getSubtypesForFamilyId(familyId(), false /* including restricted? */, enmArch); 681 = gpGlobalSession->guestOSTypeManager().getSubtypesForFamilyId(familyId(), 682 false /* including restricted? */, 683 enmArch); 688 684 m_pLabelDistribution->setEnabled(!distributions.isEmpty()); 689 685 m_pComboDistribution->setEnabled(!distributions.isEmpty());
Note:
See TracChangeset
for help on using the changeset viewer.