VirtualBox

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

Last change on this file was 104364, checked in by vboxsync, 5 weeks ago

FE/Qt. Build fix.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use