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