VirtualBox

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

Last change on this file was 103803, checked in by vboxsync, 2 months ago

FE/Qt. bugref:10618. Splitting COMEnums.h file into individual enum header files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h79224,​79228,​79233,​79235,​79258,​79262-79263,​79273,​79341,​79345,​79354,​79357,​79387-79388,​79559-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h79645-79692
File size: 6.1 KB
Line 
1/* $Id: UIMediumDefs.h 103803 2024-03-12 11:15:18Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMedium related declarations.
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_UIMediumDefs_h
29#define FEQT_INCLUDED_SRC_medium_UIMediumDefs_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QtGlobal>
36#include <QString>
37
38/* GUI includes: */
39#include "UILibraryDefs.h"
40
41/* COM includes: */
42#include "KDeviceType.h"
43#include "KStorageBus.h"
44
45/* Forward declarations: */
46class CVirtualBox;
47
48
49/** Medium formats. */
50enum UIMediumFormat
51{
52 UIMediumFormat_VDI,
53 UIMediumFormat_VMDK,
54 UIMediumFormat_VHD,
55 UIMediumFormat_Parallels,
56 UIMediumFormat_QED,
57 UIMediumFormat_QCOW,
58};
59
60/** UIMediumDefs namespace. */
61namespace UIMediumDefs
62{
63 /** UIMedium types. */
64 enum UIMediumDeviceType
65 {
66 UIMediumDeviceType_HardDisk,
67 UIMediumDeviceType_DVD,
68 UIMediumDeviceType_Floppy,
69 UIMediumDeviceType_All,
70 UIMediumDeviceType_Invalid
71 };
72
73 /** Converts global medium type (KDeviceType) to local (UIMediumDeviceType). */
74 SHARED_LIBRARY_STUFF UIMediumDeviceType mediumTypeToLocal(KDeviceType globalType);
75 /** Convert local medium type (UIMediumDeviceType) to global (KDeviceType). */
76 SHARED_LIBRARY_STUFF KDeviceType mediumTypeToGlobal(UIMediumDeviceType localType);
77
78 /** Returns medium formats which are currently supported by @a comVBox for the given @a enmDeviceType. */
79 QList<QPair<QString, QString> > MediumBackends(const CVirtualBox &comVBox, KDeviceType enmDeviceType);
80 /** Returns which hard disk formats are currently supported by @a comVBox. */
81 QList<QPair<QString, QString> > HDDBackends(const CVirtualBox &comVBox);
82 /** Returns which optical disk formats are currently supported by @a comVBox. */
83 QList<QPair<QString, QString> > DVDBackends(const CVirtualBox &comVBox);
84 /** Returns which floppy disk formats are currently supported by @a comVBox. */
85 QList<QPair<QString, QString> > FloppyBackends(const CVirtualBox &comVBox);
86
87 /** Returns the first file extension of the list of file extension support for the @a enmDeviceType. */
88 QString getPreferredExtensionForMedium(KDeviceType enmDeviceType);
89}
90/* Using this namespace globally: */
91using namespace UIMediumDefs;
92
93/** Medium-target. */
94struct UIMediumTarget
95{
96 /** Medium-target types. */
97 enum UIMediumTargetType
98 {
99 UIMediumTargetType_WithID,
100 UIMediumTargetType_WithLocation,
101 UIMediumTargetType_WithFileDialog,
102 UIMediumTargetType_CreateAdHocVISO,
103 UIMediumTargetType_CreateFloppyDisk
104 };
105
106 /** Medium-target constructor. */
107 UIMediumTarget(const QString &strName = QString(), qint32 iPort = 0, qint32 iDevice = 0,
108 UIMediumDeviceType aMediumType = UIMediumDeviceType_Invalid,
109 UIMediumTargetType aType = UIMediumTargetType_WithID, const QString &strData = QString())
110 : name(strName), port(iPort), device(iDevice)
111 , mediumType(aMediumType)
112 , type(aType), data(strData)
113 {}
114
115 /** Determines controller name. */
116 QString name;
117 /** Determines controller port. */
118 qint32 port;
119 /** Determines controller device. */
120 qint32 device;
121
122 /** Determines medium-target medium-type. */
123 UIMediumDeviceType mediumType;
124
125 /** Determines medium-target type. */
126 UIMediumTargetType type;
127 /** Depending on medium-target type holds <i>ID</i> or <i>location</i>. */
128 QString data;
129};
130
131/** Storage-slot struct. */
132struct StorageSlot
133{
134 StorageSlot() : bus(KStorageBus_Null), port(0), device(0) {}
135 StorageSlot(const StorageSlot &other) : bus(other.bus), port(other.port), device(other.device) {}
136 StorageSlot(KStorageBus otherBus, qint32 iPort, qint32 iDevice) : bus(otherBus), port(iPort), device(iDevice) {}
137 StorageSlot& operator=(const StorageSlot &other) { bus = other.bus; port = other.port; device = other.device; return *this; }
138 bool operator==(const StorageSlot &other) const { return bus == other.bus && port == other.port && device == other.device; }
139 bool operator!=(const StorageSlot &other) const { return bus != other.bus || port != other.port || device != other.device; }
140 bool operator<(const StorageSlot &other) const { return (bus < other.bus) ||
141 (bus == other.bus && port < other.port) ||
142 (bus == other.bus && port == other.port && device < other.device); }
143 bool operator>(const StorageSlot &other) const { return (bus > other.bus) ||
144 (bus == other.bus && port > other.port) ||
145 (bus == other.bus && port == other.port && device > other.device); }
146 bool isNull() const { return bus == KStorageBus_Null; }
147 KStorageBus bus; qint32 port; qint32 device;
148};
149
150/** Storage-slot struct extension with exact controller name. */
151struct ExactStorageSlot : public StorageSlot
152{
153 ExactStorageSlot(const QString &strController,
154 KStorageBus enmBus, qint32 iPort, qint32 iDevice)
155 : StorageSlot(enmBus, iPort, iDevice)
156 , controller(strController)
157 {}
158 QString controller;
159};
160
161/* Let QMetaType know about our types: */
162Q_DECLARE_METATYPE(UIMediumDeviceType);
163Q_DECLARE_METATYPE(UIMediumTarget);
164Q_DECLARE_METATYPE(StorageSlot);
165
166#endif /* !FEQT_INCLUDED_SRC_medium_UIMediumDefs_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use