VirtualBox

Changeset 91539 in vbox for trunk


Ignore:
Timestamp:
Oct 4, 2021 10:57:58 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996: UIWizardExportApp: Move local appliance creation logic from UIApplianceExportEditorWidget to UIWizardExportAppPageBasic2 where it belongs.

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

Legend:

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

    r91538 r91539  
    2222#include "QITreeView.h"
    2323#include "UIApplianceExportEditorWidget.h"
    24 #include "UICommon.h"
    2524#include "UIMessageCenter.h"
    26 
    27 /* COM includes: */
    28 #include "CAppliance.h"
    2925
    3026
     
    6763}
    6864
    69 CAppliance *UIApplianceExportEditorWidget::init()
     65void UIApplianceExportEditorWidget::setAppliance(const CAppliance &comAppliance)
    7066{
    71     if (m_pAppliance)
    72         delete m_pAppliance;
    73     CVirtualBox comVBox = uiCommon().virtualBox();
    74     /* Create a appliance object: */
    75     m_pAppliance = new CAppliance(comVBox.CreateAppliance());
    76     return m_pAppliance;
    77 }
     67    /* Cache newly passed appliance: */
     68    m_comAppliance = comAppliance;
    7869
    79 void UIApplianceExportEditorWidget::populate()
    80 {
    8170    /* Cleanup previous stuff: */
    8271    if (m_pModel)
     
    8473
    8574    /* Prepare model: */
    86     QVector<CVirtualSystemDescription> vsds = m_pAppliance->GetVirtualSystemDescriptions();
     75    QVector<CVirtualSystemDescription> vsds = m_comAppliance.GetVirtualSystemDescriptions();
    8776    m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
    8877    if (m_pModel)
     
    114103
    115104    /* Check for warnings & if there are one display them: */
    116     const QVector<QString> warnings = m_pAppliance->GetWarnings();
     105    const QVector<QString> warnings = m_comAppliance.GetWarnings();
    117106    const bool fWarningsEnabled = warnings.size() > 0;
    118107    foreach (const QString &strText, warnings)
     
    123112void UIApplianceExportEditorWidget::prepareExport()
    124113{
    125     if (m_pAppliance)
     114    if (m_comAppliance.isNotNull())
    126115        m_pModel->putBack();
    127116}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceExportEditorWidget.h

    r91538 r91539  
    2525#include "UIApplianceEditorWidget.h"
    2626
    27 /* Forward declarations: */
    28 class CAppliance;
     27/* COM includes: */
     28#include "CAppliance.h"
    2929
    3030/** UIApplianceEditorWidget subclass for Export Appliance wizard. */
     
    3838    UIApplianceExportEditorWidget(QWidget *pParent = 0);
    3939
    40     /** Inits the widget by creating appliance instance. */
    41     CAppliance *init();
    42 
    43     /** Populates widget contents. */
    44     void populate();
     40    /** Assigns @a comAppliance and populates widget contents. */
     41    void setAppliance(const CAppliance &comAppliance);
    4542
    4643    /** Prepares export by pushing edited data back to appliance. */
    4744    void prepareExport();
     45
     46private:
     47
     48    /** Holds the appliance wrapper instance. */
     49    CAppliance  m_comAppliance;
    4850};
    4951
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp

    r91460 r91539  
    318318        /* Enable include ISO check-box: */
    319319        pCheckBox->setEnabled(true);
     320    }
     321}
     322
     323void UIWizardExportAppPage2::refreshLocalStuff(CAppliance &comLocalAppliance,
     324                                               const QList<QUuid> &machineIDs,
     325                                               const QString &strUri)
     326{
     327    /* Clear stuff: */
     328    comLocalAppliance = CAppliance();
     329
     330    /* Create appliance: */
     331    CVirtualBox comVBox = uiCommon().virtualBox();
     332    CAppliance comAppliance = comVBox.CreateAppliance();
     333    if (!comVBox.isOk())
     334    {
     335        msgCenter().cannotCreateAppliance(comVBox);
     336        return;
     337    }
     338
     339    /* Remember appliance: */
     340    comLocalAppliance = comAppliance;
     341
     342    /* Iterate over all the selected machine uuids: */
     343    foreach (const QUuid &uMachineId, machineIDs)
     344    {
     345        /* Get the machine with the uMachineId: */
     346        CVirtualBox comVBox = uiCommon().virtualBox();
     347        CMachine comMachine = comVBox.FindMachine(uMachineId.toString());
     348        if (!comVBox.isOk())
     349            return msgCenter().cannotFindMachineById(comVBox, uMachineId);
     350        /* Add the export description to our appliance object: */
     351        CVirtualSystemDescription comVsd = comMachine.ExportTo(comLocalAppliance, strUri);
     352        if (!comMachine.isOk())
     353            return msgCenter().cannotExportAppliance(comMachine, comLocalAppliance.GetPath());
     354        /* Add some additional fields the user may change: */
     355        comVsd.AddDescription(KVirtualSystemDescriptionType_Product, "", "");
     356        comVsd.AddDescription(KVirtualSystemDescriptionType_ProductUrl, "", "");
     357        comVsd.AddDescription(KVirtualSystemDescriptionType_Vendor, "", "");
     358        comVsd.AddDescription(KVirtualSystemDescriptionType_VendorUrl, "", "");
     359        comVsd.AddDescription(KVirtualSystemDescriptionType_Version, "", "");
     360        comVsd.AddDescription(KVirtualSystemDescriptionType_License, "", "");
    320361    }
    321362}
     
    10061047                  && wizard()->vsdExportForm().isNotNull();
    10071048    }
     1049    else
     1050    {
     1051        /* Update local stuff: */
     1052        updateLocalStuff();
     1053        /* Which is required to continue to the next page: */
     1054        fResult = wizard()->localAppliance().isNotNull();
     1055    }
    10081056
    10091057    /* Return result: */
     
    10931141    /* Update profile: */
    10941142    updateProfile();
     1143}
     1144
     1145void UIWizardExportAppPageBasic2::updateLocalStuff()
     1146{
     1147    /* Create appliance: */
     1148    CAppliance comAppliance;
     1149    refreshLocalStuff(comAppliance, wizard()->machineIDs(), wizard()->uri());
     1150    wizard()->setLocalAppliance(comAppliance);
    10951151}
    10961152
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.h

    r91460 r91539  
    9797    void refreshIncludeISOsCheckBoxAccess(QCheckBox *pCheckBox,
    9898                                          bool fIsFormatCloudOne);
     99    /** Refresh local stuff. */
     100    void refreshLocalStuff(CAppliance &comLocalAppliance,
     101                           const QList<QUuid> &machineIDs,
     102                           const QString &strUri);
    99103
    100104    /** Refresh profile combo. */
     
    189193    /** Updates format. */
    190194    void updateFormat();
     195
     196    /** Update local stuff. */
     197    void updateLocalStuff();
     198
    191199    /** Updates profile. */
    192200    void updateProfile();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp

    r91467 r91539  
    5050
    5151void UIWizardExportAppPage3::refreshApplianceSettingsWidget(UIApplianceExportEditorWidget *pApplianceWidget,
    52                                                             const QList<QUuid> &machineIDs,
    53                                                             const QString &strUri,
     52                                                            const CAppliance &comAppliance,
    5453                                                            bool fIsFormatCloudOne)
    5554{
     
    5857        return;
    5958
    60     /* Acquire appliance: */
    61     CAppliance *pAppliance = pApplianceWidget->init();
    62     if (pAppliance->isOk())
    63     {
    64         /* Iterate over all the selected machine uuids: */
    65         foreach (const QUuid &uMachineId, machineIDs)
    66         {
    67             /* Get the machine with the uMachineId: */
    68             CVirtualBox comVBox = uiCommon().virtualBox();
    69             CMachine comMachine = comVBox.FindMachine(uMachineId.toString());
    70             if (comVBox.isOk() && comMachine.isNotNull())
    71             {
    72                 /* Add the export description to our appliance object: */
    73                 CVirtualSystemDescription comVsd = comMachine.ExportTo(*pAppliance, strUri);
    74                 if (comMachine.isOk() && comVsd.isNotNull())
    75                 {
    76                     /* Add some additional fields the user may change: */
    77                     comVsd.AddDescription(KVirtualSystemDescriptionType_Product, "", "");
    78                     comVsd.AddDescription(KVirtualSystemDescriptionType_ProductUrl, "", "");
    79                     comVsd.AddDescription(KVirtualSystemDescriptionType_Vendor, "", "");
    80                     comVsd.AddDescription(KVirtualSystemDescriptionType_VendorUrl, "", "");
    81                     comVsd.AddDescription(KVirtualSystemDescriptionType_Version, "", "");
    82                     comVsd.AddDescription(KVirtualSystemDescriptionType_License, "", "");
    83                 }
    84                 else
    85                     return msgCenter().cannotExportAppliance(comMachine, pAppliance->GetPath());
    86             }
    87             else
    88                 return msgCenter().cannotFindMachineById(comVBox, uMachineId);
    89         }
    90         /* Make sure the settings widget get the new descriptions: */
    91         pApplianceWidget->populate();
    92     }
     59    /* Sanity check: */
     60    AssertReturnVoid(comAppliance.isNotNull());
     61
     62    /* Make sure the settings widget get the new appliance: */
     63    pApplianceWidget->setAppliance(comAppliance);
    9364}
    9465
     
    10172        return;
    10273
     74    /* Sanity check: */
     75    AssertReturnVoid(comVsdForm.isNotNull());
     76
    10377    /* Make sure the properties table get the new description form: */
    104     if (comVsdForm.isNotNull())
    105         pFormEditor->setVirtualSystemDescriptionForm(comVsdForm);
     78    pFormEditor->setVirtualSystemDescriptionForm(comVsdForm);
    10679}
    10780
     
    208181    refreshStackedWidget(m_pSettingsWidget2, wizard()->isFormatCloudOne());
    209182    /* Refresh corresponding widgets: */
    210     refreshApplianceSettingsWidget(m_pApplianceWidget, wizard()->machineIDs(), wizard()->uri(), wizard()->isFormatCloudOne());
     183    refreshApplianceSettingsWidget(m_pApplianceWidget, wizard()->localAppliance(), wizard()->isFormatCloudOne());
    211184    refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdExportForm(), wizard()->isFormatCloudOne());
    212185
     
    295268        /* Prepare export: */
    296269        m_pApplianceWidget->prepareExport();
    297         wizard()->setLocalAppliance(*m_pApplianceWidget->appliance());
    298270
    299271        /* Try to export appliance: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.h

    r91467 r91539  
    4848    /** Refreshes appliance settings widget. */
    4949    void refreshApplianceSettingsWidget(UIApplianceExportEditorWidget *pApplianceWidget,
    50                                         const QList<QUuid> &machineIDs,
    51                                         const QString &strUri,
     50                                        const CAppliance &comAppliance,
    5251                                        bool fIsFormatCloudOne);
    5352    /** Refreshes form properties table. */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp

    r91467 r91539  
    8585    , m_pApplianceWidget(0)
    8686    , m_pFormEditor(0)
    87     , m_fLaunching(0)
     87    , m_fLaunching(false)
    8888{
    8989    /* Create widgets: */
     
    660660        /* Prepare export: */
    661661        if (fResult)
    662         {
    663662            m_pApplianceWidget->prepareExport();
    664             wizard()->setLocalAppliance(*m_pApplianceWidget->appliance());
    665         }
    666663
    667664        /* Try to export appliance: */
     
    750747    refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne());
    751748
     749    /* Update local stuff: */
     750    updateLocalStuff();
    752751    /* Update cloud stuff: */
    753752    updateCloudStuff();
     
    775774    refreshCloudExportMode(m_exportModeButtons, wizard()->isFormatCloudOne());
    776775
     776    /* Update local stuff: */
     777    updateLocalStuff();
    777778    /* Update profile: */
    778779    updateProfile();
     780}
     781
     782void UIWizardExportAppPageExpert::updateLocalStuff()
     783{
     784    /* Create appliance: */
     785    CAppliance comAppliance;
     786    refreshLocalStuff(comAppliance, wizard()->machineIDs(), wizard()->uri());
     787    wizard()->setLocalAppliance(comAppliance);
    779788}
    780789
     
    815824
    816825    /* Refresh corresponding widgets: */
    817     refreshApplianceSettingsWidget(m_pApplianceWidget, wizard()->machineIDs(), wizard()->uri(), wizard()->isFormatCloudOne());
     826    refreshApplianceSettingsWidget(m_pApplianceWidget, wizard()->localAppliance(), wizard()->isFormatCloudOne());
    818827    refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdExportForm(), wizard()->isFormatCloudOne());
    819828}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.h

    r91467 r91539  
    114114    /** Updates format. */
    115115    void updateFormat();
     116
     117    /** Update local stuff. */
     118    void updateLocalStuff();
     119
    116120    /** Updates profile. */
    117121    void updateProfile();
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