VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h@ 67509

Last change on this file since 67509 was 67509, checked in by vboxsync, 8 years ago

FE/Qt: bugref:8901: Selector UI: Tools pane: Snapshot pane: Implement 'delete snapshot' event handler.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 8.5 KB
Line 
1/* $Id: UISnapshotPane.h 67509 2017-06-20 14:10:06Z 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: */
29class QIcon;
30class QReadWriteLock;
31class QTimer;
32class QTreeWidgetItem;
33class QITreeWidgetItem;
34class UISnapshotDetailsWidget;
35class UISnapshotItem;
36class UISnapshotTree;
37class UIToolBar;
38
39
40/** Snapshot age format. */
41enum 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. */
52class UISnapshotPane : public QIWithRetranslateUI<QWidget>
53{
54 Q_OBJECT;
55
56public:
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
69protected:
70
71 /** @name Qt event handlers.
72 * @{ */
73 /** Handles translation event. */
74 virtual void retranslateUi() /* override */;
75
76 /** Handles resize @a pEvent. */
77 virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
78
79 /** Handles show @a pEvent. */
80 virtual void showEvent(QShowEvent *pEvent) /* override */;
81 /** @} */
82
83private slots:
84
85 /** @name Main event handlers.
86 * @{ */
87 /** Handles machine data change for machine with @a strMachineId. */
88 void sltHandleMachineDataChange(QString strMachineId);
89 /** Handles machine @a enmState change for machine with @a strMachineId. */
90 void sltHandleMachineStateChange(QString strMachineId, KMachineState enmState);
91
92 /** Handles session @a enmState change for machine with @a strMachineId. */
93 void sltHandleSessionStateChange(QString strMachineId, KSessionState enmState);
94
95 /** Handles snapshot take event for machine with @a strMachineId. */
96 void sltHandleSnapshotTake(QString strMachineId, QString strSnapshotId);
97 /** Handles snapshot delete event for machine with @a strMachineId. */
98 void sltHandleSnapshotDelete(QString strMachineId, QString strSnapshotId);
99 /** Handles snapshot change event for machine with @a strMachineId. */
100 void sltHandleSnapshotChange(QString strMachineId, QString strSnapshotId);
101 /** Handles snapshot restore event for machine with @a strMachineId. */
102 void sltHandleSnapshotRestore(QString strMachineId, QString strSnapshotId);
103 /** @} */
104
105 /** @name Timer event handlers.
106 * @{ */
107 /** Updates snapshots age. */
108 void sltUpdateSnapshotsAge();
109 /** @} */
110
111 /** @name Toolbar handlers.
112 * @{ */
113 /** Handles command to take a snapshot. */
114 void sltTakeSnapshot() { takeSnapshot(); }
115 /** Handles command to restore the snapshot. */
116 void sltRestoreSnapshot() { restoreSnapshot(); }
117 /** Handles command to delete the snapshot. */
118 void sltDeleteSnapshot() { deleteSnapshot(); }
119 /** Handles command to make snapshot details @a fVisible. */
120 void sltToggleSnapshotDetailsVisibility(bool fVisible);
121 /** Handles command to commit snapshot details changes. */
122 void sltCommitSnapshotDetailsChanges();
123 /** Proposes to clone the snapshot. */
124 void sltCloneSnapshot() { cloneSnapshot(); }
125 /** @} */
126
127 /** @name Tree-widget handlers.
128 * @{ */
129 /** Handles tree-widget current item change. */
130 void sltHandleCurrentItemChange();
131 /** Handles context menu request for tree-widget @a position. */
132 void sltHandleContextMenuRequest(const QPoint &position);
133 /** Handles tree-widget @a pItem change. */
134 void sltHandleItemChange(QTreeWidgetItem *pItem);
135 /** Handles tree-widget @a pItem double-click. */
136 void sltHandleItemDoubleClick(QTreeWidgetItem *pItem);
137 /** @} */
138
139private:
140
141 /** @name Prepare/cleanup cascade.
142 * @{ */
143 /** Prepares all. */
144 void prepare();
145 /** Prepares widgets. */
146 void prepareWidgets();
147 /** Prepares toolbar. */
148 void prepareToolbar();
149 /** Prepares tree-widget. */
150 void prepareTreeWidget();
151 /** Prepares details-widget. */
152 void prepareDetailsWidget();
153
154 /** Refreshes everything. */
155 void refreshAll();
156 /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
157 void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
158
159 /** Cleanups all. */
160 void cleanup();
161 /** @} */
162
163 /** @name Toolbar helpers.
164 * @{ */
165 /** Updates action states. */
166 void updateActionStates();
167
168 /** Proposes to take a snapshot. */
169 bool takeSnapshot();
170 /** Proposes to delete the snapshot. */
171 bool deleteSnapshot();
172 /** Proposes to restore the snapshot. */
173 bool restoreSnapshot(bool fSuppressNonCriticalWarnings = false);
174 /** Proposes to clone the snapshot. */
175 void cloneSnapshot();
176 /** @} */
177
178 /** @name Tree-widget helpers.
179 * @{ */
180 /** Handles command to adjust snapshot tree. */
181 void adjustTreeWidget();
182
183 /** Searches for an item with corresponding @a strSnapshotID. */
184 UISnapshotItem *findItem(const QString &strSnapshotID) const;
185
186 /** Searches for smallest snapshot age starting with @a pItem as parent. */
187 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
188
189 /** Expand all the children starting with @a pItem. */
190 void expandItemChildren(QTreeWidgetItem *pItem);
191 /** @} */
192
193 /** @name General variables.
194 * @{ */
195 /** Holds the COM machine object. */
196 CMachine m_comMachine;
197 /** Holds the machine object ID. */
198 QString m_strMachineId;
199 /** Holds the cached session state. */
200 KSessionState m_enmSessionState;
201
202 /** Holds whether the snapshot operations are allowed. */
203 bool m_fShapshotOperationsAllowed;
204
205 /** Holds the snapshot item editing protector. */
206 QReadWriteLock *m_pLockReadWrite;
207
208 /** Holds the cached snapshot-item pixmap for 'offline' state. */
209 QIcon *m_pIconSnapshotOffline;
210 /** Holds the cached snapshot-item pixmap for 'online' state. */
211 QIcon *m_pIconSnapshotOnline;
212
213 /** Holds the snapshot age update timer. */
214 QTimer *m_pTimerUpdateAge;
215 /** @} */
216
217 /** @name Widget variables.
218 * @{ */
219 /** Holds the toolbar instance. */
220 UIToolBar *m_pToolBar;
221 /** Holds the Take Snapshot action instance. */
222 QAction *m_pActionTakeSnapshot;
223 /** Holds the Delete Snapshot action instance. */
224 QAction *m_pActionDeleteSnapshot;
225 /** Holds the Restore Snapshot action instance. */
226 QAction *m_pActionRestoreSnapshot;
227 /** Holds the Show Snapshot Details action instance. */
228 QAction *m_pActionShowSnapshotDetails;
229 /** Holds the Commit Snapshot Details action instance. */
230 QAction *m_pActionCommitSnapshotDetails;
231 /** Holds the Clone Snapshot action instance. */
232 QAction *m_pActionCloneSnapshot;
233
234 /** Holds the snapshot tree instance. */
235 UISnapshotTree *m_pSnapshotTree;
236 /** Holds the "current snapshot" item reference. */
237 UISnapshotItem *m_pCurrentSnapshotItem;
238 /** Holds the "current state" item reference. */
239 UISnapshotItem *m_pCurrentStateItem;
240
241 /** Holds the details-widget instance. */
242 UISnapshotDetailsWidget *m_pDetailsWidget;
243 /** @} */
244};
245
246#endif /* !___UISnapshotPane_h___ */
247
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