VirtualBox

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

Last change on this file since 63834 was 63834, checked in by vboxsync, 9 years ago

FE/Qt: bugref:6899: Accessibility support (step 29): Selector UI: UISnapshotPane: Replacing self-made guard-block with QReadWriteLock.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 6.5 KB
Line 
1/* $Id: UISnapshotPane.h 63834 2016-09-14 13:15:45Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISnapshotPane class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-2016 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/* Qt includes: */
22#include <QTimer>
23#include <QIcon>
24#include <QReadWriteLock>
25
26/* GUI includes: */
27#include "UISnapshotPane.gen.h"
28#include "VBoxGlobal.h"
29#include "QIWithRetranslateUI.h"
30
31/* COM includes: */
32#include "CMachine.h"
33
34/* Forward declarations: */
35class SnapshotWgtItem;
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>, public Ui::UISnapshotPane
51{
52 Q_OBJECT;
53
54public:
55
56 /** Constructs snapshot pane passing @a pParent to the base-class. */
57 UISnapshotPane(QWidget *pParent);
58
59 /** Defines the @a comMachine to be parsed. */
60 void setMachine(const CMachine &comMachine);
61
62 /** Returns cached snapshot-item icon depending on @a fOnline flag. */
63 const QIcon &snapshotItemIcon(bool fOnline) const { return !fOnline ? m_snapshotIconOffline : m_snapshotIconOnline; }
64
65protected:
66
67 /** Handles translation event. */
68 virtual void retranslateUi() /* override */;
69
70private slots:
71
72 /** @name Tree-view handlers
73 * @{ */
74 /** Handles cursor change to @a pItem. */
75 void sltCurrentItemChanged(QTreeWidgetItem *pItem = 0);
76 /** Handles context menu request for @a point. */
77 void sltContextMenuRequested(const QPoint &point);
78 /** Handles modification for @a pItem. */
79 void sltItemChanged(QTreeWidgetItem *pItem);
80 /** Handles double-click for @a pItem. */
81 void sltItemDoubleClicked(QTreeWidgetItem *pItem);
82 /** @} */
83
84 /** @name Snapshot operations
85 * @{ */
86 /** Proposes to take a snapshot. */
87 void sltTakeSnapshot() { takeSnapshot(); }
88 /** Proposes to restore the snapshot. */
89 void sltRestoreSnapshot(bool fSuppressNonCriticalWarnings = false);
90 /** Proposes to delete the snapshot. */
91 void sltDeleteSnapshot();
92 /** Displays the snapshot details dialog. */
93 void sltShowSnapshotDetails();
94 /** Proposes to clone the snapshot. */
95 void sltCloneSnapshot();
96 /** @} */
97
98 /** @name Main event handlers
99 * @{ */
100 /** Handles machine data change for machine with @a strMachineID. */
101 void sltMachineDataChange(QString strMachineID);
102 /** Handles machine @a enmState change for machine with @a strMachineID. */
103 void sltMachineStateChange(QString strMachineID, KMachineState enmState);
104 /** Handles session @a enmState change for machine with @a strMachineID. */
105 void sltSessionStateChange(QString strMachineID, KSessionState enmState);
106 /** @} */
107
108 /** @name Timer event handlers
109 * @{ */
110 /** Updates snapshots age. */
111 void sltUpdateSnapshotsAge();
112 /** @} */
113
114private:
115
116 /** @name Snapshot operations
117 * @{ */
118 /** Proposes to take a snapshot. */
119 bool takeSnapshot();
120 /** Proposes to restore the snapshot. */
121 //bool restoreSnapshot();
122 /** Proposes to delete the snapshot. */
123 //bool deleteSnapshot();
124 /** Displays the snapshot details dialog. */
125 //bool showSnapshotDetails();
126 /** Proposes to clone the snapshot. */
127 //bool cloneSnapshot();
128 /** @} */
129
130 /** Refreshes everything. */
131 void refreshAll();
132
133 /** Searches for an item with corresponding @a strSnapshotID. */
134 SnapshotWgtItem *findItem(const QString &strSnapshotID) const;
135 /** Returns the "current state" item. */
136 SnapshotWgtItem *currentStateItem() const;
137
138 /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
139 void populateSnapshots(const CSnapshot &comSnapshot, QTreeWidgetItem *pItem);
140
141 /** Searches for smallest snapshot age starting with @a pItem as parent. */
142 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
143
144 /** Casts QTreeWidgetItem to SnapshotWgtItem if possible. */
145 static SnapshotWgtItem *toSnapshotItem(QTreeWidgetItem *pItem);
146 /** Casts const QTreeWidgetItem to const SnapshotWgtItem if possible. */
147 static const SnapshotWgtItem *toSnapshotItem(const QTreeWidgetItem *pItem);
148
149 /** Holds the machine COM wrapper. */
150 CMachine m_comMachine;
151 /** Holds the machine ID. */
152 QString m_strMachineID;
153 /** Holds the cached session state. */
154 KSessionState m_enmSessionState;
155 /** Holds the current snapshot item reference. */
156 SnapshotWgtItem *m_pCurrentSnapshotItem;
157 /** Holds the snapshot item editing protector. */
158 QReadWriteLock m_lockReadWrite;
159
160 /** Holds the snapshot item action group instance. */
161 QActionGroup *m_pSnapshotItemActionGroup;
162 /** Holds the current item action group instance. */
163 QActionGroup *m_pCurrentStateItemActionGroup;
164
165 /** Holds the snapshot restore action instance. */
166 QAction *m_pActionRestoreSnapshot;
167 /** Holds the snapshot delete action instance. */
168 QAction *m_pActionDeleteSnapshot;
169 /** Holds the show snapshot details action instance. */
170 QAction *m_pActionShowSnapshotDetails;
171 /** Holds the snapshot take action instance. */
172 QAction *m_pActionTakeSnapshot;
173 /** Holds the snapshot clone action instance. */
174 QAction *m_pActionCloneSnapshot;
175
176 /** Holds the snapshot age update timer. */
177 QTimer m_ageUpdateTimer;
178
179 /** Holds whether the snapshot operations are allowed. */
180 bool m_fShapshotOperationsAllowed;
181
182 /** Holds the cached snapshot-item pixmap for 'offline' state. */
183 QIcon m_snapshotIconOffline;
184 /** Holds the cached snapshot-item pixmap for 'online' state. */
185 QIcon m_snapshotIconOnline;
186};
187
188#endif /* !___UISnapshotPane_h___ */
189
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