1 | /* $Id: UISnapshotPane.h 67260 2017-06-05 16:08:22Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISnapshotPane class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 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 ___UISnapshotPane_h___
|
---|
19 | #define ___UISnapshotPane_h___
|
---|
20 |
|
---|
21 | /* GUI includes: */
|
---|
22 | #include "QIWithRetranslateUI.h"
|
---|
23 | #include "VBoxGlobal.h"
|
---|
24 |
|
---|
25 | /* COM includes: */
|
---|
26 | #include "CMachine.h"
|
---|
27 |
|
---|
28 | /* Forward declarations: */
|
---|
29 | class QIcon;
|
---|
30 | class QReadWriteLock;
|
---|
31 | class QTimer;
|
---|
32 | class QTreeWidgetItem;
|
---|
33 | class QITreeWidgetItem;
|
---|
34 | class UISnapshotDetailsWidget;
|
---|
35 | class UISnapshotItem;
|
---|
36 | class UISnapshotTree;
|
---|
37 | class UIToolBar;
|
---|
38 |
|
---|
39 |
|
---|
40 | /** Snapshot age format. */
|
---|
41 | enum SnapshotAgeFormat
|
---|
42 | {
|
---|
43 | SnapshotAgeFormat_InSeconds,
|
---|
44 | SnapshotAgeFormat_InMinutes,
|
---|
45 | SnapshotAgeFormat_InHours,
|
---|
46 | SnapshotAgeFormat_InDays,
|
---|
47 | SnapshotAgeFormat_Max
|
---|
48 | };
|
---|
49 |
|
---|
50 |
|
---|
51 | /** QWidget extension providing GUI with the pane to control snapshot related functionality. */
|
---|
52 | class UISnapshotPane : public QIWithRetranslateUI<QWidget>
|
---|
53 | {
|
---|
54 | Q_OBJECT;
|
---|
55 |
|
---|
56 | public:
|
---|
57 |
|
---|
58 | /** Constructs snapshot pane passing @a pParent to the base-class. */
|
---|
59 | UISnapshotPane(QWidget *pParent = 0);
|
---|
60 | /** Destructs snapshot pane. */
|
---|
61 | virtual ~UISnapshotPane() /* override */;
|
---|
62 |
|
---|
63 | /** Defines the @a comMachine object to be parsed. */
|
---|
64 | void setMachine(const CMachine &comMachine);
|
---|
65 |
|
---|
66 | /** Returns cached snapshot-item icon depending on @a fOnline flag. */
|
---|
67 | const QIcon *snapshotItemIcon(bool fOnline) const;
|
---|
68 |
|
---|
69 | protected:
|
---|
70 |
|
---|
71 | /** @name Event-handling stuff.
|
---|
72 | * @{ */
|
---|
73 | /** Handles translation event. */
|
---|
74 | virtual void retranslateUi() /* override */;
|
---|
75 | /** @} */
|
---|
76 |
|
---|
77 | private slots:
|
---|
78 |
|
---|
79 | /** @name Main event handlers.
|
---|
80 | * @{ */
|
---|
81 | /** Handles machine data change for machine with @a strMachineID. */
|
---|
82 | void sltMachineDataChange(QString strMachineID);
|
---|
83 | /** Handles machine @a enmState change for machine with @a strMachineID. */
|
---|
84 | void sltMachineStateChange(QString strMachineID, KMachineState enmState);
|
---|
85 | /** Handles session @a enmState change for machine with @a strMachineID. */
|
---|
86 | void sltSessionStateChange(QString strMachineID, KSessionState enmState);
|
---|
87 | /** @} */
|
---|
88 |
|
---|
89 | /** @name Timer event handlers.
|
---|
90 | * @{ */
|
---|
91 | /** Updates snapshots age. */
|
---|
92 | void sltUpdateSnapshotsAge();
|
---|
93 | /** @} */
|
---|
94 |
|
---|
95 | /** @name Toolbar handlers.
|
---|
96 | * @{ */
|
---|
97 | /** Handles command to take a snapshot. */
|
---|
98 | void sltTakeSnapshot() { takeSnapshot(); }
|
---|
99 | /** Handles command to restore the snapshot. */
|
---|
100 | void sltRestoreSnapshot() { restoreSnapshot(); }
|
---|
101 | /** Handles command to delete the snapshot. */
|
---|
102 | void sltDeleteSnapshot() { deleteSnapshot(); }
|
---|
103 | /** Handles command to make snapshot details @a fVisible. */
|
---|
104 | void sltToggleSnapshotDetailsVisibility(bool fVisible);
|
---|
105 | /** Handles command to commit snapshot details changes. */
|
---|
106 | void sltCommitSnapshotDetailsChanges();
|
---|
107 | /** Proposes to clone the snapshot. */
|
---|
108 | void sltCloneSnapshot() { cloneSnapshot(); }
|
---|
109 | /** @} */
|
---|
110 |
|
---|
111 | /** @name Tree-widget handlers.
|
---|
112 | * @{ */
|
---|
113 | /** Handles tree-widget current item change. */
|
---|
114 | void sltHandleCurrentItemChange();
|
---|
115 | /** Handles context menu request for tree-widget @a position. */
|
---|
116 | void sltHandleContextMenuRequest(const QPoint &position);
|
---|
117 | /** Handles tree-widget @a pItem change. */
|
---|
118 | void sltHandleItemChange(QTreeWidgetItem *pItem);
|
---|
119 | /** Handles tree-widget @a pItem double-click. */
|
---|
120 | void sltHandleItemDoubleClick(QTreeWidgetItem *pItem);
|
---|
121 | /** @} */
|
---|
122 |
|
---|
123 | private:
|
---|
124 |
|
---|
125 | /** @name Prepare/cleanup cascade.
|
---|
126 | * @{ */
|
---|
127 | /** Prepares all. */
|
---|
128 | void prepare();
|
---|
129 | /** Prepares widgets. */
|
---|
130 | void prepareWidgets();
|
---|
131 | /** Prepares toolbar. */
|
---|
132 | void prepareToolbar();
|
---|
133 | /** Prepares tree-widget. */
|
---|
134 | void prepareTreeWidget();
|
---|
135 | /** Prepares details-widget. */
|
---|
136 | void prepareDetailsWidget();
|
---|
137 |
|
---|
138 | /** Refreshes everything. */
|
---|
139 | void refreshAll();
|
---|
140 | /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
|
---|
141 | void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
|
---|
142 |
|
---|
143 | /** Cleanups all. */
|
---|
144 | void cleanup();
|
---|
145 | /** @} */
|
---|
146 |
|
---|
147 | /** @name Toolbar helpers.
|
---|
148 | * @{ */
|
---|
149 | /** Proposes to take a snapshot. */
|
---|
150 | bool takeSnapshot();
|
---|
151 | /** Proposes to delete the snapshot. */
|
---|
152 | bool deleteSnapshot();
|
---|
153 | /** Proposes to restore the snapshot. */
|
---|
154 | bool restoreSnapshot(bool fSuppressNonCriticalWarnings = false);
|
---|
155 | /** Proposes to clone the snapshot. */
|
---|
156 | void cloneSnapshot();
|
---|
157 | /** @} */
|
---|
158 |
|
---|
159 | /** @name Tree-widget helpers.
|
---|
160 | * @{ */
|
---|
161 | /** Searches for an item with corresponding @a strSnapshotID. */
|
---|
162 | UISnapshotItem *findItem(const QString &strSnapshotID) const;
|
---|
163 | /** Returns the "current state" item. */
|
---|
164 | UISnapshotItem *currentStateItem() const;
|
---|
165 |
|
---|
166 | /** Searches for smallest snapshot age starting with @a pItem as parent. */
|
---|
167 | SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
|
---|
168 | /** @} */
|
---|
169 |
|
---|
170 | /** @name General variables.
|
---|
171 | * @{ */
|
---|
172 | /** Holds the COM machine object. */
|
---|
173 | CMachine m_comMachine;
|
---|
174 | /** Holds the machine object ID. */
|
---|
175 | QString m_strMachineID;
|
---|
176 | /** Holds the cached session state. */
|
---|
177 | KSessionState m_enmSessionState;
|
---|
178 |
|
---|
179 | /** Holds whether the snapshot operations are allowed. */
|
---|
180 | bool m_fShapshotOperationsAllowed;
|
---|
181 |
|
---|
182 | /** Holds the snapshot item editing protector. */
|
---|
183 | QReadWriteLock *m_pLockReadWrite;
|
---|
184 |
|
---|
185 | /** Holds the cached snapshot-item pixmap for 'offline' state. */
|
---|
186 | QIcon *m_pIconSnapshotOffline;
|
---|
187 | /** Holds the cached snapshot-item pixmap for 'online' state. */
|
---|
188 | QIcon *m_pIconSnapshotOnline;
|
---|
189 |
|
---|
190 | /** Holds the snapshot age update timer. */
|
---|
191 | QTimer *m_pTimerUpdateAge;
|
---|
192 | /** @} */
|
---|
193 |
|
---|
194 | /** @name Widget variables.
|
---|
195 | * @{ */
|
---|
196 | /** Holds the toolbar instance. */
|
---|
197 | UIToolBar *m_pToolBar;
|
---|
198 | /** Holds the Take Snapshot action instance. */
|
---|
199 | QAction *m_pActionTakeSnapshot;
|
---|
200 | /** Holds the Delete Snapshot action instance. */
|
---|
201 | QAction *m_pActionDeleteSnapshot;
|
---|
202 | /** Holds the Restore Snapshot action instance. */
|
---|
203 | QAction *m_pActionRestoreSnapshot;
|
---|
204 | /** Holds the Show Snapshot Details action instance. */
|
---|
205 | QAction *m_pActionShowSnapshotDetails;
|
---|
206 | /** Holds the Commit Snapshot Details action instance. */
|
---|
207 | QAction *m_pActionCommitSnapshotDetails;
|
---|
208 | /** Holds the Clone Snapshot action instance. */
|
---|
209 | QAction *m_pActionCloneSnapshot;
|
---|
210 |
|
---|
211 | /** Holds the snapshot tree instance. */
|
---|
212 | UISnapshotTree *m_pSnapshotTree;
|
---|
213 | /** Holds the current snapshot item reference. */
|
---|
214 | UISnapshotItem *m_pCurrentSnapshotItem;
|
---|
215 |
|
---|
216 | /** Holds the details-widget instance. */
|
---|
217 | UISnapshotDetailsWidget *m_pDetailsWidget;
|
---|
218 | /** @} */
|
---|
219 | };
|
---|
220 |
|
---|
221 | #endif /* !___UISnapshotPane_h___ */
|
---|
222 |
|
---|