VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.h@ 82781

Last change on this file since 82781 was 79365, checked in by vboxsync, 5 years ago

Renaming VBoxGlobal to UICommon for bugref:9049 as planned.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1/* $Id: UISnapshotPane.h 79365 2019-06-26 15:57:32Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISnapshotPane class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-2019 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 FEQT_INCLUDED_SRC_snapshots_UISnapshotPane_h
19#define FEQT_INCLUDED_SRC_snapshots_UISnapshotPane_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* GUI includes: */
25#include "QIWithRetranslateUI.h"
26#include "UICommon.h"
27
28/* COM includes: */
29#include "CMachine.h"
30
31/* Forward declarations: */
32class QIcon;
33class QReadWriteLock;
34class QTimer;
35class QTreeWidgetItem;
36class QITreeWidgetItem;
37class UIActionPool;
38class UISnapshotDetailsWidget;
39class UISnapshotItem;
40class UISnapshotTree;
41class UIToolBar;
42
43
44/** Snapshot age format. */
45enum SnapshotAgeFormat
46{
47 SnapshotAgeFormat_InSeconds,
48 SnapshotAgeFormat_InMinutes,
49 SnapshotAgeFormat_InHours,
50 SnapshotAgeFormat_InDays,
51 SnapshotAgeFormat_Max
52};
53
54
55/** QWidget extension providing GUI with the pane to control snapshot related functionality. */
56class UISnapshotPane : public QIWithRetranslateUI<QWidget>
57{
58 Q_OBJECT;
59
60signals:
61
62 /** Notifies listeners about current item change. */
63 void sigCurrentItemChange();
64
65public:
66
67 /** Constructs snapshot pane passing @a pParent to the base-class. */
68 UISnapshotPane(UIActionPool *pActionPool, bool fShowToolbar = true, QWidget *pParent = 0);
69 /** Destructs snapshot pane. */
70 virtual ~UISnapshotPane() /* override */;
71
72 /** Defines the @a comMachine object to be parsed. */
73 void setMachine(const CMachine &comMachine);
74
75 /** Returns cached snapshot-item icon depending on @a fOnline flag. */
76 const QIcon *snapshotItemIcon(bool fOnline) const;
77
78 /** Returns whether "current state" item selected. */
79 bool isCurrentStateItemSelected() const;
80
81protected:
82
83 /** @name Qt event handlers.
84 * @{ */
85 /** Handles translation event. */
86 virtual void retranslateUi() /* override */;
87
88 /** Handles resize @a pEvent. */
89 virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
90
91 /** Handles show @a pEvent. */
92 virtual void showEvent(QShowEvent *pEvent) /* override */;
93 /** @} */
94
95private slots:
96
97 /** @name Main event handlers.
98 * @{ */
99 /** Handles machine data change for machine with @a uMachineId. */
100 void sltHandleMachineDataChange(const QUuid &uMachineId);
101 /** Handles machine @a enmState change for machine with @a uMachineId. */
102 void sltHandleMachineStateChange(const QUuid &uMachineId, const KMachineState enmState);
103
104 /** Handles session @a enmState change for machine with @a uMachineId. */
105 void sltHandleSessionStateChange(const QUuid &uMachineId, const KSessionState enmState);
106
107 /** Handles snapshot take event for machine with @a uMachineId. */
108 void sltHandleSnapshotTake(const QUuid &uMachineId, const QUuid &uSnapshotId);
109 /** Handles snapshot delete event for machine with @a uMachineId. */
110 void sltHandleSnapshotDelete(const QUuid &uMachineId, const QUuid &uSnapshotId);
111 /** Handles snapshot change event for machine with @a uMachineId. */
112 void sltHandleSnapshotChange(const QUuid &uMachineId, const QUuid &uSnapshotId);
113 /** Handles snapshot restore event for machine with @a uMachineId. */
114 void sltHandleSnapshotRestore(const QUuid &uMachineId, const QUuid &uSnapshotId);
115 /** @} */
116
117 /** @name Timer event handlers.
118 * @{ */
119 /** Updates snapshots age. */
120 void sltUpdateSnapshotsAge();
121 /** @} */
122
123 /** @name Toolbar handlers.
124 * @{ */
125 /** Handles command to take a snapshot. */
126 void sltTakeSnapshot() { takeSnapshot(); }
127 /** Handles command to restore the snapshot. */
128 void sltRestoreSnapshot() { restoreSnapshot(); }
129 /** Handles command to delete the snapshot. */
130 void sltDeleteSnapshot() { deleteSnapshot(); }
131 /** Handles command to make snapshot details @a fVisible. */
132 void sltToggleSnapshotDetailsVisibility(bool fVisible);
133 /** Handles command to apply snapshot details changes. */
134 void sltApplySnapshotDetailsChanges();
135 /** Proposes to clone the snapshot. */
136 void sltCloneSnapshot() { cloneSnapshot(); }
137 /** @} */
138
139 /** @name Tree-widget handlers.
140 * @{ */
141 /** Handles tree-widget current item change. */
142 void sltHandleCurrentItemChange();
143 /** Handles context menu request for tree-widget @a position. */
144 void sltHandleContextMenuRequest(const QPoint &position);
145 /** Handles tree-widget @a pItem change. */
146 void sltHandleItemChange(QTreeWidgetItem *pItem);
147 /** Handles tree-widget @a pItem double-click. */
148 void sltHandleItemDoubleClick(QTreeWidgetItem *pItem);
149 /** @} */
150
151private:
152
153 /** @name Prepare/cleanup cascade.
154 * @{ */
155 /** Prepares all. */
156 void prepare();
157 /** Prepares connections. */
158 void prepareConnections();
159 /** Prepares actions. */
160 void prepareActions();
161 /** Prepares widgets. */
162 void prepareWidgets();
163 /** Prepares toolbar. */
164 void prepareToolbar();
165 /** Prepares tree-widget. */
166 void prepareTreeWidget();
167 /** Prepares details-widget. */
168 void prepareDetailsWidget();
169 /** Load settings: */
170 void loadSettings();
171
172 /** Refreshes everything. */
173 void refreshAll();
174 /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
175 void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
176
177 /** Cleanups all. */
178 void cleanup();
179 /** @} */
180
181 /** @name Toolbar helpers.
182 * @{ */
183 /** Updates action states. */
184 void updateActionStates();
185
186 /** Proposes to take a snapshot. */
187 bool takeSnapshot(bool fAutomatically = false);
188 /** Proposes to delete the snapshot. */
189 bool deleteSnapshot(bool fAutomatically = false);
190 /** Proposes to restore the snapshot. */
191 bool restoreSnapshot(bool fAutomatically = false);
192 /** Proposes to clone the snapshot. */
193 void cloneSnapshot();
194 /** @} */
195
196 /** @name Tree-widget helpers.
197 * @{ */
198 /** Handles command to adjust snapshot tree. */
199 void adjustTreeWidget();
200
201 /** Searches for an item with corresponding @a uSnapshotID. */
202 UISnapshotItem *findItem(const QUuid &uSnapshotID) const;
203
204 /** Searches for smallest snapshot age starting with @a pItem as parent. */
205 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
206
207 /** Expand all the children starting with @a pItem. */
208 void expandItemChildren(QTreeWidgetItem *pItem);
209 /** @} */
210
211 /** @name General variables.
212 * @{ */
213 /** Holds the action-pool reference. */
214 UIActionPool *m_pActionPool;
215 /** Holds whether we should show toolbar. */
216 bool m_fShowToolbar;
217 /** Holds the COM machine object. */
218 CMachine m_comMachine;
219 /** Holds the machine object ID. */
220 QUuid m_uMachineId;
221 /** Holds the cached session state. */
222 KSessionState m_enmSessionState;
223
224 /** Holds whether the snapshot operations are allowed. */
225 bool m_fShapshotOperationsAllowed;
226
227 /** Holds the snapshot item editing protector. */
228 QReadWriteLock *m_pLockReadWrite;
229
230 /** Holds the cached snapshot-item pixmap for 'offline' state. */
231 QIcon *m_pIconSnapshotOffline;
232 /** Holds the cached snapshot-item pixmap for 'online' state. */
233 QIcon *m_pIconSnapshotOnline;
234
235 /** Holds the snapshot age update timer. */
236 QTimer *m_pTimerUpdateAge;
237 /** @} */
238
239 /** @name Widget variables.
240 * @{ */
241 /** Holds the toolbar instance. */
242 UIToolBar *m_pToolBar;
243
244 /** Holds the snapshot tree instance. */
245 UISnapshotTree *m_pSnapshotTree;
246 /** Holds the "current snapshot" item reference. */
247 UISnapshotItem *m_pCurrentSnapshotItem;
248 /** Holds the "current state" item reference. */
249 UISnapshotItem *m_pCurrentStateItem;
250
251 /** Holds the details-widget instance. */
252 UISnapshotDetailsWidget *m_pDetailsWidget;
253 /** @} */
254};
255
256#endif /* !FEQT_INCLUDED_SRC_snapshots_UISnapshotPane_h */
257
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use