VirtualBox

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

Last change on this file since 76553 was 76553, checked in by vboxsync, 5 years ago

scm --update-copyright-year

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

© 2023 Oracle
ContactPrivacy policyTerms of Use