VirtualBox

Changeset 74766 in vbox for trunk


Ignore:
Timestamp:
Oct 11, 2018 12:13:26 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9265: More refactoring for UIWizardExportAppPageBasic2 and UIWizardExportAppPageExpert (s.a. r125696).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp

    r74758 r74766  
    8080    AssertReturnVoid(m_pFormatComboBox->count() == 0);
    8181
    82     /* Apply hardcoded format list: */
     82    /* Compose hardcoded format list: */
    8383    QStringList formats;
    8484    formats << "ovf-0.9";
     
    8787    formats << "opc-1.0";
    8888    formats << "csp-1.0";
    89     m_pFormatComboBox->addItems(formats);
    90 
    91     /* Duplicate non-translated names to data fields: */
    92     for (int i = 0; i < m_pFormatComboBox->count(); ++i)
    93         m_pFormatComboBox->setItemData(i, m_pFormatComboBox->itemText(i));
     89    /* Add that list to combo: */
     90    foreach (const QString &strShortName, formats)
     91    {
     92        /* Compose empty item, fill it's data: */
     93        m_pFormatComboBox->addItem(QString());
     94        m_pFormatComboBox->setItemData(m_pFormatComboBox->count() - 1, strShortName, FormatData_ShortName);
     95    }
    9496
    9597    /* Set default: */
     
    117119    AssertReturnVoid(m_pAccountComboBox->count() == 0);
    118120
    119     /* Acquire provider list: */
    120     QVector<CCloudProvider> comProviders = m_comCloudProviderManager.GetProviders();
    121 
    122121    /* Iterate through providers: */
    123     foreach (const CCloudProvider &comProvider, comProviders)
     122    foreach (const CCloudProvider &comCloudProvider, m_comCloudProviderManager.GetProviders())
    124123    {
    125124        /* Skip if we have nothing to populate (file missing?): */
    126         if (comProvider.isNull())
     125        if (comCloudProvider.isNull())
    127126            continue;
    128127
    129128        /* Iterate through profile names: */
    130         foreach (const QString &strProfileName, comProvider.GetProfileNames())
     129        foreach (const QString &strProfileName, comCloudProvider.GetProfileNames())
    131130        {
    132131            m_pAccountComboBox->addItem(QString());
    133             m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, comProvider.GetId(), ProviderID);
    134             m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, comProvider.GetName(), ProviderName);
    135             m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, comProvider.GetShortName(), ProviderShortName);
    136             m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, strProfileName, ProfileName);
     132            m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, comCloudProvider.GetId(),        AccountData_ProviderID);
     133            m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, comCloudProvider.GetName(),      AccountData_ProviderName);
     134            m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, comCloudProvider.GetShortName(), AccountData_ProviderShortName);
     135            m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, strProfileName,                  AccountData_ProfileName);
    137136        }
    138137    }
     
    145144void UIWizardExportAppPage2::populateAccountProperties()
    146145{
     146    /* Clear table initially: */
     147    m_pAccountPropertyTable->clear();
     148
    147149    /* Acquire Cloud Provider: */
    148150    CCloudProvider comCloudProvider = m_comCloudProviderManager.GetProviderById(providerId());
     
    156158    if (m_comCloudProfile.isNull())
    157159        return;
    158 
    159     /* Clear table initially: */
    160     m_pAccountPropertyTable->clear();
    161160
    162161    /* Acquire properties: */
     
    365364void UIWizardExportAppPage2::setFormat(const QString &strFormat)
    366365{
    367     const int iIndex = m_pFormatComboBox->findData(strFormat);
     366    const int iIndex = m_pFormatComboBox->findData(strFormat, FormatData_ShortName);
    368367    AssertMsg(iIndex != -1, ("Data not found!"));
    369368    m_pFormatComboBox->setCurrentIndex(iIndex);
    370369}
     370
    371371QString UIWizardExportAppPage2::format() const
    372372{
    373373    const int iIndex = m_pFormatComboBox->currentIndex();
    374     return m_pFormatComboBox->itemData(iIndex).toString();
     374    return m_pFormatComboBox->itemData(iIndex, FormatData_ShortName).toString();
    375375}
    376376
     
    420420void UIWizardExportAppPage2::setProviderById(const QString &strId)
    421421{
    422     const int iIndex = m_pAccountComboBox->findData(strId, ProviderID);
     422    const int iIndex = m_pAccountComboBox->findData(strId, AccountData_ProviderID);
    423423    AssertMsg(iIndex != -1, ("Data not found!"));
    424424    m_pAccountComboBox->setCurrentIndex(iIndex);
     
    428428{
    429429    const int iIndex = m_pAccountComboBox->currentIndex();
    430     return m_pAccountComboBox->itemData(iIndex, ProviderID).toString();
     430    return m_pAccountComboBox->itemData(iIndex, AccountData_ProviderID).toString();
    431431}
    432432
     
    434434{
    435435    const int iIndex = m_pAccountComboBox->currentIndex();
    436     return m_pAccountComboBox->itemData(iIndex, ProviderShortName).toString();
     436    return m_pAccountComboBox->itemData(iIndex, AccountData_ProviderShortName).toString();
    437437}
    438438
     
    440440{
    441441    const int iIndex = m_pAccountComboBox->currentIndex();
    442     return m_pAccountComboBox->itemData(iIndex, ProfileName).toString();
     442    return m_pAccountComboBox->itemData(iIndex, AccountData_ProfileName).toString();
    443443}
    444444
     
    753753    m_pFileSelector->setFileDialogTitle(UIWizardExportApp::tr("Please choose a file to export the virtual appliance to"));
    754754
    755     /* Translate Format combo-box: */
     755    /* Translate hardcoded values of Format combo-box: */
    756756    m_pFormatComboBoxLabel->setText(UIWizardExportApp::tr("F&ormat:"));
    757757    m_pFormatComboBox->setItemText(0, UIWizardExportApp::tr("Open Virtualization Format 0.9"));
     
    797797    {
    798798        m_pAccountComboBox->setItemText(i, UIWizardExportApp::tr("%1: %2", "provider: profile")
    799             .arg(m_pAccountComboBox->itemData(i, ProviderName).toString())
    800             .arg(m_pAccountComboBox->itemData(i, ProfileName).toString()));
     799            .arg(m_pAccountComboBox->itemData(i, AccountData_ProviderName).toString())
     800            .arg(m_pAccountComboBox->itemData(i, AccountData_ProfileName).toString()));
    801801    }
    802802
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.h

    r74758 r74766  
    5353Q_DECLARE_METATYPE(MACAddressPolicy);
    5454
     55/** Format combo data fields. */
     56enum
     57{
     58    FormatData_ShortName = Qt::UserRole + 1
     59};
     60
    5561/** Account combo data fields. */
    5662enum
    5763{
    58     ProviderID        = Qt::UserRole + 1,
    59     ProviderName      = Qt::UserRole + 2,
    60     ProviderShortName = Qt::UserRole + 3,
    61     ProfileName       = Qt::UserRole + 4
     64    AccountData_ProviderID        = Qt::UserRole + 1,
     65    AccountData_ProviderName      = Qt::UserRole + 2,
     66    AccountData_ProviderShortName = Qt::UserRole + 3,
     67    AccountData_ProfileName       = Qt::UserRole + 4
    6268};
    6369
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp

    r74558 r74766  
    390390    m_pFileSelector->setFileDialogTitle(UIWizardExportApp::tr("Please choose a file to export the virtual appliance to"));
    391391
    392     /* Translate Format combo-box: */
     392    /* Translate hard-coded values of Format combo-box: */
    393393    m_pFormatComboBoxLabel->setText(UIWizardExportApp::tr("F&ormat:"));
    394394    m_pFormatComboBox->setItemText(0, UIWizardExportApp::tr("Open Virtualization Format 0.9"));
     
    434434    {
    435435        m_pAccountComboBox->setItemText(i, UIWizardExportApp::tr("%1: %2", "provider: profile")
    436             .arg(m_pAccountComboBox->itemData(i, ProviderName).toString())
    437             .arg(m_pAccountComboBox->itemData(i, ProfileName).toString()));
     436            .arg(m_pAccountComboBox->itemData(i, AccountData_ProviderName).toString())
     437            .arg(m_pAccountComboBox->itemData(i, AccountData_ProfileName).toString()));
    438438    }
    439439
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