Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qwidgetsvariant.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||
25 | ** | - | ||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||
29 | ** | - | ||||||
30 | ** $QT_END_LICENSE$ | - | ||||||
31 | ** | - | ||||||
32 | ****************************************************************************/ | - | ||||||
33 | - | |||||||
34 | #include "qvariant.h" | - | ||||||
35 | - | |||||||
36 | #include "qsizepolicy.h" | - | ||||||
37 | #include "qwidget.h" | - | ||||||
38 | - | |||||||
39 | #include "private/qvariant_p.h" | - | ||||||
40 | #include <private/qmetatype_p.h> | - | ||||||
41 | - | |||||||
42 | QT_BEGIN_NAMESPACE | - | ||||||
43 | - | |||||||
44 | namespace { | - | ||||||
45 | static void construct(QVariant::Private *x, const void *copy) | - | ||||||
46 | { | - | ||||||
47 | switch (x->type) { | - | ||||||
48 | case QVariant::SizePolicy: never executed: case QVariant::SizePolicy: | 0 | ||||||
49 | v_construct<QSizePolicy>(x, copy); | - | ||||||
50 | break; never executed: break; | 0 | ||||||
51 | default: never executed: default: | 0 | ||||||
52 | qWarning("Trying to construct an instance of an invalid type, type id: %i", x->type); | - | ||||||
53 | x->type = QVariant::Invalid; | - | ||||||
54 | return; never executed: return; | 0 | ||||||
55 | } | - | ||||||
56 | x->is_null = !copy; | - | ||||||
57 | } never executed: end of block | 0 | ||||||
58 | - | |||||||
59 | static void clear(QVariant::Private *d) | - | ||||||
60 | { | - | ||||||
61 | switch (d->type) { | - | ||||||
62 | case QVariant::SizePolicy: never executed: case QVariant::SizePolicy: | 0 | ||||||
63 | v_clear<QSizePolicy>(d); | - | ||||||
64 | break; never executed: break; | 0 | ||||||
65 | default: never executed: default: | 0 | ||||||
66 | Q_ASSERT(false); | - | ||||||
67 | return; never executed: return; | 0 | ||||||
68 | } | - | ||||||
69 | - | |||||||
70 | d->type = QVariant::Invalid; | - | ||||||
71 | d->is_null = true; | - | ||||||
72 | d->is_shared = false; | - | ||||||
73 | } never executed: end of block | 0 | ||||||
74 | - | |||||||
75 | - | |||||||
76 | static bool isNull(const QVariant::Private *) | - | ||||||
77 | { | - | ||||||
78 | return false; never executed: return false; | 0 | ||||||
79 | } | - | ||||||
80 | - | |||||||
81 | static bool compare(const QVariant::Private *a, const QVariant::Private *b) | - | ||||||
82 | { | - | ||||||
83 | Q_ASSERT(a->type == b->type); | - | ||||||
84 | switch(a->type) { | - | ||||||
85 | case QVariant::SizePolicy: never executed: case QVariant::SizePolicy: | 0 | ||||||
86 | return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b); never executed: return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b); | 0 | ||||||
87 | default: never executed: default: | 0 | ||||||
88 | Q_ASSERT(false); | - | ||||||
89 | } never executed: end of block | 0 | ||||||
90 | return false; never executed: return false; | 0 | ||||||
91 | } | - | ||||||
92 | - | |||||||
93 | static bool convert(const QVariant::Private *d, int type, void *result, bool *ok) | - | ||||||
94 | { | - | ||||||
95 | Q_UNUSED(d); | - | ||||||
96 | Q_UNUSED(type); | - | ||||||
97 | Q_UNUSED(result); | - | ||||||
98 | if (ok)
| 0 | ||||||
99 | *ok = false; never executed: *ok = false; | 0 | ||||||
100 | return false; never executed: return false; | 0 | ||||||
101 | } | - | ||||||
102 | - | |||||||
103 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||
104 | static void streamDebug(QDebug dbg, const QVariant &v) | - | ||||||
105 | { | - | ||||||
106 | QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); | - | ||||||
107 | switch (d->type) { | - | ||||||
108 | case QVariant::SizePolicy: never executed: case QVariant::SizePolicy: | 0 | ||||||
109 | dbg.nospace() << *v_cast<QSizePolicy>(d); | - | ||||||
110 | break; never executed: break; | 0 | ||||||
111 | default: never executed: default: | 0 | ||||||
112 | dbg.nospace() << "QMetaType::Type(" << d->type << ')'; | - | ||||||
113 | } never executed: end of block | 0 | ||||||
114 | } | - | ||||||
115 | #endif | - | ||||||
116 | - | |||||||
117 | static const QVariant::Handler widgets_handler = { | - | ||||||
118 | construct, | - | ||||||
119 | clear, | - | ||||||
120 | isNull, | - | ||||||
121 | #ifndef QT_NO_DATASTREAM | - | ||||||
122 | 0, | - | ||||||
123 | 0, | - | ||||||
124 | #endif | - | ||||||
125 | compare, | - | ||||||
126 | convert, | - | ||||||
127 | 0, | - | ||||||
128 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||
129 | streamDebug | - | ||||||
130 | #else | - | ||||||
131 | 0 | - | ||||||
132 | #endif | - | ||||||
133 | }; | - | ||||||
134 | - | |||||||
135 | #define QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES(MetaTypeName, MetaTypeId, RealName) \ | - | ||||||
136 | QT_METATYPE_INTERFACE_INIT(RealName), | - | ||||||
137 | - | |||||||
138 | static const QMetaTypeInterface qVariantWidgetsHelper[] = { | - | ||||||
139 | QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES) | - | ||||||
140 | }; | - | ||||||
141 | - | |||||||
142 | #undef QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES | - | ||||||
143 | - | |||||||
144 | } // namespace | - | ||||||
145 | - | |||||||
146 | extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper; | - | ||||||
147 | - | |||||||
148 | void qRegisterWidgetsVariant() | - | ||||||
149 | { | - | ||||||
150 | qRegisterMetaType<QWidget*>(); | - | ||||||
151 | qMetaTypeWidgetsHelper = qVariantWidgetsHelper; | - | ||||||
152 | QVariantPrivate::registerHandler(QModulesPrivate::Widgets, &widgets_handler); | - | ||||||
153 | } never executed: end of block | 0 | ||||||
154 | Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant) never executed: end of block | 0 | ||||||
155 | - | |||||||
156 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |