VirtualBox

Changeset 74677 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 8, 2018 12:51:19 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager: Details pane: Full cleanup for UIDetails class.

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

Legend:

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

    r74674 r74677  
    55
    66/*
    7  * Copyright (C) 2012-2017 Oracle Corporation
     7 * Copyright (C) 2012-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3535UIDetails::UIDetails(QWidget *pParent /* = 0 */)
    3636    : QWidget(pParent)
    37     , m_pMainLayout(0)
    3837    , m_pDetailsModel(0)
    3938    , m_pDetailsView(0)
    4039{
    41     /* Prepare layout: */
    42     prepareLayout();
    43 
    44     /* Prepare model: */
    45     prepareModel();
    46 
    47     /* Prepare view: */
    48     prepareView();
    49 
    50     /* Prepare connections: */
    51     prepareConnections();
     40    /* Prepare: */
     41    prepare();
    5242}
    5343
     
    5848}
    5949
    60 void UIDetails::prepareLayout()
     50void UIDetails::prepare()
    6151{
    62     /* Setup main-layout: */
    63     m_pMainLayout = new QVBoxLayout(this);
    64     const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 9;
    65     m_pMainLayout->setContentsMargins(iL, 0, 0, 0);
    66     m_pMainLayout->setSpacing(0);
    67 }
     52    /* Create main-layout: */
     53    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     54    if (pMainLayout)
     55    {
     56        const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 9;
     57        pMainLayout->setContentsMargins(iL, 0, 0, 0);
     58        pMainLayout->setSpacing(0);
    6859
    69 void UIDetails::prepareModel()
    70 {
    71     /* Setup details-model: */
    72     m_pDetailsModel = new UIDetailsModel(this);
    73 }
     60        /* Create details-model: */
     61        m_pDetailsModel = new UIDetailsModel(this);
     62        if (m_pDetailsModel)
     63        {
     64            /* Create details-view: */
     65            m_pDetailsView = new UIDetailsView(this);
     66            if (m_pDetailsView)
     67            {
     68                m_pDetailsView->setScene(m_pDetailsModel->scene());
     69                m_pDetailsView->show();
     70                setFocusProxy(m_pDetailsView);
    7471
    75 void UIDetails::prepareView()
    76 {
    77     /* Setup details-view: */
    78     m_pDetailsView = new UIDetailsView(this);
    79     m_pDetailsView->setScene(m_pDetailsModel->scene());
    80     m_pDetailsView->show();
    81     setFocusProxy(m_pDetailsView);
    82     m_pMainLayout->addWidget(m_pDetailsView);
    83 }
     72                /* Add into layout: */
     73                pMainLayout->addWidget(m_pDetailsView);
     74            }
     75        }
     76    }
    8477
    85 void UIDetails::prepareConnections()
    86 {
    8778    /* Setup details-model connections: */
    88     connect(m_pDetailsModel, SIGNAL(sigRootItemMinimumWidthHintChanged(int)),
    89             m_pDetailsView, SLOT(sltMinimumWidthHintChanged(int)));
    90     connect(m_pDetailsModel, SIGNAL(sigRootItemMinimumHeightHintChanged(int)),
    91             m_pDetailsView, SLOT(sltMinimumHeightHintChanged(int)));
    92     connect(m_pDetailsModel, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),
    93             this, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)));
    94     connect(this, SIGNAL(sigSlidingStarted()),
    95             m_pDetailsModel, SLOT(sltHandleSlidingStarted()));
    96     connect(this, SIGNAL(sigToggleStarted()),
    97             m_pDetailsModel, SLOT(sltHandleToggleStarted()));
    98     connect(this, SIGNAL(sigToggleFinished()),
    99             m_pDetailsModel, SLOT(sltHandleToggleFinished()));
     79    connect(m_pDetailsModel, &UIDetailsModel::sigRootItemMinimumWidthHintChanged,
     80            m_pDetailsView, &UIDetailsView::sltMinimumWidthHintChanged);
     81    connect(m_pDetailsModel, &UIDetailsModel::sigRootItemMinimumHeightHintChanged,
     82            m_pDetailsView, &UIDetailsView::sltMinimumHeightHintChanged);
     83    connect(m_pDetailsModel, &UIDetailsModel::sigLinkClicked,
     84            this, &UIDetails::sigLinkClicked);
     85    connect(this, &UIDetails::sigSlidingStarted,
     86            m_pDetailsModel, &UIDetailsModel::sltHandleSlidingStarted);
     87    connect(this, &UIDetails::sigToggleStarted,
     88            m_pDetailsModel, &UIDetailsModel::sltHandleToggleStarted);
     89    connect(this, &UIDetails::sigToggleFinished,
     90            m_pDetailsModel, &UIDetailsModel::sltHandleToggleFinished);
    10091
    10192    /* Setup details-view connections: */
    102     connect(m_pDetailsView, SIGNAL(sigResized()),
    103             m_pDetailsModel, SLOT(sltHandleViewResize()));
     93    connect(m_pDetailsView, &UIDetailsView::sigResized,
     94            m_pDetailsModel, &UIDetailsModel::sltHandleViewResize);
    10495}
    105 
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetails.h

    r74674 r74677  
    55
    66/*
    7  * Copyright (C) 2012-2017 Oracle Corporation
     7 * Copyright (C) 2012-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UIDetails_h__
    19 #define __UIDetails_h__
     18#ifndef ___UIDetails_h___
     19#define ___UIDetails_h___
    2020
    2121/* Qt includes: */
     
    2424/* Forward declartions: */
    2525class QVBoxLayout;
     26class QWidget;
    2627class UIDetailsModel;
    2728class UIDetailsView;
    2829class UIVirtualMachineItem;
    2930
    30 /* Details widget: */
     31/** QWidget-based Details pane container. */
    3132class UIDetails : public QWidget
    3233{
     
    3536signals:
    3637
    37     /* Notifier: Link processing stuff: */
    38     void sigLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId);
     38    /** Notifies listeners about link click.
     39      * @param  strCategory  Brings link category.
     40      * @param  strControl   Brings control name.
     41      * @param  strId        Brings machine ID. */
     42    void sigLinkClicked(const QString &strCategory,
     43                        const QString &strControl,
     44                        const QString &strId);
    3945
    40     /* Notifier: Sliding stuff: */
     46    /** Notifies listeners about sliding started. */
    4147    void sigSlidingStarted();
    4248
    43     /* Notifiers: Toggle stuff: */
     49    /** Notifies listeners about toggling started. */
    4450    void sigToggleStarted();
     51    /** Notifies listeners about toggling finished. */
    4552    void sigToggleFinished();
    4653
    4754public:
    4855
    49     /* Constructor: */
     56    /** Constructs Details pane passing @a pParent to the base-class. */
    5057    UIDetails(QWidget *pParent = 0);
    5158
     
    5562    UIDetailsView *view() const { return m_pDetailsView; }
    5663
    57     /* API: Current item(s) stuff: */
     64    /** Replaces current model @a items. */
    5865    void setItems(const QList<UIVirtualMachineItem*> &items);
    5966
    6067private:
    6168
    62     /* Helpers: Prepare stuff: */
    63     void prepareLayout();
    64     void prepareModel();
    65     void prepareView();
    66     void prepareConnections();
     69    /** Prepares all. */
     70    void prepare();
    6771
    68     /* Variables: */
    69     QVBoxLayout *m_pMainLayout;
     72    /** Holds the details model instance. */
    7073    UIDetailsModel *m_pDetailsModel;
    71     UIDetailsView *m_pDetailsView;
     74    /** Holds the details view instance. */
     75    UIDetailsView  *m_pDetailsView;
    7276};
    7377
    74 #endif /* __UIDetails_h__ */
    75 
     78#endif /* !___UIDetails_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsModel.cpp

    r74110 r74677  
    117117    /* Relayout: */
    118118    updateLayout();
     119}
     120
     121void UIDetailsModel::sltHandleSlidingStarted()
     122{
     123    m_pRoot->stopBuildingGroup();
     124}
     125
     126void UIDetailsModel::sltHandleToggleStarted()
     127{
     128    m_pRoot->stopBuildingGroup();
     129}
     130
     131void UIDetailsModel::sltHandleToggleFinished()
     132{
     133    m_pRoot->rebuildGroup();
    119134}
    120135
     
    197212}
    198213
    199 void UIDetailsModel::sltHandleSlidingStarted()
    200 {
    201     m_pRoot->stopBuildingGroup();
    202 }
    203 
    204 void UIDetailsModel::sltHandleToggleStarted()
    205 {
    206     m_pRoot->stopBuildingGroup();
    207 }
    208 
    209 void UIDetailsModel::sltHandleToggleFinished()
    210 {
    211     m_pRoot->rebuildGroup();
    212 }
    213 
    214214QVariant UIDetailsModel::data(int iKey) const
    215215{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsModel.h

    r73424 r74677  
    8484    const QMap<DetailsElementType, bool>& settings() const { return m_settings; }
    8585
    86 private slots:
     86public slots:
    8787
    8888    /* Handler: Details-view stuff: */
    8989    void sltHandleViewResize();
     90
     91    /* Handlers: Chooser stuff: */
     92    void sltHandleSlidingStarted();
     93    void sltHandleToggleStarted();
     94    void sltHandleToggleFinished();
     95
     96private slots:
    9097
    9198    /* Handlers: Element-items stuff: */
     
    93100    void sltToggleAnimationFinished(DetailsElementType type, bool fToggled);
    94101    void sltElementTypeToggled();
    95 
    96     /* Handlers: Chooser stuff: */
    97     void sltHandleSlidingStarted();
    98     void sltHandleToggleStarted();
    99     void sltHandleToggleFinished();
    100102
    101103private:
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsView.h

    r73424 r74677  
    4545    UIDetails *details() const { return m_pDetails; }
    4646
    47 private slots:
     47public slots:
    4848
    4949    /* Handlers: Size-hint 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