1 | /* $Id: UIDetailsSet.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIDetailsSet class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-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_manager_details_UIDetailsSet_h
|
---|
29 | #define FEQT_INCLUDED_SRC_manager_details_UIDetailsSet_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* GUI includes: */
|
---|
35 | #include "UIDetailsItem.h"
|
---|
36 | #include "UIExtraDataDefs.h"
|
---|
37 | #include "UISettingsDefs.h"
|
---|
38 |
|
---|
39 | /* COM includes: */
|
---|
40 | #include "CCloudMachine.h"
|
---|
41 | #include "CMachine.h"
|
---|
42 |
|
---|
43 | /* Forward declarations: */
|
---|
44 | class UIVirtualMachineItem;
|
---|
45 |
|
---|
46 | /* Using declarations: */
|
---|
47 | using namespace UISettingsDefs;
|
---|
48 |
|
---|
49 | /** UIDetailsItem extension implementing set item. */
|
---|
50 | class UIDetailsSet : public UIDetailsItem
|
---|
51 | {
|
---|
52 | Q_OBJECT;
|
---|
53 |
|
---|
54 | public:
|
---|
55 |
|
---|
56 | /** RTTI item type. */
|
---|
57 | enum { Type = UIDetailsItemType_Set };
|
---|
58 |
|
---|
59 | /** Constructs set item, passing pParent to the base-class. */
|
---|
60 | UIDetailsSet(UIDetailsItem *pParent);
|
---|
61 | /** Destructs set item. */
|
---|
62 | virtual ~UIDetailsSet() RT_OVERRIDE;
|
---|
63 |
|
---|
64 | /** @name Item stuff.
|
---|
65 | * @{ */
|
---|
66 | /** Cleanups set, wiping out machine-item and [cloud]machine information for good. */
|
---|
67 | void clearSet();
|
---|
68 | /** Builds set based on passed @a pMachineItem.
|
---|
69 | * @param fFullSet Brings whether full set should be built.
|
---|
70 | * @param settings Brings details related settings. */
|
---|
71 | void buildSet(UIVirtualMachineItem *pMachineItem, bool fFullSet, const QMap<DetailsElementType, bool> &settings);
|
---|
72 |
|
---|
73 | /** Returns cached machine. */
|
---|
74 | const CMachine &machine() const { return m_comMachine; }
|
---|
75 | /** Returns cached cloud machine. */
|
---|
76 | const CCloudMachine &cloudMachine() const { return m_comCloudMachine; }
|
---|
77 |
|
---|
78 | /** Returns whether set is of local type. */
|
---|
79 | bool isLocal() const { return m_fIsLocal; }
|
---|
80 | /** Returns whether set has cached details. */
|
---|
81 | bool hasDetails() const { return m_fHasDetails; }
|
---|
82 | /** Returns configuration access level. */
|
---|
83 | ConfigurationAccessLevel configurationAccessLevel() const { return m_configurationAccessLevel; }
|
---|
84 | /** @} */
|
---|
85 |
|
---|
86 | /** @name Layout stuff.
|
---|
87 | * @{ */
|
---|
88 | /** Updates layout. */
|
---|
89 | virtual void updateLayout() RT_OVERRIDE;
|
---|
90 | /** @} */
|
---|
91 |
|
---|
92 | protected slots:
|
---|
93 |
|
---|
94 | /** @name Item stuff.
|
---|
95 | * @{ */
|
---|
96 | /** Handles request about starting step build.
|
---|
97 | * @param uStepId Brings the step ID.
|
---|
98 | * @param iStepNumber Brings the step number. */
|
---|
99 | virtual void sltBuildStep(const QUuid &uStepId, int iStepNumber) RT_OVERRIDE;
|
---|
100 | /** @} */
|
---|
101 |
|
---|
102 | protected:
|
---|
103 |
|
---|
104 | /** @name Event-handling stuff.
|
---|
105 | * @{ */
|
---|
106 | /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */
|
---|
107 | virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *pWidget = 0) RT_OVERRIDE;
|
---|
108 | /** @} */
|
---|
109 |
|
---|
110 | /** @name Item stuff.
|
---|
111 | * @{ */
|
---|
112 | /** Returns RTTI item type. */
|
---|
113 | virtual int type() const RT_OVERRIDE { return Type; }
|
---|
114 |
|
---|
115 | /** Returns the description of the item. */
|
---|
116 | virtual QString description() const RT_OVERRIDE;
|
---|
117 | /** @} */
|
---|
118 |
|
---|
119 | /** @name Children stuff.
|
---|
120 | * @{ */
|
---|
121 | /** Adds child @a pItem. */
|
---|
122 | virtual void addItem(UIDetailsItem *pItem) RT_OVERRIDE;
|
---|
123 | /** Removes child @a pItem. */
|
---|
124 | virtual void removeItem(UIDetailsItem *pItem) RT_OVERRIDE;
|
---|
125 |
|
---|
126 | /** Returns children items of certain @a enmType. */
|
---|
127 | virtual QList<UIDetailsItem*> items(UIDetailsItemType type = UIDetailsItemType_Element) const RT_OVERRIDE;
|
---|
128 | /** Returns whether there are children items of certain @a enmType. */
|
---|
129 | virtual bool hasItems(UIDetailsItemType type = UIDetailsItemType_Element) const RT_OVERRIDE;
|
---|
130 | /** Clears children items of certain @a enmType. */
|
---|
131 | virtual void clearItems(UIDetailsItemType type = UIDetailsItemType_Element) RT_OVERRIDE;
|
---|
132 |
|
---|
133 | /** Returns details element of certain @a enmElementType. */
|
---|
134 | UIDetailsElement *element(DetailsElementType enmElementType) const;
|
---|
135 | /** @} */
|
---|
136 |
|
---|
137 | /** @name Layout stuff.
|
---|
138 | * @{ */
|
---|
139 | /** Returns minimum width-hint. */
|
---|
140 | virtual int minimumWidthHint() const RT_OVERRIDE;
|
---|
141 | /** Returns minimum height-hint. */
|
---|
142 | virtual int minimumHeightHint() const RT_OVERRIDE;
|
---|
143 | /** @} */
|
---|
144 |
|
---|
145 | private slots:
|
---|
146 |
|
---|
147 | /** @name Event-handling stuff.
|
---|
148 | * @{ */
|
---|
149 | /** Handles machine-state change for item with @a uId. */
|
---|
150 | void sltMachineStateChange(const QUuid &uId);
|
---|
151 | /** Handles machine-attribute change for item with @a uId. */
|
---|
152 | void sltMachineAttributesChange(const QUuid &uId);
|
---|
153 | /** @} */
|
---|
154 |
|
---|
155 | /** @name Item stuff.
|
---|
156 | * @{ */
|
---|
157 | /** Handles enumerated signal for medium with @a uId. */
|
---|
158 | void sltMediumEnumerated(const QUuid &uId);
|
---|
159 | /** @} */
|
---|
160 |
|
---|
161 | private:
|
---|
162 |
|
---|
163 | /** Data field types. */
|
---|
164 | enum SetItemData
|
---|
165 | {
|
---|
166 | /* Layout hints: */
|
---|
167 | SetData_Margin,
|
---|
168 | SetData_Spacing
|
---|
169 | };
|
---|
170 |
|
---|
171 | /** @name Prepare/cleanup cascade.
|
---|
172 | * @{ */
|
---|
173 | /** Prepares set. */
|
---|
174 | void prepareSet();
|
---|
175 | /** Prepares connections. */
|
---|
176 | void prepareConnections();
|
---|
177 | /** @} */
|
---|
178 |
|
---|
179 | /** @name Item stuff.
|
---|
180 | * @{ */
|
---|
181 | /** Returns abstractly stored data value for certain @a iKey. */
|
---|
182 | QVariant data(int iKey) const;
|
---|
183 |
|
---|
184 | /** Rebuilds set based on cached machine item. */
|
---|
185 | void rebuildSet();
|
---|
186 |
|
---|
187 | /** Creates element of specified @a enmElementType in @a fOpen state. */
|
---|
188 | UIDetailsElement *createElement(DetailsElementType enmElementType, bool fOpen);
|
---|
189 | /** @} */
|
---|
190 |
|
---|
191 | /** @name Painting stuff.
|
---|
192 | * @{ */
|
---|
193 | /** Paints background using specified @a pPainter and certain @a pOptions. */
|
---|
194 | void paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions) const;
|
---|
195 | /** @} */
|
---|
196 |
|
---|
197 | /** @name Item stuff.
|
---|
198 | * @{ */
|
---|
199 | /** Holds the machine-item this set is built for. */
|
---|
200 | UIVirtualMachineItem *m_pMachineItem;
|
---|
201 | /** Holds whether whether full set should be built. */
|
---|
202 | bool m_fFullSet;
|
---|
203 | /** Holds the details related settings. */
|
---|
204 | QMap<DetailsElementType, bool> m_settings;
|
---|
205 |
|
---|
206 | /** Holds the machine reference. */
|
---|
207 | CMachine m_comMachine;
|
---|
208 | /** Holds the cloud machine reference. */
|
---|
209 | CCloudMachine m_comCloudMachine;
|
---|
210 |
|
---|
211 | /** Holds whether set is of local type. */
|
---|
212 | bool m_fIsLocal;
|
---|
213 | /** Holds whether set has details. */
|
---|
214 | bool m_fHasDetails;
|
---|
215 | /** Holds configuration access level. */
|
---|
216 | ConfigurationAccessLevel m_configurationAccessLevel;
|
---|
217 |
|
---|
218 | /** Holds the build step instance. */
|
---|
219 | UIPrepareStep *m_pBuildStep;
|
---|
220 | /** Holds the list of types to build steps for. */
|
---|
221 | QList<DetailsElementType> m_types;
|
---|
222 | /** Holds the generated set ID. */
|
---|
223 | QUuid m_uSetId;
|
---|
224 |
|
---|
225 | /** Holds the start background darkness. */
|
---|
226 | int m_iBackgroundDarknessStart;
|
---|
227 | /** Holds the final background darkness. */
|
---|
228 | int m_iBackgroundDarknessFinal;
|
---|
229 | /** @} */
|
---|
230 |
|
---|
231 | /** @name Children stuff.
|
---|
232 | * @{ */
|
---|
233 | /** Holds the map of generated detail elements. */
|
---|
234 | QMap<int, UIDetailsItem*> m_elements;
|
---|
235 | /** @} */
|
---|
236 |
|
---|
237 | /** @name Layout stuff.
|
---|
238 | * @{ */
|
---|
239 | /** Holds the list of elements in the Preview group. */
|
---|
240 | QList<DetailsElementType> m_listPreviewGroup;
|
---|
241 | /** Holds the list of elements in the Outside group. */
|
---|
242 | QList<DetailsElementType> m_listOutsideGroup;
|
---|
243 | /** @} */
|
---|
244 | };
|
---|
245 |
|
---|
246 | #endif /* !FEQT_INCLUDED_SRC_manager_details_UIDetailsSet_h */
|
---|