VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp@ 82781

Last change on this file since 82781 was 82694, checked in by vboxsync, 4 years ago

FE/Qt: bugref:8651: A bit of GUI related fixes for r135597.

  • 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/VBoxGlobal.cpp58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp79224,​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/converter/UIConverterBackendCOM.cpp79645-79692
File size: 39.7 KB
Line 
1/* $Id: UIConverterBackendCOM.cpp 82694 2020-01-09 13:28:59Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIConverterBackendCOM implementation.
4 */
5
6/*
7 * Copyright (C) 2012-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/* Qt includes: */
19#include <QApplication>
20#include <QHash>
21
22/* GUI includes: */
23#include "UIConverterBackend.h"
24#include "UIIconPool.h"
25
26/* COM includes: */
27#include "COMEnums.h"
28
29
30/* Determines if <Object of type X> can be converted to object of other type.
31 * These functions returns 'true' for all allowed conversions. */
32template<> bool canConvert<KMachineState>() { return true; }
33template<> bool canConvert<KSessionState>() { return true; }
34template<> bool canConvert<KParavirtProvider>() { return true; }
35template<> bool canConvert<KDeviceType>() { return true; }
36template<> bool canConvert<KClipboardMode>() { return true; }
37template<> bool canConvert<KDnDMode>() { return true; }
38template<> bool canConvert<KPointingHIDType>() { return true; }
39template<> bool canConvert<KGraphicsControllerType>() { return true; }
40template<> bool canConvert<KMediumType>() { return true; }
41template<> bool canConvert<KMediumVariant>() { return true; }
42template<> bool canConvert<KNetworkAttachmentType>() { return true; }
43template<> bool canConvert<KNetworkAdapterType>() { return true; }
44template<> bool canConvert<KNetworkAdapterPromiscModePolicy>() { return true; }
45template<> bool canConvert<KPortMode>() { return true; }
46template<> bool canConvert<KUSBControllerType>() { return true; }
47template<> bool canConvert<KUSBDeviceState>() { return true; }
48template<> bool canConvert<KUSBDeviceFilterAction>() { return true; }
49template<> bool canConvert<KAudioDriverType>() { return true; }
50template<> bool canConvert<KAudioControllerType>() { return true; }
51template<> bool canConvert<KAuthType>() { return true; }
52template<> bool canConvert<KStorageBus>() { return true; }
53template<> bool canConvert<KStorageControllerType>() { return true; }
54template<> bool canConvert<KChipsetType>() { return true; }
55template<> bool canConvert<KNATProtocol>() { return true; }
56
57/* QColor <= KMachineState: */
58template<> QColor toColor(const KMachineState &state)
59{
60 switch (state)
61 {
62 case KMachineState_PoweredOff: return QColor(Qt::gray);
63 case KMachineState_Saved: return QColor(Qt::yellow);
64 case KMachineState_Aborted: return QColor(Qt::darkRed);
65 case KMachineState_Teleported: return QColor(Qt::red);
66 case KMachineState_Running: return QColor(Qt::green);
67 case KMachineState_Paused: return QColor(Qt::darkGreen);
68 case KMachineState_Stuck: return QColor(Qt::darkMagenta);
69 case KMachineState_Teleporting: return QColor(Qt::blue);
70 case KMachineState_Snapshotting: return QColor(Qt::green);
71 case KMachineState_OnlineSnapshotting: return QColor(Qt::green);
72 case KMachineState_LiveSnapshotting: return QColor(Qt::green);
73 case KMachineState_Starting: return QColor(Qt::green);
74 case KMachineState_Stopping: return QColor(Qt::green);
75 case KMachineState_Saving: return QColor(Qt::green);
76 case KMachineState_Restoring: return QColor(Qt::green);
77 case KMachineState_TeleportingPausedVM: return QColor(Qt::blue);
78 case KMachineState_TeleportingIn: return QColor(Qt::blue);
79 case KMachineState_DeletingSnapshotOnline: return QColor(Qt::green);
80 case KMachineState_DeletingSnapshotPaused: return QColor(Qt::darkGreen);
81 case KMachineState_RestoringSnapshot: return QColor(Qt::green);
82 case KMachineState_DeletingSnapshot: return QColor(Qt::green);
83 case KMachineState_SettingUp: return QColor(Qt::green);
84 // case KMachineState_FirstOnline:
85 // case KMachineState_LastOnline:
86 // case KMachineState_FirstTransient:
87 // case KMachineState_LastTransient:
88 default: AssertMsgFailed(("No color for %d", state)); break;
89 }
90 return QColor();
91}
92
93/* QIcon <= KMachineState: */
94template<> QIcon toIcon(const KMachineState &state)
95{
96 switch (state)
97 {
98 case KMachineState_PoweredOff: return UIIconPool::iconSet(":/state_powered_off_16px.png");
99 case KMachineState_Saved: return UIIconPool::iconSet(":/state_saved_16px.png");
100 case KMachineState_Aborted: return UIIconPool::iconSet(":/state_aborted_16px.png");
101 case KMachineState_Teleported: return UIIconPool::iconSet(":/state_saved_16px.png");
102 case KMachineState_Running: return UIIconPool::iconSet(":/state_running_16px.png");
103 case KMachineState_Paused: return UIIconPool::iconSet(":/state_paused_16px.png");
104 case KMachineState_Stuck: return UIIconPool::iconSet(":/state_stuck_16px.png");
105 case KMachineState_Teleporting: return UIIconPool::iconSet(":/state_running_16px.png");
106 case KMachineState_Snapshotting: return UIIconPool::iconSet(":/state_saving_16px.png");
107 case KMachineState_OnlineSnapshotting: return UIIconPool::iconSet(":/state_running_16px.png");
108 case KMachineState_LiveSnapshotting: return UIIconPool::iconSet(":/state_running_16px.png");
109 case KMachineState_Starting: return UIIconPool::iconSet(":/state_running_16px.png");
110 case KMachineState_Stopping: return UIIconPool::iconSet(":/state_running_16px.png");
111 case KMachineState_Saving: return UIIconPool::iconSet(":/state_saving_16px.png");
112 case KMachineState_Restoring: return UIIconPool::iconSet(":/state_restoring_16px.png");
113 case KMachineState_TeleportingPausedVM: return UIIconPool::iconSet(":/state_saving_16px.png");
114 case KMachineState_TeleportingIn: return UIIconPool::iconSet(":/state_restoring_16px.png");
115 case KMachineState_DeletingSnapshotOnline: return UIIconPool::iconSet(":/state_discarding_16px.png");
116 case KMachineState_DeletingSnapshotPaused: return UIIconPool::iconSet(":/state_discarding_16px.png");
117 case KMachineState_RestoringSnapshot: return UIIconPool::iconSet(":/state_discarding_16px.png");
118 case KMachineState_DeletingSnapshot: return UIIconPool::iconSet(":/state_discarding_16px.png");
119 case KMachineState_SettingUp: return UIIconPool::iconSet(":/vm_settings_16px.png"); /// @todo Change icon!
120 // case KMachineState_FirstOnline:
121 // case KMachineState_LastOnline:
122 // case KMachineState_FirstTransient:
123 // case KMachineState_LastTransient:
124 default: AssertMsgFailed(("No icon for %d", state)); break;
125 }
126 return QIcon();
127}
128
129/* QString <= KMachineState: */
130template<> QString toString(const KMachineState &state)
131{
132 switch (state)
133 {
134 case KMachineState_PoweredOff: return QApplication::translate("UICommon", "Powered Off", "MachineState");
135 case KMachineState_Saved: return QApplication::translate("UICommon", "Saved", "MachineState");
136 case KMachineState_Aborted: return QApplication::translate("UICommon", "Aborted", "MachineState");
137 case KMachineState_Teleported: return QApplication::translate("UICommon", "Teleported", "MachineState");
138 case KMachineState_Running: return QApplication::translate("UICommon", "Running", "MachineState");
139 case KMachineState_Paused: return QApplication::translate("UICommon", "Paused", "MachineState");
140 case KMachineState_Stuck: return QApplication::translate("UICommon", "Guru Meditation", "MachineState");
141 case KMachineState_Teleporting: return QApplication::translate("UICommon", "Teleporting", "MachineState");
142 case KMachineState_Snapshotting: return QApplication::translate("UICommon", "Taking Snapshot", "MachineState");
143 case KMachineState_OnlineSnapshotting: return QApplication::translate("UICommon", "Taking Online Snapshot", "MachineState");
144 case KMachineState_LiveSnapshotting: return QApplication::translate("UICommon", "Taking Live Snapshot", "MachineState");
145 case KMachineState_Starting: return QApplication::translate("UICommon", "Starting", "MachineState");
146 case KMachineState_Stopping: return QApplication::translate("UICommon", "Stopping", "MachineState");
147 case KMachineState_Saving: return QApplication::translate("UICommon", "Saving", "MachineState");
148 case KMachineState_Restoring: return QApplication::translate("UICommon", "Restoring", "MachineState");
149 case KMachineState_TeleportingPausedVM: return QApplication::translate("UICommon", "Teleporting Paused VM", "MachineState");
150 case KMachineState_TeleportingIn: return QApplication::translate("UICommon", "Teleporting", "MachineState");
151 case KMachineState_DeletingSnapshotOnline: return QApplication::translate("UICommon", "Deleting Snapshot", "MachineState");
152 case KMachineState_DeletingSnapshotPaused: return QApplication::translate("UICommon", "Deleting Snapshot", "MachineState");
153 case KMachineState_RestoringSnapshot: return QApplication::translate("UICommon", "Restoring Snapshot", "MachineState");
154 case KMachineState_DeletingSnapshot: return QApplication::translate("UICommon", "Deleting Snapshot", "MachineState");
155 case KMachineState_SettingUp: return QApplication::translate("UICommon", "Setting Up", "MachineState");
156 // case KMachineState_FirstOnline:
157 // case KMachineState_LastOnline:
158 // case KMachineState_FirstTransient:
159 // case KMachineState_LastTransient:
160 default: AssertMsgFailed(("No text for %d", state)); break;
161 }
162 return QString();
163}
164
165/* QString <= KSessionState: */
166template<> QString toString(const KSessionState &state)
167{
168 switch (state)
169 {
170 case KSessionState_Unlocked: return QApplication::translate("UICommon", "Unlocked", "SessionState");
171 case KSessionState_Locked: return QApplication::translate("UICommon", "Locked", "SessionState");
172 case KSessionState_Spawning: return QApplication::translate("UICommon", "Spawning", "SessionState");
173 case KSessionState_Unlocking: return QApplication::translate("UICommon", "Unlocking", "SessionState");
174 default: AssertMsgFailed(("No text for %d", state)); break;
175 }
176 return QString();
177}
178
179/* QString <= KParavirtProvider: */
180template<> QString toString(const KParavirtProvider &type)
181{
182 switch (type)
183 {
184 case KParavirtProvider_None: return QApplication::translate("UICommon", "None", "ParavirtProvider");
185 case KParavirtProvider_Default: return QApplication::translate("UICommon", "Default", "ParavirtProvider");
186 case KParavirtProvider_Legacy: return QApplication::translate("UICommon", "Legacy", "ParavirtProvider");
187 case KParavirtProvider_Minimal: return QApplication::translate("UICommon", "Minimal", "ParavirtProvider");
188 case KParavirtProvider_HyperV: return QApplication::translate("UICommon", "Hyper-V", "ParavirtProvider");
189 case KParavirtProvider_KVM: return QApplication::translate("UICommon", "KVM", "ParavirtProvider");
190 default: AssertMsgFailed(("No text for %d", type)); break;
191 }
192 return QString();
193}
194
195/* QString <= KDeviceType: */
196template<> QString toString(const KDeviceType &type)
197{
198 switch (type)
199 {
200 case KDeviceType_Null: return QApplication::translate("UICommon", "None", "DeviceType");
201 case KDeviceType_Floppy: return QApplication::translate("UICommon", "Floppy", "DeviceType");
202 case KDeviceType_DVD: return QApplication::translate("UICommon", "Optical", "DeviceType");
203 case KDeviceType_HardDisk: return QApplication::translate("UICommon", "Hard Disk", "DeviceType");
204 case KDeviceType_Network: return QApplication::translate("UICommon", "Network", "DeviceType");
205 case KDeviceType_USB: return QApplication::translate("UICommon", "USB", "DeviceType");
206 case KDeviceType_SharedFolder: return QApplication::translate("UICommon", "Shared Folder", "DeviceType");
207 default: AssertMsgFailed(("No text for %d", type)); break;
208 }
209 return QString();
210}
211
212/* QString <= KClipboardMode: */
213template<> QString toString(const KClipboardMode &mode)
214{
215 switch (mode)
216 {
217 case KClipboardMode_Disabled: return QApplication::translate("UICommon", "Disabled", "ClipboardType");
218 case KClipboardMode_HostToGuest: return QApplication::translate("UICommon", "Host To Guest", "ClipboardType");
219 case KClipboardMode_GuestToHost: return QApplication::translate("UICommon", "Guest To Host", "ClipboardType");
220 case KClipboardMode_Bidirectional: return QApplication::translate("UICommon", "Bidirectional", "ClipboardType");
221 default: AssertMsgFailed(("No text for %d", mode)); break;
222 }
223 return QString();
224}
225
226/* QString <= KDnDMode: */
227template<> QString toString(const KDnDMode &mode)
228{
229 switch (mode)
230 {
231 case KDnDMode_Disabled: return QApplication::translate("UICommon", "Disabled", "DragAndDropType");
232 case KDnDMode_HostToGuest: return QApplication::translate("UICommon", "Host To Guest", "DragAndDropType");
233 case KDnDMode_GuestToHost: return QApplication::translate("UICommon", "Guest To Host", "DragAndDropType");
234 case KDnDMode_Bidirectional: return QApplication::translate("UICommon", "Bidirectional", "DragAndDropType");
235 default: AssertMsgFailed(("No text for %d", mode)); break;
236 }
237 return QString();
238}
239
240/* QString <= KPointingHIDType: */
241template<> QString toString(const KPointingHIDType &type)
242{
243 switch (type)
244 {
245 case KPointingHIDType_PS2Mouse: return QApplication::translate("UICommon", "PS/2 Mouse", "PointingHIDType");
246 case KPointingHIDType_USBMouse: return QApplication::translate("UICommon", "USB Mouse", "PointingHIDType");
247 case KPointingHIDType_USBTablet: return QApplication::translate("UICommon", "USB Tablet", "PointingHIDType");
248 case KPointingHIDType_ComboMouse: return QApplication::translate("UICommon", "PS/2 and USB Mouse", "PointingHIDType");
249 case KPointingHIDType_USBMultiTouch: return QApplication::translate("UICommon", "USB Multi-Touch Tablet", "PointingHIDType");
250 default: AssertMsgFailed(("No text for %d", type)); break;
251 }
252 return QString();
253}
254
255/* QString <= KGraphicsControllerType: */
256template<> QString toString(const KGraphicsControllerType &type)
257{
258 switch (type)
259 {
260 case KGraphicsControllerType_Null: return QApplication::translate("UICommon", "None", "GraphicsControllerType");
261 case KGraphicsControllerType_VBoxVGA: return QApplication::translate("UICommon", "VBoxVGA", "GraphicsControllerType");
262 case KGraphicsControllerType_VMSVGA: return QApplication::translate("UICommon", "VMSVGA", "GraphicsControllerType");
263 case KGraphicsControllerType_VBoxSVGA: return QApplication::translate("UICommon", "VBoxSVGA", "GraphicsControllerType");
264 default: AssertMsgFailed(("No text for %d", type)); break;
265 }
266 return QString();
267}
268
269/* KGraphicsControllerType <= QString: */
270template<> KGraphicsControllerType fromString<KGraphicsControllerType>(const QString &strType)
271{
272 QHash<QString, KGraphicsControllerType> list;
273 list.insert(QApplication::translate("UICommon", "None", "GraphicsControllerType"), KGraphicsControllerType_Null);
274 list.insert(QApplication::translate("UICommon", "VBoxVGA", "GraphicsControllerType"), KGraphicsControllerType_VBoxVGA);
275 list.insert(QApplication::translate("UICommon", "VMSVGA", "GraphicsControllerType"), KGraphicsControllerType_VMSVGA);
276 list.insert(QApplication::translate("UICommon", "VBoxSVGA", "GraphicsControllerType"), KGraphicsControllerType_VBoxSVGA);
277 if (!list.contains(strType))
278 {
279 AssertMsgFailed(("No value for '%s'", strType.toUtf8().constData()));
280 }
281 return list.value(strType, KGraphicsControllerType_Null);
282}
283
284/* QString <= KMediumType: */
285template<> QString toString(const KMediumType &type)
286{
287 switch (type)
288 {
289 case KMediumType_Normal: return QApplication::translate("UICommon", "Normal", "MediumType");
290 case KMediumType_Immutable: return QApplication::translate("UICommon", "Immutable", "MediumType");
291 case KMediumType_Writethrough: return QApplication::translate("UICommon", "Writethrough", "MediumType");
292 case KMediumType_Shareable: return QApplication::translate("UICommon", "Shareable", "MediumType");
293 case KMediumType_Readonly: return QApplication::translate("UICommon", "Readonly", "MediumType");
294 case KMediumType_MultiAttach: return QApplication::translate("UICommon", "Multi-attach", "MediumType");
295 default: AssertMsgFailed(("No text for %d", type)); break;
296 }
297 return QString();
298}
299
300/* QString <= KMediumVariant: */
301template<> QString toString(const KMediumVariant &variant)
302{
303 /* Note: KMediumVariant_Diff and KMediumVariant_Fixed are so far mutually exclusive: */
304 switch ((int)variant)
305 {
306 case KMediumVariant_Standard:
307 return QApplication::translate("UICommon", "Dynamically allocated storage", "MediumVariant");
308 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_VdiZeroExpand):
309 return QApplication::translate("UICommon", "New dynamically allocated storage", "MediumVariant");
310 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_Diff):
311 return QApplication::translate("UICommon", "Dynamically allocated differencing storage", "MediumVariant");
312 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_Fixed):
313 return QApplication::translate("UICommon", "Fixed size storage", "MediumVariant");
314 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_VmdkSplit2G):
315 return QApplication::translate("UICommon", "Dynamically allocated storage split into files of less than 2GB", "MediumVariant");
316 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_VmdkSplit2G | KMediumVariant_Diff):
317 return QApplication::translate("UICommon", "Dynamically allocated differencing storage split into files of less than 2GB", "MediumVariant");
318 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_Fixed | KMediumVariant_VmdkSplit2G):
319 return QApplication::translate("UICommon", "Fixed size storage split into files of less than 2GB", "MediumVariant");
320 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_VmdkStreamOptimized):
321 return QApplication::translate("UICommon", "Dynamically allocated compressed storage", "MediumVariant");
322 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_VmdkStreamOptimized | KMediumVariant_Diff):
323 return QApplication::translate("UICommon", "Dynamically allocated differencing compressed storage", "MediumVariant");
324 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_Fixed | KMediumVariant_VmdkESX):
325 return QApplication::translate("UICommon", "Fixed size ESX storage", "MediumVariant");
326 case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_Fixed | KMediumVariant_VmdkRawDisk):
327 return QApplication::translate("UICommon", "Fixed size storage on raw disk", "MediumVariant");
328 default:
329 AssertMsgFailed(("No text for %d", variant)); break;
330 }
331 return QString();
332}
333
334/* QString <= KNetworkAttachmentType: */
335template<> QString toString(const KNetworkAttachmentType &type)
336{
337 switch (type)
338 {
339 case KNetworkAttachmentType_Null: return QApplication::translate("UICommon", "Not attached", "NetworkAttachmentType");
340 case KNetworkAttachmentType_NAT: return QApplication::translate("UICommon", "NAT", "NetworkAttachmentType");
341 case KNetworkAttachmentType_Bridged: return QApplication::translate("UICommon", "Bridged Adapter", "NetworkAttachmentType");
342 case KNetworkAttachmentType_Internal: return QApplication::translate("UICommon", "Internal Network", "NetworkAttachmentType");
343 case KNetworkAttachmentType_HostOnly: return QApplication::translate("UICommon", "Host-only Adapter", "NetworkAttachmentType");
344 case KNetworkAttachmentType_Generic: return QApplication::translate("UICommon", "Generic Driver", "NetworkAttachmentType");
345 case KNetworkAttachmentType_NATNetwork: return QApplication::translate("UICommon", "NAT Network", "NetworkAttachmentType");
346#ifdef VBOX_WITH_CLOUD_NET
347 case KNetworkAttachmentType_Cloud: return QApplication::translate("UICommon", "Cloud Network", "NetworkAttachmentType");
348#endif /* VBOX_WITH_CLOUD_NET */
349 default: AssertMsgFailed(("No text for %d", type)); break;
350 }
351 return QString();
352}
353
354/* QString <= KNetworkAdapterType: */
355template<> QString toString(const KNetworkAdapterType &type)
356{
357 switch (type)
358 {
359 case KNetworkAdapterType_Am79C970A: return QApplication::translate("UICommon", "PCnet-PCI II (Am79C970A)", "NetworkAdapterType");
360 case KNetworkAdapterType_Am79C973: return QApplication::translate("UICommon", "PCnet-FAST III (Am79C973)", "NetworkAdapterType");
361 case KNetworkAdapterType_I82540EM: return QApplication::translate("UICommon", "Intel PRO/1000 MT Desktop (82540EM)", "NetworkAdapterType");
362 case KNetworkAdapterType_I82543GC: return QApplication::translate("UICommon", "Intel PRO/1000 T Server (82543GC)", "NetworkAdapterType");
363 case KNetworkAdapterType_I82545EM: return QApplication::translate("UICommon", "Intel PRO/1000 MT Server (82545EM)", "NetworkAdapterType");
364#ifdef VBOX_WITH_VIRTIO
365 case KNetworkAdapterType_Virtio: return QApplication::translate("UICommon", "Paravirtualized Network (virtio-net)", "NetworkAdapterType");
366#endif /* VBOX_WITH_VIRTIO */
367 case KNetworkAdapterType_Virtio_1_0: return QApplication::translate("UICommon", "Paravirtualized Network (virtio-net 1.0)", "NetworkAdapterType");
368 case KNetworkAdapterType_Am79C960: return QApplication::translate("UICommon", "PCnet-ISA (Am79C960)", "NetworkAdapterType");
369 default: AssertMsgFailed(("No text for %d", type)); break;
370 }
371 return QString();
372}
373
374/* QString <= KNetworkAdapterPromiscModePolicy: */
375template<> QString toString(const KNetworkAdapterPromiscModePolicy &policy)
376{
377 switch (policy)
378 {
379 case KNetworkAdapterPromiscModePolicy_Deny:
380 return QApplication::translate("UICommon", "Deny", "NetworkAdapterPromiscModePolicy");
381 case KNetworkAdapterPromiscModePolicy_AllowNetwork:
382 return QApplication::translate("UICommon", "Allow VMs", "NetworkAdapterPromiscModePolicy");
383 case KNetworkAdapterPromiscModePolicy_AllowAll:
384 return QApplication::translate("UICommon", "Allow All", "NetworkAdapterPromiscModePolicy");
385 default:
386 AssertMsgFailed(("No text for %d", policy)); break;
387 }
388 return QString();
389}
390
391/* QString <= KPortMode: */
392template<> QString toString(const KPortMode &mode)
393{
394 switch (mode)
395 {
396 case KPortMode_Disconnected: return QApplication::translate("UICommon", "Disconnected", "PortMode");
397 case KPortMode_HostPipe: return QApplication::translate("UICommon", "Host Pipe", "PortMode");
398 case KPortMode_HostDevice: return QApplication::translate("UICommon", "Host Device", "PortMode");
399 case KPortMode_RawFile: return QApplication::translate("UICommon", "Raw File", "PortMode");
400 case KPortMode_TCP: return QApplication::translate("UICommon", "TCP", "PortMode");
401 default: AssertMsgFailed(("No text for %d", mode)); break;
402 }
403 return QString();
404}
405
406/* KPortMode <= QString: */
407template<> KPortMode fromString<KPortMode>(const QString &strMode)
408{
409 QHash<QString, KPortMode> list;
410 list.insert(QApplication::translate("UICommon", "Disconnected", "PortMode"), KPortMode_Disconnected);
411 list.insert(QApplication::translate("UICommon", "Host Pipe", "PortMode"), KPortMode_HostPipe);
412 list.insert(QApplication::translate("UICommon", "Host Device", "PortMode"), KPortMode_HostDevice);
413 list.insert(QApplication::translate("UICommon", "Raw File", "PortMode"), KPortMode_RawFile);
414 list.insert(QApplication::translate("UICommon", "TCP", "PortMode"), KPortMode_TCP);
415 if (!list.contains(strMode))
416 {
417 AssertMsgFailed(("No value for '%s'", strMode.toUtf8().constData()));
418 }
419 return list.value(strMode, KPortMode_Disconnected);
420}
421
422/* QString <= KUSBControllerType: */
423template<> QString toString(const KUSBControllerType &type)
424{
425 switch (type)
426 {
427 case KUSBControllerType_OHCI: return QApplication::translate("UICommon", "OHCI", "USBControllerType");
428 case KUSBControllerType_EHCI: return QApplication::translate("UICommon", "EHCI", "USBControllerType");
429 case KUSBControllerType_XHCI: return QApplication::translate("UICommon", "xHCI", "USBControllerType");
430 default: AssertMsgFailed(("No text for %d", type)); break;
431 }
432 return QString();
433}
434
435/* QString <= KUSBDeviceState: */
436template<> QString toString(const KUSBDeviceState &state)
437{
438 switch (state)
439 {
440 case KUSBDeviceState_NotSupported: return QApplication::translate("UICommon", "Not supported", "USBDeviceState");
441 case KUSBDeviceState_Unavailable: return QApplication::translate("UICommon", "Unavailable", "USBDeviceState");
442 case KUSBDeviceState_Busy: return QApplication::translate("UICommon", "Busy", "USBDeviceState");
443 case KUSBDeviceState_Available: return QApplication::translate("UICommon", "Available", "USBDeviceState");
444 case KUSBDeviceState_Held: return QApplication::translate("UICommon", "Held", "USBDeviceState");
445 case KUSBDeviceState_Captured: return QApplication::translate("UICommon", "Captured", "USBDeviceState");
446 default: AssertMsgFailed(("No text for %d", state)); break;
447 }
448 return QString();
449}
450
451/* QString <= KUSBDeviceFilterAction: */
452template<> QString toString(const KUSBDeviceFilterAction &action)
453{
454 switch (action)
455 {
456 case KUSBDeviceFilterAction_Ignore: return QApplication::translate("UICommon", "Ignore", "USBDeviceFilterAction");
457 case KUSBDeviceFilterAction_Hold: return QApplication::translate("UICommon", "Hold", "USBDeviceFilterAction");
458 default: AssertMsgFailed(("No text for %d", action)); break;
459 }
460 return QString();
461}
462
463/* KUSBDeviceFilterAction <= QString: */
464template<> KUSBDeviceFilterAction fromString<KUSBDeviceFilterAction>(const QString &strAction)
465{
466 QHash<QString, KUSBDeviceFilterAction> list;
467 list.insert(QApplication::translate("UICommon", "Ignore", "USBDeviceFilterAction"), KUSBDeviceFilterAction_Ignore);
468 list.insert(QApplication::translate("UICommon", "Hold", "USBDeviceFilterAction"), KUSBDeviceFilterAction_Hold);
469 if (!list.contains(strAction))
470 {
471 AssertMsgFailed(("No value for '%s'", strAction.toUtf8().constData()));
472 }
473 return list.value(strAction, KUSBDeviceFilterAction_Null);
474}
475
476/* QString <= KAudioDriverType: */
477template<> QString toString(const KAudioDriverType &type)
478{
479 switch (type)
480 {
481 case KAudioDriverType_Null: return QApplication::translate("UICommon", "Null Audio Driver", "AudioDriverType");
482 case KAudioDriverType_WinMM: return QApplication::translate("UICommon", "Windows Multimedia", "AudioDriverType");
483 case KAudioDriverType_OSS: return QApplication::translate("UICommon", "OSS Audio Driver", "AudioDriverType");
484 case KAudioDriverType_ALSA: return QApplication::translate("UICommon", "ALSA Audio Driver", "AudioDriverType");
485 case KAudioDriverType_DirectSound: return QApplication::translate("UICommon", "Windows DirectSound", "AudioDriverType");
486 case KAudioDriverType_CoreAudio: return QApplication::translate("UICommon", "CoreAudio", "AudioDriverType");
487 // case KAudioDriverType_MMPM:
488 case KAudioDriverType_Pulse: return QApplication::translate("UICommon", "PulseAudio", "AudioDriverType");
489 case KAudioDriverType_SolAudio: return QApplication::translate("UICommon", "Solaris Audio", "AudioDriverType");
490 default: AssertMsgFailed(("No text for %d", type)); break;
491 }
492 return QString();
493}
494
495/* KAudioDriverType <= QString: */
496template<> KAudioDriverType fromString<KAudioDriverType>(const QString &strType)
497{
498 QHash<QString, KAudioDriverType> list;
499 list.insert(QApplication::translate("UICommon", "Null Audio Driver", "AudioDriverType"), KAudioDriverType_Null);
500 list.insert(QApplication::translate("UICommon", "Windows Multimedia", "AudioDriverType"), KAudioDriverType_WinMM);
501 list.insert(QApplication::translate("UICommon", "OSS Audio Driver", "AudioDriverType"), KAudioDriverType_OSS);
502 list.insert(QApplication::translate("UICommon", "ALSA Audio Driver", "AudioDriverType"), KAudioDriverType_ALSA);
503 list.insert(QApplication::translate("UICommon", "Windows DirectSound", "AudioDriverType"), KAudioDriverType_DirectSound);
504 list.insert(QApplication::translate("UICommon", "CoreAudio", "AudioDriverType"), KAudioDriverType_CoreAudio);
505 // list.insert(..., KAudioDriverType_MMPM);
506 list.insert(QApplication::translate("UICommon", "PulseAudio", "AudioDriverType"), KAudioDriverType_Pulse);
507 list.insert(QApplication::translate("UICommon", "Solaris Audio", "AudioDriverType"), KAudioDriverType_SolAudio);
508 if (!list.contains(strType))
509 {
510 AssertMsgFailed(("No value for '%s'", strType.toUtf8().constData()));
511 }
512 return list.value(strType, KAudioDriverType_Null);
513}
514
515/* QString <= KAudioControllerType: */
516template<> QString toString(const KAudioControllerType &type)
517{
518 switch (type)
519 {
520 case KAudioControllerType_AC97: return QApplication::translate("UICommon", "ICH AC97", "AudioControllerType");
521 case KAudioControllerType_SB16: return QApplication::translate("UICommon", "SoundBlaster 16", "AudioControllerType");
522 case KAudioControllerType_HDA: return QApplication::translate("UICommon", "Intel HD Audio", "AudioControllerType");
523 default: AssertMsgFailed(("No text for %d", type)); break;
524 }
525 return QString();
526}
527
528/* KAudioControllerType <= QString: */
529template<> KAudioControllerType fromString<KAudioControllerType>(const QString &strType)
530{
531 QHash<QString, KAudioControllerType> list;
532 list.insert(QApplication::translate("UICommon", "ICH AC97", "AudioControllerType"), KAudioControllerType_AC97);
533 list.insert(QApplication::translate("UICommon", "SoundBlaster 16", "AudioControllerType"), KAudioControllerType_SB16);
534 list.insert(QApplication::translate("UICommon", "Intel HD Audio", "AudioControllerType"), KAudioControllerType_HDA);
535 if (!list.contains(strType))
536 {
537 AssertMsgFailed(("No value for '%s'", strType.toUtf8().constData()));
538 }
539 return list.value(strType, KAudioControllerType_AC97);
540}
541
542/* QString <= KAuthType: */
543template<> QString toString(const KAuthType &type)
544{
545 switch (type)
546 {
547 case KAuthType_Null: return QApplication::translate("UICommon", "Null", "AuthType");
548 case KAuthType_External: return QApplication::translate("UICommon", "External", "AuthType");
549 case KAuthType_Guest: return QApplication::translate("UICommon", "Guest", "AuthType");
550 default: AssertMsgFailed(("No text for %d", type)); break;
551 }
552 return QString();
553}
554
555/* KAuthType <= QString: */
556template<> KAuthType fromString<KAuthType>(const QString &strType)
557{
558 QHash<QString, KAuthType> list;
559 list.insert(QApplication::translate("UICommon", "Null", "AuthType"), KAuthType_Null);
560 list.insert(QApplication::translate("UICommon", "External", "AuthType"), KAuthType_External);
561 list.insert(QApplication::translate("UICommon", "Guest", "AuthType"), KAuthType_Guest);
562 if (!list.contains(strType))
563 {
564 AssertMsgFailed(("No value for '%s'", strType.toUtf8().constData()));
565 }
566 return list.value(strType, KAuthType_Null);
567}
568
569/* QString <= KStorageBus: */
570template<> QString toString(const KStorageBus &bus)
571{
572 switch (bus)
573 {
574 case KStorageBus_IDE: return QApplication::translate("UICommon", "IDE", "StorageBus");
575 case KStorageBus_SATA: return QApplication::translate("UICommon", "SATA", "StorageBus");
576 case KStorageBus_SCSI: return QApplication::translate("UICommon", "SCSI", "StorageBus");
577 case KStorageBus_Floppy: return QApplication::translate("UICommon", "Floppy", "StorageBus");
578 case KStorageBus_SAS: return QApplication::translate("UICommon", "SAS", "StorageBus");
579 case KStorageBus_USB: return QApplication::translate("UICommon", "USB", "StorageBus");
580 case KStorageBus_PCIe: return QApplication::translate("UICommon", "PCIe", "StorageBus");
581 case KStorageBus_VirtioSCSI: return QApplication::translate("UICommon", "virtio-scsi", "StorageBus");
582 default: AssertMsgFailed(("No text for %d", bus)); break;
583 }
584 return QString();
585}
586
587/* KStorageBus <= QString: */
588template<> KStorageBus fromString<KStorageBus>(const QString &strType)
589{
590 QHash<QString, KStorageBus> list;
591 list.insert(QApplication::translate("UICommon", "IDE", "StorageBus"), KStorageBus_IDE);
592 list.insert(QApplication::translate("UICommon", "SATA", "StorageBus"), KStorageBus_SATA);
593 list.insert(QApplication::translate("UICommon", "SCSI", "StorageBus"), KStorageBus_SCSI);
594 list.insert(QApplication::translate("UICommon", "Floppy", "StorageBus"), KStorageBus_Floppy);
595 list.insert(QApplication::translate("UICommon", "SAS", "StorageBus"), KStorageBus_SAS);
596 list.insert(QApplication::translate("UICommon", "USB", "StorageBus"), KStorageBus_USB);
597 list.insert(QApplication::translate("UICommon", "PCIe", "StorageBus"), KStorageBus_PCIe);
598 list.insert(QApplication::translate("UICommon", "virtio-scsi", "StorageBus"), KStorageBus_VirtioSCSI);
599 if (!list.contains(strType))
600 {
601 AssertMsgFailed(("No value for '%s'", strType.toUtf8().constData()));
602 }
603 return list.value(strType, KStorageBus_Null);
604}
605
606/* QString <= KStorageControllerType: */
607template<> QString toString(const KStorageControllerType &type)
608{
609 switch (type)
610 {
611 case KStorageControllerType_LsiLogic: return QApplication::translate("UICommon", "LsiLogic", "StorageControllerType");
612 case KStorageControllerType_BusLogic: return QApplication::translate("UICommon", "BusLogic", "StorageControllerType");
613 case KStorageControllerType_IntelAhci: return QApplication::translate("UICommon", "AHCI", "StorageControllerType");
614 case KStorageControllerType_PIIX3: return QApplication::translate("UICommon", "PIIX3", "StorageControllerType");
615 case KStorageControllerType_PIIX4: return QApplication::translate("UICommon", "PIIX4", "StorageControllerType");
616 case KStorageControllerType_ICH6: return QApplication::translate("UICommon", "ICH6", "StorageControllerType");
617 case KStorageControllerType_I82078: return QApplication::translate("UICommon", "I82078", "StorageControllerType");
618 case KStorageControllerType_LsiLogicSas: return QApplication::translate("UICommon", "LsiLogic SAS", "StorageControllerType");
619 case KStorageControllerType_USB: return QApplication::translate("UICommon", "USB", "StorageControllerType");
620 case KStorageControllerType_NVMe: return QApplication::translate("UICommon", "NVMe", "StorageControllerType");
621 case KStorageControllerType_VirtioSCSI: return QApplication::translate("UICommon", "virtio-scsi", "StorageControllerType");
622 default: AssertMsgFailed(("No text for %d", type)); break;
623 }
624 return QString();
625}
626
627/* KStorageControllerType <= QString: */
628template<> KStorageControllerType fromString<KStorageControllerType>(const QString &strType)
629{
630 QHash<QString, KStorageControllerType> list;
631 list.insert(QApplication::translate("UICommon", "LsiLogic", "StorageControllerType"), KStorageControllerType_LsiLogic);
632 list.insert(QApplication::translate("UICommon", "BusLogic", "StorageControllerType"), KStorageControllerType_BusLogic);
633 list.insert(QApplication::translate("UICommon", "AHCI", "StorageControllerType"), KStorageControllerType_IntelAhci);
634 list.insert(QApplication::translate("UICommon", "PIIX3", "StorageControllerType"), KStorageControllerType_PIIX3);
635 list.insert(QApplication::translate("UICommon", "PIIX4", "StorageControllerType"), KStorageControllerType_PIIX4);
636 list.insert(QApplication::translate("UICommon", "ICH6", "StorageControllerType"), KStorageControllerType_ICH6);
637 list.insert(QApplication::translate("UICommon", "I82078", "StorageControllerType"), KStorageControllerType_I82078);
638 list.insert(QApplication::translate("UICommon", "LsiLogic SAS", "StorageControllerType"), KStorageControllerType_LsiLogicSas);
639 list.insert(QApplication::translate("UICommon", "USB", "StorageControllerType"), KStorageControllerType_USB);
640 list.insert(QApplication::translate("UICommon", "NVMe", "StorageControllerType"), KStorageControllerType_NVMe);
641 list.insert(QApplication::translate("UICommon", "virtio-scsi", "StorageControllerType"), KStorageControllerType_VirtioSCSI);
642 if (!list.contains(strType))
643 {
644 AssertMsgFailed(("No value for '%s'", strType.toUtf8().constData()));
645 }
646 return list.value(strType, KStorageControllerType_Null);
647}
648
649/* QString <= KChipsetType: */
650template<> QString toString(const KChipsetType &type)
651{
652 switch (type)
653 {
654 case KChipsetType_PIIX3: return QApplication::translate("UICommon", "PIIX3", "ChipsetType");
655 case KChipsetType_ICH9: return QApplication::translate("UICommon", "ICH9", "ChipsetType");
656 default: AssertMsgFailed(("No text for %d", type)); break;
657 }
658 return QString();
659}
660
661/* QString <= KNATProtocol: */
662template<> QString toString(const KNATProtocol &protocol)
663{
664 switch (protocol)
665 {
666 case KNATProtocol_UDP: return QApplication::translate("UICommon", "UDP", "NATProtocol");
667 case KNATProtocol_TCP: return QApplication::translate("UICommon", "TCP", "NATProtocol");
668 default: AssertMsgFailed(("No text for %d", protocol)); break;
669 }
670 return QString();
671}
672
673/* QString <= KNATProtocol: */
674template<> QString toInternalString(const KNATProtocol &protocol)
675{
676 QString strResult;
677 switch (protocol)
678 {
679 case KNATProtocol_UDP: strResult = "udp"; break;
680 case KNATProtocol_TCP: strResult = "tcp"; break;
681 default: AssertMsgFailed(("No text for protocol type=%d", protocol)); break;
682 }
683 return strResult;
684}
685
686/* KNATProtocol <= QString: */
687template<> KNATProtocol fromInternalString<KNATProtocol>(const QString &strProtocol)
688{
689 /* Here we have some fancy stuff allowing us
690 * to search through the keys using 'case-insensitive' rule: */
691 QStringList keys; QList<KNATProtocol> values;
692 keys << "udp"; values << KNATProtocol_UDP;
693 keys << "tcp"; values << KNATProtocol_TCP;
694 /* Invalid type for unknown words: */
695 if (!keys.contains(strProtocol, Qt::CaseInsensitive))
696 {
697 AssertMsgFailed(("No value for '%s'", strProtocol.toUtf8().constData()));
698 return KNATProtocol_UDP;
699 }
700 /* Corresponding type for known words: */
701 return values.at(keys.indexOf(QRegExp(strProtocol, Qt::CaseInsensitive)));
702}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use