| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qvariant.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 4 | ** Copyright (C) 2016 Intel Corporation. | - | ||||||||||||||||||||||||
| 5 | ** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com> | - | ||||||||||||||||||||||||
| 6 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||
| 8 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 9 | ** | - | ||||||||||||||||||||||||
| 10 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
| 11 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 12 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 13 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 14 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 15 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 16 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 17 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 18 | ** | - | ||||||||||||||||||||||||
| 19 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 20 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 21 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
| 22 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
| 23 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
| 24 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
| 25 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
| 26 | ** | - | ||||||||||||||||||||||||
| 27 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
| 28 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
| 29 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
| 30 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
| 31 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
| 32 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
| 33 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
| 34 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
| 35 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
| 36 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||||||||
| 38 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 39 | ** | - | ||||||||||||||||||||||||
| 40 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | #include "qvariant.h" | - | ||||||||||||||||||||||||
| 43 | #include "qbitarray.h" | - | ||||||||||||||||||||||||
| 44 | #include "qbytearray.h" | - | ||||||||||||||||||||||||
| 45 | #include "qdatastream.h" | - | ||||||||||||||||||||||||
| 46 | #include "qdebug.h" | - | ||||||||||||||||||||||||
| 47 | #include "qmap.h" | - | ||||||||||||||||||||||||
| 48 | #include "qdatetime.h" | - | ||||||||||||||||||||||||
| 49 | #include "qeasingcurve.h" | - | ||||||||||||||||||||||||
| 50 | #include "qlist.h" | - | ||||||||||||||||||||||||
| 51 | #include "qregularexpression.h" | - | ||||||||||||||||||||||||
| 52 | #include "qstring.h" | - | ||||||||||||||||||||||||
| 53 | #include "qstringlist.h" | - | ||||||||||||||||||||||||
| 54 | #include "qurl.h" | - | ||||||||||||||||||||||||
| 55 | #include "qlocale.h" | - | ||||||||||||||||||||||||
| 56 | #include "quuid.h" | - | ||||||||||||||||||||||||
| 57 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 58 | #include "qabstractitemmodel.h" | - | ||||||||||||||||||||||||
| 59 | #include "qjsonvalue.h" | - | ||||||||||||||||||||||||
| 60 | #include "qjsonobject.h" | - | ||||||||||||||||||||||||
| 61 | #include "qjsonarray.h" | - | ||||||||||||||||||||||||
| 62 | #include "qjsondocument.h" | - | ||||||||||||||||||||||||
| 63 | #include "qbytearraylist.h" | - | ||||||||||||||||||||||||
| 64 | #endif | - | ||||||||||||||||||||||||
| 65 | #include "private/qvariant_p.h" | - | ||||||||||||||||||||||||
| 66 | #include "private/qlocale_p.h" | - | ||||||||||||||||||||||||
| 67 | #include "qmetatype_p.h" | - | ||||||||||||||||||||||||
| 68 | #include <qmetaobject.h> | - | ||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
| 71 | #include "qsize.h" | - | ||||||||||||||||||||||||
| 72 | #include "qpoint.h" | - | ||||||||||||||||||||||||
| 73 | #include "qrect.h" | - | ||||||||||||||||||||||||
| 74 | #include "qline.h" | - | ||||||||||||||||||||||||
| 75 | #endif | - | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | #include <float.h> | - | ||||||||||||||||||||||||
| 78 | #include <cstring> | - | ||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | namespace { | - | ||||||||||||||||||||||||
| 83 | class HandlersManager | - | ||||||||||||||||||||||||
| 84 | { | - | ||||||||||||||||||||||||
| 85 | static const QVariant::Handler *Handlers[QModulesPrivate::ModulesCount]; | - | ||||||||||||||||||||||||
| 86 | public: | - | ||||||||||||||||||||||||
| 87 | const QVariant::Handler *operator[] (const uint typeId) const | - | ||||||||||||||||||||||||
| 88 | { | - | ||||||||||||||||||||||||
| 89 | return Handlers[QModulesPrivate::moduleForType(typeId)]; executed 21763616 times by 454 tests: return Handlers[QModulesPrivate::moduleForType(typeId)];Executed by:
| 21763616 | ||||||||||||||||||||||||
| 90 | } | - | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | void registerHandler(const QModulesPrivate::Names name, const QVariant::Handler *handler) | - | ||||||||||||||||||||||||
| 93 | { | - | ||||||||||||||||||||||||
| 94 | Handlers[name] = handler; | - | ||||||||||||||||||||||||
| 95 | } executed 263 times by 5 tests: end of blockExecuted by:
| 263 | ||||||||||||||||||||||||
| 96 | }; | - | ||||||||||||||||||||||||
| 97 | } // namespace | - | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | namespace { | - | ||||||||||||||||||||||||
| 100 | struct CoreTypesFilter { | - | ||||||||||||||||||||||||
| 101 | template<typename T> | - | ||||||||||||||||||||||||
| 102 | struct Acceptor { | - | ||||||||||||||||||||||||
| 103 | static const bool IsAccepted = QModulesPrivate::QTypeModuleInfo<T>::IsCore && QtMetaTypePrivate::TypeDefinition<T>::IsAvailable; | - | ||||||||||||||||||||||||
| 104 | }; | - | ||||||||||||||||||||||||
| 105 | }; | - | ||||||||||||||||||||||||
| 106 | } // annonymous | - | ||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | namespace { // annonymous used to hide QVariant handlers | - | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | static void construct(QVariant::Private *x, const void *copy) | - | ||||||||||||||||||||||||
| 111 | { | - | ||||||||||||||||||||||||
| 112 | QVariantConstructor<CoreTypesFilter> constructor(x, copy); | - | ||||||||||||||||||||||||
| 113 | QMetaTypeSwitcher::switcher<void>(constructor, x->type, 0); | - | ||||||||||||||||||||||||
| 114 | } executed 4705573 times by 394 tests: end of blockExecuted by:
| 4705573 | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | static void clear(QVariant::Private *d) | - | ||||||||||||||||||||||||
| 117 | { | - | ||||||||||||||||||||||||
| 118 | QVariantDestructor<CoreTypesFilter> cleaner(d); | - | ||||||||||||||||||||||||
| 119 | QMetaTypeSwitcher::switcher<void>(cleaner, d->type, 0); | - | ||||||||||||||||||||||||
| 120 | } executed 8711456 times by 424 tests: end of blockExecuted by:
| 8711456 | ||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | static bool isNull(const QVariant::Private *d) | - | ||||||||||||||||||||||||
| 123 | { | - | ||||||||||||||||||||||||
| 124 | QVariantIsNull<CoreTypesFilter> isNull(d); | - | ||||||||||||||||||||||||
| 125 | return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0); executed 411638 times by 136 tests: return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0);Executed by:
| 411638 | ||||||||||||||||||||||||
| 126 | } | - | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | /*! | - | ||||||||||||||||||||||||
| 129 | \internal | - | ||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | Compares \a a to \a b. The caller guarantees that \a a and \a b | - | ||||||||||||||||||||||||
| 132 | are of the same type. | - | ||||||||||||||||||||||||
| 133 | */ | - | ||||||||||||||||||||||||
| 134 | static bool compare(const QVariant::Private *a, const QVariant::Private *b) | - | ||||||||||||||||||||||||
| 135 | { | - | ||||||||||||||||||||||||
| 136 | QVariantComparator<CoreTypesFilter> comparator(a, b); | - | ||||||||||||||||||||||||
| 137 | return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0); executed 94720 times by 72 tests: return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0);Executed by:
| 94720 | ||||||||||||||||||||||||
| 138 | } | - | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | /*! | - | ||||||||||||||||||||||||
| 141 | \internal | - | ||||||||||||||||||||||||
| 142 | */ | - | ||||||||||||||||||||||||
| 143 | static qlonglong qMetaTypeNumber(const QVariant::Private *d) | - | ||||||||||||||||||||||||
| 144 | { | - | ||||||||||||||||||||||||
| 145 | switch (d->type) { | - | ||||||||||||||||||||||||
| 146 | case QMetaType::Int: executed 358715 times by 94 tests: case QMetaType::Int:Executed by:
| 358715 | ||||||||||||||||||||||||
| 147 | return d->data.i; executed 358715 times by 94 tests: return d->data.i;Executed by:
| 358715 | ||||||||||||||||||||||||
| 148 | case QMetaType::LongLong: executed 6002 times by 21 tests: case QMetaType::LongLong:Executed by:
| 6002 | ||||||||||||||||||||||||
| 149 | return d->data.ll; executed 6002 times by 21 tests: return d->data.ll;Executed by:
| 6002 | ||||||||||||||||||||||||
| 150 | case QMetaType::Char: executed 177 times by 1 test: case QMetaType::Char:Executed by:
| 177 | ||||||||||||||||||||||||
| 151 | return qlonglong(d->data.c); executed 177 times by 1 test: return qlonglong(d->data.c);Executed by:
| 177 | ||||||||||||||||||||||||
| 152 | case QMetaType::SChar: executed 186 times by 1 test: case QMetaType::SChar:Executed by:
| 186 | ||||||||||||||||||||||||
| 153 | return qlonglong(d->data.sc); executed 186 times by 1 test: return qlonglong(d->data.sc);Executed by:
| 186 | ||||||||||||||||||||||||
| 154 | case QMetaType::Short: executed 231 times by 2 tests: case QMetaType::Short:Executed by:
| 231 | ||||||||||||||||||||||||
| 155 | return qlonglong(d->data.s); executed 231 times by 2 tests: return qlonglong(d->data.s);Executed by:
| 231 | ||||||||||||||||||||||||
| 156 | case QMetaType::Long: executed 120 times by 1 test: case QMetaType::Long:Executed by:
| 120 | ||||||||||||||||||||||||
| 157 | return qlonglong(d->data.l); executed 120 times by 1 test: return qlonglong(d->data.l);Executed by:
| 120 | ||||||||||||||||||||||||
| 158 | case QMetaType::Float: executed 12 times by 1 test: case QMetaType::Float:Executed by:
| 12 | ||||||||||||||||||||||||
| 159 | return qRound64(d->data.f); executed 12 times by 1 test: return qRound64(d->data.f);Executed by:
| 12 | ||||||||||||||||||||||||
| 160 | case QVariant::Double: executed 236 times by 13 tests: case QVariant::Double:Executed by:
| 236 | ||||||||||||||||||||||||
| 161 | return qRound64(d->data.d); executed 236 times by 13 tests: return qRound64(d->data.d);Executed by:
| 236 | ||||||||||||||||||||||||
| 162 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 163 | case QMetaType::QJsonValue: executed 4 times by 1 test: case QMetaType::QJsonValue:Executed by:
| 4 | ||||||||||||||||||||||||
| 164 | return v_cast<QJsonValue>(d)->toDouble(); executed 4 times by 1 test: return v_cast<QJsonValue>(d)->toDouble();Executed by:
| 4 | ||||||||||||||||||||||||
| 165 | #endif | - | ||||||||||||||||||||||||
| 166 | } | - | ||||||||||||||||||||||||
| 167 | Q_ASSERT(false); | - | ||||||||||||||||||||||||
| 168 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 169 | } | - | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | static qulonglong qMetaTypeUNumber(const QVariant::Private *d) | - | ||||||||||||||||||||||||
| 172 | { | - | ||||||||||||||||||||||||
| 173 | switch (d->type) { | - | ||||||||||||||||||||||||
| 174 | case QVariant::UInt: executed 2310 times by 23 tests: case QVariant::UInt:Executed by:
| 2310 | ||||||||||||||||||||||||
| 175 | return d->data.u; executed 2310 times by 23 tests: return d->data.u;Executed by:
| 2310 | ||||||||||||||||||||||||
| 176 | case QVariant::ULongLong: executed 465 times by 19 tests: case QVariant::ULongLong:Executed by:
| 465 | ||||||||||||||||||||||||
| 177 | return d->data.ull; executed 465 times by 19 tests: return d->data.ull;Executed by:
| 465 | ||||||||||||||||||||||||
| 178 | case QMetaType::UChar: executed 153 times by 2 tests: case QMetaType::UChar:Executed by:
| 153 | ||||||||||||||||||||||||
| 179 | return d->data.uc; executed 153 times by 2 tests: return d->data.uc;Executed by:
| 153 | ||||||||||||||||||||||||
| 180 | case QMetaType::UShort: executed 183 times by 2 tests: case QMetaType::UShort:Executed by:
| 183 | ||||||||||||||||||||||||
| 181 | return d->data.us; executed 183 times by 2 tests: return d->data.us;Executed by:
| 183 | ||||||||||||||||||||||||
| 182 | case QMetaType::ULong: executed 87 times by 1 test: case QMetaType::ULong:Executed by:
| 87 | ||||||||||||||||||||||||
| 183 | return d->data.ul; executed 87 times by 1 test: return d->data.ul;Executed by:
| 87 | ||||||||||||||||||||||||
| 184 | } | - | ||||||||||||||||||||||||
| 185 | Q_ASSERT(false); | - | ||||||||||||||||||||||||
| 186 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 187 | } | - | ||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||
| 189 | static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||||||||||||||
| 190 | { | - | ||||||||||||||||||||||||
| 191 | *ok = true; | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | switch (uint(d->type)) { | - | ||||||||||||||||||||||||
| 194 | case QVariant::String: executed 12478 times by 37 tests: case QVariant::String:Executed by:
| 12478 | ||||||||||||||||||||||||
| 195 | return v_cast<QString>(d)->toLongLong(ok); executed 12478 times by 37 tests: return v_cast<QString>(d)->toLongLong(ok);Executed by:
| 12478 | ||||||||||||||||||||||||
| 196 | case QVariant::Char: executed 7 times by 2 tests: case QVariant::Char:Executed by:
| 7 | ||||||||||||||||||||||||
| 197 | return v_cast<QChar>(d)->unicode(); executed 7 times by 2 tests: return v_cast<QChar>(d)->unicode();Executed by:
| 7 | ||||||||||||||||||||||||
| 198 | case QVariant::ByteArray: executed 5 times by 1 test: case QVariant::ByteArray:Executed by:
| 5 | ||||||||||||||||||||||||
| 199 | return v_cast<QByteArray>(d)->toLongLong(ok); executed 5 times by 1 test: return v_cast<QByteArray>(d)->toLongLong(ok);Executed by:
| 5 | ||||||||||||||||||||||||
| 200 | case QVariant::Bool: executed 541 times by 22 tests: case QVariant::Bool:Executed by:
| 541 | ||||||||||||||||||||||||
| 201 | return qlonglong(d->data.b); executed 541 times by 22 tests: return qlonglong(d->data.b);Executed by:
| 541 | ||||||||||||||||||||||||
| 202 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 203 | case QMetaType::QJsonValue: executed 4 times by 1 test: case QMetaType::QJsonValue:Executed by:
| 4 | ||||||||||||||||||||||||
| 204 | if (!v_cast<QJsonValue>(d)->isDouble())
| 2 | ||||||||||||||||||||||||
| 205 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 206 | // no break | - | ||||||||||||||||||||||||
| 207 | #endif | - | ||||||||||||||||||||||||
| 208 | case QVariant::Double: code before this statement executed 2 times by 1 test: case QVariant::Double:Executed by:
executed 222 times by 13 tests: case QVariant::Double:Executed by:
| 2-222 | ||||||||||||||||||||||||
| 209 | case QVariant::Int: executed 329292 times by 81 tests: case QVariant::Int:Executed by:
| 329292 | ||||||||||||||||||||||||
| 210 | case QMetaType::Char: executed 168 times by 1 test: case QMetaType::Char:Executed by:
| 168 | ||||||||||||||||||||||||
| 211 | case QMetaType::SChar: executed 169 times by 1 test: case QMetaType::SChar:Executed by:
| 169 | ||||||||||||||||||||||||
| 212 | case QMetaType::Short: executed 201 times by 2 tests: case QMetaType::Short:Executed by:
| 201 | ||||||||||||||||||||||||
| 213 | case QMetaType::Long: executed 108 times by 1 test: case QMetaType::Long:Executed by:
| 108 | ||||||||||||||||||||||||
| 214 | case QMetaType::Float: executed 3 times by 1 test: case QMetaType::Float:Executed by:
| 3 | ||||||||||||||||||||||||
| 215 | case QMetaType::LongLong: executed 5471 times by 20 tests: case QMetaType::LongLong:Executed by:
| 5471 | ||||||||||||||||||||||||
| 216 | return qMetaTypeNumber(d); executed 335636 times by 86 tests: return qMetaTypeNumber(d);Executed by:
| 335636 | ||||||||||||||||||||||||
| 217 | case QVariant::ULongLong: executed 323 times by 4 tests: case QVariant::ULongLong:Executed by:
| 323 | ||||||||||||||||||||||||
| 218 | case QVariant::UInt: executed 742 times by 11 tests: case QVariant::UInt:Executed by:
| 742 | ||||||||||||||||||||||||
| 219 | case QMetaType::UChar: executed 136 times by 2 tests: case QMetaType::UChar:Executed by:
| 136 | ||||||||||||||||||||||||
| 220 | case QMetaType::UShort: executed 146 times by 2 tests: case QMetaType::UShort:Executed by:
| 146 | ||||||||||||||||||||||||
| 221 | case QMetaType::ULong: executed 86 times by 1 test: case QMetaType::ULong:Executed by:
| 86 | ||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||
| 223 | return qlonglong(qMetaTypeUNumber(d)); executed 1433 times by 12 tests: return qlonglong(qMetaTypeUNumber(d));Executed by:
| 1433 | ||||||||||||||||||||||||
| 224 | } | - | ||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||
| 226 | QMetaType typeInfo(d->type); | - | ||||||||||||||||||||||||
| 227 | if (typeInfo.flags() & QMetaType::IsEnumeration) {
| 116-868 | ||||||||||||||||||||||||
| 228 | switch (typeInfo.sizeOf()) { | - | ||||||||||||||||||||||||
| 229 | case 1: executed 10 times by 1 test: case 1:Executed by:
| 10 | ||||||||||||||||||||||||
| 230 | return d->is_shared ? *reinterpret_cast<signed char *>(d->data.shared->ptr) : d->data.sc; executed 10 times by 1 test: return d->is_shared ? *reinterpret_cast<signed char *>(d->data.shared->ptr) : d->data.sc;Executed by:
| 10 | ||||||||||||||||||||||||
| 231 | case 2: executed 10 times by 1 test: case 2:Executed by:
| 10 | ||||||||||||||||||||||||
| 232 | return d->is_shared ? *reinterpret_cast<qint16 *>(d->data.shared->ptr) : d->data.s; executed 10 times by 1 test: return d->is_shared ? *reinterpret_cast<qint16 *>(d->data.shared->ptr) : d->data.s;Executed by:
| 10 | ||||||||||||||||||||||||
| 233 | case 4: executed 32 times by 4 tests: case 4:Executed by:
| 32 | ||||||||||||||||||||||||
| 234 | return d->is_shared ? *reinterpret_cast<qint32 *>(d->data.shared->ptr) : d->data.i; executed 32 times by 4 tests: return d->is_shared ? *reinterpret_cast<qint32 *>(d->data.shared->ptr) : d->data.i;Executed by:
| 32 | ||||||||||||||||||||||||
| 235 | case 8: executed 64 times by 1 test: case 8:Executed by:
| 64 | ||||||||||||||||||||||||
| 236 | return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ll; executed 64 times by 1 test: return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ll;Executed by:
| 64 | ||||||||||||||||||||||||
| 237 | } | - | ||||||||||||||||||||||||
| 238 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | *ok = false; | - | ||||||||||||||||||||||||
| 241 | return Q_INT64_C(0); executed 868 times by 19 tests: return static_cast<long long>(0LL);Executed by:
| 868 | ||||||||||||||||||||||||
| 242 | } | - | ||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||||||||||||||
| 245 | { | - | ||||||||||||||||||||||||
| 246 | *ok = true; | - | ||||||||||||||||||||||||
| 247 | switch (uint(d->type)) { | - | ||||||||||||||||||||||||
| 248 | case QVariant::Double: executed 10949 times by 32 tests: case QVariant::Double:Executed by:
| 10949 | ||||||||||||||||||||||||
| 249 | return qreal(d->data.d); executed 10949 times by 32 tests: return qreal(d->data.d);Executed by:
| 10949 | ||||||||||||||||||||||||
| 250 | case QMetaType::Float: executed 301 times by 1 test: case QMetaType::Float:Executed by:
| 301 | ||||||||||||||||||||||||
| 251 | return qreal(d->data.f); executed 301 times by 1 test: return qreal(d->data.f);Executed by:
| 301 | ||||||||||||||||||||||||
| 252 | case QVariant::ULongLong: never executed: case QVariant::ULongLong: | 0 | ||||||||||||||||||||||||
| 253 | case QVariant::UInt: executed 80 times by 1 test: case QVariant::UInt:Executed by:
| 80 | ||||||||||||||||||||||||
| 254 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
| 255 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
| 256 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 257 | return qreal(qMetaTypeUNumber(d)); executed 80 times by 1 test: return qreal(qMetaTypeUNumber(d));Executed by:
| 80 | ||||||||||||||||||||||||
| 258 | default: executed 96 times by 3 tests: default:Executed by:
| 96 | ||||||||||||||||||||||||
| 259 | // includes enum conversion as well as invalid types | - | ||||||||||||||||||||||||
| 260 | return qreal(qConvertToNumber(d, ok)); executed 96 times by 3 tests: return qreal(qConvertToNumber(d, ok));Executed by:
| 96 | ||||||||||||||||||||||||
| 261 | } | - | ||||||||||||||||||||||||
| 262 | } | - | ||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||||||||||||||
| 265 | { | - | ||||||||||||||||||||||||
| 266 | *ok = true; | - | ||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | switch (uint(d->type)) { | - | ||||||||||||||||||||||||
| 269 | case QVariant::String: executed 47 times by 3 tests: case QVariant::String:Executed by:
| 47 | ||||||||||||||||||||||||
| 270 | return v_cast<QString>(d)->toULongLong(ok); executed 47 times by 3 tests: return v_cast<QString>(d)->toULongLong(ok);Executed by:
| 47 | ||||||||||||||||||||||||
| 271 | case QVariant::Char: executed 2 times by 1 test: case QVariant::Char:Executed by:
| 2 | ||||||||||||||||||||||||
| 272 | return v_cast<QChar>(d)->unicode(); executed 2 times by 1 test: return v_cast<QChar>(d)->unicode();Executed by:
| 2 | ||||||||||||||||||||||||
| 273 | case QVariant::ByteArray: executed 4 times by 1 test: case QVariant::ByteArray:Executed by:
| 4 | ||||||||||||||||||||||||
| 274 | return v_cast<QByteArray>(d)->toULongLong(ok); executed 4 times by 1 test: return v_cast<QByteArray>(d)->toULongLong(ok);Executed by:
| 4 | ||||||||||||||||||||||||
| 275 | case QVariant::Bool: never executed: case QVariant::Bool: | 0 | ||||||||||||||||||||||||
| 276 | return qulonglong(d->data.b); never executed: return qulonglong(d->data.b); | 0 | ||||||||||||||||||||||||
| 277 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 278 | case QMetaType::QJsonValue: executed 4 times by 1 test: case QMetaType::QJsonValue:Executed by:
| 4 | ||||||||||||||||||||||||
| 279 | if (!v_cast<QJsonValue>(d)->isDouble())
| 2 | ||||||||||||||||||||||||
| 280 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 281 | // no break | - | ||||||||||||||||||||||||
| 282 | #endif | - | ||||||||||||||||||||||||
| 283 | case QVariant::Double: code before this statement executed 2 times by 1 test: case QVariant::Double:Executed by:
executed 3 times by 1 test: case QVariant::Double:Executed by:
| 2-3 | ||||||||||||||||||||||||
| 284 | case QVariant::Int: executed 47 times by 6 tests: case QVariant::Int:Executed by:
| 47 | ||||||||||||||||||||||||
| 285 | case QMetaType::Char: executed 1 time by 1 test: case QMetaType::Char:Executed by:
| 1 | ||||||||||||||||||||||||
| 286 | case QMetaType::SChar: executed 1 time by 1 test: case QMetaType::SChar:Executed by:
| 1 | ||||||||||||||||||||||||
| 287 | case QMetaType::Short: executed 2 times by 1 test: case QMetaType::Short:Executed by:
| 2 | ||||||||||||||||||||||||
| 288 | case QMetaType::Long: executed 7 times by 1 test: case QMetaType::Long:Executed by:
| 7 | ||||||||||||||||||||||||
| 289 | case QMetaType::Float: executed 3 times by 1 test: case QMetaType::Float:Executed by:
| 3 | ||||||||||||||||||||||||
| 290 | case QMetaType::LongLong: executed 5 times by 2 tests: case QMetaType::LongLong:Executed by:
| 5 | ||||||||||||||||||||||||
| 291 | return qulonglong(qMetaTypeNumber(d)); executed 71 times by 7 tests: return qulonglong(qMetaTypeNumber(d));Executed by:
| 71 | ||||||||||||||||||||||||
| 292 | case QVariant::ULongLong: executed 75 times by 16 tests: case QVariant::ULongLong:Executed by:
| 75 | ||||||||||||||||||||||||
| 293 | case QVariant::UInt: executed 34 times by 3 tests: case QVariant::UInt:Executed by:
| 34 | ||||||||||||||||||||||||
| 294 | case QMetaType::UChar: executed 1 time by 1 test: case QMetaType::UChar:Executed by:
| 1 | ||||||||||||||||||||||||
| 295 | case QMetaType::UShort: executed 11 times by 1 test: case QMetaType::UShort:Executed by:
| 11 | ||||||||||||||||||||||||
| 296 | case QMetaType::ULong: executed 1 time by 1 test: case QMetaType::ULong:Executed by:
| 1 | ||||||||||||||||||||||||
| 297 | return qMetaTypeUNumber(d); executed 122 times by 18 tests: return qMetaTypeUNumber(d);Executed by:
| 122 | ||||||||||||||||||||||||
| 298 | } | - | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | QMetaType typeInfo(d->type); | - | ||||||||||||||||||||||||
| 301 | if (typeInfo.flags() & QMetaType::IsEnumeration) {
| 48-69 | ||||||||||||||||||||||||
| 302 | switch (typeInfo.sizeOf()) { | - | ||||||||||||||||||||||||
| 303 | case 1: executed 6 times by 1 test: case 1:Executed by:
| 6 | ||||||||||||||||||||||||
| 304 | return d->is_shared ? *reinterpret_cast<uchar *>(d->data.shared->ptr) : d->data.uc; executed 6 times by 1 test: return d->is_shared ? *reinterpret_cast<uchar *>(d->data.shared->ptr) : d->data.uc;Executed by:
| 6 | ||||||||||||||||||||||||
| 305 | case 2: executed 6 times by 1 test: case 2:Executed by:
| 6 | ||||||||||||||||||||||||
| 306 | return d->is_shared ? *reinterpret_cast<quint16 *>(d->data.shared->ptr) : d->data.us; executed 6 times by 1 test: return d->is_shared ? *reinterpret_cast<quint16 *>(d->data.shared->ptr) : d->data.us;Executed by:
| 6 | ||||||||||||||||||||||||
| 307 | case 4: executed 18 times by 1 test: case 4:Executed by:
| 18 | ||||||||||||||||||||||||
| 308 | return d->is_shared ? *reinterpret_cast<quint32 *>(d->data.shared->ptr) : d->data.u; executed 18 times by 1 test: return d->is_shared ? *reinterpret_cast<quint32 *>(d->data.shared->ptr) : d->data.u;Executed by:
| 18 | ||||||||||||||||||||||||
| 309 | case 8: executed 39 times by 1 test: case 8:Executed by:
| 39 | ||||||||||||||||||||||||
| 310 | return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ull; executed 39 times by 1 test: return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ull;Executed by:
| 39 | ||||||||||||||||||||||||
| 311 | } | - | ||||||||||||||||||||||||
| 312 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||
| 314 | *ok = false; | - | ||||||||||||||||||||||||
| 315 | return Q_UINT64_C(0); executed 48 times by 11 tests: return static_cast<unsigned long long>(0ULL);Executed by:
| 48 | ||||||||||||||||||||||||
| 316 | } | - | ||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||
| 318 | template<typename TInput, typename LiteralWrapper> | - | ||||||||||||||||||||||||
| 319 | inline bool qt_convertToBool(const QVariant::Private *const d) | - | ||||||||||||||||||||||||
| 320 | { | - | ||||||||||||||||||||||||
| 321 | TInput str = v_cast<TInput>(d)->toLower(); | - | ||||||||||||||||||||||||
| 322 | return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty()); executed 30 times by 3 tests: return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty());Executed by:
| 30 | ||||||||||||||||||||||||
| 323 | } | - | ||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||
| 325 | /*! | - | ||||||||||||||||||||||||
| 326 | \internal | - | ||||||||||||||||||||||||
| 327 | Returns the internal data pointer from \a d. | - | ||||||||||||||||||||||||
| 328 | */ | - | ||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||
| 330 | static const void *constData(const QVariant::Private &d) | - | ||||||||||||||||||||||||
| 331 | { | - | ||||||||||||||||||||||||
| 332 | return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.c); executed 2624 times by 33 tests: return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.c);Executed by:
| 2624 | ||||||||||||||||||||||||
| 333 | } | - | ||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
| 336 | /*! | - | ||||||||||||||||||||||||
| 337 | \internal | - | ||||||||||||||||||||||||
| 338 | returns a QMetaEnum for a given meta tape type id if possible | - | ||||||||||||||||||||||||
| 339 | */ | - | ||||||||||||||||||||||||
| 340 | static QMetaEnum metaEnumFromType(int type) | - | ||||||||||||||||||||||||
| 341 | { | - | ||||||||||||||||||||||||
| 342 | QMetaType t(type); | - | ||||||||||||||||||||||||
| 343 | if (t.flags() & QMetaType::IsEnumeration) {
| 37-20461 | ||||||||||||||||||||||||
| 344 | if (const QMetaObject *metaObject = t.metaObject()) {
| 0-37 | ||||||||||||||||||||||||
| 345 | const char *enumName = QMetaType::typeName(type); | - | ||||||||||||||||||||||||
| 346 | const char *lastColon = std::strrchr(enumName, ':'); | - | ||||||||||||||||||||||||
| 347 | if (lastColon)
| 0-37 | ||||||||||||||||||||||||
| 348 | enumName = lastColon + 1; executed 37 times by 1 test: enumName = lastColon + 1;Executed by:
| 37 | ||||||||||||||||||||||||
| 349 | return metaObject->enumerator(metaObject->indexOfEnumerator(enumName)); executed 37 times by 1 test: return metaObject->enumerator(metaObject->indexOfEnumerator(enumName));Executed by:
| 37 | ||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||
| 351 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 352 | return QMetaEnum(); executed 20461 times by 37 tests: return QMetaEnum();Executed by:
| 20461 | ||||||||||||||||||||||||
| 353 | } | - | ||||||||||||||||||||||||
| 354 | #endif | - | ||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||
| 356 | /*! | - | ||||||||||||||||||||||||
| 357 | \internal | - | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | Converts \a d to type \a t, which is placed in \a result. | - | ||||||||||||||||||||||||
| 360 | */ | - | ||||||||||||||||||||||||
| 361 | static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) | - | ||||||||||||||||||||||||
| 362 | { | - | ||||||||||||||||||||||||
| 363 | Q_ASSERT(d->type != uint(t)); | - | ||||||||||||||||||||||||
| 364 | Q_ASSERT(result); | - | ||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | if (d->type >= QMetaType::User || t >= QMetaType::User) {
| 228-422562 | ||||||||||||||||||||||||
| 367 | const bool isOk = QMetaType::convert(constData(*d), d->type, result, t); | - | ||||||||||||||||||||||||
| 368 | if (ok)
| 27-807 | ||||||||||||||||||||||||
| 369 | *ok = isOk; executed 27 times by 1 test: *ok = isOk;Executed by:
| 27 | ||||||||||||||||||||||||
| 370 | if (isOk)
| 27-807 | ||||||||||||||||||||||||
| 371 | return true; executed 27 times by 2 tests: return true;Executed by:
| 27 | ||||||||||||||||||||||||
| 372 | } executed 807 times by 24 tests: end of blockExecuted by:
| 807 | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | bool dummy; | - | ||||||||||||||||||||||||
| 375 | if (!ok)
| 653-422488 | ||||||||||||||||||||||||
| 376 | ok = &dummy; executed 422488 times by 203 tests: ok = &dummy;Executed by:
| 422488 | ||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | switch (uint(t)) { | - | ||||||||||||||||||||||||
| 379 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 380 | case QVariant::Url: executed 6 times by 3 tests: case QVariant::Url:Executed by:
| 6 | ||||||||||||||||||||||||
| 381 | switch (d->type) { | - | ||||||||||||||||||||||||
| 382 | case QVariant::String: executed 6 times by 3 tests: case QVariant::String:Executed by:
| 6 | ||||||||||||||||||||||||
| 383 | *static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d)); | - | ||||||||||||||||||||||||
| 384 | break; executed 6 times by 3 tests: break;Executed by:
| 6 | ||||||||||||||||||||||||
| 385 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 386 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 387 | } | - | ||||||||||||||||||||||||
| 388 | break; executed 6 times by 3 tests: break;Executed by:
| 6 | ||||||||||||||||||||||||
| 389 | case QVariant::ModelIndex: executed 1 time by 1 test: case QVariant::ModelIndex:Executed by:
| 1 | ||||||||||||||||||||||||
| 390 | switch (d->type) { | - | ||||||||||||||||||||||||
| 391 | case QVariant::PersistentModelIndex: executed 1 time by 1 test: case QVariant::PersistentModelIndex:Executed by:
| 1 | ||||||||||||||||||||||||
| 392 | *static_cast<QModelIndex *>(result) = QModelIndex(*v_cast<QPersistentModelIndex>(d)); | - | ||||||||||||||||||||||||
| 393 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 394 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 395 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 396 | } | - | ||||||||||||||||||||||||
| 397 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 398 | case QVariant::PersistentModelIndex: executed 1 time by 1 test: case QVariant::PersistentModelIndex:Executed by:
| 1 | ||||||||||||||||||||||||
| 399 | switch (d->type) { | - | ||||||||||||||||||||||||
| 400 | case QVariant::ModelIndex: executed 1 time by 1 test: case QVariant::ModelIndex:Executed by:
| 1 | ||||||||||||||||||||||||
| 401 | *static_cast<QPersistentModelIndex *>(result) = QPersistentModelIndex(*v_cast<QModelIndex>(d)); | - | ||||||||||||||||||||||||
| 402 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 403 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 404 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 405 | } | - | ||||||||||||||||||||||||
| 406 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 407 | #endif // QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 408 | case QVariant::String: { executed 55537 times by 77 tests: case QVariant::String:Executed by:
| 55537 | ||||||||||||||||||||||||
| 409 | QString *str = static_cast<QString *>(result); | - | ||||||||||||||||||||||||
| 410 | switch (d->type) { | - | ||||||||||||||||||||||||
| 411 | case QVariant::Char: executed 5106 times by 14 tests: case QVariant::Char:Executed by:
| 5106 | ||||||||||||||||||||||||
| 412 | *str = *v_cast<QChar>(d); | - | ||||||||||||||||||||||||
| 413 | break; executed 5106 times by 14 tests: break;Executed by:
| 5106 | ||||||||||||||||||||||||
| 414 | case QMetaType::Char: executed 29 times by 1 test: case QMetaType::Char:Executed by:
| 29 | ||||||||||||||||||||||||
| 415 | case QMetaType::SChar: executed 36 times by 1 test: case QMetaType::SChar:Executed by:
| 36 | ||||||||||||||||||||||||
| 416 | case QMetaType::UChar: executed 10 times by 1 test: case QMetaType::UChar:Executed by:
| 10 | ||||||||||||||||||||||||
| 417 | *str = QChar::fromLatin1(d->data.c); | - | ||||||||||||||||||||||||
| 418 | break; executed 75 times by 1 test: break;Executed by:
| 75 | ||||||||||||||||||||||||
| 419 | case QMetaType::Short: executed 10 times by 1 test: case QMetaType::Short:Executed by:
| 10 | ||||||||||||||||||||||||
| 420 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
| 421 | case QVariant::Int: executed 29283 times by 45 tests: case QVariant::Int:Executed by:
| 29283 | ||||||||||||||||||||||||
| 422 | case QVariant::LongLong: executed 250 times by 9 tests: case QVariant::LongLong:Executed by:
| 250 | ||||||||||||||||||||||||
| 423 | *str = QString::number(qMetaTypeNumber(d)); | - | ||||||||||||||||||||||||
| 424 | break; executed 29543 times by 47 tests: break;Executed by:
| 29543 | ||||||||||||||||||||||||
| 425 | case QVariant::UInt: executed 179 times by 5 tests: case QVariant::UInt:Executed by:
| 179 | ||||||||||||||||||||||||
| 426 | case QVariant::ULongLong: executed 43 times by 2 tests: case QVariant::ULongLong:Executed by:
| 43 | ||||||||||||||||||||||||
| 427 | case QMetaType::UShort: executed 10 times by 1 test: case QMetaType::UShort:Executed by:
| 10 | ||||||||||||||||||||||||
| 428 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 429 | *str = QString::number(qMetaTypeUNumber(d)); | - | ||||||||||||||||||||||||
| 430 | break; executed 232 times by 5 tests: break;Executed by:
| 232 | ||||||||||||||||||||||||
| 431 | case QMetaType::Float: executed 39 times by 1 test: case QMetaType::Float:Executed by:
| 39 | ||||||||||||||||||||||||
| 432 | *str = QString::number(d->data.f, 'g', QLocale::FloatingPointShortest); | - | ||||||||||||||||||||||||
| 433 | break; executed 39 times by 1 test: break;Executed by:
| 39 | ||||||||||||||||||||||||
| 434 | case QVariant::Double: executed 120 times by 13 tests: case QVariant::Double:Executed by:
| 120 | ||||||||||||||||||||||||
| 435 | *str = QString::number(d->data.d, 'g', QLocale::FloatingPointShortest); | - | ||||||||||||||||||||||||
| 436 | break; executed 120 times by 13 tests: break;Executed by:
| 120 | ||||||||||||||||||||||||
| 437 | #if !defined(QT_NO_DATESTRING) | - | ||||||||||||||||||||||||
| 438 | case QVariant::Date: executed 5 times by 2 tests: case QVariant::Date:Executed by:
| 5 | ||||||||||||||||||||||||
| 439 | *str = v_cast<QDate>(d)->toString(Qt::ISODate); | - | ||||||||||||||||||||||||
| 440 | break; executed 5 times by 2 tests: break;Executed by:
| 5 | ||||||||||||||||||||||||
| 441 | case QVariant::Time: executed 3 times by 1 test: case QVariant::Time:Executed by:
| 3 | ||||||||||||||||||||||||
| 442 | *str = v_cast<QTime>(d)->toString(Qt::ISODate); | - | ||||||||||||||||||||||||
| 443 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 444 | case QVariant::DateTime: executed 11 times by 2 tests: case QVariant::DateTime:Executed by:
| 11 | ||||||||||||||||||||||||
| 445 | *str = v_cast<QDateTime>(d)->toString(Qt::ISODate); | - | ||||||||||||||||||||||||
| 446 | break; executed 11 times by 2 tests: break;Executed by:
| 11 | ||||||||||||||||||||||||
| 447 | #endif | - | ||||||||||||||||||||||||
| 448 | case QVariant::Bool: executed 77 times by 6 tests: case QVariant::Bool:Executed by:
| 77 | ||||||||||||||||||||||||
| 449 | *str = d->data.b ? QStringLiteral("true") : QStringLiteral("false"); executed 44 times by 6 tests: return qstring_literal_temp;Executed by:
executed 33 times by 4 tests: return qstring_literal_temp;Executed by:
| 33-44 | ||||||||||||||||||||||||
| 450 | break; executed 77 times by 6 tests: break;Executed by:
| 77 | ||||||||||||||||||||||||
| 451 | case QVariant::ByteArray: executed 25 times by 2 tests: case QVariant::ByteArray:Executed by:
| 25 | ||||||||||||||||||||||||
| 452 | *str = QString::fromUtf8(v_cast<QByteArray>(d)->constData()); | - | ||||||||||||||||||||||||
| 453 | break; executed 25 times by 2 tests: break;Executed by:
| 25 | ||||||||||||||||||||||||
| 454 | case QVariant::StringList: executed 18 times by 2 tests: case QVariant::StringList:Executed by:
| 18 | ||||||||||||||||||||||||
| 455 | if (v_cast<QStringList>(d)->count() == 1)
| 3-15 | ||||||||||||||||||||||||
| 456 | *str = v_cast<QStringList>(d)->at(0); executed 3 times by 1 test: *str = v_cast<QStringList>(d)->at(0);Executed by:
| 3 | ||||||||||||||||||||||||
| 457 | break; executed 18 times by 2 tests: break;Executed by:
| 18 | ||||||||||||||||||||||||
| 458 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 459 | case QVariant::Url: executed 8 times by 2 tests: case QVariant::Url:Executed by:
| 8 | ||||||||||||||||||||||||
| 460 | *str = v_cast<QUrl>(d)->toString(); | - | ||||||||||||||||||||||||
| 461 | break; executed 8 times by 2 tests: break;Executed by:
| 8 | ||||||||||||||||||||||||
| 462 | case QMetaType::QJsonValue: executed 2 times by 1 test: case QMetaType::QJsonValue:Executed by:
| 2 | ||||||||||||||||||||||||
| 463 | if (v_cast<QJsonValue>(d)->isString())
| 1 | ||||||||||||||||||||||||
| 464 | *str = v_cast<QJsonValue>(d)->toString(); executed 1 time by 1 test: *str = v_cast<QJsonValue>(d)->toString();Executed by:
| 1 | ||||||||||||||||||||||||
| 465 | else if (!v_cast<QJsonValue>(d)->isNull())
| 0-1 | ||||||||||||||||||||||||
| 466 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 467 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 468 | #endif | - | ||||||||||||||||||||||||
| 469 | case QVariant::Uuid: executed 19 times by 2 tests: case QVariant::Uuid:Executed by:
| 19 | ||||||||||||||||||||||||
| 470 | *str = v_cast<QUuid>(d)->toString(); | - | ||||||||||||||||||||||||
| 471 | break; executed 19 times by 2 tests: break;Executed by:
| 19 | ||||||||||||||||||||||||
| 472 | default: executed 20254 times by 37 tests: default:Executed by:
| 20254 | ||||||||||||||||||||||||
| 473 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
| 474 | { | - | ||||||||||||||||||||||||
| 475 | QMetaEnum en = metaEnumFromType(d->type); | - | ||||||||||||||||||||||||
| 476 | if (en.isValid()) {
| 10-20244 | ||||||||||||||||||||||||
| 477 | *str = QString::fromUtf8(en.valueToKey(qConvertToNumber(d, ok))); | - | ||||||||||||||||||||||||
| 478 | return *ok; executed 10 times by 1 test: return *ok;Executed by:
| 10 | ||||||||||||||||||||||||
| 479 | } | - | ||||||||||||||||||||||||
| 480 | } | - | ||||||||||||||||||||||||
| 481 | #endif | - | ||||||||||||||||||||||||
| 482 | return false; executed 20244 times by 37 tests: return false;Executed by:
| 20244 | ||||||||||||||||||||||||
| 483 | } | - | ||||||||||||||||||||||||
| 484 | break; executed 35283 times by 65 tests: break;Executed by:
| 35283 | ||||||||||||||||||||||||
| 485 | } | - | ||||||||||||||||||||||||
| 486 | case QVariant::Char: { executed 4 times by 2 tests: case QVariant::Char:Executed by:
| 4 | ||||||||||||||||||||||||
| 487 | QChar *c = static_cast<QChar *>(result); | - | ||||||||||||||||||||||||
| 488 | switch (d->type) { | - | ||||||||||||||||||||||||
| 489 | case QVariant::Int: executed 2 times by 1 test: case QVariant::Int:Executed by:
| 2 | ||||||||||||||||||||||||
| 490 | case QVariant::LongLong: executed 1 time by 1 test: case QVariant::LongLong:Executed by:
| 1 | ||||||||||||||||||||||||
| 491 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
| 492 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
| 493 | case QMetaType::Short: never executed: case QMetaType::Short: | 0 | ||||||||||||||||||||||||
| 494 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
| 495 | case QMetaType::Float: never executed: case QMetaType::Float: | 0 | ||||||||||||||||||||||||
| 496 | *c = QChar(ushort(qMetaTypeNumber(d))); | - | ||||||||||||||||||||||||
| 497 | break; executed 3 times by 2 tests: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 498 | case QVariant::UInt: never executed: case QVariant::UInt: | 0 | ||||||||||||||||||||||||
| 499 | case QVariant::ULongLong: executed 1 time by 1 test: case QVariant::ULongLong:Executed by:
| 1 | ||||||||||||||||||||||||
| 500 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
| 501 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
| 502 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 503 | *c = QChar(ushort(qMetaTypeUNumber(d))); | - | ||||||||||||||||||||||||
| 504 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 505 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 506 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 507 | } | - | ||||||||||||||||||||||||
| 508 | break; executed 4 times by 2 tests: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 509 | } | - | ||||||||||||||||||||||||
| 510 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
| 511 | case QVariant::Size: { executed 62 times by 5 tests: case QVariant::Size:Executed by:
| 62 | ||||||||||||||||||||||||
| 512 | QSize *s = static_cast<QSize *>(result); | - | ||||||||||||||||||||||||
| 513 | switch (d->type) { | - | ||||||||||||||||||||||||
| 514 | case QVariant::SizeF: executed 4 times by 1 test: case QVariant::SizeF:Executed by:
| 4 | ||||||||||||||||||||||||
| 515 | *s = v_cast<QSizeF>(d)->toSize(); | - | ||||||||||||||||||||||||
| 516 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 517 | default: executed 58 times by 4 tests: default:Executed by:
| 58 | ||||||||||||||||||||||||
| 518 | return false; executed 58 times by 4 tests: return false;Executed by:
| 58 | ||||||||||||||||||||||||
| 519 | } | - | ||||||||||||||||||||||||
| 520 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 521 | } | - | ||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||
| 523 | case QVariant::SizeF: { executed 23 times by 3 tests: case QVariant::SizeF:Executed by:
| 23 | ||||||||||||||||||||||||
| 524 | QSizeF *s = static_cast<QSizeF *>(result); | - | ||||||||||||||||||||||||
| 525 | switch (d->type) { | - | ||||||||||||||||||||||||
| 526 | case QVariant::Size: executed 21 times by 2 tests: case QVariant::Size:Executed by:
| 21 | ||||||||||||||||||||||||
| 527 | *s = QSizeF(*(v_cast<QSize>(d))); | - | ||||||||||||||||||||||||
| 528 | break; executed 21 times by 2 tests: break;Executed by:
| 21 | ||||||||||||||||||||||||
| 529 | default: executed 2 times by 1 test: default:Executed by:
| 2 | ||||||||||||||||||||||||
| 530 | return false; executed 2 times by 1 test: return false;Executed by:
| 2 | ||||||||||||||||||||||||
| 531 | } | - | ||||||||||||||||||||||||
| 532 | break; executed 21 times by 2 tests: break;Executed by:
| 21 | ||||||||||||||||||||||||
| 533 | } | - | ||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||
| 535 | case QVariant::Line: { executed 4 times by 1 test: case QVariant::Line:Executed by:
| 4 | ||||||||||||||||||||||||
| 536 | QLine *s = static_cast<QLine *>(result); | - | ||||||||||||||||||||||||
| 537 | switch (d->type) { | - | ||||||||||||||||||||||||
| 538 | case QVariant::LineF: executed 4 times by 1 test: case QVariant::LineF:Executed by:
| 4 | ||||||||||||||||||||||||
| 539 | *s = v_cast<QLineF>(d)->toLine(); | - | ||||||||||||||||||||||||
| 540 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 541 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 542 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 543 | } | - | ||||||||||||||||||||||||
| 544 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 545 | } | - | ||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||
| 547 | case QVariant::LineF: { executed 6 times by 2 tests: case QVariant::LineF:Executed by:
| 6 | ||||||||||||||||||||||||
| 548 | QLineF *s = static_cast<QLineF *>(result); | - | ||||||||||||||||||||||||
| 549 | switch (d->type) { | - | ||||||||||||||||||||||||
| 550 | case QVariant::Line: executed 4 times by 1 test: case QVariant::Line:Executed by:
| 4 | ||||||||||||||||||||||||
| 551 | *s = QLineF(*(v_cast<QLine>(d))); | - | ||||||||||||||||||||||||
| 552 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 553 | default: executed 2 times by 1 test: default:Executed by:
| 2 | ||||||||||||||||||||||||
| 554 | return false; executed 2 times by 1 test: return false;Executed by:
| 2 | ||||||||||||||||||||||||
| 555 | } | - | ||||||||||||||||||||||||
| 556 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 557 | } | - | ||||||||||||||||||||||||
| 558 | #endif | - | ||||||||||||||||||||||||
| 559 | case QVariant::StringList: executed 30 times by 26 tests: case QVariant::StringList:Executed by:
| 30 | ||||||||||||||||||||||||
| 560 | if (d->type == QVariant::List) {
| 0-30 | ||||||||||||||||||||||||
| 561 | QStringList *slst = static_cast<QStringList *>(result); | - | ||||||||||||||||||||||||
| 562 | const QVariantList *list = v_cast<QVariantList >(d); | - | ||||||||||||||||||||||||
| 563 | const int size = list->size(); | - | ||||||||||||||||||||||||
| 564 | slst->reserve(size); | - | ||||||||||||||||||||||||
| 565 | for (int i = 0; i < size; ++i)
| 0 | ||||||||||||||||||||||||
| 566 | slst->append(list->at(i).toString()); never executed: slst->append(list->at(i).toString()); | 0 | ||||||||||||||||||||||||
| 567 | } else if (d->type == QVariant::String) { never executed: end of block
| 0-30 | ||||||||||||||||||||||||
| 568 | QStringList *slst = static_cast<QStringList *>(result); | - | ||||||||||||||||||||||||
| 569 | *slst = QStringList(*v_cast<QString>(d)); | - | ||||||||||||||||||||||||
| 570 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 571 | return false; executed 30 times by 26 tests: return false;Executed by:
| 30 | ||||||||||||||||||||||||
| 572 | } | - | ||||||||||||||||||||||||
| 573 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 574 | case QVariant::Date: { executed 12673 times by 4 tests: case QVariant::Date:Executed by:
| 12673 | ||||||||||||||||||||||||
| 575 | QDate *dt = static_cast<QDate *>(result); | - | ||||||||||||||||||||||||
| 576 | if (d->type == QVariant::DateTime)
| 2-12671 | ||||||||||||||||||||||||
| 577 | *dt = v_cast<QDateTime>(d)->date(); executed 12671 times by 4 tests: *dt = v_cast<QDateTime>(d)->date();Executed by:
| 12671 | ||||||||||||||||||||||||
| 578 | #ifndef QT_NO_DATESTRING | - | ||||||||||||||||||||||||
| 579 | else if (d->type == QVariant::String)
| 0-2 | ||||||||||||||||||||||||
| 580 | *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate); executed 2 times by 1 test: *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);Executed by:
| 2 | ||||||||||||||||||||||||
| 581 | #endif | - | ||||||||||||||||||||||||
| 582 | else | - | ||||||||||||||||||||||||
| 583 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 584 | - | |||||||||||||||||||||||||
| 585 | return dt->isValid(); executed 12673 times by 4 tests: return dt->isValid();Executed by:
| 12673 | ||||||||||||||||||||||||
| 586 | } | - | ||||||||||||||||||||||||
| 587 | case QVariant::Time: { executed 10943 times by 5 tests: case QVariant::Time:Executed by:
| 10943 | ||||||||||||||||||||||||
| 588 | QTime *t = static_cast<QTime *>(result); | - | ||||||||||||||||||||||||
| 589 | switch (d->type) { | - | ||||||||||||||||||||||||
| 590 | case QVariant::DateTime: executed 10941 times by 5 tests: case QVariant::DateTime:Executed by:
| 10941 | ||||||||||||||||||||||||
| 591 | *t = v_cast<QDateTime>(d)->time(); | - | ||||||||||||||||||||||||
| 592 | break; executed 10941 times by 5 tests: break;Executed by:
| 10941 | ||||||||||||||||||||||||
| 593 | #ifndef QT_NO_DATESTRING | - | ||||||||||||||||||||||||
| 594 | case QVariant::String: executed 2 times by 1 test: case QVariant::String:Executed by:
| 2 | ||||||||||||||||||||||||
| 595 | *t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate); | - | ||||||||||||||||||||||||
| 596 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 597 | #endif | - | ||||||||||||||||||||||||
| 598 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 599 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 600 | } | - | ||||||||||||||||||||||||
| 601 | return t->isValid(); executed 10943 times by 5 tests: return t->isValid();Executed by:
| 10943 | ||||||||||||||||||||||||
| 602 | } | - | ||||||||||||||||||||||||
| 603 | case QVariant::DateTime: { executed 940 times by 7 tests: case QVariant::DateTime:Executed by:
| 940 | ||||||||||||||||||||||||
| 604 | QDateTime *dt = static_cast<QDateTime *>(result); | - | ||||||||||||||||||||||||
| 605 | switch (d->type) { | - | ||||||||||||||||||||||||
| 606 | #ifndef QT_NO_DATESTRING | - | ||||||||||||||||||||||||
| 607 | case QVariant::String: executed 9 times by 2 tests: case QVariant::String:Executed by:
| 9 | ||||||||||||||||||||||||
| 608 | *dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate); | - | ||||||||||||||||||||||||
| 609 | break; executed 9 times by 2 tests: break;Executed by:
| 9 | ||||||||||||||||||||||||
| 610 | #endif | - | ||||||||||||||||||||||||
| 611 | case QVariant::Date: executed 2 times by 2 tests: case QVariant::Date:Executed by:
| 2 | ||||||||||||||||||||||||
| 612 | *dt = QDateTime(*v_cast<QDate>(d)); | - | ||||||||||||||||||||||||
| 613 | break; executed 2 times by 2 tests: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 614 | default: executed 929 times by 5 tests: default:Executed by:
| 929 | ||||||||||||||||||||||||
| 615 | return false; executed 929 times by 5 tests: return false;Executed by:
| 929 | ||||||||||||||||||||||||
| 616 | } | - | ||||||||||||||||||||||||
| 617 | return dt->isValid(); executed 11 times by 3 tests: return dt->isValid();Executed by:
| 11 | ||||||||||||||||||||||||
| 618 | } | - | ||||||||||||||||||||||||
| 619 | case QVariant::ByteArray: { executed 611 times by 11 tests: case QVariant::ByteArray:Executed by:
| 611 | ||||||||||||||||||||||||
| 620 | QByteArray *ba = static_cast<QByteArray *>(result); | - | ||||||||||||||||||||||||
| 621 | switch (d->type) { | - | ||||||||||||||||||||||||
| 622 | case QVariant::String: executed 118 times by 6 tests: case QVariant::String:Executed by:
| 118 | ||||||||||||||||||||||||
| 623 | *ba = v_cast<QString>(d)->toUtf8(); | - | ||||||||||||||||||||||||
| 624 | break; executed 118 times by 6 tests: break;Executed by:
| 118 | ||||||||||||||||||||||||
| 625 | case QVariant::Double: executed 3 times by 1 test: case QVariant::Double:Executed by:
| 3 | ||||||||||||||||||||||||
| 626 | *ba = QByteArray::number(d->data.d, 'g', QLocale::FloatingPointShortest); | - | ||||||||||||||||||||||||
| 627 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 628 | case QMetaType::Float: executed 3 times by 1 test: case QMetaType::Float:Executed by:
| 3 | ||||||||||||||||||||||||
| 629 | *ba = QByteArray::number(d->data.f, 'g', QLocale::FloatingPointShortest); | - | ||||||||||||||||||||||||
| 630 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 631 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
| 632 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
| 633 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
| 634 | *ba = QByteArray(1, d->data.c); | - | ||||||||||||||||||||||||
| 635 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 636 | case QVariant::Int: executed 6 times by 4 tests: case QVariant::Int:Executed by:
| 6 | ||||||||||||||||||||||||
| 637 | case QVariant::LongLong: executed 249 times by 5 tests: case QVariant::LongLong:Executed by:
| 249 | ||||||||||||||||||||||||
| 638 | case QMetaType::Short: never executed: case QMetaType::Short: | 0 | ||||||||||||||||||||||||
| 639 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
| 640 | *ba = QByteArray::number(qMetaTypeNumber(d)); | - | ||||||||||||||||||||||||
| 641 | break; executed 255 times by 6 tests: break;Executed by:
| 255 | ||||||||||||||||||||||||
| 642 | case QVariant::UInt: executed 2 times by 1 test: case QVariant::UInt:Executed by:
| 2 | ||||||||||||||||||||||||
| 643 | case QVariant::ULongLong: executed 2 times by 1 test: case QVariant::ULongLong:Executed by:
| 2 | ||||||||||||||||||||||||
| 644 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
| 645 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 646 | *ba = QByteArray::number(qMetaTypeUNumber(d)); | - | ||||||||||||||||||||||||
| 647 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 648 | case QVariant::Bool: executed 3 times by 1 test: case QVariant::Bool:Executed by:
| 3 | ||||||||||||||||||||||||
| 649 | *ba = QByteArray(d->data.b ? "true" : "false"); | - | ||||||||||||||||||||||||
| 650 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 651 | default: executed 225 times by 4 tests: default:Executed by:
| 225 | ||||||||||||||||||||||||
| 652 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
| 653 | { | - | ||||||||||||||||||||||||
| 654 | QMetaEnum en = metaEnumFromType(d->type); | - | ||||||||||||||||||||||||
| 655 | if (en.isValid()) {
| 10-215 | ||||||||||||||||||||||||
| 656 | *ba = en.valueToKey(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
| 657 | return *ok; executed 10 times by 1 test: return *ok;Executed by:
| 10 | ||||||||||||||||||||||||
| 658 | } | - | ||||||||||||||||||||||||
| 659 | } | - | ||||||||||||||||||||||||
| 660 | #endif | - | ||||||||||||||||||||||||
| 661 | return false; executed 215 times by 3 tests: return false;Executed by:
| 215 | ||||||||||||||||||||||||
| 662 | } | - | ||||||||||||||||||||||||
| 663 | } | - | ||||||||||||||||||||||||
| 664 | break; executed 386 times by 8 tests: break;Executed by:
| 386 | ||||||||||||||||||||||||
| 665 | case QMetaType::Short: executed 28 times by 2 tests: case QMetaType::Short:Executed by:
| 28 | ||||||||||||||||||||||||
| 666 | *static_cast<short *>(result) = short(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
| 667 | return *ok; executed 28 times by 2 tests: return *ok;Executed by:
| 28 | ||||||||||||||||||||||||
| 668 | case QMetaType::Long: executed 1 time by 1 test: case QMetaType::Long:Executed by:
| 1 | ||||||||||||||||||||||||
| 669 | *static_cast<long *>(result) = long(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
| 670 | return *ok; executed 1 time by 1 test: return *ok;Executed by:
| 1 | ||||||||||||||||||||||||
| 671 | case QMetaType::UShort: executed 31 times by 1 test: case QMetaType::UShort:Executed by:
| 31 | ||||||||||||||||||||||||
| 672 | *static_cast<ushort *>(result) = ushort(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||||||||||||||
| 673 | return *ok; executed 31 times by 1 test: return *ok;Executed by:
| 31 | ||||||||||||||||||||||||
| 674 | case QMetaType::ULong: executed 7 times by 1 test: case QMetaType::ULong:Executed by:
| 7 | ||||||||||||||||||||||||
| 675 | *static_cast<ulong *>(result) = ulong(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||||||||||||||
| 676 | return *ok; executed 7 times by 1 test: return *ok;Executed by:
| 7 | ||||||||||||||||||||||||
| 677 | case QVariant::Int: executed 16313 times by 69 tests: case QVariant::Int:Executed by:
| 16313 | ||||||||||||||||||||||||
| 678 | *static_cast<int *>(result) = int(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
| 679 | return *ok; executed 16313 times by 69 tests: return *ok;Executed by:
| 16313 | ||||||||||||||||||||||||
| 680 | case QVariant::UInt: executed 189 times by 24 tests: case QVariant::UInt:Executed by:
| 189 | ||||||||||||||||||||||||
| 681 | *static_cast<uint *>(result) = uint(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||||||||||||||
| 682 | return *ok; executed 189 times by 24 tests: return *ok;Executed by:
| 189 | ||||||||||||||||||||||||
| 683 | case QVariant::LongLong: executed 10784 times by 15 tests: case QVariant::LongLong:Executed by:
| 10784 | ||||||||||||||||||||||||
| 684 | *static_cast<qlonglong *>(result) = qConvertToNumber(d, ok); | - | ||||||||||||||||||||||||
| 685 | return *ok; executed 10784 times by 15 tests: return *ok;Executed by:
| 10784 | ||||||||||||||||||||||||
| 686 | case QVariant::ULongLong: { executed 135 times by 12 tests: case QVariant::ULongLong:Executed by:
| 135 | ||||||||||||||||||||||||
| 687 | *static_cast<qulonglong *>(result) = qConvertToUnsignedNumber(d, ok); | - | ||||||||||||||||||||||||
| 688 | return *ok; executed 135 times by 12 tests: return *ok;Executed by:
| 135 | ||||||||||||||||||||||||
| 689 | } | - | ||||||||||||||||||||||||
| 690 | case QMetaType::SChar: { executed 1 time by 1 test: case QMetaType::SChar:Executed by:
| 1 | ||||||||||||||||||||||||
| 691 | signed char s = qConvertToNumber(d, ok); | - | ||||||||||||||||||||||||
| 692 | *static_cast<signed char*>(result) = s; | - | ||||||||||||||||||||||||
| 693 | return *ok; executed 1 time by 1 test: return *ok;Executed by:
| 1 | ||||||||||||||||||||||||
| 694 | } | - | ||||||||||||||||||||||||
| 695 | case QMetaType::UChar: { executed 1 time by 1 test: case QMetaType::UChar:Executed by:
| 1 | ||||||||||||||||||||||||
| 696 | *static_cast<uchar *>(result) = qConvertToUnsignedNumber(d, ok); | - | ||||||||||||||||||||||||
| 697 | return *ok; executed 1 time by 1 test: return *ok;Executed by:
| 1 | ||||||||||||||||||||||||
| 698 | } | - | ||||||||||||||||||||||||
| 699 | case QVariant::Bool: { executed 39499 times by 116 tests: case QVariant::Bool:Executed by:
| 39499 | ||||||||||||||||||||||||
| 700 | bool *b = static_cast<bool *>(result); | - | ||||||||||||||||||||||||
| 701 | switch(d->type) { | - | ||||||||||||||||||||||||
| 702 | case QVariant::ByteArray: executed 10 times by 1 test: case QVariant::ByteArray:Executed by:
| 10 | ||||||||||||||||||||||||
| 703 | *b = qt_convertToBool<QByteArray, QByteArray>(d); | - | ||||||||||||||||||||||||
| 704 | break; executed 10 times by 1 test: break;Executed by:
| 10 | ||||||||||||||||||||||||
| 705 | case QVariant::String: executed 20 times by 3 tests: case QVariant::String:Executed by:
| 20 | ||||||||||||||||||||||||
| 706 | *b = qt_convertToBool<QString, QLatin1String>(d); | - | ||||||||||||||||||||||||
| 707 | break; executed 20 times by 3 tests: break;Executed by:
| 20 | ||||||||||||||||||||||||
| 708 | case QVariant::Char: executed 2 times by 1 test: case QVariant::Char:Executed by:
| 2 | ||||||||||||||||||||||||
| 709 | *b = !v_cast<QChar>(d)->isNull(); | - | ||||||||||||||||||||||||
| 710 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 711 | case QVariant::Double: executed 11 times by 2 tests: case QVariant::Double:Executed by:
| 11 | ||||||||||||||||||||||||
| 712 | case QVariant::Int: executed 35 times by 4 tests: case QVariant::Int:Executed by:
| 35 | ||||||||||||||||||||||||
| 713 | case QVariant::LongLong: executed 16 times by 2 tests: case QVariant::LongLong:Executed by:
| 16 | ||||||||||||||||||||||||
| 714 | case QMetaType::Char: executed 4 times by 1 test: case QMetaType::Char:Executed by:
| 4 | ||||||||||||||||||||||||
| 715 | case QMetaType::SChar: executed 8 times by 1 test: case QMetaType::SChar:Executed by:
| 8 | ||||||||||||||||||||||||
| 716 | case QMetaType::Short: executed 8 times by 1 test: case QMetaType::Short:Executed by:
| 8 | ||||||||||||||||||||||||
| 717 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
| 718 | case QMetaType::Float: executed 6 times by 1 test: case QMetaType::Float:Executed by:
| 6 | ||||||||||||||||||||||||
| 719 | *b = qMetaTypeNumber(d) != Q_INT64_C(0); | - | ||||||||||||||||||||||||
| 720 | break; executed 88 times by 6 tests: break;Executed by:
| 88 | ||||||||||||||||||||||||
| 721 | case QVariant::UInt: executed 1266 times by 12 tests: case QVariant::UInt:Executed by:
| 1266 | ||||||||||||||||||||||||
| 722 | case QVariant::ULongLong: executed 10 times by 1 test: case QVariant::ULongLong:Executed by:
| 10 | ||||||||||||||||||||||||
| 723 | case QMetaType::UChar: executed 8 times by 1 test: case QMetaType::UChar:Executed by:
| 8 | ||||||||||||||||||||||||
| 724 | case QMetaType::UShort: executed 8 times by 1 test: case QMetaType::UShort:Executed by:
| 8 | ||||||||||||||||||||||||
| 725 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 726 | *b = qMetaTypeUNumber(d) != Q_UINT64_C(0); | - | ||||||||||||||||||||||||
| 727 | break; executed 1292 times by 12 tests: break;Executed by:
| 1292 | ||||||||||||||||||||||||
| 728 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 729 | case QMetaType::QJsonValue: executed 2 times by 1 test: case QMetaType::QJsonValue:Executed by:
| 2 | ||||||||||||||||||||||||
| 730 | *b = v_cast<QJsonValue>(d)->toBool(false); | - | ||||||||||||||||||||||||
| 731 | if (!v_cast<QJsonValue>(d)->isBool())
| 0-2 | ||||||||||||||||||||||||
| 732 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 733 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 734 | #endif | - | ||||||||||||||||||||||||
| 735 | default: executed 38085 times by 111 tests: default:Executed by:
| 38085 | ||||||||||||||||||||||||
| 736 | *b = false; | - | ||||||||||||||||||||||||
| 737 | return false; executed 38085 times by 111 tests: return false;Executed by:
| 38085 | ||||||||||||||||||||||||
| 738 | } | - | ||||||||||||||||||||||||
| 739 | break; executed 1414 times by 17 tests: break;Executed by:
| 1414 | ||||||||||||||||||||||||
| 740 | } | - | ||||||||||||||||||||||||
| 741 | case QVariant::Double: { executed 635 times by 17 tests: case QVariant::Double:Executed by:
| 635 | ||||||||||||||||||||||||
| 742 | double *f = static_cast<double *>(result); | - | ||||||||||||||||||||||||
| 743 | switch (d->type) { | - | ||||||||||||||||||||||||
| 744 | case QVariant::String: executed 370 times by 13 tests: case QVariant::String:Executed by:
| 370 | ||||||||||||||||||||||||
| 745 | *f = v_cast<QString>(d)->toDouble(ok); | - | ||||||||||||||||||||||||
| 746 | break; executed 370 times by 13 tests: break;Executed by:
| 370 | ||||||||||||||||||||||||
| 747 | case QVariant::ByteArray: executed 3 times by 1 test: case QVariant::ByteArray:Executed by:
| 3 | ||||||||||||||||||||||||
| 748 | *f = v_cast<QByteArray>(d)->toDouble(ok); | - | ||||||||||||||||||||||||
| 749 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 750 | case QVariant::Bool: executed 8 times by 1 test: case QVariant::Bool:Executed by:
| 8 | ||||||||||||||||||||||||
| 751 | *f = double(d->data.b); | - | ||||||||||||||||||||||||
| 752 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||||||||
| 753 | case QMetaType::Float: executed 9 times by 2 tests: case QMetaType::Float:Executed by:
| 9 | ||||||||||||||||||||||||
| 754 | *f = double(d->data.f); | - | ||||||||||||||||||||||||
| 755 | break; executed 9 times by 2 tests: break;Executed by:
| 9 | ||||||||||||||||||||||||
| 756 | case QVariant::LongLong: executed 10 times by 2 tests: case QVariant::LongLong:Executed by:
| 10 | ||||||||||||||||||||||||
| 757 | case QVariant::Int: executed 47 times by 4 tests: case QVariant::Int:Executed by:
| 47 | ||||||||||||||||||||||||
| 758 | case QMetaType::Char: executed 4 times by 1 test: case QMetaType::Char:Executed by:
| 4 | ||||||||||||||||||||||||
| 759 | case QMetaType::SChar: executed 8 times by 1 test: case QMetaType::SChar:Executed by:
| 8 | ||||||||||||||||||||||||
| 760 | case QMetaType::Short: executed 9 times by 1 test: case QMetaType::Short:Executed by:
| 9 | ||||||||||||||||||||||||
| 761 | case QMetaType::Long: executed 3 times by 1 test: case QMetaType::Long:Executed by:
| 3 | ||||||||||||||||||||||||
| 762 | *f = double(qMetaTypeNumber(d)); | - | ||||||||||||||||||||||||
| 763 | break; executed 81 times by 5 tests: break;Executed by:
| 81 | ||||||||||||||||||||||||
| 764 | case QVariant::UInt: executed 6 times by 1 test: case QVariant::UInt:Executed by:
| 6 | ||||||||||||||||||||||||
| 765 | case QVariant::ULongLong: executed 10 times by 1 test: case QVariant::ULongLong:Executed by:
| 10 | ||||||||||||||||||||||||
| 766 | case QMetaType::UChar: executed 8 times by 1 test: case QMetaType::UChar:Executed by:
| 8 | ||||||||||||||||||||||||
| 767 | case QMetaType::UShort: executed 8 times by 1 test: case QMetaType::UShort:Executed by:
| 8 | ||||||||||||||||||||||||
| 768 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 769 | *f = double(qMetaTypeUNumber(d)); | - | ||||||||||||||||||||||||
| 770 | break; executed 32 times by 1 test: break;Executed by:
| 32 | ||||||||||||||||||||||||
| 771 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 772 | case QMetaType::QJsonValue: executed 2 times by 1 test: case QMetaType::QJsonValue:Executed by:
| 2 | ||||||||||||||||||||||||
| 773 | *f = v_cast<QJsonValue>(d)->toDouble(0.0); | - | ||||||||||||||||||||||||
| 774 | if (!v_cast<QJsonValue>(d)->isDouble())
| 1 | ||||||||||||||||||||||||
| 775 | return false; executed 1 time by 1 test: return false;Executed by:
| 1 | ||||||||||||||||||||||||
| 776 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 777 | #endif | - | ||||||||||||||||||||||||
| 778 | default: executed 130 times by 1 test: default:Executed by:
| 130 | ||||||||||||||||||||||||
| 779 | *f = 0.0; | - | ||||||||||||||||||||||||
| 780 | return false; executed 130 times by 1 test: return false;Executed by:
| 130 | ||||||||||||||||||||||||
| 781 | } | - | ||||||||||||||||||||||||
| 782 | break; executed 504 times by 17 tests: break;Executed by:
| 504 | ||||||||||||||||||||||||
| 783 | } | - | ||||||||||||||||||||||||
| 784 | case QMetaType::Float: { executed 25 times by 3 tests: case QMetaType::Float:Executed by:
| 25 | ||||||||||||||||||||||||
| 785 | float *f = static_cast<float *>(result); | - | ||||||||||||||||||||||||
| 786 | switch (d->type) { | - | ||||||||||||||||||||||||
| 787 | case QVariant::String: executed 7 times by 2 tests: case QVariant::String:Executed by:
| 7 | ||||||||||||||||||||||||
| 788 | *f = v_cast<QString>(d)->toFloat(ok); | - | ||||||||||||||||||||||||
| 789 | break; executed 7 times by 2 tests: break;Executed by:
| 7 | ||||||||||||||||||||||||
| 790 | case QVariant::ByteArray: executed 3 times by 1 test: case QVariant::ByteArray:Executed by:
| 3 | ||||||||||||||||||||||||
| 791 | *f = v_cast<QByteArray>(d)->toFloat(ok); | - | ||||||||||||||||||||||||
| 792 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 793 | case QVariant::Bool: never executed: case QVariant::Bool: | 0 | ||||||||||||||||||||||||
| 794 | *f = float(d->data.b); | - | ||||||||||||||||||||||||
| 795 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 796 | case QVariant::Double: executed 3 times by 1 test: case QVariant::Double:Executed by:
| 3 | ||||||||||||||||||||||||
| 797 | *f = float(d->data.d); | - | ||||||||||||||||||||||||
| 798 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 799 | case QVariant::LongLong: never executed: case QVariant::LongLong: | 0 | ||||||||||||||||||||||||
| 800 | case QVariant::Int: executed 3 times by 1 test: case QVariant::Int:Executed by:
| 3 | ||||||||||||||||||||||||
| 801 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
| 802 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
| 803 | case QMetaType::Short: executed 1 time by 1 test: case QMetaType::Short:Executed by:
| 1 | ||||||||||||||||||||||||
| 804 | case QMetaType::Long: executed 2 times by 1 test: case QMetaType::Long:Executed by:
| 2 | ||||||||||||||||||||||||
| 805 | *f = float(qMetaTypeNumber(d)); | - | ||||||||||||||||||||||||
| 806 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||||||||||||||
| 807 | case QVariant::UInt: executed 1 time by 1 test: case QVariant::UInt:Executed by:
| 1 | ||||||||||||||||||||||||
| 808 | case QVariant::ULongLong: executed 1 time by 1 test: case QVariant::ULongLong:Executed by:
| 1 | ||||||||||||||||||||||||
| 809 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
| 810 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
| 811 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 812 | *f = float(qMetaTypeUNumber(d)); | - | ||||||||||||||||||||||||
| 813 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 814 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 815 | case QMetaType::QJsonValue: executed 2 times by 1 test: case QMetaType::QJsonValue:Executed by:
| 2 | ||||||||||||||||||||||||
| 816 | *f = v_cast<QJsonValue>(d)->toDouble(0.0); | - | ||||||||||||||||||||||||
| 817 | if (!v_cast<QJsonValue>(d)->isDouble())
| 1 | ||||||||||||||||||||||||
| 818 | return false; executed 1 time by 1 test: return false;Executed by:
| 1 | ||||||||||||||||||||||||
| 819 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 820 | #endif | - | ||||||||||||||||||||||||
| 821 | default: executed 2 times by 1 test: default:Executed by:
| 2 | ||||||||||||||||||||||||
| 822 | *f = 0.0f; | - | ||||||||||||||||||||||||
| 823 | return false; executed 2 times by 1 test: return false;Executed by:
| 2 | ||||||||||||||||||||||||
| 824 | } | - | ||||||||||||||||||||||||
| 825 | break; executed 22 times by 2 tests: break;Executed by:
| 22 | ||||||||||||||||||||||||
| 826 | } | - | ||||||||||||||||||||||||
| 827 | case QVariant::List: executed 489 times by 6 tests: case QVariant::List:Executed by:
| 489 | ||||||||||||||||||||||||
| 828 | if (d->type == QVariant::StringList) {
| 0-489 | ||||||||||||||||||||||||
| 829 | QVariantList *lst = static_cast<QVariantList *>(result); | - | ||||||||||||||||||||||||
| 830 | const QStringList *slist = v_cast<QStringList>(d); | - | ||||||||||||||||||||||||
| 831 | const int size = slist->size(); | - | ||||||||||||||||||||||||
| 832 | lst->reserve(size); | - | ||||||||||||||||||||||||
| 833 | for (int i = 0; i < size; ++i)
| 489-813 | ||||||||||||||||||||||||
| 834 | lst->append(QVariant(slist->at(i))); executed 813 times by 6 tests: lst->append(QVariant(slist->at(i)));Executed by:
| 813 | ||||||||||||||||||||||||
| 835 | } else if (qstrcmp(QMetaType::typeName(d->type), "QList<QVariant>") == 0) { executed 489 times by 6 tests: end of blockExecuted by:
| 0-489 | ||||||||||||||||||||||||
| 836 | *static_cast<QVariantList *>(result) = | - | ||||||||||||||||||||||||
| 837 | *static_cast<QList<QVariant> *>(d->data.shared->ptr); | - | ||||||||||||||||||||||||
| 838 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 839 | } else if (d->type == QMetaType::QJsonValue) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 840 | if (!v_cast<QJsonValue>(d)->isArray())
| 0 | ||||||||||||||||||||||||
| 841 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 842 | *static_cast<QVariantList *>(result) = v_cast<QJsonValue>(d)->toArray().toVariantList(); | - | ||||||||||||||||||||||||
| 843 | } else if (d->type == QMetaType::QJsonArray) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 844 | *static_cast<QVariantList *>(result) = v_cast<QJsonArray>(d)->toVariantList(); | - | ||||||||||||||||||||||||
| 845 | #endif | - | ||||||||||||||||||||||||
| 846 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 847 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 848 | } | - | ||||||||||||||||||||||||
| 849 | break; executed 489 times by 6 tests: break;Executed by:
| 489 | ||||||||||||||||||||||||
| 850 | case QVariant::Map: executed 2 times by 1 test: case QVariant::Map:Executed by:
| 2 | ||||||||||||||||||||||||
| 851 | if (qstrcmp(QMetaType::typeName(d->type), "QMap<QString, QVariant>") == 0) {
| 0-2 | ||||||||||||||||||||||||
| 852 | *static_cast<QVariantMap *>(result) = | - | ||||||||||||||||||||||||
| 853 | *static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr); | - | ||||||||||||||||||||||||
| 854 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 855 | } else if (d->type == QMetaType::QJsonValue) { never executed: end of block
| 0-2 | ||||||||||||||||||||||||
| 856 | if (!v_cast<QJsonValue>(d)->isObject())
| 0 | ||||||||||||||||||||||||
| 857 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 858 | *static_cast<QVariantMap *>(result) = v_cast<QJsonValue>(d)->toObject().toVariantMap(); | - | ||||||||||||||||||||||||
| 859 | } else if (d->type == QMetaType::QJsonObject) { never executed: end of block
| 0-2 | ||||||||||||||||||||||||
| 860 | *static_cast<QVariantMap *>(result) = v_cast<QJsonObject>(d)->toVariantMap(); | - | ||||||||||||||||||||||||
| 861 | #endif | - | ||||||||||||||||||||||||
| 862 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 863 | return false; executed 2 times by 1 test: return false;Executed by:
| 2 | ||||||||||||||||||||||||
| 864 | } | - | ||||||||||||||||||||||||
| 865 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 866 | case QVariant::Hash: never executed: case QVariant::Hash: | 0 | ||||||||||||||||||||||||
| 867 | if (qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0) {
| 0 | ||||||||||||||||||||||||
| 868 | *static_cast<QVariantHash *>(result) = | - | ||||||||||||||||||||||||
| 869 | *static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr); | - | ||||||||||||||||||||||||
| 870 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 871 | } else if (d->type == QMetaType::QJsonValue) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 872 | if (!v_cast<QJsonValue>(d)->isObject())
| 0 | ||||||||||||||||||||||||
| 873 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 874 | *static_cast<QVariantHash *>(result) = v_cast<QJsonValue>(d)->toObject().toVariantHash(); | - | ||||||||||||||||||||||||
| 875 | } else if (d->type == QMetaType::QJsonObject) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 876 | *static_cast<QVariantHash *>(result) = v_cast<QJsonObject>(d)->toVariantHash(); | - | ||||||||||||||||||||||||
| 877 | #endif | - | ||||||||||||||||||||||||
| 878 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 879 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 880 | } | - | ||||||||||||||||||||||||
| 881 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 882 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
| 883 | case QVariant::Rect: executed 8 times by 4 tests: case QVariant::Rect:Executed by:
| 8 | ||||||||||||||||||||||||
| 884 | if (d->type == QVariant::RectF)
| 0-8 | ||||||||||||||||||||||||
| 885 | *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect(); executed 8 times by 4 tests: *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect();Executed by:
| 8 | ||||||||||||||||||||||||
| 886 | else | - | ||||||||||||||||||||||||
| 887 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 888 | break; executed 8 times by 4 tests: break;Executed by:
| 8 | ||||||||||||||||||||||||
| 889 | case QVariant::RectF: executed 3 times by 2 tests: case QVariant::RectF:Executed by:
| 3 | ||||||||||||||||||||||||
| 890 | if (d->type == QVariant::Rect)
| 1-2 | ||||||||||||||||||||||||
| 891 | *static_cast<QRectF *>(result) = *v_cast<QRect>(d); executed 1 time by 1 test: *static_cast<QRectF *>(result) = *v_cast<QRect>(d);Executed by:
| 1 | ||||||||||||||||||||||||
| 892 | else | - | ||||||||||||||||||||||||
| 893 | return false; executed 2 times by 1 test: return false;Executed by:
| 2 | ||||||||||||||||||||||||
| 894 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 895 | case QVariant::PointF: executed 4 times by 2 tests: case QVariant::PointF:Executed by:
| 4 | ||||||||||||||||||||||||
| 896 | if (d->type == QVariant::Point)
| 0-4 | ||||||||||||||||||||||||
| 897 | *static_cast<QPointF *>(result) = *v_cast<QPoint>(d); never executed: *static_cast<QPointF *>(result) = *v_cast<QPoint>(d); | 0 | ||||||||||||||||||||||||
| 898 | else | - | ||||||||||||||||||||||||
| 899 | return false; executed 4 times by 2 tests: return false;Executed by:
| 4 | ||||||||||||||||||||||||
| 900 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 901 | case QVariant::Point: executed 28 times by 3 tests: case QVariant::Point:Executed by:
| 28 | ||||||||||||||||||||||||
| 902 | if (d->type == QVariant::PointF)
| 0-28 | ||||||||||||||||||||||||
| 903 | *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint(); executed 28 times by 3 tests: *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint();Executed by:
| 28 | ||||||||||||||||||||||||
| 904 | else | - | ||||||||||||||||||||||||
| 905 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 906 | break; executed 28 times by 3 tests: break;Executed by:
| 28 | ||||||||||||||||||||||||
| 907 | case QMetaType::Char: executed 1 time by 1 test: case QMetaType::Char:Executed by:
| 1 | ||||||||||||||||||||||||
| 908 | { | - | ||||||||||||||||||||||||
| 909 | *static_cast<qint8 *>(result) = qint8(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
| 910 | return *ok; executed 1 time by 1 test: return *ok;Executed by:
| 1 | ||||||||||||||||||||||||
| 911 | } | - | ||||||||||||||||||||||||
| 912 | #endif | - | ||||||||||||||||||||||||
| 913 | case QVariant::Uuid: executed 2 times by 2 tests: case QVariant::Uuid:Executed by:
| 2 | ||||||||||||||||||||||||
| 914 | switch (d->type) { | - | ||||||||||||||||||||||||
| 915 | case QVariant::String: executed 2 times by 2 tests: case QVariant::String:Executed by:
| 2 | ||||||||||||||||||||||||
| 916 | *static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d)); | - | ||||||||||||||||||||||||
| 917 | break; executed 2 times by 2 tests: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 918 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 919 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 920 | } | - | ||||||||||||||||||||||||
| 921 | break; executed 2 times by 2 tests: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 922 | default: executed 274114 times by 97 tests: default:Executed by:
| 274114 | ||||||||||||||||||||||||
| 923 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
| 924 | if (d->type == QVariant::String || d->type == QVariant::ByteArray) {
| 7-274102 | ||||||||||||||||||||||||
| 925 | QMetaEnum en = metaEnumFromType(t); | - | ||||||||||||||||||||||||
| 926 | if (en.isValid()) {
| 2-17 | ||||||||||||||||||||||||
| 927 | QByteArray keys = (d->type == QVariant::String) ? v_cast<QString>(d)->toUtf8() : *v_cast<QByteArray>(d);
| 7-10 | ||||||||||||||||||||||||
| 928 | int value = en.keysToValue(keys.constData(), ok); | - | ||||||||||||||||||||||||
| 929 | if (*ok) {
| 0-17 | ||||||||||||||||||||||||
| 930 | switch (QMetaType::sizeOf(t)) { | - | ||||||||||||||||||||||||
| 931 | case 1: executed 2 times by 1 test: case 1:Executed by:
| 2 | ||||||||||||||||||||||||
| 932 | *static_cast<signed char *>(result) = value; | - | ||||||||||||||||||||||||
| 933 | return true; executed 2 times by 1 test: return true;Executed by:
| 2 | ||||||||||||||||||||||||
| 934 | case 2: executed 2 times by 1 test: case 2:Executed by:
| 2 | ||||||||||||||||||||||||
| 935 | *static_cast<qint16 *>(result) = value; | - | ||||||||||||||||||||||||
| 936 | return true; executed 2 times by 1 test: return true;Executed by:
| 2 | ||||||||||||||||||||||||
| 937 | case 4: executed 4 times by 1 test: case 4:Executed by:
| 4 | ||||||||||||||||||||||||
| 938 | *static_cast<qint32 *>(result) = value; | - | ||||||||||||||||||||||||
| 939 | return true; executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||
| 940 | case 8: executed 9 times by 1 test: case 8:Executed by:
| 9 | ||||||||||||||||||||||||
| 941 | *static_cast<qint64 *>(result) = value; | - | ||||||||||||||||||||||||
| 942 | return true; executed 9 times by 1 test: return true;Executed by:
| 9 | ||||||||||||||||||||||||
| 943 | } | - | ||||||||||||||||||||||||
| 944 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 945 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 946 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 947 | #endif | - | ||||||||||||||||||||||||
| 948 | if (QMetaType::typeFlags(t) & QMetaType::IsEnumeration) {
| 40-274057 | ||||||||||||||||||||||||
| 949 | qlonglong value = qConvertToNumber(d, ok); | - | ||||||||||||||||||||||||
| 950 | if (*ok) {
| 0-40 | ||||||||||||||||||||||||
| 951 | switch (QMetaType::sizeOf(t)) { | - | ||||||||||||||||||||||||
| 952 | case 1: executed 4 times by 1 test: case 1:Executed by:
| 4 | ||||||||||||||||||||||||
| 953 | *static_cast<signed char *>(result) = value; | - | ||||||||||||||||||||||||
| 954 | return true; executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||
| 955 | case 2: executed 4 times by 1 test: case 2:Executed by:
| 4 | ||||||||||||||||||||||||
| 956 | *static_cast<qint16 *>(result) = value; | - | ||||||||||||||||||||||||
| 957 | return true; executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||
| 958 | case 4: executed 12 times by 1 test: case 4:Executed by:
| 12 | ||||||||||||||||||||||||
| 959 | *static_cast<qint32 *>(result) = value; | - | ||||||||||||||||||||||||
| 960 | return true; executed 12 times by 1 test: return true;Executed by:
| 12 | ||||||||||||||||||||||||
| 961 | case 8: executed 20 times by 1 test: case 8:Executed by:
| 20 | ||||||||||||||||||||||||
| 962 | *static_cast<qint64 *>(result) = value; | - | ||||||||||||||||||||||||
| 963 | return true; executed 20 times by 1 test: return true;Executed by:
| 20 | ||||||||||||||||||||||||
| 964 | } | - | ||||||||||||||||||||||||
| 965 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 966 | return *ok; never executed: return *ok; | 0 | ||||||||||||||||||||||||
| 967 | } | - | ||||||||||||||||||||||||
| 968 | return false; executed 274057 times by 97 tests: return false;Executed by:
| 274057 | ||||||||||||||||||||||||
| 969 | } | - | ||||||||||||||||||||||||
| 970 | return true; executed 38182 times by 84 tests: return true;Executed by:
| 38182 | ||||||||||||||||||||||||
| 971 | } | - | ||||||||||||||||||||||||
| 972 | - | |||||||||||||||||||||||||
| 973 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
| 974 | static void streamDebug(QDebug dbg, const QVariant &v) | - | ||||||||||||||||||||||||
| 975 | { | - | ||||||||||||||||||||||||
| 976 | QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); | - | ||||||||||||||||||||||||
| 977 | QVariantDebugStream<CoreTypesFilter> stream(dbg, d); | - | ||||||||||||||||||||||||
| 978 | QMetaTypeSwitcher::switcher<void>(stream, d->type, 0); | - | ||||||||||||||||||||||||
| 979 | } executed 51 times by 2 tests: end of blockExecuted by:
| 51 | ||||||||||||||||||||||||
| 980 | #endif | - | ||||||||||||||||||||||||
| 981 | - | |||||||||||||||||||||||||
| 982 | const QVariant::Handler qt_kernel_variant_handler = { | - | ||||||||||||||||||||||||
| 983 | construct, | - | ||||||||||||||||||||||||
| 984 | clear, | - | ||||||||||||||||||||||||
| 985 | isNull, | - | ||||||||||||||||||||||||
| 986 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 987 | 0, | - | ||||||||||||||||||||||||
| 988 | 0, | - | ||||||||||||||||||||||||
| 989 | #endif | - | ||||||||||||||||||||||||
| 990 | compare, | - | ||||||||||||||||||||||||
| 991 | convert, | - | ||||||||||||||||||||||||
| 992 | 0, | - | ||||||||||||||||||||||||
| 993 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
| 994 | streamDebug | - | ||||||||||||||||||||||||
| 995 | #else | - | ||||||||||||||||||||||||
| 996 | 0 | - | ||||||||||||||||||||||||
| 997 | #endif | - | ||||||||||||||||||||||||
| 998 | }; | - | ||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||
| 1000 | static never executed: void dummyConstruct(QVariant::Private *, const void *) { Q_ASSERT_X(false, "QVariant", "Trying to construct an unknown type"); }end of blocknever executed: end of block | 0 | ||||||||||||||||||||||||
| 1001 | static never executed: void dummyClear(QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to clear an unknown type"); }end of blocknever executed: end of block | 0 | ||||||||||||||||||||||||
| 1002 | static never executed: bool dummyIsNull(const QVariant::Private *d) { Q_ASSERT_X(false, "QVariant::isNull", "Trying to call isNull on an unknown type"); return d->is_null; }return d->is_null;never executed: return d->is_null; | 0 | ||||||||||||||||||||||||
| 1003 | static never executed: bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to compare an unknown types"); return false; }return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1004 | static never executed: bool dummyConvert(const QVariant::Private *, int, void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; }return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1005 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
| 1006 | static never executed: void dummyStreamDebug(QDebug, const QVariant &) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); }end of blocknever executed: end of block | 0 | ||||||||||||||||||||||||
| 1007 | #endif | - | ||||||||||||||||||||||||
| 1008 | const QVariant::Handler qt_dummy_variant_handler = { | - | ||||||||||||||||||||||||
| 1009 | dummyConstruct, | - | ||||||||||||||||||||||||
| 1010 | dummyClear, | - | ||||||||||||||||||||||||
| 1011 | dummyIsNull, | - | ||||||||||||||||||||||||
| 1012 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 1013 | 0, | - | ||||||||||||||||||||||||
| 1014 | 0, | - | ||||||||||||||||||||||||
| 1015 | #endif | - | ||||||||||||||||||||||||
| 1016 | dummyCompare, | - | ||||||||||||||||||||||||
| 1017 | dummyConvert, | - | ||||||||||||||||||||||||
| 1018 | 0, | - | ||||||||||||||||||||||||
| 1019 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
| 1020 | dummyStreamDebug | - | ||||||||||||||||||||||||
| 1021 | #else | - | ||||||||||||||||||||||||
| 1022 | 0 | - | ||||||||||||||||||||||||
| 1023 | #endif | - | ||||||||||||||||||||||||
| 1024 | }; | - | ||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||
| 1026 | static void customConstruct(QVariant::Private *d, const void *copy) | - | ||||||||||||||||||||||||
| 1027 | { | - | ||||||||||||||||||||||||
| 1028 | const QMetaType type(d->type); | - | ||||||||||||||||||||||||
| 1029 | const uint size = type.sizeOf(); | - | ||||||||||||||||||||||||
| 1030 | if (!size) {
| 18-108391 | ||||||||||||||||||||||||
| 1031 | qWarning("Trying to construct an instance of an invalid type, type id: %i", d->type); | - | ||||||||||||||||||||||||
| 1032 | d->type = QVariant::Invalid; | - | ||||||||||||||||||||||||
| 1033 | return; executed 18 times by 3 tests: return;Executed by:
| 18 | ||||||||||||||||||||||||
| 1034 | } | - | ||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||
| 1036 | // this logic should match with QVariantIntegrator::CanUseInternalSpace | - | ||||||||||||||||||||||||
| 1037 | if (size <= sizeof(QVariant::Private::Data)
| 3609-104782 | ||||||||||||||||||||||||
| 1038 | && (type.flags() & (QMetaType::MovableType | QMetaType::IsEnumeration))) { | - | ||||||||||||||||||||||||
| 1039 | type.construct(&d->data.ptr, copy); | - | ||||||||||||||||||||||||
| 1040 | d->is_shared = false; | - | ||||||||||||||||||||||||
| 1041 | } else { executed 104594 times by 121 tests: end of blockExecuted by:
| 104594 | ||||||||||||||||||||||||
| 1042 | void *ptr = type.create(copy); | - | ||||||||||||||||||||||||
| 1043 | d->is_shared = true; | - | ||||||||||||||||||||||||
| 1044 | d->data.shared = new QVariant::PrivateShared(ptr); | - | ||||||||||||||||||||||||
| 1045 | } executed 3797 times by 174 tests: end of blockExecuted by:
| 3797 | ||||||||||||||||||||||||
| 1046 | } | - | ||||||||||||||||||||||||
| 1047 | - | |||||||||||||||||||||||||
| 1048 | static void customClear(QVariant::Private *d) | - | ||||||||||||||||||||||||
| 1049 | { | - | ||||||||||||||||||||||||
| 1050 | if (!d->is_shared) {
| 3793-146641 | ||||||||||||||||||||||||
| 1051 | QMetaType::destruct(d->type, &d->data.ptr); | - | ||||||||||||||||||||||||
| 1052 | } else { executed 146641 times by 144 tests: end of blockExecuted by:
| 146641 | ||||||||||||||||||||||||
| 1053 | QMetaType::destroy(d->type, d->data.shared->ptr); | - | ||||||||||||||||||||||||
| 1054 | delete d->data.shared; | - | ||||||||||||||||||||||||
| 1055 | } executed 3793 times by 176 tests: end of blockExecuted by:
| 3793 | ||||||||||||||||||||||||
| 1056 | } | - | ||||||||||||||||||||||||
| 1057 | - | |||||||||||||||||||||||||
| 1058 | static bool customIsNull(const QVariant::Private *d) | - | ||||||||||||||||||||||||
| 1059 | { | - | ||||||||||||||||||||||||
| 1060 | return d->is_null; executed 398 times by 10 tests: return d->is_null;Executed by:
| 398 | ||||||||||||||||||||||||
| 1061 | } | - | ||||||||||||||||||||||||
| 1062 | - | |||||||||||||||||||||||||
| 1063 | static bool customCompare(const QVariant::Private *a, const QVariant::Private *b) | - | ||||||||||||||||||||||||
| 1064 | { | - | ||||||||||||||||||||||||
| 1065 | const char *const typeName = QMetaType::typeName(a->type); | - | ||||||||||||||||||||||||
| 1066 | if (Q_UNLIKELY(!typeName) && Q_LIKELY(!QMetaType::isRegistered(a->type)))
| 0-349 | ||||||||||||||||||||||||
| 1067 | qFatal("QVariant::compare: type %d unknown to QVariant.", a->type); never executed: QMessageLogger(__FILE__, 1067, __PRETTY_FUNCTION__).fatal("QVariant::compare: type %d unknown to QVariant.", a->type); | 0 | ||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||
| 1069 | const void *a_ptr = a->is_shared ? a->data.shared->ptr : &(a->data.ptr);
| 41-308 | ||||||||||||||||||||||||
| 1070 | const void *b_ptr = b->is_shared ? b->data.shared->ptr : &(b->data.ptr);
| 41-308 | ||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||
| 1072 | uint typeNameLen = qstrlen(typeName); | - | ||||||||||||||||||||||||
| 1073 | if (typeNameLen > 0 && typeName[typeNameLen - 1] == '*')
| 0-349 | ||||||||||||||||||||||||
| 1074 | return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr); executed 19 times by 3 tests: return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr);Executed by:
| 19 | ||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||
| 1076 | if (a->is_null && b->is_null)
| 0-330 | ||||||||||||||||||||||||
| 1077 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||
| 1079 | return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type)); executed 330 times by 21 tests: return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type));Executed by:
| 330 | ||||||||||||||||||||||||
| 1080 | } | - | ||||||||||||||||||||||||
| 1081 | - | |||||||||||||||||||||||||
| 1082 | static bool customConvert(const QVariant::Private *d, int t, void *result, bool *ok) | - | ||||||||||||||||||||||||
| 1083 | { | - | ||||||||||||||||||||||||
| 1084 | if (d->type >= QMetaType::User || t >= QMetaType::User) {
| 0-482 | ||||||||||||||||||||||||
| 1085 | if (QMetaType::convert(constData(*d), d->type, result, t)) {
| 103-636 | ||||||||||||||||||||||||
| 1086 | if (ok)
| 3-100 | ||||||||||||||||||||||||
| 1087 | *ok = true; executed 3 times by 2 tests: *ok = true;Executed by:
| 3 | ||||||||||||||||||||||||
| 1088 | return true; executed 103 times by 3 tests: return true;Executed by:
| 103 | ||||||||||||||||||||||||
| 1089 | } | - | ||||||||||||||||||||||||
| 1090 | } executed 636 times by 24 tests: end of blockExecuted by:
| 636 | ||||||||||||||||||||||||
| 1091 | return convert(d, t, result, ok); executed 636 times by 24 tests: return convert(d, t, result, ok);Executed by:
| 636 | ||||||||||||||||||||||||
| 1092 | } | - | ||||||||||||||||||||||||
| 1093 | - | |||||||||||||||||||||||||
| 1094 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
| 1095 | static void customStreamDebug(QDebug dbg, const QVariant &variant) { | - | ||||||||||||||||||||||||
| 1096 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 1097 | QMetaType::TypeFlags flags = QMetaType::typeFlags(variant.userType()); | - | ||||||||||||||||||||||||
| 1098 | if (flags & QMetaType::PointerToQObject)
| 1-3 | ||||||||||||||||||||||||
| 1099 | dbg.nospace() << variant.value<QObject*>(); executed 1 time by 1 test: dbg.nospace() << variant.value<QObject*>();Executed by:
| 1 | ||||||||||||||||||||||||
| 1100 | #else | - | ||||||||||||||||||||||||
| 1101 | Q_UNUSED(dbg); | - | ||||||||||||||||||||||||
| 1102 | Q_UNUSED(variant); | - | ||||||||||||||||||||||||
| 1103 | #endif | - | ||||||||||||||||||||||||
| 1104 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 1105 | #endif | - | ||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | const QVariant::Handler qt_custom_variant_handler = { | - | ||||||||||||||||||||||||
| 1108 | customConstruct, | - | ||||||||||||||||||||||||
| 1109 | customClear, | - | ||||||||||||||||||||||||
| 1110 | customIsNull, | - | ||||||||||||||||||||||||
| 1111 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 1112 | 0, | - | ||||||||||||||||||||||||
| 1113 | 0, | - | ||||||||||||||||||||||||
| 1114 | #endif | - | ||||||||||||||||||||||||
| 1115 | customCompare, | - | ||||||||||||||||||||||||
| 1116 | customConvert, | - | ||||||||||||||||||||||||
| 1117 | 0, | - | ||||||||||||||||||||||||
| 1118 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
| 1119 | customStreamDebug | - | ||||||||||||||||||||||||
| 1120 | #else | - | ||||||||||||||||||||||||
| 1121 | 0 | - | ||||||||||||||||||||||||
| 1122 | #endif | - | ||||||||||||||||||||||||
| 1123 | }; | - | ||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||
| 1125 | } // annonymous used to hide QVariant handlers | - | ||||||||||||||||||||||||
| 1126 | - | |||||||||||||||||||||||||
| 1127 | static HandlersManager handlerManager; | - | ||||||||||||||||||||||||
| 1128 | Q_STATIC_ASSERT_X(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0"); | - | ||||||||||||||||||||||||
| 1129 | const QVariant::Handler *HandlersManager::Handlers[QModulesPrivate::ModulesCount] | - | ||||||||||||||||||||||||
| 1130 | = { &qt_kernel_variant_handler, &qt_dummy_variant_handler, | - | ||||||||||||||||||||||||
| 1131 | &qt_dummy_variant_handler, &qt_custom_variant_handler }; | - | ||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||
| 1133 | Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler() | - | ||||||||||||||||||||||||
| 1134 | { | - | ||||||||||||||||||||||||
| 1135 | return &qt_kernel_variant_handler; executed 242206 times by 59 tests: return &qt_kernel_variant_handler;Executed by:
| 242206 | ||||||||||||||||||||||||
| 1136 | } | - | ||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||
| 1138 | Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names */name, const QVariant::Handler *handler) | - | ||||||||||||||||||||||||
| 1139 | { | - | ||||||||||||||||||||||||
| 1140 | handlerManager.registerHandler(static_cast<QModulesPrivate::Names>(name), handler); | - | ||||||||||||||||||||||||
| 1141 | } executed 263 times by 5 tests: end of blockExecuted by:
| 263 | ||||||||||||||||||||||||
| 1142 | - | |||||||||||||||||||||||||
| 1143 | /*! | - | ||||||||||||||||||||||||
| 1144 | \class QVariant | - | ||||||||||||||||||||||||
| 1145 | \inmodule QtCore | - | ||||||||||||||||||||||||
| 1146 | \brief The QVariant class acts like a union for the most common Qt data types. | - | ||||||||||||||||||||||||
| 1147 | - | |||||||||||||||||||||||||
| 1148 | \ingroup objectmodel | - | ||||||||||||||||||||||||
| 1149 | \ingroup shared | - | ||||||||||||||||||||||||
| 1150 | - | |||||||||||||||||||||||||
| 1151 | - | |||||||||||||||||||||||||
| 1152 | Because C++ forbids unions from including types that have | - | ||||||||||||||||||||||||
| 1153 | non-default constructors or destructors, most interesting Qt | - | ||||||||||||||||||||||||
| 1154 | classes cannot be used in unions. Without QVariant, this would be | - | ||||||||||||||||||||||||
| 1155 | a problem for QObject::property() and for database work, etc. | - | ||||||||||||||||||||||||
| 1156 | - | |||||||||||||||||||||||||
| 1157 | A QVariant object holds a single value of a single type() at a | - | ||||||||||||||||||||||||
| 1158 | time. (Some type()s are multi-valued, for example a string list.) | - | ||||||||||||||||||||||||
| 1159 | You can find out what type, T, the variant holds, convert it to a | - | ||||||||||||||||||||||||
| 1160 | different type using convert(), get its value using one of the | - | ||||||||||||||||||||||||
| 1161 | toT() functions (e.g., toSize()) and check whether the type can | - | ||||||||||||||||||||||||
| 1162 | be converted to a particular type using canConvert(). | - | ||||||||||||||||||||||||
| 1163 | - | |||||||||||||||||||||||||
| 1164 | The methods named toT() (e.g., toInt(), toString()) are const. If | - | ||||||||||||||||||||||||
| 1165 | you ask for the stored type, they return a copy of the stored | - | ||||||||||||||||||||||||
| 1166 | object. If you ask for a type that can be generated from the | - | ||||||||||||||||||||||||
| 1167 | stored type, toT() copies and converts and leaves the object | - | ||||||||||||||||||||||||
| 1168 | itself unchanged. If you ask for a type that cannot be generated | - | ||||||||||||||||||||||||
| 1169 | from the stored type, the result depends on the type; see the | - | ||||||||||||||||||||||||
| 1170 | function documentation for details. | - | ||||||||||||||||||||||||
| 1171 | - | |||||||||||||||||||||||||
| 1172 | Here is some example code to demonstrate the use of QVariant: | - | ||||||||||||||||||||||||
| 1173 | - | |||||||||||||||||||||||||
| 1174 | \snippet code/src_corelib_kernel_qvariant.cpp 0 | - | ||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | You can even store QList<QVariant> and QMap<QString, QVariant> | - | ||||||||||||||||||||||||
| 1177 | values in a variant, so you can easily construct arbitrarily | - | ||||||||||||||||||||||||
| 1178 | complex data structures of arbitrary types. This is very powerful | - | ||||||||||||||||||||||||
| 1179 | and versatile, but may prove less memory and speed efficient than | - | ||||||||||||||||||||||||
| 1180 | storing specific types in standard data structures. | - | ||||||||||||||||||||||||
| 1181 | - | |||||||||||||||||||||||||
| 1182 | QVariant also supports the notion of null values, where you can | - | ||||||||||||||||||||||||
| 1183 | have a defined type with no value set. However, note that QVariant | - | ||||||||||||||||||||||||
| 1184 | types can only be cast when they have had a value set. | - | ||||||||||||||||||||||||
| 1185 | - | |||||||||||||||||||||||||
| 1186 | \snippet code/src_corelib_kernel_qvariant.cpp 1 | - | ||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||
| 1188 | QVariant can be extended to support other types than those | - | ||||||||||||||||||||||||
| 1189 | mentioned in the \l Type enum. See the \l QMetaType documentation | - | ||||||||||||||||||||||||
| 1190 | for details. | - | ||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||
| 1192 | \section1 A Note on GUI Types | - | ||||||||||||||||||||||||
| 1193 | - | |||||||||||||||||||||||||
| 1194 | Because QVariant is part of the Qt Core module, it cannot provide | - | ||||||||||||||||||||||||
| 1195 | conversion functions to data types defined in Qt GUI, such as | - | ||||||||||||||||||||||||
| 1196 | QColor, QImage, and QPixmap. In other words, there is no \c | - | ||||||||||||||||||||||||
| 1197 | toColor() function. Instead, you can use the QVariant::value() or | - | ||||||||||||||||||||||||
| 1198 | the qvariant_cast() template function. For example: | - | ||||||||||||||||||||||||
| 1199 | - | |||||||||||||||||||||||||
| 1200 | \snippet code/src_corelib_kernel_qvariant.cpp 2 | - | ||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||
| 1202 | The inverse conversion (e.g., from QColor to QVariant) is | - | ||||||||||||||||||||||||
| 1203 | automatic for all data types supported by QVariant, including | - | ||||||||||||||||||||||||
| 1204 | GUI-related types: | - | ||||||||||||||||||||||||
| 1205 | - | |||||||||||||||||||||||||
| 1206 | \snippet code/src_corelib_kernel_qvariant.cpp 3 | - | ||||||||||||||||||||||||
| 1207 | - | |||||||||||||||||||||||||
| 1208 | \section1 Using canConvert() and convert() Consecutively | - | ||||||||||||||||||||||||
| 1209 | - | |||||||||||||||||||||||||
| 1210 | When using canConvert() and convert() consecutively, it is possible for | - | ||||||||||||||||||||||||
| 1211 | canConvert() to return true, but convert() to return false. This | - | ||||||||||||||||||||||||
| 1212 | is typically because canConvert() only reports the general ability of | - | ||||||||||||||||||||||||
| 1213 | QVariant to convert between types given suitable data; it is still | - | ||||||||||||||||||||||||
| 1214 | possible to supply data which cannot actually be converted. | - | ||||||||||||||||||||||||
| 1215 | - | |||||||||||||||||||||||||
| 1216 | For example, canConvert(Int) would return true when called on a variant | - | ||||||||||||||||||||||||
| 1217 | containing a string because, in principle, QVariant is able to convert | - | ||||||||||||||||||||||||
| 1218 | strings of numbers to integers. | - | ||||||||||||||||||||||||
| 1219 | However, if the string contains non-numeric characters, it cannot be | - | ||||||||||||||||||||||||
| 1220 | converted to an integer, and any attempt to convert it will fail. | - | ||||||||||||||||||||||||
| 1221 | Hence, it is important to have both functions return true for a | - | ||||||||||||||||||||||||
| 1222 | successful conversion. | - | ||||||||||||||||||||||||
| 1223 | - | |||||||||||||||||||||||||
| 1224 | \sa QMetaType | - | ||||||||||||||||||||||||
| 1225 | */ | - | ||||||||||||||||||||||||
| 1226 | - | |||||||||||||||||||||||||
| 1227 | /*! | - | ||||||||||||||||||||||||
| 1228 | \obsolete Use QMetaType::Type instead | - | ||||||||||||||||||||||||
| 1229 | \enum QVariant::Type | - | ||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | This enum type defines the types of variable that a QVariant can | - | ||||||||||||||||||||||||
| 1232 | contain. | - | ||||||||||||||||||||||||
| 1233 | - | |||||||||||||||||||||||||
| 1234 | \value Invalid no type | - | ||||||||||||||||||||||||
| 1235 | \value BitArray a QBitArray | - | ||||||||||||||||||||||||
| 1236 | \value Bitmap a QBitmap | - | ||||||||||||||||||||||||
| 1237 | \value Bool a bool | - | ||||||||||||||||||||||||
| 1238 | \value Brush a QBrush | - | ||||||||||||||||||||||||
| 1239 | \value ByteArray a QByteArray | - | ||||||||||||||||||||||||
| 1240 | \value Char a QChar | - | ||||||||||||||||||||||||
| 1241 | \value Color a QColor | - | ||||||||||||||||||||||||
| 1242 | \value Cursor a QCursor | - | ||||||||||||||||||||||||
| 1243 | \value Date a QDate | - | ||||||||||||||||||||||||
| 1244 | \value DateTime a QDateTime | - | ||||||||||||||||||||||||
| 1245 | \value Double a double | - | ||||||||||||||||||||||||
| 1246 | \value EasingCurve a QEasingCurve | - | ||||||||||||||||||||||||
| 1247 | \value Uuid a QUuid | - | ||||||||||||||||||||||||
| 1248 | \value ModelIndex a QModelIndex | - | ||||||||||||||||||||||||
| 1249 | \value PersistentModelIndex a QPersistentModelIndex (since 5.5) | - | ||||||||||||||||||||||||
| 1250 | \value Font a QFont | - | ||||||||||||||||||||||||
| 1251 | \value Hash a QVariantHash | - | ||||||||||||||||||||||||
| 1252 | \value Icon a QIcon | - | ||||||||||||||||||||||||
| 1253 | \value Image a QImage | - | ||||||||||||||||||||||||
| 1254 | \value Int an int | - | ||||||||||||||||||||||||
| 1255 | \value KeySequence a QKeySequence | - | ||||||||||||||||||||||||
| 1256 | \value Line a QLine | - | ||||||||||||||||||||||||
| 1257 | \value LineF a QLineF | - | ||||||||||||||||||||||||
| 1258 | \value List a QVariantList | - | ||||||||||||||||||||||||
| 1259 | \value Locale a QLocale | - | ||||||||||||||||||||||||
| 1260 | \value LongLong a \l qlonglong | - | ||||||||||||||||||||||||
| 1261 | \value Map a QVariantMap | - | ||||||||||||||||||||||||
| 1262 | \value Matrix a QMatrix | - | ||||||||||||||||||||||||
| 1263 | \value Transform a QTransform | - | ||||||||||||||||||||||||
| 1264 | \value Matrix4x4 a QMatrix4x4 | - | ||||||||||||||||||||||||
| 1265 | \value Palette a QPalette | - | ||||||||||||||||||||||||
| 1266 | \value Pen a QPen | - | ||||||||||||||||||||||||
| 1267 | \value Pixmap a QPixmap | - | ||||||||||||||||||||||||
| 1268 | \value Point a QPoint | - | ||||||||||||||||||||||||
| 1269 | \value PointF a QPointF | - | ||||||||||||||||||||||||
| 1270 | \value Polygon a QPolygon | - | ||||||||||||||||||||||||
| 1271 | \value PolygonF a QPolygonF | - | ||||||||||||||||||||||||
| 1272 | \value Quaternion a QQuaternion | - | ||||||||||||||||||||||||
| 1273 | \value Rect a QRect | - | ||||||||||||||||||||||||
| 1274 | \value RectF a QRectF | - | ||||||||||||||||||||||||
| 1275 | \value RegExp a QRegExp | - | ||||||||||||||||||||||||
| 1276 | \value RegularExpression a QRegularExpression | - | ||||||||||||||||||||||||
| 1277 | \value Region a QRegion | - | ||||||||||||||||||||||||
| 1278 | \value Size a QSize | - | ||||||||||||||||||||||||
| 1279 | \value SizeF a QSizeF | - | ||||||||||||||||||||||||
| 1280 | \value SizePolicy a QSizePolicy | - | ||||||||||||||||||||||||
| 1281 | \value String a QString | - | ||||||||||||||||||||||||
| 1282 | \value StringList a QStringList | - | ||||||||||||||||||||||||
| 1283 | \value TextFormat a QTextFormat | - | ||||||||||||||||||||||||
| 1284 | \value TextLength a QTextLength | - | ||||||||||||||||||||||||
| 1285 | \value Time a QTime | - | ||||||||||||||||||||||||
| 1286 | \value UInt a \l uint | - | ||||||||||||||||||||||||
| 1287 | \value ULongLong a \l qulonglong | - | ||||||||||||||||||||||||
| 1288 | \value Url a QUrl | - | ||||||||||||||||||||||||
| 1289 | \value Vector2D a QVector2D | - | ||||||||||||||||||||||||
| 1290 | \value Vector3D a QVector3D | - | ||||||||||||||||||||||||
| 1291 | \value Vector4D a QVector4D | - | ||||||||||||||||||||||||
| 1292 | - | |||||||||||||||||||||||||
| 1293 | \value UserType Base value for user-defined types. | - | ||||||||||||||||||||||||
| 1294 | - | |||||||||||||||||||||||||
| 1295 | \omitvalue LastGuiType | - | ||||||||||||||||||||||||
| 1296 | \omitvalue LastCoreType | - | ||||||||||||||||||||||||
| 1297 | \omitvalue LastType | - | ||||||||||||||||||||||||
| 1298 | */ | - | ||||||||||||||||||||||||
| 1299 | - | |||||||||||||||||||||||||
| 1300 | /*! | - | ||||||||||||||||||||||||
| 1301 | \fn QVariant::QVariant(QVariant &&other) | - | ||||||||||||||||||||||||
| 1302 | - | |||||||||||||||||||||||||
| 1303 | Move-constructs a QVariant instance, making it point at the same | - | ||||||||||||||||||||||||
| 1304 | object that \a other was pointing to. | - | ||||||||||||||||||||||||
| 1305 | - | |||||||||||||||||||||||||
| 1306 | \since 5.2 | - | ||||||||||||||||||||||||
| 1307 | */ | - | ||||||||||||||||||||||||
| 1308 | - | |||||||||||||||||||||||||
| 1309 | /*! | - | ||||||||||||||||||||||||
| 1310 | \fn QVariant &QVariant::operator=(QVariant &&other) | - | ||||||||||||||||||||||||
| 1311 | - | |||||||||||||||||||||||||
| 1312 | Move-assigns \a other to this QVariant instance. | - | ||||||||||||||||||||||||
| 1313 | - | |||||||||||||||||||||||||
| 1314 | \since 5.2 | - | ||||||||||||||||||||||||
| 1315 | */ | - | ||||||||||||||||||||||||
| 1316 | - | |||||||||||||||||||||||||
| 1317 | /*! | - | ||||||||||||||||||||||||
| 1318 | \fn QVariant::QVariant() | - | ||||||||||||||||||||||||
| 1319 | - | |||||||||||||||||||||||||
| 1320 | Constructs an invalid variant. | - | ||||||||||||||||||||||||
| 1321 | */ | - | ||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||
| 1323 | - | |||||||||||||||||||||||||
| 1324 | /*! | - | ||||||||||||||||||||||||
| 1325 | \fn QVariant::QVariant(int typeId, const void *copy) | - | ||||||||||||||||||||||||
| 1326 | - | |||||||||||||||||||||||||
| 1327 | Constructs variant of type \a typeId, and initializes with | - | ||||||||||||||||||||||||
| 1328 | \a copy if \a copy is not 0. | - | ||||||||||||||||||||||||
| 1329 | - | |||||||||||||||||||||||||
| 1330 | Note that you have to pass the address of the variable you want stored. | - | ||||||||||||||||||||||||
| 1331 | - | |||||||||||||||||||||||||
| 1332 | Usually, you never have to use this constructor, use QVariant::fromValue() | - | ||||||||||||||||||||||||
| 1333 | instead to construct variants from the pointer types represented by | - | ||||||||||||||||||||||||
| 1334 | \c QMetaType::VoidStar, and \c QMetaType::QObjectStar. | - | ||||||||||||||||||||||||
| 1335 | - | |||||||||||||||||||||||||
| 1336 | \sa QVariant::fromValue(), QMetaType::Type | - | ||||||||||||||||||||||||
| 1337 | */ | - | ||||||||||||||||||||||||
| 1338 | - | |||||||||||||||||||||||||
| 1339 | /*! | - | ||||||||||||||||||||||||
| 1340 | \fn QVariant::QVariant(Type type) | - | ||||||||||||||||||||||||
| 1341 | - | |||||||||||||||||||||||||
| 1342 | Constructs a null variant of type \a type. | - | ||||||||||||||||||||||||
| 1343 | */ | - | ||||||||||||||||||||||||
| 1344 | - | |||||||||||||||||||||||||
| 1345 | - | |||||||||||||||||||||||||
| 1346 | - | |||||||||||||||||||||||||
| 1347 | /*! | - | ||||||||||||||||||||||||
| 1348 | \fn QVariant::create(int type, const void *copy) | - | ||||||||||||||||||||||||
| 1349 | - | |||||||||||||||||||||||||
| 1350 | \internal | - | ||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||
| 1352 | Constructs a variant private of type \a type, and initializes with \a copy if | - | ||||||||||||||||||||||||
| 1353 | \a copy is not 0. | - | ||||||||||||||||||||||||
| 1354 | */ | - | ||||||||||||||||||||||||
| 1355 | - | |||||||||||||||||||||||||
| 1356 | void QVariant::create(int type, const void *copy) | - | ||||||||||||||||||||||||
| 1357 | { | - | ||||||||||||||||||||||||
| 1358 | d.type = type; | - | ||||||||||||||||||||||||
| 1359 | handlerManager[type]->construct(&d, copy); | - | ||||||||||||||||||||||||
| 1360 | } executed 3554336 times by 249 tests: end of blockExecuted by:
| 3554336 | ||||||||||||||||||||||||
| 1361 | - | |||||||||||||||||||||||||
| 1362 | /*! | - | ||||||||||||||||||||||||
| 1363 | \fn QVariant::~QVariant() | - | ||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||
| 1365 | Destroys the QVariant and the contained object. | - | ||||||||||||||||||||||||
| 1366 | - | |||||||||||||||||||||||||
| 1367 | Note that subclasses that reimplement clear() should reimplement | - | ||||||||||||||||||||||||
| 1368 | the destructor to call clear(). This destructor calls clear(), but | - | ||||||||||||||||||||||||
| 1369 | because it is the destructor, QVariant::clear() is called rather | - | ||||||||||||||||||||||||
| 1370 | than a subclass's clear(). | - | ||||||||||||||||||||||||
| 1371 | */ | - | ||||||||||||||||||||||||
| 1372 | - | |||||||||||||||||||||||||
| 1373 | QVariant::~QVariant() | - | ||||||||||||||||||||||||
| 1374 | { | - | ||||||||||||||||||||||||
| 1375 | if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char))
| 3438896-22424944 | ||||||||||||||||||||||||
| 1376 | handlerManager[d.type]->clear(&d); executed 12253881 times by 446 tests: handlerManager[d.type]->clear(&d);Executed by:
| 12253881 | ||||||||||||||||||||||||
| 1377 | } executed 29356221 times by 493 tests: end of blockExecuted by:
| 29356221 | ||||||||||||||||||||||||
| 1378 | - | |||||||||||||||||||||||||
| 1379 | /*! | - | ||||||||||||||||||||||||
| 1380 | \fn QVariant::QVariant(const QVariant &p) | - | ||||||||||||||||||||||||
| 1381 | - | |||||||||||||||||||||||||
| 1382 | Constructs a copy of the variant, \a p, passed as the argument to | - | ||||||||||||||||||||||||
| 1383 | this constructor. | - | ||||||||||||||||||||||||
| 1384 | */ | - | ||||||||||||||||||||||||
| 1385 | - | |||||||||||||||||||||||||
| 1386 | QVariant::QVariant(const QVariant &p) | - | ||||||||||||||||||||||||
| 1387 | : d(p.d) | - | ||||||||||||||||||||||||
| 1388 | { | - | ||||||||||||||||||||||||
| 1389 | if (d.is_shared) {
| 3490590-5536927 | ||||||||||||||||||||||||
| 1390 | d.data.shared->ref.ref(); | - | ||||||||||||||||||||||||
| 1391 | } else if (p.d.type > Char) { executed 3490590 times by 175 tests: end of blockExecuted by:
| 943864-4593063 | ||||||||||||||||||||||||
| 1392 | handlerManager[d.type]->construct(&d, p.constData()); | - | ||||||||||||||||||||||||
| 1393 | d.is_null = p.d.is_null; | - | ||||||||||||||||||||||||
| 1394 | } executed 4593063 times by 392 tests: end of blockExecuted by:
| 4593063 | ||||||||||||||||||||||||
| 1395 | } executed 9027517 times by 410 tests: end of blockExecuted by:
| 9027517 | ||||||||||||||||||||||||
| 1396 | - | |||||||||||||||||||||||||
| 1397 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 1398 | /*! | - | ||||||||||||||||||||||||
| 1399 | Reads the variant from the data stream, \a s. | - | ||||||||||||||||||||||||
| 1400 | */ | - | ||||||||||||||||||||||||
| 1401 | QVariant::QVariant(QDataStream &s) | - | ||||||||||||||||||||||||
| 1402 | { | - | ||||||||||||||||||||||||
| 1403 | d.is_null = true; | - | ||||||||||||||||||||||||
| 1404 | s >> *this; | - | ||||||||||||||||||||||||
| 1405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1406 | #endif //QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||
| 1408 | /*! | - | ||||||||||||||||||||||||
| 1409 | \fn QVariant::QVariant(const QString &val) | - | ||||||||||||||||||||||||
| 1410 | - | |||||||||||||||||||||||||
| 1411 | Constructs a new variant with a string value, \a val. | - | ||||||||||||||||||||||||
| 1412 | */ | - | ||||||||||||||||||||||||
| 1413 | - | |||||||||||||||||||||||||
| 1414 | /*! | - | ||||||||||||||||||||||||
| 1415 | \fn QVariant::QVariant(QLatin1String val) | - | ||||||||||||||||||||||||
| 1416 | - | |||||||||||||||||||||||||
| 1417 | Constructs a new variant with a string value, \a val. | - | ||||||||||||||||||||||||
| 1418 | */ | - | ||||||||||||||||||||||||
| 1419 | - | |||||||||||||||||||||||||
| 1420 | /*! | - | ||||||||||||||||||||||||
| 1421 | \fn QVariant::QVariant(const char *val) | - | ||||||||||||||||||||||||
| 1422 | - | |||||||||||||||||||||||||
| 1423 | Constructs a new variant with a string value of \a val. | - | ||||||||||||||||||||||||
| 1424 | The variant creates a deep copy of \a val into a QString assuming | - | ||||||||||||||||||||||||
| 1425 | UTF-8 encoding on the input \a val. | - | ||||||||||||||||||||||||
| 1426 | - | |||||||||||||||||||||||||
| 1427 | Note that \a val is converted to a QString for storing in the | - | ||||||||||||||||||||||||
| 1428 | variant and QVariant::userType() will return QMetaType::QString for | - | ||||||||||||||||||||||||
| 1429 | the variant. | - | ||||||||||||||||||||||||
| 1430 | - | |||||||||||||||||||||||||
| 1431 | You can disable this operator by defining \c | - | ||||||||||||||||||||||||
| 1432 | QT_NO_CAST_FROM_ASCII when you compile your applications. | - | ||||||||||||||||||||||||
| 1433 | */ | - | ||||||||||||||||||||||||
| 1434 | - | |||||||||||||||||||||||||
| 1435 | #ifndef QT_NO_CAST_FROM_ASCII | - | ||||||||||||||||||||||||
| 1436 | QVariant::QVariant(const char *val) | - | ||||||||||||||||||||||||
| 1437 | { | - | ||||||||||||||||||||||||
| 1438 | QString s = QString::fromUtf8(val); | - | ||||||||||||||||||||||||
| 1439 | create(String, &s); | - | ||||||||||||||||||||||||
| 1440 | } executed 10680 times by 45 tests: end of blockExecuted by:
| 10680 | ||||||||||||||||||||||||
| 1441 | #endif | - | ||||||||||||||||||||||||
| 1442 | - | |||||||||||||||||||||||||
| 1443 | /*! | - | ||||||||||||||||||||||||
| 1444 | \fn QVariant::QVariant(const QStringList &val) | - | ||||||||||||||||||||||||
| 1445 | - | |||||||||||||||||||||||||
| 1446 | Constructs a new variant with a string list value, \a val. | - | ||||||||||||||||||||||||
| 1447 | */ | - | ||||||||||||||||||||||||
| 1448 | - | |||||||||||||||||||||||||
| 1449 | /*! | - | ||||||||||||||||||||||||
| 1450 | \fn QVariant::QVariant(const QMap<QString, QVariant> &val) | - | ||||||||||||||||||||||||
| 1451 | - | |||||||||||||||||||||||||
| 1452 | Constructs a new variant with a map of \l {QVariant}s, \a val. | - | ||||||||||||||||||||||||
| 1453 | */ | - | ||||||||||||||||||||||||
| 1454 | - | |||||||||||||||||||||||||
| 1455 | /*! | - | ||||||||||||||||||||||||
| 1456 | \fn QVariant::QVariant(const QHash<QString, QVariant> &val) | - | ||||||||||||||||||||||||
| 1457 | - | |||||||||||||||||||||||||
| 1458 | Constructs a new variant with a hash of \l {QVariant}s, \a val. | - | ||||||||||||||||||||||||
| 1459 | */ | - | ||||||||||||||||||||||||
| 1460 | - | |||||||||||||||||||||||||
| 1461 | /*! | - | ||||||||||||||||||||||||
| 1462 | \fn QVariant::QVariant(const QDate &val) | - | ||||||||||||||||||||||||
| 1463 | - | |||||||||||||||||||||||||
| 1464 | Constructs a new variant with a date value, \a val. | - | ||||||||||||||||||||||||
| 1465 | */ | - | ||||||||||||||||||||||||
| 1466 | - | |||||||||||||||||||||||||
| 1467 | /*! | - | ||||||||||||||||||||||||
| 1468 | \fn QVariant::QVariant(const QTime &val) | - | ||||||||||||||||||||||||
| 1469 | - | |||||||||||||||||||||||||
| 1470 | Constructs a new variant with a time value, \a val. | - | ||||||||||||||||||||||||
| 1471 | */ | - | ||||||||||||||||||||||||
| 1472 | - | |||||||||||||||||||||||||
| 1473 | /*! | - | ||||||||||||||||||||||||
| 1474 | \fn QVariant::QVariant(const QDateTime &val) | - | ||||||||||||||||||||||||
| 1475 | - | |||||||||||||||||||||||||
| 1476 | Constructs a new variant with a date/time value, \a val. | - | ||||||||||||||||||||||||
| 1477 | */ | - | ||||||||||||||||||||||||
| 1478 | - | |||||||||||||||||||||||||
| 1479 | /*! | - | ||||||||||||||||||||||||
| 1480 | \since 4.7 | - | ||||||||||||||||||||||||
| 1481 | \fn QVariant::QVariant(const QEasingCurve &val) | - | ||||||||||||||||||||||||
| 1482 | - | |||||||||||||||||||||||||
| 1483 | Constructs a new variant with an easing curve value, \a val. | - | ||||||||||||||||||||||||
| 1484 | */ | - | ||||||||||||||||||||||||
| 1485 | - | |||||||||||||||||||||||||
| 1486 | /*! | - | ||||||||||||||||||||||||
| 1487 | \since 5.0 | - | ||||||||||||||||||||||||
| 1488 | \fn QVariant::QVariant(const QUuid &val) | - | ||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||
| 1490 | Constructs a new variant with an uuid value, \a val. | - | ||||||||||||||||||||||||
| 1491 | */ | - | ||||||||||||||||||||||||
| 1492 | - | |||||||||||||||||||||||||
| 1493 | /*! | - | ||||||||||||||||||||||||
| 1494 | \since 5.0 | - | ||||||||||||||||||||||||
| 1495 | \fn QVariant::QVariant(const QModelIndex &val) | - | ||||||||||||||||||||||||
| 1496 | - | |||||||||||||||||||||||||
| 1497 | Constructs a new variant with a QModelIndex value, \a val. | - | ||||||||||||||||||||||||
| 1498 | */ | - | ||||||||||||||||||||||||
| 1499 | - | |||||||||||||||||||||||||
| 1500 | /*! | - | ||||||||||||||||||||||||
| 1501 | \since 5.5 | - | ||||||||||||||||||||||||
| 1502 | \fn QVariant::QVariant(const QPersistentModelIndex &val) | - | ||||||||||||||||||||||||
| 1503 | - | |||||||||||||||||||||||||
| 1504 | Constructs a new variant with a QPersistentModelIndex value, \a val. | - | ||||||||||||||||||||||||
| 1505 | */ | - | ||||||||||||||||||||||||
| 1506 | - | |||||||||||||||||||||||||
| 1507 | /*! | - | ||||||||||||||||||||||||
| 1508 | \since 5.0 | - | ||||||||||||||||||||||||
| 1509 | \fn QVariant::QVariant(const QJsonValue &val) | - | ||||||||||||||||||||||||
| 1510 | - | |||||||||||||||||||||||||
| 1511 | Constructs a new variant with a json value, \a val. | - | ||||||||||||||||||||||||
| 1512 | */ | - | ||||||||||||||||||||||||
| 1513 | - | |||||||||||||||||||||||||
| 1514 | /*! | - | ||||||||||||||||||||||||
| 1515 | \since 5.0 | - | ||||||||||||||||||||||||
| 1516 | \fn QVariant::QVariant(const QJsonObject &val) | - | ||||||||||||||||||||||||
| 1517 | - | |||||||||||||||||||||||||
| 1518 | Constructs a new variant with a json object value, \a val. | - | ||||||||||||||||||||||||
| 1519 | */ | - | ||||||||||||||||||||||||
| 1520 | - | |||||||||||||||||||||||||
| 1521 | /*! | - | ||||||||||||||||||||||||
| 1522 | \since 5.0 | - | ||||||||||||||||||||||||
| 1523 | \fn QVariant::QVariant(const QJsonArray &val) | - | ||||||||||||||||||||||||
| 1524 | - | |||||||||||||||||||||||||
| 1525 | Constructs a new variant with a json array value, \a val. | - | ||||||||||||||||||||||||
| 1526 | */ | - | ||||||||||||||||||||||||
| 1527 | - | |||||||||||||||||||||||||
| 1528 | /*! | - | ||||||||||||||||||||||||
| 1529 | \since 5.0 | - | ||||||||||||||||||||||||
| 1530 | \fn QVariant::QVariant(const QJsonDocument &val) | - | ||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||
| 1532 | Constructs a new variant with a json document value, \a val. | - | ||||||||||||||||||||||||
| 1533 | */ | - | ||||||||||||||||||||||||
| 1534 | - | |||||||||||||||||||||||||
| 1535 | /*! | - | ||||||||||||||||||||||||
| 1536 | \fn QVariant::QVariant(const QByteArray &val) | - | ||||||||||||||||||||||||
| 1537 | - | |||||||||||||||||||||||||
| 1538 | Constructs a new variant with a bytearray value, \a val. | - | ||||||||||||||||||||||||
| 1539 | */ | - | ||||||||||||||||||||||||
| 1540 | - | |||||||||||||||||||||||||
| 1541 | /*! | - | ||||||||||||||||||||||||
| 1542 | \fn QVariant::QVariant(const QBitArray &val) | - | ||||||||||||||||||||||||
| 1543 | - | |||||||||||||||||||||||||
| 1544 | Constructs a new variant with a bitarray value, \a val. | - | ||||||||||||||||||||||||
| 1545 | */ | - | ||||||||||||||||||||||||
| 1546 | - | |||||||||||||||||||||||||
| 1547 | /*! | - | ||||||||||||||||||||||||
| 1548 | \fn QVariant::QVariant(const QPoint &val) | - | ||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||
| 1550 | Constructs a new variant with a point value of \a val. | - | ||||||||||||||||||||||||
| 1551 | */ | - | ||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||
| 1553 | /*! | - | ||||||||||||||||||||||||
| 1554 | \fn QVariant::QVariant(const QPointF &val) | - | ||||||||||||||||||||||||
| 1555 | - | |||||||||||||||||||||||||
| 1556 | Constructs a new variant with a point value of \a val. | - | ||||||||||||||||||||||||
| 1557 | */ | - | ||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||
| 1559 | /*! | - | ||||||||||||||||||||||||
| 1560 | \fn QVariant::QVariant(const QRectF &val) | - | ||||||||||||||||||||||||
| 1561 | - | |||||||||||||||||||||||||
| 1562 | Constructs a new variant with a rect value of \a val. | - | ||||||||||||||||||||||||
| 1563 | */ | - | ||||||||||||||||||||||||
| 1564 | - | |||||||||||||||||||||||||
| 1565 | /*! | - | ||||||||||||||||||||||||
| 1566 | \fn QVariant::QVariant(const QLineF &val) | - | ||||||||||||||||||||||||
| 1567 | - | |||||||||||||||||||||||||
| 1568 | Constructs a new variant with a line value of \a val. | - | ||||||||||||||||||||||||
| 1569 | */ | - | ||||||||||||||||||||||||
| 1570 | - | |||||||||||||||||||||||||
| 1571 | /*! | - | ||||||||||||||||||||||||
| 1572 | \fn QVariant::QVariant(const QLine &val) | - | ||||||||||||||||||||||||
| 1573 | - | |||||||||||||||||||||||||
| 1574 | Constructs a new variant with a line value of \a val. | - | ||||||||||||||||||||||||
| 1575 | */ | - | ||||||||||||||||||||||||
| 1576 | - | |||||||||||||||||||||||||
| 1577 | /*! | - | ||||||||||||||||||||||||
| 1578 | \fn QVariant::QVariant(const QRect &val) | - | ||||||||||||||||||||||||
| 1579 | - | |||||||||||||||||||||||||
| 1580 | Constructs a new variant with a rect value of \a val. | - | ||||||||||||||||||||||||
| 1581 | */ | - | ||||||||||||||||||||||||
| 1582 | - | |||||||||||||||||||||||||
| 1583 | /*! | - | ||||||||||||||||||||||||
| 1584 | \fn QVariant::QVariant(const QSize &val) | - | ||||||||||||||||||||||||
| 1585 | - | |||||||||||||||||||||||||
| 1586 | Constructs a new variant with a size value of \a val. | - | ||||||||||||||||||||||||
| 1587 | */ | - | ||||||||||||||||||||||||
| 1588 | - | |||||||||||||||||||||||||
| 1589 | /*! | - | ||||||||||||||||||||||||
| 1590 | \fn QVariant::QVariant(const QSizeF &val) | - | ||||||||||||||||||||||||
| 1591 | - | |||||||||||||||||||||||||
| 1592 | Constructs a new variant with a size value of \a val. | - | ||||||||||||||||||||||||
| 1593 | */ | - | ||||||||||||||||||||||||
| 1594 | - | |||||||||||||||||||||||||
| 1595 | /*! | - | ||||||||||||||||||||||||
| 1596 | \fn QVariant::QVariant(const QUrl &val) | - | ||||||||||||||||||||||||
| 1597 | - | |||||||||||||||||||||||||
| 1598 | Constructs a new variant with a url value of \a val. | - | ||||||||||||||||||||||||
| 1599 | */ | - | ||||||||||||||||||||||||
| 1600 | - | |||||||||||||||||||||||||
| 1601 | /*! | - | ||||||||||||||||||||||||
| 1602 | \fn QVariant::QVariant(int val) | - | ||||||||||||||||||||||||
| 1603 | - | |||||||||||||||||||||||||
| 1604 | Constructs a new variant with an integer value, \a val. | - | ||||||||||||||||||||||||
| 1605 | */ | - | ||||||||||||||||||||||||
| 1606 | - | |||||||||||||||||||||||||
| 1607 | /*! | - | ||||||||||||||||||||||||
| 1608 | \fn QVariant::QVariant(uint val) | - | ||||||||||||||||||||||||
| 1609 | - | |||||||||||||||||||||||||
| 1610 | Constructs a new variant with an unsigned integer value, \a val. | - | ||||||||||||||||||||||||
| 1611 | */ | - | ||||||||||||||||||||||||
| 1612 | - | |||||||||||||||||||||||||
| 1613 | /*! | - | ||||||||||||||||||||||||
| 1614 | \fn QVariant::QVariant(qlonglong val) | - | ||||||||||||||||||||||||
| 1615 | - | |||||||||||||||||||||||||
| 1616 | Constructs a new variant with a long long integer value, \a val. | - | ||||||||||||||||||||||||
| 1617 | */ | - | ||||||||||||||||||||||||
| 1618 | - | |||||||||||||||||||||||||
| 1619 | /*! | - | ||||||||||||||||||||||||
| 1620 | \fn QVariant::QVariant(qulonglong val) | - | ||||||||||||||||||||||||
| 1621 | - | |||||||||||||||||||||||||
| 1622 | Constructs a new variant with an unsigned long long integer value, \a val. | - | ||||||||||||||||||||||||
| 1623 | */ | - | ||||||||||||||||||||||||
| 1624 | - | |||||||||||||||||||||||||
| 1625 | - | |||||||||||||||||||||||||
| 1626 | /*! | - | ||||||||||||||||||||||||
| 1627 | \fn QVariant::QVariant(bool val) | - | ||||||||||||||||||||||||
| 1628 | - | |||||||||||||||||||||||||
| 1629 | Constructs a new variant with a boolean value, \a val. | - | ||||||||||||||||||||||||
| 1630 | */ | - | ||||||||||||||||||||||||
| 1631 | - | |||||||||||||||||||||||||
| 1632 | /*! | - | ||||||||||||||||||||||||
| 1633 | \fn QVariant::QVariant(double val) | - | ||||||||||||||||||||||||
| 1634 | - | |||||||||||||||||||||||||
| 1635 | Constructs a new variant with a floating point value, \a val. | - | ||||||||||||||||||||||||
| 1636 | */ | - | ||||||||||||||||||||||||
| 1637 | - | |||||||||||||||||||||||||
| 1638 | /*! | - | ||||||||||||||||||||||||
| 1639 | \fn QVariant::QVariant(float val) | - | ||||||||||||||||||||||||
| 1640 | - | |||||||||||||||||||||||||
| 1641 | Constructs a new variant with a floating point value, \a val. | - | ||||||||||||||||||||||||
| 1642 | \since 4.6 | - | ||||||||||||||||||||||||
| 1643 | */ | - | ||||||||||||||||||||||||
| 1644 | - | |||||||||||||||||||||||||
| 1645 | /*! | - | ||||||||||||||||||||||||
| 1646 | \fn QVariant::QVariant(const QList<QVariant> &val) | - | ||||||||||||||||||||||||
| 1647 | - | |||||||||||||||||||||||||
| 1648 | Constructs a new variant with a list value, \a val. | - | ||||||||||||||||||||||||
| 1649 | */ | - | ||||||||||||||||||||||||
| 1650 | - | |||||||||||||||||||||||||
| 1651 | /*! | - | ||||||||||||||||||||||||
| 1652 | \fn QVariant::QVariant(QChar c) | - | ||||||||||||||||||||||||
| 1653 | - | |||||||||||||||||||||||||
| 1654 | Constructs a new variant with a char value, \a c. | - | ||||||||||||||||||||||||
| 1655 | */ | - | ||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||
| 1657 | /*! | - | ||||||||||||||||||||||||
| 1658 | \fn QVariant::QVariant(const QLocale &l) | - | ||||||||||||||||||||||||
| 1659 | - | |||||||||||||||||||||||||
| 1660 | Constructs a new variant with a locale value, \a l. | - | ||||||||||||||||||||||||
| 1661 | */ | - | ||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||
| 1663 | /*! | - | ||||||||||||||||||||||||
| 1664 | \fn QVariant::QVariant(const QRegExp ®Exp) | - | ||||||||||||||||||||||||
| 1665 | - | |||||||||||||||||||||||||
| 1666 | Constructs a new variant with the regexp value \a regExp. | - | ||||||||||||||||||||||||
| 1667 | */ | - | ||||||||||||||||||||||||
| 1668 | - | |||||||||||||||||||||||||
| 1669 | /*! | - | ||||||||||||||||||||||||
| 1670 | \fn QVariant::QVariant(const QRegularExpression &re) | - | ||||||||||||||||||||||||
| 1671 | - | |||||||||||||||||||||||||
| 1672 | \since 5.0 | - | ||||||||||||||||||||||||
| 1673 | - | |||||||||||||||||||||||||
| 1674 | Constructs a new variant with the regular expression value \a re. | - | ||||||||||||||||||||||||
| 1675 | */ | - | ||||||||||||||||||||||||
| 1676 | - | |||||||||||||||||||||||||
| 1677 | QVariant::QVariant(Type type) | - | ||||||||||||||||||||||||
| 1678 | { executed 8097 times by 17 tests: create(type, 0); }end of blockExecuted by:
executed 8097 times by 17 tests: end of blockExecuted by:
| 8097 | ||||||||||||||||||||||||
| 1679 | QVariant::QVariant(int typeId, const void *copy) | - | ||||||||||||||||||||||||
| 1680 | { executed 3499821 times by 228 tests: create(typeId, copy); d.is_null = false; }end of blockExecuted by:
executed 3499821 times by 228 tests: end of blockExecuted by:
| 3499821 | ||||||||||||||||||||||||
| 1681 | - | |||||||||||||||||||||||||
| 1682 | /*! | - | ||||||||||||||||||||||||
| 1683 | \internal | - | ||||||||||||||||||||||||
| 1684 | flags is true if it is a pointer type | - | ||||||||||||||||||||||||
| 1685 | */ | - | ||||||||||||||||||||||||
| 1686 | QVariant::QVariant(int typeId, const void *copy, uint flags) | - | ||||||||||||||||||||||||
| 1687 | { | - | ||||||||||||||||||||||||
| 1688 | if (flags) { //type is a pointer type
| 18593-42087 | ||||||||||||||||||||||||
| 1689 | d.type = typeId; | - | ||||||||||||||||||||||||
| 1690 | d.data.ptr = *reinterpret_cast<void *const*>(copy); | - | ||||||||||||||||||||||||
| 1691 | } else { executed 42087 times by 30 tests: end of blockExecuted by:
| 42087 | ||||||||||||||||||||||||
| 1692 | create(typeId, copy); | - | ||||||||||||||||||||||||
| 1693 | } executed 18593 times by 195 tests: end of blockExecuted by:
| 18593 | ||||||||||||||||||||||||
| 1694 | d.is_null = false; | - | ||||||||||||||||||||||||
| 1695 | } executed 60680 times by 199 tests: end of blockExecuted by:
| 60680 | ||||||||||||||||||||||||
| 1696 | - | |||||||||||||||||||||||||
| 1697 | QVariant::QVariant(int val) | - | ||||||||||||||||||||||||
| 1698 | : d(Int) | - | ||||||||||||||||||||||||
| 1699 | { executed 651560 times by 221 tests: d.data.i = val; }end of blockExecuted by:
executed 651560 times by 221 tests: end of blockExecuted by:
| 651560 | ||||||||||||||||||||||||
| 1700 | QVariant::QVariant(uint val) | - | ||||||||||||||||||||||||
| 1701 | : d(UInt) | - | ||||||||||||||||||||||||
| 1702 | { executed 3346 times by 54 tests: d.data.u = val; }end of blockExecuted by:
executed 3346 times by 54 tests: end of blockExecuted by:
| 3346 | ||||||||||||||||||||||||
| 1703 | QVariant::QVariant(qlonglong val) | - | ||||||||||||||||||||||||
| 1704 | : d(LongLong) | - | ||||||||||||||||||||||||
| 1705 | { executed 40329 times by 23 tests: d.data.ll = val; }end of blockExecuted by:
executed 40329 times by 23 tests: end of blockExecuted by:
| 40329 | ||||||||||||||||||||||||
| 1706 | QVariant::QVariant(qulonglong val) | - | ||||||||||||||||||||||||
| 1707 | : d(ULongLong) | - | ||||||||||||||||||||||||
| 1708 | { executed 87 times by 24 tests: d.data.ull = val; }end of blockExecuted by:
executed 87 times by 24 tests: end of blockExecuted by:
| 87 | ||||||||||||||||||||||||
| 1709 | QVariant::QVariant(bool val) | - | ||||||||||||||||||||||||
| 1710 | : d(Bool) | - | ||||||||||||||||||||||||
| 1711 | { executed 146913 times by 175 tests: d.data.b = val; }end of blockExecuted by:
executed 146913 times by 175 tests: end of blockExecuted by:
| 146913 | ||||||||||||||||||||||||
| 1712 | QVariant::QVariant(double val) | - | ||||||||||||||||||||||||
| 1713 | : d(Double) | - | ||||||||||||||||||||||||
| 1714 | { executed 73146 times by 75 tests: d.data.d = val; }end of blockExecuted by:
executed 73146 times by 75 tests: end of blockExecuted by:
| 73146 | ||||||||||||||||||||||||
| 1715 | QVariant::QVariant(float val) | - | ||||||||||||||||||||||||
| 1716 | : d(QMetaType::Float) | - | ||||||||||||||||||||||||
| 1717 | { executed 158 times by 16 tests: d.data.f = val; }end of blockExecuted by:
executed 158 times by 16 tests: end of blockExecuted by:
| 158 | ||||||||||||||||||||||||
| 1718 | - | |||||||||||||||||||||||||
| 1719 | QVariant::QVariant(const QByteArray &val) | - | ||||||||||||||||||||||||
| 1720 | : d(ByteArray) | - | ||||||||||||||||||||||||
| 1721 | { executed 902 times by 38 tests: v_construct<QByteArray>(&d, val); }end of blockExecuted by:
executed 902 times by 38 tests: end of blockExecuted by:
| 902 | ||||||||||||||||||||||||
| 1722 | QVariant::QVariant(const QBitArray &val) | - | ||||||||||||||||||||||||
| 1723 | : d(BitArray) | - | ||||||||||||||||||||||||
| 1724 | { executed 6 times by 1 test: v_construct<QBitArray>(&d, val); }end of blockExecuted by:
executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 1725 | QVariant::QVariant(const QString &val) | - | ||||||||||||||||||||||||
| 1726 | : d(String) | - | ||||||||||||||||||||||||
| 1727 | { executed 3991762 times by 380 tests: v_construct<QString>(&d, val); }end of blockExecuted by:
executed 3991762 times by 380 tests: end of blockExecuted by:
| 3991762 | ||||||||||||||||||||||||
| 1728 | QVariant::QVariant(QChar val) | - | ||||||||||||||||||||||||
| 1729 | : d(Char) | - | ||||||||||||||||||||||||
| 1730 | { executed 6958 times by 67 tests: v_construct<QChar>(&d, val); }end of blockExecuted by:
executed 6958 times by 67 tests: end of blockExecuted by:
| 6958 | ||||||||||||||||||||||||
| 1731 | QVariant::QVariant(QLatin1String val) | - | ||||||||||||||||||||||||
| 1732 | : d(String) | - | ||||||||||||||||||||||||
| 1733 | { executed 885 times by 35 tests: v_construct<QString>(&d, val); }end of blockExecuted by:
executed 885 times by 35 tests: end of blockExecuted by:
| 885 | ||||||||||||||||||||||||
| 1734 | QVariant::QVariant(const QStringList &val) | - | ||||||||||||||||||||||||
| 1735 | : d(StringList) | - | ||||||||||||||||||||||||
| 1736 | { executed 924 times by 59 tests: v_construct<QStringList>(&d, val); }end of blockExecuted by:
executed 924 times by 59 tests: end of blockExecuted by:
| 924 | ||||||||||||||||||||||||
| 1737 | - | |||||||||||||||||||||||||
| 1738 | QVariant::QVariant(const QDate &val) | - | ||||||||||||||||||||||||
| 1739 | : d(Date) | - | ||||||||||||||||||||||||
| 1740 | { executed 166 times by 9 tests: v_construct<QDate>(&d, val); }end of blockExecuted by:
executed 166 times by 9 tests: end of blockExecuted by:
| 166 | ||||||||||||||||||||||||
| 1741 | QVariant::QVariant(const QTime &val) | - | ||||||||||||||||||||||||
| 1742 | : d(Time) | - | ||||||||||||||||||||||||
| 1743 | { executed 66 times by 7 tests: v_construct<QTime>(&d, val); }end of blockExecuted by:
executed 66 times by 7 tests: end of blockExecuted by:
| 66 | ||||||||||||||||||||||||
| 1744 | QVariant::QVariant(const QDateTime &val) | - | ||||||||||||||||||||||||
| 1745 | : d(DateTime) | - | ||||||||||||||||||||||||
| 1746 | { executed 25042 times by 21 tests: v_construct<QDateTime>(&d, val); }end of blockExecuted by:
executed 25042 times by 21 tests: end of blockExecuted by:
| 25042 | ||||||||||||||||||||||||
| 1747 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 1748 | QVariant::QVariant(const QEasingCurve &val) | - | ||||||||||||||||||||||||
| 1749 | : d(EasingCurve) | - | ||||||||||||||||||||||||
| 1750 | { executed 3 times by 2 tests: v_construct<QEasingCurve>(&d, val); }end of blockExecuted by:
executed 3 times by 2 tests: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 1751 | #endif | - | ||||||||||||||||||||||||
| 1752 | QVariant::QVariant(const QList<QVariant> &list) | - | ||||||||||||||||||||||||
| 1753 | : d(List) | - | ||||||||||||||||||||||||
| 1754 | { executed 182 times by 19 tests: v_construct<QVariantList>(&d, list); }end of blockExecuted by:
executed 182 times by 19 tests: end of blockExecuted by:
| 182 | ||||||||||||||||||||||||
| 1755 | QVariant::QVariant(const QMap<QString, QVariant> &map) | - | ||||||||||||||||||||||||
| 1756 | : d(Map) | - | ||||||||||||||||||||||||
| 1757 | { executed 29 times by 4 tests: v_construct<QVariantMap>(&d, map); }end of blockExecuted by:
executed 29 times by 4 tests: end of blockExecuted by:
| 29 | ||||||||||||||||||||||||
| 1758 | QVariant::QVariant(const QHash<QString, QVariant> &hash) | - | ||||||||||||||||||||||||
| 1759 | : d(Hash) | - | ||||||||||||||||||||||||
| 1760 | { executed 14 times by 1 test: v_construct<QVariantHash>(&d, hash); }end of blockExecuted by:
executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||
| 1761 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
| 1762 | QVariant::QVariant(const QPoint &pt) | - | ||||||||||||||||||||||||
| 1763 | : d(Point) | - | ||||||||||||||||||||||||
| 1764 | { executed 50 times by 5 tests: v_construct<QPoint>(&d, pt); }end of blockExecuted by:
executed 50 times by 5 tests: end of blockExecuted by:
| 50 | ||||||||||||||||||||||||
| 1765 | QVariant::QVariant(const QPointF &pt) | - | ||||||||||||||||||||||||
| 1766 | : d(PointF) | - | ||||||||||||||||||||||||
| 1767 | { executed 67 times by 7 tests: v_construct<QPointF>(&d, pt); }end of blockExecuted by:
executed 67 times by 7 tests: end of blockExecuted by:
| 67 | ||||||||||||||||||||||||
| 1768 | QVariant::QVariant(const QRectF &r) | - | ||||||||||||||||||||||||
| 1769 | : d(RectF) | - | ||||||||||||||||||||||||
| 1770 | { executed 30 times by 7 tests: v_construct<QRectF>(&d, r); }end of blockExecuted by:
executed 30 times by 7 tests: end of blockExecuted by:
| 30 | ||||||||||||||||||||||||
| 1771 | QVariant::QVariant(const QLineF &l) | - | ||||||||||||||||||||||||
| 1772 | : d(LineF) | - | ||||||||||||||||||||||||
| 1773 | { executed 8 times by 3 tests: v_construct<QLineF>(&d, l); }end of blockExecuted by:
executed 8 times by 3 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 1774 | QVariant::QVariant(const QLine &l) | - | ||||||||||||||||||||||||
| 1775 | : d(Line) | - | ||||||||||||||||||||||||
| 1776 | { executed 8 times by 3 tests: v_construct<QLine>(&d, l); }end of blockExecuted by:
executed 8 times by 3 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 1777 | QVariant::QVariant(const QRect &r) | - | ||||||||||||||||||||||||
| 1778 | : d(Rect) | - | ||||||||||||||||||||||||
| 1779 | { executed 5360 times by 23 tests: v_construct<QRect>(&d, r); }end of blockExecuted by:
executed 5360 times by 23 tests: end of blockExecuted by:
| 5360 | ||||||||||||||||||||||||
| 1780 | QVariant::QVariant(const QSize &s) | - | ||||||||||||||||||||||||
| 1781 | : d(Size) | - | ||||||||||||||||||||||||
| 1782 | { executed 1215 times by 16 tests: v_construct<QSize>(&d, s); }end of blockExecuted by:
executed 1215 times by 16 tests: end of blockExecuted by:
| 1215 | ||||||||||||||||||||||||
| 1783 | QVariant::QVariant(const QSizeF &s) | - | ||||||||||||||||||||||||
| 1784 | : d(SizeF) | - | ||||||||||||||||||||||||
| 1785 | { executed 38 times by 4 tests: v_construct<QSizeF>(&d, s); }end of blockExecuted by:
executed 38 times by 4 tests: end of blockExecuted by:
| 38 | ||||||||||||||||||||||||
| 1786 | #endif | - | ||||||||||||||||||||||||
| 1787 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 1788 | QVariant::QVariant(const QUrl &u) | - | ||||||||||||||||||||||||
| 1789 | : d(Url) | - | ||||||||||||||||||||||||
| 1790 | { executed 5499 times by 10 tests: v_construct<QUrl>(&d, u); }end of blockExecuted by:
executed 5499 times by 10 tests: end of blockExecuted by:
| 5499 | ||||||||||||||||||||||||
| 1791 | #endif | - | ||||||||||||||||||||||||
| 1792 | QVariant::QVariant(const QLocale &l) | - | ||||||||||||||||||||||||
| 1793 | : d(Locale) | - | ||||||||||||||||||||||||
| 1794 | { executed 3 times by 2 tests: v_construct<QLocale>(&d, l); }end of blockExecuted by:
executed 3 times by 2 tests: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 1795 | #ifndef QT_NO_REGEXP | - | ||||||||||||||||||||||||
| 1796 | QVariant::QVariant(const QRegExp ®Exp) | - | ||||||||||||||||||||||||
| 1797 | : d(RegExp) | - | ||||||||||||||||||||||||
| 1798 | { executed 46 times by 2 tests: v_construct<QRegExp>(&d, regExp); }end of blockExecuted by:
executed 46 times by 2 tests: end of blockExecuted by:
| 46 | ||||||||||||||||||||||||
| 1799 | #endif // QT_NO_REGEXP | - | ||||||||||||||||||||||||
| 1800 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 1801 | #ifndef QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
| 1802 | QVariant::QVariant(const QRegularExpression &re) | - | ||||||||||||||||||||||||
| 1803 | : d(RegularExpression) | - | ||||||||||||||||||||||||
| 1804 | { executed 120 times by 4 tests: v_construct<QRegularExpression>(&d, re); }end of blockExecuted by:
executed 120 times by 4 tests: end of blockExecuted by:
| 120 | ||||||||||||||||||||||||
| 1805 | #endif | - | ||||||||||||||||||||||||
| 1806 | QVariant::QVariant(const QUuid &uuid) | - | ||||||||||||||||||||||||
| 1807 | : d(Uuid) | - | ||||||||||||||||||||||||
| 1808 | { executed 5 times by 1 test: v_construct<QUuid>(&d, uuid); }end of blockExecuted by:
executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 1809 | QVariant::QVariant(const QModelIndex &modelIndex) | - | ||||||||||||||||||||||||
| 1810 | : d(ModelIndex) | - | ||||||||||||||||||||||||
| 1811 | { executed 2 times by 1 test: v_construct<QModelIndex>(&d, modelIndex); }end of blockExecuted by:
executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 1812 | QVariant::QVariant(const QPersistentModelIndex &modelIndex) | - | ||||||||||||||||||||||||
| 1813 | : d(PersistentModelIndex) | - | ||||||||||||||||||||||||
| 1814 | { executed 1 time by 1 test: v_construct<QPersistentModelIndex>(&d, modelIndex); }end of blockExecuted by:
executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 1815 | QVariant::QVariant(const QJsonValue &jsonValue) | - | ||||||||||||||||||||||||
| 1816 | : d(QMetaType::QJsonValue) | - | ||||||||||||||||||||||||
| 1817 | { executed 17 times by 1 test: v_construct<QJsonValue>(&d, jsonValue); }end of blockExecuted by:
executed 17 times by 1 test: end of blockExecuted by:
| 17 | ||||||||||||||||||||||||
| 1818 | QVariant::QVariant(const QJsonObject &jsonObject) | - | ||||||||||||||||||||||||
| 1819 | : d(QMetaType::QJsonObject) | - | ||||||||||||||||||||||||
| 1820 | { executed 1 time by 1 test: v_construct<QJsonObject>(&d, jsonObject); }end of blockExecuted by:
executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 1821 | QVariant::QVariant(const QJsonArray &jsonArray) | - | ||||||||||||||||||||||||
| 1822 | : d(QMetaType::QJsonArray) | - | ||||||||||||||||||||||||
| 1823 | { executed 1 time by 1 test: v_construct<QJsonArray>(&d, jsonArray); }end of blockExecuted by:
executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 1824 | QVariant::QVariant(const QJsonDocument &jsonDocument) | - | ||||||||||||||||||||||||
| 1825 | : d(QMetaType::QJsonDocument) | - | ||||||||||||||||||||||||
| 1826 | { executed 1 time by 1 test: v_construct<QJsonDocument>(&d, jsonDocument); }end of blockExecuted by:
executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 1827 | #endif // QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 1828 | - | |||||||||||||||||||||||||
| 1829 | /*! | - | ||||||||||||||||||||||||
| 1830 | Returns the storage type of the value stored in the variant. | - | ||||||||||||||||||||||||
| 1831 | Although this function is declared as returning QVariant::Type, | - | ||||||||||||||||||||||||
| 1832 | the return value should be interpreted as QMetaType::Type. In | - | ||||||||||||||||||||||||
| 1833 | particular, QVariant::UserType is returned here only if the value | - | ||||||||||||||||||||||||
| 1834 | is equal or greater than QMetaType::User. | - | ||||||||||||||||||||||||
| 1835 | - | |||||||||||||||||||||||||
| 1836 | Note that return values in the ranges QVariant::Char through | - | ||||||||||||||||||||||||
| 1837 | QVariant::RegExp and QVariant::Font through QVariant::Transform | - | ||||||||||||||||||||||||
| 1838 | correspond to the values in the ranges QMetaType::QChar through | - | ||||||||||||||||||||||||
| 1839 | QMetaType::QRegExp and QMetaType::QFont through QMetaType::QQuaternion. | - | ||||||||||||||||||||||||
| 1840 | - | |||||||||||||||||||||||||
| 1841 | Pay particular attention when working with char and QChar | - | ||||||||||||||||||||||||
| 1842 | variants. Note that there is no QVariant constructor specifically | - | ||||||||||||||||||||||||
| 1843 | for type char, but there is one for QChar. For a variant of type | - | ||||||||||||||||||||||||
| 1844 | QChar, this function returns QVariant::Char, which is the same as | - | ||||||||||||||||||||||||
| 1845 | QMetaType::QChar, but for a variant of type \c char, this function | - | ||||||||||||||||||||||||
| 1846 | returns QMetaType::Char, which is \e not the same as | - | ||||||||||||||||||||||||
| 1847 | QVariant::Char. | - | ||||||||||||||||||||||||
| 1848 | - | |||||||||||||||||||||||||
| 1849 | Also note that the types \c void*, \c long, \c short, \c unsigned | - | ||||||||||||||||||||||||
| 1850 | \c long, \c unsigned \c short, \c unsigned \c char, \c float, \c | - | ||||||||||||||||||||||||
| 1851 | QObject*, and \c QWidget* are represented in QMetaType::Type but | - | ||||||||||||||||||||||||
| 1852 | not in QVariant::Type, and they can be returned by this function. | - | ||||||||||||||||||||||||
| 1853 | However, they are considered to be user defined types when tested | - | ||||||||||||||||||||||||
| 1854 | against QVariant::Type. | - | ||||||||||||||||||||||||
| 1855 | - | |||||||||||||||||||||||||
| 1856 | To test whether an instance of QVariant contains a data type that | - | ||||||||||||||||||||||||
| 1857 | is compatible with the data type you are interested in, use | - | ||||||||||||||||||||||||
| 1858 | canConvert(). | - | ||||||||||||||||||||||||
| 1859 | */ | - | ||||||||||||||||||||||||
| 1860 | - | |||||||||||||||||||||||||
| 1861 | QVariant::Type QVariant::type() const | - | ||||||||||||||||||||||||
| 1862 | { | - | ||||||||||||||||||||||||
| 1863 | return d.type >= QMetaType::User ? UserType : static_cast<Type>(d.type); executed 332516 times by 161 tests: return d.type >= QMetaType::User ? UserType : static_cast<Type>(d.type);Executed by:
| 332516 | ||||||||||||||||||||||||
| 1864 | } | - | ||||||||||||||||||||||||
| 1865 | - | |||||||||||||||||||||||||
| 1866 | /*! | - | ||||||||||||||||||||||||
| 1867 | Returns the storage type of the value stored in the variant. For | - | ||||||||||||||||||||||||
| 1868 | non-user types, this is the same as type(). | - | ||||||||||||||||||||||||
| 1869 | - | |||||||||||||||||||||||||
| 1870 | \sa type() | - | ||||||||||||||||||||||||
| 1871 | */ | - | ||||||||||||||||||||||||
| 1872 | - | |||||||||||||||||||||||||
| 1873 | int QVariant::userType() const | - | ||||||||||||||||||||||||
| 1874 | { | - | ||||||||||||||||||||||||
| 1875 | return d.type; executed 3327781 times by 229 tests: return d.type;Executed by:
| 3327781 | ||||||||||||||||||||||||
| 1876 | } | - | ||||||||||||||||||||||||
| 1877 | - | |||||||||||||||||||||||||
| 1878 | /*! | - | ||||||||||||||||||||||||
| 1879 | Assigns the value of the variant \a variant to this variant. | - | ||||||||||||||||||||||||
| 1880 | */ | - | ||||||||||||||||||||||||
| 1881 | QVariant& QVariant::operator=(const QVariant &variant) | - | ||||||||||||||||||||||||
| 1882 | { | - | ||||||||||||||||||||||||
| 1883 | if (this == &variant)
| 306-363869 | ||||||||||||||||||||||||
| 1884 | return *this; executed 306 times by 10 tests: return *this;Executed by:
| 306 | ||||||||||||||||||||||||
| 1885 | - | |||||||||||||||||||||||||
| 1886 | clear(); | - | ||||||||||||||||||||||||
| 1887 | if (variant.d.is_shared) {
| 1934-361935 | ||||||||||||||||||||||||
| 1888 | variant.d.data.shared->ref.ref(); | - | ||||||||||||||||||||||||
| 1889 | d = variant.d; | - | ||||||||||||||||||||||||
| 1890 | } else if (variant.d.type > Char) { executed 1934 times by 36 tests: end of blockExecuted by:
| 1934-191399 | ||||||||||||||||||||||||
| 1891 | d.type = variant.d.type; | - | ||||||||||||||||||||||||
| 1892 | handlerManager[d.type]->construct(&d, variant.constData()); | - | ||||||||||||||||||||||||
| 1893 | d.is_null = variant.d.is_null; | - | ||||||||||||||||||||||||
| 1894 | } else { executed 191399 times by 113 tests: end of blockExecuted by:
| 191399 | ||||||||||||||||||||||||
| 1895 | d = variant.d; | - | ||||||||||||||||||||||||
| 1896 | } executed 170536 times by 188 tests: end of blockExecuted by:
| 170536 | ||||||||||||||||||||||||
| 1897 | - | |||||||||||||||||||||||||
| 1898 | return *this; executed 363869 times by 211 tests: return *this;Executed by:
| 363869 | ||||||||||||||||||||||||
| 1899 | } | - | ||||||||||||||||||||||||
| 1900 | - | |||||||||||||||||||||||||
| 1901 | /*! | - | ||||||||||||||||||||||||
| 1902 | \fn void QVariant::swap(QVariant &other) | - | ||||||||||||||||||||||||
| 1903 | \since 4.8 | - | ||||||||||||||||||||||||
| 1904 | - | |||||||||||||||||||||||||
| 1905 | Swaps variant \a other with this variant. This operation is very | - | ||||||||||||||||||||||||
| 1906 | fast and never fails. | - | ||||||||||||||||||||||||
| 1907 | */ | - | ||||||||||||||||||||||||
| 1908 | - | |||||||||||||||||||||||||
| 1909 | /*! | - | ||||||||||||||||||||||||
| 1910 | \fn void QVariant::detach() | - | ||||||||||||||||||||||||
| 1911 | - | |||||||||||||||||||||||||
| 1912 | \internal | - | ||||||||||||||||||||||||
| 1913 | */ | - | ||||||||||||||||||||||||
| 1914 | - | |||||||||||||||||||||||||
| 1915 | void QVariant::detach() | - | ||||||||||||||||||||||||
| 1916 | { | - | ||||||||||||||||||||||||
| 1917 | if (!d.is_shared || d.data.shared->ref.load() == 1)
| 25-36663 | ||||||||||||||||||||||||
| 1918 | return; executed 42049 times by 164 tests: return;Executed by:
| 42049 | ||||||||||||||||||||||||
| 1919 | - | |||||||||||||||||||||||||
| 1920 | Private dd; | - | ||||||||||||||||||||||||
| 1921 | dd.type = d.type; | - | ||||||||||||||||||||||||
| 1922 | handlerManager[d.type]->construct(&dd, constData()); | - | ||||||||||||||||||||||||
| 1923 | if (!d.data.shared->ref.deref())
| 0-25 | ||||||||||||||||||||||||
| 1924 | handlerManager[d.type]->clear(&d); never executed: handlerManager[d.type]->clear(&d); | 0 | ||||||||||||||||||||||||
| 1925 | d.data.shared = dd.data.shared; | - | ||||||||||||||||||||||||
| 1926 | } executed 25 times by 7 tests: end of blockExecuted by:
| 25 | ||||||||||||||||||||||||
| 1927 | - | |||||||||||||||||||||||||
| 1928 | /*! | - | ||||||||||||||||||||||||
| 1929 | \fn bool QVariant::isDetached() const | - | ||||||||||||||||||||||||
| 1930 | - | |||||||||||||||||||||||||
| 1931 | \internal | - | ||||||||||||||||||||||||
| 1932 | */ | - | ||||||||||||||||||||||||
| 1933 | - | |||||||||||||||||||||||||
| 1934 | /*! | - | ||||||||||||||||||||||||
| 1935 | Returns the name of the type stored in the variant. The returned | - | ||||||||||||||||||||||||
| 1936 | strings describe the C++ datatype used to store the data: for | - | ||||||||||||||||||||||||
| 1937 | example, "QFont", "QString", or "QVariantList". An Invalid | - | ||||||||||||||||||||||||
| 1938 | variant returns 0. | - | ||||||||||||||||||||||||
| 1939 | */ | - | ||||||||||||||||||||||||
| 1940 | const char *QVariant::typeName() const | - | ||||||||||||||||||||||||
| 1941 | { | - | ||||||||||||||||||||||||
| 1942 | return QMetaType::typeName(d.type); executed 6025 times by 47 tests: return QMetaType::typeName(d.type);Executed by:
| 6025 | ||||||||||||||||||||||||
| 1943 | } | - | ||||||||||||||||||||||||
| 1944 | - | |||||||||||||||||||||||||
| 1945 | /*! | - | ||||||||||||||||||||||||
| 1946 | Convert this variant to type QMetaType::UnknownType and free up any resources | - | ||||||||||||||||||||||||
| 1947 | used. | - | ||||||||||||||||||||||||
| 1948 | */ | - | ||||||||||||||||||||||||
| 1949 | void QVariant::clear() | - | ||||||||||||||||||||||||
| 1950 | { | - | ||||||||||||||||||||||||
| 1951 | if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char))
| 52-391475 | ||||||||||||||||||||||||
| 1952 | handlerManager[d.type]->clear(&d); executed 132859 times by 85 tests: handlerManager[d.type]->clear(&d);Executed by:
| 132859 | ||||||||||||||||||||||||
| 1953 | d.type = Invalid; | - | ||||||||||||||||||||||||
| 1954 | d.is_null = true; | - | ||||||||||||||||||||||||
| 1955 | d.is_shared = false; | - | ||||||||||||||||||||||||
| 1956 | } executed 391633 times by 218 tests: end of blockExecuted by:
| 391633 | ||||||||||||||||||||||||
| 1957 | - | |||||||||||||||||||||||||
| 1958 | /*! | - | ||||||||||||||||||||||||
| 1959 | Converts the int representation of the storage type, \a typeId, to | - | ||||||||||||||||||||||||
| 1960 | its string representation. | - | ||||||||||||||||||||||||
| 1961 | - | |||||||||||||||||||||||||
| 1962 | Returns a null pointer if the type is QMetaType::UnknownType or doesn't exist. | - | ||||||||||||||||||||||||
| 1963 | */ | - | ||||||||||||||||||||||||
| 1964 | const char *QVariant::typeToName(int typeId) | - | ||||||||||||||||||||||||
| 1965 | { | - | ||||||||||||||||||||||||
| 1966 | return QMetaType::typeName(typeId); executed 408 times by 2 tests: return QMetaType::typeName(typeId);Executed by:
| 408 | ||||||||||||||||||||||||
| 1967 | } | - | ||||||||||||||||||||||||
| 1968 | - | |||||||||||||||||||||||||
| 1969 | - | |||||||||||||||||||||||||
| 1970 | /*! | - | ||||||||||||||||||||||||
| 1971 | Converts the string representation of the storage type given in \a | - | ||||||||||||||||||||||||
| 1972 | name, to its enum representation. | - | ||||||||||||||||||||||||
| 1973 | - | |||||||||||||||||||||||||
| 1974 | If the string representation cannot be converted to any enum | - | ||||||||||||||||||||||||
| 1975 | representation, the variant is set to \c Invalid. | - | ||||||||||||||||||||||||
| 1976 | */ | - | ||||||||||||||||||||||||
| 1977 | QVariant::Type QVariant::nameToType(const char *name) | - | ||||||||||||||||||||||||
| 1978 | { | - | ||||||||||||||||||||||||
| 1979 | int metaType = QMetaType::type(name); | - | ||||||||||||||||||||||||
| 1980 | return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType; executed 81 times by 1 test: return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType;Executed by:
| 81 | ||||||||||||||||||||||||
| 1981 | } | - | ||||||||||||||||||||||||
| 1982 | - | |||||||||||||||||||||||||
| 1983 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 1984 | enum { MapFromThreeCount = 36 }; | - | ||||||||||||||||||||||||
| 1985 | static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = | - | ||||||||||||||||||||||||
| 1986 | { | - | ||||||||||||||||||||||||
| 1987 | QVariant::Invalid, | - | ||||||||||||||||||||||||
| 1988 | QVariant::Map, | - | ||||||||||||||||||||||||
| 1989 | QVariant::List, | - | ||||||||||||||||||||||||
| 1990 | QVariant::String, | - | ||||||||||||||||||||||||
| 1991 | QVariant::StringList, | - | ||||||||||||||||||||||||
| 1992 | QVariant::Font, | - | ||||||||||||||||||||||||
| 1993 | QVariant::Pixmap, | - | ||||||||||||||||||||||||
| 1994 | QVariant::Brush, | - | ||||||||||||||||||||||||
| 1995 | QVariant::Rect, | - | ||||||||||||||||||||||||
| 1996 | QVariant::Size, | - | ||||||||||||||||||||||||
| 1997 | QVariant::Color, | - | ||||||||||||||||||||||||
| 1998 | QVariant::Palette, | - | ||||||||||||||||||||||||
| 1999 | 0, // ColorGroup | - | ||||||||||||||||||||||||
| 2000 | QVariant::Icon, | - | ||||||||||||||||||||||||
| 2001 | QVariant::Point, | - | ||||||||||||||||||||||||
| 2002 | QVariant::Image, | - | ||||||||||||||||||||||||
| 2003 | QVariant::Int, | - | ||||||||||||||||||||||||
| 2004 | QVariant::UInt, | - | ||||||||||||||||||||||||
| 2005 | QVariant::Bool, | - | ||||||||||||||||||||||||
| 2006 | QVariant::Double, | - | ||||||||||||||||||||||||
| 2007 | 0, // Buggy ByteArray, QByteArray never had id == 20 | - | ||||||||||||||||||||||||
| 2008 | QVariant::Polygon, | - | ||||||||||||||||||||||||
| 2009 | QVariant::Region, | - | ||||||||||||||||||||||||
| 2010 | QVariant::Bitmap, | - | ||||||||||||||||||||||||
| 2011 | QVariant::Cursor, | - | ||||||||||||||||||||||||
| 2012 | QVariant::SizePolicy, | - | ||||||||||||||||||||||||
| 2013 | QVariant::Date, | - | ||||||||||||||||||||||||
| 2014 | QVariant::Time, | - | ||||||||||||||||||||||||
| 2015 | QVariant::DateTime, | - | ||||||||||||||||||||||||
| 2016 | QVariant::ByteArray, | - | ||||||||||||||||||||||||
| 2017 | QVariant::BitArray, | - | ||||||||||||||||||||||||
| 2018 | QVariant::KeySequence, | - | ||||||||||||||||||||||||
| 2019 | QVariant::Pen, | - | ||||||||||||||||||||||||
| 2020 | QVariant::LongLong, | - | ||||||||||||||||||||||||
| 2021 | QVariant::ULongLong, | - | ||||||||||||||||||||||||
| 2022 | QVariant::EasingCurve | - | ||||||||||||||||||||||||
| 2023 | }; | - | ||||||||||||||||||||||||
| 2024 | - | |||||||||||||||||||||||||
| 2025 | /*! | - | ||||||||||||||||||||||||
| 2026 | Internal function for loading a variant from stream \a s. Use the | - | ||||||||||||||||||||||||
| 2027 | stream operators instead. | - | ||||||||||||||||||||||||
| 2028 | - | |||||||||||||||||||||||||
| 2029 | \internal | - | ||||||||||||||||||||||||
| 2030 | */ | - | ||||||||||||||||||||||||
| 2031 | void QVariant::load(QDataStream &s) | - | ||||||||||||||||||||||||
| 2032 | { | - | ||||||||||||||||||||||||
| 2033 | clear(); | - | ||||||||||||||||||||||||
| 2034 | - | |||||||||||||||||||||||||
| 2035 | quint32 typeId; | - | ||||||||||||||||||||||||
| 2036 | s >> typeId; | - | ||||||||||||||||||||||||
| 2037 | if (s.version() < QDataStream::Qt_4_0) {
| 1-16322 | ||||||||||||||||||||||||
| 2038 | if (typeId >= MapFromThreeCount)
| 0-1 | ||||||||||||||||||||||||
| 2039 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2040 | typeId = mapIdFromQt3ToCurrent[typeId]; | - | ||||||||||||||||||||||||
| 2041 | } else if (s.version() < QDataStream::Qt_5_0) { executed 1 time by 1 test: end of blockExecuted by:
| 1-15915 | ||||||||||||||||||||||||
| 2042 | if (typeId == 127 /* QVariant::UserType */) {
| 1-406 | ||||||||||||||||||||||||
| 2043 | typeId = QMetaType::User; | - | ||||||||||||||||||||||||
| 2044 | } else if (typeId >= 128 && typeId != QVariant::UserType) { executed 1 time by 1 test: end of blockExecuted by:
| 0-390 | ||||||||||||||||||||||||
| 2045 | // In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes | - | ||||||||||||||||||||||||
| 2046 | // by moving all ids down by 97. | - | ||||||||||||||||||||||||
| 2047 | typeId -= 97; | - | ||||||||||||||||||||||||
| 2048 | } else if (typeId == 75 /* QSizePolicy */) { executed 16 times by 1 test: end of blockExecuted by:
| 0-390 | ||||||||||||||||||||||||
| 2049 | typeId = QMetaType::QSizePolicy; | - | ||||||||||||||||||||||||
| 2050 | } else if (typeId > 75 && typeId <= 86) { never executed: end of block
| 0-390 | ||||||||||||||||||||||||
| 2051 | // and as a result these types received lower ids too | - | ||||||||||||||||||||||||
| 2052 | // QKeySequence QPen QTextLength QTextFormat QMatrix QTransform QMatrix4x4 QVector2D QVector3D QVector4D QQuaternion | - | ||||||||||||||||||||||||
| 2053 | typeId -=1; | - | ||||||||||||||||||||||||
| 2054 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2055 | } executed 407 times by 3 tests: end of blockExecuted by:
| 407 | ||||||||||||||||||||||||
| 2056 | - | |||||||||||||||||||||||||
| 2057 | qint8 is_null = false; | - | ||||||||||||||||||||||||
| 2058 | if (s.version() >= QDataStream::Qt_4_2)
| 332-15991 | ||||||||||||||||||||||||
| 2059 | s >> is_null; executed 15991 times by 15 tests: s >> is_null;Executed by:
| 15991 | ||||||||||||||||||||||||
| 2060 | if (typeId == QVariant::UserType) {
| 4-16319 | ||||||||||||||||||||||||
| 2061 | QByteArray name; | - | ||||||||||||||||||||||||
| 2062 | s >> name; | - | ||||||||||||||||||||||||
| 2063 | typeId = QMetaType::type(name.constData()); | - | ||||||||||||||||||||||||
| 2064 | if (typeId == QMetaType::UnknownType) {
| 0-4 | ||||||||||||||||||||||||
| 2065 | s.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
| 2066 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2067 | } | - | ||||||||||||||||||||||||
| 2068 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 2069 | create(typeId, 0); | - | ||||||||||||||||||||||||
| 2070 | d.is_null = is_null; | - | ||||||||||||||||||||||||
| 2071 | - | |||||||||||||||||||||||||
| 2072 | if (!isValid()) {
| 13-16310 | ||||||||||||||||||||||||
| 2073 | if (s.version() < QDataStream::Qt_5_0) {
| 3-10 | ||||||||||||||||||||||||
| 2074 | // Since we wrote something, we should read something | - | ||||||||||||||||||||||||
| 2075 | QString x; | - | ||||||||||||||||||||||||
| 2076 | s >> x; | - | ||||||||||||||||||||||||
| 2077 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 2078 | d.is_null = true; | - | ||||||||||||||||||||||||
| 2079 | return; executed 13 times by 2 tests: return;Executed by:
| 13 | ||||||||||||||||||||||||
| 2080 | } | - | ||||||||||||||||||||||||
| 2081 | - | |||||||||||||||||||||||||
| 2082 | // const cast is safe since we operate on a newly constructed variant | - | ||||||||||||||||||||||||
| 2083 | if (!QMetaType::load(s, d.type, const_cast<void *>(constData()))) {
| 1-16309 | ||||||||||||||||||||||||
| 2084 | s.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
| 2085 | qWarning("QVariant::load: unable to load type %d.", d.type); | - | ||||||||||||||||||||||||
| 2086 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 2087 | } executed 16310 times by 14 tests: end of blockExecuted by:
| 16310 | ||||||||||||||||||||||||
| 2088 | - | |||||||||||||||||||||||||
| 2089 | /*! | - | ||||||||||||||||||||||||
| 2090 | Internal function for saving a variant to the stream \a s. Use the | - | ||||||||||||||||||||||||
| 2091 | stream operators instead. | - | ||||||||||||||||||||||||
| 2092 | - | |||||||||||||||||||||||||
| 2093 | \internal | - | ||||||||||||||||||||||||
| 2094 | */ | - | ||||||||||||||||||||||||
| 2095 | void QVariant::save(QDataStream &s) const | - | ||||||||||||||||||||||||
| 2096 | { | - | ||||||||||||||||||||||||
| 2097 | quint32 typeId = type(); | - | ||||||||||||||||||||||||
| 2098 | bool fakeUserType = false; | - | ||||||||||||||||||||||||
| 2099 | if (s.version() < QDataStream::Qt_4_0) {
| 9-16343 | ||||||||||||||||||||||||
| 2100 | int i; | - | ||||||||||||||||||||||||
| 2101 | for (i = 0; i <= MapFromThreeCount - 1; ++i) {
| 1-76 | ||||||||||||||||||||||||
| 2102 | if (mapIdFromQt3ToCurrent[i] == typeId) {
| 8-68 | ||||||||||||||||||||||||
| 2103 | typeId = i; | - | ||||||||||||||||||||||||
| 2104 | break; executed 8 times by 2 tests: break;Executed by:
| 8 | ||||||||||||||||||||||||
| 2105 | } | - | ||||||||||||||||||||||||
| 2106 | } executed 68 times by 2 tests: end of blockExecuted by:
| 68 | ||||||||||||||||||||||||
| 2107 | if (i >= MapFromThreeCount) {
| 1-8 | ||||||||||||||||||||||||
| 2108 | s << QVariant(); | - | ||||||||||||||||||||||||
| 2109 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||
| 2110 | } | - | ||||||||||||||||||||||||
| 2111 | } else if (s.version() < QDataStream::Qt_5_0) { executed 8 times by 2 tests: end of blockExecuted by:
| 8-15916 | ||||||||||||||||||||||||
| 2112 | if (typeId == QMetaType::User) {
| 0-427 | ||||||||||||||||||||||||
| 2113 | typeId = 127; // QVariant::UserType had this value in Qt4 | - | ||||||||||||||||||||||||
| 2114 | } else if (typeId >= 128 - 97 && typeId <= LastCoreType) { never executed: end of block
| 0-368 | ||||||||||||||||||||||||
| 2115 | // In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes | - | ||||||||||||||||||||||||
| 2116 | // by moving all ids down by 97. | - | ||||||||||||||||||||||||
| 2117 | typeId += 97; | - | ||||||||||||||||||||||||
| 2118 | } else if (typeId == QMetaType::QSizePolicy) { executed 8 times by 1 test: end of blockExecuted by:
| 0-419 | ||||||||||||||||||||||||
| 2119 | typeId = 75; | - | ||||||||||||||||||||||||
| 2120 | } else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) { never executed: end of block
| 0-419 | ||||||||||||||||||||||||
| 2121 | // and as a result these types received lower ids too | - | ||||||||||||||||||||||||
| 2122 | typeId +=1; | - | ||||||||||||||||||||||||
| 2123 | } else if (typeId == QMetaType::QPolygonF) { never executed: end of block
| 0-419 | ||||||||||||||||||||||||
| 2124 | // This existed in Qt 4 only as a custom type | - | ||||||||||||||||||||||||
| 2125 | typeId = 127; | - | ||||||||||||||||||||||||
| 2126 | fakeUserType = true; | - | ||||||||||||||||||||||||
| 2127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2128 | } executed 427 times by 2 tests: end of blockExecuted by:
| 427 | ||||||||||||||||||||||||
| 2129 | s << typeId; | - | ||||||||||||||||||||||||
| 2130 | if (s.version() >= QDataStream::Qt_4_2)
| 393-15958 | ||||||||||||||||||||||||
| 2131 | s << qint8(d.is_null); executed 15958 times by 16 tests: s << qint8(d.is_null);Executed by:
| 15958 | ||||||||||||||||||||||||
| 2132 | if (d.type >= QVariant::UserType || fakeUserType) {
| 0-16349 | ||||||||||||||||||||||||
| 2133 | s << QMetaType::typeName(userType()); | - | ||||||||||||||||||||||||
| 2134 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 2135 | - | |||||||||||||||||||||||||
| 2136 | if (!isValid()) {
| 18-16333 | ||||||||||||||||||||||||
| 2137 | if (s.version() < QDataStream::Qt_5_0)
| 5-13 | ||||||||||||||||||||||||
| 2138 | s << QString(); executed 13 times by 1 test: s << QString();Executed by:
| 13 | ||||||||||||||||||||||||
| 2139 | return; executed 18 times by 2 tests: return;Executed by:
| 18 | ||||||||||||||||||||||||
| 2140 | } | - | ||||||||||||||||||||||||
| 2141 | - | |||||||||||||||||||||||||
| 2142 | if (!QMetaType::save(s, d.type, constData())) {
| 0-16333 | ||||||||||||||||||||||||
| 2143 | qWarning("QVariant::save: unable to save type '%s' (type id: %d).\n", QMetaType::typeName(d.type), d.type); | - | ||||||||||||||||||||||||
| 2144 | Q_ASSERT_X(false, "QVariant::save", "Invalid type to save"); | - | ||||||||||||||||||||||||
| 2145 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2146 | } executed 16333 times by 15 tests: end of blockExecuted by:
| 16333 | ||||||||||||||||||||||||
| 2147 | - | |||||||||||||||||||||||||
| 2148 | /*! | - | ||||||||||||||||||||||||
| 2149 | \since 4.4 | - | ||||||||||||||||||||||||
| 2150 | - | |||||||||||||||||||||||||
| 2151 | Reads a variant \a p from the stream \a s. | - | ||||||||||||||||||||||||
| 2152 | - | |||||||||||||||||||||||||
| 2153 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||||||||||||||
| 2154 | */ | - | ||||||||||||||||||||||||
| 2155 | QDataStream& operator>>(QDataStream &s, QVariant &p) | - | ||||||||||||||||||||||||
| 2156 | { | - | ||||||||||||||||||||||||
| 2157 | p.load(s); | - | ||||||||||||||||||||||||
| 2158 | return s; executed 16321 times by 15 tests: return s;Executed by:
| 16321 | ||||||||||||||||||||||||
| 2159 | } | - | ||||||||||||||||||||||||
| 2160 | - | |||||||||||||||||||||||||
| 2161 | /*! | - | ||||||||||||||||||||||||
| 2162 | Writes a variant \a p to the stream \a s. | - | ||||||||||||||||||||||||
| 2163 | - | |||||||||||||||||||||||||
| 2164 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||||||||||||||
| 2165 | */ | - | ||||||||||||||||||||||||
| 2166 | QDataStream& operator<<(QDataStream &s, const QVariant &p) | - | ||||||||||||||||||||||||
| 2167 | { | - | ||||||||||||||||||||||||
| 2168 | p.save(s); | - | ||||||||||||||||||||||||
| 2169 | return s; executed 16352 times by 16 tests: return s;Executed by:
| 16352 | ||||||||||||||||||||||||
| 2170 | } | - | ||||||||||||||||||||||||
| 2171 | - | |||||||||||||||||||||||||
| 2172 | /*! | - | ||||||||||||||||||||||||
| 2173 | Reads a variant type \a p in enum representation from the stream \a s. | - | ||||||||||||||||||||||||
| 2174 | */ | - | ||||||||||||||||||||||||
| 2175 | QDataStream& operator>>(QDataStream &s, QVariant::Type &p) | - | ||||||||||||||||||||||||
| 2176 | { | - | ||||||||||||||||||||||||
| 2177 | quint32 u; | - | ||||||||||||||||||||||||
| 2178 | s >> u; | - | ||||||||||||||||||||||||
| 2179 | p = (QVariant::Type)u; | - | ||||||||||||||||||||||||
| 2180 | - | |||||||||||||||||||||||||
| 2181 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||
| 2182 | } | - | ||||||||||||||||||||||||
| 2183 | - | |||||||||||||||||||||||||
| 2184 | /*! | - | ||||||||||||||||||||||||
| 2185 | Writes a variant type \a p to the stream \a s. | - | ||||||||||||||||||||||||
| 2186 | */ | - | ||||||||||||||||||||||||
| 2187 | QDataStream& operator<<(QDataStream &s, const QVariant::Type p) | - | ||||||||||||||||||||||||
| 2188 | { | - | ||||||||||||||||||||||||
| 2189 | s << static_cast<quint32>(p); | - | ||||||||||||||||||||||||
| 2190 | - | |||||||||||||||||||||||||
| 2191 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||
| 2192 | } | - | ||||||||||||||||||||||||
| 2193 | - | |||||||||||||||||||||||||
| 2194 | #endif //QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
| 2195 | - | |||||||||||||||||||||||||
| 2196 | /*! | - | ||||||||||||||||||||||||
| 2197 | \fn bool QVariant::isValid() const | - | ||||||||||||||||||||||||
| 2198 | - | |||||||||||||||||||||||||
| 2199 | Returns \c true if the storage type of this variant is not | - | ||||||||||||||||||||||||
| 2200 | QMetaType::UnknownType; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 2201 | */ | - | ||||||||||||||||||||||||
| 2202 | - | |||||||||||||||||||||||||
| 2203 | template <typename T> | - | ||||||||||||||||||||||||
| 2204 | inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &handlerManager) | - | ||||||||||||||||||||||||
| 2205 | { | - | ||||||||||||||||||||||||
| 2206 | const uint targetType = qMetaTypeId<T>(); | - | ||||||||||||||||||||||||
| 2207 | if (d.type == targetType)
| 81330-627552 | ||||||||||||||||||||||||
| 2208 | return *v_cast<T>(&d); executed 627552 times by 263 tests: return *v_cast<T>(&d);Executed by:
| 627552 | ||||||||||||||||||||||||
| 2209 | - | |||||||||||||||||||||||||
| 2210 | T ret; | - | ||||||||||||||||||||||||
| 2211 | if (d.type >= QMetaType::User || targetType >= QMetaType::User) {
| 0-81161 | ||||||||||||||||||||||||
| 2212 | const void * const from = constData(d); | - | ||||||||||||||||||||||||
| 2213 | if (QMetaType::convert(from, d.type, &ret, targetType))
| 18-151 | ||||||||||||||||||||||||
| 2214 | return ret; executed 18 times by 2 tests: return ret;Executed by:
| 18 | ||||||||||||||||||||||||
| 2215 | } executed 151 times by 2 tests: end of blockExecuted by:
| 151 | ||||||||||||||||||||||||
| 2216 | - | |||||||||||||||||||||||||
| 2217 | handlerManager[d.type]->convert(&d, targetType, &ret, 0); | - | ||||||||||||||||||||||||
| 2218 | return ret; executed 81312 times by 98 tests: return ret;Executed by:
| 81312 | ||||||||||||||||||||||||
| 2219 | } | - | ||||||||||||||||||||||||
| 2220 | - | |||||||||||||||||||||||||
| 2221 | /*! | - | ||||||||||||||||||||||||
| 2222 | \fn QStringList QVariant::toStringList() const | - | ||||||||||||||||||||||||
| 2223 | - | |||||||||||||||||||||||||
| 2224 | Returns the variant as a QStringList if the variant has userType() | - | ||||||||||||||||||||||||
| 2225 | \l QMetaType::QStringList, \l QMetaType::QString, or | - | ||||||||||||||||||||||||
| 2226 | \l QMetaType::QVariantList of a type that can be converted to QString; | - | ||||||||||||||||||||||||
| 2227 | otherwise returns an empty list. | - | ||||||||||||||||||||||||
| 2228 | - | |||||||||||||||||||||||||
| 2229 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2230 | */ | - | ||||||||||||||||||||||||
| 2231 | QStringList QVariant::toStringList() const | - | ||||||||||||||||||||||||
| 2232 | { | - | ||||||||||||||||||||||||
| 2233 | return qVariantToHelper<QStringList>(d, handlerManager); executed 1054 times by 54 tests: return qVariantToHelper<QStringList>(d, handlerManager);Executed by:
| 1054 | ||||||||||||||||||||||||
| 2234 | } | - | ||||||||||||||||||||||||
| 2235 | - | |||||||||||||||||||||||||
| 2236 | /*! | - | ||||||||||||||||||||||||
| 2237 | Returns the variant as a QString if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2238 | QMetaType::QString, \l QMetaType::Bool, \l QMetaType::QByteArray, | - | ||||||||||||||||||||||||
| 2239 | \l QMetaType::QChar, \l QMetaType::QDate, \l QMetaType::QDateTime, | - | ||||||||||||||||||||||||
| 2240 | \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
| 2241 | \l QMetaType::QStringList, \l QMetaType::QTime, \l QMetaType::UInt, or | - | ||||||||||||||||||||||||
| 2242 | \l QMetaType::ULongLong; otherwise returns an empty string. | - | ||||||||||||||||||||||||
| 2243 | - | |||||||||||||||||||||||||
| 2244 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2245 | */ | - | ||||||||||||||||||||||||
| 2246 | QString QVariant::toString() const | - | ||||||||||||||||||||||||
| 2247 | { | - | ||||||||||||||||||||||||
| 2248 | return qVariantToHelper<QString>(d, handlerManager); executed 542207 times by 262 tests: return qVariantToHelper<QString>(d, handlerManager);Executed by:
| 542207 | ||||||||||||||||||||||||
| 2249 | } | - | ||||||||||||||||||||||||
| 2250 | - | |||||||||||||||||||||||||
| 2251 | /*! | - | ||||||||||||||||||||||||
| 2252 | Returns the variant as a QMap<QString, QVariant> if the variant | - | ||||||||||||||||||||||||
| 2253 | has type() \l QMetaType::QVariantMap; otherwise returns an empty map. | - | ||||||||||||||||||||||||
| 2254 | - | |||||||||||||||||||||||||
| 2255 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2256 | */ | - | ||||||||||||||||||||||||
| 2257 | QVariantMap QVariant::toMap() const | - | ||||||||||||||||||||||||
| 2258 | { | - | ||||||||||||||||||||||||
| 2259 | return qVariantToHelper<QVariantMap>(d, handlerManager); executed 7 times by 3 tests: return qVariantToHelper<QVariantMap>(d, handlerManager);Executed by:
| 7 | ||||||||||||||||||||||||
| 2260 | } | - | ||||||||||||||||||||||||
| 2261 | - | |||||||||||||||||||||||||
| 2262 | /*! | - | ||||||||||||||||||||||||
| 2263 | Returns the variant as a QHash<QString, QVariant> if the variant | - | ||||||||||||||||||||||||
| 2264 | has type() \l QMetaType::QVariantHash; otherwise returns an empty map. | - | ||||||||||||||||||||||||
| 2265 | - | |||||||||||||||||||||||||
| 2266 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2267 | */ | - | ||||||||||||||||||||||||
| 2268 | QVariantHash QVariant::toHash() const | - | ||||||||||||||||||||||||
| 2269 | { | - | ||||||||||||||||||||||||
| 2270 | return qVariantToHelper<QVariantHash>(d, handlerManager); executed 2 times by 1 test: return qVariantToHelper<QVariantHash>(d, handlerManager);Executed by:
| 2 | ||||||||||||||||||||||||
| 2271 | } | - | ||||||||||||||||||||||||
| 2272 | - | |||||||||||||||||||||||||
| 2273 | /*! | - | ||||||||||||||||||||||||
| 2274 | \fn QDate QVariant::toDate() const | - | ||||||||||||||||||||||||
| 2275 | - | |||||||||||||||||||||||||
| 2276 | Returns the variant as a QDate if the variant has userType() | - | ||||||||||||||||||||||||
| 2277 | \l QMetaType::QDate, \l QMetaType::QDateTime, or \l QMetaType::QString; | - | ||||||||||||||||||||||||
| 2278 | otherwise returns an invalid date. | - | ||||||||||||||||||||||||
| 2279 | - | |||||||||||||||||||||||||
| 2280 | If the type() is \l QMetaType::QString, an invalid date will be returned if | - | ||||||||||||||||||||||||
| 2281 | the string cannot be parsed as a Qt::ISODate format date. | - | ||||||||||||||||||||||||
| 2282 | - | |||||||||||||||||||||||||
| 2283 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2284 | */ | - | ||||||||||||||||||||||||
| 2285 | QDate QVariant::toDate() const | - | ||||||||||||||||||||||||
| 2286 | { | - | ||||||||||||||||||||||||
| 2287 | return qVariantToHelper<QDate>(d, handlerManager); executed 12853 times by 6 tests: return qVariantToHelper<QDate>(d, handlerManager);Executed by:
| 12853 | ||||||||||||||||||||||||
| 2288 | } | - | ||||||||||||||||||||||||
| 2289 | - | |||||||||||||||||||||||||
| 2290 | /*! | - | ||||||||||||||||||||||||
| 2291 | \fn QTime QVariant::toTime() const | - | ||||||||||||||||||||||||
| 2292 | - | |||||||||||||||||||||||||
| 2293 | Returns the variant as a QTime if the variant has userType() | - | ||||||||||||||||||||||||
| 2294 | \l QMetaType::QTime, \l QMetaType::QDateTime, or \l QMetaType::QString; | - | ||||||||||||||||||||||||
| 2295 | otherwise returns an invalid time. | - | ||||||||||||||||||||||||
| 2296 | - | |||||||||||||||||||||||||
| 2297 | If the type() is \l QMetaType::QString, an invalid time will be returned if | - | ||||||||||||||||||||||||
| 2298 | the string cannot be parsed as a Qt::ISODate format time. | - | ||||||||||||||||||||||||
| 2299 | - | |||||||||||||||||||||||||
| 2300 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2301 | */ | - | ||||||||||||||||||||||||
| 2302 | QTime QVariant::toTime() const | - | ||||||||||||||||||||||||
| 2303 | { | - | ||||||||||||||||||||||||
| 2304 | return qVariantToHelper<QTime>(d, handlerManager); executed 11023 times by 7 tests: return qVariantToHelper<QTime>(d, handlerManager);Executed by:
| 11023 | ||||||||||||||||||||||||
| 2305 | } | - | ||||||||||||||||||||||||
| 2306 | - | |||||||||||||||||||||||||
| 2307 | /*! | - | ||||||||||||||||||||||||
| 2308 | \fn QDateTime QVariant::toDateTime() const | - | ||||||||||||||||||||||||
| 2309 | - | |||||||||||||||||||||||||
| 2310 | Returns the variant as a QDateTime if the variant has userType() | - | ||||||||||||||||||||||||
| 2311 | \l QMetaType::QDateTime, \l QMetaType::QDate, or \l QMetaType::QString; | - | ||||||||||||||||||||||||
| 2312 | otherwise returns an invalid date/time. | - | ||||||||||||||||||||||||
| 2313 | - | |||||||||||||||||||||||||
| 2314 | If the type() is \l QMetaType::QString, an invalid date/time will be | - | ||||||||||||||||||||||||
| 2315 | returned if the string cannot be parsed as a Qt::ISODate format date/time. | - | ||||||||||||||||||||||||
| 2316 | - | |||||||||||||||||||||||||
| 2317 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2318 | */ | - | ||||||||||||||||||||||||
| 2319 | QDateTime QVariant::toDateTime() const | - | ||||||||||||||||||||||||
| 2320 | { | - | ||||||||||||||||||||||||
| 2321 | return qVariantToHelper<QDateTime>(d, handlerManager); executed 128015 times by 19 tests: return qVariantToHelper<QDateTime>(d, handlerManager);Executed by:
| 128015 | ||||||||||||||||||||||||
| 2322 | } | - | ||||||||||||||||||||||||
| 2323 | - | |||||||||||||||||||||||||
| 2324 | /*! | - | ||||||||||||||||||||||||
| 2325 | \since 4.7 | - | ||||||||||||||||||||||||
| 2326 | \fn QEasingCurve QVariant::toEasingCurve() const | - | ||||||||||||||||||||||||
| 2327 | - | |||||||||||||||||||||||||
| 2328 | Returns the variant as a QEasingCurve if the variant has userType() | - | ||||||||||||||||||||||||
| 2329 | \l QMetaType::QEasingCurve; otherwise returns a default easing curve. | - | ||||||||||||||||||||||||
| 2330 | - | |||||||||||||||||||||||||
| 2331 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2332 | */ | - | ||||||||||||||||||||||||
| 2333 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 2334 | QEasingCurve QVariant::toEasingCurve() const | - | ||||||||||||||||||||||||
| 2335 | { | - | ||||||||||||||||||||||||
| 2336 | return qVariantToHelper<QEasingCurve>(d, handlerManager); executed 3 times by 2 tests: return qVariantToHelper<QEasingCurve>(d, handlerManager);Executed by:
| 3 | ||||||||||||||||||||||||
| 2337 | } | - | ||||||||||||||||||||||||
| 2338 | #endif | - | ||||||||||||||||||||||||
| 2339 | - | |||||||||||||||||||||||||
| 2340 | /*! | - | ||||||||||||||||||||||||
| 2341 | \fn QByteArray QVariant::toByteArray() const | - | ||||||||||||||||||||||||
| 2342 | - | |||||||||||||||||||||||||
| 2343 | Returns the variant as a QByteArray if the variant has userType() | - | ||||||||||||||||||||||||
| 2344 | \l QMetaType::QByteArray or \l QMetaType::QString (converted using | - | ||||||||||||||||||||||||
| 2345 | QString::fromUtf8()); otherwise returns an empty byte array. | - | ||||||||||||||||||||||||
| 2346 | - | |||||||||||||||||||||||||
| 2347 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2348 | */ | - | ||||||||||||||||||||||||
| 2349 | QByteArray QVariant::toByteArray() const | - | ||||||||||||||||||||||||
| 2350 | { | - | ||||||||||||||||||||||||
| 2351 | return qVariantToHelper<QByteArray>(d, handlerManager); executed 1650 times by 53 tests: return qVariantToHelper<QByteArray>(d, handlerManager);Executed by:
| 1650 | ||||||||||||||||||||||||
| 2352 | } | - | ||||||||||||||||||||||||
| 2353 | - | |||||||||||||||||||||||||
| 2354 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
| 2355 | /*! | - | ||||||||||||||||||||||||
| 2356 | \fn QPoint QVariant::toPoint() const | - | ||||||||||||||||||||||||
| 2357 | - | |||||||||||||||||||||||||
| 2358 | Returns the variant as a QPoint if the variant has userType() | - | ||||||||||||||||||||||||
| 2359 | \l QMetaType::QPointF or \l QMetaType::QPointF; otherwise returns a null | - | ||||||||||||||||||||||||
| 2360 | QPoint. | - | ||||||||||||||||||||||||
| 2361 | - | |||||||||||||||||||||||||
| 2362 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2363 | */ | - | ||||||||||||||||||||||||
| 2364 | QPoint QVariant::toPoint() const | - | ||||||||||||||||||||||||
| 2365 | { | - | ||||||||||||||||||||||||
| 2366 | return qVariantToHelper<QPoint>(d, handlerManager); executed 34 times by 5 tests: return qVariantToHelper<QPoint>(d, handlerManager);Executed by:
| 34 | ||||||||||||||||||||||||
| 2367 | } | - | ||||||||||||||||||||||||
| 2368 | - | |||||||||||||||||||||||||
| 2369 | /*! | - | ||||||||||||||||||||||||
| 2370 | \fn QRect QVariant::toRect() const | - | ||||||||||||||||||||||||
| 2371 | - | |||||||||||||||||||||||||
| 2372 | Returns the variant as a QRect if the variant has userType() | - | ||||||||||||||||||||||||
| 2373 | \l QMetaType::QRect; otherwise returns an invalid QRect. | - | ||||||||||||||||||||||||
| 2374 | - | |||||||||||||||||||||||||
| 2375 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2376 | */ | - | ||||||||||||||||||||||||
| 2377 | QRect QVariant::toRect() const | - | ||||||||||||||||||||||||
| 2378 | { | - | ||||||||||||||||||||||||
| 2379 | return qVariantToHelper<QRect>(d, handlerManager); executed 129 times by 10 tests: return qVariantToHelper<QRect>(d, handlerManager);Executed by:
| 129 | ||||||||||||||||||||||||
| 2380 | } | - | ||||||||||||||||||||||||
| 2381 | - | |||||||||||||||||||||||||
| 2382 | /*! | - | ||||||||||||||||||||||||
| 2383 | \fn QSize QVariant::toSize() const | - | ||||||||||||||||||||||||
| 2384 | - | |||||||||||||||||||||||||
| 2385 | Returns the variant as a QSize if the variant has userType() | - | ||||||||||||||||||||||||
| 2386 | \l QMetaType::QSize; otherwise returns an invalid QSize. | - | ||||||||||||||||||||||||
| 2387 | - | |||||||||||||||||||||||||
| 2388 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2389 | */ | - | ||||||||||||||||||||||||
| 2390 | QSize QVariant::toSize() const | - | ||||||||||||||||||||||||
| 2391 | { | - | ||||||||||||||||||||||||
| 2392 | return qVariantToHelper<QSize>(d, handlerManager); executed 166 times by 10 tests: return qVariantToHelper<QSize>(d, handlerManager);Executed by:
| 166 | ||||||||||||||||||||||||
| 2393 | } | - | ||||||||||||||||||||||||
| 2394 | - | |||||||||||||||||||||||||
| 2395 | /*! | - | ||||||||||||||||||||||||
| 2396 | \fn QSizeF QVariant::toSizeF() const | - | ||||||||||||||||||||||||
| 2397 | - | |||||||||||||||||||||||||
| 2398 | Returns the variant as a QSizeF if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2399 | QMetaType::QSizeF; otherwise returns an invalid QSizeF. | - | ||||||||||||||||||||||||
| 2400 | - | |||||||||||||||||||||||||
| 2401 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2402 | */ | - | ||||||||||||||||||||||||
| 2403 | QSizeF QVariant::toSizeF() const | - | ||||||||||||||||||||||||
| 2404 | { | - | ||||||||||||||||||||||||
| 2405 | return qVariantToHelper<QSizeF>(d, handlerManager); executed 92 times by 3 tests: return qVariantToHelper<QSizeF>(d, handlerManager);Executed by:
| 92 | ||||||||||||||||||||||||
| 2406 | } | - | ||||||||||||||||||||||||
| 2407 | - | |||||||||||||||||||||||||
| 2408 | /*! | - | ||||||||||||||||||||||||
| 2409 | \fn QRectF QVariant::toRectF() const | - | ||||||||||||||||||||||||
| 2410 | - | |||||||||||||||||||||||||
| 2411 | Returns the variant as a QRectF if the variant has userType() | - | ||||||||||||||||||||||||
| 2412 | \l QMetaType::QRect or \l QMetaType::QRectF; otherwise returns an invalid | - | ||||||||||||||||||||||||
| 2413 | QRectF. | - | ||||||||||||||||||||||||
| 2414 | - | |||||||||||||||||||||||||
| 2415 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2416 | */ | - | ||||||||||||||||||||||||
| 2417 | QRectF QVariant::toRectF() const | - | ||||||||||||||||||||||||
| 2418 | { | - | ||||||||||||||||||||||||
| 2419 | return qVariantToHelper<QRectF>(d, handlerManager); executed 24 times by 7 tests: return qVariantToHelper<QRectF>(d, handlerManager);Executed by:
| 24 | ||||||||||||||||||||||||
| 2420 | } | - | ||||||||||||||||||||||||
| 2421 | - | |||||||||||||||||||||||||
| 2422 | /*! | - | ||||||||||||||||||||||||
| 2423 | \fn QLineF QVariant::toLineF() const | - | ||||||||||||||||||||||||
| 2424 | - | |||||||||||||||||||||||||
| 2425 | Returns the variant as a QLineF if the variant has userType() | - | ||||||||||||||||||||||||
| 2426 | \l QMetaType::QLineF; otherwise returns an invalid QLineF. | - | ||||||||||||||||||||||||
| 2427 | - | |||||||||||||||||||||||||
| 2428 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2429 | */ | - | ||||||||||||||||||||||||
| 2430 | QLineF QVariant::toLineF() const | - | ||||||||||||||||||||||||
| 2431 | { | - | ||||||||||||||||||||||||
| 2432 | return qVariantToHelper<QLineF>(d, handlerManager); executed 9 times by 2 tests: return qVariantToHelper<QLineF>(d, handlerManager);Executed by:
| 9 | ||||||||||||||||||||||||
| 2433 | } | - | ||||||||||||||||||||||||
| 2434 | - | |||||||||||||||||||||||||
| 2435 | /*! | - | ||||||||||||||||||||||||
| 2436 | \fn QLine QVariant::toLine() const | - | ||||||||||||||||||||||||
| 2437 | - | |||||||||||||||||||||||||
| 2438 | Returns the variant as a QLine if the variant has userType() | - | ||||||||||||||||||||||||
| 2439 | \l QMetaType::QLine; otherwise returns an invalid QLine. | - | ||||||||||||||||||||||||
| 2440 | - | |||||||||||||||||||||||||
| 2441 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2442 | */ | - | ||||||||||||||||||||||||
| 2443 | QLine QVariant::toLine() const | - | ||||||||||||||||||||||||
| 2444 | { | - | ||||||||||||||||||||||||
| 2445 | return qVariantToHelper<QLine>(d, handlerManager); executed 9 times by 2 tests: return qVariantToHelper<QLine>(d, handlerManager);Executed by:
| 9 | ||||||||||||||||||||||||
| 2446 | } | - | ||||||||||||||||||||||||
| 2447 | - | |||||||||||||||||||||||||
| 2448 | /*! | - | ||||||||||||||||||||||||
| 2449 | \fn QPointF QVariant::toPointF() const | - | ||||||||||||||||||||||||
| 2450 | - | |||||||||||||||||||||||||
| 2451 | Returns the variant as a QPointF if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2452 | QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null | - | ||||||||||||||||||||||||
| 2453 | QPointF. | - | ||||||||||||||||||||||||
| 2454 | - | |||||||||||||||||||||||||
| 2455 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2456 | */ | - | ||||||||||||||||||||||||
| 2457 | QPointF QVariant::toPointF() const | - | ||||||||||||||||||||||||
| 2458 | { | - | ||||||||||||||||||||||||
| 2459 | return qVariantToHelper<QPointF>(d, handlerManager); executed 1629 times by 17 tests: return qVariantToHelper<QPointF>(d, handlerManager);Executed by:
| 1629 | ||||||||||||||||||||||||
| 2460 | } | - | ||||||||||||||||||||||||
| 2461 | - | |||||||||||||||||||||||||
| 2462 | #endif // QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
| 2463 | - | |||||||||||||||||||||||||
| 2464 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 2465 | /*! | - | ||||||||||||||||||||||||
| 2466 | \fn QUrl QVariant::toUrl() const | - | ||||||||||||||||||||||||
| 2467 | - | |||||||||||||||||||||||||
| 2468 | Returns the variant as a QUrl if the variant has userType() | - | ||||||||||||||||||||||||
| 2469 | \l QMetaType::QUrl; otherwise returns an invalid QUrl. | - | ||||||||||||||||||||||||
| 2470 | - | |||||||||||||||||||||||||
| 2471 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2472 | */ | - | ||||||||||||||||||||||||
| 2473 | QUrl QVariant::toUrl() const | - | ||||||||||||||||||||||||
| 2474 | { | - | ||||||||||||||||||||||||
| 2475 | return qVariantToHelper<QUrl>(d, handlerManager); executed 7238 times by 10 tests: return qVariantToHelper<QUrl>(d, handlerManager);Executed by:
| 7238 | ||||||||||||||||||||||||
| 2476 | } | - | ||||||||||||||||||||||||
| 2477 | #endif | - | ||||||||||||||||||||||||
| 2478 | - | |||||||||||||||||||||||||
| 2479 | /*! | - | ||||||||||||||||||||||||
| 2480 | \fn QLocale QVariant::toLocale() const | - | ||||||||||||||||||||||||
| 2481 | - | |||||||||||||||||||||||||
| 2482 | Returns the variant as a QLocale if the variant has userType() | - | ||||||||||||||||||||||||
| 2483 | \l QMetaType::QLocale; otherwise returns an invalid QLocale. | - | ||||||||||||||||||||||||
| 2484 | - | |||||||||||||||||||||||||
| 2485 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2486 | */ | - | ||||||||||||||||||||||||
| 2487 | QLocale QVariant::toLocale() const | - | ||||||||||||||||||||||||
| 2488 | { | - | ||||||||||||||||||||||||
| 2489 | return qVariantToHelper<QLocale>(d, handlerManager); executed 3 times by 1 test: return qVariantToHelper<QLocale>(d, handlerManager);Executed by:
| 3 | ||||||||||||||||||||||||
| 2490 | } | - | ||||||||||||||||||||||||
| 2491 | - | |||||||||||||||||||||||||
| 2492 | /*! | - | ||||||||||||||||||||||||
| 2493 | \fn QRegExp QVariant::toRegExp() const | - | ||||||||||||||||||||||||
| 2494 | \since 4.1 | - | ||||||||||||||||||||||||
| 2495 | - | |||||||||||||||||||||||||
| 2496 | Returns the variant as a QRegExp if the variant has userType() | - | ||||||||||||||||||||||||
| 2497 | \l QMetaType::QRegExp; otherwise returns an empty QRegExp. | - | ||||||||||||||||||||||||
| 2498 | - | |||||||||||||||||||||||||
| 2499 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2500 | */ | - | ||||||||||||||||||||||||
| 2501 | #ifndef QT_NO_REGEXP | - | ||||||||||||||||||||||||
| 2502 | QRegExp QVariant::toRegExp() const | - | ||||||||||||||||||||||||
| 2503 | { | - | ||||||||||||||||||||||||
| 2504 | return qVariantToHelper<QRegExp>(d, handlerManager); executed 45 times by 2 tests: return qVariantToHelper<QRegExp>(d, handlerManager);Executed by:
| 45 | ||||||||||||||||||||||||
| 2505 | } | - | ||||||||||||||||||||||||
| 2506 | #endif | - | ||||||||||||||||||||||||
| 2507 | - | |||||||||||||||||||||||||
| 2508 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 2509 | /*! | - | ||||||||||||||||||||||||
| 2510 | \fn QRegularExpression QVariant::toRegularExpression() const | - | ||||||||||||||||||||||||
| 2511 | \since 5.0 | - | ||||||||||||||||||||||||
| 2512 | - | |||||||||||||||||||||||||
| 2513 | Returns the variant as a QRegularExpression if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2514 | QRegularExpression; otherwise returns an empty QRegularExpression. | - | ||||||||||||||||||||||||
| 2515 | - | |||||||||||||||||||||||||
| 2516 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2517 | */ | - | ||||||||||||||||||||||||
| 2518 | #ifndef QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
| 2519 | QRegularExpression QVariant::toRegularExpression() const | - | ||||||||||||||||||||||||
| 2520 | { | - | ||||||||||||||||||||||||
| 2521 | return qVariantToHelper<QRegularExpression>(d, handlerManager); executed 119 times by 4 tests: return qVariantToHelper<QRegularExpression>(d, handlerManager);Executed by:
| 119 | ||||||||||||||||||||||||
| 2522 | } | - | ||||||||||||||||||||||||
| 2523 | #endif // QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
| 2524 | - | |||||||||||||||||||||||||
| 2525 | /*! | - | ||||||||||||||||||||||||
| 2526 | \since 5.0 | - | ||||||||||||||||||||||||
| 2527 | - | |||||||||||||||||||||||||
| 2528 | Returns the variant as a QUuid if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2529 | QUuid; otherwise returns a default constructed QUuid. | - | ||||||||||||||||||||||||
| 2530 | - | |||||||||||||||||||||||||
| 2531 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2532 | */ | - | ||||||||||||||||||||||||
| 2533 | QUuid QVariant::toUuid() const | - | ||||||||||||||||||||||||
| 2534 | { | - | ||||||||||||||||||||||||
| 2535 | return qVariantToHelper<QUuid>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QUuid>(d, handlerManager);Executed by:
| 1 | ||||||||||||||||||||||||
| 2536 | } | - | ||||||||||||||||||||||||
| 2537 | - | |||||||||||||||||||||||||
| 2538 | /*! | - | ||||||||||||||||||||||||
| 2539 | \since 5.0 | - | ||||||||||||||||||||||||
| 2540 | - | |||||||||||||||||||||||||
| 2541 | Returns the variant as a QModelIndex if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2542 | QModelIndex; otherwise returns a default constructed QModelIndex. | - | ||||||||||||||||||||||||
| 2543 | - | |||||||||||||||||||||||||
| 2544 | \sa canConvert(), convert(), toPersistentModelIndex() | - | ||||||||||||||||||||||||
| 2545 | */ | - | ||||||||||||||||||||||||
| 2546 | QModelIndex QVariant::toModelIndex() const | - | ||||||||||||||||||||||||
| 2547 | { | - | ||||||||||||||||||||||||
| 2548 | return qVariantToHelper<QModelIndex>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QModelIndex>(d, handlerManager);Executed by:
| 1 | ||||||||||||||||||||||||
| 2549 | } | - | ||||||||||||||||||||||||
| 2550 | - | |||||||||||||||||||||||||
| 2551 | /*! | - | ||||||||||||||||||||||||
| 2552 | \since 5.5 | - | ||||||||||||||||||||||||
| 2553 | - | |||||||||||||||||||||||||
| 2554 | Returns the variant as a QPersistentModelIndex if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2555 | QPersistentModelIndex; otherwise returns a default constructed QPersistentModelIndex. | - | ||||||||||||||||||||||||
| 2556 | - | |||||||||||||||||||||||||
| 2557 | \sa canConvert(), convert(), toModelIndex() | - | ||||||||||||||||||||||||
| 2558 | */ | - | ||||||||||||||||||||||||
| 2559 | QPersistentModelIndex QVariant::toPersistentModelIndex() const | - | ||||||||||||||||||||||||
| 2560 | { | - | ||||||||||||||||||||||||
| 2561 | return qVariantToHelper<QPersistentModelIndex>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QPersistentModelIndex>(d, handlerManager);Executed by:
| 1 | ||||||||||||||||||||||||
| 2562 | } | - | ||||||||||||||||||||||||
| 2563 | - | |||||||||||||||||||||||||
| 2564 | /*! | - | ||||||||||||||||||||||||
| 2565 | \since 5.0 | - | ||||||||||||||||||||||||
| 2566 | - | |||||||||||||||||||||||||
| 2567 | Returns the variant as a QJsonValue if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2568 | QJsonValue; otherwise returns a default constructed QJsonValue. | - | ||||||||||||||||||||||||
| 2569 | - | |||||||||||||||||||||||||
| 2570 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2571 | */ | - | ||||||||||||||||||||||||
| 2572 | QJsonValue QVariant::toJsonValue() const | - | ||||||||||||||||||||||||
| 2573 | { | - | ||||||||||||||||||||||||
| 2574 | return qVariantToHelper<QJsonValue>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QJsonValue>(d, handlerManager);Executed by:
| 1 | ||||||||||||||||||||||||
| 2575 | } | - | ||||||||||||||||||||||||
| 2576 | - | |||||||||||||||||||||||||
| 2577 | /*! | - | ||||||||||||||||||||||||
| 2578 | \since 5.0 | - | ||||||||||||||||||||||||
| 2579 | - | |||||||||||||||||||||||||
| 2580 | Returns the variant as a QJsonObject if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2581 | QJsonObject; otherwise returns a default constructed QJsonObject. | - | ||||||||||||||||||||||||
| 2582 | - | |||||||||||||||||||||||||
| 2583 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2584 | */ | - | ||||||||||||||||||||||||
| 2585 | QJsonObject QVariant::toJsonObject() const | - | ||||||||||||||||||||||||
| 2586 | { | - | ||||||||||||||||||||||||
| 2587 | return qVariantToHelper<QJsonObject>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QJsonObject>(d, handlerManager);Executed by:
| 1 | ||||||||||||||||||||||||
| 2588 | } | - | ||||||||||||||||||||||||
| 2589 | - | |||||||||||||||||||||||||
| 2590 | /*! | - | ||||||||||||||||||||||||
| 2591 | \since 5.0 | - | ||||||||||||||||||||||||
| 2592 | - | |||||||||||||||||||||||||
| 2593 | Returns the variant as a QJsonArray if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2594 | QJsonArray; otherwise returns a default constructed QJsonArray. | - | ||||||||||||||||||||||||
| 2595 | - | |||||||||||||||||||||||||
| 2596 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2597 | */ | - | ||||||||||||||||||||||||
| 2598 | QJsonArray QVariant::toJsonArray() const | - | ||||||||||||||||||||||||
| 2599 | { | - | ||||||||||||||||||||||||
| 2600 | return qVariantToHelper<QJsonArray>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QJsonArray>(d, handlerManager);Executed by:
| 1 | ||||||||||||||||||||||||
| 2601 | } | - | ||||||||||||||||||||||||
| 2602 | - | |||||||||||||||||||||||||
| 2603 | /*! | - | ||||||||||||||||||||||||
| 2604 | \since 5.0 | - | ||||||||||||||||||||||||
| 2605 | - | |||||||||||||||||||||||||
| 2606 | Returns the variant as a QJsonDocument if the variant has userType() \l | - | ||||||||||||||||||||||||
| 2607 | QJsonDocument; otherwise returns a default constructed QJsonDocument. | - | ||||||||||||||||||||||||
| 2608 | - | |||||||||||||||||||||||||
| 2609 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2610 | */ | - | ||||||||||||||||||||||||
| 2611 | QJsonDocument QVariant::toJsonDocument() const | - | ||||||||||||||||||||||||
| 2612 | { | - | ||||||||||||||||||||||||
| 2613 | return qVariantToHelper<QJsonDocument>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QJsonDocument>(d, handlerManager);Executed by:
| 1 | ||||||||||||||||||||||||
| 2614 | } | - | ||||||||||||||||||||||||
| 2615 | #endif | - | ||||||||||||||||||||||||
| 2616 | - | |||||||||||||||||||||||||
| 2617 | /*! | - | ||||||||||||||||||||||||
| 2618 | \fn QChar QVariant::toChar() const | - | ||||||||||||||||||||||||
| 2619 | - | |||||||||||||||||||||||||
| 2620 | Returns the variant as a QChar if the variant has userType() | - | ||||||||||||||||||||||||
| 2621 | \l QMetaType::QChar, \l QMetaType::Int, or \l QMetaType::UInt; otherwise | - | ||||||||||||||||||||||||
| 2622 | returns an invalid QChar. | - | ||||||||||||||||||||||||
| 2623 | - | |||||||||||||||||||||||||
| 2624 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2625 | */ | - | ||||||||||||||||||||||||
| 2626 | QChar QVariant::toChar() const | - | ||||||||||||||||||||||||
| 2627 | { | - | ||||||||||||||||||||||||
| 2628 | return qVariantToHelper<QChar>(d, handlerManager); executed 1866 times by 56 tests: return qVariantToHelper<QChar>(d, handlerManager);Executed by:
| 1866 | ||||||||||||||||||||||||
| 2629 | } | - | ||||||||||||||||||||||||
| 2630 | - | |||||||||||||||||||||||||
| 2631 | /*! | - | ||||||||||||||||||||||||
| 2632 | Returns the variant as a QBitArray if the variant has userType() | - | ||||||||||||||||||||||||
| 2633 | \l QMetaType::QBitArray; otherwise returns an empty bit array. | - | ||||||||||||||||||||||||
| 2634 | - | |||||||||||||||||||||||||
| 2635 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2636 | */ | - | ||||||||||||||||||||||||
| 2637 | QBitArray QVariant::toBitArray() const | - | ||||||||||||||||||||||||
| 2638 | { | - | ||||||||||||||||||||||||
| 2639 | return qVariantToHelper<QBitArray>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QBitArray>(d, handlerManager);Executed by:
| 1 | ||||||||||||||||||||||||
| 2640 | } | - | ||||||||||||||||||||||||
| 2641 | - | |||||||||||||||||||||||||
| 2642 | template <typename T> | - | ||||||||||||||||||||||||
| 2643 | inline T qNumVariantToHelper(const QVariant::Private &d, | - | ||||||||||||||||||||||||
| 2644 | const HandlersManager &handlerManager, bool *ok, const T& val) | - | ||||||||||||||||||||||||
| 2645 | { | - | ||||||||||||||||||||||||
| 2646 | const uint t = qMetaTypeId<T>(); | - | ||||||||||||||||||||||||
| 2647 | if (ok)
| 6096-738589 | ||||||||||||||||||||||||
| 2648 | *ok = true; executed 6096 times by 31 tests: *ok = true;Executed by:
| 6096 | ||||||||||||||||||||||||
| 2649 | - | |||||||||||||||||||||||||
| 2650 | if (d.type == t)
| 27441-717244 | ||||||||||||||||||||||||
| 2651 | return val; executed 717244 times by 215 tests: return val;Executed by:
| 717244 | ||||||||||||||||||||||||
| 2652 | - | |||||||||||||||||||||||||
| 2653 | T ret = 0; | - | ||||||||||||||||||||||||
| 2654 | if ((d.type >= QMetaType::User || t >= QMetaType::User)
| 0-27311 | ||||||||||||||||||||||||
| 2655 | && QMetaType::convert(constData(d), d.type, &ret, t))
| 8-122 | ||||||||||||||||||||||||
| 2656 | return ret; executed 8 times by 2 tests: return ret;Executed by:
| 8 | ||||||||||||||||||||||||
| 2657 | - | |||||||||||||||||||||||||
| 2658 | if (!handlerManager[d.type]->convert(&d, t, &ret, ok) && ok)
| 20-26429 | ||||||||||||||||||||||||
| 2659 | *ok = false; executed 20 times by 2 tests: *ok = false;Executed by:
| 20 | ||||||||||||||||||||||||
| 2660 | return ret; executed 27433 times by 86 tests: return ret;Executed by:
| 27433 | ||||||||||||||||||||||||
| 2661 | } | - | ||||||||||||||||||||||||
| 2662 | - | |||||||||||||||||||||||||
| 2663 | /*! | - | ||||||||||||||||||||||||
| 2664 | Returns the variant as an int if the variant has userType() | - | ||||||||||||||||||||||||
| 2665 | \l QMetaType::Int, \l QMetaType::Bool, \l QMetaType::QByteArray, | - | ||||||||||||||||||||||||
| 2666 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
| 2667 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
| 2668 | otherwise returns 0. | - | ||||||||||||||||||||||||
| 2669 | - | |||||||||||||||||||||||||
| 2670 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
| 2671 | converted to an int; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
| 2672 | - | |||||||||||||||||||||||||
| 2673 | \b{Warning:} If the value is convertible to a \l QMetaType::LongLong but is | - | ||||||||||||||||||||||||
| 2674 | too large to be represented in an int, the resulting arithmetic overflow | - | ||||||||||||||||||||||||
| 2675 | will not be reflected in \a ok. A simple workaround is to use | - | ||||||||||||||||||||||||
| 2676 | QString::toInt(). | - | ||||||||||||||||||||||||
| 2677 | - | |||||||||||||||||||||||||
| 2678 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2679 | */ | - | ||||||||||||||||||||||||
| 2680 | int QVariant::toInt(bool *ok) const | - | ||||||||||||||||||||||||
| 2681 | { | - | ||||||||||||||||||||||||
| 2682 | return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i); executed 674448 times by 207 tests: return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i);Executed by:
| 674448 | ||||||||||||||||||||||||
| 2683 | } | - | ||||||||||||||||||||||||
| 2684 | - | |||||||||||||||||||||||||
| 2685 | /*! | - | ||||||||||||||||||||||||
| 2686 | Returns the variant as an unsigned int if the variant has userType() | - | ||||||||||||||||||||||||
| 2687 | \l QMetaType::UInt, \l QMetaType::Bool, \l QMetaType::QByteArray, | - | ||||||||||||||||||||||||
| 2688 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, | - | ||||||||||||||||||||||||
| 2689 | \l QMetaType::LongLong, \l QMetaType::QString, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
| 2690 | otherwise returns 0. | - | ||||||||||||||||||||||||
| 2691 | - | |||||||||||||||||||||||||
| 2692 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
| 2693 | converted to an unsigned int; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
| 2694 | - | |||||||||||||||||||||||||
| 2695 | \b{Warning:} If the value is convertible to a \l QMetaType::ULongLong but is | - | ||||||||||||||||||||||||
| 2696 | too large to be represented in an unsigned int, the resulting arithmetic | - | ||||||||||||||||||||||||
| 2697 | overflow will not be reflected in \a ok. A simple workaround is to use | - | ||||||||||||||||||||||||
| 2698 | QString::toUInt(). | - | ||||||||||||||||||||||||
| 2699 | - | |||||||||||||||||||||||||
| 2700 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2701 | */ | - | ||||||||||||||||||||||||
| 2702 | uint QVariant::toUInt(bool *ok) const | - | ||||||||||||||||||||||||
| 2703 | { | - | ||||||||||||||||||||||||
| 2704 | return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u); executed 1494 times by 57 tests: return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u);Executed by:
| 1494 | ||||||||||||||||||||||||
| 2705 | } | - | ||||||||||||||||||||||||
| 2706 | - | |||||||||||||||||||||||||
| 2707 | /*! | - | ||||||||||||||||||||||||
| 2708 | Returns the variant as a long long int if the variant has userType() | - | ||||||||||||||||||||||||
| 2709 | \l QMetaType::LongLong, \l QMetaType::Bool, \l QMetaType::QByteArray, | - | ||||||||||||||||||||||||
| 2710 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, | - | ||||||||||||||||||||||||
| 2711 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
| 2712 | otherwise returns 0. | - | ||||||||||||||||||||||||
| 2713 | - | |||||||||||||||||||||||||
| 2714 | If \a ok is non-null: \c{*}\c{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
| 2715 | converted to an int; otherwise \c{*}\c{ok} is set to false. | - | ||||||||||||||||||||||||
| 2716 | - | |||||||||||||||||||||||||
| 2717 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2718 | */ | - | ||||||||||||||||||||||||
| 2719 | qlonglong QVariant::toLongLong(bool *ok) const | - | ||||||||||||||||||||||||
| 2720 | { | - | ||||||||||||||||||||||||
| 2721 | return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll); executed 11707 times by 23 tests: return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll);Executed by:
| 11707 | ||||||||||||||||||||||||
| 2722 | } | - | ||||||||||||||||||||||||
| 2723 | - | |||||||||||||||||||||||||
| 2724 | /*! | - | ||||||||||||||||||||||||
| 2725 | Returns the variant as an unsigned long long int if the | - | ||||||||||||||||||||||||
| 2726 | variant has type() \l QMetaType::ULongLong, \l QMetaType::Bool, | - | ||||||||||||||||||||||||
| 2727 | \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, | - | ||||||||||||||||||||||||
| 2728 | \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, or | - | ||||||||||||||||||||||||
| 2729 | \l QMetaType::UInt; otherwise returns 0. | - | ||||||||||||||||||||||||
| 2730 | - | |||||||||||||||||||||||||
| 2731 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
| 2732 | converted to an int; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
| 2733 | - | |||||||||||||||||||||||||
| 2734 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2735 | */ | - | ||||||||||||||||||||||||
| 2736 | qulonglong QVariant::toULongLong(bool *ok) const | - | ||||||||||||||||||||||||
| 2737 | { | - | ||||||||||||||||||||||||
| 2738 | return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull); executed 104 times by 5 tests: return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull);Executed by:
| 104 | ||||||||||||||||||||||||
| 2739 | } | - | ||||||||||||||||||||||||
| 2740 | - | |||||||||||||||||||||||||
| 2741 | /*! | - | ||||||||||||||||||||||||
| 2742 | Returns the variant as a bool if the variant has userType() Bool. | - | ||||||||||||||||||||||||
| 2743 | - | |||||||||||||||||||||||||
| 2744 | Returns \c true if the variant has userType() \l QMetaType::Bool, | - | ||||||||||||||||||||||||
| 2745 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, | - | ||||||||||||||||||||||||
| 2746 | \l QMetaType::LongLong, \l QMetaType::UInt, or \l QMetaType::ULongLong and | - | ||||||||||||||||||||||||
| 2747 | the value is non-zero, or if the variant has type \l QMetaType::QString or | - | ||||||||||||||||||||||||
| 2748 | \l QMetaType::QByteArray and its lower-case content is not one of the | - | ||||||||||||||||||||||||
| 2749 | following: empty, "0" or "false"; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 2750 | - | |||||||||||||||||||||||||
| 2751 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2752 | */ | - | ||||||||||||||||||||||||
| 2753 | bool QVariant::toBool() const | - | ||||||||||||||||||||||||
| 2754 | { | - | ||||||||||||||||||||||||
| 2755 | if (d.type == Bool)
| 39492-80058 | ||||||||||||||||||||||||
| 2756 | return d.data.b; executed 80058 times by 160 tests: return d.data.b;Executed by:
| 80058 | ||||||||||||||||||||||||
| 2757 | - | |||||||||||||||||||||||||
| 2758 | bool res = false; | - | ||||||||||||||||||||||||
| 2759 | handlerManager[d.type]->convert(&d, Bool, &res, 0); | - | ||||||||||||||||||||||||
| 2760 | - | |||||||||||||||||||||||||
| 2761 | return res; executed 39492 times by 116 tests: return res;Executed by:
| 39492 | ||||||||||||||||||||||||
| 2762 | } | - | ||||||||||||||||||||||||
| 2763 | - | |||||||||||||||||||||||||
| 2764 | /*! | - | ||||||||||||||||||||||||
| 2765 | Returns the variant as a double if the variant has userType() | - | ||||||||||||||||||||||||
| 2766 | \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, | - | ||||||||||||||||||||||||
| 2767 | \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
| 2768 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
| 2769 | otherwise returns 0.0. | - | ||||||||||||||||||||||||
| 2770 | - | |||||||||||||||||||||||||
| 2771 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
| 2772 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
| 2773 | - | |||||||||||||||||||||||||
| 2774 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2775 | */ | - | ||||||||||||||||||||||||
| 2776 | double QVariant::toDouble(bool *ok) const | - | ||||||||||||||||||||||||
| 2777 | { | - | ||||||||||||||||||||||||
| 2778 | return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d); executed 40171 times by 58 tests: return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d);Executed by:
| 40171 | ||||||||||||||||||||||||
| 2779 | } | - | ||||||||||||||||||||||||
| 2780 | - | |||||||||||||||||||||||||
| 2781 | /*! | - | ||||||||||||||||||||||||
| 2782 | Returns the variant as a float if the variant has userType() | - | ||||||||||||||||||||||||
| 2783 | \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, | - | ||||||||||||||||||||||||
| 2784 | \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
| 2785 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
| 2786 | otherwise returns 0.0. | - | ||||||||||||||||||||||||
| 2787 | - | |||||||||||||||||||||||||
| 2788 | \since 4.6 | - | ||||||||||||||||||||||||
| 2789 | - | |||||||||||||||||||||||||
| 2790 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
| 2791 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
| 2792 | - | |||||||||||||||||||||||||
| 2793 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2794 | */ | - | ||||||||||||||||||||||||
| 2795 | float QVariant::toFloat(bool *ok) const | - | ||||||||||||||||||||||||
| 2796 | { | - | ||||||||||||||||||||||||
| 2797 | return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f); executed 154 times by 16 tests: return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f);Executed by:
| 154 | ||||||||||||||||||||||||
| 2798 | } | - | ||||||||||||||||||||||||
| 2799 | - | |||||||||||||||||||||||||
| 2800 | /*! | - | ||||||||||||||||||||||||
| 2801 | Returns the variant as a qreal if the variant has userType() | - | ||||||||||||||||||||||||
| 2802 | \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, | - | ||||||||||||||||||||||||
| 2803 | \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
| 2804 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
| 2805 | otherwise returns 0.0. | - | ||||||||||||||||||||||||
| 2806 | - | |||||||||||||||||||||||||
| 2807 | \since 4.6 | - | ||||||||||||||||||||||||
| 2808 | - | |||||||||||||||||||||||||
| 2809 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
| 2810 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
| 2811 | - | |||||||||||||||||||||||||
| 2812 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2813 | */ | - | ||||||||||||||||||||||||
| 2814 | qreal QVariant::toReal(bool *ok) const | - | ||||||||||||||||||||||||
| 2815 | { | - | ||||||||||||||||||||||||
| 2816 | return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real); executed 16607 times by 29 tests: return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real);Executed by:
| 16607 | ||||||||||||||||||||||||
| 2817 | } | - | ||||||||||||||||||||||||
| 2818 | - | |||||||||||||||||||||||||
| 2819 | /*! | - | ||||||||||||||||||||||||
| 2820 | Returns the variant as a QVariantList if the variant has userType() | - | ||||||||||||||||||||||||
| 2821 | \l QMetaType::QVariantList or \l QMetaType::QStringList; otherwise returns | - | ||||||||||||||||||||||||
| 2822 | an empty list. | - | ||||||||||||||||||||||||
| 2823 | - | |||||||||||||||||||||||||
| 2824 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
| 2825 | */ | - | ||||||||||||||||||||||||
| 2826 | QVariantList QVariant::toList() const | - | ||||||||||||||||||||||||
| 2827 | { | - | ||||||||||||||||||||||||
| 2828 | return qVariantToHelper<QVariantList>(d, handlerManager); executed 697 times by 17 tests: return qVariantToHelper<QVariantList>(d, handlerManager);Executed by:
| 697 | ||||||||||||||||||||||||
| 2829 | } | - | ||||||||||||||||||||||||
| 2830 | - | |||||||||||||||||||||||||
| 2831 | - | |||||||||||||||||||||||||
| 2832 | static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = | - | ||||||||||||||||||||||||
| 2833 | { | - | ||||||||||||||||||||||||
| 2834 | /*Invalid*/ 0, | - | ||||||||||||||||||||||||
| 2835 | - | |||||||||||||||||||||||||
| 2836 | /*Bool*/ 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt | - | ||||||||||||||||||||||||
| 2837 | | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray | - | ||||||||||||||||||||||||
| 2838 | | 1 << QVariant::String | 1 << QVariant::Char, | - | ||||||||||||||||||||||||
| 2839 | - | |||||||||||||||||||||||||
| 2840 | /*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||||||||||||||
| 2841 | | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | - | ||||||||||||||||||||||||
| 2842 | | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int, | - | ||||||||||||||||||||||||
| 2843 | - | |||||||||||||||||||||||||
| 2844 | /*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||||||||||||||
| 2845 | | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | - | ||||||||||||||||||||||||
| 2846 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||||||||||||||
| 2847 | - | |||||||||||||||||||||||||
| 2848 | /*LLong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||||||||||||||
| 2849 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong | - | ||||||||||||||||||||||||
| 2850 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||||||||||||||
| 2851 | - | |||||||||||||||||||||||||
| 2852 | /*ULlong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||||||||||||||
| 2853 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||||||||||||||
| 2854 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||||||||||||||
| 2855 | - | |||||||||||||||||||||||||
| 2856 | /*double*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong | - | ||||||||||||||||||||||||
| 2857 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||||||||||||||
| 2858 | | 1 << QVariant::ByteArray, | - | ||||||||||||||||||||||||
| 2859 | - | |||||||||||||||||||||||||
| 2860 | /*QChar*/ 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||||||||||||||
| 2861 | | 1 << QVariant::ULongLong, | - | ||||||||||||||||||||||||
| 2862 | - | |||||||||||||||||||||||||
| 2863 | /*QMap*/ 0, | - | ||||||||||||||||||||||||
| 2864 | - | |||||||||||||||||||||||||
| 2865 | /*QList*/ 1 << QVariant::StringList, | - | ||||||||||||||||||||||||
| 2866 | - | |||||||||||||||||||||||||
| 2867 | /*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int | - | ||||||||||||||||||||||||
| 2868 | | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double | - | ||||||||||||||||||||||||
| 2869 | | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime | - | ||||||||||||||||||||||||
| 2870 | | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char | - | ||||||||||||||||||||||||
| 2871 | | 1 << QVariant::Url | 1 << QVariant::Uuid, | - | ||||||||||||||||||||||||
| 2872 | - | |||||||||||||||||||||||||
| 2873 | /*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, | - | ||||||||||||||||||||||||
| 2874 | - | |||||||||||||||||||||||||
| 2875 | /*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool | - | ||||||||||||||||||||||||
| 2876 | | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, | - | ||||||||||||||||||||||||
| 2877 | - | |||||||||||||||||||||||||
| 2878 | /*QBitArray*/ 0, | - | ||||||||||||||||||||||||
| 2879 | - | |||||||||||||||||||||||||
| 2880 | /*QDate*/ 1 << QVariant::String | 1 << QVariant::DateTime, | - | ||||||||||||||||||||||||
| 2881 | - | |||||||||||||||||||||||||
| 2882 | /*QTime*/ 1 << QVariant::String | 1 << QVariant::DateTime, | - | ||||||||||||||||||||||||
| 2883 | - | |||||||||||||||||||||||||
| 2884 | /*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date, | - | ||||||||||||||||||||||||
| 2885 | - | |||||||||||||||||||||||||
| 2886 | /*QUrl*/ 1 << QVariant::String, | - | ||||||||||||||||||||||||
| 2887 | - | |||||||||||||||||||||||||
| 2888 | /*QLocale*/ 0, | - | ||||||||||||||||||||||||
| 2889 | - | |||||||||||||||||||||||||
| 2890 | /*QRect*/ 1 << QVariant::RectF, | - | ||||||||||||||||||||||||
| 2891 | - | |||||||||||||||||||||||||
| 2892 | /*QRectF*/ 1 << QVariant::Rect, | - | ||||||||||||||||||||||||
| 2893 | - | |||||||||||||||||||||||||
| 2894 | /*QSize*/ 1 << QVariant::SizeF, | - | ||||||||||||||||||||||||
| 2895 | - | |||||||||||||||||||||||||
| 2896 | /*QSizeF*/ 1 << QVariant::Size, | - | ||||||||||||||||||||||||
| 2897 | - | |||||||||||||||||||||||||
| 2898 | /*QLine*/ 1 << QVariant::LineF, | - | ||||||||||||||||||||||||
| 2899 | - | |||||||||||||||||||||||||
| 2900 | /*QLineF*/ 1 << QVariant::Line, | - | ||||||||||||||||||||||||
| 2901 | - | |||||||||||||||||||||||||
| 2902 | /*QPoint*/ 1 << QVariant::PointF, | - | ||||||||||||||||||||||||
| 2903 | - | |||||||||||||||||||||||||
| 2904 | /*QPointF*/ 1 << QVariant::Point, | - | ||||||||||||||||||||||||
| 2905 | - | |||||||||||||||||||||||||
| 2906 | /*QRegExp*/ 0, | - | ||||||||||||||||||||||||
| 2907 | - | |||||||||||||||||||||||||
| 2908 | /*QHash*/ 0, | - | ||||||||||||||||||||||||
| 2909 | - | |||||||||||||||||||||||||
| 2910 | /*QEasingCurve*/ 0, | - | ||||||||||||||||||||||||
| 2911 | - | |||||||||||||||||||||||||
| 2912 | /*QUuid*/ 1 << QVariant::String | - | ||||||||||||||||||||||||
| 2913 | }; | - | ||||||||||||||||||||||||
| 2914 | static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix); | - | ||||||||||||||||||||||||
| 2915 | - | |||||||||||||||||||||||||
| 2916 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 2917 | /*! | - | ||||||||||||||||||||||||
| 2918 | Returns \c true if from inherits to. | - | ||||||||||||||||||||||||
| 2919 | */ | - | ||||||||||||||||||||||||
| 2920 | static bool canConvertMetaObject(const QMetaObject *from, const QMetaObject *to) | - | ||||||||||||||||||||||||
| 2921 | { | - | ||||||||||||||||||||||||
| 2922 | if (from && to == &QObject::staticMetaObject)
| 0-19 | ||||||||||||||||||||||||
| 2923 | return true; executed 12 times by 2 tests: return true;Executed by:
| 12 | ||||||||||||||||||||||||
| 2924 | - | |||||||||||||||||||||||||
| 2925 | while (from) {
| 0-11 | ||||||||||||||||||||||||
| 2926 | if (from == to)
| 4-7 | ||||||||||||||||||||||||
| 2927 | return true; executed 7 times by 2 tests: return true;Executed by:
| 7 | ||||||||||||||||||||||||
| 2928 | from = from->superClass(); | - | ||||||||||||||||||||||||
| 2929 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 2930 | - | |||||||||||||||||||||||||
| 2931 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 2932 | } | - | ||||||||||||||||||||||||
| 2933 | #endif | - | ||||||||||||||||||||||||
| 2934 | - | |||||||||||||||||||||||||
| 2935 | static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) | - | ||||||||||||||||||||||||
| 2936 | { | - | ||||||||||||||||||||||||
| 2937 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
| 2938 | QMetaType toType(toId); | - | ||||||||||||||||||||||||
| 2939 | if ((QMetaType::typeFlags(fromId) & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) { | - | ||||||||||||||||||||||||
| 2940 | if (!fromObject)
| 4-19 | ||||||||||||||||||||||||
| 2941 | return true; executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||
| 2942 | return canConvertMetaObject(fromObject->metaObject(), toType.metaObject()); executed 19 times by 3 tests: return canConvertMetaObject(fromObject->metaObject(), toType.metaObject());Executed by:
| 19 | ||||||||||||||||||||||||
| 2943 | } | - | ||||||||||||||||||||||||
| 2944 | #else | - | ||||||||||||||||||||||||
| 2945 | Q_UNUSED(fromId); | - | ||||||||||||||||||||||||
| 2946 | Q_UNUSED(toId); | - | ||||||||||||||||||||||||
| 2947 | Q_UNUSED(fromObject); | - | ||||||||||||||||||||||||
| 2948 | #endif | - | ||||||||||||||||||||||||
| 2949 | return false; executed 93 times by 5 tests: return false;Executed by:
| 93 | ||||||||||||||||||||||||
| 2950 | } | - | ||||||||||||||||||||||||
| 2951 | - | |||||||||||||||||||||||||
| 2952 | - | |||||||||||||||||||||||||
| 2953 | /*! | - | ||||||||||||||||||||||||
| 2954 | Returns \c true if the variant's type can be cast to the requested | - | ||||||||||||||||||||||||
| 2955 | type, \a targetTypeId. Such casting is done automatically when calling the | - | ||||||||||||||||||||||||
| 2956 | toInt(), toBool(), ... methods. | - | ||||||||||||||||||||||||
| 2957 | - | |||||||||||||||||||||||||
| 2958 | The following casts are done automatically: | - | ||||||||||||||||||||||||
| 2959 | - | |||||||||||||||||||||||||
| 2960 | \table | - | ||||||||||||||||||||||||
| 2961 | \header \li Type \li Automatically Cast To | - | ||||||||||||||||||||||||
| 2962 | \row \li \l QMetaType::Bool \li \l QMetaType::QChar, \l QMetaType::Double, | - | ||||||||||||||||||||||||
| 2963 | \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, | - | ||||||||||||||||||||||||
| 2964 | \l QMetaType::UInt, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
| 2965 | \row \li \l QMetaType::QByteArray \li \l QMetaType::Double, | - | ||||||||||||||||||||||||
| 2966 | \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, | - | ||||||||||||||||||||||||
| 2967 | \l QMetaType::UInt, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
| 2968 | \row \li \l QMetaType::QChar \li \l QMetaType::Bool, \l QMetaType::Int, | - | ||||||||||||||||||||||||
| 2969 | \l QMetaType::UInt, \l QMetaType::LongLong, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
| 2970 | \row \li \l QMetaType::QColor \li \l QMetaType::QString | - | ||||||||||||||||||||||||
| 2971 | \row \li \l QMetaType::QDate \li \l QMetaType::QDateTime, | - | ||||||||||||||||||||||||
| 2972 | \l QMetaType::QString | - | ||||||||||||||||||||||||
| 2973 | \row \li \l QMetaType::QDateTime \li \l QMetaType::QDate, | - | ||||||||||||||||||||||||
| 2974 | \l QMetaType::QString, \l QMetaType::QTime | - | ||||||||||||||||||||||||
| 2975 | \row \li \l QMetaType::Double \li \l QMetaType::Bool, \l QMetaType::Int, | - | ||||||||||||||||||||||||
| 2976 | \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, | - | ||||||||||||||||||||||||
| 2977 | \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
| 2978 | \row \li \l QMetaType::QFont \li \l QMetaType::QString | - | ||||||||||||||||||||||||
| 2979 | \row \li \l QMetaType::Int \li \l QMetaType::Bool, \l QMetaType::QChar, | - | ||||||||||||||||||||||||
| 2980 | \l QMetaType::Double, \l QMetaType::LongLong, \l QMetaType::QString, | - | ||||||||||||||||||||||||
| 2981 | \l QMetaType::UInt, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
| 2982 | \row \li \l QMetaType::QKeySequence \li \l QMetaType::Int, | - | ||||||||||||||||||||||||
| 2983 | \l QMetaType::QString | - | ||||||||||||||||||||||||
| 2984 | \row \li \l QMetaType::QVariantList \li \l QMetaType::QStringList (if the | - | ||||||||||||||||||||||||
| 2985 | list's items can be converted to QStrings) | - | ||||||||||||||||||||||||
| 2986 | \row \li \l QMetaType::LongLong \li \l QMetaType::Bool, | - | ||||||||||||||||||||||||
| 2987 | \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, | - | ||||||||||||||||||||||||
| 2988 | \l QMetaType::Int, \l QMetaType::QString, \l QMetaType::UInt, | - | ||||||||||||||||||||||||
| 2989 | \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
| 2990 | \row \li \l QMetaType::QPoint \li QMetaType::QPointF | - | ||||||||||||||||||||||||
| 2991 | \row \li \l QMetaType::QRect \li QMetaType::QRectF | - | ||||||||||||||||||||||||
| 2992 | \row \li \l QMetaType::QString \li \l QMetaType::Bool, | - | ||||||||||||||||||||||||
| 2993 | \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::QColor, | - | ||||||||||||||||||||||||
| 2994 | \l QMetaType::QDate, \l QMetaType::QDateTime, \l QMetaType::Double, | - | ||||||||||||||||||||||||
| 2995 | \l QMetaType::QFont, \l QMetaType::Int, \l QMetaType::QKeySequence, | - | ||||||||||||||||||||||||
| 2996 | \l QMetaType::LongLong, \l QMetaType::QStringList, \l QMetaType::QTime, | - | ||||||||||||||||||||||||
| 2997 | \l QMetaType::UInt, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
| 2998 | \row \li \l QMetaType::QStringList \li \l QMetaType::QVariantList, | - | ||||||||||||||||||||||||
| 2999 | \l QMetaType::QString (if the list contains exactly one item) | - | ||||||||||||||||||||||||
| 3000 | \row \li \l QMetaType::QTime \li \l QMetaType::QString | - | ||||||||||||||||||||||||
| 3001 | \row \li \l QMetaType::UInt \li \l QMetaType::Bool, \l QMetaType::QChar, | - | ||||||||||||||||||||||||
| 3002 | \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
| 3003 | \l QMetaType::QString, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
| 3004 | \row \li \l QMetaType::ULongLong \li \l QMetaType::Bool, | - | ||||||||||||||||||||||||
| 3005 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, | - | ||||||||||||||||||||||||
| 3006 | \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt | - | ||||||||||||||||||||||||
| 3007 | \endtable | - | ||||||||||||||||||||||||
| 3008 | - | |||||||||||||||||||||||||
| 3009 | A QVariant containing a pointer to a type derived from QObject will also return true for this | - | ||||||||||||||||||||||||
| 3010 | function if a qobject_cast to the type described by \a targetTypeId would succeed. Note that | - | ||||||||||||||||||||||||
| 3011 | this only works for QObject subclasses which use the Q_OBJECT macro. | - | ||||||||||||||||||||||||
| 3012 | - | |||||||||||||||||||||||||
| 3013 | A QVariant containing a sequential container will also return true for this | - | ||||||||||||||||||||||||
| 3014 | function if the \a targetTypeId is QVariantList. It is possible to iterate over | - | ||||||||||||||||||||||||
| 3015 | the contents of the container without extracting it as a (copied) QVariantList: | - | ||||||||||||||||||||||||
| 3016 | - | |||||||||||||||||||||||||
| 3017 | \snippet code/src_corelib_kernel_qvariant.cpp 9 | - | ||||||||||||||||||||||||
| 3018 | - | |||||||||||||||||||||||||
| 3019 | This requires that the value_type of the container is itself a metatype. | - | ||||||||||||||||||||||||
| 3020 | - | |||||||||||||||||||||||||
| 3021 | Similarly, a QVariant containing a sequential container will also return true for this | - | ||||||||||||||||||||||||
| 3022 | function the \a targetTypeId is QVariantHash or QVariantMap. It is possible to iterate over | - | ||||||||||||||||||||||||
| 3023 | the contents of the container without extracting it as a (copied) QVariantHash or QVariantMap: | - | ||||||||||||||||||||||||
| 3024 | - | |||||||||||||||||||||||||
| 3025 | \snippet code/src_corelib_kernel_qvariant.cpp 10 | - | ||||||||||||||||||||||||
| 3026 | - | |||||||||||||||||||||||||
| 3027 | \sa convert(), QSequentialIterable, Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(), QAssociativeIterable, | - | ||||||||||||||||||||||||
| 3028 | Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE() | - | ||||||||||||||||||||||||
| 3029 | */ | - | ||||||||||||||||||||||||
| 3030 | bool QVariant::canConvert(int targetTypeId) const | - | ||||||||||||||||||||||||
| 3031 | { | - | ||||||||||||||||||||||||
| 3032 | if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex)
| 0-228043 | ||||||||||||||||||||||||
| 3033 | || (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex))
| 0-228041 | ||||||||||||||||||||||||
| 3034 | return true; executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||
| 3035 | - | |||||||||||||||||||||||||
| 3036 | if (targetTypeId == QMetaType::QVariantList
| 63-227978 | ||||||||||||||||||||||||
| 3037 | && (d.type == QMetaType::QVariantList
| 2-61 | ||||||||||||||||||||||||
| 3038 | || d.type == QMetaType::QStringList
| 2-59 | ||||||||||||||||||||||||
| 3039 | || d.type == QMetaType::QByteArrayList
| 2-57 | ||||||||||||||||||||||||
| 3040 | || QMetaType::hasRegisteredConverterFunction(d.type,
| 20-37 | ||||||||||||||||||||||||
| 3041 | qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>()))) {
| 20-37 | ||||||||||||||||||||||||
| 3042 | return true; executed 26 times by 1 test: return true;Executed by:
| 26 | ||||||||||||||||||||||||
| 3043 | } | - | ||||||||||||||||||||||||
| 3044 | - | |||||||||||||||||||||||||
| 3045 | if ((targetTypeId == QMetaType::QVariantHash || targetTypeId == QMetaType::QVariantMap)
| 25-227990 | ||||||||||||||||||||||||
| 3046 | && (d.type == QMetaType::QVariantMap
| 1-63 | ||||||||||||||||||||||||
| 3047 | || d.type == QMetaType::QVariantHash
| 0-63 | ||||||||||||||||||||||||
| 3048 | || QMetaType::hasRegisteredConverterFunction(d.type,
| 0-63 | ||||||||||||||||||||||||
| 3049 | qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>()))) {
| 0-63 | ||||||||||||||||||||||||
| 3050 | return true; executed 1 time by 1 test: return true;Executed by:
| 1 | ||||||||||||||||||||||||
| 3051 | } | - | ||||||||||||||||||||||||
| 3052 | - | |||||||||||||||||||||||||
| 3053 | if (targetTypeId == qMetaTypeId<QPair<QVariant, QVariant> >() &&
| 10-228004 | ||||||||||||||||||||||||
| 3054 | QMetaType::hasRegisteredConverterFunction(d.type,
| 0-10 | ||||||||||||||||||||||||
| 3055 | qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) {
| 0-10 | ||||||||||||||||||||||||
| 3056 | return true; executed 10 times by 1 test: return true;Executed by:
| 10 | ||||||||||||||||||||||||
| 3057 | } | - | ||||||||||||||||||||||||
| 3058 | - | |||||||||||||||||||||||||
| 3059 | if ((d.type >= QMetaType::User || targetTypeId >= QMetaType::User)
| 133-227507 | ||||||||||||||||||||||||
| 3060 | && QMetaType::hasRegisteredConverterFunction(d.type, targetTypeId)) {
| 16-614 | ||||||||||||||||||||||||
| 3061 | return true; executed 16 times by 3 tests: return true;Executed by:
| 16 | ||||||||||||||||||||||||
| 3062 | } | - | ||||||||||||||||||||||||
| 3063 | - | |||||||||||||||||||||||||
| 3064 | // TODO Reimplement this function, currently it works but it is a historical mess. | - | ||||||||||||||||||||||||
| 3065 | uint currentType = ((d.type == QMetaType::Float) ? QVariant::Double : d.type);
| 84-227904 | ||||||||||||||||||||||||
| 3066 | if (currentType == QMetaType::SChar || currentType == QMetaType::Char)
| 63-227924 | ||||||||||||||||||||||||
| 3067 | currentType = QMetaType::UInt; executed 127 times by 1 test: currentType = QMetaType::UInt;Executed by:
| 127 | ||||||||||||||||||||||||
| 3068 | if (targetTypeId == QMetaType::SChar || currentType == QMetaType::Char)
| 0-227987 | ||||||||||||||||||||||||
| 3069 | targetTypeId = QMetaType::UInt; executed 1 time by 1 test: targetTypeId = QMetaType::UInt;Executed by:
| 1 | ||||||||||||||||||||||||
| 3070 | if (uint(targetTypeId) == uint(QMetaType::Float)) targetTypeId = QVariant::Double; executed 51 times by 5 tests: targetTypeId = QVariant::Double;Executed by:
| 51-227937 | ||||||||||||||||||||||||
| 3071 | - | |||||||||||||||||||||||||
| 3072 | - | |||||||||||||||||||||||||
| 3073 | if (currentType == uint(targetTypeId))
| 735-227253 | ||||||||||||||||||||||||
| 3074 | return true; executed 735 times by 27 tests: return true;Executed by:
| 735 | ||||||||||||||||||||||||
| 3075 | - | |||||||||||||||||||||||||
| 3076 | if (targetTypeId < 0)
| 75-227178 | ||||||||||||||||||||||||
| 3077 | return false; executed 75 times by 1 test: return false;Executed by:
| 75 | ||||||||||||||||||||||||
| 3078 | if (targetTypeId >= QMetaType::User) {
| 133-227045 | ||||||||||||||||||||||||
| 3079 | if (QMetaType::typeFlags(targetTypeId) & QMetaType::IsEnumeration) {
| 57-76 | ||||||||||||||||||||||||
| 3080 | targetTypeId = QMetaType::Int; | - | ||||||||||||||||||||||||
| 3081 | } else { executed 57 times by 1 test: end of blockExecuted by:
| 57 | ||||||||||||||||||||||||
| 3082 | return canConvertMetaObject(currentType, targetTypeId, d.data.o); executed 76 times by 6 tests: return canConvertMetaObject(currentType, targetTypeId, d.data.o);Executed by:
| 76 | ||||||||||||||||||||||||
| 3083 | } | - | ||||||||||||||||||||||||
| 3084 | } | - | ||||||||||||||||||||||||
| 3085 | - | |||||||||||||||||||||||||
| 3086 | if (currentType == QMetaType::QJsonValue) {
| 48-227054 | ||||||||||||||||||||||||
| 3087 | switch (targetTypeId) { | - | ||||||||||||||||||||||||
| 3088 | case QMetaType::QString: executed 3 times by 1 test: case QMetaType::QString:Executed by:
| 3 | ||||||||||||||||||||||||
| 3089 | case QMetaType::Bool: executed 3 times by 1 test: case QMetaType::Bool:Executed by:
| 3 | ||||||||||||||||||||||||
| 3090 | case QMetaType::Int: executed 3 times by 1 test: case QMetaType::Int:Executed by:
| 3 | ||||||||||||||||||||||||
| 3091 | case QMetaType::UInt: executed 3 times by 1 test: case QMetaType::UInt:Executed by:
| 3 | ||||||||||||||||||||||||
| 3092 | case QMetaType::Double: executed 6 times by 1 test: case QMetaType::Double:Executed by:
| 6 | ||||||||||||||||||||||||
| 3093 | case QMetaType::Float: never executed: case QMetaType::Float: | 0 | ||||||||||||||||||||||||
| 3094 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 3095 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
| 3096 | case QMetaType::LongLong: executed 3 times by 1 test: case QMetaType::LongLong:Executed by:
| 3 | ||||||||||||||||||||||||
| 3097 | case QMetaType::ULongLong: executed 3 times by 1 test: case QMetaType::ULongLong:Executed by:
| 3 | ||||||||||||||||||||||||
| 3098 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
| 3099 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
| 3100 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
| 3101 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
| 3102 | case QMetaType::Short: never executed: case QMetaType::Short: | 0 | ||||||||||||||||||||||||
| 3103 | case QMetaType::QVariantList: executed 1 time by 1 test: case QMetaType::QVariantList:Executed by:
| 1 | ||||||||||||||||||||||||
| 3104 | case QMetaType::QVariantMap: executed 1 time by 1 test: case QMetaType::QVariantMap:Executed by:
| 1 | ||||||||||||||||||||||||
| 3105 | case QMetaType::QVariantHash: never executed: case QMetaType::QVariantHash: | 0 | ||||||||||||||||||||||||
| 3106 | return true; executed 26 times by 1 test: return true;Executed by:
| 26 | ||||||||||||||||||||||||
| 3107 | default: executed 22 times by 1 test: default:Executed by:
| 22 | ||||||||||||||||||||||||
| 3108 | return false; executed 22 times by 1 test: return false;Executed by:
| 22 | ||||||||||||||||||||||||
| 3109 | } | - | ||||||||||||||||||||||||
| 3110 | } | - | ||||||||||||||||||||||||
| 3111 | if (currentType == QMetaType::QJsonArray)
| 32-227022 | ||||||||||||||||||||||||
| 3112 | return targetTypeId == QMetaType::QVariantList; executed 32 times by 1 test: return targetTypeId == QMetaType::QVariantList;Executed by:
| 32 | ||||||||||||||||||||||||
| 3113 | if (currentType == QMetaType::QJsonObject)
| 32-226990 | ||||||||||||||||||||||||
| 3114 | return targetTypeId == QMetaType::QVariantMap || targetTypeId == QMetaType::QVariantHash; executed 32 times by 1 test: return targetTypeId == QMetaType::QVariantMap || targetTypeId == QMetaType::QVariantHash;Executed by:
| 32 | ||||||||||||||||||||||||
| 3115 | - | |||||||||||||||||||||||||
| 3116 | // FIXME It should be LastCoreType intead of Uuid | - | ||||||||||||||||||||||||
| 3117 | if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) {
| 12839-166896 | ||||||||||||||||||||||||
| 3118 | switch (uint(targetTypeId)) { | - | ||||||||||||||||||||||||
| 3119 | case QVariant::Int: executed 71 times by 4 tests: case QVariant::Int:Executed by:
| 71 | ||||||||||||||||||||||||
| 3120 | if (currentType == QVariant::KeySequence)
| 2-69 | ||||||||||||||||||||||||
| 3121 | return true; executed 2 times by 1 test: return true;Executed by:
| 2 | ||||||||||||||||||||||||
| 3122 | // fall through | - | ||||||||||||||||||||||||
| 3123 | case QVariant::UInt: code before this statement executed 69 times by 4 tests: case QVariant::UInt:Executed by:
executed 37 times by 3 tests: case QVariant::UInt:Executed by:
| 37-69 | ||||||||||||||||||||||||
| 3124 | case QVariant::LongLong: executed 40 times by 3 tests: case QVariant::LongLong:Executed by:
| 40 | ||||||||||||||||||||||||
| 3125 | case QVariant::ULongLong: executed 40 times by 3 tests: case QVariant::ULongLong:Executed by:
| 40 | ||||||||||||||||||||||||
| 3126 | return currentType == QMetaType::ULong executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 186 | ||||||||||||||||||||||||
| 3127 | || currentType == QMetaType::Long executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 186 | ||||||||||||||||||||||||
| 3128 | || currentType == QMetaType::UShort executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 186 | ||||||||||||||||||||||||
| 3129 | || currentType == QMetaType::UChar executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 186 | ||||||||||||||||||||||||
| 3130 | || currentType == QMetaType::Char executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 186 | ||||||||||||||||||||||||
| 3131 | || currentType == QMetaType::SChar executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 186 | ||||||||||||||||||||||||
| 3132 | || currentType == QMetaType::Short executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 186 | ||||||||||||||||||||||||
| 3133 | || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 186 | ||||||||||||||||||||||||
| 3134 | case QVariant::Image: executed 35 times by 3 tests: case QVariant::Image:Executed by:
| 35 | ||||||||||||||||||||||||
| 3135 | return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap; executed 35 times by 3 tests: return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap;Executed by:
| 35 | ||||||||||||||||||||||||
| 3136 | case QVariant::Pixmap: executed 36 times by 3 tests: case QVariant::Pixmap:Executed by:
| 36 | ||||||||||||||||||||||||
| 3137 | return currentType == QVariant::Image || currentType == QVariant::Bitmap executed 36 times by 3 tests: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush;Executed by:
| 36 | ||||||||||||||||||||||||
| 3138 | || currentType == QVariant::Brush; executed 36 times by 3 tests: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush;Executed by:
| 36 | ||||||||||||||||||||||||
| 3139 | case QVariant::Bitmap: executed 35 times by 3 tests: case QVariant::Bitmap:Executed by:
| 35 | ||||||||||||||||||||||||
| 3140 | return currentType == QVariant::Pixmap || currentType == QVariant::Image; executed 35 times by 3 tests: return currentType == QVariant::Pixmap || currentType == QVariant::Image;Executed by:
| 35 | ||||||||||||||||||||||||
| 3141 | case QVariant::ByteArray: executed 24 times by 3 tests: case QVariant::ByteArray:Executed by:
| 24 | ||||||||||||||||||||||||
| 3142 | return currentType == QVariant::Color executed 24 times by 3 tests: return currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));Executed by:
| 24 | ||||||||||||||||||||||||
| 3143 | || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); executed 24 times by 3 tests: return currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));Executed by:
| 24 | ||||||||||||||||||||||||
| 3144 | case QVariant::String: executed 438 times by 12 tests: case QVariant::String:Executed by:
| 438 | ||||||||||||||||||||||||
| 3145 | return currentType == QVariant::KeySequence || currentType == QVariant::Font executed 438 times by 12 tests: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));Executed by:
| 438 | ||||||||||||||||||||||||
| 3146 | || currentType == QVariant::Color executed 438 times by 12 tests: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));Executed by:
| 438 | ||||||||||||||||||||||||
| 3147 | || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); executed 438 times by 12 tests: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));Executed by:
| 438 | ||||||||||||||||||||||||
| 3148 | case QVariant::KeySequence: executed 37 times by 3 tests: case QVariant::KeySequence:Executed by:
| 37 | ||||||||||||||||||||||||
| 3149 | return currentType == QVariant::String || currentType == QVariant::Int; executed 37 times by 3 tests: return currentType == QVariant::String || currentType == QVariant::Int;Executed by:
| 37 | ||||||||||||||||||||||||
| 3150 | case QVariant::Font: executed 71 times by 4 tests: case QVariant::Font:Executed by:
| 71 | ||||||||||||||||||||||||
| 3151 | return currentType == QVariant::String; executed 71 times by 4 tests: return currentType == QVariant::String;Executed by:
| 71 | ||||||||||||||||||||||||
| 3152 | case QVariant::Color: executed 303 times by 13 tests: case QVariant::Color:Executed by:
| 303 | ||||||||||||||||||||||||
| 3153 | return currentType == QVariant::String || currentType == QVariant::ByteArray executed 303 times by 13 tests: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush;Executed by:
| 303 | ||||||||||||||||||||||||
| 3154 | || currentType == QVariant::Brush; executed 303 times by 13 tests: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush;Executed by:
| 303 | ||||||||||||||||||||||||
| 3155 | case QVariant::Brush: executed 212336 times by 32 tests: case QVariant::Brush:Executed by:
| 212336 | ||||||||||||||||||||||||
| 3156 | return currentType == QVariant::Color || currentType == QVariant::Pixmap; executed 212336 times by 32 tests: return currentType == QVariant::Color || currentType == QVariant::Pixmap;Executed by:
| 212336 | ||||||||||||||||||||||||
| 3157 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
| 3158 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
| 3159 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
| 3160 | case QMetaType::UChar: executed 1 time by 1 test: case QMetaType::UChar:Executed by:
| 1 | ||||||||||||||||||||||||
| 3161 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
| 3162 | case QMetaType::Short: executed 24 times by 1 test: case QMetaType::Short:Executed by:
| 24 | ||||||||||||||||||||||||
| 3163 | case QMetaType::UShort: executed 24 times by 1 test: case QMetaType::UShort:Executed by:
| 24 | ||||||||||||||||||||||||
| 3164 | return currentType == QVariant::Int executed 49 times by 1 test: return currentType == QVariant::Int || (currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 49 | ||||||||||||||||||||||||
| 3165 | || (currentType < qCanConvertMatrixMaximumTargetType executed 49 times by 1 test: return currentType == QVariant::Int || (currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 49 | ||||||||||||||||||||||||
| 3166 | && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) executed 49 times by 1 test: return currentType == QVariant::Int || (currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 49 | ||||||||||||||||||||||||
| 3167 | || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; executed 49 times by 1 test: return currentType == QVariant::Int || (currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration;Executed by:
| 49 | ||||||||||||||||||||||||
| 3168 | case QMetaType::QObjectStar: executed 40 times by 2 tests: case QMetaType::QObjectStar:Executed by:
| 40 | ||||||||||||||||||||||||
| 3169 | return canConvertMetaObject(currentType, targetTypeId, d.data.o); executed 40 times by 2 tests: return canConvertMetaObject(currentType, targetTypeId, d.data.o);Executed by:
| 40 | ||||||||||||||||||||||||
| 3170 | default: executed 559 times by 6 tests: default:Executed by:
| 559 | ||||||||||||||||||||||||
| 3171 | return false; executed 559 times by 6 tests: return false;Executed by:
| 559 | ||||||||||||||||||||||||
| 3172 | } | - | ||||||||||||||||||||||||
| 3173 | } | - | ||||||||||||||||||||||||
| 3174 | - | |||||||||||||||||||||||||
| 3175 | if (targetTypeId == String && currentType == StringList)
| 18-7684 | ||||||||||||||||||||||||
| 3176 | return v_cast<QStringList>(&d)->count() == 1; executed 18 times by 3 tests: return v_cast<QStringList>(&d)->count() == 1;Executed by:
| 18 | ||||||||||||||||||||||||
| 3177 | return currentType < qCanConvertMatrixMaximumTargetType executed 12821 times by 66 tests: return currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[targetTypeId] & (1U << currentType);Executed by:
| 12821 | ||||||||||||||||||||||||
| 3178 | && qCanConvertMatrix[targetTypeId] & (1U << currentType); executed 12821 times by 66 tests: return currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[targetTypeId] & (1U << currentType);Executed by:
| 12821 | ||||||||||||||||||||||||
| 3179 | } | - | ||||||||||||||||||||||||
| 3180 | - | |||||||||||||||||||||||||
| 3181 | /*! | - | ||||||||||||||||||||||||
| 3182 | Casts the variant to the requested type, \a targetTypeId. If the cast cannot be | - | ||||||||||||||||||||||||
| 3183 | done, the variant is cleared. Returns \c true if the current type of | - | ||||||||||||||||||||||||
| 3184 | the variant was successfully cast; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 3185 | - | |||||||||||||||||||||||||
| 3186 | A QVariant containing a pointer to a type derived from QObject will also convert | - | ||||||||||||||||||||||||
| 3187 | and return true for this function if a qobject_cast to the type described | - | ||||||||||||||||||||||||
| 3188 | by \a targetTypeId would succeed. Note that this only works for QObject subclasses | - | ||||||||||||||||||||||||
| 3189 | which use the Q_OBJECT macro. | - | ||||||||||||||||||||||||
| 3190 | - | |||||||||||||||||||||||||
| 3191 | \warning For historical reasons, converting a null QVariant results | - | ||||||||||||||||||||||||
| 3192 | in a null value of the desired type (e.g., an empty string for | - | ||||||||||||||||||||||||
| 3193 | QString) and a result of false. | - | ||||||||||||||||||||||||
| 3194 | - | |||||||||||||||||||||||||
| 3195 | \sa canConvert(), clear() | - | ||||||||||||||||||||||||
| 3196 | */ | - | ||||||||||||||||||||||||
| 3197 | - | |||||||||||||||||||||||||
| 3198 | bool QVariant::convert(int targetTypeId) | - | ||||||||||||||||||||||||
| 3199 | { | - | ||||||||||||||||||||||||
| 3200 | if (d.type == uint(targetTypeId))
| 1356-6277 | ||||||||||||||||||||||||
| 3201 | return true; executed 1356 times by 27 tests: return true;Executed by:
| 1356 | ||||||||||||||||||||||||
| 3202 | - | |||||||||||||||||||||||||
| 3203 | QVariant oldValue = *this; | - | ||||||||||||||||||||||||
| 3204 | - | |||||||||||||||||||||||||
| 3205 | clear(); | - | ||||||||||||||||||||||||
| 3206 | if (!oldValue.canConvert(targetTypeId))
| 815-5462 | ||||||||||||||||||||||||
| 3207 | return false; executed 5462 times by 34 tests: return false;Executed by:
| 5462 | ||||||||||||||||||||||||
| 3208 | - | |||||||||||||||||||||||||
| 3209 | create(targetTypeId, 0); | - | ||||||||||||||||||||||||
| 3210 | if (oldValue.isNull())
| 20-795 | ||||||||||||||||||||||||
| 3211 | return false; executed 20 times by 2 tests: return false;Executed by:
| 20 | ||||||||||||||||||||||||
| 3212 | - | |||||||||||||||||||||||||
| 3213 | if ((QMetaType::typeFlags(oldValue.userType()) & QMetaType::PointerToQObject) && (QMetaType::typeFlags(targetTypeId) & QMetaType::PointerToQObject)) { | - | ||||||||||||||||||||||||
| 3214 | create(targetTypeId, &oldValue.d.data.o); | - | ||||||||||||||||||||||||
| 3215 | return true; executed 7 times by 3 tests: return true;Executed by:
| 7 | ||||||||||||||||||||||||
| 3216 | } | - | ||||||||||||||||||||||||
| 3217 | - | |||||||||||||||||||||||||
| 3218 | bool isOk = true; | - | ||||||||||||||||||||||||
| 3219 | int converterType = std::max(oldValue.userType(), targetTypeId); | - | ||||||||||||||||||||||||
| 3220 | if (!handlerManager[converterType]->convert(&oldValue.d, targetTypeId, data(), &isOk))
| 64-724 | ||||||||||||||||||||||||
| 3221 | isOk = false; executed 64 times by 7 tests: isOk = false;Executed by:
| 64 | ||||||||||||||||||||||||
| 3222 | d.is_null = !isOk; | - | ||||||||||||||||||||||||
| 3223 | return isOk; executed 788 times by 29 tests: return isOk;Executed by:
| 788 | ||||||||||||||||||||||||
| 3224 | } | - | ||||||||||||||||||||||||
| 3225 | - | |||||||||||||||||||||||||
| 3226 | /*! | - | ||||||||||||||||||||||||
| 3227 | \fn bool QVariant::convert(const int type, void *ptr) const | - | ||||||||||||||||||||||||
| 3228 | \internal | - | ||||||||||||||||||||||||
| 3229 | Created for qvariant_cast() usage | - | ||||||||||||||||||||||||
| 3230 | */ | - | ||||||||||||||||||||||||
| 3231 | bool QVariant::convert(const int type, void *ptr) const | - | ||||||||||||||||||||||||
| 3232 | { | - | ||||||||||||||||||||||||
| 3233 | return handlerManager[type]->convert(&d, type, ptr, 0); executed 371763 times by 107 tests: return handlerManager[type]->convert(&d, type, ptr, 0);Executed by:
| 371763 | ||||||||||||||||||||||||
| 3234 | } | - | ||||||||||||||||||||||||
| 3235 | - | |||||||||||||||||||||||||
| 3236 | - | |||||||||||||||||||||||||
| 3237 | /*! | - | ||||||||||||||||||||||||
| 3238 | \fn bool operator==(const QVariant &v1, const QVariant &v2) | - | ||||||||||||||||||||||||
| 3239 | - | |||||||||||||||||||||||||
| 3240 | \relates QVariant | - | ||||||||||||||||||||||||
| 3241 | - | |||||||||||||||||||||||||
| 3242 | Returns \c true if \a v1 and \a v2 are equal; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 3243 | - | |||||||||||||||||||||||||
| 3244 | If \a v1 and \a v2 have the same \l{QVariant::}{type()}, the | - | ||||||||||||||||||||||||
| 3245 | type's equality operator is used for comparison. If not, it is | - | ||||||||||||||||||||||||
| 3246 | attempted to \l{QVariant::}{convert()} \a v2 to the same type as | - | ||||||||||||||||||||||||
| 3247 | \a v1. See \l{QVariant::}{canConvert()} for a list of possible | - | ||||||||||||||||||||||||
| 3248 | conversions. | - | ||||||||||||||||||||||||
| 3249 | - | |||||||||||||||||||||||||
| 3250 | The result of the function is not affected by the result of QVariant::isNull, | - | ||||||||||||||||||||||||
| 3251 | which means that two values can be equal even if one of them is null and | - | ||||||||||||||||||||||||
| 3252 | another is not. | - | ||||||||||||||||||||||||
| 3253 | - | |||||||||||||||||||||||||
| 3254 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
| 3255 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
| 3256 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
| 3257 | */ | - | ||||||||||||||||||||||||
| 3258 | /*! | - | ||||||||||||||||||||||||
| 3259 | \fn bool operator!=(const QVariant &v1, const QVariant &v2) | - | ||||||||||||||||||||||||
| 3260 | - | |||||||||||||||||||||||||
| 3261 | \relates QVariant | - | ||||||||||||||||||||||||
| 3262 | - | |||||||||||||||||||||||||
| 3263 | Returns \c false if \a v1 and \a v2 are equal; otherwise returns \c true. | - | ||||||||||||||||||||||||
| 3264 | - | |||||||||||||||||||||||||
| 3265 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
| 3266 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
| 3267 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
| 3268 | */ | - | ||||||||||||||||||||||||
| 3269 | - | |||||||||||||||||||||||||
| 3270 | /*! \fn bool QVariant::operator==(const QVariant &v) const | - | ||||||||||||||||||||||||
| 3271 | - | |||||||||||||||||||||||||
| 3272 | Compares this QVariant with \a v and returns \c true if they are | - | ||||||||||||||||||||||||
| 3273 | equal; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 3274 | - | |||||||||||||||||||||||||
| 3275 | QVariant uses the equality operator of the type() it contains to | - | ||||||||||||||||||||||||
| 3276 | check for equality. QVariant will try to convert() \a v if its | - | ||||||||||||||||||||||||
| 3277 | type is not the same as this variant's type. See canConvert() for | - | ||||||||||||||||||||||||
| 3278 | a list of possible conversions. | - | ||||||||||||||||||||||||
| 3279 | - | |||||||||||||||||||||||||
| 3280 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
| 3281 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
| 3282 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
| 3283 | */ | - | ||||||||||||||||||||||||
| 3284 | - | |||||||||||||||||||||||||
| 3285 | /*! | - | ||||||||||||||||||||||||
| 3286 | \fn bool QVariant::operator!=(const QVariant &v) const | - | ||||||||||||||||||||||||
| 3287 | - | |||||||||||||||||||||||||
| 3288 | Compares this QVariant with \a v and returns \c true if they are not | - | ||||||||||||||||||||||||
| 3289 | equal; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 3290 | - | |||||||||||||||||||||||||
| 3291 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
| 3292 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
| 3293 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
| 3294 | */ | - | ||||||||||||||||||||||||
| 3295 | - | |||||||||||||||||||||||||
| 3296 | /*! | - | ||||||||||||||||||||||||
| 3297 | \fn bool QVariant::operator<(const QVariant &v) const | - | ||||||||||||||||||||||||
| 3298 | - | |||||||||||||||||||||||||
| 3299 | Compares this QVariant with \a v and returns \c true if this is less than \a v. | - | ||||||||||||||||||||||||
| 3300 | - | |||||||||||||||||||||||||
| 3301 | \note Comparability might not be availabe for the type stored in this QVariant | - | ||||||||||||||||||||||||
| 3302 | or in \a v. | - | ||||||||||||||||||||||||
| 3303 | - | |||||||||||||||||||||||||
| 3304 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
| 3305 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
| 3306 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
| 3307 | */ | - | ||||||||||||||||||||||||
| 3308 | - | |||||||||||||||||||||||||
| 3309 | /*! | - | ||||||||||||||||||||||||
| 3310 | \fn bool QVariant::operator<=(const QVariant &v) const | - | ||||||||||||||||||||||||
| 3311 | - | |||||||||||||||||||||||||
| 3312 | Compares this QVariant with \a v and returns \c true if this is less or equal than \a v. | - | ||||||||||||||||||||||||
| 3313 | - | |||||||||||||||||||||||||
| 3314 | \note Comparability might not be available for the type stored in this QVariant | - | ||||||||||||||||||||||||
| 3315 | or in \a v. | - | ||||||||||||||||||||||||
| 3316 | - | |||||||||||||||||||||||||
| 3317 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
| 3318 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
| 3319 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
| 3320 | */ | - | ||||||||||||||||||||||||
| 3321 | - | |||||||||||||||||||||||||
| 3322 | /*! | - | ||||||||||||||||||||||||
| 3323 | \fn bool QVariant::operator>(const QVariant &v) const | - | ||||||||||||||||||||||||
| 3324 | - | |||||||||||||||||||||||||
| 3325 | Compares this QVariant with \a v and returns \c true if this is larger than \a v. | - | ||||||||||||||||||||||||
| 3326 | - | |||||||||||||||||||||||||
| 3327 | \note Comparability might not be available for the type stored in this QVariant | - | ||||||||||||||||||||||||
| 3328 | or in \a v. | - | ||||||||||||||||||||||||
| 3329 | - | |||||||||||||||||||||||||
| 3330 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
| 3331 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
| 3332 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
| 3333 | */ | - | ||||||||||||||||||||||||
| 3334 | - | |||||||||||||||||||||||||
| 3335 | /*! | - | ||||||||||||||||||||||||
| 3336 | \fn bool QVariant::operator>=(const QVariant &v) const | - | ||||||||||||||||||||||||
| 3337 | - | |||||||||||||||||||||||||
| 3338 | Compares this QVariant with \a v and returns \c true if this is larger or equal than \a v. | - | ||||||||||||||||||||||||
| 3339 | - | |||||||||||||||||||||||||
| 3340 | \note Comparability might not be available for the type stored in this QVariant | - | ||||||||||||||||||||||||
| 3341 | or in \a v. | - | ||||||||||||||||||||||||
| 3342 | - | |||||||||||||||||||||||||
| 3343 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
| 3344 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
| 3345 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
| 3346 | */ | - | ||||||||||||||||||||||||
| 3347 | - | |||||||||||||||||||||||||
| 3348 | static bool qIsNumericType(uint tp) | - | ||||||||||||||||||||||||
| 3349 | { | - | ||||||||||||||||||||||||
| 3350 | static const qulonglong numericTypeBits = | - | ||||||||||||||||||||||||
| 3351 | Q_UINT64_C(1) << QMetaType::Bool | | - | ||||||||||||||||||||||||
| 3352 | Q_UINT64_C(1) << QMetaType::Double | | - | ||||||||||||||||||||||||
| 3353 | Q_UINT64_C(1) << QMetaType::Float | | - | ||||||||||||||||||||||||
| 3354 | Q_UINT64_C(1) << QMetaType::Char | | - | ||||||||||||||||||||||||
| 3355 | Q_UINT64_C(1) << QMetaType::SChar | | - | ||||||||||||||||||||||||
| 3356 | Q_UINT64_C(1) << QMetaType::UChar | | - | ||||||||||||||||||||||||
| 3357 | Q_UINT64_C(1) << QMetaType::Short | | - | ||||||||||||||||||||||||
| 3358 | Q_UINT64_C(1) << QMetaType::UShort | | - | ||||||||||||||||||||||||
| 3359 | Q_UINT64_C(1) << QMetaType::Int | | - | ||||||||||||||||||||||||
| 3360 | Q_UINT64_C(1) << QMetaType::UInt | | - | ||||||||||||||||||||||||
| 3361 | Q_UINT64_C(1) << QMetaType::Long | | - | ||||||||||||||||||||||||
| 3362 | Q_UINT64_C(1) << QMetaType::ULong | | - | ||||||||||||||||||||||||
| 3363 | Q_UINT64_C(1) << QMetaType::LongLong | | - | ||||||||||||||||||||||||
| 3364 | Q_UINT64_C(1) << QMetaType::ULongLong; | - | ||||||||||||||||||||||||
| 3365 | return tp < (CHAR_BIT * sizeof numericTypeBits) ? numericTypeBits & (Q_UINT64_C(1) << tp) : false; executed 769050 times by 116 tests: return tp < (8 * sizeof numericTypeBits) ? numericTypeBits & (static_cast<unsigned long long>(1ULL) << tp) : false;Executed by:
| 769050 | ||||||||||||||||||||||||
| 3366 | } | - | ||||||||||||||||||||||||
| 3367 | - | |||||||||||||||||||||||||
| 3368 | static bool qIsFloatingPoint(uint tp) | - | ||||||||||||||||||||||||
| 3369 | { | - | ||||||||||||||||||||||||
| 3370 | return tp == QVariant::Double || tp == QMetaType::Float; executed 329598 times by 84 tests: return tp == QVariant::Double || tp == QMetaType::Float;Executed by:
| 329598 | ||||||||||||||||||||||||
| 3371 | } | - | ||||||||||||||||||||||||
| 3372 | - | |||||||||||||||||||||||||
| 3373 | static int normalizeLowerRanks(uint tp) | - | ||||||||||||||||||||||||
| 3374 | { | - | ||||||||||||||||||||||||
| 3375 | static const qulonglong numericTypeBits = | - | ||||||||||||||||||||||||
| 3376 | Q_UINT64_C(1) << QMetaType::Bool | | - | ||||||||||||||||||||||||
| 3377 | Q_UINT64_C(1) << QMetaType::Char | | - | ||||||||||||||||||||||||
| 3378 | Q_UINT64_C(1) << QMetaType::SChar | | - | ||||||||||||||||||||||||
| 3379 | Q_UINT64_C(1) << QMetaType::UChar | | - | ||||||||||||||||||||||||
| 3380 | Q_UINT64_C(1) << QMetaType::Short | | - | ||||||||||||||||||||||||
| 3381 | Q_UINT64_C(1) << QMetaType::UShort; | - | ||||||||||||||||||||||||
| 3382 | return numericTypeBits & (Q_UINT64_C(1) << tp) ? QVariant::Int : tp; executed 323800 times by 83 tests: return numericTypeBits & (static_cast<unsigned long long>(1ULL) << tp) ? QVariant::Int : tp;Executed by:
| 323800 | ||||||||||||||||||||||||
| 3383 | } | - | ||||||||||||||||||||||||
| 3384 | - | |||||||||||||||||||||||||
| 3385 | static int normalizeLong(uint tp) | - | ||||||||||||||||||||||||
| 3386 | { | - | ||||||||||||||||||||||||
| 3387 | const uint IntType = sizeof(long) == sizeof(int) ? QVariant::Int : QVariant::LongLong;
| 0-323800 | ||||||||||||||||||||||||
| 3388 | const uint UIntType = sizeof(ulong) == sizeof(uint) ? QVariant::UInt : QVariant::ULongLong;
| 0-323800 | ||||||||||||||||||||||||
| 3389 | return tp == QMetaType::Long ? IntType : executed 323800 times by 83 tests: return tp == QMetaType::Long ? IntType : tp == QMetaType::ULong ? UIntType : tp;Executed by:
| 323800 | ||||||||||||||||||||||||
| 3390 | tp == QMetaType::ULong ? UIntType : tp; executed 323800 times by 83 tests: return tp == QMetaType::Long ? IntType : tp == QMetaType::ULong ? UIntType : tp;Executed by:
| 323800 | ||||||||||||||||||||||||
| 3391 | } | - | ||||||||||||||||||||||||
| 3392 | - | |||||||||||||||||||||||||
| 3393 | static int numericTypePromotion(uint t1, uint t2) | - | ||||||||||||||||||||||||
| 3394 | { | - | ||||||||||||||||||||||||
| 3395 | Q_ASSERT(qIsNumericType(t1)); | - | ||||||||||||||||||||||||
| 3396 | Q_ASSERT(qIsNumericType(t2)); | - | ||||||||||||||||||||||||
| 3397 | - | |||||||||||||||||||||||||
| 3398 | // C++ integral ranks: (4.13 Integer conversion rank [conv.rank]) | - | ||||||||||||||||||||||||
| 3399 | // bool < signed char < short < int < long < long long | - | ||||||||||||||||||||||||
| 3400 | // unsigneds have the same rank as their signed counterparts | - | ||||||||||||||||||||||||
| 3401 | // C++ integral promotion rules (4.5 Integral Promotions [conv.prom]) | - | ||||||||||||||||||||||||
| 3402 | // - any type with rank less than int can be converted to int or unsigned int | - | ||||||||||||||||||||||||
| 3403 | // 5 Expressions [expr] paragraph 9: | - | ||||||||||||||||||||||||
| 3404 | // - if either operand is double, the other shall be converted to double | - | ||||||||||||||||||||||||
| 3405 | // - " " float, " " " float | - | ||||||||||||||||||||||||
| 3406 | // - if both operands have the same type, no further conversion is needed. | - | ||||||||||||||||||||||||
| 3407 | // - if both are signed or if both are unsigned, convert to the one with highest rank | - | ||||||||||||||||||||||||
| 3408 | // - if the unsigned has higher or same rank, convert the signed to the unsigned one | - | ||||||||||||||||||||||||
| 3409 | // - if the signed can represent all values of the unsigned, convert to the signed | - | ||||||||||||||||||||||||
| 3410 | // - otherwise, convert to the unsigned corresponding to the rank of the signed | - | ||||||||||||||||||||||||
| 3411 | - | |||||||||||||||||||||||||
| 3412 | // floating point: we deviate from the C++ standard by always using qreal | - | ||||||||||||||||||||||||
| 3413 | if (qIsFloatingPoint(t1) || qIsFloatingPoint(t2))
| 85-161985 | ||||||||||||||||||||||||
| 3414 | return QMetaType::QReal; executed 5713 times by 32 tests: return QMetaType::QReal;Executed by:
| 5713 | ||||||||||||||||||||||||
| 3415 | - | |||||||||||||||||||||||||
| 3416 | // integral rules: | - | ||||||||||||||||||||||||
| 3417 | // for all platforms we support, int can always hold the values of lower-ranked types | - | ||||||||||||||||||||||||
| 3418 | t1 = normalizeLowerRanks(t1); | - | ||||||||||||||||||||||||
| 3419 | t2 = normalizeLowerRanks(t2); | - | ||||||||||||||||||||||||
| 3420 | - | |||||||||||||||||||||||||
| 3421 | // normalize long / ulong: in all platforms we run, they're either the same as int or as long long | - | ||||||||||||||||||||||||
| 3422 | t1 = normalizeLong(t1); | - | ||||||||||||||||||||||||
| 3423 | t2 = normalizeLong(t2); | - | ||||||||||||||||||||||||
| 3424 | - | |||||||||||||||||||||||||
| 3425 | // implement the other rules | - | ||||||||||||||||||||||||
| 3426 | // the four possibilities are Int, UInt, LongLong and ULongLong | - | ||||||||||||||||||||||||
| 3427 | // if any of the two is ULongLong, then it wins (highest rank, unsigned) | - | ||||||||||||||||||||||||
| 3428 | // otherwise, if one of the two is LongLong, then the other is either LongLong too or lower-ranked | - | ||||||||||||||||||||||||
| 3429 | // otherwise, if one of the two is UInt, then the other is either UInt too or Int | - | ||||||||||||||||||||||||
| 3430 | if (t1 == QVariant::ULongLong || t2 == QVariant::ULongLong)
| 105-161699 | ||||||||||||||||||||||||
| 3431 | return QVariant::ULongLong; executed 306 times by 3 tests: return QVariant::ULongLong;Executed by:
| 306 | ||||||||||||||||||||||||
| 3432 | if (t1 == QVariant::LongLong || t2 == QVariant::LongLong)
| 102-159605 | ||||||||||||||||||||||||
| 3433 | return QVariant::LongLong; executed 2091 times by 14 tests: return QVariant::LongLong;Executed by:
| 2091 | ||||||||||||||||||||||||
| 3434 | if (t1 == QVariant::UInt || t2 == QVariant::UInt)
| 235-159193 | ||||||||||||||||||||||||
| 3435 | return QVariant::UInt; executed 545 times by 10 tests: return QVariant::UInt;Executed by:
| 545 | ||||||||||||||||||||||||
| 3436 | return QVariant::Int; executed 158958 times by 77 tests: return QVariant::Int;Executed by:
| 158958 | ||||||||||||||||||||||||
| 3437 | } | - | ||||||||||||||||||||||||
| 3438 | - | |||||||||||||||||||||||||
| 3439 | static int integralCompare(uint promotedType, const QVariant::Private *d1, const QVariant::Private *d2) | - | ||||||||||||||||||||||||
| 3440 | { | - | ||||||||||||||||||||||||
| 3441 | // use toLongLong to retrieve the data, it gets us all the bits | - | ||||||||||||||||||||||||
| 3442 | bool ok; | - | ||||||||||||||||||||||||
| 3443 | qlonglong l1 = qConvertToNumber(d1, &ok); | - | ||||||||||||||||||||||||
| 3444 | Q_ASSERT(ok); | - | ||||||||||||||||||||||||
| 3445 | - | |||||||||||||||||||||||||
| 3446 | qlonglong l2 = qConvertToNumber(d2, &ok); | - | ||||||||||||||||||||||||
| 3447 | Q_ASSERT(ok); | - | ||||||||||||||||||||||||
| 3448 | - | |||||||||||||||||||||||||
| 3449 | if (promotedType == QVariant::Int)
| 2942-158958 | ||||||||||||||||||||||||
| 3450 | return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1; executed 158958 times by 77 tests: return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1;Executed by:
| 158958 | ||||||||||||||||||||||||
| 3451 | if (promotedType == QVariant::UInt)
| 545-2397 | ||||||||||||||||||||||||
| 3452 | return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1; executed 545 times by 10 tests: return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1;Executed by:
| 545 | ||||||||||||||||||||||||
| 3453 | if (promotedType == QVariant::LongLong)
| 306-2091 | ||||||||||||||||||||||||
| 3454 | return l1 < l2 ? -1 : l1 == l2 ? 0 : 1; executed 2091 times by 14 tests: return l1 < l2 ? -1 : l1 == l2 ? 0 : 1;Executed by:
| 2091 | ||||||||||||||||||||||||
| 3455 | if (promotedType == QVariant::ULongLong)
| 0-306 | ||||||||||||||||||||||||
| 3456 | return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1; executed 306 times by 3 tests: return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1;Executed by:
| 306 | ||||||||||||||||||||||||
| 3457 | - | |||||||||||||||||||||||||
| 3458 | Q_UNREACHABLE(); | - | ||||||||||||||||||||||||
| 3459 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 3460 | } | - | ||||||||||||||||||||||||
| 3461 | - | |||||||||||||||||||||||||
| 3462 | static int numericCompare(const QVariant::Private *d1, const QVariant::Private *d2) | - | ||||||||||||||||||||||||
| 3463 | { | - | ||||||||||||||||||||||||
| 3464 | uint promotedType = numericTypePromotion(d1->type, d2->type); | - | ||||||||||||||||||||||||
| 3465 | if (promotedType != QMetaType::QReal)
| 5713-161900 | ||||||||||||||||||||||||
| 3466 | return integralCompare(promotedType, d1, d2); executed 161900 times by 83 tests: return integralCompare(promotedType, d1, d2);Executed by:
| 161900 | ||||||||||||||||||||||||
| 3467 | - | |||||||||||||||||||||||||
| 3468 | // qreal comparisons | - | ||||||||||||||||||||||||
| 3469 | bool ok; | - | ||||||||||||||||||||||||
| 3470 | qreal r1 = qConvertToRealNumber(d1, &ok); | - | ||||||||||||||||||||||||
| 3471 | Q_ASSERT(ok); | - | ||||||||||||||||||||||||
| 3472 | qreal r2 = qConvertToRealNumber(d2, &ok); | - | ||||||||||||||||||||||||
| 3473 | Q_ASSERT(ok); | - | ||||||||||||||||||||||||
| 3474 | if (r1 == r2 || qFuzzyCompare(r1, r2))
| 10-2995 | ||||||||||||||||||||||||
| 3475 | return 0; executed 3005 times by 32 tests: return 0;Executed by:
| 3005 | ||||||||||||||||||||||||
| 3476 | return r1 < r2 ? -1 : 1; executed 2708 times by 8 tests: return r1 < r2 ? -1 : 1;Executed by:
| 2708 | ||||||||||||||||||||||||
| 3477 | } | - | ||||||||||||||||||||||||
| 3478 | - | |||||||||||||||||||||||||
| 3479 | /*! | - | ||||||||||||||||||||||||
| 3480 | \internal | - | ||||||||||||||||||||||||
| 3481 | */ | - | ||||||||||||||||||||||||
| 3482 | bool QVariant::cmp(const QVariant &v) const | - | ||||||||||||||||||||||||
| 3483 | { | - | ||||||||||||||||||||||||
| 3484 | // try numerics first, with C++ type promotion rules (no conversion) | - | ||||||||||||||||||||||||
| 3485 | if (qIsNumericType(d.type) && qIsNumericType(v.d.type))
| 141-166009 | ||||||||||||||||||||||||
| 3486 | return numericCompare(&d, &v.d) == 0; executed 165868 times by 84 tests: return numericCompare(&d, &v.d) == 0;Executed by:
| 165868 | ||||||||||||||||||||||||
| 3487 | - | |||||||||||||||||||||||||
| 3488 | QVariant v1 = *this; | - | ||||||||||||||||||||||||
| 3489 | QVariant v2 = v; | - | ||||||||||||||||||||||||
| 3490 | if (d.type != v2.d.type) {
| 1595-96638 | ||||||||||||||||||||||||
| 3491 | if (v2.canConvert(v1.d.type)) {
| 129-1466 | ||||||||||||||||||||||||
| 3492 | if (!v2.convert(v1.d.type))
| 53-76 | ||||||||||||||||||||||||
| 3493 | return false; executed 76 times by 6 tests: return false;Executed by:
| 76 | ||||||||||||||||||||||||
| 3494 | } else { executed 53 times by 6 tests: end of blockExecuted by:
| 53 | ||||||||||||||||||||||||
| 3495 | // try the opposite conversion, it might work | - | ||||||||||||||||||||||||
| 3496 | qSwap(v1, v2); | - | ||||||||||||||||||||||||
| 3497 | if (!v2.convert(v1.d.type))
| 5-1461 | ||||||||||||||||||||||||
| 3498 | return false; executed 1461 times by 11 tests: return false;Executed by:
| 1461 | ||||||||||||||||||||||||
| 3499 | } executed 5 times by 2 tests: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 3500 | } | - | ||||||||||||||||||||||||
| 3501 | if (v1.d.type >= QMetaType::User) {
| 366-96330 | ||||||||||||||||||||||||
| 3502 | int result; | - | ||||||||||||||||||||||||
| 3503 | if (QMetaType::equals(QT_PREPEND_NAMESPACE(constData(v1.d)), QT_PREPEND_NAMESPACE(constData(v2.d)), v1.d.type, &result))
| 17-349 | ||||||||||||||||||||||||
| 3504 | return result == 0; executed 17 times by 1 test: return result == 0;Executed by:
| 17 | ||||||||||||||||||||||||
| 3505 | } executed 349 times by 23 tests: end of blockExecuted by:
| 349 | ||||||||||||||||||||||||
| 3506 | return handlerManager[v1.d.type]->compare(&v1.d, &v2.d); executed 96679 times by 91 tests: return handlerManager[v1.d.type]->compare(&v1.d, &v2.d);Executed by:
| 96679 | ||||||||||||||||||||||||
| 3507 | } | - | ||||||||||||||||||||||||
| 3508 | - | |||||||||||||||||||||||||
| 3509 | /*! | - | ||||||||||||||||||||||||
| 3510 | \internal | - | ||||||||||||||||||||||||
| 3511 | */ | - | ||||||||||||||||||||||||
| 3512 | int QVariant::compare(const QVariant &v) const | - | ||||||||||||||||||||||||
| 3513 | { | - | ||||||||||||||||||||||||
| 3514 | // try numerics first, with C++ type promotion rules (no conversion) | - | ||||||||||||||||||||||||
| 3515 | if (qIsNumericType(d.type) && qIsNumericType(v.d.type))
| 9-1754 | ||||||||||||||||||||||||
| 3516 | return numericCompare(&d, &v.d); executed 1745 times by 2 tests: return numericCompare(&d, &v.d);Executed by:
| 1745 | ||||||||||||||||||||||||
| 3517 | - | |||||||||||||||||||||||||
| 3518 | // check for equality next, as more types implement operator== than operator< | - | ||||||||||||||||||||||||
| 3519 | if (cmp(v))
| 37-170 | ||||||||||||||||||||||||
| 3520 | return 0; executed 37 times by 2 tests: return 0;Executed by:
| 37 | ||||||||||||||||||||||||
| 3521 | - | |||||||||||||||||||||||||
| 3522 | QVariant v1 = *this; | - | ||||||||||||||||||||||||
| 3523 | QVariant v2 = v; | - | ||||||||||||||||||||||||
| 3524 | - | |||||||||||||||||||||||||
| 3525 | if (v1.d.type != v2.d.type) {
| 12-158 | ||||||||||||||||||||||||
| 3526 | // if both types differ, try to convert | - | ||||||||||||||||||||||||
| 3527 | if (v2.canConvert(v1.d.type)) {
| 5-7 | ||||||||||||||||||||||||
| 3528 | QVariant temp = v2; | - | ||||||||||||||||||||||||
| 3529 | if (temp.convert(v1.d.type))
| 2-3 | ||||||||||||||||||||||||
| 3530 | v2 = temp; executed 2 times by 1 test: v2 = temp;Executed by:
| 2 | ||||||||||||||||||||||||
| 3531 | } executed 5 times by 2 tests: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 3532 | if (v1.d.type != v2.d.type && v1.canConvert(v2.d.type)) {
| 2-10 | ||||||||||||||||||||||||
| 3533 | QVariant temp = v1; | - | ||||||||||||||||||||||||
| 3534 | if (temp.convert(v2.d.type))
| 0-5 | ||||||||||||||||||||||||
| 3535 | v1 = temp; executed 5 times by 2 tests: v1 = temp;Executed by:
| 5 | ||||||||||||||||||||||||
| 3536 | } executed 5 times by 2 tests: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 3537 | if (v1.d.type != v2.d.type) {
| 5-7 | ||||||||||||||||||||||||
| 3538 | // if conversion fails, default to toString | - | ||||||||||||||||||||||||
| 3539 | int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); | - | ||||||||||||||||||||||||
| 3540 | if (r == 0) {
| 2-3 | ||||||||||||||||||||||||
| 3541 | // cmp(v) returned false, so we should try to agree with it. | - | ||||||||||||||||||||||||
| 3542 | return (v1.d.type < v2.d.type) ? -1 : 1; executed 2 times by 1 test: return (v1.d.type < v2.d.type) ? -1 : 1;Executed by:
| 2 | ||||||||||||||||||||||||
| 3543 | } | - | ||||||||||||||||||||||||
| 3544 | return r; executed 3 times by 2 tests: return r;Executed by:
| 3 | ||||||||||||||||||||||||
| 3545 | } | - | ||||||||||||||||||||||||
| 3546 | - | |||||||||||||||||||||||||
| 3547 | // did we end up with two numerics? If so, restart | - | ||||||||||||||||||||||||
| 3548 | if (qIsNumericType(v1.d.type) && qIsNumericType(v2.d.type))
| 0-6 | ||||||||||||||||||||||||
| 3549 | return v1.compare(v2); executed 1 time by 1 test: return v1.compare(v2);Executed by:
| 1 | ||||||||||||||||||||||||
| 3550 | } executed 6 times by 2 tests: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 3551 | if (v1.d.type >= QMetaType::User) {
| 7-157 | ||||||||||||||||||||||||
| 3552 | int result; | - | ||||||||||||||||||||||||
| 3553 | if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2.d)), d.type, &result))
| 2-5 | ||||||||||||||||||||||||
| 3554 | return result; executed 5 times by 1 test: return result;Executed by:
| 5 | ||||||||||||||||||||||||
| 3555 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 3556 | switch (v1.d.type) { | - | ||||||||||||||||||||||||
| 3557 | case QVariant::Date: executed 16 times by 2 tests: case QVariant::Date:Executed by:
| 16 | ||||||||||||||||||||||||
| 3558 | return v1.toDate() < v2.toDate() ? -1 : 1; executed 16 times by 2 tests: return v1.toDate() < v2.toDate() ? -1 : 1;Executed by:
| 16 | ||||||||||||||||||||||||
| 3559 | case QVariant::Time: executed 15 times by 2 tests: case QVariant::Time:Executed by:
| 15 | ||||||||||||||||||||||||
| 3560 | return v1.toTime() < v2.toTime() ? -1 : 1; executed 15 times by 2 tests: return v1.toTime() < v2.toTime() ? -1 : 1;Executed by:
| 15 | ||||||||||||||||||||||||
| 3561 | case QVariant::DateTime: executed 8 times by 1 test: case QVariant::DateTime:Executed by:
| 8 | ||||||||||||||||||||||||
| 3562 | return v1.toDateTime() < v2.toDateTime() ? -1 : 1; executed 8 times by 1 test: return v1.toDateTime() < v2.toDateTime() ? -1 : 1;Executed by:
| 8 | ||||||||||||||||||||||||
| 3563 | case QVariant::StringList: executed 56 times by 1 test: case QVariant::StringList:Executed by:
| 56 | ||||||||||||||||||||||||
| 3564 | return v1.toStringList() < v2.toStringList() ? -1 : 1; executed 56 times by 1 test: return v1.toStringList() < v2.toStringList() ? -1 : 1;Executed by:
| 56 | ||||||||||||||||||||||||
| 3565 | } | - | ||||||||||||||||||||||||
| 3566 | int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); | - | ||||||||||||||||||||||||
| 3567 | if (r == 0) {
| 2-62 | ||||||||||||||||||||||||
| 3568 | // cmp(v) returned false, so we should try to agree with it. | - | ||||||||||||||||||||||||
| 3569 | return (d.type < v.d.type) ? -1 : 1; executed 2 times by 1 test: return (d.type < v.d.type) ? -1 : 1;Executed by:
| 2 | ||||||||||||||||||||||||
| 3570 | } | - | ||||||||||||||||||||||||
| 3571 | return r; executed 62 times by 2 tests: return r;Executed by:
| 62 | ||||||||||||||||||||||||
| 3572 | } | - | ||||||||||||||||||||||||
| 3573 | - | |||||||||||||||||||||||||
| 3574 | /*! | - | ||||||||||||||||||||||||
| 3575 | \internal | - | ||||||||||||||||||||||||
| 3576 | */ | - | ||||||||||||||||||||||||
| 3577 | - | |||||||||||||||||||||||||
| 3578 | const void *QVariant::constData() const | - | ||||||||||||||||||||||||
| 3579 | { | - | ||||||||||||||||||||||||
| 3580 | return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr); executed 5078917 times by 405 tests: return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr);Executed by:
| 5078917 | ||||||||||||||||||||||||
| 3581 | } | - | ||||||||||||||||||||||||
| 3582 | - | |||||||||||||||||||||||||
| 3583 | /*! | - | ||||||||||||||||||||||||
| 3584 | \fn const void* QVariant::data() const | - | ||||||||||||||||||||||||
| 3585 | - | |||||||||||||||||||||||||
| 3586 | \internal | - | ||||||||||||||||||||||||
| 3587 | */ | - | ||||||||||||||||||||||||
| 3588 | - | |||||||||||||||||||||||||
| 3589 | /*! | - | ||||||||||||||||||||||||
| 3590 | \internal | - | ||||||||||||||||||||||||
| 3591 | */ | - | ||||||||||||||||||||||||
| 3592 | void* QVariant::data() | - | ||||||||||||||||||||||||
| 3593 | { | - | ||||||||||||||||||||||||
| 3594 | detach(); | - | ||||||||||||||||||||||||
| 3595 | return const_cast<void *>(constData()); executed 42073 times by 164 tests: return const_cast<void *>(constData());Executed by:
| 42073 | ||||||||||||||||||||||||
| 3596 | } | - | ||||||||||||||||||||||||
| 3597 | - | |||||||||||||||||||||||||
| 3598 | - | |||||||||||||||||||||||||
| 3599 | /*! | - | ||||||||||||||||||||||||
| 3600 | Returns \c true if this is a null variant, false otherwise. A variant is | - | ||||||||||||||||||||||||
| 3601 | considered null if it contains a default constructed value or a built-in | - | ||||||||||||||||||||||||
| 3602 | type instance that has an isNull method, in which case the result | - | ||||||||||||||||||||||||
| 3603 | would be the same as calling isNull on the wrapped object. | - | ||||||||||||||||||||||||
| 3604 | - | |||||||||||||||||||||||||
| 3605 | \warning The result of the function doesn't affect == operator, which means | - | ||||||||||||||||||||||||
| 3606 | that two values can be equal even if one of them is null and another is not. | - | ||||||||||||||||||||||||
| 3607 | */ | - | ||||||||||||||||||||||||
| 3608 | bool QVariant::isNull() const | - | ||||||||||||||||||||||||
| 3609 | { | - | ||||||||||||||||||||||||
| 3610 | return handlerManager[d.type]->isNull(&d); executed 420507 times by 136 tests: return handlerManager[d.type]->isNull(&d);Executed by:
| 420507 | ||||||||||||||||||||||||
| 3611 | } | - | ||||||||||||||||||||||||
| 3612 | - | |||||||||||||||||||||||||
| 3613 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
| 3614 | QDebug operator<<(QDebug dbg, const QVariant &v) | - | ||||||||||||||||||||||||
| 3615 | { | - | ||||||||||||||||||||||||
| 3616 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||
| 3617 | const uint typeId = v.d.type; | - | ||||||||||||||||||||||||
| 3618 | dbg.nospace() << "QVariant("; | - | ||||||||||||||||||||||||
| 3619 | if (typeId != QMetaType::UnknownType) {
| 2-81 | ||||||||||||||||||||||||
| 3620 | dbg << QMetaType::typeName(typeId) << ", "; | - | ||||||||||||||||||||||||
| 3621 | bool userStream = false; | - | ||||||||||||||||||||||||
| 3622 | bool canConvertToString = false; | - | ||||||||||||||||||||||||
| 3623 | if (typeId >= QMetaType::User) {
| 6-75 | ||||||||||||||||||||||||
| 3624 | userStream = QMetaType::debugStream(dbg, constData(v.d), typeId); | - | ||||||||||||||||||||||||
| 3625 | canConvertToString = v.canConvert<QString>(); | - | ||||||||||||||||||||||||
| 3626 | } executed 6 times by 2 tests: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 3627 | if (!userStream && canConvertToString)
| 1-80 | ||||||||||||||||||||||||
| 3628 | dbg << v.toString(); executed 1 time by 1 test: dbg << v.toString();Executed by:
| 1 | ||||||||||||||||||||||||
| 3629 | else if (!userStream)
| 1-79 | ||||||||||||||||||||||||
| 3630 | handlerManager[typeId]->debugStream(dbg, v); executed 79 times by 5 tests: handlerManager[typeId]->debugStream(dbg, v);Executed by:
| 79 | ||||||||||||||||||||||||
| 3631 | } else { executed 81 times by 5 tests: end of blockExecuted by:
| 81 | ||||||||||||||||||||||||
| 3632 | dbg << "Invalid"; | - | ||||||||||||||||||||||||
| 3633 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 3634 | dbg << ')'; | - | ||||||||||||||||||||||||
| 3635 | return dbg; executed 83 times by 5 tests: return dbg;Executed by:
| 83 | ||||||||||||||||||||||||
| 3636 | } | - | ||||||||||||||||||||||||
| 3637 | - | |||||||||||||||||||||||||
| 3638 | QDebug operator<<(QDebug dbg, const QVariant::Type p) | - | ||||||||||||||||||||||||
| 3639 | { | - | ||||||||||||||||||||||||
| 3640 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||
| 3641 | dbg.nospace() << "QVariant::" | - | ||||||||||||||||||||||||
| 3642 | << (int(p) != int(QMetaType::UnknownType) | - | ||||||||||||||||||||||||
| 3643 | ? QMetaType::typeName(p) | - | ||||||||||||||||||||||||
| 3644 | : "Invalid"); | - | ||||||||||||||||||||||||
| 3645 | return dbg; executed 54 times by 1 test: return dbg;Executed by:
| 54 | ||||||||||||||||||||||||
| 3646 | } | - | ||||||||||||||||||||||||
| 3647 | #endif | - | ||||||||||||||||||||||||
| 3648 | - | |||||||||||||||||||||||||
| 3649 | - | |||||||||||||||||||||||||
| 3650 | /*! \fn void QVariant::setValue(const T &value) | - | ||||||||||||||||||||||||
| 3651 | - | |||||||||||||||||||||||||
| 3652 | Stores a copy of \a value. If \c{T} is a type that QVariant | - | ||||||||||||||||||||||||
| 3653 | doesn't support, QMetaType is used to store the value. A compile | - | ||||||||||||||||||||||||
| 3654 | error will occur if QMetaType doesn't handle the type. | - | ||||||||||||||||||||||||
| 3655 | - | |||||||||||||||||||||||||
| 3656 | Example: | - | ||||||||||||||||||||||||
| 3657 | - | |||||||||||||||||||||||||
| 3658 | \snippet code/src_corelib_kernel_qvariant.cpp 4 | - | ||||||||||||||||||||||||
| 3659 | - | |||||||||||||||||||||||||
| 3660 | \sa value(), fromValue(), canConvert() | - | ||||||||||||||||||||||||
| 3661 | */ | - | ||||||||||||||||||||||||
| 3662 | - | |||||||||||||||||||||||||
| 3663 | /*! \fn T QVariant::value() const | - | ||||||||||||||||||||||||
| 3664 | - | |||||||||||||||||||||||||
| 3665 | Returns the stored value converted to the template type \c{T}. | - | ||||||||||||||||||||||||
| 3666 | Call canConvert() to find out whether a type can be converted. | - | ||||||||||||||||||||||||
| 3667 | If the value cannot be converted, a \l{default-constructed value} | - | ||||||||||||||||||||||||
| 3668 | will be returned. | - | ||||||||||||||||||||||||
| 3669 | - | |||||||||||||||||||||||||
| 3670 | If the type \c{T} is supported by QVariant, this function behaves | - | ||||||||||||||||||||||||
| 3671 | exactly as toString(), toInt() etc. | - | ||||||||||||||||||||||||
| 3672 | - | |||||||||||||||||||||||||
| 3673 | Example: | - | ||||||||||||||||||||||||
| 3674 | - | |||||||||||||||||||||||||
| 3675 | \snippet code/src_corelib_kernel_qvariant.cpp 5 | - | ||||||||||||||||||||||||
| 3676 | - | |||||||||||||||||||||||||
| 3677 | If the QVariant contains a pointer to a type derived from QObject then | - | ||||||||||||||||||||||||
| 3678 | \c{T} may be any QObject type. If the pointer stored in the QVariant can be | - | ||||||||||||||||||||||||
| 3679 | qobject_cast to T, then that result is returned. Otherwise a null pointer is | - | ||||||||||||||||||||||||
| 3680 | returned. Note that this only works for QObject subclasses which use the | - | ||||||||||||||||||||||||
| 3681 | Q_OBJECT macro. | - | ||||||||||||||||||||||||
| 3682 | - | |||||||||||||||||||||||||
| 3683 | If the QVariant contains a sequential container and \c{T} is QVariantList, the | - | ||||||||||||||||||||||||
| 3684 | elements of the container will be converted into \l {QVariant}s and returned as a QVariantList. | - | ||||||||||||||||||||||||
| 3685 | - | |||||||||||||||||||||||||
| 3686 | \snippet code/src_corelib_kernel_qvariant.cpp 9 | - | ||||||||||||||||||||||||
| 3687 | - | |||||||||||||||||||||||||
| 3688 | \sa setValue(), fromValue(), canConvert(), Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE() | - | ||||||||||||||||||||||||
| 3689 | */ | - | ||||||||||||||||||||||||
| 3690 | - | |||||||||||||||||||||||||
| 3691 | /*! \fn bool QVariant::canConvert() const | - | ||||||||||||||||||||||||
| 3692 | - | |||||||||||||||||||||||||
| 3693 | Returns \c true if the variant can be converted to the template type \c{T}, | - | ||||||||||||||||||||||||
| 3694 | otherwise false. | - | ||||||||||||||||||||||||
| 3695 | - | |||||||||||||||||||||||||
| 3696 | Example: | - | ||||||||||||||||||||||||
| 3697 | - | |||||||||||||||||||||||||
| 3698 | \snippet code/src_corelib_kernel_qvariant.cpp 6 | - | ||||||||||||||||||||||||
| 3699 | - | |||||||||||||||||||||||||
| 3700 | A QVariant containing a pointer to a type derived from QObject will also return true for this | - | ||||||||||||||||||||||||
| 3701 | function if a qobject_cast to the template type \c{T} would succeed. Note that this only works | - | ||||||||||||||||||||||||
| 3702 | for QObject subclasses which use the Q_OBJECT macro. | - | ||||||||||||||||||||||||
| 3703 | - | |||||||||||||||||||||||||
| 3704 | \sa convert() | - | ||||||||||||||||||||||||
| 3705 | */ | - | ||||||||||||||||||||||||
| 3706 | - | |||||||||||||||||||||||||
| 3707 | /*! \fn static QVariant QVariant::fromValue(const T &value) | - | ||||||||||||||||||||||||
| 3708 | - | |||||||||||||||||||||||||
| 3709 | Returns a QVariant containing a copy of \a value. Behaves | - | ||||||||||||||||||||||||
| 3710 | exactly like setValue() otherwise. | - | ||||||||||||||||||||||||
| 3711 | - | |||||||||||||||||||||||||
| 3712 | Example: | - | ||||||||||||||||||||||||
| 3713 | - | |||||||||||||||||||||||||
| 3714 | \snippet code/src_corelib_kernel_qvariant.cpp 7 | - | ||||||||||||||||||||||||
| 3715 | - | |||||||||||||||||||||||||
| 3716 | \note If you are working with custom types, you should use | - | ||||||||||||||||||||||||
| 3717 | the Q_DECLARE_METATYPE() macro to register your custom type. | - | ||||||||||||||||||||||||
| 3718 | - | |||||||||||||||||||||||||
| 3719 | \sa setValue(), value() | - | ||||||||||||||||||||||||
| 3720 | */ | - | ||||||||||||||||||||||||
| 3721 | - | |||||||||||||||||||||||||
| 3722 | /*! | - | ||||||||||||||||||||||||
| 3723 | \fn QVariant qVariantFromValue(const T &value) | - | ||||||||||||||||||||||||
| 3724 | \relates QVariant | - | ||||||||||||||||||||||||
| 3725 | \obsolete | - | ||||||||||||||||||||||||
| 3726 | - | |||||||||||||||||||||||||
| 3727 | Returns a variant containing a copy of the given \a value | - | ||||||||||||||||||||||||
| 3728 | with template type \c{T}. | - | ||||||||||||||||||||||||
| 3729 | - | |||||||||||||||||||||||||
| 3730 | This function is equivalent to QVariant::fromValue(\a value). | - | ||||||||||||||||||||||||
| 3731 | - | |||||||||||||||||||||||||
| 3732 | \note This function was provided as a workaround for MSVC 6 | - | ||||||||||||||||||||||||
| 3733 | which did not support member template functions. It is advised | - | ||||||||||||||||||||||||
| 3734 | to use the other form in new code. | - | ||||||||||||||||||||||||
| 3735 | - | |||||||||||||||||||||||||
| 3736 | For example, a QObject pointer can be stored in a variant with the | - | ||||||||||||||||||||||||
| 3737 | following code: | - | ||||||||||||||||||||||||
| 3738 | - | |||||||||||||||||||||||||
| 3739 | \snippet code/src_corelib_kernel_qvariant.cpp 8 | - | ||||||||||||||||||||||||
| 3740 | - | |||||||||||||||||||||||||
| 3741 | \sa QVariant::fromValue() | - | ||||||||||||||||||||||||
| 3742 | */ | - | ||||||||||||||||||||||||
| 3743 | - | |||||||||||||||||||||||||
| 3744 | /*! \fn void qVariantSetValue(QVariant &variant, const T &value) | - | ||||||||||||||||||||||||
| 3745 | \relates QVariant | - | ||||||||||||||||||||||||
| 3746 | \obsolete | - | ||||||||||||||||||||||||
| 3747 | - | |||||||||||||||||||||||||
| 3748 | Sets the contents of the given \a variant to a copy of the | - | ||||||||||||||||||||||||
| 3749 | \a value with the specified template type \c{T}. | - | ||||||||||||||||||||||||
| 3750 | - | |||||||||||||||||||||||||
| 3751 | This function is equivalent to QVariant::setValue(\a value). | - | ||||||||||||||||||||||||
| 3752 | - | |||||||||||||||||||||||||
| 3753 | \note This function was provided as a workaround for MSVC 6 | - | ||||||||||||||||||||||||
| 3754 | which did not support member template functions. It is advised | - | ||||||||||||||||||||||||
| 3755 | to use the other form in new code. | - | ||||||||||||||||||||||||
| 3756 | - | |||||||||||||||||||||||||
| 3757 | \sa QVariant::setValue() | - | ||||||||||||||||||||||||
| 3758 | */ | - | ||||||||||||||||||||||||
| 3759 | - | |||||||||||||||||||||||||
| 3760 | /*! | - | ||||||||||||||||||||||||
| 3761 | \fn T qvariant_cast(const QVariant &value) | - | ||||||||||||||||||||||||
| 3762 | \relates QVariant | - | ||||||||||||||||||||||||
| 3763 | - | |||||||||||||||||||||||||
| 3764 | Returns the given \a value converted to the template type \c{T}. | - | ||||||||||||||||||||||||
| 3765 | - | |||||||||||||||||||||||||
| 3766 | This function is equivalent to QVariant::value(). | - | ||||||||||||||||||||||||
| 3767 | - | |||||||||||||||||||||||||
| 3768 | \sa QVariant::value() | - | ||||||||||||||||||||||||
| 3769 | */ | - | ||||||||||||||||||||||||
| 3770 | - | |||||||||||||||||||||||||
| 3771 | /*! \fn T qVariantValue(const QVariant &value) | - | ||||||||||||||||||||||||
| 3772 | \relates QVariant | - | ||||||||||||||||||||||||
| 3773 | \obsolete | - | ||||||||||||||||||||||||
| 3774 | - | |||||||||||||||||||||||||
| 3775 | Returns the given \a value converted to the template type \c{T}. | - | ||||||||||||||||||||||||
| 3776 | - | |||||||||||||||||||||||||
| 3777 | This function is equivalent to | - | ||||||||||||||||||||||||
| 3778 | \l{QVariant::value()}{QVariant::value}<T>(\a value). | - | ||||||||||||||||||||||||
| 3779 | - | |||||||||||||||||||||||||
| 3780 | \note This function was provided as a workaround for MSVC 6 | - | ||||||||||||||||||||||||
| 3781 | which did not support member template functions. It is advised | - | ||||||||||||||||||||||||
| 3782 | to use the other form in new code. | - | ||||||||||||||||||||||||
| 3783 | - | |||||||||||||||||||||||||
| 3784 | \sa QVariant::value(), qvariant_cast() | - | ||||||||||||||||||||||||
| 3785 | */ | - | ||||||||||||||||||||||||
| 3786 | - | |||||||||||||||||||||||||
| 3787 | /*! \fn bool qVariantCanConvert(const QVariant &value) | - | ||||||||||||||||||||||||
| 3788 | \relates QVariant | - | ||||||||||||||||||||||||
| 3789 | \obsolete | - | ||||||||||||||||||||||||
| 3790 | - | |||||||||||||||||||||||||
| 3791 | Returns \c true if the given \a value can be converted to the | - | ||||||||||||||||||||||||
| 3792 | template type specified; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 3793 | - | |||||||||||||||||||||||||
| 3794 | This function is equivalent to QVariant::canConvert(\a value). | - | ||||||||||||||||||||||||
| 3795 | - | |||||||||||||||||||||||||
| 3796 | \note This function was provided as a workaround for MSVC 6 | - | ||||||||||||||||||||||||
| 3797 | which did not support member template functions. It is advised | - | ||||||||||||||||||||||||
| 3798 | to use the other form in new code. | - | ||||||||||||||||||||||||
| 3799 | - | |||||||||||||||||||||||||
| 3800 | \sa QVariant::canConvert() | - | ||||||||||||||||||||||||
| 3801 | */ | - | ||||||||||||||||||||||||
| 3802 | - | |||||||||||||||||||||||||
| 3803 | /*! | - | ||||||||||||||||||||||||
| 3804 | \typedef QVariantList | - | ||||||||||||||||||||||||
| 3805 | \relates QVariant | - | ||||||||||||||||||||||||
| 3806 | - | |||||||||||||||||||||||||
| 3807 | Synonym for QList<QVariant>. | - | ||||||||||||||||||||||||
| 3808 | */ | - | ||||||||||||||||||||||||
| 3809 | - | |||||||||||||||||||||||||
| 3810 | /*! | - | ||||||||||||||||||||||||
| 3811 | \typedef QVariantMap | - | ||||||||||||||||||||||||
| 3812 | \relates QVariant | - | ||||||||||||||||||||||||
| 3813 | - | |||||||||||||||||||||||||
| 3814 | Synonym for QMap<QString, QVariant>. | - | ||||||||||||||||||||||||
| 3815 | */ | - | ||||||||||||||||||||||||
| 3816 | - | |||||||||||||||||||||||||
| 3817 | /*! | - | ||||||||||||||||||||||||
| 3818 | \typedef QVariantHash | - | ||||||||||||||||||||||||
| 3819 | \relates QVariant | - | ||||||||||||||||||||||||
| 3820 | \since 4.5 | - | ||||||||||||||||||||||||
| 3821 | - | |||||||||||||||||||||||||
| 3822 | Synonym for QHash<QString, QVariant>. | - | ||||||||||||||||||||||||
| 3823 | */ | - | ||||||||||||||||||||||||
| 3824 | - | |||||||||||||||||||||||||
| 3825 | /*! | - | ||||||||||||||||||||||||
| 3826 | \typedef QVariant::DataPtr | - | ||||||||||||||||||||||||
| 3827 | \internal | - | ||||||||||||||||||||||||
| 3828 | */ | - | ||||||||||||||||||||||||
| 3829 | - | |||||||||||||||||||||||||
| 3830 | /*! | - | ||||||||||||||||||||||||
| 3831 | \fn DataPtr &QVariant::data_ptr() | - | ||||||||||||||||||||||||
| 3832 | \internal | - | ||||||||||||||||||||||||
| 3833 | */ | - | ||||||||||||||||||||||||
| 3834 | - | |||||||||||||||||||||||||
| 3835 | /*! | - | ||||||||||||||||||||||||
| 3836 | \fn const DataPtr &QVariant::data_ptr() const | - | ||||||||||||||||||||||||
| 3837 | \internal | - | ||||||||||||||||||||||||
| 3838 | */ | - | ||||||||||||||||||||||||
| 3839 | - | |||||||||||||||||||||||||
| 3840 | /*! | - | ||||||||||||||||||||||||
| 3841 | \class QSequentialIterable | - | ||||||||||||||||||||||||
| 3842 | \since 5.2 | - | ||||||||||||||||||||||||
| 3843 | \inmodule QtCore | - | ||||||||||||||||||||||||
| 3844 | \brief The QSequentialIterable class is an iterable interface for a container in a QVariant. | - | ||||||||||||||||||||||||
| 3845 | - | |||||||||||||||||||||||||
| 3846 | This class allows several methods of accessing the elements of a container held within | - | ||||||||||||||||||||||||
| 3847 | a QVariant. An instance of QSequentialIterable can be extracted from a QVariant if it can | - | ||||||||||||||||||||||||
| 3848 | be converted to a QVariantList. | - | ||||||||||||||||||||||||
| 3849 | - | |||||||||||||||||||||||||
| 3850 | \snippet code/src_corelib_kernel_qvariant.cpp 9 | - | ||||||||||||||||||||||||
| 3851 | - | |||||||||||||||||||||||||
| 3852 | The container itself is not copied before iterating over it. | - | ||||||||||||||||||||||||
| 3853 | - | |||||||||||||||||||||||||
| 3854 | \sa QVariant | - | ||||||||||||||||||||||||
| 3855 | */ | - | ||||||||||||||||||||||||
| 3856 | - | |||||||||||||||||||||||||
| 3857 | /*! | - | ||||||||||||||||||||||||
| 3858 | \internal | - | ||||||||||||||||||||||||
| 3859 | */ | - | ||||||||||||||||||||||||
| 3860 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | - | ||||||||||||||||||||||||
| 3861 | QSequentialIterable::QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl impl) | - | ||||||||||||||||||||||||
| 3862 | #else | - | ||||||||||||||||||||||||
| 3863 | QSequentialIterable::QSequentialIterable(const QtMetaTypePrivate::QSequentialIterableImpl &impl) | - | ||||||||||||||||||||||||
| 3864 | #endif | - | ||||||||||||||||||||||||
| 3865 | : m_impl(impl) | - | ||||||||||||||||||||||||
| 3866 | { | - | ||||||||||||||||||||||||
| 3867 | } executed 50 times by 1 test: end of blockExecuted by:
| 50 | ||||||||||||||||||||||||
| 3868 | - | |||||||||||||||||||||||||
| 3869 | QSequentialIterable::const_iterator::const_iterator(const QSequentialIterable &iter, QAtomicInt *ref_) | - | ||||||||||||||||||||||||
| 3870 | : m_impl(iter.m_impl), ref(ref_) | - | ||||||||||||||||||||||||
| 3871 | { | - | ||||||||||||||||||||||||
| 3872 | ref->ref(); | - | ||||||||||||||||||||||||
| 3873 | } executed 149 times by 1 test: end of blockExecuted by:
| 149 | ||||||||||||||||||||||||
| 3874 | - | |||||||||||||||||||||||||
| 3875 | QSequentialIterable::const_iterator::const_iterator(const QtMetaTypePrivate::QSequentialIterableImpl &impl, QAtomicInt *ref_) | - | ||||||||||||||||||||||||
| 3876 | : m_impl(impl), ref(ref_) | - | ||||||||||||||||||||||||
| 3877 | { | - | ||||||||||||||||||||||||
| 3878 | ref->ref(); | - | ||||||||||||||||||||||||
| 3879 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 3880 | - | |||||||||||||||||||||||||
| 3881 | void QSequentialIterable::const_iterator::begin() | - | ||||||||||||||||||||||||
| 3882 | { | - | ||||||||||||||||||||||||
| 3883 | m_impl.moveToBegin(); | - | ||||||||||||||||||||||||
| 3884 | } executed 75 times by 1 test: end of blockExecuted by:
| 75 | ||||||||||||||||||||||||
| 3885 | - | |||||||||||||||||||||||||
| 3886 | void QSequentialIterable::const_iterator::end() | - | ||||||||||||||||||||||||
| 3887 | { | - | ||||||||||||||||||||||||
| 3888 | m_impl.moveToEnd(); | - | ||||||||||||||||||||||||
| 3889 | } executed 74 times by 1 test: end of blockExecuted by:
| 74 | ||||||||||||||||||||||||
| 3890 | - | |||||||||||||||||||||||||
| 3891 | /*! \fn QSequentialIterable::const_iterator QSequentialIterable::begin() const | - | ||||||||||||||||||||||||
| 3892 | - | |||||||||||||||||||||||||
| 3893 | Returns a QSequentialIterable::const_iterator for the beginning of the container. This | - | ||||||||||||||||||||||||
| 3894 | can be used in stl-style iteration. | - | ||||||||||||||||||||||||
| 3895 | - | |||||||||||||||||||||||||
| 3896 | \sa end() | - | ||||||||||||||||||||||||
| 3897 | */ | - | ||||||||||||||||||||||||
| 3898 | QSequentialIterable::const_iterator QSequentialIterable::begin() const | - | ||||||||||||||||||||||||
| 3899 | { | - | ||||||||||||||||||||||||
| 3900 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
| 3901 | it.begin(); | - | ||||||||||||||||||||||||
| 3902 | return it; executed 75 times by 1 test: return it;Executed by:
| 75 | ||||||||||||||||||||||||
| 3903 | } | - | ||||||||||||||||||||||||
| 3904 | - | |||||||||||||||||||||||||
| 3905 | /*! | - | ||||||||||||||||||||||||
| 3906 | Returns a QSequentialIterable::const_iterator for the end of the container. This | - | ||||||||||||||||||||||||
| 3907 | can be used in stl-style iteration. | - | ||||||||||||||||||||||||
| 3908 | - | |||||||||||||||||||||||||
| 3909 | \sa begin() | - | ||||||||||||||||||||||||
| 3910 | */ | - | ||||||||||||||||||||||||
| 3911 | QSequentialIterable::const_iterator QSequentialIterable::end() const | - | ||||||||||||||||||||||||
| 3912 | { | - | ||||||||||||||||||||||||
| 3913 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
| 3914 | it.end(); | - | ||||||||||||||||||||||||
| 3915 | return it; executed 74 times by 1 test: return it;Executed by:
| 74 | ||||||||||||||||||||||||
| 3916 | } | - | ||||||||||||||||||||||||
| 3917 | - | |||||||||||||||||||||||||
| 3918 | /*! | - | ||||||||||||||||||||||||
| 3919 | Returns the element at position \a idx in the container. | - | ||||||||||||||||||||||||
| 3920 | */ | - | ||||||||||||||||||||||||
| 3921 | QVariant QSequentialIterable::at(int idx) const | - | ||||||||||||||||||||||||
| 3922 | { | - | ||||||||||||||||||||||||
| 3923 | const QtMetaTypePrivate::VariantData d = m_impl.at(idx); | - | ||||||||||||||||||||||||
| 3924 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 42-102 | ||||||||||||||||||||||||
| 3925 | return *reinterpret_cast<const QVariant*>(d.data); executed 42 times by 1 test: return *reinterpret_cast<const QVariant*>(d.data);Executed by:
| 42 | ||||||||||||||||||||||||
| 3926 | return QVariant(d.metaTypeId, d.data, d.flags); executed 102 times by 1 test: return QVariant(d.metaTypeId, d.data, d.flags);Executed by:
| 102 | ||||||||||||||||||||||||
| 3927 | } | - | ||||||||||||||||||||||||
| 3928 | - | |||||||||||||||||||||||||
| 3929 | /*! | - | ||||||||||||||||||||||||
| 3930 | Returns the number of elements in the container. | - | ||||||||||||||||||||||||
| 3931 | */ | - | ||||||||||||||||||||||||
| 3932 | int QSequentialIterable::size() const | - | ||||||||||||||||||||||||
| 3933 | { | - | ||||||||||||||||||||||||
| 3934 | return m_impl.size(); executed 145 times by 1 test: return m_impl.size();Executed by:
| 145 | ||||||||||||||||||||||||
| 3935 | } | - | ||||||||||||||||||||||||
| 3936 | - | |||||||||||||||||||||||||
| 3937 | /*! | - | ||||||||||||||||||||||||
| 3938 | Returns whether it is possible to iterate over the container in reverse. This | - | ||||||||||||||||||||||||
| 3939 | corresponds to the std::bidirectional_iterator_tag iterator trait of the | - | ||||||||||||||||||||||||
| 3940 | const_iterator of the container. | - | ||||||||||||||||||||||||
| 3941 | */ | - | ||||||||||||||||||||||||
| 3942 | bool QSequentialIterable::canReverseIterate() const | - | ||||||||||||||||||||||||
| 3943 | { | - | ||||||||||||||||||||||||
| 3944 | return m_impl._iteratorCapabilities & QtMetaTypePrivate::BiDirectionalCapability; never executed: return m_impl._iteratorCapabilities & QtMetaTypePrivate::BiDirectionalCapability; | 0 | ||||||||||||||||||||||||
| 3945 | } | - | ||||||||||||||||||||||||
| 3946 | - | |||||||||||||||||||||||||
| 3947 | /*! | - | ||||||||||||||||||||||||
| 3948 | \class QSequentialIterable::const_iterator | - | ||||||||||||||||||||||||
| 3949 | \since 5.2 | - | ||||||||||||||||||||||||
| 3950 | \inmodule QtCore | - | ||||||||||||||||||||||||
| 3951 | \brief The QSequentialIterable::const_iterator allows iteration over a container in a QVariant. | - | ||||||||||||||||||||||||
| 3952 | - | |||||||||||||||||||||||||
| 3953 | A QSequentialIterable::const_iterator can only be created by a QSequentialIterable instance, | - | ||||||||||||||||||||||||
| 3954 | and can be used in a way similar to other stl-style iterators. | - | ||||||||||||||||||||||||
| 3955 | - | |||||||||||||||||||||||||
| 3956 | \snippet code/src_corelib_kernel_qvariant.cpp 9 | - | ||||||||||||||||||||||||
| 3957 | - | |||||||||||||||||||||||||
| 3958 | \sa QSequentialIterable | - | ||||||||||||||||||||||||
| 3959 | */ | - | ||||||||||||||||||||||||
| 3960 | - | |||||||||||||||||||||||||
| 3961 | - | |||||||||||||||||||||||||
| 3962 | /*! | - | ||||||||||||||||||||||||
| 3963 | Destroys the QSequentialIterable::const_iterator. | - | ||||||||||||||||||||||||
| 3964 | */ | - | ||||||||||||||||||||||||
| 3965 | QSequentialIterable::const_iterator::~const_iterator() { | - | ||||||||||||||||||||||||
| 3966 | if (!ref->deref()) {
| 1-152 | ||||||||||||||||||||||||
| 3967 | m_impl.destroyIter(); | - | ||||||||||||||||||||||||
| 3968 | delete ref; | - | ||||||||||||||||||||||||
| 3969 | } executed 152 times by 1 test: end of blockExecuted by:
| 152 | ||||||||||||||||||||||||
| 3970 | } executed 153 times by 1 test: end of blockExecuted by:
| 153 | ||||||||||||||||||||||||
| 3971 | - | |||||||||||||||||||||||||
| 3972 | /*! | - | ||||||||||||||||||||||||
| 3973 | Creates a copy of \a other. | - | ||||||||||||||||||||||||
| 3974 | */ | - | ||||||||||||||||||||||||
| 3975 | QSequentialIterable::const_iterator::const_iterator(const const_iterator &other) | - | ||||||||||||||||||||||||
| 3976 | : m_impl(other.m_impl), ref(other.ref) | - | ||||||||||||||||||||||||
| 3977 | { | - | ||||||||||||||||||||||||
| 3978 | ref->ref(); | - | ||||||||||||||||||||||||
| 3979 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3980 | - | |||||||||||||||||||||||||
| 3981 | /*! | - | ||||||||||||||||||||||||
| 3982 | Assigns \a other to this. | - | ||||||||||||||||||||||||
| 3983 | */ | - | ||||||||||||||||||||||||
| 3984 | QSequentialIterable::const_iterator& | - | ||||||||||||||||||||||||
| 3985 | QSequentialIterable::const_iterator::operator=(const const_iterator &other) | - | ||||||||||||||||||||||||
| 3986 | { | - | ||||||||||||||||||||||||
| 3987 | other.ref->ref(); | - | ||||||||||||||||||||||||
| 3988 | if (!ref->deref()) {
| 0-1 | ||||||||||||||||||||||||
| 3989 | m_impl.destroyIter(); | - | ||||||||||||||||||||||||
| 3990 | delete ref; | - | ||||||||||||||||||||||||
| 3991 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 3992 | m_impl = other.m_impl; | - | ||||||||||||||||||||||||
| 3993 | ref = other.ref; | - | ||||||||||||||||||||||||
| 3994 | return *this; executed 1 time by 1 test: return *this;Executed by:
| 1 | ||||||||||||||||||||||||
| 3995 | } | - | ||||||||||||||||||||||||
| 3996 | - | |||||||||||||||||||||||||
| 3997 | /*! | - | ||||||||||||||||||||||||
| 3998 | Returns the current item, converted to a QVariant. | - | ||||||||||||||||||||||||
| 3999 | */ | - | ||||||||||||||||||||||||
| 4000 | const QVariant QSequentialIterable::const_iterator::operator*() const | - | ||||||||||||||||||||||||
| 4001 | { | - | ||||||||||||||||||||||||
| 4002 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrent(); | - | ||||||||||||||||||||||||
| 4003 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 67-155 | ||||||||||||||||||||||||
| 4004 | return *reinterpret_cast<const QVariant*>(d.data); executed 67 times by 1 test: return *reinterpret_cast<const QVariant*>(d.data);Executed by:
| 67 | ||||||||||||||||||||||||
| 4005 | return QVariant(d.metaTypeId, d.data, d.flags); executed 155 times by 1 test: return QVariant(d.metaTypeId, d.data, d.flags);Executed by:
| 155 | ||||||||||||||||||||||||
| 4006 | } | - | ||||||||||||||||||||||||
| 4007 | - | |||||||||||||||||||||||||
| 4008 | /*! | - | ||||||||||||||||||||||||
| 4009 | Returns \c true if \a other points to the same item as this | - | ||||||||||||||||||||||||
| 4010 | iterator; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 4011 | - | |||||||||||||||||||||||||
| 4012 | \sa operator!=() | - | ||||||||||||||||||||||||
| 4013 | */ | - | ||||||||||||||||||||||||
| 4014 | bool QSequentialIterable::const_iterator::operator==(const const_iterator &other) const | - | ||||||||||||||||||||||||
| 4015 | { | - | ||||||||||||||||||||||||
| 4016 | return m_impl.equal(other.m_impl); never executed: return m_impl.equal(other.m_impl); | 0 | ||||||||||||||||||||||||
| 4017 | } | - | ||||||||||||||||||||||||
| 4018 | - | |||||||||||||||||||||||||
| 4019 | /*! | - | ||||||||||||||||||||||||
| 4020 | Returns \c true if \a other points to a different item than this | - | ||||||||||||||||||||||||
| 4021 | iterator; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 4022 | - | |||||||||||||||||||||||||
| 4023 | \sa operator==() | - | ||||||||||||||||||||||||
| 4024 | */ | - | ||||||||||||||||||||||||
| 4025 | bool QSequentialIterable::const_iterator::operator!=(const const_iterator &other) const | - | ||||||||||||||||||||||||
| 4026 | { | - | ||||||||||||||||||||||||
| 4027 | return !m_impl.equal(other.m_impl); executed 292 times by 1 test: return !m_impl.equal(other.m_impl);Executed by:
| 292 | ||||||||||||||||||||||||
| 4028 | } | - | ||||||||||||||||||||||||
| 4029 | - | |||||||||||||||||||||||||
| 4030 | /*! | - | ||||||||||||||||||||||||
| 4031 | The prefix ++ operator (\c{++it}) advances the iterator to the | - | ||||||||||||||||||||||||
| 4032 | next item in the container and returns an iterator to the new current | - | ||||||||||||||||||||||||
| 4033 | item. | - | ||||||||||||||||||||||||
| 4034 | - | |||||||||||||||||||||||||
| 4035 | Calling this function on QSequentialIterable::end() leads to undefined results. | - | ||||||||||||||||||||||||
| 4036 | - | |||||||||||||||||||||||||
| 4037 | \sa operator--() | - | ||||||||||||||||||||||||
| 4038 | */ | - | ||||||||||||||||||||||||
| 4039 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator++() | - | ||||||||||||||||||||||||
| 4040 | { | - | ||||||||||||||||||||||||
| 4041 | m_impl.advance(1); | - | ||||||||||||||||||||||||
| 4042 | return *this; executed 218 times by 1 test: return *this;Executed by:
| 218 | ||||||||||||||||||||||||
| 4043 | } | - | ||||||||||||||||||||||||
| 4044 | - | |||||||||||||||||||||||||
| 4045 | /*! | - | ||||||||||||||||||||||||
| 4046 | \overload | - | ||||||||||||||||||||||||
| 4047 | - | |||||||||||||||||||||||||
| 4048 | The postfix ++ operator (\c{it++}) advances the iterator to the | - | ||||||||||||||||||||||||
| 4049 | next item in the container and returns an iterator to the previously | - | ||||||||||||||||||||||||
| 4050 | current item. | - | ||||||||||||||||||||||||
| 4051 | */ | - | ||||||||||||||||||||||||
| 4052 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator++(int) | - | ||||||||||||||||||||||||
| 4053 | { | - | ||||||||||||||||||||||||
| 4054 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||||||||||||||
| 4055 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
| 4056 | m_impl.advance(1); | - | ||||||||||||||||||||||||
| 4057 | return const_iterator(impl, new QAtomicInt(0)); executed 3 times by 1 test: return const_iterator(impl, new QAtomicInt(0));Executed by:
| 3 | ||||||||||||||||||||||||
| 4058 | } | - | ||||||||||||||||||||||||
| 4059 | - | |||||||||||||||||||||||||
| 4060 | /*! | - | ||||||||||||||||||||||||
| 4061 | The prefix -- operator (\c{--it}) makes the preceding item | - | ||||||||||||||||||||||||
| 4062 | current and returns an iterator to the new current item. | - | ||||||||||||||||||||||||
| 4063 | - | |||||||||||||||||||||||||
| 4064 | Calling this function on QSequentialIterable::begin() leads to undefined results. | - | ||||||||||||||||||||||||
| 4065 | - | |||||||||||||||||||||||||
| 4066 | If the container in the QVariant does not support bi-directional iteration, calling this function | - | ||||||||||||||||||||||||
| 4067 | leads to undefined results. | - | ||||||||||||||||||||||||
| 4068 | - | |||||||||||||||||||||||||
| 4069 | \sa operator++(), canReverseIterate() | - | ||||||||||||||||||||||||
| 4070 | */ | - | ||||||||||||||||||||||||
| 4071 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator--() | - | ||||||||||||||||||||||||
| 4072 | { | - | ||||||||||||||||||||||||
| 4073 | m_impl.advance(-1); | - | ||||||||||||||||||||||||
| 4074 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 4075 | } | - | ||||||||||||||||||||||||
| 4076 | - | |||||||||||||||||||||||||
| 4077 | /*! | - | ||||||||||||||||||||||||
| 4078 | \overload | - | ||||||||||||||||||||||||
| 4079 | - | |||||||||||||||||||||||||
| 4080 | The postfix -- operator (\c{it--}) makes the preceding item | - | ||||||||||||||||||||||||
| 4081 | current and returns an iterator to the previously current item. | - | ||||||||||||||||||||||||
| 4082 | - | |||||||||||||||||||||||||
| 4083 | If the container in the QVariant does not support bi-directional iteration, calling this function | - | ||||||||||||||||||||||||
| 4084 | leads to undefined results. | - | ||||||||||||||||||||||||
| 4085 | - | |||||||||||||||||||||||||
| 4086 | \sa canReverseIterate() | - | ||||||||||||||||||||||||
| 4087 | */ | - | ||||||||||||||||||||||||
| 4088 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator--(int) | - | ||||||||||||||||||||||||
| 4089 | { | - | ||||||||||||||||||||||||
| 4090 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||||||||||||||
| 4091 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
| 4092 | m_impl.advance(-1); | - | ||||||||||||||||||||||||
| 4093 | return const_iterator(impl, new QAtomicInt(0)); never executed: return const_iterator(impl, new QAtomicInt(0)); | 0 | ||||||||||||||||||||||||
| 4094 | } | - | ||||||||||||||||||||||||
| 4095 | - | |||||||||||||||||||||||||
| 4096 | /*! | - | ||||||||||||||||||||||||
| 4097 | Advances the iterator by \a j items. | - | ||||||||||||||||||||||||
| 4098 | - | |||||||||||||||||||||||||
| 4099 | \sa operator-=(), operator+() | - | ||||||||||||||||||||||||
| 4100 | */ | - | ||||||||||||||||||||||||
| 4101 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator+=(int j) | - | ||||||||||||||||||||||||
| 4102 | { | - | ||||||||||||||||||||||||
| 4103 | m_impl.advance(j); | - | ||||||||||||||||||||||||
| 4104 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 4105 | } | - | ||||||||||||||||||||||||
| 4106 | - | |||||||||||||||||||||||||
| 4107 | /*! | - | ||||||||||||||||||||||||
| 4108 | Makes the iterator go back by \a j items. | - | ||||||||||||||||||||||||
| 4109 | - | |||||||||||||||||||||||||
| 4110 | If the container in the QVariant does not support bi-directional iteration, calling this function | - | ||||||||||||||||||||||||
| 4111 | leads to undefined results. | - | ||||||||||||||||||||||||
| 4112 | - | |||||||||||||||||||||||||
| 4113 | \sa operator+=(), operator-(), canReverseIterate() | - | ||||||||||||||||||||||||
| 4114 | */ | - | ||||||||||||||||||||||||
| 4115 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator-=(int j) | - | ||||||||||||||||||||||||
| 4116 | { | - | ||||||||||||||||||||||||
| 4117 | m_impl.advance(-j); | - | ||||||||||||||||||||||||
| 4118 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 4119 | } | - | ||||||||||||||||||||||||
| 4120 | - | |||||||||||||||||||||||||
| 4121 | /*! | - | ||||||||||||||||||||||||
| 4122 | Returns an iterator to the item at \a j positions forward from | - | ||||||||||||||||||||||||
| 4123 | this iterator. | - | ||||||||||||||||||||||||
| 4124 | - | |||||||||||||||||||||||||
| 4125 | \sa operator-(), operator+=() | - | ||||||||||||||||||||||||
| 4126 | */ | - | ||||||||||||||||||||||||
| 4127 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator+(int j) const | - | ||||||||||||||||||||||||
| 4128 | { | - | ||||||||||||||||||||||||
| 4129 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||||||||||||||
| 4130 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
| 4131 | impl.advance(j); | - | ||||||||||||||||||||||||
| 4132 | return const_iterator(impl, new QAtomicInt(0)); executed 1 time by 1 test: return const_iterator(impl, new QAtomicInt(0));Executed by:
| 1 | ||||||||||||||||||||||||
| 4133 | } | - | ||||||||||||||||||||||||
| 4134 | - | |||||||||||||||||||||||||
| 4135 | /*! | - | ||||||||||||||||||||||||
| 4136 | Returns an iterator to the item at \a j positions backward from | - | ||||||||||||||||||||||||
| 4137 | this iterator. | - | ||||||||||||||||||||||||
| 4138 | - | |||||||||||||||||||||||||
| 4139 | If the container in the QVariant does not support bi-directional iteration, calling this function | - | ||||||||||||||||||||||||
| 4140 | leads to undefined results. | - | ||||||||||||||||||||||||
| 4141 | - | |||||||||||||||||||||||||
| 4142 | \sa operator+(), operator-=(), canReverseIterate() | - | ||||||||||||||||||||||||
| 4143 | */ | - | ||||||||||||||||||||||||
| 4144 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator-(int j) const | - | ||||||||||||||||||||||||
| 4145 | { | - | ||||||||||||||||||||||||
| 4146 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||||||||||||||
| 4147 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
| 4148 | impl.advance(-j); | - | ||||||||||||||||||||||||
| 4149 | return const_iterator(impl, new QAtomicInt(0)); never executed: return const_iterator(impl, new QAtomicInt(0)); | 0 | ||||||||||||||||||||||||
| 4150 | } | - | ||||||||||||||||||||||||
| 4151 | - | |||||||||||||||||||||||||
| 4152 | /*! | - | ||||||||||||||||||||||||
| 4153 | \class QAssociativeIterable | - | ||||||||||||||||||||||||
| 4154 | \since 5.2 | - | ||||||||||||||||||||||||
| 4155 | \inmodule QtCore | - | ||||||||||||||||||||||||
| 4156 | \brief The QAssociativeIterable class is an iterable interface for an associative container in a QVariant. | - | ||||||||||||||||||||||||
| 4157 | - | |||||||||||||||||||||||||
| 4158 | This class allows several methods of accessing the elements of an associative container held within | - | ||||||||||||||||||||||||
| 4159 | a QVariant. An instance of QAssociativeIterable can be extracted from a QVariant if it can | - | ||||||||||||||||||||||||
| 4160 | be converted to a QVariantHash or QVariantMap. | - | ||||||||||||||||||||||||
| 4161 | - | |||||||||||||||||||||||||
| 4162 | \snippet code/src_corelib_kernel_qvariant.cpp 10 | - | ||||||||||||||||||||||||
| 4163 | - | |||||||||||||||||||||||||
| 4164 | The container itself is not copied before iterating over it. | - | ||||||||||||||||||||||||
| 4165 | - | |||||||||||||||||||||||||
| 4166 | \sa QVariant | - | ||||||||||||||||||||||||
| 4167 | */ | - | ||||||||||||||||||||||||
| 4168 | - | |||||||||||||||||||||||||
| 4169 | /*! | - | ||||||||||||||||||||||||
| 4170 | \internal | - | ||||||||||||||||||||||||
| 4171 | */ | - | ||||||||||||||||||||||||
| 4172 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | - | ||||||||||||||||||||||||
| 4173 | QAssociativeIterable::QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl impl) | - | ||||||||||||||||||||||||
| 4174 | #else | - | ||||||||||||||||||||||||
| 4175 | QAssociativeIterable::QAssociativeIterable(const QtMetaTypePrivate::QAssociativeIterableImpl &impl) | - | ||||||||||||||||||||||||
| 4176 | #endif | - | ||||||||||||||||||||||||
| 4177 | : m_impl(impl) | - | ||||||||||||||||||||||||
| 4178 | { | - | ||||||||||||||||||||||||
| 4179 | } executed 23 times by 1 test: end of blockExecuted by:
| 23 | ||||||||||||||||||||||||
| 4180 | - | |||||||||||||||||||||||||
| 4181 | QAssociativeIterable::const_iterator::const_iterator(const QAssociativeIterable &iter, QAtomicInt *ref_) | - | ||||||||||||||||||||||||
| 4182 | : m_impl(iter.m_impl), ref(ref_) | - | ||||||||||||||||||||||||
| 4183 | { | - | ||||||||||||||||||||||||
| 4184 | ref->ref(); | - | ||||||||||||||||||||||||
| 4185 | } executed 71 times by 1 test: end of blockExecuted by:
| 71 | ||||||||||||||||||||||||
| 4186 | - | |||||||||||||||||||||||||
| 4187 | QAssociativeIterable::const_iterator::const_iterator(const QtMetaTypePrivate::QAssociativeIterableImpl &impl, QAtomicInt *ref_) | - | ||||||||||||||||||||||||
| 4188 | : m_impl(impl), ref(ref_) | - | ||||||||||||||||||||||||
| 4189 | { | - | ||||||||||||||||||||||||
| 4190 | ref->ref(); | - | ||||||||||||||||||||||||
| 4191 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 4192 | - | |||||||||||||||||||||||||
| 4193 | void QAssociativeIterable::const_iterator::begin() | - | ||||||||||||||||||||||||
| 4194 | { | - | ||||||||||||||||||||||||
| 4195 | m_impl.begin(); | - | ||||||||||||||||||||||||
| 4196 | } executed 21 times by 1 test: end of blockExecuted by:
| 21 | ||||||||||||||||||||||||
| 4197 | - | |||||||||||||||||||||||||
| 4198 | void QAssociativeIterable::const_iterator::end() | - | ||||||||||||||||||||||||
| 4199 | { | - | ||||||||||||||||||||||||
| 4200 | m_impl.end(); | - | ||||||||||||||||||||||||
| 4201 | } executed 35 times by 1 test: end of blockExecuted by:
| 35 | ||||||||||||||||||||||||
| 4202 | - | |||||||||||||||||||||||||
| 4203 | void QAssociativeIterable::const_iterator::find(const QVariant &key) | - | ||||||||||||||||||||||||
| 4204 | { | - | ||||||||||||||||||||||||
| 4205 | Q_ASSERT(key.userType() == m_impl._metaType_id_key); | - | ||||||||||||||||||||||||
| 4206 | const QtMetaTypePrivate::VariantData dkey(key.userType(), key.constData(), 0 /*key.flags()*/); | - | ||||||||||||||||||||||||
| 4207 | m_impl.find(dkey); | - | ||||||||||||||||||||||||
| 4208 | } executed 15 times by 1 test: end of blockExecuted by:
| 15 | ||||||||||||||||||||||||
| 4209 | - | |||||||||||||||||||||||||
| 4210 | /*! | - | ||||||||||||||||||||||||
| 4211 | Returns a QAssociativeIterable::const_iterator for the beginning of the container. This | - | ||||||||||||||||||||||||
| 4212 | can be used in stl-style iteration. | - | ||||||||||||||||||||||||
| 4213 | - | |||||||||||||||||||||||||
| 4214 | \sa end() | - | ||||||||||||||||||||||||
| 4215 | */ | - | ||||||||||||||||||||||||
| 4216 | QAssociativeIterable::const_iterator QAssociativeIterable::begin() const | - | ||||||||||||||||||||||||
| 4217 | { | - | ||||||||||||||||||||||||
| 4218 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
| 4219 | it.begin(); | - | ||||||||||||||||||||||||
| 4220 | return it; executed 21 times by 1 test: return it;Executed by:
| 21 | ||||||||||||||||||||||||
| 4221 | } | - | ||||||||||||||||||||||||
| 4222 | - | |||||||||||||||||||||||||
| 4223 | /*! | - | ||||||||||||||||||||||||
| 4224 | Returns a QAssociativeIterable::const_iterator for the end of the container. This | - | ||||||||||||||||||||||||
| 4225 | can be used in stl-style iteration. | - | ||||||||||||||||||||||||
| 4226 | - | |||||||||||||||||||||||||
| 4227 | \sa begin() | - | ||||||||||||||||||||||||
| 4228 | */ | - | ||||||||||||||||||||||||
| 4229 | QAssociativeIterable::const_iterator QAssociativeIterable::end() const | - | ||||||||||||||||||||||||
| 4230 | { | - | ||||||||||||||||||||||||
| 4231 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
| 4232 | it.end(); | - | ||||||||||||||||||||||||
| 4233 | return it; executed 35 times by 1 test: return it;Executed by:
| 35 | ||||||||||||||||||||||||
| 4234 | } | - | ||||||||||||||||||||||||
| 4235 | - | |||||||||||||||||||||||||
| 4236 | /*! | - | ||||||||||||||||||||||||
| 4237 | \since 5.5 | - | ||||||||||||||||||||||||
| 4238 | - | |||||||||||||||||||||||||
| 4239 | Returns a QAssociativeIterable::const_iterator for the given key \a key | - | ||||||||||||||||||||||||
| 4240 | in the container, if the types are convertible. | - | ||||||||||||||||||||||||
| 4241 | - | |||||||||||||||||||||||||
| 4242 | If the key is not found, returns end(). | - | ||||||||||||||||||||||||
| 4243 | - | |||||||||||||||||||||||||
| 4244 | This can be used in stl-style iteration. | - | ||||||||||||||||||||||||
| 4245 | - | |||||||||||||||||||||||||
| 4246 | \sa begin(), end(), value() | - | ||||||||||||||||||||||||
| 4247 | */ | - | ||||||||||||||||||||||||
| 4248 | QAssociativeIterable::const_iterator QAssociativeIterable::find(const QVariant &key) const | - | ||||||||||||||||||||||||
| 4249 | { | - | ||||||||||||||||||||||||
| 4250 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
| 4251 | QVariant key_ = key; | - | ||||||||||||||||||||||||
| 4252 | if (key_.canConvert(m_impl._metaType_id_key) && key_.convert(m_impl._metaType_id_key))
| 0-15 | ||||||||||||||||||||||||
| 4253 | it.find(key_); executed 15 times by 1 test: it.find(key_);Executed by:
| 15 | ||||||||||||||||||||||||
| 4254 | else | - | ||||||||||||||||||||||||
| 4255 | it.end(); never executed: it.end(); | 0 | ||||||||||||||||||||||||
| 4256 | return it; executed 15 times by 1 test: return it;Executed by:
| 15 | ||||||||||||||||||||||||
| 4257 | } | - | ||||||||||||||||||||||||
| 4258 | - | |||||||||||||||||||||||||
| 4259 | /*! | - | ||||||||||||||||||||||||
| 4260 | Returns the value for the given \a key in the container, if the types are convertible. | - | ||||||||||||||||||||||||
| 4261 | - | |||||||||||||||||||||||||
| 4262 | \sa find() | - | ||||||||||||||||||||||||
| 4263 | */ | - | ||||||||||||||||||||||||
| 4264 | QVariant QAssociativeIterable::value(const QVariant &key) const | - | ||||||||||||||||||||||||
| 4265 | { | - | ||||||||||||||||||||||||
| 4266 | const const_iterator it = find(key); | - | ||||||||||||||||||||||||
| 4267 | if (it == end())
| 0-6 | ||||||||||||||||||||||||
| 4268 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
| 4269 | return *it; executed 6 times by 1 test: return *it;Executed by:
| 6 | ||||||||||||||||||||||||
| 4270 | } | - | ||||||||||||||||||||||||
| 4271 | - | |||||||||||||||||||||||||
| 4272 | /*! | - | ||||||||||||||||||||||||
| 4273 | Returns the number of elements in the container. | - | ||||||||||||||||||||||||
| 4274 | */ | - | ||||||||||||||||||||||||
| 4275 | int QAssociativeIterable::size() const | - | ||||||||||||||||||||||||
| 4276 | { | - | ||||||||||||||||||||||||
| 4277 | return m_impl.size(); executed 6 times by 1 test: return m_impl.size();Executed by:
| 6 | ||||||||||||||||||||||||
| 4278 | } | - | ||||||||||||||||||||||||
| 4279 | - | |||||||||||||||||||||||||
| 4280 | /*! | - | ||||||||||||||||||||||||
| 4281 | \class QAssociativeIterable::const_iterator | - | ||||||||||||||||||||||||
| 4282 | \since 5.2 | - | ||||||||||||||||||||||||
| 4283 | \inmodule QtCore | - | ||||||||||||||||||||||||
| 4284 | \brief The QAssociativeIterable::const_iterator allows iteration over a container in a QVariant. | - | ||||||||||||||||||||||||
| 4285 | - | |||||||||||||||||||||||||
| 4286 | A QAssociativeIterable::const_iterator can only be created by a QAssociativeIterable instance, | - | ||||||||||||||||||||||||
| 4287 | and can be used in a way similar to other stl-style iterators. | - | ||||||||||||||||||||||||
| 4288 | - | |||||||||||||||||||||||||
| 4289 | \snippet code/src_corelib_kernel_qvariant.cpp 10 | - | ||||||||||||||||||||||||
| 4290 | - | |||||||||||||||||||||||||
| 4291 | \sa QAssociativeIterable | - | ||||||||||||||||||||||||
| 4292 | */ | - | ||||||||||||||||||||||||
| 4293 | - | |||||||||||||||||||||||||
| 4294 | - | |||||||||||||||||||||||||
| 4295 | /*! | - | ||||||||||||||||||||||||
| 4296 | Destroys the QAssociativeIterable::const_iterator. | - | ||||||||||||||||||||||||
| 4297 | */ | - | ||||||||||||||||||||||||
| 4298 | QAssociativeIterable::const_iterator::~const_iterator() | - | ||||||||||||||||||||||||
| 4299 | { | - | ||||||||||||||||||||||||
| 4300 | if (!ref->deref()) {
| 1-74 | ||||||||||||||||||||||||
| 4301 | m_impl.destroyIter(); | - | ||||||||||||||||||||||||
| 4302 | delete ref; | - | ||||||||||||||||||||||||
| 4303 | } executed 74 times by 1 test: end of blockExecuted by:
| 74 | ||||||||||||||||||||||||
| 4304 | } executed 75 times by 1 test: end of blockExecuted by:
| 75 | ||||||||||||||||||||||||
| 4305 | - | |||||||||||||||||||||||||
| 4306 | /*! | - | ||||||||||||||||||||||||
| 4307 | Creates a copy of \a other. | - | ||||||||||||||||||||||||
| 4308 | */ | - | ||||||||||||||||||||||||
| 4309 | QAssociativeIterable::const_iterator::const_iterator(const const_iterator &other) | - | ||||||||||||||||||||||||
| 4310 | : m_impl(other.m_impl), ref(other.ref) | - | ||||||||||||||||||||||||
| 4311 | { | - | ||||||||||||||||||||||||
| 4312 | ref->ref(); | - | ||||||||||||||||||||||||
| 4313 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4314 | - | |||||||||||||||||||||||||
| 4315 | /*! | - | ||||||||||||||||||||||||
| 4316 | Assigns \a other to this. | - | ||||||||||||||||||||||||
| 4317 | */ | - | ||||||||||||||||||||||||
| 4318 | QAssociativeIterable::const_iterator& | - | ||||||||||||||||||||||||
| 4319 | QAssociativeIterable::const_iterator::operator=(const const_iterator &other) | - | ||||||||||||||||||||||||
| 4320 | { | - | ||||||||||||||||||||||||
| 4321 | other.ref->ref(); | - | ||||||||||||||||||||||||
| 4322 | if (!ref->deref()) {
| 0-1 | ||||||||||||||||||||||||
| 4323 | m_impl.destroyIter(); | - | ||||||||||||||||||||||||
| 4324 | delete ref; | - | ||||||||||||||||||||||||
| 4325 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 4326 | m_impl = other.m_impl; | - | ||||||||||||||||||||||||
| 4327 | ref = other.ref; | - | ||||||||||||||||||||||||
| 4328 | return *this; executed 1 time by 1 test: return *this;Executed by:
| 1 | ||||||||||||||||||||||||
| 4329 | } | - | ||||||||||||||||||||||||
| 4330 | - | |||||||||||||||||||||||||
| 4331 | /*! | - | ||||||||||||||||||||||||
| 4332 | Returns the current value, converted to a QVariant. | - | ||||||||||||||||||||||||
| 4333 | */ | - | ||||||||||||||||||||||||
| 4334 | const QVariant QAssociativeIterable::const_iterator::operator*() const | - | ||||||||||||||||||||||||
| 4335 | { | - | ||||||||||||||||||||||||
| 4336 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue(); | - | ||||||||||||||||||||||||
| 4337 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||||||||||||||
| 4338 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 0-13 | ||||||||||||||||||||||||
| 4339 | return *reinterpret_cast<const QVariant*>(d.data); never executed: return *reinterpret_cast<const QVariant*>(d.data); | 0 | ||||||||||||||||||||||||
| 4340 | return v; executed 13 times by 1 test: return v;Executed by:
| 13 | ||||||||||||||||||||||||
| 4341 | } | - | ||||||||||||||||||||||||
| 4342 | - | |||||||||||||||||||||||||
| 4343 | /*! | - | ||||||||||||||||||||||||
| 4344 | Returns the current key, converted to a QVariant. | - | ||||||||||||||||||||||||
| 4345 | */ | - | ||||||||||||||||||||||||
| 4346 | const QVariant QAssociativeIterable::const_iterator::key() const | - | ||||||||||||||||||||||||
| 4347 | { | - | ||||||||||||||||||||||||
| 4348 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentKey(); | - | ||||||||||||||||||||||||
| 4349 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||||||||||||||
| 4350 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 0-31 | ||||||||||||||||||||||||
| 4351 | return *reinterpret_cast<const QVariant*>(d.data); never executed: return *reinterpret_cast<const QVariant*>(d.data); | 0 | ||||||||||||||||||||||||
| 4352 | return v; executed 31 times by 1 test: return v;Executed by:
| 31 | ||||||||||||||||||||||||
| 4353 | } | - | ||||||||||||||||||||||||
| 4354 | - | |||||||||||||||||||||||||
| 4355 | /*! | - | ||||||||||||||||||||||||
| 4356 | Returns the current value, converted to a QVariant. | - | ||||||||||||||||||||||||
| 4357 | */ | - | ||||||||||||||||||||||||
| 4358 | const QVariant QAssociativeIterable::const_iterator::value() const | - | ||||||||||||||||||||||||
| 4359 | { | - | ||||||||||||||||||||||||
| 4360 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue(); | - | ||||||||||||||||||||||||
| 4361 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||||||||||||||
| 4362 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 6-30 | ||||||||||||||||||||||||
| 4363 | return *reinterpret_cast<const QVariant*>(d.data); executed 6 times by 1 test: return *reinterpret_cast<const QVariant*>(d.data);Executed by:
| 6 | ||||||||||||||||||||||||
| 4364 | return v; executed 30 times by 1 test: return v;Executed by:
| 30 | ||||||||||||||||||||||||
| 4365 | } | - | ||||||||||||||||||||||||
| 4366 | - | |||||||||||||||||||||||||
| 4367 | /*! | - | ||||||||||||||||||||||||
| 4368 | Returns \c true if \a other points to the same item as this | - | ||||||||||||||||||||||||
| 4369 | iterator; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 4370 | - | |||||||||||||||||||||||||
| 4371 | \sa operator!=() | - | ||||||||||||||||||||||||
| 4372 | */ | - | ||||||||||||||||||||||||
| 4373 | bool QAssociativeIterable::const_iterator::operator==(const const_iterator &other) const | - | ||||||||||||||||||||||||
| 4374 | { | - | ||||||||||||||||||||||||
| 4375 | return m_impl.equal(other.m_impl); executed 9 times by 1 test: return m_impl.equal(other.m_impl);Executed by:
| 9 | ||||||||||||||||||||||||
| 4376 | } | - | ||||||||||||||||||||||||
| 4377 | - | |||||||||||||||||||||||||
| 4378 | /*! | - | ||||||||||||||||||||||||
| 4379 | Returns \c true if \a other points to a different item than this | - | ||||||||||||||||||||||||
| 4380 | iterator; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 4381 | - | |||||||||||||||||||||||||
| 4382 | \sa operator==() | - | ||||||||||||||||||||||||
| 4383 | */ | - | ||||||||||||||||||||||||
| 4384 | bool QAssociativeIterable::const_iterator::operator!=(const const_iterator &other) const | - | ||||||||||||||||||||||||
| 4385 | { | - | ||||||||||||||||||||||||
| 4386 | return !m_impl.equal(other.m_impl); executed 60 times by 1 test: return !m_impl.equal(other.m_impl);Executed by:
| 60 | ||||||||||||||||||||||||
| 4387 | } | - | ||||||||||||||||||||||||
| 4388 | - | |||||||||||||||||||||||||
| 4389 | /*! | - | ||||||||||||||||||||||||
| 4390 | The prefix ++ operator (\c{++it}) advances the iterator to the | - | ||||||||||||||||||||||||
| 4391 | next item in the container and returns an iterator to the new current | - | ||||||||||||||||||||||||
| 4392 | item. | - | ||||||||||||||||||||||||
| 4393 | - | |||||||||||||||||||||||||
| 4394 | Calling this function on QAssociativeIterable::end() leads to undefined results. | - | ||||||||||||||||||||||||
| 4395 | - | |||||||||||||||||||||||||
| 4396 | \sa operator--() | - | ||||||||||||||||||||||||
| 4397 | */ | - | ||||||||||||||||||||||||
| 4398 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator++() | - | ||||||||||||||||||||||||
| 4399 | { | - | ||||||||||||||||||||||||
| 4400 | m_impl.advance(1); | - | ||||||||||||||||||||||||
| 4401 | return *this; executed 34 times by 1 test: return *this;Executed by:
| 34 | ||||||||||||||||||||||||
| 4402 | } | - | ||||||||||||||||||||||||
| 4403 | - | |||||||||||||||||||||||||
| 4404 | /*! | - | ||||||||||||||||||||||||
| 4405 | \overload | - | ||||||||||||||||||||||||
| 4406 | - | |||||||||||||||||||||||||
| 4407 | The postfix ++ operator (\c{it++}) advances the iterator to the | - | ||||||||||||||||||||||||
| 4408 | next item in the container and returns an iterator to the previously | - | ||||||||||||||||||||||||
| 4409 | current item. | - | ||||||||||||||||||||||||
| 4410 | */ | - | ||||||||||||||||||||||||
| 4411 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator++(int) | - | ||||||||||||||||||||||||
| 4412 | { | - | ||||||||||||||||||||||||
| 4413 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||||||||||||||
| 4414 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
| 4415 | m_impl.advance(1); | - | ||||||||||||||||||||||||
| 4416 | return const_iterator(impl, new QAtomicInt(0)); executed 3 times by 1 test: return const_iterator(impl, new QAtomicInt(0));Executed by:
| 3 | ||||||||||||||||||||||||
| 4417 | } | - | ||||||||||||||||||||||||
| 4418 | - | |||||||||||||||||||||||||
| 4419 | /*! | - | ||||||||||||||||||||||||
| 4420 | The prefix -- operator (\c{--it}) makes the preceding item | - | ||||||||||||||||||||||||
| 4421 | current and returns an iterator to the new current item. | - | ||||||||||||||||||||||||
| 4422 | - | |||||||||||||||||||||||||
| 4423 | Calling this function on QAssociativeIterable::begin() leads to undefined results. | - | ||||||||||||||||||||||||
| 4424 | - | |||||||||||||||||||||||||
| 4425 | \sa operator++() | - | ||||||||||||||||||||||||
| 4426 | */ | - | ||||||||||||||||||||||||
| 4427 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator--() | - | ||||||||||||||||||||||||
| 4428 | { | - | ||||||||||||||||||||||||
| 4429 | m_impl.advance(-1); | - | ||||||||||||||||||||||||
| 4430 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 4431 | } | - | ||||||||||||||||||||||||
| 4432 | - | |||||||||||||||||||||||||
| 4433 | /*! | - | ||||||||||||||||||||||||
| 4434 | \overload | - | ||||||||||||||||||||||||
| 4435 | - | |||||||||||||||||||||||||
| 4436 | The postfix -- operator (\c{it--}) makes the preceding item | - | ||||||||||||||||||||||||
| 4437 | current and returns an iterator to the previously current item. | - | ||||||||||||||||||||||||
| 4438 | */ | - | ||||||||||||||||||||||||
| 4439 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator--(int) | - | ||||||||||||||||||||||||
| 4440 | { | - | ||||||||||||||||||||||||
| 4441 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||||||||||||||
| 4442 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
| 4443 | m_impl.advance(-1); | - | ||||||||||||||||||||||||
| 4444 | return const_iterator(impl, new QAtomicInt(0)); never executed: return const_iterator(impl, new QAtomicInt(0)); | 0 | ||||||||||||||||||||||||
| 4445 | } | - | ||||||||||||||||||||||||
| 4446 | - | |||||||||||||||||||||||||
| 4447 | /*! | - | ||||||||||||||||||||||||
| 4448 | Advances the iterator by \a j items. | - | ||||||||||||||||||||||||
| 4449 | - | |||||||||||||||||||||||||
| 4450 | \sa operator-=(), operator+() | - | ||||||||||||||||||||||||
| 4451 | */ | - | ||||||||||||||||||||||||
| 4452 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator+=(int j) | - | ||||||||||||||||||||||||
| 4453 | { | - | ||||||||||||||||||||||||
| 4454 | m_impl.advance(j); | - | ||||||||||||||||||||||||
| 4455 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 4456 | } | - | ||||||||||||||||||||||||
| 4457 | - | |||||||||||||||||||||||||
| 4458 | /*! | - | ||||||||||||||||||||||||
| 4459 | Makes the iterator go back by \a j items. | - | ||||||||||||||||||||||||
| 4460 | - | |||||||||||||||||||||||||
| 4461 | \sa operator+=(), operator-() | - | ||||||||||||||||||||||||
| 4462 | */ | - | ||||||||||||||||||||||||
| 4463 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator-=(int j) | - | ||||||||||||||||||||||||
| 4464 | { | - | ||||||||||||||||||||||||
| 4465 | m_impl.advance(-j); | - | ||||||||||||||||||||||||
| 4466 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 4467 | } | - | ||||||||||||||||||||||||
| 4468 | - | |||||||||||||||||||||||||
| 4469 | /*! | - | ||||||||||||||||||||||||
| 4470 | Returns an iterator to the item at \a j positions forward from | - | ||||||||||||||||||||||||
| 4471 | this iterator. | - | ||||||||||||||||||||||||
| 4472 | - | |||||||||||||||||||||||||
| 4473 | \sa operator-(), operator+=() | - | ||||||||||||||||||||||||
| 4474 | */ | - | ||||||||||||||||||||||||
| 4475 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator+(int j) const | - | ||||||||||||||||||||||||
| 4476 | { | - | ||||||||||||||||||||||||
| 4477 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||||||||||||||
| 4478 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
| 4479 | impl.advance(j); | - | ||||||||||||||||||||||||
| 4480 | return const_iterator(impl, new QAtomicInt(0)); executed 1 time by 1 test: return const_iterator(impl, new QAtomicInt(0));Executed by:
| 1 | ||||||||||||||||||||||||
| 4481 | } | - | ||||||||||||||||||||||||
| 4482 | - | |||||||||||||||||||||||||
| 4483 | /*! | - | ||||||||||||||||||||||||
| 4484 | Returns an iterator to the item at \a j positions backward from | - | ||||||||||||||||||||||||
| 4485 | this iterator. | - | ||||||||||||||||||||||||
| 4486 | - | |||||||||||||||||||||||||
| 4487 | \sa operator+(), operator-=() | - | ||||||||||||||||||||||||
| 4488 | */ | - | ||||||||||||||||||||||||
| 4489 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator-(int j) const | - | ||||||||||||||||||||||||
| 4490 | { | - | ||||||||||||||||||||||||
| 4491 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||||||||||||||
| 4492 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
| 4493 | impl.advance(-j); | - | ||||||||||||||||||||||||
| 4494 | return const_iterator(impl, new QAtomicInt(0)); never executed: return const_iterator(impl, new QAtomicInt(0)); | 0 | ||||||||||||||||||||||||
| 4495 | } | - | ||||||||||||||||||||||||
| 4496 | - | |||||||||||||||||||||||||
| 4497 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |