VirtualBox

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

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

FE/Qt: Selector UI: Tools pane: Snapshot pane: Rework snapshot tree to have additional 'Taken' column.

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