1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include "qsizepolicy.h"
47 #include "private/qvariant_p.h"
52 static void construct(QVariant::Private *x, const void *copy)
57 v_construct<QIcon>(x, copy);
60 case QVariant::SizePolicy:
61 v_construct<QSizePolicy>(x, copy);
70 static void clear(QVariant::Private *d)
78 case QVariant::SizePolicy:
79 v_clear<QSizePolicy>(d);
86 d->type = QVariant::Invalid;
92 static bool isNull(const QVariant::Private *d)
97 return v_cast<QIcon>(d)->isNull();
105 static bool compare(const QVariant::Private *a, const QVariant::Private *b)
107 Q_ASSERT(a->type == b->type);
113 case QVariant::SizePolicy:
114 return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
122 static const QVariant::Handler widgets_handler = {
126 #ifndef QT_NO_DATASTREAM
133 #if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
140 struct QMetaTypeGuiHelper
142 QMetaType::Creator creator;
143 QMetaType::Deleter deleter;
144 #ifndef QT_NO_DATASTREAM
145 QMetaType::SaveOperator saveOp;
146 QMetaType::LoadOperator loadOp;
148 QMetaType::Constructor constructor;
149 QMetaType::Destructor destructor;
153 extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper;
156 #ifdef QT_NO_DATASTREAM
157 # define Q_DECL_METATYPE_HELPER(TYPE) \
158 typedef void *(*QCreate##TYPE)(const TYPE *); \
159 static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
160 typedef void (*QDelete##TYPE)(TYPE *); \
161 static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>; \
162 typedef void *(*QConstruct##TYPE)(void *, const TYPE *); \
163 static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
164 typedef void (*QDestruct##TYPE)(TYPE *); \
165 static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDestructHelper<TYPE>;
167 # define Q_DECL_METATYPE_HELPER(TYPE) \
168 typedef void *(*QCreate##TYPE)(const TYPE *); \
169 static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
170 typedef void (*QDelete##TYPE)(TYPE *); \
171 static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>; \
172 typedef void *(*QConstruct##TYPE)(void *, const TYPE *); \
173 static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
174 typedef void (*QDestruct##TYPE)(TYPE *); \
175 static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDestructHelper<TYPE>; \
176 typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
177 static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
178 typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
179 static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>;
183 Q_DECL_METATYPE_HELPER(QIcon)
185 Q_DECL_METATYPE_HELPER(QSizePolicy)
187 #ifdef QT_NO_DATASTREAM
188 # define Q_IMPL_METATYPE_HELPER(TYPE) \
189 { reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
190 reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE), \
191 reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
192 reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
196 # define Q_IMPL_METATYPE_HELPER(TYPE) \
197 { reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
198 reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE), \
199 reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
200 reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE), \
201 reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
202 reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
207 static const QMetaTypeGuiHelper qVariantWidgetsHelper[] = {
211 Q_IMPL_METATYPE_HELPER(QIcon),
213 Q_IMPL_METATYPE_HELPER(QSizePolicy),
216 extern Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler;
218 int qRegisterWidgetsVariant()
220 qt_widgets_variant_handler = &widgets_handler;
221 qMetaTypeWidgetsHelper = qVariantWidgetsHelper;
224 Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant)
226 int qUnregisterWidgetsVariant()
228 qt_widgets_variant_handler = 0;
229 qMetaTypeWidgetsHelper = 0;
232 Q_DESTRUCTOR_FUNCTION(qUnregisterWidgetsVariant)