VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediaComboBox.h

Last change on this file was 103546, checked in by vboxsync, 3 months ago

FE/Qt: UIMediaComboBox: Get rid of UICommon include in the header.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use