1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include "qsizepolicy.h"
47 #include "private/qvariant_p.h"
48 #include <private/qmetatype_p.h>
53 static void construct(QVariant::Private *x, const void *copy)
58 v_construct<QIcon>(x, copy);
61 case QVariant::SizePolicy:
62 v_construct<QSizePolicy>(x, copy);
71 static void clear(QVariant::Private *d)
79 case QVariant::SizePolicy:
80 v_clear<QSizePolicy>(d);
87 d->type = QVariant::Invalid;
93 static bool isNull(const QVariant::Private *d)
98 return v_cast<QIcon>(d)->isNull();
104 static bool compare(const QVariant::Private *a, const QVariant::Private *b)
106 Q_ASSERT(a->type == b->type);
112 case QVariant::SizePolicy:
113 return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
120 static bool convert(const QVariant::Private *d, int type, void *result, bool *ok)
130 #if !defined(QT_NO_DEBUG_STREAM)
131 static void streamDebug(QDebug dbg, const QVariant &v)
133 QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
137 dbg.nospace() << *v_cast<QIcon>(d);
140 case QVariant::SizePolicy:
141 dbg.nospace() << *v_cast<QSizePolicy>(d);
144 dbg.nospace() << "QMetaType::Type(" << d->type << ")";
149 static const QVariant::Handler widgets_handler = {
153 #ifndef QT_NO_DATASTREAM
160 #if !defined(QT_NO_DEBUG_STREAM)
167 #define QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES(MetaTypeName, MetaTypeId, RealName) \
168 QT_METATYPE_INTERFACE_INIT(RealName),
170 static const QMetaTypeInterface qVariantWidgetsHelper[] = {
171 QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES)
174 #undef QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES
178 extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper;
180 void qRegisterWidgetsVariant()
182 qMetaTypeWidgetsHelper = qVariantWidgetsHelper;
183 QVariantPrivate::registerHandler(QModulesPrivate::Widgets, &widgets_handler);
185 Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant)
187 void qUnregisterWidgetsVariant()
189 QVariantPrivate::unregisterHandler(QModulesPrivate::Widgets);
190 qMetaTypeWidgetsHelper = 0;
192 Q_DESTRUCTOR_FUNCTION(qUnregisterWidgetsVariant)