VirtualBox

Ignore:
Timestamp:
Apr 25, 2016 6:41:42 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: ​​​​​​​​​bugref:6769: Rework/cleanup for VM properties editor (part 04): Refactoring.

File:
1 edited

Legend:

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

    r60696 r60697  
    4545    qRegisterMetaType<CGuestOSType>();
    4646
    47     /* Create widgets: */
     47    /* Create main-layout: */
    4848    QGridLayout *pMainLayout = new QGridLayout(this);
    4949    {
     50        /* Configure main-layout: */
    5051        pMainLayout->setContentsMargins(0, 0, 0, 0);
    51         m_pLabelName = new QLabel(this);
    52         {
     52
     53        /* Create VM name label: */
     54        m_pLabelName = new QLabel;
     55        {
     56            /* Configure VM name label: */
    5357            m_pLabelName->setAlignment(Qt::AlignRight);
    5458            m_pLabelName->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    55         }
    56         m_pEditorName = new QLineEdit(this);
    57         {
     59            /* Add VM name label into main-layout: */
     60            pMainLayout->addWidget(m_pLabelName, 0, 0);
     61        }
     62
     63        /* Create VM name editor: */
     64        m_pEditorName = new QLineEdit;
     65        {
     66            /* Configure VM name editor: */
    5867            m_pEditorName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    5968            m_pLabelName->setBuddy(m_pEditorName);
    60         }
    61         m_pLabelFamily = new QLabel(this);
    62         {
     69            /* Add VM name editor into main-layout: */
     70            pMainLayout->addWidget(m_pEditorName, 0, 1, 1, 2);
     71        }
     72
     73        /* Create VM OS family label: */
     74        m_pLabelFamily = new QLabel;
     75        {
     76            /* Configure VM OS family label: */
    6377            m_pLabelFamily->setAlignment(Qt::AlignRight);
    6478            m_pLabelFamily->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    65         }
    66         m_pComboFamily = new QComboBox(this);
    67         {
     79            /* Add VM OS family label into main-layout: */
     80            pMainLayout->addWidget(m_pLabelFamily, 1, 0);
     81        }
     82
     83        /* Create VM OS family combo: */
     84        m_pComboFamily = new QComboBox;
     85        {
     86            /* Configure VM OS family combo: */
    6887            m_pComboFamily->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    6988            m_pLabelFamily->setBuddy(m_pComboFamily);
    70         }
    71         m_pLabelType = new QLabel(this);
    72         {
     89            /* Add VM OS family combo into main-layout: */
     90            pMainLayout->addWidget(m_pComboFamily, 1, 1);
     91        }
     92
     93        /* Create VM OS type label: */
     94        m_pLabelType = new QLabel;
     95        {
     96            /* Configure VM OS type label: */
    7397            m_pLabelType->setAlignment(Qt::AlignRight);
    7498            m_pLabelType->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    75         }
    76         m_pComboType = new QComboBox(this);
    77         {
     99            /* Add VM OS type label into main-layout: */
     100            pMainLayout->addWidget(m_pLabelType, 2, 0);
     101        }
     102
     103        /* Create VM OS type combo: */
     104        m_pComboType = new QComboBox;
     105        {
     106            /* Configure VM OS type combo: */
    78107            m_pComboType->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    79108            m_pLabelType->setBuddy(m_pComboType);
    80         }
     109            /* Add VM OS type combo into main-layout: */
     110            pMainLayout->addWidget(m_pComboType, 2, 1);
     111        }
     112
     113        /* Create sub-layout: */
    81114        QVBoxLayout *pLayoutIcon = new QVBoxLayout;
    82115        {
    83             m_pIconType = new QLabel(this);
     116            /* Create VM OS type icon: */
     117            m_pIconType = new QLabel;
    84118            {
     119                /* Configure VM OS type icon: */
    85120                m_pIconType->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     121                /* Add VM OS type icon into sub-layout: */
     122                pLayoutIcon->addWidget(m_pIconType);
    86123            }
    87             pLayoutIcon->addWidget(m_pIconType);
     124            /* Add stretch to sub-layout: */
    88125            pLayoutIcon->addStretch();
    89         }
    90         pMainLayout->addWidget(m_pLabelName, 0, 0);
    91         pMainLayout->addWidget(m_pEditorName, 0, 1, 1, 2);
    92         pMainLayout->addWidget(m_pLabelFamily, 1, 0);
    93         pMainLayout->addWidget(m_pComboFamily, 1, 1);
    94         pMainLayout->addWidget(m_pLabelType, 2, 0);
    95         pMainLayout->addWidget(m_pComboType, 2, 1);
    96         pMainLayout->addLayout(pLayoutIcon, 1, 2, 2, 1);
     126            /* Add sub-layout into main-layout: */
     127            pMainLayout->addLayout(pLayoutIcon, 1, 2, 2, 1);
     128        }
    97129    }
    98130
     
    103135
    104136    /* Fill OS family selector: */
    105     QList<CGuestOSType> families(vboxGlobal().vmGuestOSFamilyList());
     137    const QList<CGuestOSType> families = vboxGlobal().vmGuestOSFamilyList();
    106138    for (int i = 0; i < families.size(); ++i)
    107139    {
    108         QString strFamilyName(families[i].GetFamilyDescription());
     140        const QString strFamilyName = families.at(i).GetFamilyDescription();
    109141        m_pComboFamily->insertItem(i, strFamilyName);
    110         m_pComboFamily->setItemData(i, families[i].GetFamilyId(), TypeID);
     142        m_pComboFamily->setItemData(i, families.at(i).GetFamilyId(), TypeID);
    111143    }
    112144    m_pComboFamily->setCurrentIndex(0);
     
    140172{
    141173    /* Initialize variables: */
    142     QString strFamilyId(type.GetFamilyId());
    143     QString strTypeId(type.GetId());
     174    const QString strFamilyId = type.GetFamilyId();
     175    const QString strTypeId = type.GetId();
    144176
    145177    /* Get/check family index: */
    146     int iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID);
     178    const int iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID);
    147179    AssertMsg(iFamilyIndex != -1, ("Invalid family ID: '%s'", strFamilyId.toLatin1().constData()));
    148180    if (iFamilyIndex != -1)
     
    150182
    151183    /* Get/check type index: */
    152     int iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
     184    const int iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
    153185    AssertMsg(iTypeIndex != -1, ("Invalid type ID: '%s'", strTypeId.toLatin1().constData()));
    154186    if (iTypeIndex != -1)
     
    176208
    177209    /* Populate combo-box with OS types related to currently selected family id: */
    178     QString strFamilyId(m_pComboFamily->itemData(iIndex, TypeID).toString());
    179     QList<CGuestOSType> types(vboxGlobal().vmGuestOSTypeList(strFamilyId));
     210    const QString strFamilyId = m_pComboFamily->itemData(iIndex, TypeID).toString();
     211    const QList<CGuestOSType> types = vboxGlobal().vmGuestOSTypeList(strFamilyId);
    180212    for (int i = 0; i < types.size(); ++i)
    181213    {
    182         if (types[i].GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode))
     214        /* Skip 64bit OS types is hardware virtualization or long mode is not supported: */
     215        if (types.at(i).GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode))
    183216            continue;
    184         int iIndex = m_pComboType->count();
     217        const int iIndex = m_pComboType->count();
    185218        m_pComboType->insertItem(iIndex, types[i].GetDescription());
    186219        m_pComboType->setItemData(iIndex, types[i].GetId(), TypeID);
     
    190223    if (m_currentIds.contains(strFamilyId))
    191224    {
    192         QString strTypeId(m_currentIds[strFamilyId]);
    193         int iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
     225        const QString strTypeId = m_currentIds.value(strFamilyId);
     226        const int iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
    194227        if (iTypeIndex != -1)
    195228            m_pComboType->setCurrentIndex(iTypeIndex);
     
    201234        if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode)
    202235            strDefaultID += "_64";
    203         int iIndexWin7 = m_pComboType->findData(strDefaultID, TypeID);
     236        const int iIndexWin7 = m_pComboType->findData(strDefaultID, TypeID);
    204237        if (iIndexWin7 != -1)
    205238            m_pComboType->setCurrentIndex(iIndexWin7);
     
    211244        if (ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode)
    212245            strDefaultID += "_64";
    213         int iIndexUbuntu = m_pComboType->findData(strDefaultID, TypeID);
     246        const int iIndexUbuntu = m_pComboType->findData(strDefaultID, TypeID);
    214247        if (iIndexUbuntu != -1)
    215248            m_pComboType->setCurrentIndex(iIndexUbuntu);
    216249    }
    217250    /* Else simply select the first one present: */
    218     else m_pComboType->setCurrentIndex(0);
     251    else
     252        m_pComboType->setCurrentIndex(0);
    219253
    220254    /* Update all the stuff: */
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