1 | /* $Id: UISnapshotPane.h 67160 2017-05-31 09:44:38Z 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 | /** Handles translation event. */
|
---|
72 | virtual void retranslateUi() /* override */;
|
---|
73 |
|
---|
74 | private slots:
|
---|
75 |
|
---|
76 | /** @name Main event handlers.
|
---|
77 | * @{ */
|
---|
78 | /** Handles machine data change for machine with @a strMachineID. */
|
---|
79 | void sltMachineDataChange(QString strMachineID);
|
---|
80 | /** Handles machine @a enmState change for machine with @a strMachineID. */
|
---|
81 | void sltMachineStateChange(QString strMachineID, KMachineState enmState);
|
---|
82 | /** Handles session @a enmState change for machine with @a strMachineID. */
|
---|
83 | void sltSessionStateChange(QString strMachineID, KSessionState enmState);
|
---|
84 | /** @} */
|
---|
85 |
|
---|
86 | /** @name Timer event handlers.
|
---|
87 | * @{ */
|
---|
88 | /** Updates snapshots age. */
|
---|
89 | void sltUpdateSnapshotsAge();
|
---|
90 | /** @} */
|
---|
91 |
|
---|
92 | /** @name Toolbar handlers.
|
---|
93 | * @{ */
|
---|
94 | /** Handles command to take a snapshot. */
|
---|
95 | void sltTakeSnapshot() { takeSnapshot(); }
|
---|
96 | /** Handles command to restore the snapshot. */
|
---|
97 | void sltRestoreSnapshot() { restoreSnapshot(); }
|
---|
98 | /** Handles command to delete the snapshot. */
|
---|
99 | void sltDeleteSnapshot() { deleteSnapshot(); }
|
---|
100 | /** Handles command to make snapshot details @a fVisible. */
|
---|
101 | void sltToggleSnapshotDetailsVisibility(bool fVisible);
|
---|
102 | /** Handles command to commit snapshot details changes. */
|
---|
103 | void sltCommitSnapshotDetailsChanges();
|
---|
104 | /** Proposes to clone the snapshot. */
|
---|
105 | void sltCloneSnapshot() { cloneSnapshot(); }
|
---|
106 | /** @} */
|
---|
107 |
|
---|
108 | /** @name Tree-widget handlers.
|
---|
109 | * @{ */
|
---|
110 | /** Handles tree-widget current item change. */
|
---|
111 | void sltHandleCurrentItemChange();
|
---|
112 | /** Handles context menu request for tree-widget @a position. */
|
---|
113 | void sltHandleContextMenuRequest(const QPoint &position);
|
---|
114 | /** Handles tree-widget @a pItem change. */
|
---|
115 | void sltHandleItemChange(QTreeWidgetItem *pItem);
|
---|
116 | /** Handles tree-widget @a pItem double-click. */
|
---|
117 | void sltHandleItemDoubleClick(QTreeWidgetItem *pItem);
|
---|
118 | /** @} */
|
---|
119 |
|
---|
120 | private:
|
---|
121 |
|
---|
122 | /** @name Prepare/cleanup cascade.
|
---|
123 | * @{ */
|
---|
124 | /** Prepares all. */
|
---|
125 | void prepare();
|
---|
126 | /** Prepares widgets. */
|
---|
127 | void prepareWidgets();
|
---|
128 | /** Prepares toolbar. */
|
---|
129 | void prepareToolbar();
|
---|
130 | /** Prepares tree-widget. */
|
---|
131 | void prepareTreeWidget();
|
---|
132 | /** Prepares details-widget. */
|
---|
133 | void prepareDetailsWidget();
|
---|
134 |
|
---|
135 | /** Refreshes everything. */
|
---|
136 | void refreshAll();
|
---|
137 | /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
|
---|
138 | void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
|
---|
139 |
|
---|
140 | /** Cleanups all. */
|
---|
141 | void cleanup();
|
---|
142 | /** @} */
|
---|
143 |
|
---|
144 | /** @name Toolbar helpers.
|
---|
145 | * @{ */
|
---|
146 | /** Proposes to take a snapshot. */
|
---|
147 | bool takeSnapshot();
|
---|
148 | /** Proposes to delete the snapshot. */
|
---|
149 | bool deleteSnapshot();
|
---|
150 | /** Proposes to restore the snapshot. */
|
---|
151 | bool restoreSnapshot(bool fSuppressNonCriticalWarnings = false);
|
---|
152 | /** Proposes to clone the snapshot. */
|
---|
153 | void cloneSnapshot();
|
---|
154 | /** @} */
|
---|
155 |
|
---|
156 | /** @name Tree-widget helpers.
|
---|
157 | * @{ */
|
---|
158 | /** Searches for an item with corresponding @a strSnapshotID. */
|
---|
159 | UISnapshotItem *findItem(const QString &strSnapshotID) const;
|
---|
160 | /** Returns the "current state" item. */
|
---|
161 | UISnapshotItem *currentStateItem() const;
|
---|
162 |
|
---|
163 | /** Searches for smallest snapshot age starting with @a pItem as parent. */
|
---|
164 | SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
|
---|
165 | /** @} */
|
---|
166 |
|
---|
167 | /** @name General variables.
|
---|
168 | * @{ */
|
---|
169 | /** Holds the COM machine object. */
|
---|
170 | CMachine m_comMachine;
|
---|
171 | /** Holds the machine object ID. */
|
---|
172 | QString m_strMachineID;
|
---|
173 | /** Holds the cached session state. */
|
---|
174 | KSessionState m_enmSessionState;
|
---|
175 |
|
---|
176 | /** Holds whether the snapshot operations are allowed. */
|
---|
177 | bool m_fShapshotOperationsAllowed;
|
---|
178 |
|
---|
179 | /** Holds the snapshot item editing protector. */
|
---|
180 | QReadWriteLock *m_pLockReadWrite;
|
---|
181 |
|
---|
182 | /** Holds the cached snapshot-item pixmap for 'offline' state. */
|
---|
183 | QIcon *m_pIconSnapshotOffline;
|
---|
184 | /** Holds the cached snapshot-item pixmap for 'online' state. */
|
---|
185 | QIcon *m_pIconSnapshotOnline;
|
---|
186 |
|
---|
187 | /** Holds the snapshot age update timer. */
|
---|
188 | QTimer *m_pTimerUpdateAge;
|
---|
189 | /** @} */
|
---|
190 |
|
---|
191 | /** @name Widget variables.
|
---|
192 | * @{ */
|
---|
193 | /** Holds the toolbar instance. */
|
---|
194 | UIToolBar *m_pToolBar;
|
---|
195 | /** Holds the Take Snapshot action instance. */
|
---|
196 | QAction *m_pActionTakeSnapshot;
|
---|
197 | /** Holds the Delete Snapshot action instance. */
|
---|
198 | QAction *m_pActionDeleteSnapshot;
|
---|
199 | /** Holds the Restore Snapshot action instance. */
|
---|
200 | QAction *m_pActionRestoreSnapshot;
|
---|
201 | /** Holds the Show Snapshot Details action instance. */
|
---|
202 | QAction *m_pActionShowSnapshotDetails;
|
---|
203 | /** Holds the Commit Snapshot Details action instance. */
|
---|
204 | QAction *m_pActionCommitSnapshotDetails;
|
---|
205 | /** Holds the Clone Snapshot action instance. */
|
---|
206 | QAction *m_pActionCloneSnapshot;
|
---|
207 |
|
---|
208 | /** Holds the snapshot tree instance. */
|
---|
209 | UISnapshotTree *m_pSnapshotTree;
|
---|
210 | /** Holds the current snapshot item reference. */
|
---|
211 | UISnapshotItem *m_pCurrentSnapshotItem;
|
---|
212 |
|
---|
213 | /** Holds the details-widget instance. */
|
---|
214 | UISnapshotDetailsWidget *m_pDetailsWidget;
|
---|
215 | /** @} */
|
---|
216 | };
|
---|
217 |
|
---|
218 | #endif /* !___UISnapshotPane_h___ */
|
---|
219 |
|
---|