VirtualBox

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

Last change on this file since 104158 was 103803, checked in by vboxsync, 9 months ago

FE/Qt. bugref:10618. Splitting COMEnums.h file into individual enum header files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1/* $Id: UISnapshotPane.h 103803 2024-03-12 11:15:18Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISnapshotPane class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_snapshots_UISnapshotPane_h
29#define FEQT_INCLUDED_SRC_snapshots_UISnapshotPane_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QUuid>
36
37/* GUI includes: */
38#include "QIWithRetranslateUI.h"
39
40/* COM includes: */
41#include "CMachine.h"
42
43/* Forward declarations: */
44class QIcon;
45class QReadWriteLock;
46class QTimer;
47class QTreeWidgetItem;
48class QVBoxLayout;
49class QIToolBar;
50class QITreeWidgetItem;
51class UIActionPool;
52class UISnapshotDetailsWidget;
53class UISnapshotItem;
54class UISnapshotTree;
55class UIVirtualMachineItem;
56class CSnapshot;
57
58
59/** Snapshot age format. */
60enum SnapshotAgeFormat
61{
62 SnapshotAgeFormat_InSeconds,
63 SnapshotAgeFormat_InMinutes,
64 SnapshotAgeFormat_InHours,
65 SnapshotAgeFormat_InDays,
66 SnapshotAgeFormat_Max
67};
68
69
70/** QWidget extension providing GUI with the pane to control snapshot related functionality. */
71class UISnapshotPane : public QIWithRetranslateUI<QWidget>
72{
73 Q_OBJECT;
74
75signals:
76
77 /** Notifies listeners about current item change. */
78 void sigCurrentItemChange();
79
80public:
81
82 /** Constructs snapshot pane passing @a pParent to the base-class. */
83 UISnapshotPane(UIActionPool *pActionPool, bool fShowToolbar = true, QWidget *pParent = 0);
84 /** Destructs snapshot pane. */
85 virtual ~UISnapshotPane() RT_OVERRIDE;
86
87 /** Defines the machine @a items to be parsed. */
88 void setMachineItems(const QList<UIVirtualMachineItem*> &items);
89
90 /** Returns cached snapshot-item icon depending on @a fOnline flag. */
91 const QIcon *snapshotItemIcon(bool fOnline) const;
92
93 /** Returns whether "current state" item selected. */
94 bool isCurrentStateItemSelected() const;
95
96 /** Returns currently selected snapshot ID if any. */
97 QUuid currentSnapshotId();
98
99protected:
100
101 /** @name Qt event handlers.
102 * @{ */
103 /** Handles translation event. */
104 virtual void retranslateUi() RT_OVERRIDE;
105
106 /** Handles resize @a pEvent. */
107 virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
108
109 /** Handles show @a pEvent. */
110 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
111 /** @} */
112
113private slots:
114
115 /** @name Main event handlers.
116 * @{ */
117 /** Handles machine data change for machine with @a uMachineId. */
118 void sltHandleMachineDataChange(const QUuid &uMachineId);
119 /** Handles machine @a enmState change for machine with @a uMachineId. */
120 void sltHandleMachineStateChange(const QUuid &uMachineId, const KMachineState enmState);
121
122 /** Handles session @a enmState change for machine with @a uMachineId. */
123 void sltHandleSessionStateChange(const QUuid &uMachineId, const KSessionState enmState);
124
125 /** Handles snapshot take event for machine with @a uMachineId. */
126 void sltHandleSnapshotTake(const QUuid &uMachineId, const QUuid &uSnapshotId);
127 /** Handles snapshot delete event for machine with @a uMachineId. */
128 void sltHandleSnapshotDelete(const QUuid &uMachineId, const QUuid &uSnapshotId);
129 /** Handles snapshot change event for machine with @a uMachineId. */
130 void sltHandleSnapshotChange(const QUuid &uMachineId, const QUuid &uSnapshotId);
131 /** Handles snapshot restore event for machine with @a uMachineId. */
132 void sltHandleSnapshotRestore(const QUuid &uMachineId, const QUuid &uSnapshotId);
133 /** @} */
134
135 /** @name Timer event handlers.
136 * @{ */
137 /** Updates snapshots age. */
138 void sltUpdateSnapshotsAge();
139 /** @} */
140
141 /** @name Toolbar handlers.
142 * @{ */
143 /** Handles command to take a snapshot. */
144 void sltTakeSnapshot() { takeSnapshot(); }
145 /** Handles command to restore the snapshot. */
146 void sltRestoreSnapshot() { restoreSnapshot(); }
147 /** Handles command to delete the snapshot. */
148 void sltDeleteSnapshot() { deleteSnapshot(); }
149 /** Handles command to make snapshot details @a fVisible. */
150 void sltToggleSnapshotDetailsVisibility(bool fVisible);
151 /** Handles command to apply snapshot details changes. */
152 void sltApplySnapshotDetailsChanges();
153 /** @} */
154
155 /** @name Tree-widget handlers.
156 * @{ */
157 /** Handles tree-widget current item change. */
158 void sltHandleCurrentItemChange();
159 /** Handles context menu request for tree-widget @a position. */
160 void sltHandleContextMenuRequest(const QPoint &position);
161 /** Handles tree-widget @a pItem change. */
162 void sltHandleItemChange(QTreeWidgetItem *pItem);
163 /** Handles tree-widget @a pItem double-click. */
164 void sltHandleItemDoubleClick(QTreeWidgetItem *pItem);
165 /** Handles tree-widget's scroll-bar visibility change. */
166 void sltHandleScrollBarVisibilityChange();
167 /** @} */
168
169private:
170
171 /** @name Prepare/cleanup cascade.
172 * @{ */
173 /** Prepares all. */
174 void prepare();
175 /** Prepares connections. */
176 void prepareConnections();
177 /** Prepares actions. */
178 void prepareActions();
179 /** Prepares widgets. */
180 void prepareWidgets();
181 /** Prepares toolbar. */
182 void prepareToolbar();
183 /** Prepares tree-widget. */
184 void prepareTreeWidget();
185 /** Prepares details-widget. */
186 void prepareDetailsWidget();
187 /** Load settings: */
188 void loadSettings();
189
190 /** Refreshes everything. */
191 void refreshAll();
192 /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
193 void populateSnapshots(const QUuid &uMachineId, const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
194
195 /** Cleanups all. */
196 void cleanup();
197 /** @} */
198
199 /** @name Toolbar helpers.
200 * @{ */
201 /** Updates action states. */
202 void updateActionStates();
203
204 /** Proposes to take a snapshot. */
205 bool takeSnapshot(bool fAutomatically = false);
206 /** Proposes to delete the snapshot. */
207 bool deleteSnapshot(bool fAutomatically = false);
208 /** Proposes to restore the snapshot. */
209 bool restoreSnapshot(bool fAutomatically = false);
210 /** @} */
211
212 /** @name Tree-widget helpers.
213 * @{ */
214 /** Handles command to adjust snapshot tree. */
215 void adjustTreeWidget();
216
217 /** Searches for an item with corresponding @a uSnapshotID. */
218 UISnapshotItem *findItem(const QUuid &uSnapshotID) const;
219
220 /** Searches for smallest snapshot age starting with @a pItem as parent. */
221 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
222
223 /** Expand all the children starting with @a pItem. */
224 void expandItemChildren(QTreeWidgetItem *pItem);
225 /** @} */
226
227 /** @name General variables.
228 * @{ */
229 /** Holds the action-pool reference. */
230 UIActionPool *m_pActionPool;
231 /** Holds whether we should show toolbar. */
232 bool m_fShowToolbar;
233
234 /** Holds the COM machine object list. */
235 QMap<QUuid, CMachine> m_machines;
236 /** Holds the cached session state list. */
237 QMap<QUuid, KSessionState> m_sessionStates;
238 /** Holds the list of operation allowance states. */
239 QMap<QUuid, bool> m_operationAllowed;
240
241 /** Holds the snapshot item editing protector. */
242 QReadWriteLock *m_pLockReadWrite;
243
244 /** Holds the cached snapshot-item pixmap for 'offline' state. */
245 QIcon *m_pIconSnapshotOffline;
246 /** Holds the cached snapshot-item pixmap for 'online' state. */
247 QIcon *m_pIconSnapshotOnline;
248
249 /** Holds the snapshot age update timer. */
250 QTimer *m_pTimerUpdateAge;
251 /** @} */
252
253 /** @name Widget variables.
254 * @{ */
255 /** Holds the main layout instance. */
256 QVBoxLayout *m_pLayoutMain;
257
258 /** Holds the toolbar instance. */
259 QIToolBar *m_pToolBar;
260
261 /** Holds the snapshot tree instance. */
262 UISnapshotTree *m_pSnapshotTree;
263
264 /** Holds the "current snapshot" item list. */
265 QMap<QUuid, UISnapshotItem*> m_currentSnapshotItems;
266 /** Holds the "current state" item list. */
267 QMap<QUuid, UISnapshotItem*> m_currentStateItems;
268
269 /** Holds the details-widget instance. */
270 UISnapshotDetailsWidget *m_pDetailsWidget;
271 /** @} */
272};
273
274#endif /* !FEQT_INCLUDED_SRC_snapshots_UISnapshotPane_h */
275
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