VirtualBox

Ignore:
Timestamp:
Jul 13, 2018 12:44:55 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9206: Reworking VBoxGlobal, UIGuestOSTypeSelectionButton and UINameAndSystemEditor to use more proper guest OS type family ID list.

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

Legend:

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

    r73017 r73119  
    21432143}
    21442144
    2145 QList<CGuestOSType> VBoxGlobal::vmGuestOSFamilyList() const
    2146 {
    2147     QList<CGuestOSType> result;
    2148     for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i)
    2149         result << m_guestOSTypes[i][0];
    2150     return result;
     2145QString VBoxGlobal::vmGuestOSFamilyDescription(const QString &strFamilyId) const
     2146{
     2147    AssertMsg(m_guestOSFamilyDescriptions.contains(strFamilyId),
     2148              ("Family ID incorrect: '%s'.", strFamilyId.toLatin1().constData()));
     2149    return m_guestOSFamilyDescriptions.value(strFamilyId);
    21512150}
    21522151
    21532152QList<CGuestOSType> VBoxGlobal::vmGuestOSTypeList(const QString &strFamilyId) const
    21542153{
    2155     AssertMsg(m_guestOSFamilyIDs.contains(strFamilyId), ("Family ID incorrect: '%s'.", strFamilyId.toLatin1().constData()));
     2154    AssertMsg(m_guestOSFamilyIDs.contains(strFamilyId),
     2155              ("Family ID incorrect: '%s'.", strFamilyId.toLatin1().constData()));
    21562156    return m_guestOSFamilyIDs.contains(strFamilyId) ?
    21572157           m_guestOSTypes[m_guestOSFamilyIDs.indexOf(strFamilyId)] : QList<CGuestOSType>();
     
    43854385                const CGuestOSType os = guestOSTypes.at(i);
    43864386                const QString strFamilyID = os.GetFamilyId();
     4387                const QString strFamilyDescription = os.GetFamilyDescription();
    43874388                if (!m_guestOSFamilyIDs.contains(strFamilyID))
    43884389                {
    43894390                    m_guestOSFamilyIDs << strFamilyID;
     4391                    m_guestOSFamilyDescriptions[strFamilyID] = strFamilyDescription;
    43904392                    m_guestOSTypes << QList<CGuestOSType>();
    43914393                }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r73017 r73119  
    2121/* Qt includes: */
    2222#include <QFileIconProvider>
     23#include <QMap>
    2324#include <QReadWriteLock>
    2425
     
    442443    /** @name COM: Guest OS Type.
    443444     * @{ */
    444         /** Returns the list of few guest OS types, queried from
    445           * IVirtualBox corresponding to every family id. */
    446         QList<CGuestOSType> vmGuestOSFamilyList() const;
    447         /** Returns the list of all guest OS types, queried from
    448           * IVirtualBox corresponding to passed family id. */
     445        /** Returns the list of family IDs. */
     446        QList<QString> vmGuestOSFamilyIDs() const { return m_guestOSFamilyIDs; }
     447
     448        /** Returns a family description with passed @a strFamilyId. */
     449        QString vmGuestOSFamilyDescription(const QString &strFamilyId) const;
     450        /** Returns a list of all guest OS types with passed @a strFamilyId. */
    449451        QList<CGuestOSType> vmGuestOSTypeList(const QString &strFamilyId) const;
    450452
    451         /** Returns the guest OS type object corresponding to the given type id of list
    452           * containing OS types related to OS family determined by family id attribute.
    453           * If the index is invalid a null object is returned. */
     453        /** Returns the guest OS type for passed @a strTypeId.
     454          * It is being serached through the list of family with passed @a strFamilyId if specified. */
    454455        CGuestOSType vmGuestOSType(const QString &strTypeId, const QString &strFamilyId = QString()) const;
    455         /** Returns the description corresponding to the given guest OS type id. */
     456        /** Returns a type description with passed @a strTypeId. */
    456457        QString vmGuestOSTypeDescription(const QString &strTypeId) const;
    457458
     
    833834        /** Holds the guest OS family IDs. */
    834835        QList<QString>               m_guestOSFamilyIDs;
     836        /** Holds the guest OS family descriptions. */
     837        QMap<QString, QString>       m_guestOSFamilyDescriptions;
    835838        /** Holds the guest OS types for each family ID. */
    836839        QList<QList<CGuestOSType> >  m_guestOSTypes;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestOSTypeSelectionButton.cpp

    r73118 r73119  
    8484void UIGuestOSTypeSelectionButton::populateMenu()
    8585{
     86    /* Clea initially: */
    8687    m_pMainMenu->clear();
    8788
    88     /* Create a list of all possible OS types */
    89     QList<CGuestOSType> families = vboxGlobal().vmGuestOSFamilyList();
    90     foreach(const CGuestOSType &comFamily, families)
     89    /* Create a list of all possible OS types: */
     90    foreach(const QString &strFamilyId, vboxGlobal().vmGuestOSFamilyIDs())
    9191    {
    92         QMenu *pSubMenu = m_pMainMenu->addMenu(comFamily.GetFamilyDescription());
    93         QList<CGuestOSType> types = vboxGlobal().vmGuestOSTypeList(comFamily.GetFamilyId());
    94         foreach (const CGuestOSType &comType, types)
     92        QMenu *pSubMenu = m_pMainMenu->addMenu(vboxGlobal().vmGuestOSFamilyDescription(strFamilyId));
     93        foreach (const CGuestOSType &comType, vboxGlobal().vmGuestOSTypeList(strFamilyId))
    9594        {
    9695            QAction *pAction = pSubMenu->addAction(vboxGlobal().vmGuestOSTypePixmapDefault(comType.GetId()),
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp

    r72603 r73119  
    338338{
    339339    /* Populate VM OS family combo: */
    340     const QList<CGuestOSType> families = vboxGlobal().vmGuestOSFamilyList();
    341     for (int i = 0; i < families.size(); ++i)
    342     {
    343         const QString strFamilyName = families.at(i).GetFamilyDescription();
    344         m_pComboFamily->insertItem(i, strFamilyName);
    345         m_pComboFamily->setItemData(i, families.at(i).GetFamilyId(), TypeID);
     340    const QList<QString> &familyIDs = vboxGlobal().vmGuestOSFamilyIDs();
     341    for (int i = 0; i < familyIDs.size(); ++i)
     342    {
     343        const QString &strFamilyId = familyIDs.at(i);
     344        m_pComboFamily->insertItem(i, vboxGlobal().vmGuestOSFamilyDescription(strFamilyId));
     345        m_pComboFamily->setItemData(i, strFamilyId, TypeID);
    346346    }
    347347
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