VirtualBox

Changeset 88506 in vbox


Ignore:
Timestamp:
Apr 14, 2021 12:51:11 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8161: A bit of refactoring for Details pane; Mostly proper prepare/cleanup cascade; This is necessary for shutdown procedure.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/details
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetails.cpp

    r87103 r88506  
    55
    66/*
    7  * Copyright (C) 2012-2020 Oracle Corporation
     7 * Copyright (C) 2012-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2929UIDetails::UIDetails(QWidget *pParent /* = 0 */)
    3030    : QWidget(pParent)
     31    , m_pMainLayout(0)
    3132    , m_pDetailsModel(0)
    3233    , m_pDetailsView(0)
    3334{
    34     /* Prepare: */
    3535    prepare();
    3636}
     
    4444void UIDetails::prepare()
    4545{
    46     /* Create main-layout: */
    47     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    48     if (pMainLayout)
     46    /* Prepare everything: */
     47    prepareContents();
     48    prepareConnections();
     49
     50    /* Configure context-sensitive help: */
     51    uiCommon().setHelpKeyword(this, "vm-details-tool");
     52
     53    /* Init model finally: */
     54    initModel();
     55}
     56
     57void UIDetails::prepareContents()
     58{
     59    /* Prepare main-layout: */
     60    m_pMainLayout = new QVBoxLayout(this);
     61    if (m_pMainLayout)
    4962    {
    50         pMainLayout->setContentsMargins(0, 0, 0, 0);
    51         pMainLayout->setSpacing(0);
     63        m_pMainLayout->setContentsMargins(0, 0, 0, 0);
     64        m_pMainLayout->setSpacing(0);
    5265
    53         /* Create details-model: */
    54         m_pDetailsModel = new UIDetailsModel(this);
    55         if (m_pDetailsModel)
    56         {
    57             /* Create details-view: */
    58             m_pDetailsView = new UIDetailsView(this);
    59             if (m_pDetailsView)
    60             {
    61                 m_pDetailsView->setScene(m_pDetailsModel->scene());
    62                 m_pDetailsView->show();
    63                 setFocusProxy(m_pDetailsView);
     66        /* Prepare model: */
     67        prepareModel();
     68    }
     69}
    6470
    65                 /* Add into layout: */
    66                 pMainLayout->addWidget(m_pDetailsView);
    67             }
     71void UIDetails::prepareModel()
     72{
     73    /* Prepare model: */
     74    m_pDetailsModel = new UIDetailsModel(this);
     75    if (m_pDetailsModel)
     76        prepareView();
     77}
    6878
    69             /* Init model: */
    70             m_pDetailsModel->init();
    71         }
     79void UIDetails::prepareView()
     80{
     81    AssertPtrReturnVoid(m_pDetailsModel);
     82    AssertPtrReturnVoid(m_pMainLayout);
     83
     84    /* Prepare view: */
     85    m_pDetailsView = new UIDetailsView(this);
     86    if (m_pDetailsView)
     87    {
     88        m_pDetailsView->setScene(m_pDetailsModel->scene());
     89        m_pDetailsView->show();
     90        setFocusProxy(m_pDetailsView);
     91
     92        /* Add into layout: */
     93        m_pMainLayout->addWidget(m_pDetailsView);
    7294    }
     95}
    7396
     97void UIDetails::prepareConnections()
     98{
    7499    /* Extra-data events connections: */
    75100    connect(gEDataManager, &UIExtraDataManager::sigDetailsCategoriesChange,
     
    78103            m_pDetailsModel, &UIDetailsModel::sltHandleExtraDataOptionsChange);
    79104
    80     /* Setup details-model connections: */
     105    /* Model connections: */
    81106    connect(m_pDetailsModel, &UIDetailsModel::sigRootItemMinimumWidthHintChanged,
    82107            m_pDetailsView, &UIDetailsView::sltMinimumWidthHintChanged);
     
    88113            m_pDetailsModel, &UIDetailsModel::sltHandleToggleFinished);
    89114
    90     /* Setup details-view connections: */
     115    /* View connections: */
    91116    connect(m_pDetailsView, &UIDetailsView::sigResized,
    92117            m_pDetailsModel, &UIDetailsModel::sltHandleViewResize);
     118}
    93119
    94     /* For context sensitive help: */
    95     uiCommon().setHelpKeyword(this, "vm-details-tool");
     120void UIDetails::initModel()
     121{
     122    m_pDetailsModel->init();
    96123}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetails.h

    r82968 r88506  
    55
    66/*
    7  * Copyright (C) 2012-2020 Oracle Corporation
     7 * Copyright (C) 2012-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2727/* Forward declartions: */
    2828class QString;
     29class QVBoxLayout;
    2930class UIDetailsModel;
    3031class UIDetailsView;
     
    3839signals:
    3940
    40     /** Notifies listeners about link click.
    41       * @param  strCategory  Brings link category.
    42       * @param  strControl   Brings control name.
    43       * @param  uId        Brings machine ID. */
    44     void sigLinkClicked(const QString &strCategory,
    45                         const QString &strControl,
    46                         const QUuid &uId);
    47 
    48     /** Notifies listeners about toggling started. */
    49     void sigToggleStarted();
    50     /** Notifies listeners about toggling finished. */
    51     void sigToggleFinished();
     41    /** @name General stuff.
     42      * @{ */
     43        /** Notifies listeners about link click.
     44          * @param  strCategory  Brings link category.
     45          * @param  strControl   Brings control name.
     46          * @param  uId        Brings machine ID. */
     47        void sigLinkClicked(const QString &strCategory,
     48                            const QString &strControl,
     49                            const QUuid &uId);
     50   
     51        /** Notifies listeners about toggling started. */
     52        void sigToggleStarted();
     53        /** Notifies listeners about toggling finished. */
     54        void sigToggleFinished();
     55    /** @} */
    5256
    5357public:
     
    5559    /** Constructs Details pane passing @a pParent to the base-class. */
    5660    UIDetails(QWidget *pParent = 0);
    57 
    58     /** Return the Details-model instance. */
    59     UIDetailsModel *model() const { return m_pDetailsModel; }
    60     /** Return the Details-view instance. */
    61     UIDetailsView *view() const { return m_pDetailsView; }
    62 
    63     /** Replaces current model @a items. */
    64     void setItems(const QList<UIVirtualMachineItem*> &items);
     61   
     62    /** @name General stuff.
     63      * @{ */
     64        /** Return the Details-model instance. */
     65        UIDetailsModel *model() const { return m_pDetailsModel; }
     66        /** Return the Details-view instance. */
     67        UIDetailsView *view() const { return m_pDetailsView; }
     68   
     69        /** Replaces current model @a items. */
     70        void setItems(const QList<UIVirtualMachineItem*> &items);
     71    /** @} */
    6572
    6673private:
    6774
    68     /** Prepares all. */
    69     void prepare();
     75    /** @name Prepare/Cleanup cascade.
     76      * @{ */
     77        /** Prepares all. */
     78        void prepare();
     79        /** Prepares contents. */
     80        void prepareContents();
     81        /** Prepares model. */
     82        void prepareModel();
     83        /** Prepares view. */
     84        void prepareView();
     85        /** Prepares connections. */
     86        void prepareConnections();
     87        /** Inits model. */
     88        void initModel();
     89    /** @} */
    7090
    71     /** Holds the details model instance. */
    72     UIDetailsModel *m_pDetailsModel;
    73     /** Holds the details view instance. */
    74     UIDetailsView  *m_pDetailsView;
     91    /** @name General stuff.
     92      * @{ */
     93        /** Holds the main layout instance. */
     94        QVBoxLayout    *m_pMainLayout;
     95        /** Holds the details model instance. */
     96        UIDetailsModel *m_pDetailsModel;
     97        /** Holds the details view instance. */
     98        UIDetailsView  *m_pDetailsView;
     99    /** @} */
    75100};
    76101
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