1 | /* $Id: VBoxSnapshotsWgt.h 55401 2015-04-23 10:03:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - VBoxSnapshotsWgt class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2012 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef __VBoxSnapshotsWgt_h__
|
---|
19 | #define __VBoxSnapshotsWgt_h__
|
---|
20 |
|
---|
21 | /* Qt includes: */
|
---|
22 | #include <QTimer>
|
---|
23 | #include <QIcon>
|
---|
24 |
|
---|
25 | /* GUI includes: */
|
---|
26 | #include "VBoxSnapshotsWgt.gen.h"
|
---|
27 | #include "VBoxGlobal.h"
|
---|
28 | #include "QIWithRetranslateUI.h"
|
---|
29 |
|
---|
30 | /* COM includes: */
|
---|
31 | #include "CMachine.h"
|
---|
32 |
|
---|
33 | /* Local forwards */
|
---|
34 | class SnapshotWgtItem;
|
---|
35 |
|
---|
36 | /* Snapshot age format */
|
---|
37 | enum SnapshotAgeFormat
|
---|
38 | {
|
---|
39 | AgeInSeconds,
|
---|
40 | AgeInMinutes,
|
---|
41 | AgeInHours,
|
---|
42 | AgeInDays,
|
---|
43 | AgeMax
|
---|
44 | };
|
---|
45 |
|
---|
46 | class VBoxSnapshotsWgt : public QIWithRetranslateUI <QWidget>, public Ui::VBoxSnapshotsWgt
|
---|
47 | {
|
---|
48 | Q_OBJECT;
|
---|
49 |
|
---|
50 | public:
|
---|
51 |
|
---|
52 | VBoxSnapshotsWgt (QWidget *aParent);
|
---|
53 |
|
---|
54 | void setMachine (const CMachine &aMachine);
|
---|
55 |
|
---|
56 | /** Returns cached snapshot-item icon depending on @a fOnline flag. */
|
---|
57 | const QIcon& snapshotItemIcon(bool fOnline) { return !fOnline ? m_offlineSnapshotIcon : m_onlineSnapshotIcon; }
|
---|
58 |
|
---|
59 | protected:
|
---|
60 |
|
---|
61 | void retranslateUi();
|
---|
62 |
|
---|
63 | private slots:
|
---|
64 |
|
---|
65 | /* Snapshot tree slots: */
|
---|
66 | void onCurrentChanged (QTreeWidgetItem *aItem = 0);
|
---|
67 | void onContextMenuRequested (const QPoint &aPoint);
|
---|
68 | void onItemChanged (QTreeWidgetItem *aItem);
|
---|
69 | void sltItemDoubleClicked(QTreeWidgetItem *pItem);
|
---|
70 |
|
---|
71 | /* Snapshot functionality slots: */
|
---|
72 | void sltTakeSnapshot();
|
---|
73 | void sltRestoreSnapshot(bool fSuppressNonCriticalWarnings = false);
|
---|
74 | void sltDeleteSnapshot();
|
---|
75 | void sltShowSnapshotDetails();
|
---|
76 | void sltCloneSnapshot();
|
---|
77 |
|
---|
78 | /* Main API event handlers: */
|
---|
79 | void machineDataChanged(QString strId);
|
---|
80 | void machineStateChanged(QString strId, KMachineState state);
|
---|
81 | void sessionStateChanged(QString strId, KSessionState state);
|
---|
82 |
|
---|
83 | void updateSnapshotsAge();
|
---|
84 |
|
---|
85 | private:
|
---|
86 |
|
---|
87 | /* Snapshot private functions: */
|
---|
88 | bool takeSnapshot();
|
---|
89 | //bool restoreSnapshot();
|
---|
90 | //bool deleteSnapshot();
|
---|
91 | //bool showSnapshotDetails();
|
---|
92 |
|
---|
93 | void refreshAll();
|
---|
94 | SnapshotWgtItem* findItem (const QString &aSnapshotId);
|
---|
95 | SnapshotWgtItem* curStateItem();
|
---|
96 | void populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem);
|
---|
97 | SnapshotAgeFormat traverseSnapshotAge (QTreeWidgetItem *aParentItem);
|
---|
98 |
|
---|
99 | CMachine mMachine;
|
---|
100 | QString mMachineId;
|
---|
101 | KSessionState mSessionState;
|
---|
102 | SnapshotWgtItem *mCurSnapshotItem;
|
---|
103 | bool mEditProtector;
|
---|
104 |
|
---|
105 | QActionGroup *mSnapshotActionGroup;
|
---|
106 | QActionGroup *mCurStateActionGroup;
|
---|
107 |
|
---|
108 | QAction *mRestoreSnapshotAction;
|
---|
109 | QAction *mDeleteSnapshotAction;
|
---|
110 | QAction *mShowSnapshotDetailsAction;
|
---|
111 | QAction *mTakeSnapshotAction;
|
---|
112 | QAction *mCloneSnapshotAction;
|
---|
113 |
|
---|
114 | QTimer mAgeUpdateTimer;
|
---|
115 |
|
---|
116 | bool m_fShapshotOperationsAllowed;
|
---|
117 |
|
---|
118 | /** Pointer to cached snapshot-item pixmap for 'offline' state. */
|
---|
119 | QIcon m_offlineSnapshotIcon;
|
---|
120 | /** Pointer to cached snapshot-item pixmap for 'online' state. */
|
---|
121 | QIcon m_onlineSnapshotIcon;
|
---|
122 | };
|
---|
123 |
|
---|
124 | #endif // __VBoxSnapshotsWgt_h__
|
---|