VirtualBox

Changeset 67121 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 26, 2017 4:09:51 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115792
Message:

FE/Qt: Selector UI: Tools pane: Snapshot pane: Reordering.

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

Legend:

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

    r67120 r67121  
    521521    : QIWithRetranslateUI<QWidget>(pParent)
    522522    , m_enmSessionState(KSessionState_Null)
    523     , m_pCurrentSnapshotItem(0)
     523    , m_fShapshotOperationsAllowed(false)
    524524    , m_pLockReadWrite(0)
     525    , m_pIconSnapshotOffline(0)
     526    , m_pIconSnapshotOnline(0)
     527    , m_pTimerUpdateAge(0)
    525528    , m_pToolBar(0)
    526529    , m_pActionTakeSnapshot(0)
     530    , m_pActionDeleteSnapshot(0)
    527531    , m_pActionRestoreSnapshot(0)
    528     , m_pActionDeleteSnapshot(0)
    529532    , m_pActionShowSnapshotDetails(0)
    530533    , m_pActionCloneSnapshot(0)
    531     , m_pTimerUpdateAge(0)
    532     , m_fShapshotOperationsAllowed(false)
    533     , m_pIconSnapshotOffline(0)
    534     , m_pIconSnapshotOnline(0)
    535534    , m_pSnapshotTree(0)
     535    , m_pCurrentSnapshotItem(0)
    536536{
    537537    /* Prepare: */
     
    580580    /* Translate actions names: */
    581581    m_pActionTakeSnapshot->setText(tr("&Take..."));
     582    m_pActionDeleteSnapshot->setText(tr("&Delete"));
    582583    m_pActionRestoreSnapshot->setText(tr("&Restore"));
    583     m_pActionDeleteSnapshot->setText(tr("&Delete"));
    584584    m_pActionShowSnapshotDetails->setText(tr("D&etails..."));
    585585    m_pActionCloneSnapshot->setText(tr("&Clone..."));
    586586    /* Translate actions tool-tips: */
    587587    m_pActionTakeSnapshot->setToolTip(tr("Take Snapshot (%1)").arg(m_pActionTakeSnapshot->shortcut().toString()));
     588    m_pActionDeleteSnapshot->setToolTip(tr("Delete Snapshot (%1)").arg(m_pActionDeleteSnapshot->shortcut().toString()));
    588589    m_pActionRestoreSnapshot->setToolTip(tr("Restore Snapshot (%1)").arg(m_pActionRestoreSnapshot->shortcut().toString()));
    589     m_pActionDeleteSnapshot->setToolTip(tr("Delete Snapshot (%1)").arg(m_pActionDeleteSnapshot->shortcut().toString()));
    590590    m_pActionShowSnapshotDetails->setToolTip(tr("Show Snapshot Details (%1)").arg(m_pActionShowSnapshotDetails->shortcut().toString()));
    591591    m_pActionCloneSnapshot->setToolTip(tr("Clone Virtual Machine (%1)").arg(m_pActionCloneSnapshot->shortcut().toString()));
    592592    /* Translate actions status-tips: */
    593593    m_pActionTakeSnapshot->setStatusTip(tr("Take a snapshot of the current virtual machine state"));
     594    m_pActionDeleteSnapshot->setStatusTip(tr("Delete selected snapshot of the virtual machine"));
    594595    m_pActionRestoreSnapshot->setStatusTip(tr("Restore selected snapshot of the virtual machine"));
    595     m_pActionDeleteSnapshot->setStatusTip(tr("Delete selected snapshot of the virtual machine"));
    596596    m_pActionShowSnapshotDetails->setStatusTip(tr("Display a window with selected snapshot details"));
    597597    m_pActionCloneSnapshot->setStatusTip(tr("Clone selected virtual machine"));
     
    609609}
    610610
     611void UISnapshotPane::sltMachineDataChange(QString strMachineID)
     612{
     613    /* Make sure it's our VM: */
     614    if (strMachineID != m_strMachineID)
     615        return;
     616
     617    /* Prevent snapshot editing in the meantime: */
     618    QWriteLocker locker(m_pLockReadWrite);
     619
     620    /* Recache state current item: */
     621    currentStateItem()->recache();
     622}
     623
     624void UISnapshotPane::sltMachineStateChange(QString strMachineID, KMachineState enmState)
     625{
     626    /* Make sure it's our VM: */
     627    if (strMachineID != m_strMachineID)
     628        return;
     629
     630    /* Prevent snapshot editing in the meantime: */
     631    QWriteLocker locker(m_pLockReadWrite);
     632
     633    /* Recache new machine state: */
     634    currentStateItem()->recache();
     635    currentStateItem()->updateCurrentState(enmState);
     636}
     637
     638void UISnapshotPane::sltSessionStateChange(QString strMachineID, KSessionState enmState)
     639{
     640    /* Make sure it's our VM: */
     641    if (strMachineID != m_strMachineID)
     642        return;
     643
     644    /* Prevent snapshot editing in the meantime: */
     645    QWriteLocker locker(m_pLockReadWrite);
     646
     647    /* Recache new session state: */
     648    m_enmSessionState = enmState;
     649    sltCurrentItemChanged(m_pSnapshotTree->currentItem());
     650}
     651
     652void UISnapshotPane::sltUpdateSnapshotsAge()
     653{
     654    /* Stop timer if active: */
     655    if (m_pTimerUpdateAge->isActive())
     656        m_pTimerUpdateAge->stop();
     657
     658    /* Search for smallest snapshot age to optimize timer timeout: */
     659    const SnapshotAgeFormat age = traverseSnapshotAge(m_pSnapshotTree->invisibleRootItem());
     660    switch (age)
     661    {
     662        case SnapshotAgeFormat_InSeconds: m_pTimerUpdateAge->setInterval(5 * 1000); break;
     663        case SnapshotAgeFormat_InMinutes: m_pTimerUpdateAge->setInterval(60 * 1000); break;
     664        case SnapshotAgeFormat_InHours:   m_pTimerUpdateAge->setInterval(60 * 60 * 1000); break;
     665        case SnapshotAgeFormat_InDays:    m_pTimerUpdateAge->setInterval(24 * 60 * 60 * 1000); break;
     666        default:                          m_pTimerUpdateAge->setInterval(0); break;
     667    }
     668
     669    /* Restart timer if necessary: */
     670    if (m_pTimerUpdateAge->interval() > 0)
     671        m_pTimerUpdateAge->start();
     672}
     673
    611674void UISnapshotPane::sltCurrentItemChanged(QTreeWidgetItem *pItem)
    612675{
     
    648711                && !m_pCurrentSnapshotItem))
    649712    );
    650     m_pActionRestoreSnapshot->setEnabled(
    651            !fBusy
     713    m_pActionDeleteSnapshot->setEnabled(
     714           m_fShapshotOperationsAllowed
     715        && fCanTakeDeleteSnapshot
    652716        && m_pCurrentSnapshotItem
    653717        && pSnapshotItem
    654718        && !pSnapshotItem->isCurrentStateItem()
    655719    );
    656     m_pActionDeleteSnapshot->setEnabled(
    657            m_fShapshotOperationsAllowed
    658         && fCanTakeDeleteSnapshot
     720    m_pActionRestoreSnapshot->setEnabled(
     721           !fBusy
    659722        && m_pCurrentSnapshotItem
    660723        && pSnapshotItem
     
    689752    if (m_pCurrentSnapshotItem && !pSnapshotItem->isCurrentStateItem())
    690753    {
     754        menu.addAction(m_pActionDeleteSnapshot);
     755        menu.addSeparator();
    691756        menu.addAction(m_pActionRestoreSnapshot);
    692         menu.addAction(m_pActionDeleteSnapshot);
    693757        menu.addAction(m_pActionShowSnapshotDetails);
    694758        menu.addSeparator();
     
    738802        restoreSnapshot(true /* suppress non-critical warnings */);
    739803    }
    740 }
    741 
    742 void UISnapshotPane::sltMachineDataChange(QString strMachineID)
    743 {
    744     /* Make sure it's our VM: */
    745     if (strMachineID != m_strMachineID)
    746         return;
    747 
    748     /* Prevent snapshot editing in the meantime: */
    749     QWriteLocker locker(m_pLockReadWrite);
    750 
    751     /* Recache state current item: */
    752     currentStateItem()->recache();
    753 }
    754 
    755 void UISnapshotPane::sltMachineStateChange(QString strMachineID, KMachineState enmState)
    756 {
    757     /* Make sure it's our VM: */
    758     if (strMachineID != m_strMachineID)
    759         return;
    760 
    761     /* Prevent snapshot editing in the meantime: */
    762     QWriteLocker locker(m_pLockReadWrite);
    763 
    764     /* Recache new machine state: */
    765     currentStateItem()->recache();
    766     currentStateItem()->updateCurrentState(enmState);
    767 }
    768 
    769 void UISnapshotPane::sltSessionStateChange(QString strMachineID, KSessionState enmState)
    770 {
    771     /* Make sure it's our VM: */
    772     if (strMachineID != m_strMachineID)
    773         return;
    774 
    775     /* Prevent snapshot editing in the meantime: */
    776     QWriteLocker locker(m_pLockReadWrite);
    777 
    778     /* Recache new session state: */
    779     m_enmSessionState = enmState;
    780     sltCurrentItemChanged(m_pSnapshotTree->currentItem());
    781 }
    782 
    783 void UISnapshotPane::sltUpdateSnapshotsAge()
    784 {
    785     /* Stop timer if active: */
    786     if (m_pTimerUpdateAge->isActive())
    787         m_pTimerUpdateAge->stop();
    788 
    789     /* Search for smallest snapshot age to optimize timer timeout: */
    790     const SnapshotAgeFormat age = traverseSnapshotAge(m_pSnapshotTree->invisibleRootItem());
    791     switch (age)
    792     {
    793         case SnapshotAgeFormat_InSeconds: m_pTimerUpdateAge->setInterval(5 * 1000); break;
    794         case SnapshotAgeFormat_InMinutes: m_pTimerUpdateAge->setInterval(60 * 1000); break;
    795         case SnapshotAgeFormat_InHours:   m_pTimerUpdateAge->setInterval(60 * 60 * 1000); break;
    796         case SnapshotAgeFormat_InDays:    m_pTimerUpdateAge->setInterval(24 * 60 * 60 * 1000); break;
    797         default:                          m_pTimerUpdateAge->setInterval(0); break;
    798     }
    799 
    800     /* Restart timer if necessary: */
    801     if (m_pTimerUpdateAge->interval() > 0)
    802         m_pTimerUpdateAge->start();
    803804}
    804805
     
    944945        layout()->addWidget(m_pSnapshotTree);
    945946    }
     947}
     948
     949void UISnapshotPane::refreshAll()
     950{
     951    /* Prevent snapshot editing in the meantime: */
     952    QWriteLocker locker(m_pLockReadWrite);
     953
     954    /* If VM is null, just updated the current itm: */
     955    if (m_comMachine.isNull())
     956    {
     957        sltCurrentItemChanged();
     958        return;
     959    }
     960
     961    /* Remember the selected item and it's first child: */
     962    QString strSelectedItem, strFirstChildOfSelectedItem;
     963    const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
     964    if (pSnapshotItem)
     965    {
     966        strSelectedItem = pSnapshotItem->snapshotID();
     967        if (pSnapshotItem->child(0))
     968            strFirstChildOfSelectedItem = UISnapshotItem::toSnapshotItem(pSnapshotItem->child(0))->snapshotID();
     969    }
     970
     971    /* Clear the tree: */
     972    m_pSnapshotTree->clear();
     973
     974    /* If machine has snapshots: */
     975    if (m_comMachine.GetSnapshotCount() > 0)
     976    {
     977        /* Get the first snapshot: */
     978        const CSnapshot comSnapshot = m_comMachine.FindSnapshot(QString());
     979
     980        /* Populate snapshot tree: */
     981        populateSnapshots(comSnapshot, 0);
     982        /* And make sure it has current snapshot item: */
     983        Assert(m_pCurrentSnapshotItem);
     984
     985        /* Add the "current state" item as a child to current snapshot item: */
     986        UISnapshotItem *pCsi = new UISnapshotItem(this, m_pCurrentSnapshotItem, m_comMachine);
     987        pCsi->setBold(true);
     988        pCsi->recache();
     989
     990        /* Search for a previously selected item: */
     991        UISnapshotItem *pCurrentItem = findItem(strSelectedItem);
     992        if (pCurrentItem == 0)
     993            pCurrentItem = findItem(strFirstChildOfSelectedItem);
     994        if (pCurrentItem == 0)
     995            pCurrentItem = currentStateItem();
     996
     997        /* Choose current item: */
     998        m_pSnapshotTree->scrollToItem(pCurrentItem);
     999        m_pSnapshotTree->setCurrentItem(pCurrentItem);
     1000        sltCurrentItemChanged(pCurrentItem);
     1001    }
     1002    /* If machine has no snapshots: */
     1003    else
     1004    {
     1005        /* There is no current snapshot item: */
     1006        m_pCurrentSnapshotItem = 0;
     1007
     1008        /* Add the "current state" item as a child of snapshot tree: */
     1009        UISnapshotItem *pCsi = new UISnapshotItem(this, m_pSnapshotTree, m_comMachine);
     1010        pCsi->setBold(true);
     1011        pCsi->recache();
     1012
     1013        /* Choose current item: */
     1014        m_pSnapshotTree->setCurrentItem(pCsi);
     1015        sltCurrentItemChanged(pCsi);
     1016    }
     1017
     1018    /* Update age: */
     1019    sltUpdateSnapshotsAge();
     1020
     1021    /* Adjust snapshot tree: */
     1022    m_pSnapshotTree->resizeColumnToContents(0);
     1023}
     1024
     1025void UISnapshotPane::populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem)
     1026{
     1027    /* Create a child of passed item: */
     1028    UISnapshotItem *pSnapshotItem = pItem ? new UISnapshotItem(this, pItem, comSnapshot) :
     1029                                            new UISnapshotItem(this, m_pSnapshotTree, comSnapshot);
     1030    /* And recache it's content: */
     1031    pSnapshotItem->recache();
     1032
     1033    /* Mark current snapshot item bold and remember it: */
     1034    CSnapshot comCurrentSnapshot = m_comMachine.GetCurrentSnapshot();
     1035    if (!comCurrentSnapshot.isNull() && comCurrentSnapshot.GetId() == comSnapshot.GetId())
     1036    {
     1037        pSnapshotItem->setBold(true);
     1038        m_pCurrentSnapshotItem = pSnapshotItem;
     1039    }
     1040
     1041    /* Walk through the children recursively: */
     1042    foreach (const CSnapshot &comIteratedSnapshot, comSnapshot.GetChildren())
     1043        populateSnapshots(comIteratedSnapshot, pSnapshotItem);
     1044
     1045    /* Expand the newly created item: */
     1046    pSnapshotItem->setExpanded(true);
     1047    /* And mark it as editable: */
     1048    pSnapshotItem->setFlags(pSnapshotItem->flags() | Qt::ItemIsEditable);
    9461049}
    9471050
     
    10611164}
    10621165
     1166bool UISnapshotPane::deleteSnapshot()
     1167{
     1168    /* Simulate try-catch block: */
     1169    bool fSuccess = false;
     1170    do
     1171    {
     1172        /* Acquire currently chosen snapshot item: */
     1173        const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
     1174        AssertPtr(pSnapshotItem);
     1175        if (!pSnapshotItem)
     1176            break;
     1177
     1178        /* Get corresponding snapshot: */
     1179        const CSnapshot comSnapshot = pSnapshotItem->snapshot();
     1180        Assert(!comSnapshot.isNull());
     1181        if (comSnapshot.isNull())
     1182            break;
     1183
     1184        /* Ask if user really wants to remove the selected snapshot: */
     1185        if (!msgCenter().confirmSnapshotRemoval(comSnapshot.GetName()))
     1186            break;
     1187
     1188        /** @todo check available space on the target filesystem etc etc. */
     1189#if 0
     1190        if (!msgCenter().warnAboutSnapshotRemovalFreeSpace(comSnapshot.GetName(),
     1191                                                           "/home/juser/.VirtualBox/Machines/SampleVM/Snapshots/{01020304-0102-0102-0102-010203040506}.vdi",
     1192                                                           "59 GiB",
     1193                                                           "15 GiB"))
     1194            break;
     1195#endif
     1196
     1197        /* Open a session (this call will handle all errors): */
     1198        CSession comSession;
     1199        if (m_enmSessionState != KSessionState_Unlocked)
     1200            comSession = vboxGlobal().openExistingSession(m_strMachineID);
     1201        else
     1202            comSession = vboxGlobal().openSession(m_strMachineID);
     1203        if (comSession.isNull())
     1204            break;
     1205
     1206        /* Simulate try-catch block: */
     1207        do
     1208        {
     1209            /* Remove chosen snapshot: */
     1210            CMachine comMachine = comSession.GetMachine();
     1211            CProgress comProgress = comMachine.DeleteSnapshot(pSnapshotItem->snapshotID());
     1212            if (!comMachine.isOk())
     1213            {
     1214                msgCenter().cannotRemoveSnapshot(comMachine,  comSnapshot.GetName(), m_comMachine.GetName());
     1215                break;
     1216            }
     1217
     1218            /* Show snapshot removing progress: */
     1219            msgCenter().showModalProgressDialog(comProgress, m_comMachine.GetName(), ":/progress_snapshot_discard_90px.png");
     1220            if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     1221            {
     1222                msgCenter().cannotRemoveSnapshot(comProgress,  comSnapshot.GetName(), m_comMachine.GetName());
     1223                break;
     1224            }
     1225
     1226            /* Mark snapshot removing successful: */
     1227            fSuccess = true;
     1228        }
     1229        while (0);
     1230
     1231        /* Cleanup try-catch block: */
     1232        comSession.UnlockMachine();
     1233    }
     1234    while (0);
     1235
     1236    /* Return result: */
     1237    return fSuccess;
     1238}
     1239
    10631240bool UISnapshotPane::restoreSnapshot(bool fSuppressNonCriticalWarnings /* = false */)
    10641241{
     
    11361313}
    11371314
    1138 bool UISnapshotPane::deleteSnapshot()
    1139 {
    1140     /* Simulate try-catch block: */
    1141     bool fSuccess = false;
    1142     do
    1143     {
    1144         /* Acquire currently chosen snapshot item: */
    1145         const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    1146         AssertPtr(pSnapshotItem);
    1147         if (!pSnapshotItem)
    1148             break;
    1149 
    1150         /* Get corresponding snapshot: */
    1151         const CSnapshot comSnapshot = pSnapshotItem->snapshot();
    1152         Assert(!comSnapshot.isNull());
    1153         if (comSnapshot.isNull())
    1154             break;
    1155 
    1156         /* Ask if user really wants to remove the selected snapshot: */
    1157         if (!msgCenter().confirmSnapshotRemoval(comSnapshot.GetName()))
    1158             break;
    1159 
    1160         /** @todo check available space on the target filesystem etc etc. */
    1161 #if 0
    1162         if (!msgCenter().warnAboutSnapshotRemovalFreeSpace(comSnapshot.GetName(),
    1163                                                            "/home/juser/.VirtualBox/Machines/SampleVM/Snapshots/{01020304-0102-0102-0102-010203040506}.vdi",
    1164                                                            "59 GiB",
    1165                                                            "15 GiB"))
    1166             break;
    1167 #endif
    1168 
    1169         /* Open a session (this call will handle all errors): */
    1170         CSession comSession;
    1171         if (m_enmSessionState != KSessionState_Unlocked)
    1172             comSession = vboxGlobal().openExistingSession(m_strMachineID);
    1173         else
    1174             comSession = vboxGlobal().openSession(m_strMachineID);
    1175         if (comSession.isNull())
    1176             break;
    1177 
    1178         /* Simulate try-catch block: */
    1179         do
    1180         {
    1181             /* Remove chosen snapshot: */
    1182             CMachine comMachine = comSession.GetMachine();
    1183             CProgress comProgress = comMachine.DeleteSnapshot(pSnapshotItem->snapshotID());
    1184             if (!comMachine.isOk())
    1185             {
    1186                 msgCenter().cannotRemoveSnapshot(comMachine,  comSnapshot.GetName(), m_comMachine.GetName());
    1187                 break;
    1188             }
    1189 
    1190             /* Show snapshot removing progress: */
    1191             msgCenter().showModalProgressDialog(comProgress, m_comMachine.GetName(), ":/progress_snapshot_discard_90px.png");
    1192             if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    1193             {
    1194                 msgCenter().cannotRemoveSnapshot(comProgress,  comSnapshot.GetName(), m_comMachine.GetName());
    1195                 break;
    1196             }
    1197 
    1198             /* Mark snapshot removing successful: */
    1199             fSuccess = true;
    1200         }
    1201         while (0);
    1202 
    1203         /* Cleanup try-catch block: */
    1204         comSession.UnlockMachine();
    1205     }
    1206     while (0);
    1207 
    1208     /* Return result: */
    1209     return fSuccess;
    1210 }
    1211 
    12121315void UISnapshotPane::showSnapshotDetails()
    12131316{
     
    12561359}
    12571360
    1258 void UISnapshotPane::refreshAll()
    1259 {
    1260     /* Prevent snapshot editing in the meantime: */
    1261     QWriteLocker locker(m_pLockReadWrite);
    1262 
    1263     /* If VM is null, just updated the current itm: */
    1264     if (m_comMachine.isNull())
    1265     {
    1266         sltCurrentItemChanged();
    1267         return;
    1268     }
    1269 
    1270     /* Remember the selected item and it's first child: */
    1271     QString strSelectedItem, strFirstChildOfSelectedItem;
    1272     const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    1273     if (pSnapshotItem)
    1274     {
    1275         strSelectedItem = pSnapshotItem->snapshotID();
    1276         if (pSnapshotItem->child(0))
    1277             strFirstChildOfSelectedItem = UISnapshotItem::toSnapshotItem(pSnapshotItem->child(0))->snapshotID();
    1278     }
    1279 
    1280     /* Clear the tree: */
    1281     m_pSnapshotTree->clear();
    1282 
    1283     /* If machine has snapshots: */
    1284     if (m_comMachine.GetSnapshotCount() > 0)
    1285     {
    1286         /* Get the first snapshot: */
    1287         const CSnapshot comSnapshot = m_comMachine.FindSnapshot(QString());
    1288 
    1289         /* Populate snapshot tree: */
    1290         populateSnapshots(comSnapshot, 0);
    1291         /* And make sure it has current snapshot item: */
    1292         Assert(m_pCurrentSnapshotItem);
    1293 
    1294         /* Add the "current state" item as a child to current snapshot item: */
    1295         UISnapshotItem *pCsi = new UISnapshotItem(this, m_pCurrentSnapshotItem, m_comMachine);
    1296         pCsi->setBold(true);
    1297         pCsi->recache();
    1298 
    1299         /* Search for a previously selected item: */
    1300         UISnapshotItem *pCurrentItem = findItem(strSelectedItem);
    1301         if (pCurrentItem == 0)
    1302             pCurrentItem = findItem(strFirstChildOfSelectedItem);
    1303         if (pCurrentItem == 0)
    1304             pCurrentItem = currentStateItem();
    1305 
    1306         /* Choose current item: */
    1307         m_pSnapshotTree->scrollToItem(pCurrentItem);
    1308         m_pSnapshotTree->setCurrentItem(pCurrentItem);
    1309         sltCurrentItemChanged(pCurrentItem);
    1310     }
    1311     /* If machine has no snapshots: */
    1312     else
    1313     {
    1314         /* There is no current snapshot item: */
    1315         m_pCurrentSnapshotItem = 0;
    1316 
    1317         /* Add the "current state" item as a child of snapshot tree: */
    1318         UISnapshotItem *pCsi = new UISnapshotItem(this, m_pSnapshotTree, m_comMachine);
    1319         pCsi->setBold(true);
    1320         pCsi->recache();
    1321 
    1322         /* Choose current item: */
    1323         m_pSnapshotTree->setCurrentItem(pCsi);
    1324         sltCurrentItemChanged(pCsi);
    1325     }
    1326 
    1327     /* Update age: */
    1328     sltUpdateSnapshotsAge();
    1329 
    1330     /* Adjust snapshot tree: */
    1331     m_pSnapshotTree->resizeColumnToContents(0);
    1332 }
    1333 
    1334 void UISnapshotPane::populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem)
    1335 {
    1336     /* Create a child of passed item: */
    1337     UISnapshotItem *pSnapshotItem = pItem ? new UISnapshotItem(this, pItem, comSnapshot) :
    1338                                             new UISnapshotItem(this, m_pSnapshotTree, comSnapshot);
    1339     /* And recache it's content: */
    1340     pSnapshotItem->recache();
    1341 
    1342     /* Mark current snapshot item bold and remember it: */
    1343     CSnapshot comCurrentSnapshot = m_comMachine.GetCurrentSnapshot();
    1344     if (!comCurrentSnapshot.isNull() && comCurrentSnapshot.GetId() == comSnapshot.GetId())
    1345     {
    1346         pSnapshotItem->setBold(true);
    1347         m_pCurrentSnapshotItem = pSnapshotItem;
    1348     }
    1349 
    1350     /* Walk through the children recursively: */
    1351     foreach (const CSnapshot &comIteratedSnapshot, comSnapshot.GetChildren())
    1352         populateSnapshots(comIteratedSnapshot, pSnapshotItem);
    1353 
    1354     /* Expand the newly created item: */
    1355     pSnapshotItem->setExpanded(true);
    1356     /* And mark it as editable: */
    1357     pSnapshotItem->setFlags(pSnapshotItem->flags() | Qt::ItemIsEditable);
    1358 }
    1359 
    13601361UISnapshotItem *UISnapshotPane::findItem(const QString &strSnapshotID) const
    13611362{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r67120 r67121  
    7373private slots:
    7474
    75     /** @name Tree-widget handlers.
    76       * @{ */
    77         /** Handles cursor change to @a pItem. */
    78         void sltCurrentItemChanged(QTreeWidgetItem *pItem = 0);
    79         /** Handles context menu request for @a point. */
    80         void sltContextMenuRequested(const QPoint &point);
    81         /** Handles modification for @a pItem. */
    82         void sltItemChanged(QTreeWidgetItem *pItem);
    83         /** Handles double-click for @a pItem. */
    84         void sltItemDoubleClicked(QTreeWidgetItem *pItem);
    85     /** @} */
    86 
    8775    /** @name Main event handlers.
    8876      * @{ */
     
    115103    /** @} */
    116104
     105    /** @name Tree-widget handlers.
     106      * @{ */
     107        /** Handles cursor change to @a pItem. */
     108        void sltCurrentItemChanged(QTreeWidgetItem *pItem = 0);
     109        /** Handles context menu request for @a point. */
     110        void sltContextMenuRequested(const QPoint &point);
     111        /** Handles modification for @a pItem. */
     112        void sltItemChanged(QTreeWidgetItem *pItem);
     113        /** Handles double-click for @a pItem. */
     114        void sltItemDoubleClicked(QTreeWidgetItem *pItem);
     115    /** @} */
     116
    117117private:
    118118
     
    141141        /** Proposes to take a snapshot. */
    142142        bool takeSnapshot();
     143        /** Proposes to delete the snapshot. */
     144        bool deleteSnapshot();
    143145        /** Proposes to restore the snapshot. */
    144146        bool restoreSnapshot(bool fSuppressNonCriticalWarnings = false);
    145         /** Proposes to delete the snapshot. */
    146         bool deleteSnapshot();
    147147        /** Displays the snapshot details dialog. */
    148148        void showSnapshotDetails();
     
    170170        /** Holds the cached session state. */
    171171        KSessionState  m_enmSessionState;
    172         /** Holds the current snapshot item reference. */
    173         UISnapshotItem *m_pCurrentSnapshotItem;
     172
     173        /** Holds whether the snapshot operations are allowed. */
     174        bool  m_fShapshotOperationsAllowed;
     175
    174176        /** Holds the snapshot item editing protector. */
    175177        QReadWriteLock *m_pLockReadWrite;
     178
     179        /** Holds the cached snapshot-item pixmap for 'offline' state. */
     180        QIcon *m_pIconSnapshotOffline;
     181        /** Holds the cached snapshot-item pixmap for 'online' state. */
     182        QIcon *m_pIconSnapshotOnline;
     183
     184        /** Holds the snapshot age update timer. */
     185        QTimer *m_pTimerUpdateAge;
    176186    /** @} */
    177187
     
    182192        /** Holds the Take Snapshot action instance. */
    183193        QAction   *m_pActionTakeSnapshot;
     194        /** Holds the Delete Snapshot action instance. */
     195        QAction   *m_pActionDeleteSnapshot;
    184196        /** Holds the Restore Snapshot action instance. */
    185197        QAction   *m_pActionRestoreSnapshot;
    186         /** Holds the Delete Snapshot action instance. */
    187         QAction   *m_pActionDeleteSnapshot;
    188198        /** Holds the Show Snapshot Details action instance. */
    189199        QAction   *m_pActionShowSnapshotDetails;
     
    191201        QAction   *m_pActionCloneSnapshot;
    192202
    193         /** Holds the snapshot age update timer. */
    194         QTimer *m_pTimerUpdateAge;
    195 
    196         /** Holds whether the snapshot operations are allowed. */
    197         bool  m_fShapshotOperationsAllowed;
    198 
    199         /** Holds the cached snapshot-item pixmap for 'offline' state. */
    200         QIcon *m_pIconSnapshotOffline;
    201         /** Holds the cached snapshot-item pixmap for 'online' state. */
    202         QIcon *m_pIconSnapshotOnline;
    203 
    204203        /** Holds the snapshot tree instance. */
    205204        UISnapshotTree *m_pSnapshotTree;
     205        /** Holds the current snapshot item reference. */
     206        UISnapshotItem *m_pCurrentSnapshotItem;
    206207    /** @} */
    207208};
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