VirtualBox

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

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

FE/Qt: Selector UI: Tools pane: Snapshot pane: Detach it from the Selector UI event-handling.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 7.9 KB
Line 
1/* $Id: UISnapshotPane.h 67419 2017-06-15 09:37:52Z 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 Event-handling stuff.
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 any snapshot change for machine with @a strMachineID. */
96 void sltHandleSnapshotChange(QString strMachineID);
97 /** @} */
98
99 /** @name Timer event handlers.
100 * @{ */
101 /** Updates snapshots age. */
102 void sltUpdateSnapshotsAge();
103 /** @} */
104
105 /** @name Toolbar handlers.
106 * @{ */
107 /** Handles command to take a snapshot. */
108 void sltTakeSnapshot() { takeSnapshot(); }
109 /** Handles command to restore the snapshot. */
110 void sltRestoreSnapshot() { restoreSnapshot(); }
111 /** Handles command to delete the snapshot. */
112 void sltDeleteSnapshot() { deleteSnapshot(); }
113 /** Handles command to make snapshot details @a fVisible. */
114 void sltToggleSnapshotDetailsVisibility(bool fVisible);
115 /** Handles command to commit snapshot details changes. */
116 void sltCommitSnapshotDetailsChanges();
117 /** Proposes to clone the snapshot. */
118 void sltCloneSnapshot() { cloneSnapshot(); }
119 /** @} */
120
121 /** @name Tree-widget handlers.
122 * @{ */
123 /** Handles tree-widget current item change. */
124 void sltHandleCurrentItemChange();
125 /** Handles context menu request for tree-widget @a position. */
126 void sltHandleContextMenuRequest(const QPoint &position);
127 /** Handles tree-widget @a pItem change. */
128 void sltHandleItemChange(QTreeWidgetItem *pItem);
129 /** Handles tree-widget @a pItem double-click. */
130 void sltHandleItemDoubleClick(QTreeWidgetItem *pItem);
131 /** @} */
132
133private:
134
135 /** @name Prepare/cleanup cascade.
136 * @{ */
137 /** Prepares all. */
138 void prepare();
139 /** Prepares widgets. */
140 void prepareWidgets();
141 /** Prepares toolbar. */
142 void prepareToolbar();
143 /** Prepares tree-widget. */
144 void prepareTreeWidget();
145 /** Prepares details-widget. */
146 void prepareDetailsWidget();
147
148 /** Refreshes everything. */
149 void refreshAll();
150 /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
151 void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
152
153 /** Cleanups all. */
154 void cleanup();
155 /** @} */
156
157 /** @name Toolbar helpers.
158 * @{ */
159 /** Updates action states. */
160 void updateActionStates();
161
162 /** Proposes to take a snapshot. */
163 bool takeSnapshot();
164 /** Proposes to delete the snapshot. */
165 bool deleteSnapshot();
166 /** Proposes to restore the snapshot. */
167 bool restoreSnapshot(bool fSuppressNonCriticalWarnings = false);
168 /** Proposes to clone the snapshot. */
169 void cloneSnapshot();
170 /** @} */
171
172 /** @name Tree-widget helpers.
173 * @{ */
174 /** Handles command to adjust snapshot tree. */
175 void adjustTreeWidget();
176
177 /** Searches for an item with corresponding @a strSnapshotID. */
178 UISnapshotItem *findItem(const QString &strSnapshotID) const;
179 /** Returns the "current state" item. */
180 UISnapshotItem *currentStateItem() const;
181
182 /** Searches for smallest snapshot age starting with @a pItem as parent. */
183 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
184 /** @} */
185
186 /** @name General variables.
187 * @{ */
188 /** Holds the COM machine object. */
189 CMachine m_comMachine;
190 /** Holds the machine object ID. */
191 QString m_strMachineID;
192 /** Holds the cached session state. */
193 KSessionState m_enmSessionState;
194
195 /** Holds whether the snapshot operations are allowed. */
196 bool m_fShapshotOperationsAllowed;
197
198 /** Holds the snapshot item editing protector. */
199 QReadWriteLock *m_pLockReadWrite;
200
201 /** Holds the cached snapshot-item pixmap for 'offline' state. */
202 QIcon *m_pIconSnapshotOffline;
203 /** Holds the cached snapshot-item pixmap for 'online' state. */
204 QIcon *m_pIconSnapshotOnline;
205
206 /** Holds the snapshot age update timer. */
207 QTimer *m_pTimerUpdateAge;
208 /** @} */
209
210 /** @name Widget variables.
211 * @{ */
212 /** Holds the toolbar instance. */
213 UIToolBar *m_pToolBar;
214 /** Holds the Take Snapshot action instance. */
215 QAction *m_pActionTakeSnapshot;
216 /** Holds the Delete Snapshot action instance. */
217 QAction *m_pActionDeleteSnapshot;
218 /** Holds the Restore Snapshot action instance. */
219 QAction *m_pActionRestoreSnapshot;
220 /** Holds the Show Snapshot Details action instance. */
221 QAction *m_pActionShowSnapshotDetails;
222 /** Holds the Commit Snapshot Details action instance. */
223 QAction *m_pActionCommitSnapshotDetails;
224 /** Holds the Clone Snapshot action instance. */
225 QAction *m_pActionCloneSnapshot;
226
227 /** Holds the snapshot tree instance. */
228 UISnapshotTree *m_pSnapshotTree;
229 /** Holds the current snapshot item reference. */
230 UISnapshotItem *m_pCurrentSnapshotItem;
231
232 /** Holds the details-widget instance. */
233 UISnapshotDetailsWidget *m_pDetailsWidget;
234 /** @} */
235};
236
237#endif /* !___UISnapshotPane_h___ */
238
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