VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.h

Last change on this file was 104226, checked in by vboxsync, 6 weeks ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in medium manager related classes.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use