VirtualBox

Changeset 91538 in vbox for trunk/src/VBox


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

FE/Qt: bugref:9996: Large cleanup for UIApplianceExportEditorWidget.

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

Legend:

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

    r91537 r91538  
    2929
    3030
    31 ////////////////////////////////////////////////////////////////////////////////
    32 // ExportSortProxyModel
     31/*********************************************************************************************************************************
     32*   Class ExportSortProxyModel implementation.                                                                                   *
     33*********************************************************************************************************************************/
    3334
    3435class ExportSortProxyModel: public UIApplianceSortProxyModel
    3536{
    3637public:
    37     ExportSortProxyModel(QObject *pParent = NULL)
    38       : UIApplianceSortProxyModel(pParent)
     38
     39    ExportSortProxyModel(QObject *pParent = 0)
     40        : UIApplianceSortProxyModel(pParent)
    3941    {
    4042        m_aFilteredList
     
    5557};
    5658
    57 ////////////////////////////////////////////////////////////////////////////////
    58 // UIApplianceExportEditorWidget
    5959
    60 UIApplianceExportEditorWidget::UIApplianceExportEditorWidget(QWidget *pParent /* = NULL */)
    61   : UIApplianceEditorWidget(pParent)
     60/*********************************************************************************************************************************
     61*   Class UIApplianceExportEditorWidget implementation.                                                                          *
     62*********************************************************************************************************************************/
     63
     64UIApplianceExportEditorWidget::UIApplianceExportEditorWidget(QWidget *pParent /* = 0 */)
     65    : UIApplianceEditorWidget(pParent)
    6266{
    6367}
    6468
    65 CAppliance* UIApplianceExportEditorWidget::init()
     69CAppliance *UIApplianceExportEditorWidget::init()
    6670{
    6771    if (m_pAppliance)
    6872        delete m_pAppliance;
    69     CVirtualBox vbox = uiCommon().virtualBox();
    70     /* Create a appliance object */
    71     m_pAppliance = new CAppliance(vbox.CreateAppliance());
    72 //    bool fResult = m_pAppliance->isOk();
     73    CVirtualBox comVBox = uiCommon().virtualBox();
     74    /* Create a appliance object: */
     75    m_pAppliance = new CAppliance(comVBox.CreateAppliance());
    7376    return m_pAppliance;
    7477}
     
    7679void UIApplianceExportEditorWidget::populate()
    7780{
     81    /* Cleanup previous stuff: */
    7882    if (m_pModel)
    7983        delete m_pModel;
    8084
     85    /* Prepare model: */
    8186    QVector<CVirtualSystemDescription> vsds = m_pAppliance->GetVirtualSystemDescriptions();
     87    m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
     88    if (m_pModel)
     89    {
     90        m_pModel->setVsdHints(m_listVsdHints);
    8291
    83     m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
    84     m_pModel->setVsdHints(m_listVsdHints);
     92        /* Create proxy model: */
     93        ExportSortProxyModel *pProxy = new ExportSortProxyModel(m_pModel);
     94        if (pProxy)
     95        {
     96            pProxy->setSourceModel(m_pModel);
     97            pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
    8598
    86     ExportSortProxyModel *pProxy = new ExportSortProxyModel(this);
    87     pProxy->setSourceModel(m_pModel);
    88     pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
     99            /* Set our own model: */
     100            m_pTreeViewSettings->setModel(pProxy);
     101            /* Set our own delegate: */
     102            UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy);
     103            if (pDelegate)
     104                m_pTreeViewSettings->setItemDelegate(pDelegate);
    89105
    90     UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy);
     106            /* For now we hide the original column. This data is displayed as tooltip also. */
     107            m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true);
     108            m_pTreeViewSettings->expandAll();
     109            /* Set model root index and make it current: */
     110            m_pTreeViewSettings->setRootIndex(pProxy->mapFromSource(m_pModel->root()));
     111            m_pTreeViewSettings->setCurrentIndex(pProxy->mapFromSource(m_pModel->root()));
     112        }
     113    }
    91114
    92     /* Set our own model */
    93     m_pTreeViewSettings->setModel(pProxy);
    94     /* Set our own delegate */
    95     m_pTreeViewSettings->setItemDelegate(pDelegate);
    96     /* For now we hide the original column. This data is displayed as tooltip
    97        also. */
    98     m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true);
    99     m_pTreeViewSettings->expandAll();
    100     /* Set model root index and make it current: */
    101     m_pTreeViewSettings->setRootIndex(pProxy->mapFromSource(m_pModel->root()));
    102     m_pTreeViewSettings->setCurrentIndex(pProxy->mapFromSource(m_pModel->root()));
    103 
    104     /* Check for warnings & if there are one display them. */
    105     bool fWarningsEnabled = false;
    106     QVector<QString> warnings = m_pAppliance->GetWarnings();
    107     if (warnings.size() > 0)
    108     {
    109         foreach (const QString& text, warnings)
    110             m_pTextEditWarning->append("- " + text);
    111         fWarningsEnabled = true;
    112     }
     115    /* Check for warnings & if there are one display them: */
     116    const QVector<QString> warnings = m_pAppliance->GetWarnings();
     117    const bool fWarningsEnabled = warnings.size() > 0;
     118    foreach (const QString &strText, warnings)
     119        m_pTextEditWarning->append("- " + strText);
    113120    m_pPaneWarning->setVisible(fWarningsEnabled);
    114121}
     
    119126        m_pModel->putBack();
    120127}
    121 
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceExportEditorWidget.h

    r82968 r91538  
    55
    66/*
    7  * Copyright (C) 2009-2020 Oracle Corporation
     7 * Copyright (C) 2009-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2525#include "UIApplianceEditorWidget.h"
    2626
     27/* Forward declarations: */
     28class CAppliance;
     29
     30/** UIApplianceEditorWidget subclass for Export Appliance wizard. */
    2731class UIApplianceExportEditorWidget: public UIApplianceEditorWidget
    2832{
     
    3034
    3135public:
    32     UIApplianceExportEditorWidget(QWidget *pParent = NULL);
    3336
     37    /** Constructs widget passing @a pParent to the base-class. */
     38    UIApplianceExportEditorWidget(QWidget *pParent = 0);
     39
     40    /** Inits the widget by creating appliance instance. */
    3441    CAppliance *init();
    3542
     43    /** Populates widget contents. */
    3644    void populate();
     45
     46    /** Prepares export by pushing edited data back to appliance. */
    3747    void prepareExport();
    3848};
    3949
    4050#endif /* !FEQT_INCLUDED_SRC_widgets_UIApplianceExportEditorWidget_h */
    41 
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