VirtualBox

Changeset 73927 in vbox


Ignore:
Timestamp:
Aug 28, 2018 11:40:48 AM (6 years ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp

    r73600 r73927  
    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
     
    195195
    196196
     197/*********************************************************************************************************************************
     198*   Class UIChooserItem implementation.                                                                                          *
     199*********************************************************************************************************************************/
     200
    197201UIChooserItem::UIChooserItem(UIChooserItem *pParent, bool fTemporary)
    198     : m_fRoot(!pParent)
     202    : m_pParent(pParent)
    199203    , m_fTemporary(fTemporary)
    200     , m_pParent(pParent)
    201     , m_iPreviousMinimumWidthHint(0)
    202     , m_iPreviousMinimumHeightHint(0)
    203     , m_dragTokenPlace(DragToken_Off)
     204    , m_fRoot(!pParent)
    204205    , m_fHovered(false)
    205206    , m_pHighlightMachine(0)
     
    210211    , m_iHighlightDarkness(90)
    211212    , m_iAnimationDarkness(m_iDefaultDarkness)
     213    , m_iPreviousMinimumWidthHint(0)
     214    , m_iPreviousMinimumHeightHint(0)
     215    , m_enmDragTokenPlace(DragToken_Off)
    212216    , m_iDragTokenDarkness(110)
    213217{
     
    259263}
    260264
    261 UIChooserItemGroup* UIChooserItem::toGroupItem()
     265UIChooserItemGroup *UIChooserItem::toGroupItem()
    262266{
    263267    UIChooserItemGroup *pItem = qgraphicsitem_cast<UIChooserItemGroup*>(this);
     
    266270}
    267271
    268 UIChooserItemGlobal* UIChooserItem::toGlobalItem()
     272UIChooserItemGlobal *UIChooserItem::toGlobalItem()
    269273{
    270274    UIChooserItemGlobal *pItem = qgraphicsitem_cast<UIChooserItemGlobal*>(this);
     
    273277}
    274278
    275 UIChooserItemMachine* UIChooserItem::toMachineItem()
     279UIChooserItemMachine *UIChooserItem::toMachineItem()
    276280{
    277281    UIChooserItemMachine *pItem = qgraphicsitem_cast<UIChooserItemMachine*>(this);
     
    280284}
    281285
    282 UIChooserModel* UIChooserItem::model() const
     286UIChooserModel *UIChooserItem::model() const
    283287{
    284288    UIChooserModel *pModel = qobject_cast<UIChooserModel*>(QIGraphicsWidget::scene()->parent());
     
    287291}
    288292
    289 UIActionPool* UIChooserItem::actionPool() const
     293UIActionPool *UIChooserItem::actionPool() const
    290294{
    291295    return model()->actionPool();
    292 }
    293 
    294 UIChooserItem* UIChooserItem::parentItem() const
    295 {
    296     return m_pParent;
    297296}
    298297
     
    318317{
    319318    return m_fRoot;
    320 }
    321 
    322 bool UIChooserItem::isHovered() const
    323 {
    324     return m_fHovered;
    325319}
    326320
     
    334328}
    335329
     330bool UIChooserItem::isHovered() const
     331{
     332    return m_fHovered;
     333}
     334
    336335void UIChooserItem::updateGeometry()
    337336{
     
    382381}
    383382
    384 void UIChooserItem::setDragTokenPlace(DragToken where)
     383void UIChooserItem::setDragTokenPlace(DragToken enmPlace)
    385384{
    386385    /* Something changed? */
    387     if (m_dragTokenPlace != where)
    388     {
    389         m_dragTokenPlace = where;
     386    if (m_enmDragTokenPlace != enmPlace)
     387    {
     388        m_enmDragTokenPlace = enmPlace;
    390389        update();
    391390    }
     
    394393DragToken UIChooserItem::dragTokenPlace() const
    395394{
    396     return m_dragTokenPlace;
    397 }
    398 
    399 
    400 bool UIChooserItem::isTemporary() const
    401 {
    402     return m_fTemporary;
    403 }
    404 
    405 void UIChooserItem::hoverMoveEvent(QGraphicsSceneHoverEvent*)
     395    return m_enmDragTokenPlace;
     396}
     397
     398void UIChooserItem::hoverMoveEvent(QGraphicsSceneHoverEvent *)
    406399{
    407400    if (!m_fHovered)
     
    413406}
    414407
    415 void UIChooserItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*)
     408void UIChooserItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
    416409{
    417410    if (m_fHovered)
     
    478471}
    479472
    480 void UIChooserItem::dragLeaveEvent(QGraphicsSceneDragDropEvent*)
     473void UIChooserItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *)
    481474{
    482475    resetDragToken();
     
    511504        m_iPreviousMinimumHeightHint = 0;
    512505    }
    513 }
    514 
    515 /* static */
    516 void UIChooserItem::configurePainterShape(QPainter *pPainter,
    517                                            const QStyleOptionGraphicsItem *pOption,
    518                                            int iRadius)
    519 {
    520     /* Rounded corners? */
    521     if (iRadius)
    522     {
    523         /* Setup clipping: */
    524         QPainterPath roundedPath;
    525         roundedPath.addRoundedRect(pOption->rect, iRadius, iRadius);
    526         pPainter->setClipPath(roundedPath);
    527     }
    528 }
    529 
    530 /* static */
    531 void UIChooserItem::paintFrameRect(QPainter *pPainter, const QRect &rect, bool fIsSelected, int iRadius)
    532 {
    533     pPainter->save();
    534     QPalette pal = QApplication::palette();
    535     QColor base = pal.color(QPalette::Active, fIsSelected ? QPalette::Highlight : QPalette::Window);
    536     pPainter->setPen(base.darker(160));
    537     if (iRadius)
    538         pPainter->drawRoundedRect(rect, iRadius, iRadius);
    539     else
    540         pPainter->drawRect(rect);
    541     pPainter->restore();
    542 }
    543 
    544 /* static */
    545 void UIChooserItem::paintPixmap(QPainter *pPainter, const QPoint &point, const QPixmap &pixmap)
    546 {
    547     pPainter->drawPixmap(point, pixmap);
    548 }
    549 
    550 /* static */
    551 void UIChooserItem::paintText(QPainter *pPainter, QPoint point,
    552                                const QFont &font, QPaintDevice *pPaintDevice,
    553                                const QString &strText)
    554 {
    555     /* Prepare variables: */
    556     QFontMetrics fm(font, pPaintDevice);
    557     point += QPoint(0, fm.ascent());
    558 
    559     /* Draw text: */
    560     pPainter->save();
    561     pPainter->setFont(font);
    562     pPainter->drawText(point, strText);
    563     pPainter->restore();
    564506}
    565507
     
    606548}
    607549
     550/* static */
     551void UIChooserItem::configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius)
     552{
     553    /* Rounded corners? */
     554    if (iRadius)
     555    {
     556        /* Setup clipping: */
     557        QPainterPath roundedPath;
     558        roundedPath.addRoundedRect(pOption->rect, iRadius, iRadius);
     559        pPainter->setClipPath(roundedPath);
     560    }
     561}
     562
     563/* static */
     564void UIChooserItem::paintFrameRect(QPainter *pPainter, bool fIsSelected, int iRadius,
     565                                   const QRect &rectangle)
     566{
     567    pPainter->save();
     568    QPalette pal = QApplication::palette();
     569    QColor base = pal.color(QPalette::Active, fIsSelected ? QPalette::Highlight : QPalette::Window);
     570    pPainter->setPen(base.darker(160));
     571    if (iRadius)
     572        pPainter->drawRoundedRect(rectangle, iRadius, iRadius);
     573    else
     574        pPainter->drawRect(rectangle);
     575    pPainter->restore();
     576}
     577
     578/* static */
     579void UIChooserItem::paintPixmap(QPainter *pPainter, const QPoint &point,
     580                                const QPixmap &pixmap)
     581{
     582    pPainter->drawPixmap(point, pixmap);
     583}
     584
     585/* static */
     586void UIChooserItem::paintText(QPainter *pPainter, QPoint point,
     587                              const QFont &font, QPaintDevice *pPaintDevice,
     588                              const QString &strText)
     589{
     590    /* Prepare variables: */
     591    QFontMetrics fm(font, pPaintDevice);
     592    point += QPoint(0, fm.ascent());
     593
     594    /* Draw text: */
     595    pPainter->save();
     596    pPainter->setFont(font);
     597    pPainter->drawText(point, strText);
     598    pPainter->restore();
     599}
     600
     601
     602/*********************************************************************************************************************************
     603*   Class UIChooserItemMimeData implementation.                                                                                  *
     604*********************************************************************************************************************************/
     605
    608606UIChooserItemMimeData::UIChooserItemMimeData(UIChooserItem *pItem)
    609607    : m_pItem(pItem)
     
    617615    return false;
    618616}
    619 
    620 UIChooserItem* UIChooserItemMimeData::item() const
    621 {
    622     return m_pItem;
    623 }
    624 
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h

    r73600 r73927  
    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 __UIChooserItem_h__
    19 #define __UIChooserItem_h__
     18#ifndef ___UIChooserItem_h___
     19#define ___UIChooserItem_h___
    2020
    2121/* Qt includes: */
    2222#include <QMimeData>
     23#include <QRectF>
    2324#include <QString>
    2425
     
    3132
    3233/* Forward declaration: */
     34class QGraphicsSceneHoverEvent;
     35class QGraphicsSceneMouseEvent;
     36class QGraphicsSceneDragDropEvent;
     37class QPropertyAnimation;
     38class QStateMachine;
    3339class UIActionPool;
    34 class UIChooserModel;
    3540class UIChooserItemGroup;
    3641class UIChooserItemGlobal;
    3742class UIChooserItemMachine;
    38 class QGraphicsSceneHoverEvent;
    39 class QGraphicsSceneMouseEvent;
    40 class QGraphicsSceneDragDropEvent;
    41 class QStateMachine;
    42 class QPropertyAnimation;
    43 
    44 /* UIChooserItem types: */
     43class UIChooserModel;
     44
     45
     46/** UIChooserItem types. */
    4547enum UIChooserItemType
    4648{
    47     UIChooserItemType_Any = QGraphicsItem::UserType,
     49    UIChooserItemType_Any     = QGraphicsItem::UserType,
    4850    UIChooserItemType_Group,
    4951    UIChooserItemType_Global,
     
    5153};
    5254
    53 /* Item search flags: */
     55
     56/** UIChooserItem search flags. */
    5457enum UIChooserItemSearchFlag
    5558{
     
    6063};
    6164
    62 /* Drag token placement: */
    63 enum DragToken { DragToken_Off, DragToken_Up, DragToken_Down };
    64 
    65 /* Graphics item interface
    66  * for graphics selector model/view architecture: */
     65
     66/** Drag token placement types. */
     67enum DragToken
     68{
     69    DragToken_Off,
     70    DragToken_Up,
     71    DragToken_Down
     72};
     73
     74
     75/** QIGraphicsWidget extension used as interface
     76  * for graphics chooser model/view architecture. */
    6777class UIChooserItem : public QIWithRetranslateUI4<QIGraphicsWidget>
    6878{
     
    7282signals:
    7383
    74     /* Notifiers: Size-hint stuff: */
    75     void sigMinimumWidthHintChanged(int iMinimumWidthHint);
    76     void sigMinimumHeightHintChanged(int iMinimumHeightHint);
    77 
    78     /* Notifiers: Hover stuff: */
    79     void sigHoverEnter();
    80     void sigHoverLeave();
     84    /** @name Basic stuff.
     85      * @{ */
     86        /** Notifies listeners about hover enter. */
     87        void sigHoverEnter();
     88        /** Notifies listeners about hover leave. */
     89        void sigHoverLeave();
     90    /** @} */
     91
     92    /** @name Layout stuff.
     93      * @{ */
     94        /** Notifies listeners about @a iMinimumWidthHint change. */
     95        void sigMinimumWidthHintChanged(int iMinimumWidthHint);
     96        /** Notifies listeners about @a iMinimumHeightHint change. */
     97        void sigMinimumHeightHintChanged(int iMinimumHeightHint);
     98    /** @} */
    8199
    82100public:
    83101
    84     /* Constructor: */
     102    /** Constructs item passing @a pParent to the base-class.
     103      * @param  fTemporary  Brings whether this item created for temporary needs. */
    85104    UIChooserItem(UIChooserItem *pParent, bool fTemporary);
    86105
    87     /* API: Cast stuff: */
    88     UIChooserItemGroup *toGroupItem();
    89     UIChooserItemGlobal *toGlobalItem();
    90     UIChooserItemMachine *toMachineItem();
    91 
    92     /* API: Model stuff: */
    93     UIChooserModel* model() const;
    94 
    95     /** Returns the action-pool reference. */
    96     UIActionPool* actionPool() const;
    97 
    98     /* API: Parent stuff: */
    99     UIChooserItem* parentItem() const;
    100 
    101     /* API: Basic stuff: */
    102     virtual void show();
    103     virtual void hide();
    104     virtual void startEditing() = 0;
    105     virtual void updateToolTip() = 0;
    106     virtual QString name() const = 0;
    107     virtual QString description() const = 0;
    108     virtual QString fullName() const = 0;
    109     virtual QString definition() const = 0;
    110     void setRoot(bool fRoot);
    111     bool isRoot() const;
    112     bool isHovered() const;
    113     void setHovered(bool fHovered);
    114 
    115     /* API: Children stuff: */
    116     virtual void addItem(UIChooserItem *pItem, int iPosition) = 0;
    117     virtual void removeItem(UIChooserItem *pItem) = 0;
    118     virtual void setItems(const QList<UIChooserItem*> &items, UIChooserItemType type) = 0;
    119     virtual QList<UIChooserItem*> items(UIChooserItemType type = UIChooserItemType_Any) const = 0;
    120     virtual bool hasItems(UIChooserItemType type = UIChooserItemType_Any) const = 0;
    121     virtual void clearItems(UIChooserItemType type = UIChooserItemType_Any) = 0;
    122     virtual void updateAll(const QString &strId) = 0;
    123     virtual void removeAll(const QString &strId) = 0;
    124     virtual UIChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags) = 0;
    125     virtual UIChooserItem* firstMachineItem() = 0;
    126     virtual void sortItems() = 0;
    127 
    128     /* API: Layout stuff: */
    129     void updateGeometry();
    130     virtual void updateLayout() = 0;
    131     virtual int minimumWidthHint() const = 0;
    132     virtual int minimumHeightHint() const = 0;
    133 
    134     /* API: Navigation stuff: */
    135     virtual void makeSureItsVisible();
    136 
    137     /* API: Drag and drop stuff: */
    138     virtual QPixmap toPixmap() = 0;
    139     virtual bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where = DragToken_Off) const = 0;
    140     virtual void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho = 0, DragToken where = DragToken_Off) = 0;
    141     virtual void resetDragToken() = 0;
    142     void setDragTokenPlace(DragToken where);
    143     DragToken dragTokenPlace() const;
    144 
    145     /* API: Toggle stuff: */
    146     bool isTemporary() const;
     106    /** @name Item stuff.
     107      * @{ */
     108        /** Returns parent  reference. */
     109        UIChooserItem *parentItem() const {  return m_pParent; }
     110        /** Returns whether item is temporary. */
     111        bool isTemporary() const { return m_fTemporary; }
     112
     113        /** Casts item to group one. */
     114        UIChooserItemGroup *toGroupItem();
     115        /** Casts item to global one. */
     116        UIChooserItemGlobal *toGlobalItem();
     117        /** Casts item to machine one. */
     118        UIChooserItemMachine *toMachineItem();
     119
     120        /** Returns model reference. */
     121        UIChooserModel *model() const;
     122        /** Returns action-pool reference. */
     123        UIActionPool *actionPool() const;
     124
     125        /** Shows item. */
     126        virtual void show();
     127        /** Hides item. */
     128        virtual void hide();
     129
     130        /** Starts item editing. */
     131        virtual void startEditing() = 0;
     132
     133        /** Updates item tool-tip. */
     134        virtual void updateToolTip() = 0;
     135
     136        /** Returns item name. */
     137        virtual QString name() const = 0;
     138        /** Returns item description. */
     139        virtual QString description() const = 0;
     140        /** Returns item full-name. */
     141        virtual QString fullName() const = 0;
     142        /** Returns item definition. */
     143        virtual QString definition() const = 0;
     144
     145        /** Defines whether item is @a fRoot. */
     146        void setRoot(bool fRoot);
     147        /** Returns whether item is root. */
     148        bool isRoot() const;
     149
     150        /** Defines whether item is @a fHovered. */
     151        void setHovered(bool fHovered);
     152        /** Returns whether item is hovered. */
     153        bool isHovered() const;
     154    /** @} */
     155
     156    /** @name Children stuff.
     157      * @{ */
     158        /** Adds child @a pItem to certain @a iPosition. */
     159        virtual void addItem(UIChooserItem *pItem, int iPosition) = 0;
     160        /** Removes child @a pItem. */
     161        virtual void removeItem(UIChooserItem *pItem) = 0;
     162
     163        /** Replaces children @a items of certain @a enmType. */
     164        virtual void setItems(const QList<UIChooserItem*> &items, UIChooserItemType enmType) = 0;
     165        /** Returns children items of certain @a enmType. */
     166        virtual QList<UIChooserItem*> items(UIChooserItemType enmType = UIChooserItemType_Any) const = 0;
     167        /** Returns whether there are children items of certain @a enmType. */
     168        virtual bool hasItems(UIChooserItemType enmType = UIChooserItemType_Any) const = 0;
     169        /** Clears children items of certain @a enmType. */
     170        virtual void clearItems(UIChooserItemType enmType = UIChooserItemType_Any) = 0;
     171
     172        /** Updates all children items with specified @a strId. */
     173        virtual void updateAllItems(const QString &strId) = 0;
     174        /** Removes all children items with specified @a strId. */
     175        virtual void removeAllItems(const QString &strId) = 0;
     176
     177        /** Searches for a first child item answering to specified @a strSearchTag and @a iItemSearchFlags. */
     178        virtual UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags) = 0;
     179
     180        /** Searches for a first machine child item. */
     181        virtual UIChooserItem *firstMachineItem() = 0;
     182
     183        /** Sorts children items. */
     184        virtual void sortItems() = 0;
     185    /** @} */
     186
     187    /** @name Layout stuff.
     188      * @{ */
     189        /** Updates geometry. */
     190        void updateGeometry();
     191
     192        /** Updates layout.  */
     193        virtual void updateLayout() = 0;
     194
     195        /** Returns minimum width-hint. */
     196        virtual int minimumWidthHint() const = 0;
     197        /** Returns minimum height-hint. */
     198        virtual int minimumHeightHint() const = 0;
     199    /** @} */
     200
     201    /** @name Navigation stuff.
     202      * @{ */
     203        /** Makes sure item is visible. */
     204        virtual void makeSureItsVisible();
     205
     206        /** Returns pixmap item representation. */
     207        virtual QPixmap toPixmap() = 0;
     208
     209        /** Returns whether item drop is allowed.
     210          * @param  pEvent    Brings information about drop event.
     211          * @param  enmPlace  Brings the place of drag token to the drop moment. */
     212        virtual bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken enmPlace = DragToken_Off) const = 0;
     213        /** Processes item drop.
     214          * @param  pEvent    Brings information about drop event.
     215          * @param  pFromWho  Brings the item according to which we choose drop position.
     216          * @param  enmPlace  Brings the place of drag token to the drop moment (according to item mentioned above). */
     217        virtual void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho = 0, DragToken enmPlace = DragToken_Off) = 0;
     218        /** Reset drag token. */
     219        virtual void resetDragToken() = 0;
     220
     221        /** Defines drag token @a enmPlace. */
     222        void setDragTokenPlace(DragToken enmPlace);
     223        /** Returns drag token place. */
     224        DragToken dragTokenPlace() const;
     225    /** @} */
    147226
    148227protected:
    149228
    150     /* Hover-enter event: */
    151     void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent);
    152     /* Hover-leave event: */
    153     void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);
    154     /* Mouse-press event: */
    155     void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);
    156     /* Mouse-move event: */
    157     void mouseMoveEvent(QGraphicsSceneMouseEvent *pEvent);
    158     /* Drag-move event: */
    159     void dragMoveEvent(QGraphicsSceneDragDropEvent *pEvent);
    160     /* Drag-leave event: */
    161     void dragLeaveEvent(QGraphicsSceneDragDropEvent *pEvent);
    162     /* Drop event: */
    163     void dropEvent(QGraphicsSceneDragDropEvent *pEvent);
    164 
    165     /* Helper: Update stuff: */
    166     virtual void handleRootStatusChange();
    167     void setPreviousGeometry(const QRectF &previousGeometry) { m_previousGeometry = previousGeometry; }
    168     const QRectF& previousGeometry() const { return m_previousGeometry; }
    169 
    170     /* Static paint stuff: */
    171     static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius);
    172     static void paintFrameRect(QPainter *pPainter, const QRect &rect, bool fIsSelected, int iRadius);
    173     static void paintPixmap(QPainter *pPainter, const QPoint &point, const QPixmap &pixmap);
    174     static void paintText(QPainter *pPainter, QPoint point,
    175                           const QFont &font, QPaintDevice *pPaintDevice,
    176                           const QString &strText);
    177 
    178     /* Helpers: Drag and drop stuff: */
    179     virtual QMimeData* createMimeData() = 0;
    180 
    181     /* Hover stuff: */
    182     int defaultDarkness() const { return m_iDefaultDarkness; }
    183     int highlightDarkness() const { return m_iHighlightDarkness; }
    184     int animationDarkness() const { return m_iAnimationDarkness; }
    185     void setDefaultDarkness(int iDefaultDarkness) { m_iDefaultDarkness = iDefaultDarkness; update(); }
    186     void setHighlightDarkness(int iHighlightDarkness) { m_iHighlightDarkness = iHighlightDarkness; update(); }
    187     void setAnimationDarkness(int iAnimationDarkness) { m_iAnimationDarkness = iAnimationDarkness; update(); }
    188 
    189     /* Other color stuff: */
    190     int dragTokenDarkness() const { return m_iDragTokenDarkness; }
    191 
    192     /* Helpers: Text processing stuff: */
    193     static QSize textSize(const QFont &font, QPaintDevice *pPaintDevice, const QString &strText);
    194     static int textWidth(const QFont &font, QPaintDevice *pPaintDevice, int iCount);
    195     static QString compressText(const QFont &font, QPaintDevice *pPaintDevice, QString strText, int iWidth);
     229    /** @name Event-processing stuff.
     230      * @{ */
     231        /** Handles hover enter @a event. */
     232        void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent);
     233        /** Handles hover leave @a event. */
     234        void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);
     235
     236        /** Handles mouse press @a event. */
     237        void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);
     238        /** Handles mouse move @a event. */
     239        void mouseMoveEvent(QGraphicsSceneMouseEvent *pEvent);
     240
     241        /** Handles drag move @a event. */
     242        void dragMoveEvent(QGraphicsSceneDragDropEvent *pEvent);
     243        /** Handles drag leave @a event. */
     244        void dragLeaveEvent(QGraphicsSceneDragDropEvent *pEvent);
     245        /** Handles drop @a event. */
     246        void dropEvent(QGraphicsSceneDragDropEvent *pEvent);
     247    /** @} */
     248
     249    /** @name Item stuff.
     250      * @{ */
     251        /** Handles root status change. */
     252        virtual void handleRootStatusChange();
     253
     254        /** Defines item's @a iDefaultDarkness. */
     255        void setDefaultDarkness(int iDefaultDarkness) { m_iDefaultDarkness = iDefaultDarkness; update(); }
     256        /** Returns default item darkness. */
     257        int defaultDarkness() const { return m_iDefaultDarkness; }
     258
     259        /** Defines item's @a iHighlightDarkness. */
     260        void setHighlightDarkness(int iHighlightDarkness) { m_iHighlightDarkness = iHighlightDarkness; update(); }
     261        /** Returns highlight item darkness. */
     262        int highlightDarkness() const { return m_iHighlightDarkness; }
     263
     264        /** Defines item's @a iAnimationDarkness. */
     265        void setAnimationDarkness(int iAnimationDarkness) { m_iAnimationDarkness = iAnimationDarkness; update(); }
     266        /** Returns animation item darkness. */
     267        int animationDarkness() const { return m_iAnimationDarkness; }
     268    /** @} */
     269
     270    /** @name Layout stuff.
     271      * @{ */
     272        /** Defines previous @a geometry. */
     273        void setPreviousGeometry(const QRectF &geometry) { m_previousGeometry = geometry; }
     274        /** Returns previous geometry. */
     275        const QRectF &previousGeometry() const { return m_previousGeometry; }
     276
     277        /** Returns @a strText size calculated on the basis of certain @a font and @a pPaintDevice. */
     278        static QSize textSize(const QFont &font, QPaintDevice *pPaintDevice, const QString &strText);
     279        /** Returns a width of line containing @a iCount of chars calculated on the basis of certain @a font and @a pPaintDevice. */
     280        static int textWidth(const QFont &font, QPaintDevice *pPaintDevice, int iCount);
     281        /** Compresses @a strText to @a iWidth on the basis of certain @a font and @a pPaintDevice. */
     282        static QString compressText(const QFont &font, QPaintDevice *pPaintDevice, QString strText, int iWidth);
     283    /** @} */
     284
     285    /** @name Navigation stuff.
     286      * @{ */
     287        /** Returns D&D mime data. */
     288        virtual QMimeData *createMimeData() = 0;
     289
     290        /** Returns drag token darkness. */
     291        int dragTokenDarkness() const { return m_iDragTokenDarkness; }
     292    /** @} */
     293
     294    /** @name Painting stuff.
     295      * @{ */
     296        /** Configures @a pPainter shape with certain @a pOptions and specified @a iRadius. */
     297        static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, int iRadius);
     298
     299        /** Paints frame @a rectangle using passed @a pPainter.
     300          * @param  fIsSelected  Brings whether this rectangle should be filled.
     301          * @param  iRadius      Brings the radius of rounded corners. */
     302        static void paintFrameRect(QPainter *pPainter, bool fIsSelected, int iRadius,
     303                                   const QRect &rectangle);
     304        /** Paints @a pixmap using passed @a pPainter putting its upper-left corner to specified @a point. */
     305        static void paintPixmap(QPainter *pPainter, const QPoint &point,
     306                                const QPixmap &pixmap);
     307        /** Paints @a strText using passed @a pPainter putting its upper-left corner to specified @a point.
     308          * @param  font          Brings the text font.
     309          * @param  pPaintDevice  Brings the paint-device reference to initilize painting from. */
     310        static void paintText(QPainter *pPainter, QPoint point,
     311                              const QFont &font, QPaintDevice *pPaintDevice,
     312                              const QString &strText);
     313    /** @} */
    196314
    197315private:
    198316
    199     /* Variables: */
    200     bool m_fRoot;
    201     bool m_fTemporary;
    202     UIChooserItem *m_pParent;
    203     QRectF m_previousGeometry;
    204     int m_iPreviousMinimumWidthHint;
    205     int m_iPreviousMinimumHeightHint;
    206     DragToken m_dragTokenPlace;
    207 
    208     /* Highlight animation stuff: */
    209     bool m_fHovered;
    210     QStateMachine *m_pHighlightMachine;
    211     QPropertyAnimation *m_pForwardAnimation;
    212     QPropertyAnimation *m_pBackwardAnimation;
    213     int m_iAnimationDuration;
    214     int m_iDefaultDarkness;
    215     int m_iHighlightDarkness;
    216     int m_iAnimationDarkness;
    217     int m_iDragTokenDarkness;
    218 };
    219 
    220 /* Mime-data for graphics item interface: */
     317    /** @name Item stuff.
     318      * @{ */
     319        /** Holds the item's parent item. */
     320        UIChooserItem *m_pParent;
     321        /** Holds whether item is temporary. */
     322        bool           m_fTemporary;
     323
     324        /** Holds whether item is root. */
     325        bool  m_fRoot;
     326        /** Holds whether item is hovered. */
     327        bool  m_fHovered;
     328
     329        /** Holds item highlight machine instance. */
     330        QStateMachine *m_pHighlightMachine;
     331
     332        /** Holds item forward animation instance. */
     333        QPropertyAnimation *m_pForwardAnimation;
     334        /** Holds item backward animation instance. */
     335        QPropertyAnimation *m_pBackwardAnimation;
     336
     337        /** Holds item animation duration. */
     338        int  m_iAnimationDuration;
     339
     340        /** Holds default item darkness. */
     341        int  m_iDefaultDarkness;
     342        /** Holds highlight item darkness. */
     343        int  m_iHighlightDarkness;
     344        /** Holds animation item darkness. */
     345        int  m_iAnimationDarkness;
     346    /** @} */
     347
     348    /** @name Layout stuff.
     349      * @{ */
     350        /** Holds previous geometry. */
     351        QRectF  m_previousGeometry;
     352
     353        /** Holds previous minimum width hint. */
     354        int  m_iPreviousMinimumWidthHint;
     355        /** Holds previous minimum height hint. */
     356        int  m_iPreviousMinimumHeightHint;
     357    /** @} */
     358
     359    /** @name Navigation stuff.
     360      * @{ */
     361        /** Holds drag token place. */
     362        DragToken  m_enmDragTokenPlace;
     363
     364        /** Holds drag token darkness. */
     365        int  m_iDragTokenDarkness;
     366    /** @} */
     367};
     368
     369
     370/** QMimeData for graphics item interface. */
    221371class UIChooserItemMimeData : public QMimeData
    222372{
     
    225375public:
    226376
    227     /* Constructor: */
     377    /** Constructs mime-data on the basis of passed @a pItem. */
    228378    UIChooserItemMimeData(UIChooserItem *pItem);
    229379
    230     /* API: Format checker: */
    231     bool hasFormat(const QString &strMimeType) const;
    232 
    233     /* API: Item getter: */
    234     UIChooserItem* item() const;
     380    /** Returns cached item. */
     381    UIChooserItem *item() const { return m_pItem; }
     382
     383    /** Constructs mime-data on the basis of passed @a pItem. */
     384    virtual bool hasFormat(const QString &strMimeType) const /* override */;
    235385
    236386private:
    237387
    238     /* Variables: */
     388    /** Holds the cached item. */
    239389    UIChooserItem *m_pItem;
    240390};
    241391
    242 #endif /* __UIChooserItem_h__ */
    243 
     392
     393#endif /* !___UIChooserItem_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp

    r73658 r73927  
    287287}
    288288
    289 void UIChooserItemGlobal::updateAll(const QString &)
     289void UIChooserItemGlobal::updateAllItems(const QString &)
    290290{
    291291    /* Update this global-item: */
     
    298298}
    299299
    300 void UIChooserItemGlobal::removeAll(const QString &)
     300void UIChooserItemGlobal::removeAllItems(const QString &)
    301301{
    302302    // Just do nothing ..
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h

    r73600 r73927  
    9696    bool hasItems(UIChooserItemType type) const;
    9797    void clearItems(UIChooserItemType type);
    98     void updateAll(const QString &strId);
    99     void removeAll(const QString &strId);
     98    void updateAllItems(const QString &strId);
     99    void removeAllItems(const QString &strId);
    100100    UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags);
    101101    UIChooserItem *firstMachineItem();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp

    r73600 r73927  
    966966}
    967967
    968 void UIChooserItemGroup::updateAll(const QString &strId)
     968void UIChooserItemGroup::updateAllItems(const QString &strId)
    969969{
    970970    /* Update all the required items recursively: */
    971971    foreach (UIChooserItem *pItem, items())
    972         pItem->updateAll(strId);
    973 }
    974 
    975 void UIChooserItemGroup::removeAll(const QString &strId)
     972        pItem->updateAllItems(strId);
     973}
     974
     975void UIChooserItemGroup::removeAllItems(const QString &strId)
    976976{
    977977    /* Remove all the required items recursively: */
    978978    foreach (UIChooserItem *pItem, items())
    979         pItem->removeAll(strId);
     979        pItem->removeAllItems(strId);
    980980}
    981981
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h

    r73600 r73927  
    143143    bool hasItems(UIChooserItemType type = UIChooserItemType_Any) const;
    144144    void clearItems(UIChooserItemType type = UIChooserItemType_Any);
    145     void updateAll(const QString &strId);
    146     void removeAll(const QString &strId);
     145    void updateAllItems(const QString &strId);
     146    void removeAllItems(const QString &strId);
    147147    UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags);
    148148    UIChooserItem *firstMachineItem();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp

    r73600 r73927  
    544544}
    545545
    546 void UIChooserItemMachine::updateAll(const QString &strId)
     546void UIChooserItemMachine::updateAllItems(const QString &strId)
    547547{
    548548    /* Skip other ids: */
     
    563563}
    564564
    565 void UIChooserItemMachine::removeAll(const QString &strId)
     565void UIChooserItemMachine::removeAllItems(const QString &strId)
    566566{
    567567    /* Skip wrong id: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h

    r73600 r73927  
    125125    bool hasItems(UIChooserItemType type) const;
    126126    void clearItems(UIChooserItemType type);
    127     void updateAll(const QString &strId);
    128     void removeAll(const QString &strId);
     127    void updateAllItems(const QString &strId);
     128    void removeAllItems(const QString &strId);
    129129    UIChooserItem *searchForItem(const QString &strSearchTag, int iItemSearchFlags);
    130130    UIChooserItem *firstMachineItem();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r73926 r73927  
    699699{
    700700    /* Update machine-items with passed id: */
    701     mainRoot()->updateAll(strId);
     701    mainRoot()->updateAllItems(strId);
    702702}
    703703
     
    705705{
    706706    /* Update machine-items with passed id: */
    707     mainRoot()->updateAll(strId);
     707    mainRoot()->updateAllItems(strId);
    708708}
    709709
     
    736736    {
    737737        /* Remove machine-items with passed id: */
    738         mainRoot()->removeAll(strId);
     738        mainRoot()->removeAllItems(strId);
    739739        /* Update model: */
    740740        cleanupGroupTree();
     
    755755{
    756756    /* Update machine-items with passed id: */
    757     mainRoot()->updateAll(strId);
     757    mainRoot()->updateAllItems(strId);
    758758}
    759759
     
    761761{
    762762    /* Update machine-items with passed id: */
    763     mainRoot()->updateAll(strId);
     763    mainRoot()->updateAllItems(strId);
    764764}
    765765
     
    10181018{
    10191019    /* Remove all the items first: */
    1020     mainRoot()->removeAll(strId);
     1020    mainRoot()->removeAllItems(strId);
    10211021    /* Wipe out empty groups: */
    10221022    cleanupGroupTree();
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