VirtualBox

Changeset 74039 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Sep 3, 2018 10:22:39 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Large cleanup for UIDetailsItem, doxygen + style fixes.

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

Legend:

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

    r73424 r74039  
    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
     
    2323# include <QAccessibleObject>
    2424# include <QApplication>
     25# include <QGraphicsScene>
    2526# include <QPainter>
    26 # include <QGraphicsScene>
    2727# include <QStyleOptionGraphicsItem>
    2828
    2929/* GUI includes: */
    3030# include "UIGraphicsTextPane.h"
     31# include "UIDetails.h"
     32# include "UIDetailsElement.h"
    3133# include "UIDetailsGroup.h"
     34# include "UIDetailsModel.h"
    3235# include "UIDetailsSet.h"
    33 # include "UIDetailsElement.h"
    34 # include "UIDetailsModel.h"
    3536# include "UIDetailsView.h"
    36 # include "UIDetails.h"
    3737
    3838#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    193193
    194194
     195/*********************************************************************************************************************************
     196*   Class UIDetailsItem implementation.                                                                                          *
     197*********************************************************************************************************************************/
     198
    195199UIDetailsItem::UIDetailsItem(UIDetailsItem *pParent)
    196200    : QIWithRetranslateUI4<QIGraphicsWidget>(pParent)
     
    214218
    215219    /* Setup connections: */
    216     connect(this, SIGNAL(sigBuildStep(QString, int)),
    217             this, SLOT(sltBuildStep(QString, int)), Qt::QueuedConnection);
    218 }
    219 
    220 UIDetailsGroup* UIDetailsItem::toGroup()
     220    connect(this, &UIDetailsItem::sigBuildStep,
     221            this, &UIDetailsItem::sltBuildStep,
     222            Qt::QueuedConnection);
     223}
     224
     225UIDetailsGroup *UIDetailsItem::toGroup()
    221226{
    222227    UIDetailsGroup *pItem = qgraphicsitem_cast<UIDetailsGroup*>(this);
     
    225230}
    226231
    227 UIDetailsSet* UIDetailsItem::toSet()
     232UIDetailsSet *UIDetailsItem::toSet()
    228233{
    229234    UIDetailsSet *pItem = qgraphicsitem_cast<UIDetailsSet*>(this);
     
    232237}
    233238
    234 UIDetailsElement* UIDetailsItem::toElement()
     239UIDetailsElement *UIDetailsItem::toElement()
    235240{
    236241    UIDetailsElement *pItem = qgraphicsitem_cast<UIDetailsElement*>(this);
     
    239244}
    240245
    241 UIDetailsModel* UIDetailsItem::model() const
     246UIDetailsModel *UIDetailsItem::model() const
    242247{
    243248    UIDetailsModel *pModel = qobject_cast<UIDetailsModel*>(QIGraphicsWidget::scene()->parent());
    244249    AssertMsg(pModel, ("Incorrect graphics scene parent set!"));
    245250    return pModel;
    246 }
    247 
    248 UIDetailsItem* UIDetailsItem::parentItem() const
    249 {
    250     return m_pParent;
    251251}
    252252
     
    278278/* static */
    279279void UIDetailsItem::configurePainterShape(QPainter *pPainter,
    280                                            const QStyleOptionGraphicsItem *pOption,
    281                                            int iRadius)
     280                                          const QStyleOptionGraphicsItem *pOptions,
     281                                          int iRadius)
    282282{
    283283    /* Rounded corners? */
     
    286286        /* Setup clipping: */
    287287        QPainterPath roundedPath;
    288         roundedPath.addRoundedRect(pOption->rect, iRadius, iRadius);
     288        roundedPath.addRoundedRect(pOptions->rect, iRadius, iRadius);
    289289        pPainter->setRenderHint(QPainter::Antialiasing);
    290290        pPainter->setClipPath(roundedPath);
     
    314314/* static */
    315315void UIDetailsItem::paintText(QPainter *pPainter, QPoint point,
    316                                const QFont &font, QPaintDevice *pPaintDevice,
    317                                const QString &strText, const QColor &color)
     316                              const QFont &font, QPaintDevice *pPaintDevice,
     317                              const QString &strText, const QColor &color)
    318318{
    319319    /* Prepare variables: */
     
    329329}
    330330
     331
     332/*********************************************************************************************************************************
     333*   Class UIPrepareStep implementation.                                                                                          *
     334*********************************************************************************************************************************/
     335
    331336UIPrepareStep::UIPrepareStep(QObject *pParent, QObject *pBuildObject, const QString &strStepId, int iStepNumber)
    332337    : QObject(pParent)
     
    334339    , m_iStepNumber(iStepNumber)
    335340{
    336     /* Prepare connections: */
    337     connect(pBuildObject, SIGNAL(sigBuildDone()), this, SLOT(sltStepDone()), Qt::QueuedConnection);
    338     connect(this, SIGNAL(sigStepDone(QString, int)), pParent, SLOT(sltBuildStep(QString, int)), Qt::QueuedConnection);
     341    /* Prepare connections (old style, polymorph): */
     342    connect(pBuildObject, SIGNAL(sigBuildDone()),
     343            this, SLOT(sltStepDone()),
     344            Qt::QueuedConnection);
     345    connect(this, SIGNAL(sigStepDone(QString, int)),
     346            pParent, SLOT(sltBuildStep(QString, int)),
     347            Qt::QueuedConnection);
    339348}
    340349
     
    343352    emit sigStepDone(m_strStepId, m_iStepNumber);
    344353}
    345 
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsItem.h

    r73424 r74039  
    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 __UIDetailsItem_h__
    19 #define __UIDetailsItem_h__
     18#ifndef ___UIDetailsItem_h___
     19#define ___UIDetailsItem_h___
    2020
    2121/* GUI includes: */
     
    2424
    2525/* Forward declaration: */
    26 class UIDetailsModel;
    2726class QGraphicsSceneHoverEvent;
    2827class QGraphicsSceneMouseEvent;
     28class UIDetailsElement;
    2929class UIDetailsGroup;
     30class UIDetailsModel;
    3031class UIDetailsSet;
    31 class UIDetailsElement;
    3232
    33 /* UIDetailsItem types: */
     33
     34/** UIDetailsItem types. */
    3435enum UIDetailsItemType
    3536{
    3637    UIDetailsItemType_Any     = QGraphicsItem::UserType,
    37     UIDetailsItemType_Group   = QGraphicsItem::UserType + 1,
    38     UIDetailsItemType_Set     = QGraphicsItem::UserType + 2,
    39     UIDetailsItemType_Element = QGraphicsItem::UserType + 3,
    40     UIDetailsItemType_Preview = QGraphicsItem::UserType + 10
     38    UIDetailsItemType_Group,
     39    UIDetailsItemType_Set,
     40    UIDetailsItemType_Element,
     41    UIDetailsItemType_Preview
    4142};
    4243
    43 /* Details item interface
    44  * for graphics details model/view architecture: */
     44
     45/** QIGraphicsWidget extension used as interface
     46  * for graphics details model/view architecture. */
    4547class UIDetailsItem : public QIWithRetranslateUI4<QIGraphicsWidget>
    4648{
     
    4951signals:
    5052
    51     /* Notifiers: Build stuff: */
    52     void sigBuildStep(QString strStepId, int iStepNumber);
    53     void sigBuildDone();
     53    /** @name Item stuff.
     54      * @{ */
     55        /** Notifies listeners about step build should be started.
     56          * @param  strStepId    Brings the step ID.
     57          * @param  iStepNumber  Brings the step number. */
     58        void sigBuildStep(QString strStepId, int iStepNumber);
     59        /** Notifies listeners about step build complete. */
     60        void sigBuildDone();
     61    /** @} */
    5462
    5563public:
    5664
    57     /* Constructor: */
     65    /** Constructs item passing @a pParent to the base-class. */
    5866    UIDetailsItem(UIDetailsItem *pParent);
    5967
    60     /* API: Cast stuff: */
    61     UIDetailsGroup* toGroup();
    62     UIDetailsSet* toSet();
    63     UIDetailsElement* toElement();
     68    /** @name Item stuff.
     69      * @{ */
     70        /** Returns parent  reference. */
     71        UIDetailsItem *parentItem() const { return m_pParent; }
    6472
    65     /* API: Model stuff: */
    66     UIDetailsModel* model() const;
     73        /** Casts item to group one. */
     74        UIDetailsGroup *toGroup();
     75        /** Casts item to set one. */
     76        UIDetailsSet *toSet();
     77        /** Casts item to element one. */
     78        UIDetailsElement *toElement();
    6779
    68     /* API: Parent stuff: */
    69     UIDetailsItem* parentItem() const;
     80        /** Returns model reference. */
     81        UIDetailsModel *model() const;
    7082
    71     /** Returns the description of the item. */
    72     virtual QString description() const = 0;
     83        /** Returns the description of the item. */
     84        virtual QString description() const = 0;
     85    /** @} */
    7386
    74     /* API: Children stuff: */
    75     virtual void addItem(UIDetailsItem *pItem) = 0;
    76     virtual void removeItem(UIDetailsItem *pItem) = 0;
    77     virtual QList<UIDetailsItem*> items(UIDetailsItemType type = UIDetailsItemType_Any) const = 0;
    78     virtual bool hasItems(UIDetailsItemType type = UIDetailsItemType_Any) const = 0;
    79     virtual void clearItems(UIDetailsItemType type = UIDetailsItemType_Any) = 0;
     87    /** @name Children stuff.
     88      * @{ */
     89        /** Adds child @a pItem. */
     90        virtual void addItem(UIDetailsItem *pItem) = 0;
     91        /** Removes child @a pItem. */
     92        virtual void removeItem(UIDetailsItem *pItem) = 0;
    8093
    81     /* API: Layout stuff: */
    82     void updateGeometry();
    83     virtual int minimumWidthHint() const = 0;
    84     virtual int minimumHeightHint() const = 0;
    85     QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
    86     virtual void updateLayout() = 0;
     94        /** Returns children items of certain @a enmType. */
     95        virtual QList<UIDetailsItem*> items(UIDetailsItemType enmType = UIDetailsItemType_Any) const = 0;
     96        /** Returns whether there are children items of certain @a enmType. */
     97        virtual bool hasItems(UIDetailsItemType enmType = UIDetailsItemType_Any) const = 0;
     98        /** Clears children items of certain @a enmType. */
     99        virtual void clearItems(UIDetailsItemType enmType = UIDetailsItemType_Any) = 0;
     100    /** @} */
     101
     102    /** @name Layout stuff.
     103      * @{ */
     104        /** Updates geometry. */
     105        void updateGeometry();
     106
     107        /** Updates layout. */
     108        virtual void updateLayout() = 0;
     109
     110        /** Returns minimum width-hint. */
     111        virtual int minimumWidthHint() const = 0;
     112        /** Returns minimum height-hint. */
     113        virtual int minimumHeightHint() const = 0;
     114
     115        /** Returns size-hint.
     116          * @param  enmWhich    Brings size-hint type.
     117          * @param  constraint  Brings size constraint. */
     118        QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const;
     119    /** @} */
    87120
    88121protected slots:
    89122
    90     /* Handler: Build stuff: */
     123    /** @name Item stuff.
     124      * @{ */
     125        /** Handles request about starting step build.
     126          * @param  strStepId    Brings the step ID.
     127          * @param  iStepNumber  Brings the step number. */
     128    /** @} */
    91129    virtual void sltBuildStep(QString strStepId, int iStepNumber);
    92130
    93131protected:
    94132
    95     /* Helper: Translate stuff: */
    96     void retranslateUi() {}
     133    /** @name Event-handling stuff.
     134      * @{ */
     135        /** Handles translation event. */
     136        virtual void retranslateUi() /* override */ {}
     137    /** @} */
    97138
    98     /* Helpers: Paint stuff: */
    99     static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius);
    100     static void paintFrameRect(QPainter *pPainter, const QRect &rect, int iRadius);
    101     static void paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap);
    102     static void paintText(QPainter *pPainter, QPoint point,
    103                           const QFont &font, QPaintDevice *pPaintDevice,
    104                           const QString &strText, const QColor &color);
     139    /** @name Painting stuff.
     140      * @{ */
     141        /** Configures painting shape using passed @a pPainter, @a pOptions and spified @a iRadius. */
     142        static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, int iRadius);
     143        /** Paints frame @a rect using passed @a pPainter and spified @a iRadius. */
     144        static void paintFrameRect(QPainter *pPainter, const QRect &rect, int iRadius);
     145        /** Paints @a pixmap using passed @a pPainter and spified @a rect. */
     146        static void paintPixmap(QPainter *pPainter, const QRect &rect, const QPixmap &pixmap);
     147        /** Paints @a strText using passed @a pPainter, @a font, @a color, @a pPaintDevice and spified @a point. */
     148        static void paintText(QPainter *pPainter, QPoint point,
     149                              const QFont &font, QPaintDevice *pPaintDevice,
     150                              const QString &strText, const QColor &color);
     151    /** @} */
    105152
    106153private:
    107154
    108     /* Variables: */
     155    /** Holds the parent item reference. */
    109156    UIDetailsItem *m_pParent;
    110157};
    111158
    112 /* Allows to build item content synchronously: */
     159
     160/** QObject extension used to prepare details steps. */
    113161class UIPrepareStep : public QObject
    114162{
     
    117165signals:
    118166
    119     /* Notifier: Build stuff: */
     167    /** Notifies listeners about step preparing is complete.
     168      * @param  strStepId    Brings the step ID.
     169      * @param  iStepNumber  Brings the step number. */
    120170    void sigStepDone(QString strStepId, int iStepNumber);
    121171
    122172public:
    123173
    124     /* Constructor: */
     174    /** Constructs step preparing object passing @a pParent to the base-class.
     175      * @param  pBuildObject  Brings the build object reference.
     176      * @param  strStepId     Brings the step ID.
     177      * @param  iStepNumber   Brings the step number.*/
    125178    UIPrepareStep(QObject *pParent, QObject *pBuildObject, const QString &strStepId, int iStepNumber);
    126179
    127180private slots:
    128181
    129     /* Handler: Build stuff: */
     182    /** Handles step prepare completion. */
    130183    void sltStepDone();
    131184
    132185private:
    133186
    134     /* Variables: */
    135     QString m_strStepId;
    136     int m_iStepNumber;
     187    /** Holds the step ID. */
     188    QString  m_strStepId;
     189    /** Holds the step number. */
     190    int      m_iStepNumber;
    137191};
    138192
    139 #endif /* __UIDetailsItem_h__ */
    140193
     194#endif /* !___UIDetailsItem_h___ */
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