VirtualBox

Changeset 67261 in vbox for trunk


Ignore:
Timestamp:
Jun 5, 2017 4:17:57 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Tools pane: Snapshot pane: Better encapsulation for 'current snapshot item'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp

    r67260 r67261  
    9696    bool isCurrentStateItem() const { return m_fCurrentStateItem; }
    9797
     98    /** Returns whether this is the current snapshot item. */
     99    bool isCurrentSnapshotItem() const { return m_fCurrentSnapshotItem; }
     100    /** Defines whether this is the @a fCurrent snapshot item. */
     101    void setCurrentSnapshotItem(bool fCurrent);
     102
    98103    /** Calculates and returns the current item level. */
    99104    int level() const;
    100 
    101     /** Returns whether the font is bold. */
    102     bool bold() const;
    103     /** Defines whether the font is @a fBold. */
    104     void setBold(bool fBold);
    105 
    106     /** Returns whether the font is italic. */
    107     bool italic() const;
    108     /** Defines whether the font is @a fItalic. */
    109     void setItalic(bool fItalic);
    110105
    111106    /** Recaches the item's contents. */
     
    135130    /** Holds whether this is a "current state" item. */
    136131    bool  m_fCurrentStateItem;
     132    /** Holds whether this is a "current snapshot" item. */
     133    bool  m_fCurrentSnapshotItem;
    137134
    138135    /** Holds the snapshot COM wrapper. */
     
    200197    , m_pSnapshotWidget(pSnapshotWidget)
    201198    , m_fCurrentStateItem(false)
     199    , m_fCurrentSnapshotItem(false)
    202200    , m_comSnapshot(comSnapshot)
    203201{
     
    208206    , m_pSnapshotWidget(pSnapshotWidget)
    209207    , m_fCurrentStateItem(false)
     208    , m_fCurrentSnapshotItem(false)
    210209    , m_comSnapshot(comSnapshot)
    211210{
     
    216215    , m_pSnapshotWidget(pSnapshotWidget)
    217216    , m_fCurrentStateItem(true)
     217    , m_fCurrentSnapshotItem(false)
    218218    , m_comMachine(comMachine)
    219219{
     220    /* Set the bold font state
     221     * for current state item: */
     222    QFont myFont = font(0);
     223    myFont.setBold(true);
     224    setFont(0, myFont);
     225
    220226    /* Fetch current machine state: */
    221227    setMachineState(m_comMachine.GetState());
     
    226232    , m_pSnapshotWidget(pSnapshotWidget)
    227233    , m_fCurrentStateItem(true)
     234    , m_fCurrentSnapshotItem(false)
    228235    , m_comMachine(comMachine)
    229236{
     237    /* Set the bold font state
     238     * for current state item: */
     239    QFont myFont = font(0);
     240    myFont.setBold(true);
     241    setFont(0, myFont);
     242
    230243    /* Fetch current machine state: */
    231244    setMachineState(m_comMachine.GetState());
     
    282295}
    283296
    284 bool UISnapshotItem::bold() const
    285 {
    286     return font(0).bold();
    287 }
    288 
    289 void UISnapshotItem::setBold(bool fBold)
    290 {
    291     /* Update font: */
     297void UISnapshotItem::setCurrentSnapshotItem(bool fCurrent)
     298{
     299    /* Remember the state: */
     300    m_fCurrentSnapshotItem = fCurrent;
     301
     302    /* Set/clear the bold font state
     303     * for current snapshot item: */
    292304    QFont myFont = font(0);
    293     myFont.setBold(fBold);
     305    myFont.setBold(fCurrent);
    294306    setFont(0, myFont);
    295307
    296     /* Adjust text: */
    297     adjustText();
    298 }
    299 
    300 bool UISnapshotItem::italic() const
    301 {
    302     return font(0).italic();
    303 }
    304 
    305 void UISnapshotItem::setItalic(bool fItalic)
    306 {
    307     /* Update font: */
    308     QFont myFont = font(0);
    309     myFont.setItalic(fItalic);
    310     setFont(0, myFont);
    311 
    312     /* Adjust text: */
    313     adjustText();
     308    /* Update tool-tip: */
     309    recacheToolTip();
    314310}
    315311
     
    462458    else
    463459    {
    464         /* The current snapshot is always bold: */
    465         if (bold())
     460        if (isCurrentSnapshotItem())
    466461            strDetails = UISnapshotPane::tr(" (current, ", "Snapshot details");
    467462        else
     
    11311126        /* Add the "current state" item as a child to current snapshot item: */
    11321127        UISnapshotItem *pCsi = new UISnapshotItem(this, m_pCurrentSnapshotItem, m_comMachine);
    1133         pCsi->setBold(true);
    11341128        pCsi->recache();
    11351129
     
    11541148        /* Add the "current state" item as a child of snapshot tree: */
    11551149        UISnapshotItem *pCsi = new UISnapshotItem(this, m_pSnapshotTree, m_comMachine);
    1156         pCsi->setBold(true);
    11571150        pCsi->recache();
    11581151
     
    11771170    pSnapshotItem->recache();
    11781171
    1179     /* Mark current snapshot item bold and remember it: */
     1172    /* Mark snapshot item as "current" and remember it: */
    11801173    CSnapshot comCurrentSnapshot = m_comMachine.GetCurrentSnapshot();
    11811174    if (!comCurrentSnapshot.isNull() && comCurrentSnapshot.GetId() == comSnapshot.GetId())
    11821175    {
    1183         pSnapshotItem->setBold(true);
     1176        pSnapshotItem->setCurrentSnapshotItem(true);
    11841177        m_pCurrentSnapshotItem = pSnapshotItem;
    11851178    }
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