VirtualBox

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

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

FE/Qt: Selector UI: Tools pane: Snapshot pane: Get rid of Qt deps in header.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 6.4 KB
Line 
1/* $Id: UISnapshotPane.h 67119 2017-05-26 15:54:23Z 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 UISnapshotTree;
35class UISnapshotItem;
36
37
38/** Snapshot age format. */
39enum SnapshotAgeFormat
40{
41 SnapshotAgeFormat_InSeconds,
42 SnapshotAgeFormat_InMinutes,
43 SnapshotAgeFormat_InHours,
44 SnapshotAgeFormat_InDays,
45 SnapshotAgeFormat_Max
46};
47
48
49/** QWidget extension providing GUI with the pane to control snapshot related functionality. */
50class UISnapshotPane : public QIWithRetranslateUI<QWidget>
51{
52 Q_OBJECT;
53
54public:
55
56 /** Constructs snapshot pane passing @a pParent to the base-class. */
57 UISnapshotPane(QWidget *pParent = 0);
58 /** Destructs snapshot pane. */
59 virtual ~UISnapshotPane() /* override */;
60
61 /** Defines the @a comMachine object to be parsed. */
62 void setMachine(const CMachine &comMachine);
63
64 /** Returns cached snapshot-item icon depending on @a fOnline flag. */
65 const QIcon *snapshotItemIcon(bool fOnline) const;
66
67protected:
68
69 /** Handles translation event. */
70 virtual void retranslateUi() /* override */;
71
72private slots:
73
74 /** @name Tree-widget handlers.
75 * @{ */
76 /** Handles cursor change to @a pItem. */
77 void sltCurrentItemChanged(QTreeWidgetItem *pItem = 0);
78 /** Handles context menu request for @a point. */
79 void sltContextMenuRequested(const QPoint &point);
80 /** Handles modification for @a pItem. */
81 void sltItemChanged(QTreeWidgetItem *pItem);
82 /** Handles double-click for @a pItem. */
83 void sltItemDoubleClicked(QTreeWidgetItem *pItem);
84 /** @} */
85
86 /** @name Main event handlers.
87 * @{ */
88 /** Handles machine data change for machine with @a strMachineID. */
89 void sltMachineDataChange(QString strMachineID);
90 /** Handles machine @a enmState change for machine with @a strMachineID. */
91 void sltMachineStateChange(QString strMachineID, KMachineState enmState);
92 /** Handles session @a enmState change for machine with @a strMachineID. */
93 void sltSessionStateChange(QString strMachineID, KSessionState enmState);
94 /** @} */
95
96 /** @name Timer event handlers.
97 * @{ */
98 /** Updates snapshots age. */
99 void sltUpdateSnapshotsAge();
100 /** @} */
101
102 /** @name Toolbar handlers.
103 * @{ */
104 /** Proposes to take a snapshot. */
105 void sltTakeSnapshot() { takeSnapshot(); }
106 /** Proposes to restore the snapshot. */
107 void sltRestoreSnapshot() { restoreSnapshot(); }
108 /** Proposes to delete the snapshot. */
109 void sltDeleteSnapshot() { deleteSnapshot(); }
110 /** Displays the snapshot details dialog. */
111 void sltShowSnapshotDetails() { showSnapshotDetails(); }
112 /** Proposes to clone the snapshot. */
113 void sltCloneSnapshot() { cloneSnapshot(); }
114 /** @} */
115
116private:
117
118 /** @name Toolbar helpers.
119 * @{ */
120 /** Proposes to take a snapshot. */
121 bool takeSnapshot();
122 /** Proposes to restore the snapshot. */
123 bool restoreSnapshot(bool fSuppressNonCriticalWarnings = false);
124 /** Proposes to delete the snapshot. */
125 bool deleteSnapshot();
126 /** Displays the snapshot details dialog. */
127 void showSnapshotDetails();
128 /** Proposes to clone the snapshot. */
129 void cloneSnapshot();
130 /** @} */
131
132 /** Refreshes everything. */
133 void refreshAll();
134 /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
135 void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
136
137 /** @name Tree-widget helpers.
138 * @{ */
139 /** Searches for an item with corresponding @a strSnapshotID. */
140 UISnapshotItem *findItem(const QString &strSnapshotID) const;
141 /** Returns the "current state" item. */
142 UISnapshotItem *currentStateItem() const;
143
144 /** Searches for smallest snapshot age starting with @a pItem as parent. */
145 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
146 /** @} */
147
148 /** @name General variables.
149 * @{ */
150 /** Holds the COM machine object. */
151 CMachine m_comMachine;
152 /** Holds the machine object ID. */
153 QString m_strMachineID;
154 /** Holds the cached session state. */
155 KSessionState m_enmSessionState;
156 /** Holds the current snapshot item reference. */
157 UISnapshotItem *m_pCurrentSnapshotItem;
158 /** Holds the snapshot item editing protector. */
159 QReadWriteLock *m_pLockReadWrite;
160 /** @} */
161
162 /** @name Widget variables.
163 * @{ */
164 /** Holds the Take Snapshot action instance. */
165 QAction *m_pActionTakeSnapshot;
166 /** Holds the Restore Snapshot action instance. */
167 QAction *m_pActionRestoreSnapshot;
168 /** Holds the Delete Snapshot action instance. */
169 QAction *m_pActionDeleteSnapshot;
170 /** Holds the Show Snapshot Details action instance. */
171 QAction *m_pActionShowSnapshotDetails;
172 /** Holds the Clone Snapshot action instance. */
173 QAction *m_pActionCloneSnapshot;
174
175 /** Holds the snapshot age update timer. */
176 QTimer *m_pTimerUpdateAge;
177
178 /** Holds whether the snapshot operations are allowed. */
179 bool m_fShapshotOperationsAllowed;
180
181 /** Holds the cached snapshot-item pixmap for 'offline' state. */
182 QIcon *m_pIconSnapshotOffline;
183 /** Holds the cached snapshot-item pixmap for 'online' state. */
184 QIcon *m_pIconSnapshotOnline;
185
186 /** Holds the snapshot tree instance. */
187 UISnapshotTree *m_pSnapshotTree;
188 /** @} */
189};
190
191#endif /* !___UISnapshotPane_h___ */
192
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