1 | /* $Id: UIMediaComboBox.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMediaComboBox 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_widgets_UIMediaComboBox_h
|
---|
29 | #define FEQT_INCLUDED_SRC_widgets_UIMediaComboBox_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QComboBox>
|
---|
36 | #include <QString>
|
---|
37 |
|
---|
38 | /* GUI includes: */
|
---|
39 | #include "UICommon.h"
|
---|
40 | #include "UILibraryDefs.h"
|
---|
41 |
|
---|
42 | /** QComboBox subclass representing a list of registered media. */
|
---|
43 | class SHARED_LIBRARY_STUFF UIMediaComboBox : public QComboBox
|
---|
44 | {
|
---|
45 | Q_OBJECT;
|
---|
46 |
|
---|
47 | public:
|
---|
48 |
|
---|
49 | /** Base-to-diff media map. */
|
---|
50 | typedef QMap<QString, QString> BaseToDiffMap;
|
---|
51 |
|
---|
52 | /** Constructs media combo-box passing @a pParent to the base-class. */
|
---|
53 | UIMediaComboBox(QWidget *pParent = 0);
|
---|
54 |
|
---|
55 | /** Performs refresh. */
|
---|
56 | void refresh();
|
---|
57 | /** Performs repopulation. */
|
---|
58 | void repopulate();
|
---|
59 |
|
---|
60 | /** Defines @a enmMediaType. */
|
---|
61 | void setType(UIMediumDeviceType enmMediaType) { m_enmMediaType = enmMediaType; }
|
---|
62 | /** Returns media type. */
|
---|
63 | UIMediumDeviceType type() const { return m_enmMediaType; }
|
---|
64 |
|
---|
65 | /** Defines @a uMachineId. */
|
---|
66 | void setMachineId(const QUuid &uMachineId) { m_uMachineId = uMachineId; }
|
---|
67 |
|
---|
68 | /** Defines current item through @a uItemId. */
|
---|
69 | void setCurrentItem(const QUuid &uItemId);
|
---|
70 |
|
---|
71 | /** Returns id of item with certain @a iIndex. */
|
---|
72 | QUuid id(int iIndex = -1) const;
|
---|
73 | /** Returns location of item with certain @a iIndex. */
|
---|
74 | QString location(int iIndex = -1) const;
|
---|
75 |
|
---|
76 | protected slots:
|
---|
77 |
|
---|
78 | /** Habdles medium-created signal for medium with @a uMediumId. */
|
---|
79 | void sltHandleMediumCreated(const QUuid &uMediumId);
|
---|
80 | /** Habdles medium-enumerated signal for medium with @a uMediumId. */
|
---|
81 | void sltHandleMediumEnumerated(const QUuid &uMediumId);
|
---|
82 | /** Habdles medium-deleted signal for medium with @a uMediumId. */
|
---|
83 | void sltHandleMediumDeleted(const QUuid &uMediumId);
|
---|
84 |
|
---|
85 | /** Handles medium-enumeration start. */
|
---|
86 | void sltHandleMediumEnumerationStart();
|
---|
87 |
|
---|
88 | /** Handles combo activation for item with certain @a iIndex. */
|
---|
89 | void sltHandleComboActivated(int iIndex);
|
---|
90 |
|
---|
91 | /** Handles combo hovering for item with certain @a index. */
|
---|
92 | void sltHandleComboHovered(const QModelIndex &index);
|
---|
93 |
|
---|
94 | protected:
|
---|
95 |
|
---|
96 | /** Prepares all. */
|
---|
97 | void prepare();
|
---|
98 |
|
---|
99 | /** Uses the tool-tip of the item with @a iIndex. */
|
---|
100 | void updateToolTip(int iIndex);
|
---|
101 |
|
---|
102 | /** Appends item for certain @a guiMedium. */
|
---|
103 | void appendItem(const UIMedium &guiMedium);
|
---|
104 | /** Replases item on certain @a iPosition with new item based on @a guiMedium. */
|
---|
105 | void replaceItem(int iPosition, const UIMedium &guiMedium);
|
---|
106 |
|
---|
107 | /** Searches for a @a iIndex of medium with certain @a uId. */
|
---|
108 | bool findMediaIndex(const QUuid &uId, int &iIndex);
|
---|
109 |
|
---|
110 | /** Holds the media type. */
|
---|
111 | UIMediumDeviceType m_enmMediaType;
|
---|
112 |
|
---|
113 | /** Holds the machine ID. */
|
---|
114 | QUuid m_uMachineId;
|
---|
115 |
|
---|
116 | /** Simplified media description. */
|
---|
117 | struct Medium
|
---|
118 | {
|
---|
119 | Medium() {}
|
---|
120 | Medium(const QUuid &uId,
|
---|
121 | const QString &strLocation,
|
---|
122 | const QString &strToolTip)
|
---|
123 | : id(uId), location(strLocation), toolTip(strToolTip)
|
---|
124 | {}
|
---|
125 |
|
---|
126 | QUuid id;
|
---|
127 | QString location;
|
---|
128 | QString toolTip;
|
---|
129 | };
|
---|
130 | /** Vector of simplified media descriptions. */
|
---|
131 | typedef QVector<Medium> Media;
|
---|
132 |
|
---|
133 | /** Holds currently cached media descriptions. */
|
---|
134 | Media m_media;
|
---|
135 |
|
---|
136 | /** Holds the last chosen medium ID. */
|
---|
137 | QUuid m_uLastItemId;
|
---|
138 | };
|
---|
139 |
|
---|
140 | #endif /* !FEQT_INCLUDED_SRC_widgets_UIMediaComboBox_h */
|
---|