1 | /* $Id: UIMediumDetailsWidget.h 78437 2019-05-07 14:40:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMediumDetailsWidget class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 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 FEQT_INCLUDED_SRC_medium_UIMediumDetailsWidget_h
|
---|
19 | #define FEQT_INCLUDED_SRC_medium_UIMediumDetailsWidget_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QWidget>
|
---|
26 |
|
---|
27 | /* GUI includes: */
|
---|
28 | #include "QIManagerDialog.h"
|
---|
29 | #include "QIWithRetranslateUI.h"
|
---|
30 | #include "UIMediumDefs.h"
|
---|
31 |
|
---|
32 | /* COM includes: */
|
---|
33 | #include "COMEnums.h"
|
---|
34 |
|
---|
35 | /* Forward declarations: */
|
---|
36 | class QAbstractButton;
|
---|
37 | class QComboBox;
|
---|
38 | class QLabel;
|
---|
39 | class QLineEdit;
|
---|
40 | class QStackedLayout;
|
---|
41 | class QTextEdit;
|
---|
42 | class QWidget;
|
---|
43 | class QILabel;
|
---|
44 | class QITabWidget;
|
---|
45 | class QIToolButton;
|
---|
46 | class UIEnumerationProgressBar;
|
---|
47 | class UIMediumManagerWidget;
|
---|
48 | class UIMediumSizeEditor;
|
---|
49 |
|
---|
50 |
|
---|
51 | /** Virtual Media Manager: Medium options data structure. */
|
---|
52 | struct UIDataMediumOptions
|
---|
53 | {
|
---|
54 | /** Constructs data. */
|
---|
55 | UIDataMediumOptions()
|
---|
56 | : m_enmMediumType(KMediumType_Normal)
|
---|
57 | , m_strLocation(QString())
|
---|
58 | , m_strDescription(QString())
|
---|
59 | , m_uLogicalSize(0)
|
---|
60 | {}
|
---|
61 |
|
---|
62 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
63 | bool equal(const UIDataMediumOptions &other) const
|
---|
64 | {
|
---|
65 | return true
|
---|
66 | && (m_enmMediumType == other.m_enmMediumType)
|
---|
67 | && (m_strLocation == other.m_strLocation)
|
---|
68 | && (m_strDescription == other.m_strDescription)
|
---|
69 | && (m_uLogicalSize == other.m_uLogicalSize)
|
---|
70 | ;
|
---|
71 | }
|
---|
72 |
|
---|
73 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
74 | bool operator==(const UIDataMediumOptions &other) const { return equal(other); }
|
---|
75 | /** Returns whether the @a other passed data is different from this one. */
|
---|
76 | bool operator!=(const UIDataMediumOptions &other) const { return !equal(other); }
|
---|
77 |
|
---|
78 | /** Holds the medium type. */
|
---|
79 | KMediumType m_enmMediumType;
|
---|
80 | /** Holds the location. */
|
---|
81 | QString m_strLocation;
|
---|
82 | /** Holds the description. */
|
---|
83 | QString m_strDescription;
|
---|
84 | /** Holds the logical size. */
|
---|
85 | qulonglong m_uLogicalSize;
|
---|
86 | };
|
---|
87 |
|
---|
88 |
|
---|
89 | /** Virtual Media Manager: Medium details data structure. */
|
---|
90 | struct UIDataMediumDetails
|
---|
91 | {
|
---|
92 | /** Constructs data. */
|
---|
93 | UIDataMediumDetails()
|
---|
94 | : m_aLabels(QStringList())
|
---|
95 | , m_aFields(QStringList())
|
---|
96 | {}
|
---|
97 |
|
---|
98 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
99 | bool equal(const UIDataMediumDetails &other) const
|
---|
100 | {
|
---|
101 | return true
|
---|
102 | && (m_aLabels == other.m_aLabels)
|
---|
103 | && (m_aFields == other.m_aFields)
|
---|
104 | ;
|
---|
105 | }
|
---|
106 |
|
---|
107 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
108 | bool operator==(const UIDataMediumDetails &other) const { return equal(other); }
|
---|
109 | /** Returns whether the @a other passed data is different from this one. */
|
---|
110 | bool operator!=(const UIDataMediumDetails &other) const { return !equal(other); }
|
---|
111 |
|
---|
112 | /** Holds the labels list. */
|
---|
113 | QStringList m_aLabels;
|
---|
114 | /** Holds the fields list. */
|
---|
115 | QStringList m_aFields;
|
---|
116 | };
|
---|
117 |
|
---|
118 |
|
---|
119 | /** Virtual Media Manager: Medium data structure. */
|
---|
120 | struct UIDataMedium
|
---|
121 | {
|
---|
122 | /** Constructs data. */
|
---|
123 | UIDataMedium()
|
---|
124 | : m_fValid(false)
|
---|
125 | , m_enmDeviceType(UIMediumDeviceType_Invalid)
|
---|
126 | , m_enmVariant(KMediumVariant_Max)
|
---|
127 | , m_fHasChildren(false)
|
---|
128 | , m_options(UIDataMediumOptions())
|
---|
129 | , m_details(UIDataMediumDetails())
|
---|
130 | {}
|
---|
131 |
|
---|
132 | /** Constructs data with passed @enmType. */
|
---|
133 | UIDataMedium(UIMediumDeviceType enmType)
|
---|
134 | : m_fValid(false)
|
---|
135 | , m_enmDeviceType(enmType)
|
---|
136 | , m_enmVariant(KMediumVariant_Max)
|
---|
137 | , m_fHasChildren(false)
|
---|
138 | , m_options(UIDataMediumOptions())
|
---|
139 | , m_details(UIDataMediumDetails())
|
---|
140 | {}
|
---|
141 |
|
---|
142 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
143 | bool equal(const UIDataMedium &other) const
|
---|
144 | {
|
---|
145 | return true
|
---|
146 | && (m_fValid == other.m_fValid)
|
---|
147 | && (m_enmDeviceType == other.m_enmDeviceType)
|
---|
148 | && (m_enmVariant == other.m_enmVariant)
|
---|
149 | && (m_fHasChildren == other.m_fHasChildren)
|
---|
150 | && (m_options == other.m_options)
|
---|
151 | && (m_details == other.m_details)
|
---|
152 | ;
|
---|
153 | }
|
---|
154 |
|
---|
155 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
156 | bool operator==(const UIDataMedium &other) const { return equal(other); }
|
---|
157 | /** Returns whether the @a other passed data is different from this one. */
|
---|
158 | bool operator!=(const UIDataMedium &other) const { return !equal(other); }
|
---|
159 |
|
---|
160 | /** Holds whether data is valid. */
|
---|
161 | bool m_fValid;
|
---|
162 | /** Holds the medium type. */
|
---|
163 | UIMediumDeviceType m_enmDeviceType;
|
---|
164 | /** Holds the medium variant. */
|
---|
165 | KMediumVariant m_enmVariant;
|
---|
166 | /** Holds whether medium has children. */
|
---|
167 | bool m_fHasChildren;
|
---|
168 |
|
---|
169 | /** Holds the medium options. */
|
---|
170 | UIDataMediumOptions m_options;
|
---|
171 | /** Holds the details data. */
|
---|
172 | UIDataMediumDetails m_details;
|
---|
173 | };
|
---|
174 |
|
---|
175 |
|
---|
176 | /** Virtual Media Manager: Virtual Media Manager details-widget. */
|
---|
177 | class UIMediumDetailsWidget : public QIWithRetranslateUI<QWidget>
|
---|
178 | {
|
---|
179 | Q_OBJECT;
|
---|
180 |
|
---|
181 | signals:
|
---|
182 |
|
---|
183 | /** Notifies listeners about accept is allowed. */
|
---|
184 | void sigAcceptAllowed(bool fAllowed);
|
---|
185 | /** Notifies listeners about reject is allowed. */
|
---|
186 | void sigRejectAllowed(bool fAllowed);
|
---|
187 |
|
---|
188 | /** Notifies listeners about data change rejected and should be reseted. */
|
---|
189 | void sigDataChangeRejected();
|
---|
190 | /** Notifies listeners about data change accepted and should be applied. */
|
---|
191 | void sigDataChangeAccepted();
|
---|
192 |
|
---|
193 | public:
|
---|
194 |
|
---|
195 | /** Constructs medium details dialog passing @a pParent to the base-class.
|
---|
196 | * @param enmEmbedding Brings embedding type. */
|
---|
197 | UIMediumDetailsWidget(UIMediumManagerWidget *pParent, EmbedTo enmEmbedding);
|
---|
198 |
|
---|
199 | /** Defines the raised details @a enmType. */
|
---|
200 | void setCurrentType(UIMediumDeviceType enmType);
|
---|
201 |
|
---|
202 | /** Returns the medium data. */
|
---|
203 | const UIDataMedium &data() const { return m_newData; }
|
---|
204 | /** Defines the @a data for passed @a enmType. */
|
---|
205 | void setData(const UIDataMedium &data);
|
---|
206 | /** Enables/disables some of the medium editing widgets of the details tab. */
|
---|
207 | void enableDisableMediumModificationWidgets(bool fMediumIsModifiable);
|
---|
208 |
|
---|
209 | public slots:
|
---|
210 |
|
---|
211 | /** Defines whether the options tab is @a fEnabled. */
|
---|
212 | void setOptionsEnabled(bool fEnabled);
|
---|
213 |
|
---|
214 | protected:
|
---|
215 |
|
---|
216 | /** Handles translation event. */
|
---|
217 | virtual void retranslateUi() /* override */;
|
---|
218 |
|
---|
219 | private slots:
|
---|
220 |
|
---|
221 | /** @name Options stuff.
|
---|
222 | * @{ */
|
---|
223 | /** Handles type change. */
|
---|
224 | void sltTypeIndexChanged(int iIndex);
|
---|
225 | /** Handles location change. */
|
---|
226 | void sltLocationPathChanged(const QString &strPath);
|
---|
227 | /** Handles request to choose location. */
|
---|
228 | void sltChooseLocationPath();
|
---|
229 | /** Handles description text change. */
|
---|
230 | void sltDescriptionTextChanged();
|
---|
231 | /** Handles size editor change. */
|
---|
232 | void sltSizeValueChanged(qulonglong uSize);
|
---|
233 |
|
---|
234 | /** Handles button-box button click. */
|
---|
235 | void sltHandleButtonBoxClick(QAbstractButton *pButton);
|
---|
236 | /** @} */
|
---|
237 |
|
---|
238 | private:
|
---|
239 |
|
---|
240 | /** @name Prepare/cleanup cascade.
|
---|
241 | * @{ */
|
---|
242 | /** Prepares all. */
|
---|
243 | void prepare();
|
---|
244 | /** Prepares this. */
|
---|
245 | void prepareThis();
|
---|
246 | /** Prepares tab-widget. */
|
---|
247 | void prepareTabWidget();
|
---|
248 | /** Prepares 'Options' tab. */
|
---|
249 | void prepareTabOptions();
|
---|
250 | /** Prepares 'Details' tab. */
|
---|
251 | void prepareTabDetails();
|
---|
252 | /** Prepares information-container. */
|
---|
253 | void prepareInformationContainer(UIMediumDeviceType enmType, int cFields);
|
---|
254 | /** @} */
|
---|
255 |
|
---|
256 | /** @name Loading stuff.
|
---|
257 | * @{ */
|
---|
258 | /** Load options data. */
|
---|
259 | void loadDataForOptions();
|
---|
260 | /** Load details data. */
|
---|
261 | void loadDataForDetails();
|
---|
262 | /** @} */
|
---|
263 |
|
---|
264 | /** @name Options stuff.
|
---|
265 | * @{ */
|
---|
266 | /** Revalidates changes for passed @a pWidget. */
|
---|
267 | void revalidate(QWidget *pWidget = 0);
|
---|
268 | /** Retranslates validation for passed @a pWidget. */
|
---|
269 | void retranslateValidation(QWidget *pWidget = 0);
|
---|
270 | /** Updates button states. */
|
---|
271 | void updateButtonStates();
|
---|
272 |
|
---|
273 | /** Returns tool-tip for passed medium @a enmType. */
|
---|
274 | static QString mediumTypeTip(KMediumType enmType);
|
---|
275 | /** @} */
|
---|
276 |
|
---|
277 | /** @name Details stuff.
|
---|
278 | * @{ */
|
---|
279 | /** Returns information-container for passed medium @a enmType. */
|
---|
280 | QWidget *infoContainer(UIMediumDeviceType enmType) const;
|
---|
281 | /** Returns information-label for passed medium @a enmType and @a iIndex. */
|
---|
282 | QLabel *infoLabel(UIMediumDeviceType enmType, int iIndex) const;
|
---|
283 | /** Returns information-field for passed medium @a enmType and @a iIndex. */
|
---|
284 | QILabel *infoField(UIMediumDeviceType enmType, int iIndex) const;
|
---|
285 | /** @} */
|
---|
286 |
|
---|
287 | /** @name General variables.
|
---|
288 | * @{ */
|
---|
289 | /** Holds the parent reference. */
|
---|
290 | UIMediumManagerWidget *m_pParent;
|
---|
291 | /** Holds the parent widget embedding type. */
|
---|
292 | const EmbedTo m_enmEmbedding;
|
---|
293 |
|
---|
294 | /** Holds the old data copy. */
|
---|
295 | UIDataMedium m_oldData;
|
---|
296 | /** Holds the new data copy. */
|
---|
297 | UIDataMedium m_newData;
|
---|
298 |
|
---|
299 | /** Holds the tab-widget. */
|
---|
300 | QITabWidget *m_pTabWidget;
|
---|
301 | /** @} */
|
---|
302 |
|
---|
303 | /** @name Options variables.
|
---|
304 | * @{ */
|
---|
305 | /** Holds the type label. */
|
---|
306 | QLabel *m_pLabelType;
|
---|
307 | /** Holds the type combo-box. */
|
---|
308 | QComboBox *m_pComboBoxType;
|
---|
309 | /** Holds the type error pane. */
|
---|
310 | QLabel *m_pErrorPaneType;
|
---|
311 |
|
---|
312 | /** Holds the location label. */
|
---|
313 | QLabel *m_pLabelLocation;
|
---|
314 | /** Holds the location editor. */
|
---|
315 | QLineEdit *m_pEditorLocation;
|
---|
316 | /** Holds the location error pane. */
|
---|
317 | QLabel *m_pErrorPaneLocation;
|
---|
318 | /** Holds the location button. */
|
---|
319 | QIToolButton *m_pButtonLocation;
|
---|
320 |
|
---|
321 | /** Holds the description label. */
|
---|
322 | QLabel *m_pLabelDescription;
|
---|
323 | /** Holds the description editor. */
|
---|
324 | QTextEdit *m_pEditorDescription;
|
---|
325 | /** Holds the description error pane. */
|
---|
326 | QLabel *m_pErrorPaneDescription;
|
---|
327 |
|
---|
328 | /** Holds the size label. */
|
---|
329 | QLabel *m_pLabelSize;
|
---|
330 | /** Holds the size editor. */
|
---|
331 | UIMediumSizeEditor *m_pEditorSize;
|
---|
332 | /** Holds the size error pane. */
|
---|
333 | QLabel *m_pErrorPaneSize;
|
---|
334 |
|
---|
335 | /** Holds the button-box instance. */
|
---|
336 | QIDialogButtonBox *m_pButtonBox;
|
---|
337 | /** Holds the progress-bar widget instance. */
|
---|
338 | UIEnumerationProgressBar *m_pProgressBar;
|
---|
339 |
|
---|
340 | /** Holds whether options are valid. */
|
---|
341 | bool m_fValid;
|
---|
342 | /** @} */
|
---|
343 |
|
---|
344 | /** @name Details variables.
|
---|
345 | * @{ */
|
---|
346 | /** Holds the details layout: */
|
---|
347 | QStackedLayout *m_pLayoutDetails;
|
---|
348 |
|
---|
349 | /** Holds the map of information-container instances. */
|
---|
350 | QMap<UIMediumDeviceType, QWidget*> m_aContainers;
|
---|
351 | /** Holds the map of information-container label instances. */
|
---|
352 | QMap<UIMediumDeviceType, QList<QLabel*> > m_aLabels;
|
---|
353 | /** Holds the information-container field instances. */
|
---|
354 | QMap<UIMediumDeviceType, QList<QILabel*> > m_aFields;
|
---|
355 | /** @} */
|
---|
356 | };
|
---|
357 |
|
---|
358 | #endif /* !FEQT_INCLUDED_SRC_medium_UIMediumDetailsWidget_h */
|
---|