VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxSnapshotsWgt.ui.h@ 7669

Last change on this file since 7669 was 7669, checked in by vboxsync, 17 years ago

VBoxTakeSnapshotDlg ported qt3=>qt4.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.8 KB
Line 
1//Added by qt3to4:
2#include <Q3PopupMenu>
3/**
4 *
5 * VBox frontends: Qt GUI ("VirtualBox"):
6 * Snapshot details dialog (Qt Designer)
7 */
8
9/*
10 * Copyright (C) 2006-2007 innotek GmbH
11 *
12 * This file is part of VirtualBox Open Source Edition (OSE), as
13 * available from http://www.virtualbox.org. This file is free software;
14 * you can redistribute it and/or modify it under the terms of the GNU
15 * General Public License (GPL) as published by the Free Software
16 * Foundation, in version 2 as it comes in the "COPYING" file of the
17 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19 */
20
21/****************************************************************************
22** ui.h extension file, included from the uic-generated form implementation.
23**
24** If you want to add, delete, or rename functions or slots, use
25** Qt Designer to update this file, preserving your code.
26**
27** You should not define a constructor or destructor in this file.
28** Instead, write your code in functions called init() and destroy().
29** These will automatically be called by the form's constructor and
30** destructor.
31*****************************************************************************/
32
33/** QListViewItem subclass for snapshots */
34class VBoxSnapshotsWgt::ListViewItem : public Q3ListViewItem
35{
36public:
37
38 /** Normal snapshot item */
39 ListViewItem (Q3ListView *lv, const CSnapshot &aSnapshot)
40 : Q3ListViewItem (lv)
41 , mBld (false), mItal (false)
42 , mSnapshot (aSnapshot)
43 {
44 recache();
45 }
46
47 /** Normal snapshot item */
48 ListViewItem (Q3ListViewItem *lvi, const CSnapshot &aSnapshot)
49 : Q3ListViewItem (lvi)
50 , mBld (false), mItal (false)
51 , mSnapshot (aSnapshot)
52 {
53 recache();
54 }
55
56 /** Current state item */
57 ListViewItem (Q3ListView *lv, const CMachine &aMachine)
58 : Q3ListViewItem (lv)
59 , mBld (false), mItal (true)
60 , mMachine (aMachine)
61 {
62 recache();
63 updateCurrentState (mMachine.GetState());
64 }
65
66 /** Current state item */
67 ListViewItem (Q3ListViewItem *lvi, const CMachine &aMachine)
68 : Q3ListViewItem (lvi)
69 , mBld (false), mItal (true)
70 , mMachine (aMachine)
71 {
72 recache();
73 updateCurrentState (mMachine.GetState());
74 }
75
76 bool bold() const { return mBld; }
77 void setBold (bool bold)
78 {
79 mBld = bold;
80 repaint();
81 }
82
83 bool italic() const { return mItal; }
84 void setItalic (bool italic)
85 {
86 mItal = italic;
87 repaint();
88 }
89
90 void paintCell (QPainter *p, const QColorGroup &cg, int column, int width, int align)
91 {
92 QFont font = p->font();
93 if (font.bold() != mBld)
94 font.setBold (mBld);
95 if (font.italic() != mItal)
96 font.setItalic (mItal);
97 if (font != p->font())
98 p->setFont (font);
99 Q3ListViewItem::paintCell (p, cg, column, width, align);
100 }
101
102 int width (const QFontMetrics &fm, const Q3ListView *lv, int c) const
103 {
104 QFont font = lv->font();
105 if (font.bold() != mBld)
106 font.setBold (mBld);
107 if (font.italic() != mItal)
108 font.setItalic (mItal);
109 if (font != lv->font())
110 return Q3ListViewItem::width (QFontMetrics (font), lv, c);
111 return Q3ListViewItem::width (fm, lv, c);
112 }
113
114 CSnapshot snapshot() const { return mSnapshot; }
115 QUuid snapshotId() const { return mId; }
116
117 KMachineState machineState() const { return mMachineState; }
118
119 void recache()
120 {
121 if (!mSnapshot.isNull())
122 {
123 mId = mSnapshot.GetId();
124 setText (0, mSnapshot.GetName());
125 mOnline = mSnapshot.GetOnline();
126 setPixmap (0, vboxGlobal().snapshotIcon (mOnline));
127 mDesc = mSnapshot.GetDescription();
128 mTimestamp.setTime_t (mSnapshot.GetTimeStamp() / 1000);
129 mCurStateModified = false;
130 }
131 else
132 {
133 Assert (!mMachine.isNull());
134 mCurStateModified = mMachine.GetCurrentStateModified();
135 setText (0, mCurStateModified ?
136 VBoxSnapshotsWgt::tr ("Current State (changed)",
137 "Current State (Modified)") :
138 VBoxSnapshotsWgt::tr ("Current State",
139 "Current State (Unmodified)"));
140 mDesc = mCurStateModified ?
141 VBoxSnapshotsWgt::tr ("The current state differs from the state "
142 "stored in the current snapshot") :
143 parent() != 0 ? /* we're not the only item in the view */
144 VBoxSnapshotsWgt::tr ("The current state is identical to the state "
145 "stored in the current snapshot") :
146 QString::null;
147 }
148 }
149
150 void updateCurrentState (KMachineState aState)
151 {
152 AssertReturn (!mMachine.isNull(), (void) 0);
153 setPixmap (0, vboxGlobal().toIcon (aState));
154 mMachineState = aState;
155 mTimestamp.setTime_t (mMachine.GetLastStateChange() / 1000);
156 }
157
158 QString toolTipText() const
159 {
160 QString name = !mSnapshot.isNull() ?
161 text (0) : text (0);
162
163 bool dateTimeToday = mTimestamp.date() == QDate::currentDate();
164 QString dateTime = dateTimeToday ?
165 mTimestamp.time().toString (Qt::LocalDate) :
166 mTimestamp.toString (Qt::LocalDate);
167
168 QString details;
169 if (!mSnapshot.isNull())
170 {
171 /* the current snapshot is always bold */
172 if (mBld)
173 details = VBoxSnapshotsWgt::tr (" (current, ", "Snapshot details");
174 else
175 details = " (";
176 details += mOnline ? VBoxSnapshotsWgt::tr ("online)", "Snapshot details")
177 : VBoxSnapshotsWgt::tr ("offline)", "Snapshot details");
178
179 if (dateTimeToday)
180 dateTime = VBoxSnapshotsWgt::tr ("Taken at %1", "Snapshot (time)")
181 .arg (dateTime);
182 else
183 dateTime = VBoxSnapshotsWgt::tr ("Taken on %1", "Snapshot (date + time)")
184 .arg (dateTime);
185 }
186 else
187 {
188 dateTime = VBoxSnapshotsWgt::tr ("%1 since %2", "Current State (time or date + time)")
189 .arg (vboxGlobal().toString (mMachineState))
190 .arg (dateTime);
191 }
192
193 QString toolTip = QString ("<nobr><b>%1</b>%2</nobr><br><nobr>%3</nobr>")
194 .arg (name) .arg (details)
195 .arg (dateTime);
196
197 if (!mDesc.isEmpty())
198 toolTip += "<br><hr>" + mDesc;
199
200 return toolTip;
201 }
202
203 void okRename (int aCol)
204 {
205 Q3ListViewItem::okRename (aCol);
206 AssertReturn (aCol == 0 && !mSnapshot.isNull(), (void) 0);
207 mSnapshot.SetName (text (0));
208 }
209
210private:
211
212 bool mBld : 1;
213 bool mItal : 1;
214
215 CSnapshot mSnapshot;
216 CMachine mMachine;
217
218 QUuid mId;
219 bool mOnline;
220 QString mDesc;
221 QDateTime mTimestamp;
222
223 bool mCurStateModified;
224 KMachineState mMachineState;
225};
226
227////////////////////////////////////////////////////////////////////////////////
228
229/** Tooltips for snapshots */
230#warning port me
231//class VBoxSnapshotsWgt::ToolTip : public QToolTip
232//{
233//public:
234//
235// ToolTip (Q3ListView *aLV, QWidget *aParent, QToolTipGroup *aTG = 0)
236// : QToolTip (aParent, aTG), mLV (aLV)
237// {}
238//
239// virtual ~ToolTip()
240// {
241// remove (parentWidget());
242// }
243//
244// void maybeTip (const QPoint &aPnt);
245//
246//private:
247//
248// Q3ListView *mLV;
249//};
250
251//void VBoxSnapshotsWgt::ToolTip::maybeTip (const QPoint &aPnt)
252//{
253// ListViewItem *lvi = static_cast <ListViewItem *> (mLV->itemAt (aPnt));
254// if (!lvi)
255// return;
256//
257// if (parentWidget()->topLevelWidget()->inherits ("QMainWindow"))
258// {
259// /*
260// * Ensure the main window doesn't show the text from the previous
261// * tooltip in the status bar.
262// */
263// QToolTipGroup *toolTipGroup =
264// (::qt_cast <Q3MainWindow *> (parentWidget()->topLevelWidget()))->
265// toolTipGroup();
266// if (toolTipGroup)
267// {
268// int index = toolTipGroup->metaObject()->findSignal("removeTip()", false);
269// toolTipGroup->qt_emit (index, 0);
270// }
271// }
272//
273// tip (mLV->itemRect (lvi), lvi->toolTipText());
274//}
275
276////////////////////////////////////////////////////////////////////////////////
277
278void VBoxSnapshotsWgt::init()
279{
280 mCurSnapshotItem = 0;
281
282 listView->setItemMargin (2);
283 listView->header()->hide();
284 listView->setRootIsDecorated (true);
285 /* we have our own tooltips */
286 listView->setShowToolTips (false);
287 /* disable sorting */
288 listView->setSorting (-1);
289 /* disable unselecting items by clicking in the unused area of the list */
290 new QIListViewSelectionPreserver (this, listView);
291
292 /* toolbar */
293 VBoxToolBar *toolBar = new VBoxToolBar (0, this);
294
295 curStateActionGroup->addTo (toolBar);
296 toolBar->addSeparator();
297 snapshotActionGroup->addTo (toolBar);
298 toolBar->addSeparator();
299 showSnapshotDetailsAction->addTo (toolBar);
300
301 toolBar->setUsesTextLabel (false);
302 toolBar->setUsesBigPixmaps (true);
303 toolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
304#warning port me
305// VBoxSnapshotsWgtLayout->insertWidget (0, toolBar);
306#ifdef Q_WS_MAC
307 toolBar->setMacStyle();
308#endif
309
310 /* context menu */
311 mContextMenu = new Q3PopupMenu (this);
312 mContextMenuDirty = true;
313
314 /* icons */
315 discardSnapshotAction->setIconSet (VBoxGlobal::iconSetEx (
316 ":/discard_snapshot_22px.png", ":/discard_snapshot_16px.png",
317 ":/discard_snapshot_dis_22px.png", ":/discard_snapshot_dis_16px.png"));
318 takeSnapshotAction->setIconSet (VBoxGlobal::iconSetEx (
319 ":/take_snapshot_22px.png", ":/take_snapshot_16px.png",
320 ":/take_snapshot_dis_22px.png", ":/take_snapshot_dis_16px.png"));
321 revertToCurSnapAction->setIconSet (VBoxGlobal::iconSetEx (
322 ":/discard_cur_state_22px.png", ":/discard_cur_state_16px.png",
323 ":/discard_cur_state_dis_22px.png", ":/discard_cur_state_dis_16px.png"));
324 discardCurSnapAndStateAction->setIconSet (VBoxGlobal::iconSetEx (
325 ":/discard_cur_state_snapshot_22px.png", ":/discard_cur_state_snapshot_16px.png",
326 ":/discard_cur_state_snapshot_dis_22px.png", ":/discard_cur_state_snapshot_dis_16px.png"));
327 showSnapshotDetailsAction->setIconSet (VBoxGlobal::iconSetEx (
328 ":/show_snapshot_details_22px.png", ":/show_snapshot_details_16px.png",
329 ":/show_snapshot_details_dis_22px.png", ":/show_snapshot_details_dis_16px.png"));
330
331 /* tooltip */
332#warning port me
333// mToolTip = new ToolTip (listView, listView->viewport());
334}
335
336void VBoxSnapshotsWgt::destroy()
337{
338 delete mToolTip;
339}
340
341void VBoxSnapshotsWgt::setMachine (const CMachine &aMachine)
342{
343 mMachine = aMachine;
344
345 if (aMachine.isNull())
346 {
347 mMachineId = QUuid();
348 mSessionState = KSessionState_Null;
349 }
350 else
351 {
352 mMachineId = aMachine.GetId();
353 mSessionState = aMachine.GetSessionState();
354 }
355
356 refreshAll();
357}
358
359VBoxSnapshotsWgt::ListViewItem *VBoxSnapshotsWgt::findItem (const QUuid &aSnapshotId)
360{
361 Q3ListViewItemIterator it (listView);
362 while (it.current())
363 {
364 ListViewItem *lvi = static_cast <ListViewItem *> (it.current());
365 if (lvi->snapshotId() == aSnapshotId)
366 return lvi;
367 ++ it;
368 }
369
370 return 0;
371}
372
373void VBoxSnapshotsWgt::refreshAll (bool aKeepSelected /* = false */)
374{
375 QUuid selected, selectedFirstChild;
376 if (aKeepSelected)
377 {
378 ListViewItem *cur = static_cast <ListViewItem *> (listView->selectedItem());
379 Assert (cur);
380 if (cur)
381 {
382 selected = cur->snapshotId();
383 if (cur->firstChild())
384 selectedFirstChild =
385 static_cast <ListViewItem *> (cur->firstChild())->snapshotId();
386 }
387 }
388
389 listView->clear();
390
391 if (mMachine.isNull())
392 {
393 listView_currentChanged (NULL);
394 return;
395 }
396
397 /* get the first snapshot */
398 if (mMachine.GetSnapshotCount() > 0)
399 {
400 CSnapshot snapshot = mMachine.GetSnapshot (QUuid());
401
402 populateSnapshots (snapshot, 0);
403 Assert (mCurSnapshotItem);
404
405 /* add the "current state" item */
406 new ListViewItem (mCurSnapshotItem, mMachine);
407
408 ListViewItem *cur = 0;
409 if (aKeepSelected)
410 {
411 cur = findItem (selected);
412 if (cur == 0)
413 cur = findItem (selectedFirstChild);
414 }
415 if (cur == 0)
416 cur = curStateItem();
417 listView->setSelected (cur, true);
418 listView->ensureItemVisible (cur);
419 }
420 else
421 {
422 mCurSnapshotItem = NULL;
423
424 /* add the "current state" item */
425 ListViewItem *csi = new ListViewItem (listView, mMachine);
426
427 listView->setSelected (csi, true);
428 /*
429 * stupid Qt doesn't issue this signal when only one item is added
430 * to the empty list -- do it manually
431 */
432 listView_currentChanged (csi);
433 }
434
435 listView->adjustColumn (0);
436}
437
438VBoxSnapshotsWgt::ListViewItem *VBoxSnapshotsWgt::curStateItem()
439{
440 Q3ListViewItem *csi = mCurSnapshotItem ? mCurSnapshotItem->firstChild()
441 : listView->firstChild();
442 Assert (csi);
443 return static_cast <ListViewItem *> (csi);
444}
445
446void VBoxSnapshotsWgt::populateSnapshots (const CSnapshot &snapshot, Q3ListViewItem *item)
447{
448 ListViewItem *si = 0;
449 if (item)
450 si = new ListViewItem (item, snapshot);
451 else
452 si = new ListViewItem (listView, snapshot);
453
454 if (mMachine.GetCurrentSnapshot().GetId() == snapshot.GetId())
455 {
456 si->setBold (true);
457 mCurSnapshotItem = si;
458 }
459
460 CSnapshotEnumerator en = snapshot.GetChildren().Enumerate();
461 while (en.HasMore())
462 {
463 CSnapshot sn = en.GetNext();
464 populateSnapshots (sn, si);
465 }
466
467 si->setOpen (true);
468 si->setRenameEnabled (0, true);
469}
470
471void VBoxSnapshotsWgt::listView_currentChanged (Q3ListViewItem *item)
472{
473 /* Make the selected item visible */
474 if (item)
475 {
476 QPoint oldPos (listView->contentsX(), listView->contentsY());
477 listView->ensureItemVisible (item);
478 listView->setContentsPos (listView->treeStepSize() * item->depth(),
479 listView->contentsY());
480 /* Sometimes (here, when both X and Y are changed), affected items
481 * are not properly updated after moving the contents. Fix it. */
482 if (oldPos != QPoint (listView->contentsX(), listView->contentsY()))
483 listView->triggerUpdate();
484 }
485
486 /* whether another direct session is open or not */
487 bool busy = mSessionState != KSessionState_Closed;
488
489 /* enable/disable snapshot actions */
490 snapshotActionGroup->setEnabled (!busy &&
491 item && mCurSnapshotItem && item != mCurSnapshotItem->firstChild());
492
493 /* enable/disable the details action regardles of the session state */
494 showSnapshotDetailsAction->setEnabled (
495 item && mCurSnapshotItem && item != mCurSnapshotItem->firstChild());
496
497 /* enable/disable current state actions */
498 curStateActionGroup->setEnabled (!busy &&
499 item && mCurSnapshotItem && item == mCurSnapshotItem->firstChild());
500
501 /* the Take Snapshot action is always enabled for the current state */
502 takeSnapshotAction->setEnabled ((!busy && curStateActionGroup->isEnabled()) ||
503 (item && !mCurSnapshotItem));
504
505 mContextMenuDirty = true;
506}
507
508void VBoxSnapshotsWgt::
509listView_contextMenuRequested (Q3ListViewItem *item, const QPoint &pnt,
510 int /* col */)
511{
512 if (!item)
513 return;
514
515 if (mContextMenuDirty)
516 {
517 mContextMenu->clear();
518
519 if (!mCurSnapshotItem)
520 {
521 /* we have only one item -- current state */
522 curStateActionGroup->addTo (mContextMenu);
523 }
524 else
525 {
526 if (item == mCurSnapshotItem->firstChild())
527 {
528 /* current state is selected */
529 curStateActionGroup->addTo (mContextMenu);
530 }
531 else
532 {
533 /* snapshot is selected */
534 snapshotActionGroup->addTo (mContextMenu);
535 mContextMenu->insertSeparator();
536 showSnapshotDetailsAction->addTo (mContextMenu);
537 }
538 }
539
540 mContextMenuDirty = false;
541 }
542
543 mContextMenu->exec (pnt);
544}
545
546void VBoxSnapshotsWgt::discardSnapshot()
547{
548 ListViewItem *item = static_cast <ListViewItem *> (listView->currentItem());
549 AssertReturn (item, (void) 0);
550
551 QUuid snapId = item->snapshotId();
552 AssertReturn (!snapId.isNull(), (void) 0);
553
554 /* open a direct session (this call will handle all errors) */
555 CSession session = vboxGlobal().openSession (mMachineId);
556 if (session.isNull())
557 return;
558
559 CConsole console = session.GetConsole();
560 CProgress progress = console.DiscardSnapshot (snapId);
561 if (console.isOk())
562 {
563 /* show the progress dialog */
564 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
565 vboxProblem().mainWindowShown());
566
567 if (progress.GetResultCode() != 0)
568 vboxProblem().cannotDiscardSnapshot (progress, mMachine.GetSnapshot (snapId));
569 }
570 else
571 vboxProblem().cannotDiscardSnapshot (console, mMachine.GetSnapshot (snapId));
572
573 session.Close();
574}
575
576void VBoxSnapshotsWgt::takeSnapshot()
577{
578 ListViewItem *item = static_cast <ListViewItem *> (listView->currentItem());
579 AssertReturn (item, (void) 0);
580
581 VBoxTakeSnapshotDlg dlg (this);
582
583 QString typeId = mMachine.GetOSTypeId();
584 dlg.mLbIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (typeId));
585
586 /* search for the max available filter index */
587 int maxSnapShotIndex = 0;
588 QString snapShotName = tr ("Snapshot %1");
589 QRegExp regExp (QString ("^") + snapShotName.arg ("([0-9]+)") + QString ("$"));
590 Q3ListViewItemIterator iterator (listView);
591 while (*iterator)
592 {
593 QString snapShot = (*iterator)->text (0);
594 int pos = regExp.search (snapShot);
595 if (pos != -1)
596 maxSnapShotIndex = regExp.cap (1).toInt() > maxSnapShotIndex ?
597 regExp.cap (1).toInt() : maxSnapShotIndex;
598 ++ iterator;
599 }
600 dlg.mLeName->setText (snapShotName.arg (maxSnapShotIndex + 1));
601
602 if (dlg.exec() == QDialog::Accepted)
603 {
604 /* open a direct session (this call will handle all errors) */
605 CSession session = vboxGlobal().openSession (mMachineId);
606 if (session.isNull())
607 return;
608
609 CConsole console = session.GetConsole();
610 CProgress progress =
611 console.TakeSnapshot (dlg.mLeName->text().stripWhiteSpace(),
612 dlg.mTeDescription->text());
613 if (console.isOk())
614 {
615 /* show the progress dialog */
616 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
617 vboxProblem().mainWindowShown());
618
619 if (progress.GetResultCode() != 0)
620 vboxProblem().cannotTakeSnapshot (progress);
621 }
622 else
623 vboxProblem().cannotTakeSnapshot (console);
624
625 session.Close();
626 }
627}
628
629void VBoxSnapshotsWgt::discardCurState()
630{
631 ListViewItem *item = static_cast <ListViewItem *> (listView->currentItem());
632 AssertReturn (item, (void) 0);
633
634 /* open a direct session (this call will handle all errors) */
635 CSession session = vboxGlobal().openSession (mMachineId);
636 if (session.isNull())
637 return;
638
639 CConsole console = session.GetConsole();
640 CProgress progress = console.DiscardCurrentState();
641 if (console.isOk())
642 {
643 /* show the progress dialog */
644 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
645 vboxProblem().mainWindowShown());
646
647 if (progress.GetResultCode() != 0)
648 vboxProblem().cannotDiscardCurrentState (progress);
649 }
650 else
651 vboxProblem().cannotDiscardCurrentState (console);
652
653 session.Close();
654}
655
656void VBoxSnapshotsWgt::discardCurSnapAndState()
657{
658 ListViewItem *item = static_cast <ListViewItem *> (listView->currentItem());
659 AssertReturn (item, (void) 0);
660
661 /* open a direct session (this call will handle all errors) */
662 CSession session = vboxGlobal().openSession (mMachineId);
663 if (session.isNull())
664 return;
665
666 CConsole console = session.GetConsole();
667 CProgress progress = console.DiscardCurrentSnapshotAndState();
668 if (console.isOk())
669 {
670 /* show the progress dialog */
671 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
672 vboxProblem().mainWindowShown());
673
674 if (progress.GetResultCode() != 0)
675 vboxProblem().cannotDiscardCurrentSnapshotAndState (progress);
676 }
677 else
678 vboxProblem().cannotDiscardCurrentSnapshotAndState (console);
679
680 session.Close();
681}
682
683void VBoxSnapshotsWgt::showSnapshotDetails()
684{
685 ListViewItem *item = static_cast <ListViewItem *> (listView->currentItem());
686 AssertReturn (item, (void) 0);
687
688 CSnapshot snap = item->snapshot();
689 AssertReturn (!snap.isNull(), (void) 0);
690
691 CMachine snapMachine = snap.GetMachine();
692
693 VBoxSnapshotDetailsDlg dlg (this);
694 dlg.getFromSnapshot (snap);
695
696 if (dlg.exec() == QDialog::Accepted)
697 {
698 dlg.putBackToSnapshot();
699 }
700}
701
702void VBoxSnapshotsWgt::machineDataChanged (const VBoxMachineDataChangeEvent &aE)
703{
704 if (aE.id != mMachineId)
705 return; /* not interested in other machines */
706
707 curStateItem()->recache();
708}
709
710void VBoxSnapshotsWgt::machineStateChanged (const VBoxMachineStateChangeEvent &aE)
711{
712 if (aE.id != mMachineId)
713 return; /* not interested in other machines */
714
715 curStateItem()->recache();
716 curStateItem()->updateCurrentState (aE.state);
717}
718
719void VBoxSnapshotsWgt::sessionStateChanged (const VBoxSessionStateChangeEvent &aE)
720{
721 if (aE.id != mMachineId)
722 return; /* not interested in other machines */
723
724 mSessionState = aE.state;
725 listView_currentChanged (listView->currentItem());
726}
727
728void VBoxSnapshotsWgt::snapshotChanged (const VBoxSnapshotEvent &aE)
729{
730 if (aE.machineId != mMachineId)
731 return; /* not interested in other machines */
732
733 switch (aE.what)
734 {
735 case VBoxSnapshotEvent::Taken:
736 case VBoxSnapshotEvent::Discarded:
737 {
738 refreshAll (true);
739 break;
740 }
741 case VBoxSnapshotEvent::Changed:
742 {
743 ListViewItem *lvi = findItem (aE.snapshotId);
744 if (!lvi)
745 refreshAll();
746 else
747 {
748 lvi->recache();
749 lvi->repaint();
750 }
751 break;
752 }
753 }
754}
755
Note: See TracBrowser for help on using the repository browser.

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