VirtualBox

Changeset 67424 in vbox


Ignore:
Timestamp:
Jun 15, 2017 1:46:34 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116151
Message:

FE/Qt: Selector UI: Tools pane: Snapshot pane: Cache 'current state' item as well, not just 'current snapshot' item; A bit of cleanup as well.

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

Legend:

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

    r67419 r67424  
    9999    bool isCurrentStateItem() const { return m_fCurrentStateItem; }
    100100
    101     /** Returns whether this is the current snapshot item. */
     101    /** Returns whether this is the "current snapshot" item. */
    102102    bool isCurrentSnapshotItem() const { return m_fCurrentSnapshotItem; }
    103103    /** Defines whether this is the @a fCurrent snapshot item. */
     
    138138    CMachine   m_comMachine;
    139139
    140     /** Holds the current snapshot ID. */
     140    /** Holds the "current snapshot" ID. */
    141141    QString  m_strSnapshotID;
    142     /** Holds whether the current snapshot is online one. */
     142    /** Holds whether the "current snapshot" is online one. */
    143143    bool     m_fOnline;
    144144
     
    219219{
    220220    /* Set the bold font state
    221      * for current state item: */
     221     * for "current state" item: */
    222222    QFont myFont = font(Column_Name);
    223223    myFont.setBold(true);
     
    236236{
    237237    /* Set the bold font state
    238      * for current state item: */
     238     * for "current state" item: */
    239239    QFont myFont = font(Column_Name);
    240240    myFont.setBold(true);
     
    263263
    264264    /* Set/clear the bold font state
    265      * for current snapshot item: */
     265     * for "current snapshot" item: */
    266266    QFont myFont = font(Column_Name);
    267267    myFont.setBold(fCurrent);
     
    471471    , m_pSnapshotTree(0)
    472472    , m_pCurrentSnapshotItem(0)
     473    , m_pCurrentStateItem(0)
    473474    , m_pDetailsWidget(0)
    474475{
     
    491492    if (m_comMachine.isNull())
    492493    {
    493         m_strMachineID = QString();
     494        m_strMachineId = QString();
    494495        m_enmSessionState = KSessionState_Null;
    495496        m_fShapshotOperationsAllowed = false;
     
    497498    else
    498499    {
    499         m_strMachineID = comMachine.GetId();
     500        m_strMachineId = comMachine.GetId();
    500501        m_enmSessionState = comMachine.GetSessionState();
    501         m_fShapshotOperationsAllowed = gEDataManager->machineSnapshotOperationsEnabled(m_strMachineID);
     502        m_fShapshotOperationsAllowed = gEDataManager->machineSnapshotOperationsEnabled(m_strMachineId);
    502503    }
    503504
     
    580581}
    581582
    582 void UISnapshotPane::sltHandleMachineDataChange(QString strMachineID)
     583void UISnapshotPane::sltHandleMachineDataChange(QString strMachineId)
    583584{
    584585    /* Make sure it's our VM: */
    585     if (strMachineID != m_strMachineID)
     586    if (strMachineId != m_strMachineId)
    586587        return;
    587588
     
    589590    QWriteLocker locker(m_pLockReadWrite);
    590591
    591     /* Recache current item data: */
    592     currentStateItem()->recache();
    593 }
    594 
    595 void UISnapshotPane::sltHandleMachineStateChange(QString strMachineID, KMachineState enmState)
     592    /* Recache "current state" item data: */
     593    m_pCurrentStateItem->recache();
     594}
     595
     596void UISnapshotPane::sltHandleMachineStateChange(QString strMachineId, KMachineState enmState)
    596597{
    597598    /* Make sure it's our VM: */
    598     if (strMachineID != m_strMachineID)
     599    if (strMachineId != m_strMachineId)
    599600        return;
    600601
     
    602603    QWriteLocker locker(m_pLockReadWrite);
    603604
    604     /* Recache current item data and machine-state: */
    605     currentStateItem()->recache();
    606     currentStateItem()->setMachineState(enmState);
    607 }
    608 
    609 void UISnapshotPane::sltHandleSessionStateChange(QString strMachineID, KSessionState enmState)
     605    /* Recache "current state" item data and machine-state: */
     606    m_pCurrentStateItem->recache();
     607    m_pCurrentStateItem->setMachineState(enmState);
     608}
     609
     610void UISnapshotPane::sltHandleSessionStateChange(QString strMachineId, KSessionState enmState)
    610611{
    611612    /* Make sure it's our VM: */
    612     if (strMachineID != m_strMachineID)
     613    if (strMachineId != m_strMachineId)
    613614        return;
    614615
     
    623624}
    624625
    625 void UISnapshotPane::sltHandleSnapshotChange(QString strMachineID)
     626void UISnapshotPane::sltHandleSnapshotChange(QString strMachineId)
    626627{
    627628    /* Make sure it's our VM: */
    628     if (strMachineID != m_strMachineID)
     629    if (strMachineId != m_strMachineId)
    629630        return;
    630631
     
    664665    if (m_pDetailsWidget->isVisible())
    665666    {
    666         /* Acquire current snapshot item: */
     667        /* Acquire "current snapshot" item: */
    667668        const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    668669        /* Update details-widget: */
     
    680681    m_pActionCommitSnapshotDetails->setEnabled(false);
    681682
    682     /* Acquire current snapshot item: */
     683    /* Acquire "current snapshot" item: */
    683684    const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    684685    AssertPtr(pSnapshotItem);
     
    725726void UISnapshotPane::sltHandleCurrentItemChange()
    726727{
    727     /* Acquire current snapshot item: */
     728    /* Acquire "current snapshot" item: */
    728729    const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    729730
     
    10661067        /* Populate snapshot tree: */
    10671068        populateSnapshots(comSnapshot, 0);
    1068         /* And make sure it has current snapshot item: */
     1069        /* And make sure it has "current snapshot" item: */
    10691070        Assert(m_pCurrentSnapshotItem);
    10701071
    1071         /* Add the "current state" item as a child to current snapshot item: */
    1072         UISnapshotItem *pCsi = new UISnapshotItem(this, m_pCurrentSnapshotItem, m_comMachine);
    1073         pCsi->recache();
     1072        /* Add the "current state" item as a child to "current snapshot" item: */
     1073        m_pCurrentStateItem = new UISnapshotItem(this, m_pCurrentSnapshotItem, m_comMachine);
     1074        m_pCurrentStateItem->recache();
    10741075
    10751076        /* Search for a previously selected item: */
     
    10781079            pCurrentItem = findItem(strFirstChildOfSelectedItem);
    10791080        if (pCurrentItem == 0)
    1080             pCurrentItem = currentStateItem();
     1081            pCurrentItem = m_pCurrentStateItem;
    10811082
    10821083        /* Choose current item: */
     
    10881089    else
    10891090    {
    1090         /* There is no current snapshot item: */
     1091        /* There is no "current snapshot" item: */
    10911092        m_pCurrentSnapshotItem = 0;
    10921093
    10931094        /* Add the "current state" item as a child of snapshot tree: */
    1094         UISnapshotItem *pCsi = new UISnapshotItem(this, m_pSnapshotTree, m_comMachine);
    1095         pCsi->recache();
     1095        m_pCurrentStateItem = new UISnapshotItem(this, m_pSnapshotTree, m_comMachine);
     1096        m_pCurrentStateItem->recache();
    10961097
    10971098        /* Choose current item: */
    1098         m_pSnapshotTree->setCurrentItem(pCsi);
     1099        m_pSnapshotTree->setCurrentItem(m_pCurrentStateItem);
    10991100        sltHandleCurrentItemChange();
    11001101    }
     
    11551156void UISnapshotPane::updateActionStates()
    11561157{
    1157     /* Acquire current snapshot item: */
     1158    /* Acquire "current snapshot" item: */
    11581159    const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    11591160
     
    11631164    /* Acquire machine-state of the "current state" item: */
    11641165    KMachineState enmState = KMachineState_Null;
    1165     if (currentStateItem())
    1166         enmState = currentStateItem()->machineState();
     1166    if (m_pCurrentStateItem)
     1167        enmState = m_pCurrentStateItem->machineState();
    11671168
    11681169    /* Determine whether taking or deleting snapshots is possible: */
     
    12291230        CSession comSession;
    12301231        if (m_enmSessionState != KSessionState_Unlocked)
    1231             comSession = vboxGlobal().openExistingSession(m_strMachineID);
     1232            comSession = vboxGlobal().openExistingSession(m_strMachineId);
    12321233        else
    1233             comSession = vboxGlobal().openSession(m_strMachineID);
     1234            comSession = vboxGlobal().openSession(m_strMachineId);
    12341235        if (comSession.isNull())
    12351236            break;
     
    13241325    do
    13251326    {
    1326         /* Acquire current snapshot item: */
     1327        /* Acquire "current snapshot" item: */
    13271328        const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    13281329        AssertPtr(pSnapshotItem);
     
    13521353        CSession comSession;
    13531354        if (m_enmSessionState != KSessionState_Unlocked)
    1354             comSession = vboxGlobal().openExistingSession(m_strMachineID);
     1355            comSession = vboxGlobal().openExistingSession(m_strMachineId);
    13551356        else
    1356             comSession = vboxGlobal().openSession(m_strMachineID);
     1357            comSession = vboxGlobal().openSession(m_strMachineId);
    13571358        if (comSession.isNull())
    13581359            break;
     
    14011402    do
    14021403    {
    1403         /* Acquire current snapshot item: */
     1404        /* Acquire "current snapshot" item: */
    14041405        const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    14051406        AssertPtr(pSnapshotItem);
     
    14251426            {
    14261427                /* Take snapshot of changed current state: */
    1427                 m_pSnapshotTree->setCurrentItem(currentStateItem());
     1428                m_pSnapshotTree->setCurrentItem(m_pCurrentStateItem);
    14281429                if (!takeSnapshot())
    14291430                    break;
     
    14321433
    14331434        /* Open a direct session (this call will handle all errors): */
    1434         CSession comSession = vboxGlobal().openSession(m_strMachineID);
     1435        CSession comSession = vboxGlobal().openSession(m_strMachineId);
    14351436        if (comSession.isNull())
    14361437            break;
     
    14751476void UISnapshotPane::cloneSnapshot()
    14761477{
    1477     /* Acquire current snapshot item: */
     1478    /* Acquire "current snapshot" item: */
    14781479    const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    14791480    AssertReturnVoid(pSnapshotItem);
     
    15341535}
    15351536
    1536 UISnapshotItem *UISnapshotPane::currentStateItem() const
    1537 {
    1538     /* Last child of the current snapshot item if any or first child of invisible root item otherwise: */
    1539     QTreeWidgetItem *pCsi = m_pCurrentSnapshotItem ?
    1540                             m_pCurrentSnapshotItem->child(m_pCurrentSnapshotItem->childCount() - 1) :
    1541                             m_pSnapshotTree->invisibleRootItem()->child(0);
    1542     return static_cast<UISnapshotItem*>(pCsi);
    1543 }
    1544 
    15451537SnapshotAgeFormat UISnapshotPane::traverseSnapshotAge(QTreeWidgetItem *pItem) const
    15461538{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r67419 r67424  
    6969protected:
    7070
    71     /** @name Event-handling stuff.
     71    /** @name Qt event handlers.
    7272      * @{ */
    7373        /** Handles translation event. */
     
    8585    /** @name Main event handlers.
    8686      * @{ */
    87         /** Handles machine data change for machine with @a strMachineID. */
    88         void sltHandleMachineDataChange(QString strMachineID);
    89         /** Handles machine @a enmState change for machine with @a strMachineID. */
    90         void sltHandleMachineStateChange(QString strMachineID, KMachineState enmState);
    91 
    92         /** Handles session @a enmState change for machine with @a strMachineID. */
    93         void sltHandleSessionStateChange(QString strMachineID, KSessionState enmState);
    94 
    95         /** Handles any snapshot change for machine with @a strMachineID. */
    96         void sltHandleSnapshotChange(QString strMachineID);
     87        /** Handles machine data change for machine with @a strMachineId. */
     88        void sltHandleMachineDataChange(QString strMachineId);
     89        /** Handles machine @a enmState change for machine with @a strMachineId. */
     90        void sltHandleMachineStateChange(QString strMachineId, KMachineState enmState);
     91
     92        /** Handles session @a enmState change for machine with @a strMachineId. */
     93        void sltHandleSessionStateChange(QString strMachineId, KSessionState enmState);
     94
     95        /** Handles any snapshot change for machine with @a strMachineId. */
     96        void sltHandleSnapshotChange(QString strMachineId);
    9797    /** @} */
    9898
     
    177177        /** Searches for an item with corresponding @a strSnapshotID. */
    178178        UISnapshotItem *findItem(const QString &strSnapshotID) const;
    179         /** Returns the "current state" item. */
    180         UISnapshotItem *currentStateItem() const;
    181179
    182180        /** Searches for smallest snapshot age starting with @a pItem as parent. */
     
    189187        CMachine       m_comMachine;
    190188        /** Holds the machine object ID. */
    191         QString        m_strMachineID;
     189        QString        m_strMachineId;
    192190        /** Holds the cached session state. */
    193191        KSessionState  m_enmSessionState;
     
    227225        /** Holds the snapshot tree instance. */
    228226        UISnapshotTree *m_pSnapshotTree;
    229         /** Holds the current snapshot item reference. */
     227        /** Holds the "current snapshot" item reference. */
    230228        UISnapshotItem *m_pCurrentSnapshotItem;
     229        /** Holds the "current state" item reference. */
     230        UISnapshotItem *m_pCurrentStateItem;
    231231
    232232        /** Holds the details-widget instance. */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette