| 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) 2016 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
| 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 https://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at https://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 3 as published by the Free Software | - | ||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
| 24 | ** | - | ||||||
| 25 | ** GNU General Public License Usage | - | ||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
| 35 | ** | - | ||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||
| 37 | ** | - | ||||||
| 38 | ****************************************************************************/ | - | ||||||
| 39 | - | |||||||
| 40 | #include "qvariant.h" | - | ||||||
| 41 | - | |||||||
| 42 | #include "qsizepolicy.h" | - | ||||||
| 43 | #include "qwidget.h" | - | ||||||
| 44 | - | |||||||
| 45 | #include "private/qvariant_p.h" | - | ||||||
| 46 | #include <private/qmetatype_p.h> | - | ||||||
| 47 | - | |||||||
| 48 | QT_BEGIN_NAMESPACE | - | ||||||
| 49 | - | |||||||
| 50 | namespace { | - | ||||||
| 51 | static void construct(QVariant::Private *x, const void *copy) | - | ||||||
| 52 | { | - | ||||||
| 53 | switch (x->type) { | - | ||||||
| 54 | case QVariant::SizePolicy: never executed:  case QVariant::SizePolicy: | 0 | ||||||
| 55 | v_construct<QSizePolicy>(x, copy); | - | ||||||
| 56 | break; never executed:  break; | 0 | ||||||
| 57 | default: never executed:  default: | 0 | ||||||
| 58 | qWarning("Trying to construct an instance of an invalid type, type id: %i", x->type); | - | ||||||
| 59 | x->type = QVariant::Invalid; | - | ||||||
| 60 | return; never executed:  return; | 0 | ||||||
| 61 | } | - | ||||||
| 62 | x->is_null = !copy; | - | ||||||
| 63 | } never executed:  end of block | 0 | ||||||
| 64 | - | |||||||
| 65 | static void clear(QVariant::Private *d) | - | ||||||
| 66 | { | - | ||||||
| 67 | switch (d->type) { | - | ||||||
| 68 | case QVariant::SizePolicy: never executed:  case QVariant::SizePolicy: | 0 | ||||||
| 69 | v_clear<QSizePolicy>(d); | - | ||||||
| 70 | break; never executed:  break; | 0 | ||||||
| 71 | default: never executed:  default: | 0 | ||||||
| 72 | Q_ASSERT(false); | - | ||||||
| 73 | return; never executed:  return; | 0 | ||||||
| 74 | } | - | ||||||
| 75 | - | |||||||
| 76 | d->type = QVariant::Invalid; | - | ||||||
| 77 | d->is_null = true; | - | ||||||
| 78 | d->is_shared = false; | - | ||||||
| 79 | } never executed:  end of block | 0 | ||||||
| 80 | - | |||||||
| 81 | - | |||||||
| 82 | static bool isNull(const QVariant::Private *) | - | ||||||
| 83 | { | - | ||||||
| 84 | return false; never executed:  return false; | 0 | ||||||
| 85 | } | - | ||||||
| 86 | - | |||||||
| 87 | static bool compare(const QVariant::Private *a, const QVariant::Private *b) | - | ||||||
| 88 | { | - | ||||||
| 89 | Q_ASSERT(a->type == b->type); | - | ||||||
| 90 | switch(a->type) { | - | ||||||
| 91 | case QVariant::SizePolicy: never executed:  case QVariant::SizePolicy: | 0 | ||||||
| 92 | return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b); never executed:  return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b); | 0 | ||||||
| 93 | default: never executed:  default: | 0 | ||||||
| 94 | Q_ASSERT(false); | - | ||||||
| 95 | } never executed:  end of block | 0 | ||||||
| 96 | return false; never executed:  return false; | 0 | ||||||
| 97 | } | - | ||||||
| 98 | - | |||||||
| 99 | static bool convert(const QVariant::Private *d, int type, void *result, bool *ok) | - | ||||||
| 100 | { | - | ||||||
| 101 | Q_UNUSED(d); | - | ||||||
| 102 | Q_UNUSED(type); | - | ||||||
| 103 | Q_UNUSED(result); | - | ||||||
| 104 | if (ok) 
 | 0 | ||||||
| 105 | *ok = false; never executed:  *ok = false; | 0 | ||||||
| 106 | return false; never executed:  return false; | 0 | ||||||
| 107 | } | - | ||||||
| 108 | - | |||||||
| 109 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||
| 110 | static void streamDebug(QDebug dbg, const QVariant &v) | - | ||||||
| 111 | { | - | ||||||
| 112 | QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); | - | ||||||
| 113 | switch (d->type) { | - | ||||||
| 114 | case QVariant::SizePolicy: never executed:  case QVariant::SizePolicy: | 0 | ||||||
| 115 | dbg.nospace() << *v_cast<QSizePolicy>(d); | - | ||||||
| 116 | break; never executed:  break; | 0 | ||||||
| 117 | default: never executed:  default: | 0 | ||||||
| 118 | dbg.nospace() << "QMetaType::Type(" << d->type << ')'; | - | ||||||
| 119 | } never executed:  end of block | 0 | ||||||
| 120 | } | - | ||||||
| 121 | #endif | - | ||||||
| 122 | - | |||||||
| 123 | static const QVariant::Handler widgets_handler = { | - | ||||||
| 124 | construct, | - | ||||||
| 125 | clear, | - | ||||||
| 126 | isNull, | - | ||||||
| 127 | #ifndef QT_NO_DATASTREAM | - | ||||||
| 128 | 0, | - | ||||||
| 129 | 0, | - | ||||||
| 130 | #endif | - | ||||||
| 131 | compare, | - | ||||||
| 132 | convert, | - | ||||||
| 133 | 0, | - | ||||||
| 134 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||
| 135 | streamDebug | - | ||||||
| 136 | #else | - | ||||||
| 137 | 0 | - | ||||||
| 138 | #endif | - | ||||||
| 139 | }; | - | ||||||
| 140 | - | |||||||
| 141 | #define QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES(MetaTypeName, MetaTypeId, RealName) \ | - | ||||||
| 142 | QT_METATYPE_INTERFACE_INIT(RealName), | - | ||||||
| 143 | - | |||||||
| 144 | static const QMetaTypeInterface qVariantWidgetsHelper[] = { | - | ||||||
| 145 | QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES) | - | ||||||
| 146 | }; | - | ||||||
| 147 | - | |||||||
| 148 | #undef QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES | - | ||||||
| 149 | - | |||||||
| 150 | } // namespace | - | ||||||
| 151 | - | |||||||
| 152 | extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper; | - | ||||||
| 153 | - | |||||||
| 154 | void qRegisterWidgetsVariant() | - | ||||||
| 155 | { | - | ||||||
| 156 | qRegisterMetaType<QWidget*>(); | - | ||||||
| 157 | qMetaTypeWidgetsHelper = qVariantWidgetsHelper; | - | ||||||
| 158 | QVariantPrivate::registerHandler(QModulesPrivate::Widgets, &widgets_handler); | - | ||||||
| 159 | } never executed:  end of block | 0 | ||||||
| 160 | Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant) never executed:  end of block | 0 | ||||||
| 161 | - | |||||||
| 162 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |