VirtualBox

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

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

FE/Qt: bugref:8900: Make sure Snapshot Manager, Virtual Media Manager and Host Network Manager remember whether their details are expanded.

  • 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 68962 2017-10-03 13:26:15Z 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 apply snapshot details changes. */
122 void sltApplySnapshotDetailsChanges();
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 /** Load settings: */
154 void loadSettings();
155
156 /** Refreshes everything. */
157 void refreshAll();
158 /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
159 void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
160
161 /** Cleanups all. */
162 void cleanup();
163 /** @} */
164
165 /** @name Toolbar helpers.
166 * @{ */
167 /** Updates action states. */
168 void updateActionStates();
169
170 /** Proposes to take a snapshot. */
171 bool takeSnapshot(bool fAutomatically = false);
172 /** Proposes to delete the snapshot. */
173 bool deleteSnapshot(bool fAutomatically = false);
174 /** Proposes to restore the snapshot. */
175 bool restoreSnapshot(bool fAutomatically = false);
176 /** Proposes to clone the snapshot. */
177 void cloneSnapshot();
178 /** @} */
179
180 /** @name Tree-widget helpers.
181 * @{ */
182 /** Handles command to adjust snapshot tree. */
183 void adjustTreeWidget();
184
185 /** Searches for an item with corresponding @a strSnapshotID. */
186 UISnapshotItem *findItem(const QString &strSnapshotID) const;
187
188 /** Searches for smallest snapshot age starting with @a pItem as parent. */
189 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
190
191 /** Expand all the children starting with @a pItem. */
192 void expandItemChildren(QTreeWidgetItem *pItem);
193 /** @} */
194
195 /** @name General variables.
196 * @{ */
197 /** Holds the COM machine object. */
198 CMachine m_comMachine;
199 /** Holds the machine object ID. */
200 QString m_strMachineId;
201 /** Holds the cached session state. */
202 KSessionState m_enmSessionState;
203
204 /** Holds whether the snapshot operations are allowed. */
205 bool m_fShapshotOperationsAllowed;
206
207 /** Holds the snapshot item editing protector. */
208 QReadWriteLock *m_pLockReadWrite;
209
210 /** Holds the cached snapshot-item pixmap for 'offline' state. */
211 QIcon *m_pIconSnapshotOffline;
212 /** Holds the cached snapshot-item pixmap for 'online' state. */
213 QIcon *m_pIconSnapshotOnline;
214
215 /** Holds the snapshot age update timer. */
216 QTimer *m_pTimerUpdateAge;
217 /** @} */
218
219 /** @name Widget variables.
220 * @{ */
221 /** Holds the toolbar instance. */
222 UIToolBar *m_pToolBar;
223 /** Holds the Take Snapshot action instance. */
224 QAction *m_pActionTakeSnapshot;
225 /** Holds the Delete Snapshot action instance. */
226 QAction *m_pActionDeleteSnapshot;
227 /** Holds the Restore Snapshot action instance. */
228 QAction *m_pActionRestoreSnapshot;
229 /** Holds the Show Snapshot Details action instance. */
230 QAction *m_pActionShowSnapshotDetails;
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.

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