Changeset 101294 in vbox
- Timestamp:
- Sep 27, 2023 2:48:22 PM (12 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
-
globals/UIGuestOSType.cpp (modified) (7 diffs)
-
globals/UIGuestOSType.h (modified) (4 diffs)
-
settings/editors/UINameAndSystemEditor.cpp (modified) (3 diffs)
-
settings/editors/UINameAndSystemEditor.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.cpp
r101278 r101294 30 30 31 31 32 /** A wrapper around CGuestOSType. Some of the properties are cached here for performance. */ 33 class SHARED_LIBRARY_STUFF UIGuestOSType 34 { 35 36 public: 37 38 39 UIGuestOSType(const CGuestOSType &comGuestOSType); 40 UIGuestOSType(); 41 42 const QString &getFamilyId() const; 43 const QString &getFamilyDescription() const; 44 const QString &getId() const; 45 const QString &getVariant() const; 46 const QString &getDescription() const; 47 48 /** @name Wrapper getters for CGuestOSType member. 49 * @{ */ 50 KStorageBus getRecommendedHDStorageBus() const; 51 ULONG getRecommendedRAM() const; 52 KStorageBus getRecommendedDVDStorageBus() const; 53 ULONG getRecommendedCPUCount() const; 54 KFirmwareType getRecommendedFirmware() const; 55 bool getRecommendedFloppy() const; 56 LONG64 getRecommendedHDD() const; 57 KGraphicsControllerType getRecommendedGraphicsController() const; 58 /** @} */ 59 60 bool isOk() const; 61 62 private: 63 64 /** @name CGuestOSType properties. Cached here for a faster access. 65 * @{ */ 66 mutable QString m_strFamilyId; 67 mutable QString m_strFamilyDescription; 68 mutable QString m_strId; 69 mutable QString m_strVariant; 70 mutable QString m_strDescription; 71 /** @} */ 72 73 CGuestOSType m_comGuestOSType; 74 }; 75 76 UIGuestOSTypeManager::UIGuestOSTypeManager() 77 :m_guestOSTypes(new QList<UIGuestOSType>()) 78 { 79 } 80 32 81 void UIGuestOSTypeManager::reCacheGuestOSTypes(const CGuestOSTypeVector &guestOSTypes) 33 82 { 34 m_guestOSTypes.clear(); 83 m_typeIdIndexMap.clear(); 84 m_guestOSTypes->clear(); 35 85 m_guestOSFamilies.clear(); 36 //m_guestOSTypesPerFamily.clear(); 86 37 87 QVector<CGuestOSType> otherOSTypes; 38 88 foreach (const CGuestOSType &comType, guestOSTypes) … … 52 102 void UIGuestOSTypeManager::addGuestOSType(const CGuestOSType &comType) 53 103 { 54 m_guestOSTypes << UIGuestOSType(comType); 55 QPair<QString, QString> family = QPair<QString, QString>(m_guestOSTypes.last().getFamilyId(), m_guestOSTypes.last().getFamilyDescription()); 104 m_guestOSTypes->append(UIGuestOSType(comType)); 105 m_typeIdIndexMap[m_guestOSTypes->last().getId()] = m_guestOSTypes->size() - 1; 106 QPair<QString, QString> family = QPair<QString, QString>(m_guestOSTypes->last().getFamilyId(), m_guestOSTypes->last().getFamilyDescription()); 56 107 if (!m_guestOSFamilies.contains(family)) 57 108 m_guestOSFamilies << family; … … 65 116 QStringList UIGuestOSTypeManager::getVariantListForFamilyId(const QString &strFamilyId) const 66 117 { 118 AssertReturn(m_guestOSTypes, QStringList()); 67 119 QStringList variantList; 68 foreach (const UIGuestOSType &type, m_guestOSTypes)120 foreach (const UIGuestOSType &type, *m_guestOSTypes) 69 121 { 70 122 if (type.getFamilyId() != strFamilyId) … … 80 132 { 81 133 UIGuestOSTypeInfo typeInfoList; 82 foreach (const UIGuestOSType &type, m_guestOSTypes) 134 AssertReturn(m_guestOSTypes, typeInfoList); 135 foreach (const UIGuestOSType &type, *m_guestOSTypes) 83 136 { 84 137 if (type.getFamilyId() != strFamilyId) … … 95 148 { 96 149 UIGuestOSTypeInfo typeInfoList; 150 AssertReturn(m_guestOSTypes, typeInfoList); 97 151 if (strVariant.isEmpty()) 98 152 return typeInfoList; 99 153 100 foreach (const UIGuestOSType &type, m_guestOSTypes)154 foreach (const UIGuestOSType &type, *m_guestOSTypes) 101 155 { 102 156 if (type.getVariant() != strVariant) … … 109 163 } 110 164 111 UIGuestOSType UIGuestOSTypeManager::findGuestTypeById(const QString &strTypeId) const 112 { 113 if (strTypeId.isEmpty()) 114 return UIGuestOSType(); 115 foreach (const UIGuestOSType &type, m_guestOSTypes) 116 { 117 if (type.getId() == strTypeId) 118 return type; 119 } 120 return UIGuestOSType(); 165 QString UIGuestOSTypeManager::getFamilyId(const QString &strTypeId) const 166 { 167 AssertReturn(m_guestOSTypes, QString()); 168 /* Let QVector<>::value check for the bounds. It returns a default constructed value when it is out of bounds. */ 169 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getFamilyId(); 170 } 171 172 QString UIGuestOSTypeManager::getVariant(const QString &strTypeId) const 173 { 174 AssertReturn(m_guestOSTypes, QString()); 175 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getVariant(); 121 176 } 122 177 123 178 KGraphicsControllerType UIGuestOSTypeManager::getRecommendedGraphicsController(const QString &strTypeId) const 124 179 { 125 if (strTypeId.isEmpty()) 126 return KGraphicsControllerType_Null; 127 foreach (const UIGuestOSType &type, m_guestOSTypes) 128 { 129 if (type.getId() == strTypeId) 130 return type.getRecommendedGraphicsController(); 131 } 132 return KGraphicsControllerType_Null; 180 AssertReturn(m_guestOSTypes, KGraphicsControllerType_Null); 181 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedGraphicsController(); 133 182 } 134 183 135 184 ULONG UIGuestOSTypeManager::getRecommendedRAM(const QString &strTypeId) const 136 185 { 137 if (strTypeId.isEmpty()) 138 return 0; 139 foreach (const UIGuestOSType &type, m_guestOSTypes) 140 { 141 if (type.getId() == strTypeId) 142 return type.getRecommendedRAM(); 143 } 144 return 0; 186 AssertReturn(m_guestOSTypes, 0); 187 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedRAM(); 145 188 } 146 189 147 190 ULONG UIGuestOSTypeManager::getRecommendedCPUCount(const QString &strTypeId) const 148 191 { 149 if (strTypeId.isEmpty()) 150 return 0; 151 foreach (const UIGuestOSType &type, m_guestOSTypes) 152 { 153 if (type.getId() == strTypeId) 154 return type.getRecommendedCPUCount(); 155 } 156 return 0; 192 AssertReturn(m_guestOSTypes, 0); 193 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedCPUCount(); 157 194 } 158 195 159 196 KFirmwareType UIGuestOSTypeManager::getRecommendedFirmware(const QString &strTypeId) const 160 197 { 161 if (strTypeId.isEmpty()) 162 return KFirmwareType_Max; 163 foreach (const UIGuestOSType &type, m_guestOSTypes) 164 { 165 if (type.getId() == strTypeId) 166 return type.getRecommendedFirmware(); 167 } 168 return KFirmwareType_Max; 198 AssertReturn(m_guestOSTypes, KFirmwareType_Max); 199 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedFirmware(); 169 200 } 170 201 171 202 QString UIGuestOSTypeManager::getDescription(const QString &strTypeId) const 172 203 { 173 if (strTypeId.isEmpty()) 174 return QString(); 175 foreach (const UIGuestOSType &type, m_guestOSTypes) 176 { 177 if (type.getId() == strTypeId) 178 return type.getDescription(); 179 } 180 return QString(); 204 AssertReturn(m_guestOSTypes, QString()); 205 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getDescription(); 181 206 } 182 207 183 208 LONG64 UIGuestOSTypeManager::getRecommendedHDD(const QString &strTypeId) const 184 209 { 185 if (strTypeId.isEmpty()) 186 return 0; 187 foreach (const UIGuestOSType &type, m_guestOSTypes) 188 { 189 if (type.getId() == strTypeId) 190 return type.getRecommendedHDD(); 191 } 192 return 0; 210 AssertReturn(m_guestOSTypes, 0); 211 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedHDD(); 193 212 } 194 213 195 214 KStorageBus UIGuestOSTypeManager::getRecommendedHDStorageBus(const QString &strTypeId) const 196 215 { 197 if (strTypeId.isEmpty()) 198 return KStorageBus_Null; 199 foreach (const UIGuestOSType &type, m_guestOSTypes) 200 { 201 if (type.getId() == strTypeId) 202 return type.getRecommendedHDStorageBus(); 203 } 204 return KStorageBus_Null; 216 AssertReturn(m_guestOSTypes, KStorageBus_Null); 217 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedHDStorageBus(); 205 218 } 206 219 207 220 KStorageBus UIGuestOSTypeManager::getRecommendedDVDStorageBus(const QString &strTypeId) const 208 221 { 209 if (strTypeId.isEmpty()) 210 return KStorageBus_Null; 211 foreach (const UIGuestOSType &type, m_guestOSTypes) 212 { 213 if (type.getId() == strTypeId) 214 return type.getRecommendedDVDStorageBus(); 215 } 216 return KStorageBus_Null; 217 } 218 222 AssertReturn(m_guestOSTypes, KStorageBus_Null); 223 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedDVDStorageBus(); 224 } 219 225 220 226 bool UIGuestOSTypeManager::getRecommendedFloppy(const QString &strTypeId) const 221 227 { 222 if (strTypeId.isEmpty()) 223 return false; 224 foreach (const UIGuestOSType &type, m_guestOSTypes) 225 { 226 if (type.getId() == strTypeId) 227 return type.getRecommendedFloppy(); 228 } 229 return false; 228 AssertReturn(m_guestOSTypes, false); 229 return m_guestOSTypes->value(m_typeIdIndexMap.value(strTypeId, -1)).getRecommendedFloppy(); 230 230 } 231 231 … … 334 334 return KGraphicsControllerType_Null; 335 335 } 336 337 bool UIGuestOSType::operator==(const UIGuestOSType &other)338 {339 return m_comGuestOSType == other.m_comGuestOSType;340 }341 342 bool UIGuestOSType::operator!=(const UIGuestOSType &other)343 {344 return m_comGuestOSType != other.m_comGuestOSType;345 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.h
r101285 r101294 42 42 43 43 class UIGuestOSType; 44 44 class UIFoo; 45 45 46 46 /** A wrapper and manager class for Guest OS types (IGuestOSType). Logically we structure os types into families … … 52 52 53 53 public: 54 55 UIGuestOSTypeManager(); 56 UIGuestOSTypeManager(const UIGuestOSTypeManager &other) = delete; 54 57 55 58 /* A list of all OS families. 'first' of each pair is famil Id and 'second' is family description. */ … … 65 68 UIGuestOSTypeInfo getTypeListForVariant(const QString &strVariant) const; 66 69 67 UIGuestOSType findGuestTypeById(const QString &strTypeId) const; 68 69 KGraphicsControllerType getRecommendedGraphicsController(const QString &strTypeId) const; 70 ULONG getRecommendedRAM(const QString &strTypeId) const; 71 ULONG getRecommendedCPUCount(const QString &strTypeId) const; 72 KFirmwareType getRecommendedFirmware(const QString &strTypeId) const; 73 QString getDescription(const QString &strTypeId) const; 74 LONG64 getRecommendedHDD(const QString &strTypeId) const; 75 KStorageBus getRecommendedHDStorageBus(const QString &strTypeId) const; 76 KStorageBus getRecommendedDVDStorageBus(const QString &strTypeId) const; 77 bool getRecommendedFloppy(const QString &strTypeId) const; 70 /** @name Getters UIGuestOSType properties. They utilize a map for faster access to UIGuestOSType instance with @p strTypeId 71 * @{ */ 72 QString getFamilyId(const QString &strTypeId) const; 73 QString getVariant(const QString &strTypeId) const; 74 KGraphicsControllerType getRecommendedGraphicsController(const QString &strTypeId) const; 75 ULONG getRecommendedRAM(const QString &strTypeId) const; 76 ULONG getRecommendedCPUCount(const QString &strTypeId) const; 77 KFirmwareType getRecommendedFirmware(const QString &strTypeId) const; 78 QString getDescription(const QString &strTypeId) const; 79 LONG64 getRecommendedHDD(const QString &strTypeId) const; 80 KStorageBus getRecommendedHDStorageBus(const QString &strTypeId) const; 81 KStorageBus getRecommendedDVDStorageBus(const QString &strTypeId) const; 82 bool getRecommendedFloppy(const QString &strTypeId) const; 83 /** @} */ 78 84 79 85 private: … … 81 87 void addGuestOSType(const CGuestOSType &comType); 82 88 83 QVector<UIGuestOSType> m_guestOSTypes; 84 /* First item of the pair is family id and the 2nd is family description. */ 89 /** The type list. Here it is a pointer to QVector to delay definition of UIGuestOSType. */ 90 QVector<UIGuestOSType> *m_guestOSTypes; 91 /** A map to prevent linear search of UIGuestOSType instances wrt. typeId. Key is typeId and value 92 * is index to m_guestOSTypes list. */ 93 QMap<QString, int> m_typeIdIndexMap; 94 /** First item of the pair is family id and the 2nd is family description. */ 85 95 UIGuestOSTypeInfo m_guestOSFamilies; 86 87 96 }; 88 97 89 /** A wrapper around CGuestOSType. */90 class SHARED_LIBRARY_STUFF UIGuestOSType91 {92 93 public:94 95 96 UIGuestOSType(const CGuestOSType &comGuestOSType);97 UIGuestOSType();98 99 const QString &getFamilyId() const;100 const QString &getFamilyDescription() const;101 const QString &getId() const;102 const QString &getVariant() const;103 const QString &getDescription() const;104 105 /** @name Wrapper getters for CGuestOSType member.106 * @{ */107 KStorageBus getRecommendedHDStorageBus() const;108 ULONG getRecommendedRAM() const;109 KStorageBus getRecommendedDVDStorageBus() const;110 ULONG getRecommendedCPUCount() const;111 KFirmwareType getRecommendedFirmware() const;112 bool getRecommendedFloppy() const;113 LONG64 getRecommendedHDD() const;114 KGraphicsControllerType getRecommendedGraphicsController() const;115 /** @} */116 117 bool isOk() const;118 bool operator==(const UIGuestOSType &other);119 bool operator!=(const UIGuestOSType &other);120 121 private:122 123 /** @name CGuestOSType properties. Cached here for a faster access.124 * @{ */125 mutable QString m_strFamilyId;126 mutable QString m_strFamilyDescription;127 mutable QString m_strId;128 mutable QString m_strVariant;129 mutable QString m_strDescription;130 /** @} */131 132 CGuestOSType m_comGuestOSType;133 134 };135 98 136 99 #endif /* !FEQT_INCLUDED_SRC_globals_UIGuestOSType_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp
r101286 r101294 166 166 const UIGuestOSTypeManager * const pGuestOSTypeManager = uiCommon().guestOSTypeManager(); 167 167 AssertReturn(pGuestOSTypeManager, false); 168 const UIGuestOSType &type = pGuestOSTypeManager->findGuestTypeById(strTypeId);169 if (!type.isOk())170 return false;168 // const UIGuestOSType &type = pGuestOSTypeManager->findGuestTypeById(strTypeId); 169 // if (!type.isOk()) 170 // return false; 171 171 172 172 int iFamilyComboIndex = -1; … … 175 175 { 176 176 QString strComboFamilyId = m_pComboFamily->itemData(i, FamilyID).toString(); 177 if (!strComboFamilyId.isEmpty() && strComboFamilyId == type.getFamilyId())177 if (!strComboFamilyId.isEmpty() && strComboFamilyId == pGuestOSTypeManager->getFamilyId(strTypeId)) 178 178 iFamilyComboIndex = i; 179 179 } … … 185 185 186 186 /* If variant is not empty then try to select correct index. This will populate type combo: */ 187 if (!type.getVariant().isEmpty()) 187 QString strVariant = pGuestOSTypeManager->getVariant(strTypeId); 188 if (!strVariant.isEmpty()) 188 189 { 189 190 int index = -1; 190 191 for (int i = 0; i < m_pComboVariant->count() && index == -1; ++i) 191 192 { 192 if ( type.getVariant()== m_pComboVariant->itemText(i))193 if (strVariant == m_pComboVariant->itemText(i)) 193 194 index = i; 194 195 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h
r101286 r101294 119 119 /** Returns the VM OS family ID. */ 120 120 QString familyId() const; 121 122 /** Returns the VM OS type. */123 //UIGuestOSTypeII type() const;124 121 125 122 /** Passes the @p fError to QILineEdit::mark(bool) effectively marking it for error. */
Note:
See TracChangeset
for help on using the changeset viewer.

