VirtualBox

Changeset 103688 in vbox


Ignore:
Timestamp:
Mar 5, 2024 6:10:09 PM (9 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10384: UIGuestOSType: Extend subtype info from simple QString to UISubtypeInfo struct accumulating all the required subtype information.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.cpp

    r103686 r103688  
    110110
    111111    /* Cache or update subtype info: */
     112    UISubtypeInfo si(strSubtype);
    112113    if (!m_guestOSSubtypes.contains(strFamilyId))
    113         m_guestOSSubtypes[strFamilyId] << strSubtype;
     114        m_guestOSSubtypes[strFamilyId] << si;
    114115    else
    115116    {
    116         QStringList &subtypes = m_guestOSSubtypes[strFamilyId];
    117         if (!subtypes.contains(strSubtype))
    118             subtypes << strSubtype;
     117        UIGuestOSSubtypeInfo &subtypes = m_guestOSSubtypes[strFamilyId];
     118        if (!subtypes.contains(si))
     119            subtypes << si;
    119120    }
    120121
     
    146147}
    147148
    148 QStringList
     149UIGuestOSTypeManager::UIGuestOSSubtypeInfo
    149150UIGuestOSTypeManager::getSubtypesForFamilyId(const QString &strFamilyId,
    150151                                             KPlatformArchitecture enmArch /* = KPlatformArchitecture_None */) const
     
    155156
    156157    /* Otherwise we'll have to prepare list by arch type: */
    157     QStringList subtypes;
    158     foreach (const QString &strSubtype, m_guestOSSubtypes.value(strFamilyId))
    159     {
    160         const KPlatformArchitecture enmCurrentArch = m_guestOSSubtypeArch.value(strSubtype, KPlatformArchitecture_Max);
     158    UIGuestOSSubtypeInfo subtypes;
     159    foreach (const UISubtypeInfo &subtype, m_guestOSSubtypes.value(strFamilyId))
     160    {
     161        const KPlatformArchitecture enmCurrentArch = m_guestOSSubtypeArch.value(subtype.m_strName, KPlatformArchitecture_Max);
    161162        if (enmCurrentArch == enmArch || enmCurrentArch == KPlatformArchitecture_None)
    162             subtypes << strSubtype;
     163            subtypes << subtype;
    163164    }
    164165    return subtypes;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.h

    r103687 r103688  
    7979    /** Holds whether family is supported. */
    8080    bool                   m_fSupported;
     81};
     82
     83/** Represents guest OS subtype info. */
     84struct UISubtypeInfo
     85{
     86    /** Constructs empty subtype info. */
     87    UISubtypeInfo()
     88    {}
     89
     90    /** Constructs subtype info.
     91      * @param  strName  Brings the name. */
     92    UISubtypeInfo(const QString &strName)
     93        : m_strName(strName)
     94    {}
     95
     96    /** Returns whether this subtype info has the same name as @a other. */
     97    bool operator==(const UISubtypeInfo &other) const
     98    {
     99        return m_strName == other.m_strName;
     100    }
     101
     102    /** Holds the name. */
     103    QString  m_strName;
    81104};
    82105
     
    139162    /** A list of all OS families. */
    140163    typedef QVector<UIFamilyInfo> UIGuestOSFamilyInfo;
     164    /** A list of all OS subtypes. */
     165    typedef QVector<UISubtypeInfo> UIGuestOSSubtypeInfo;
    141166    /** A list of all OS type pairs. */
    142167    typedef QVector<UIGuestInfoPair> UIGuestOSTypeInfo;
     
    154179                                    KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
    155180    /** Returns the list of subtypes for @p strFamilyId. This may be an empty list. */
    156     QStringList getSubtypesForFamilyId(const QString &strFamilyId,
    157                                        KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
     181    UIGuestOSSubtypeInfo getSubtypesForFamilyId(const QString &strFamilyId,
     182                                                KPlatformArchitecture enmArch = KPlatformArchitecture_None) const;
    158183    /** Returns a list of OS types for the @p strFamilyId. */
    159184    UIGuestOSTypeInfo getTypesForFamilyId(const QString &strFamilyId,
     
    204229    UIGuestOSFamilyInfo m_guestOSFamilies;
    205230    /** Hold the list of guest OS subtype info. */
    206     QMap<QString, QStringList> m_guestOSSubtypes;
     231    QMap<QString, UIGuestOSSubtypeInfo> m_guestOSSubtypes;
    207232
    208233    /** Caches arch types on per-subtype basis. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r103687 r103688  
    652652
    653653    /* Acquire a list of suitable sub-types: */
    654     const QStringList distributions = uiCommon().guestOSTypeManager().getSubtypesForFamilyId(m_strFamilyId, enmArch);
     654    const UIGuestOSTypeManager::UIGuestOSSubtypeInfo distributions
     655        = uiCommon().guestOSTypeManager().getSubtypesForFamilyId(m_strFamilyId, enmArch);
    655656    m_pLabelDistribution->setEnabled(!distributions.isEmpty());
    656657    m_pComboDistribution->setEnabled(!distributions.isEmpty());
     
    661662
    662663    /* Populate distribution combo: */
    663     m_pComboDistribution->addItems(distributions);
     664    foreach (const UISubtypeInfo &distribution, distributions)
     665        m_pComboDistribution->addItem(distribution.m_strName);
    664666
    665667    /* Unblock signals finally: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestOSTypeSelectionButton.cpp

    r103687 r103688  
    114114        const UIFamilyInfo &fi = familyies.at(i);
    115115        QMenu *pSubMenu = m_pMainMenu->addMenu(fi.m_strDescription);
    116         const QStringList distributions = uiCommon().guestOSTypeManager().getSubtypesForFamilyId(fi.m_strId);
     116        const UIGuestOSTypeManager::UIGuestOSSubtypeInfo distributions = uiCommon().guestOSTypeManager().getSubtypesForFamilyId(fi.m_strId);
    117117
    118118        if (distributions.isEmpty())
     
    120120        else
    121121        {
    122             foreach (const QString &strDistribution, distributions)
    123                 createOSTypeMenu(uiCommon().guestOSTypeManager().getTypesForSubtype(strDistribution),
    124                                  pSubMenu->addMenu(strDistribution));
     122            foreach (const UISubtypeInfo &distribution, distributions)
     123                createOSTypeMenu(uiCommon().guestOSTypeManager().getTypesForSubtype(distribution.m_strName),
     124                                 pSubMenu->addMenu(distribution.m_strName));
    125125        }
    126126    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette