Changeset 101183 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 20, 2023 7:25:00 AM (15 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r101157 r101183 1405 1405 src/globals/UIErrorString.cpp \ 1406 1406 src/globals/UIExtension.cpp \ 1407 src/globals/UIGuestOSTypeII.cpp \ 1407 1408 src/globals/UIIconPool.cpp \ 1408 1409 src/globals/UIImageTools.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r101035 r101183 63 63 #include "UIConverter.h" 64 64 #include "UIDesktopWidgetWatchdog.h" 65 #include "UIGuestOSTypeII.h" 65 66 #include "UIExtraDataDefs.h" 66 67 #include "UIExtraDataManager.h" … … 214 215 , m_fWrappersValid(false) 215 216 , m_fVBoxSVCAvailable(true) 217 , m_pGuestOSTypeManager(new UIGuestOSTypeManager) 216 218 , m_pThreadPool(0) 217 219 , m_pThreadPoolCloud(0) … … 224 226 UICommon::~UICommon() 225 227 { 228 delete m_pGuestOSTypeManager; 226 229 /* Unassign instance: */ 227 230 s_pInstance = 0; … … 3014 3017 { 3015 3018 const CGuestOSType os = guestOSTypes.at(i); 3019 //printf("%s -- %s -- %s\n", qPrintable(os.GetId()), qPrintable(os.GetVariant()), qPrintable(os.GetDescription())); 3016 3020 const QString strFamilyID = os.GetFamilyId(); 3017 3021 const QString strFamilyDescription = os.GetFamilyDescription(); … … 3026 3030 } 3027 3031 } 3028 3032 if (m_pGuestOSTypeManager) 3033 m_pGuestOSTypeManager->reCacheGuestOSTypes(guestOSTypes); 3029 3034 /* Mark wrappers valid: */ 3030 3035 m_fWrappersValid = true; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r100064 r101183 67 67 class CUSBDevice; 68 68 class UIActionPool; 69 class UIGuestOSTypeManager; 69 70 class UIMedium; 70 71 class UIMediumEnumerator; … … 751 752 /** Holds the guest OS types for each family ID. */ 752 753 QList<QList<CGuestOSType> > m_guestOSTypes; 754 UIGuestOSTypeManager *m_pGuestOSTypeManager; 753 755 /** @} */ 754 756 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSTypeII.cpp
r101147 r101183 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI Versionclass implementation.3 * VBox Qt GUI - UIGuestOSTypeII class implementation. 4 4 */ 5 5 … … 26 26 */ 27 27 28 /* Qt includes: */29 #include <QStringList>30 31 28 /* GUI includes: */ 32 #include "UIVersion.h" 33 34 /* Other VBox includes: */ 35 #include <iprt/string.h> 29 #include "UIGuestOSTypeII.h" 36 30 37 31 38 UIVersion::UIVersion() 39 : m_x(-1) 40 , m_y(-1) 41 , m_z(-1) 32 void UIGuestOSTypeManager::reCacheGuestOSTypes(const CGuestOSTypeVector &guestOSTypes) 33 { 34 m_guestOSTypes.clear(); 35 m_guestOSFamilyIds.clear(); 36 m_guestOSTypesPerFamily.clear(); 37 QList<CGuestOSType> otherOSTypes; 38 foreach (const CGuestOSType &comType, guestOSTypes) 39 { 40 if (comType.GetFamilyId().contains("other", Qt::CaseInsensitive)) 41 { 42 otherOSTypes << comType; 43 continue; 44 } 45 addGuestOSType(comType); 46 } 47 /* Add OS types with family other to the end of the lists: */ 48 foreach (const CGuestOSType &comType, otherOSTypes) 49 addGuestOSType(comType); 50 51 for (int i = 0; i < m_guestOSTypes.size(); ++i) 52 { 53 QList<int> &indexList = m_guestOSTypesPerFamily[m_guestOSTypes[i].getFamilyId()]; 54 indexList << i; 55 } 56 57 // foreach (const QString &strFamilyId, m_guestOSFamilyIds) 58 // { 59 // printf(" ----family---%s\n", qPrintable(strFamilyId)); 60 // const QList<int> &indices = m_guestOSTypesPerFamily[strFamilyId]; 61 // if (!m_guestOSTypesPerFamily.contains(strFamilyId)) 62 // { 63 // printf("\t-----empty\n"); 64 // continue; 65 // } 66 // for (int i = 0; i < indices.size(); ++i) 67 // { 68 // if (indices[i] >= 0 && indices[i] < m_guestOSTypes.size()) 69 // { 70 // //printf("\t%s %s\n", qPrintable(m_guestOSTypes[indices[i]].getDescription()), qPrintable(m_guestOSTypes[indices[i]].getVariant())); 71 // } 72 // } 73 // } 74 } 75 76 void UIGuestOSTypeManager::addGuestOSType(const CGuestOSType &comType) 77 { 78 m_guestOSTypes << UIGuestOSTypeII(comType); 79 const QString &strFamilyId = m_guestOSTypes.last().getFamilyId(); 80 if (!m_guestOSFamilyIds.contains(strFamilyId)) 81 m_guestOSFamilyIds << strFamilyId; 82 } 83 84 UIGuestOSTypeII::UIGuestOSTypeII(const CGuestOSType &comGuestOSType) 85 : m_comGuestOSType(comGuestOSType) 42 86 { 43 87 } 44 88 45 UIVersion::UIVersion(const QString &strFullVersionInfo) 46 : m_x(-1) 47 , m_y(-1) 48 , m_z(-1) 89 const QString &UIGuestOSTypeII::getFamilyId() 49 90 { 50 const QStringList fullVersionInfo = strFullVersionInfo.split('_'); 51 if (fullVersionInfo.size() > 0) 52 { 53 const QStringList versionIndexes = fullVersionInfo.at(0).split('.'); 54 if (versionIndexes.size() > 0) 55 m_x = versionIndexes[0].toInt(); 56 if (versionIndexes.size() > 1) 57 m_y = versionIndexes[1].toInt(); 58 if (versionIndexes.size() > 2) 59 m_z = versionIndexes[2].toInt(); 60 } 61 if (fullVersionInfo.size() > 1) 62 m_strPostfix = fullVersionInfo.at(1); 91 if (m_strFamilyId.isEmpty() && m_comGuestOSType.isOk()) 92 m_strFamilyId = m_comGuestOSType.GetFamilyId(); 93 return m_strFamilyId; 63 94 } 64 95 65 bool UIVersion::isValid() const 96 const QString &UIGuestOSTypeII::getFamilyDescription() 66 97 { 67 return (m_x != -1)68 && (m_y != -1)69 && (m_z != -1);98 if (m_strFamilyDescription.isEmpty() && m_comGuestOSType.isOk()) 99 m_strFamilyDescription = m_comGuestOSType.GetFamilyDescription(); 100 return m_strFamilyDescription; 70 101 } 71 102 72 bool UIVersion::equal(const UIVersion &other) const 103 const QString &UIGuestOSTypeII::getId() 73 104 { 74 return (m_x == other.m_x) 75 && (m_y == other.m_y) 76 && (m_z == other.m_z) 77 && (m_strPostfix == other.m_strPostfix); 105 if (m_strId.isEmpty() && m_comGuestOSType.isOk()) 106 m_strId = m_comGuestOSType.GetId(); 107 return m_strId; 78 108 } 79 109 80 bool UIVersion::operator<(const UIVersion &other) const 110 const QString &UIGuestOSTypeII::getVariant() 81 111 { 82 return RTStrVersionCompare(toString().toUtf8().constData(), other.toString().toUtf8().constData()) < 0; 112 if (m_strVariant.isEmpty() && m_comGuestOSType.isOk()) 113 m_strVariant = m_comGuestOSType.GetVariant(); 114 return m_strVariant; 83 115 } 84 116 85 bool UIVersion::operator<=(const UIVersion &other) const 117 const QString &UIGuestOSTypeII::getDescription() 86 118 { 87 return RTStrVersionCompare(toString().toUtf8().constData(), other.toString().toUtf8().constData()) <= 0; 119 if (m_strDescription.isEmpty() && m_comGuestOSType.isOk()) 120 m_strDescription = m_comGuestOSType.GetDescription(); 121 return m_strDescription; 88 122 } 89 90 bool UIVersion::operator>(const UIVersion &other) const91 {92 return RTStrVersionCompare(toString().toUtf8().constData(), other.toString().toUtf8().constData()) > 0;93 }94 95 bool UIVersion::operator>=(const UIVersion &other) const96 {97 return RTStrVersionCompare(toString().toUtf8().constData(), other.toString().toUtf8().constData()) >= 0;98 }99 100 QString UIVersion::toString() const101 {102 return m_strPostfix.isEmpty() ? QString("%1.%2.%3").arg(m_x).arg(m_y).arg(m_z)103 : QString("%1.%2.%3_%4").arg(m_x).arg(m_y).arg(m_z).arg(m_strPostfix);104 }105 106 UIVersion UIVersion::effectiveReleasedVersion() const107 {108 /* First, we just copy the current one: */109 UIVersion version = *this;110 111 /* If this version being developed: */112 if (version.z() % 2 == 1)113 {114 /* If this version being developed on release branch (we guess the right one): */115 if (version.z() < 97)116 version.setZ(version.z() - 1);117 /* If this version being developed on trunk (we use hardcoded one for now): */118 else119 version.setZ(8); /* Current .z for 6.0.z */120 }121 122 /* Finally, we just return that we have: */123 return version;124 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSTypeII.h
r101147 r101183 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI Versionclass declaration.3 * VBox Qt GUI - UIGuestOSTypeII class declaration. 4 4 */ 5 5 … … 26 26 */ 27 27 28 #ifndef FEQT_INCLUDED_SRC_globals_UI Version_h29 #define FEQT_INCLUDED_SRC_globals_UI Version_h28 #ifndef FEQT_INCLUDED_SRC_globals_UIGuestOSTypeII_h 29 #define FEQT_INCLUDED_SRC_globals_UIGuestOSTypeII_h 30 30 #ifndef RT_WITHOUT_PRAGMA_ONCE 31 31 # pragma once … … 33 33 34 34 /* Qt includes: */ 35 #include <QList> 36 #include <QMap> 35 37 #include <QString> 36 38 37 /** Represents VirtualBox version wrapper. */ 38 class UIVersion 39 /* COM includes: */ 40 #include "COMEnums.h" 41 #include "CGuestOSType.h" 42 43 44 class UIGuestOSTypeII; 45 46 class UIGuestOSTypeManager 47 { 48 49 public: 50 51 void reCacheGuestOSTypes(const CGuestOSTypeVector &guestOSTypes); 52 53 private: 54 55 void addGuestOSType(const CGuestOSType &comType); 56 57 QList<UIGuestOSTypeII> m_guestOSTypes; 58 QStringList m_guestOSFamilyIds; 59 /* Key is family id (linux, windows, etc) and value is the list of indices to m_guestOSTypes. */ 60 QMap<QString, QList<int> > m_guestOSTypesPerFamily; 61 /* Key is variant (debian, ubuntu, ) and value is the list of indices to m_guestOSTypes. */ 62 QMap<QString, QList<int> > m_guestOSTypesPerVariant; 63 }; 64 65 /** A wrapper around CGuestOSType. */ 66 class SHARED_LIBRARY_STUFF UIGuestOSTypeII 39 67 { 40 68 public: 41 69 42 /** Constructs default object. */43 UIVersion();44 /** Constructs object based on parsed @a strFullVersionInfo. */45 UIVersion(const QString &strFullVersionInfo);46 70 47 /** Returns whether this object is valid. */ 48 bool isValid() const; 71 UIGuestOSTypeII(const CGuestOSType &comGuestOSType); 49 72 50 /** Returns whether this object is equal to @a other. */ 51 bool equal(const UIVersion &other) const; 52 /** Checks whether this object is equal to @a other. */ 53 bool operator==(const UIVersion &other) const { return equal(other); } 54 /** Checks whether this object is NOT equal to @a other. */ 55 bool operator!=(const UIVersion &other) const { return !equal(other); } 73 const QString &getFamilyId(); 74 const QString &getFamilyDescription(); 75 const QString &getId(); 76 const QString &getVariant(); 77 const QString &getDescription(); 56 78 57 /** Checks whether this object is less than @a other. */58 bool operator<(const UIVersion &other) const;59 /** Checks whether this object is less or equal than @a other. */60 bool operator<=(const UIVersion &other) const;61 /** Checks whether this object is greater than @a other. */62 bool operator>(const UIVersion &other) const;63 /** Checks whether this object is greater or equal than @a other. */64 bool operator>=(const UIVersion &other) const;65 66 /** Returns object string representation. */67 QString toString() const;68 69 /** Returns the object X value. */70 int x() const { return m_x; }71 /** Returns the object Y value. */72 int y() const { return m_y; }73 /** Returns the object Z value. */74 int z() const { return m_z; }75 /** Returns the object postfix. */76 QString postfix() const { return m_strPostfix; }77 78 /** Defines the object @a x value. */79 void setX(int x) { m_x = x; }80 /** Defines the object @a y value. */81 void setY(int y) { m_y = y; }82 /** Defines the object @a z value. */83 void setZ(int z) { m_z = z; }84 /** Defines the object @a strPostfix. */85 void setPostfix(const QString &strPostfix) { m_strPostfix = strPostfix; }86 87 /** Returns effective released version guessed or hardcoded for this one version.88 * This can be even the version itself. */89 UIVersion effectiveReleasedVersion() const;90 79 91 80 private: 92 81 93 /** Holds the object X value. */ 94 int m_x; 95 /** Holds the object Y value. */ 96 int m_y; 97 /** Holds the object Z value. */ 98 int m_z; 82 /** @name CGuestOSType properties. Cached here for a faster access. 83 * @{ */ 84 QString m_strFamilyId; 85 QString m_strFamilyDescription; 86 QString m_strId; 87 QString m_strVariant; 88 QString m_strDescription; 89 /** @} */ 99 90 100 /** Holds the object postfix. */101 QString m_strPostfix; 91 CGuestOSType m_comGuestOSType; 92 102 93 }; 103 94 104 #endif /* !FEQT_INCLUDED_SRC_globals_UI Version_h */95 #endif /* !FEQT_INCLUDED_SRC_globals_UIGuestOSTypeII_h */
Note:
See TracChangeset
for help on using the changeset viewer.