VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverter.h@ 82781

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

Fe/QT: scm header guard alignment.

  • 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.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/converter/UIConverter.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/converter/UIConverter.h91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverter.h91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/converter/UIConverter.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/converter/UIConverter.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/converter/UIConverter.h79645-79692
File size: 3.6 KB
Line 
1/* $Id: UIConverter.h 76581 2019-01-01 06:24:57Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIConverter declaration.
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#ifndef FEQT_INCLUDED_SRC_converter_UIConverter_h
19#define FEQT_INCLUDED_SRC_converter_UIConverter_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* GUI includes: */
25#include "UIConverterBackend.h"
26
27/** High-level interface for different conversions between GUI classes.
28 * @todo Replace singleton with static template interface. */
29class SHARED_LIBRARY_STUFF UIConverter
30{
31public:
32
33 /** Returns singleton instance. */
34 static UIConverter *instance() { return s_pInstance; }
35
36 /** Prepares everything. */
37 static void prepare();
38 /** Cleanups everything. */
39 static void cleanup();
40
41 /** Converts QColor <= template class. */
42 template<class T> QColor toColor(const T &data) const
43 {
44 if (canConvert<T>())
45 return ::toColor(data);
46 AssertFailed();
47 return QColor();
48 }
49
50 /** Converts QIcon <= template class. */
51 template<class T> QIcon toIcon(const T &data) const
52 {
53 if (canConvert<T>())
54 return ::toIcon(data);
55 AssertFailed();
56 return QIcon();
57 }
58 /** Converts QPixmap <= template class. */
59 template<class T> QPixmap toWarningPixmap(const T &data) const
60 {
61 if (canConvert<T>())
62 return ::toWarningPixmap(data);
63 AssertFailed();
64 return QPixmap();
65 }
66
67 /** Converts QString <= template class. */
68 template<class T> QString toString(const T &data) const
69 {
70 if (canConvert<T>())
71 return ::toString(data);
72 AssertFailed();
73 return QString();
74 }
75 /** Converts template class <= QString. */
76 template<class T> T fromString(const QString &strData) const
77 {
78 if (canConvert<T>())
79 return ::fromString<T>(strData);
80 AssertFailed();
81 return T();
82 }
83
84 /** Converts QString <= template class. */
85 template<class T> QString toInternalString(const T &data) const
86 {
87 if (canConvert<T>())
88 return ::toInternalString(data);
89 AssertFailed();
90 return QString();
91 }
92 /** Converts template class <= QString. */
93 template<class T> T fromInternalString(const QString &strData) const
94 {
95 if (canConvert<T>())
96 return ::fromInternalString<T>(strData);
97 AssertFailed();
98 return T();
99 }
100
101 /** Converts int <= template class. */
102 template<class T> int toInternalInteger(const T &data) const
103 {
104 if (canConvert<T>())
105 return ::toInternalInteger(data);
106 AssertFailed();
107 return 0;
108 }
109 /** Converts template class <= int. */
110 template<class T> T fromInternalInteger(const int &iData) const
111 {
112 if (canConvert<T>())
113 return ::fromInternalInteger<T>(iData);
114 AssertFailed();
115 return T();
116 }
117
118private:
119
120 /** Constructs converter. */
121 UIConverter() {}
122
123 /** Holds the static instance. */
124 static UIConverter *s_pInstance;
125};
126
127/** Singleton UI converter 'official' name. */
128#define gpConverter UIConverter::instance()
129
130#endif /* !FEQT_INCLUDED_SRC_converter_UIConverter_h */
131
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use