VirtualBox

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

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

FE/Qt: bugref:6899: Accessibility support (step 35): Selector UI: Extend Snapshot pane with the additional API and the translatable stuff required to be visible by the accessibility interface.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 6.6 KB
Line 
1/* $Id: UISnapshotPane.h 63893 2016-09-19 16:01: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 <QIcon>
23#include <QTimer>
24#include <QReadWriteLock>
25
26/* GUI includes: */
27#include "QIWithRetranslateUI.h"
28#include "VBoxGlobal.h"
29
30/* COM includes: */
31#include "CMachine.h"
32
33/* Forward declarations: */
34class UISnapshotTree;
35class UISnapshotItem;
36class QTreeWidgetItem;
37
38
39/** Snapshot age format. */
40enum SnapshotAgeFormat
41{
42 SnapshotAgeFormat_InSeconds,
43 SnapshotAgeFormat_InMinutes,
44 SnapshotAgeFormat_InHours,
45 SnapshotAgeFormat_InDays,
46 SnapshotAgeFormat_Max
47};
48
49
50/** QWidget extension providing GUI with the pane to control snapshot related functionality. */
51class UISnapshotPane : public QIWithRetranslateUI<QWidget>
52{
53 Q_OBJECT;
54
55public:
56
57 /** Casts QTreeWidgetItem to UISnapshotItem if possible. */
58 static UISnapshotItem *toSnapshotItem(QTreeWidgetItem *pItem);
59 /** Casts const QTreeWidgetItem to const UISnapshotItem if possible. */
60 static const UISnapshotItem *toSnapshotItem(const QTreeWidgetItem *pItem);
61
62 /** Constructs snapshot pane passing @a pParent to the base-class. */
63 UISnapshotPane(QWidget *pParent);
64
65 /** Defines the @a comMachine to be parsed. */
66 void setMachine(const CMachine &comMachine);
67
68 /** Returns cached snapshot-item icon depending on @a fOnline flag. */
69 const QIcon &snapshotItemIcon(bool fOnline) const { return !fOnline ? m_snapshotIconOffline : m_snapshotIconOnline; }
70
71protected:
72
73 /** Handles translation event. */
74 virtual void retranslateUi() /* override */;
75
76private slots:
77
78 /** @name Tree-view handlers
79 * @{ */
80 /** Handles cursor change to @a pItem. */
81 void sltCurrentItemChanged(QTreeWidgetItem *pItem = 0);
82 /** Handles context menu request for @a point. */
83 void sltContextMenuRequested(const QPoint &point);
84 /** Handles modification for @a pItem. */
85 void sltItemChanged(QTreeWidgetItem *pItem);
86 /** Handles double-click for @a pItem. */
87 void sltItemDoubleClicked(QTreeWidgetItem *pItem);
88 /** @} */
89
90 /** @name Main event handlers
91 * @{ */
92 /** Handles machine data change for machine with @a strMachineID. */
93 void sltMachineDataChange(QString strMachineID);
94 /** Handles machine @a enmState change for machine with @a strMachineID. */
95 void sltMachineStateChange(QString strMachineID, KMachineState enmState);
96 /** Handles session @a enmState change for machine with @a strMachineID. */
97 void sltSessionStateChange(QString strMachineID, KSessionState enmState);
98 /** @} */
99
100 /** @name Timer event handlers
101 * @{ */
102 /** Updates snapshots age. */
103 void sltUpdateSnapshotsAge();
104 /** @} */
105
106 /** @name Snapshot operations
107 * @{ */
108 /** Proposes to take a snapshot. */
109 void sltTakeSnapshot() { takeSnapshot(); }
110 /** Proposes to restore the snapshot. */
111 void sltRestoreSnapshot() { restoreSnapshot(); }
112 /** Proposes to delete the snapshot. */
113 void sltDeleteSnapshot() { deleteSnapshot(); }
114 /** Displays the snapshot details dialog. */
115 void sltShowSnapshotDetails() { showSnapshotDetails(); }
116 /** Proposes to clone the snapshot. */
117 void sltCloneSnapshot() { cloneSnapshot(); }
118 /** @} */
119
120private:
121
122 /** @name Snapshot operations
123 * @{ */
124 /** Proposes to take a snapshot. */
125 bool takeSnapshot();
126 /** Proposes to restore the snapshot. */
127 bool restoreSnapshot(bool fSuppressNonCriticalWarnings = false);
128 /** Proposes to delete the snapshot. */
129 bool deleteSnapshot();
130 /** Displays the snapshot details dialog. */
131 void showSnapshotDetails();
132 /** Proposes to clone the snapshot. */
133 void cloneSnapshot();
134 /** @} */
135
136 /** Refreshes everything. */
137 void refreshAll();
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 an item with corresponding @a strSnapshotID. */
142 UISnapshotItem *findItem(const QString &strSnapshotID) const;
143 /** Returns the "current state" item. */
144 UISnapshotItem *currentStateItem() const;
145
146 /** Searches for smallest snapshot age starting with @a pItem as parent. */
147 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
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 UISnapshotItem *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 take action instance. */
166 QAction *m_pActionTakeSnapshot;
167 /** Holds the snapshot restore action instance. */
168 QAction *m_pActionRestoreSnapshot;
169 /** Holds the snapshot delete action instance. */
170 QAction *m_pActionDeleteSnapshot;
171 /** Holds the show snapshot details action instance. */
172 QAction *m_pActionShowSnapshotDetails;
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 /** Holds the snapshot tree instance. */
188 UISnapshotTree *m_pSnapshotTree;
189};
190
191#endif /* !___UISnapshotPane_h___ */
192
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