VirtualBox

Changeset 67260 in vbox for trunk/src/VBox


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

FE/Qt: Selector UI: Tools pane: Snapshot pane: A bit of cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
2 edited

Legend:

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

    r67246 r67260  
    9494
    9595    /** Returns whether this is the "current state" item. */
    96     bool isCurrentStateItem() const;
     96    bool isCurrentStateItem() const { return m_fCurrentStateItem; }
    9797
    9898    /** Calculates and returns the current item level. */
     
    113113
    114114    /** Returns current machine state. */
    115     KMachineState getCurrentState() const;
    116 
    117     /** Recaches current machine state. */
    118     void updateCurrentState(KMachineState enmState);
     115    KMachineState machineState() const;
     116    /** Defines current machine @a enmState. */
     117    void setMachineState(KMachineState enmState);
    119118
    120119    /** Updates item age. */
     
    132131
    133132    /** Holds the pointer to the snapshot-widget this item belongs to. */
    134     QPointer<UISnapshotPane> m_pSnapshotWidget;
     133    QPointer<UISnapshotPane>  m_pSnapshotWidget;
    135134
    136135    /** Holds whether this is a "current state" item. */
    137     bool                     m_fCurrentState;
     136    bool  m_fCurrentStateItem;
    138137
    139138    /** Holds the snapshot COM wrapper. */
    140     CSnapshot                m_comSnapshot;
     139    CSnapshot  m_comSnapshot;
    141140    /** Holds the machine COM wrapper. */
    142     CMachine                 m_comMachine;
     141    CMachine   m_comMachine;
    143142
    144143    /** Holds the current snapshot ID. */
    145     QString                  m_strSnapshotID;
     144    QString  m_strSnapshotID;
    146145    /** Holds whether the current snapshot is online one. */
    147     bool                     m_fOnline;
     146    bool     m_fOnline;
    148147
    149148    /** Holds the item timestamp. */
    150     QDateTime                m_timestamp;
     149    QDateTime  m_timestamp;
    151150
    152151    /** Holds whether the current state is modified. */
    153     bool                     m_fCurrentStateModified;
     152    bool           m_fCurrentStateModified;
    154153    /** Holds the cached machine state. */
    155     KMachineState            m_enmMachineState;
     154    KMachineState  m_enmMachineState;
    156155};
    157156
     
    200199    : QITreeWidgetItem(pTreeWidget)
    201200    , m_pSnapshotWidget(pSnapshotWidget)
    202     , m_fCurrentState(false)
     201    , m_fCurrentStateItem(false)
    203202    , m_comSnapshot(comSnapshot)
    204203{
     
    208207    : QITreeWidgetItem(pRootItem)
    209208    , m_pSnapshotWidget(pSnapshotWidget)
    210     , m_fCurrentState(false)
     209    , m_fCurrentStateItem(false)
    211210    , m_comSnapshot(comSnapshot)
    212211{
     
    216215    : QITreeWidgetItem(pTreeWidget)
    217216    , m_pSnapshotWidget(pSnapshotWidget)
    218     , m_fCurrentState(true)
     217    , m_fCurrentStateItem(true)
    219218    , m_comMachine(comMachine)
    220219{
    221220    /* Fetch current machine state: */
    222     updateCurrentState(m_comMachine.GetState());
     221    setMachineState(m_comMachine.GetState());
    223222}
    224223
     
    226225    : QITreeWidgetItem(pRootItem)
    227226    , m_pSnapshotWidget(pSnapshotWidget)
    228     , m_fCurrentState(true)
     227    , m_fCurrentStateItem(true)
    229228    , m_comMachine(comMachine)
    230229{
    231230    /* Fetch current machine state: */
    232     updateCurrentState(m_comMachine.GetState());
     231    setMachineState(m_comMachine.GetState());
    233232}
    234233
     
    240239        {
    241240            /* Call to base-class for "current state" item, compose ourselves otherwise: */
    242             return m_fCurrentState ? QTreeWidgetItem::data(iColumn, iRole) :
    243                                      QString("%1%2")
    244                                          .arg(QTreeWidgetItem::data(iColumn, Qt::DisplayRole).toString())
    245                                          .arg(QTreeWidgetItem::data(iColumn, Qt::UserRole).toString());
     241            return m_fCurrentStateItem ? QTreeWidgetItem::data(iColumn, iRole)
     242                                       : QString("%1%2")
     243                                             .arg(QTreeWidgetItem::data(iColumn, Qt::DisplayRole).toString())
     244                                             .arg(QTreeWidgetItem::data(iColumn, Qt::UserRole).toString());
    246245        }
    247246        case Qt::SizeHintRole:
     
    271270}
    272271
    273 bool UISnapshotItem::isCurrentStateItem() const
    274 {
    275     return m_comSnapshot.isNull();
    276 }
    277 
    278272int UISnapshotItem::level() const
    279273{
     
    323317{
    324318    /* For "current state" item: */
    325     if (m_fCurrentState)
     319    if (m_fCurrentStateItem)
    326320    {
    327321        /* Fetch machine information: */
    328         AssertReturnVoid(!m_comMachine.isNull());
     322        AssertReturnVoid(m_comMachine.isNotNull());
    329323        m_fCurrentStateModified = m_comMachine.GetCurrentStateModified();
    330         m_strName = m_fCurrentStateModified ?
    331                     UISnapshotPane::tr("Current State (changed)", "Current State (Modified)") :
    332                     UISnapshotPane::tr("Current State", "Current State (Unmodified)");
     324        m_strName = m_fCurrentStateModified
     325                  ? UISnapshotPane::tr("Current State (changed)", "Current State (Modified)")
     326                  : UISnapshotPane::tr("Current State", "Current State (Unmodified)");
    333327        setText(0, m_strName);
    334         m_strDescription = m_fCurrentStateModified ?
    335                            UISnapshotPane::tr("The current state differs from the state stored in the current snapshot") :
    336                            QTreeWidgetItem::parent() != 0 ?
    337                            UISnapshotPane::tr("The current state is identical to the state stored in the current snapshot") :
    338                            QString();
    339     }
    340     /* For others: */
     328        m_strDescription = m_fCurrentStateModified
     329                         ? UISnapshotPane::tr("The current state differs from the state stored in the current snapshot")
     330                         : QTreeWidgetItem::parent() != 0
     331                         ? UISnapshotPane::tr("The current state is identical to the state stored in the current snapshot")
     332                         : QString();
     333    }
     334    /* For snapshot item: */
    341335    else
    342336    {
    343337        /* Fetch snapshot information: */
    344         AssertReturnVoid(!m_comSnapshot.isNull());
     338        AssertReturnVoid(m_comSnapshot.isNotNull());
    345339        m_strSnapshotID = m_comSnapshot.GetId();
    346340        m_strName = m_comSnapshot.GetName();
     
    359353}
    360354
    361 KMachineState UISnapshotItem::getCurrentState() const
     355KMachineState UISnapshotItem::machineState() const
    362356{
    363357    /* Make sure machine is valid: */
     
    369363}
    370364
    371 void UISnapshotItem::updateCurrentState(KMachineState enmState)
     365void UISnapshotItem::setMachineState(KMachineState enmState)
    372366{
    373367    /* Make sure machine is valid: */
     
    375369        return;
    376370
    377     /* Set corresponding icon: */
    378     setIcon(0, gpConverter->toIcon(enmState));
    379371    /* Cache new state: */
    380372    m_enmMachineState = enmState;
     373    /* Set corresponding icon: */
     374    setIcon(0, gpConverter->toIcon(m_enmMachineState));
    381375    /* Update timestamp: */
    382376    m_timestamp.setTime_t(m_comMachine.GetLastStateChange() / 1000);
     
    452446
    453447    /* Compose date time: */
    454     QString strDateTime = fDateTimeToday ?
    455                           m_timestamp.time().toString(Qt::LocalDate) :
    456                           m_timestamp.toString(Qt::LocalDate);
     448    QString strDateTime = fDateTimeToday
     449                        ? m_timestamp.time().toString(Qt::LocalDate)
     450                        : m_timestamp.toString(Qt::LocalDate);
    457451
    458452    /* Prepare details: */
    459453    QString strDetails;
    460454
     455    /* For "current state" item: */
     456    if (m_fCurrentStateItem)
     457    {
     458        strDateTime = UISnapshotPane::tr("%1 since %2", "Current State (time or date + time)")
     459                      .arg(gpConverter->toString(m_enmMachineState)).arg(strDateTime);
     460    }
    461461    /* For snapshot item: */
    462     if (!m_comSnapshot.isNull())
     462    else
    463463    {
    464464        /* The current snapshot is always bold: */
     
    477477        else
    478478            strDateTime = UISnapshotPane::tr("Taken on %1", "Snapshot (date + time)").arg(strDateTime);
    479     }
    480     /* For "current state" item: */
    481     else
    482     {
    483         strDateTime = UISnapshotPane::tr("%1 since %2", "Current State (time or date + time)")
    484                       .arg(gpConverter->toString(m_enmMachineState)).arg(strDateTime);
    485479    }
    486480
     
    644638    /* Recache current item data and machine-state: */
    645639    currentStateItem()->recache();
    646     currentStateItem()->updateCurrentState(enmState);
     640    currentStateItem()->setMachineState(enmState);
    647641}
    648642
     
    766760    KMachineState enmState = KMachineState_Null;
    767761    if (currentStateItem())
    768         enmState = currentStateItem()->getCurrentState();
     762        enmState = currentStateItem()->machineState();
    769763
    770764    /* Whether taking or deleting snapshots is possible right now: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r67160 r67260  
    6969protected:
    7070
    71     /** Handles translation event. */
    72     virtual void retranslateUi() /* override */;
     71    /** @name Event-handling stuff.
     72      * @{ */
     73        /** Handles translation event. */
     74        virtual void retranslateUi() /* override */;
     75    /** @} */
    7376
    7477private slots:
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