VirtualBox

Changeset 73251 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 19, 2018 7:30:16 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9206: Fixing bugs in r123718 and r123780.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp

    r73178 r73251  
    8585}
    8686
    87 void UINameAndSystemEditor::setTypeId(const QString &strTypeId, const QString &strFamilyId /* = QString() */)
     87void UINameAndSystemEditor::setTypeId(QString strTypeId, QString strFamilyId /* = QString() */)
    8888{
    8989    AssertMsgReturnVoid(!strTypeId.isNull(), ("Null guest OS type ID"));
    9090
    91     /* Save values: */
    92     m_strTypeId = strTypeId;
    93     m_strFamilyId = strFamilyId;
    94 
    95     /* If family ID isn't null: */
    96     if (!m_strFamilyId.isNull())
    97     {
    98         /* Serch for corresponding family ID index: */
    99         int iFamilyIndex = m_pComboFamily->findData(m_strFamilyId, TypeID);
     91    /* Initialize indexes: */
     92    int iTypeIndex = -1;
     93    int iFamilyIndex = -1;
     94
     95    /* If family ID isn't empty: */
     96    if (!strFamilyId.isEmpty())
     97    {
     98        /* Search for corresponding family ID index: */
     99        iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID);
    100100
    101101        /* If that family ID isn't present, we have to add it: */
     
    103103        {
    104104            /* Append family ID to corresponding combo: */
    105             m_pComboFamily->addItem(m_strFamilyId);
    106             m_pComboFamily->setItemData(m_pComboFamily->count() - 1, m_strFamilyId, TypeID);
    107 
    108             /* Serch for corresponding family ID index again: */
    109             iFamilyIndex = m_pComboFamily->findData(m_strFamilyId, TypeID);
    110 
    111             /* Append the type cache: */
    112             m_types[m_strFamilyId] = QList<UIGuestOSType>();
    113             UIGuestOSType guiType;
    114             guiType.typeId = m_strTypeId;
    115             guiType.typeDescription = m_strTypeId;
    116             guiType.is64bit = false;
    117             m_types[m_strFamilyId] << guiType;
    118         }
    119 
    120         /* Choose if we have something to: */
    121         if (iFamilyIndex != -1)
    122         {
    123             m_pComboFamily->setCurrentIndex(iFamilyIndex);
    124             sltFamilyChanged(m_pComboFamily->currentIndex());
    125         }
    126     }
    127 
    128     /* Serch for corresponding type ID index: */
    129     int iTypeIndex = m_pComboType->findData(m_strTypeId, TypeID);
     105            m_pComboFamily->addItem(strFamilyId);
     106            m_pComboFamily->setItemData(m_pComboFamily->count() - 1, strFamilyId, TypeID);
     107            /* Append family ID to type cache: */
     108            m_types[strFamilyId] = QList<UIGuestOSType>();
     109
     110            /* Search for corresponding family ID index finally: */
     111            iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID);
     112        }
     113    }
     114    /* If family ID is empty: */
     115    else
     116    {
     117        /* We'll try to find it by type ID: */
     118        foreach (const QString &strKnownFamilyId, m_types.keys())
     119        {
     120            foreach (const UIGuestOSType &guiType, m_types.value(strKnownFamilyId))
     121            {
     122                if (guiType.typeId == strTypeId)
     123                    strFamilyId = strKnownFamilyId;
     124                if (!strFamilyId.isNull())
     125                    break;
     126            }
     127            if (!strFamilyId.isNull())
     128                break;
     129        }
     130
     131        /* If we were unable to find it => use "Other": */
     132        if (strFamilyId.isNull())
     133            strFamilyId = "Other";
     134
     135        /* Search for corresponding family ID index finally: */
     136        iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID);
     137    }
     138
     139    /* To that moment family ID index should be always found: */
     140    AssertReturnVoid(iFamilyIndex != -1);
     141    /* So we choose it: */
     142    m_pComboFamily->setCurrentIndex(iFamilyIndex);
     143    sltFamilyChanged(m_pComboFamily->currentIndex());
     144
     145    /* Search for corresponding type ID index: */
     146    iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
    130147
    131148    /* If that type ID isn't present, we have to add it: */
    132149    if (iTypeIndex == -1)
    133150    {
    134         /* Serch for "Other" family ID index: */
    135         m_strFamilyId = "Other";
    136         int iFamilyIndex = m_pComboFamily->findData(m_strFamilyId, TypeID);
    137 
    138         /* If that family ID is present: */
    139         if (iFamilyIndex != -1)
    140         {
    141             /* Append the type cache: */
    142             UIGuestOSType guiType;
    143             guiType.typeId = m_strTypeId;
    144             guiType.typeDescription = m_strTypeId;
    145             guiType.is64bit = false;
    146             m_types[m_strFamilyId] << guiType;
    147 
    148             /* Choose required element: */
    149             m_pComboFamily->setCurrentIndex(iFamilyIndex);
    150             sltFamilyChanged(m_pComboFamily->currentIndex());
    151         }
    152 
    153         /* Serch for corresponding type ID index again: */
    154         iTypeIndex = m_pComboType->findData(m_strTypeId, TypeID);
    155     }
    156 
    157     /* Choose if we have something to: */
    158     if (iTypeIndex != -1)
    159     {
    160         m_pComboType->setCurrentIndex(iTypeIndex);
    161         sltTypeChanged(m_pComboType->currentIndex());
    162     }
     151        /* Append type ID to type cache: */
     152        UIGuestOSType guiType;
     153        guiType.typeId = strTypeId;
     154        guiType.typeDescription = strTypeId;
     155        guiType.is64bit = false;
     156        m_types[strFamilyId] << guiType;
     157
     158        /* So we re-choose family again: */
     159        m_pComboFamily->setCurrentIndex(iFamilyIndex);
     160        sltFamilyChanged(m_pComboFamily->currentIndex());
     161
     162        /* Search for corresponding type ID index finally: */
     163        iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
     164    }
     165
     166    /* To that moment type ID index should be always found: */
     167    AssertReturnVoid(iTypeIndex != -1);
     168    /* So we choose it: */
     169    m_pComboType->setCurrentIndex(iTypeIndex);
     170    sltTypeChanged(m_pComboType->currentIndex());
    163171}
    164172
     
    267275void UINameAndSystemEditor::sltTypeChanged(int iIndex)
    268276{
    269     /* Acquire type/family IDs: */
     277    /* Acquire type ID: */
    270278    m_strTypeId = m_pComboType->itemData(iIndex, TypeID).toString();
    271279
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r73130 r73251  
    7676
    7777    /** Defines the VM OS @a strTypeId and @a strFamilyId if passed. */
    78     void setTypeId(const QString &strTypeId, const QString &strFamilyId = QString());
     78    void setTypeId(QString strTypeId, QString strFamilyId = QString());
    7979    /** Returns the VM OS type ID. */
    8080    QString typeId() const;
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