Qt 4.8
qguivariant.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qvariant.h"
43 
44 #include "qbitmap.h"
45 #include "qbrush.h"
46 #include "qcolor.h"
47 #include "qcursor.h"
48 #include "qdatastream.h"
49 #include "qdebug.h"
50 #include "qfont.h"
51 #include "qicon.h"
52 #include "qimage.h"
53 #include "qkeysequence.h"
54 #include "qtransform.h"
55 #include "qmatrix.h"
56 #include "qpalette.h"
57 #include "qpen.h"
58 #include "qpixmap.h"
59 #include "qpolygon.h"
60 #include "qregion.h"
61 #include "qsizepolicy.h"
62 #include "qtextformat.h"
63 #include "qmatrix4x4.h"
64 #include "qvector2d.h"
65 #include "qvector3d.h"
66 #include "qvector4d.h"
67 #include "qquaternion.h"
68 
69 #include "private/qvariant_p.h"
70 
72 
73 #ifdef QT3_SUPPORT
74 extern QDataStream &qt_stream_out_qcolorgroup(QDataStream &s, const QColorGroup &g);
75 extern QDataStream &qt_stream_in_qcolorgroup(QDataStream &s, QColorGroup &g);
76 #endif
77 
78 Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();
79 
80 static void construct(QVariant::Private *x, const void *copy)
81 {
82  switch (x->type) {
83  case QVariant::Bitmap:
84  v_construct<QBitmap>(x, copy);
85  break;
86  case QVariant::Region:
87  v_construct<QRegion>(x, copy);
88  break;
89  case QVariant::Polygon:
90  v_construct<QPolygon>(x, copy);
91  break;
92  case QVariant::Font:
93  v_construct<QFont>(x, copy);
94  break;
95  case QVariant::Pixmap:
96  v_construct<QPixmap>(x, copy);
97  break;
98  case QVariant::Image:
99  v_construct<QImage>(x, copy);
100  break;
101  case QVariant::Brush:
102  v_construct<QBrush>(x, copy);
103  break;
104  case QVariant::Color:
105  v_construct<QColor>(x, copy);
106  break;
107  case QVariant::Palette:
108  v_construct<QPalette>(x, copy);
109  break;
110 #ifdef QT3_SUPPORT
111  case QVariant::ColorGroup:
112  v_construct<QColorGroup>(x, copy);
113  break;
114 #endif
115 #ifndef QT_NO_ICON
116  case QVariant::Icon:
117  v_construct<QIcon>(x, copy);
118  break;
119 #endif
120  case QVariant::Matrix:
121  v_construct<QMatrix>(x, copy);
122  break;
123  case QVariant::Transform:
124  v_construct<QTransform>(x, copy);
125  break;
127  v_construct<QTextFormat>(x, copy);
128  break;
130  v_construct<QTextLength>(x, copy);
131  break;
132 #ifndef QT_NO_SHORTCUT
134  v_construct<QKeySequence>(x, copy);
135  break;
136 #endif
137  case QVariant::Pen:
138  v_construct<QPen>(x, copy);
139  break;
141  v_construct<QSizePolicy>(x, copy);
142  break;
143 #ifndef QT_NO_CURSOR
144  case QVariant::Cursor:
145  v_construct<QCursor>(x, copy);
146  break;
147 #endif
148  case 62: {
149  // small 'trick' to let a QVariant(Qt::blue) create a variant
150  // of type QColor
151  x->type = QVariant::Color;
152  QColor color(*reinterpret_cast<const Qt::GlobalColor *>(copy));
153  v_construct<QColor>(x, &color);
154  break;
155  }
156 #ifndef QT_NO_MATRIX4X4
157  case QVariant::Matrix4x4:
158  v_construct<QMatrix4x4>(x, copy);
159  break;
160 #endif
161 #ifndef QT_NO_VECTOR2D
162  case QVariant::Vector2D:
163  v_construct<QVector2D>(x, copy);
164  break;
165 #endif
166 #ifndef QT_NO_VECTOR3D
167  case QVariant::Vector3D:
168  v_construct<QVector3D>(x, copy);
169  break;
170 #endif
171 #ifndef QT_NO_VECTOR4D
172  case QVariant::Vector4D:
173  v_construct<QVector4D>(x, copy);
174  break;
175 #endif
176 #ifndef QT_NO_QUATERNION
178  v_construct<QQuaternion>(x, copy);
179  break;
180 #endif
181  default:
182  qcoreVariantHandler()->construct(x, copy);
183  return;
184  }
185  x->is_null = !copy;
186 }
187 
188 static void clear(QVariant::Private *d)
189 {
190  switch (d->type) {
191  case QVariant::Bitmap:
192  v_clear<QBitmap>(d);
193  break;
194  case QVariant::Cursor:
195  v_clear<QCursor>(d);
196  break;
197  case QVariant::Region:
198  v_clear<QRegion>(d);
199  break;
200  case QVariant::Polygon:
201  v_clear<QPolygon>(d);
202  break;
203  case QVariant::Font:
204  v_clear<QFont>(d);
205  break;
206  case QVariant::Pixmap:
207  v_clear<QPixmap>(d);
208  break;
209  case QVariant::Image:
210  v_clear<QImage>(d);
211  break;
212  case QVariant::Brush:
213  v_clear<QBrush>(d);
214  break;
215  case QVariant::Color:
216  v_clear<QColor>(d);
217  break;
218  case QVariant::Palette:
219  v_clear<QPalette>(d);
220  break;
221 #ifdef QT3_SUPPORT
222  case QVariant::ColorGroup:
223  v_clear<QColorGroup>(d);
224  break;
225 #endif
226 #ifndef QT_NO_ICON
227  case QVariant::Icon:
228  v_clear<QIcon>(d);
229  break;
230 #endif
231  case QVariant::Matrix:
232  v_clear<QMatrix>(d);
233  break;
234  case QVariant::Transform:
235  v_clear<QTransform>(d);
236  break;
238  v_clear<QTextFormat>(d);
239  break;
241  v_clear<QTextLength>(d);
242  break;
244  v_clear<QSizePolicy>(d);
245  break;
246 #ifndef QT_NO_SHORTCUT
248  v_clear<QKeySequence>(d);
249  break;
250 #endif
251  case QVariant::Pen:
252  v_clear<QPen>(d);
253  break;
254 #ifndef QT_NO_MATRIX4X4
255  case QVariant::Matrix4x4:
256  v_clear<QMatrix4x4>(d);
257  break;
258 #endif
259 #ifndef QT_NO_VECTOR2D
260  case QVariant::Vector2D:
261  v_clear<QVector2D>(d);
262  break;
263 #endif
264 #ifndef QT_NO_VECTOR3D
265  case QVariant::Vector3D:
266  v_clear<QVector3D>(d);
267  break;
268 #endif
269 #ifndef QT_NO_VECTOR4D
270  case QVariant::Vector4D:
271  v_clear<QVector4D>(d);
272  break;
273 #endif
274 #ifndef QT_NO_QUATERNION
276  v_clear<QVector4D>(d);
277  break;
278 #endif
279  default:
280  qcoreVariantHandler()->clear(d);
281  return;
282  }
283 
284  d->type = QVariant::Invalid;
285  d->is_null = true;
286  d->is_shared = false;
287 }
288 
289 
290 static bool isNull(const QVariant::Private *d)
291 {
292  switch(d->type) {
293  case QVariant::Bitmap:
294  return v_cast<QBitmap>(d)->isNull();
295  case QVariant::Region:
296  return v_cast<QRegion>(d)->isEmpty();
297  case QVariant::Polygon:
298  return v_cast<QPolygon>(d)->isEmpty();
299  case QVariant::Pixmap:
300  return v_cast<QPixmap>(d)->isNull();
301  case QVariant::Image:
302  return v_cast<QImage>(d)->isNull();
303 #ifndef QT_NO_ICON
304  case QVariant::Icon:
305  return v_cast<QIcon>(d)->isNull();
306 #endif
307  case QVariant::Matrix:
310  case QVariant::Cursor:
312  case QVariant::Font:
313  case QVariant::Brush:
314  case QVariant::Color:
315  case QVariant::Palette:
316 #ifdef QT3_SUPPORT
317  case QVariant::ColorGroup:
318 #endif
320 #ifndef QT_NO_SHORTCUT
322 #endif
323  case QVariant::Pen:
324 #ifndef QT_NO_MATRIX4X4
325  case QVariant::Matrix4x4:
326 #endif
327  break;
328 #ifndef QT_NO_VECTOR2D
329  case QVariant::Vector2D:
330  return v_cast<QVector2D>(d)->isNull();
331 #endif
332 #ifndef QT_NO_VECTOR3D
333  case QVariant::Vector3D:
334  return v_cast<QVector3D>(d)->isNull();
335 #endif
336 #ifndef QT_NO_VECTOR4D
337  case QVariant::Vector4D:
338  return v_cast<QVector4D>(d)->isNull();
339 #endif
340 #ifndef QT_NO_QUATERNION
342  return v_cast<QQuaternion>(d)->isNull();
343 #endif
344  default:
345  return qcoreVariantHandler()->isNull(d);
346  }
347  return d->is_null;
348 }
349 
350 static bool compare(const QVariant::Private *a, const QVariant::Private *b)
351 {
352  Q_ASSERT(a->type == b->type);
353  switch(a->type) {
354  case QVariant::Cursor:
355 #ifndef QT_NO_CURSOR
356  return v_cast<QCursor>(a)->shape() == v_cast<QCursor>(b)->shape();
357 #endif
358  case QVariant::Bitmap:
359  return v_cast<QBitmap>(a)->cacheKey()
360  == v_cast<QBitmap>(b)->cacheKey();
361  case QVariant::Polygon:
362  return *v_cast<QPolygon>(a) == *v_cast<QPolygon>(b);
363  case QVariant::Region:
364  return *v_cast<QRegion>(a) == *v_cast<QRegion>(b);
365  case QVariant::Font:
366  return *v_cast<QFont>(a) == *v_cast<QFont>(b);
367  case QVariant::Pixmap:
368  return v_cast<QPixmap>(a)->cacheKey() == v_cast<QPixmap>(b)->cacheKey();
369  case QVariant::Image:
370  return *v_cast<QImage>(a) == *v_cast<QImage>(b);
371  case QVariant::Brush:
372  return *v_cast<QBrush>(a) == *v_cast<QBrush>(b);
373  case QVariant::Color:
374  return *v_cast<QColor>(a) == *v_cast<QColor>(b);
375  case QVariant::Palette:
376  return *v_cast<QPalette>(a) == *v_cast<QPalette>(b);
377 #ifdef QT3_SUPPORT
378  case QVariant::ColorGroup:
379  return *v_cast<QColorGroup>(a) == *v_cast<QColorGroup>(b);
380 #endif
381 #ifndef QT_NO_ICON
382  case QVariant::Icon:
383  /* QIcon::operator==() cannot be reasonably implemented for QIcon,
384  * so we always return false. */
385  return false;
386 #endif
387  case QVariant::Matrix:
388  return *v_cast<QMatrix>(a) == *v_cast<QMatrix>(b);
389  case QVariant::Transform:
390  return *v_cast<QTransform>(a) == *v_cast<QTransform>(b);
392  return *v_cast<QTextFormat>(a) == *v_cast<QTextFormat>(b);
394  return *v_cast<QTextLength>(a) == *v_cast<QTextLength>(b);
396  return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
397 #ifndef QT_NO_SHORTCUT
399  return *v_cast<QKeySequence>(a) == *v_cast<QKeySequence>(b);
400 #endif
401  case QVariant::Pen:
402  return *v_cast<QPen>(a) == *v_cast<QPen>(b);
403 #ifndef QT_NO_MATRIX4X4
404  case QVariant::Matrix4x4:
405  return *v_cast<QMatrix4x4>(a) == *v_cast<QMatrix4x4>(b);
406 #endif
407 #ifndef QT_NO_VECTOR2D
408  case QVariant::Vector2D:
409  return *v_cast<QVector2D>(a) == *v_cast<QVector2D>(b);
410 #endif
411 #ifndef QT_NO_VECTOR3D
412  case QVariant::Vector3D:
413  return *v_cast<QVector3D>(a) == *v_cast<QVector3D>(b);
414 #endif
415 #ifndef QT_NO_VECTOR4D
416  case QVariant::Vector4D:
417  return *v_cast<QVector4D>(a) == *v_cast<QVector4D>(b);
418 #endif
419 #ifndef QT_NO_QUATERNION
421  return *v_cast<QQuaternion>(a) == *v_cast<QQuaternion>(b);
422 #endif
423  default:
424  break;
425  }
426  return qcoreVariantHandler()->compare(a, b);
427 }
428 
429 
430 
431 static bool convert(const QVariant::Private *d, QVariant::Type t,
432  void *result, bool *ok)
433 {
434  switch (t) {
435  case QVariant::ByteArray:
436  if (d->type == QVariant::Color) {
437  *static_cast<QByteArray *>(result) = v_cast<QColor>(d)->name().toLatin1();
438  return true;
439  }
440  break;
441  case QVariant::String: {
442  QString *str = static_cast<QString *>(result);
443  switch (d->type) {
444 #ifndef QT_NO_SHORTCUT
446  *str = QString(*v_cast<QKeySequence>(d));
447  return true;
448 #endif
449  case QVariant::Font:
450  *str = v_cast<QFont>(d)->toString();
451  return true;
452  case QVariant::Color:
453  *str = v_cast<QColor>(d)->name();
454  return true;
455  default:
456  break;
457  }
458  break;
459  }
460  case QVariant::Pixmap:
461  if (d->type == QVariant::Image) {
462  *static_cast<QPixmap *>(result) = QPixmap::fromImage(*v_cast<QImage>(d));
463  return true;
464  } else if (d->type == QVariant::Bitmap) {
465  *static_cast<QPixmap *>(result) = *v_cast<QBitmap>(d);
466  return true;
467  } else if (d->type == QVariant::Brush) {
468  if (v_cast<QBrush>(d)->style() == Qt::TexturePattern) {
469  *static_cast<QPixmap *>(result) = v_cast<QBrush>(d)->texture();
470  return true;
471  }
472  }
473  break;
474  case QVariant::Image:
475  if (d->type == QVariant::Pixmap) {
476  *static_cast<QImage *>(result) = v_cast<QPixmap>(d)->toImage();
477  return true;
478  } else if (d->type == QVariant::Bitmap) {
479  *static_cast<QImage *>(result) = v_cast<QBitmap>(d)->toImage();
480  return true;
481  }
482  break;
483  case QVariant::Bitmap:
484  if (d->type == QVariant::Pixmap) {
485  *static_cast<QBitmap *>(result) = *v_cast<QPixmap>(d);
486  return true;
487  } else if (d->type == QVariant::Image) {
488  *static_cast<QBitmap *>(result) = QBitmap::fromImage(*v_cast<QImage>(d));
489  return true;
490  }
491  break;
492 #ifndef QT_NO_SHORTCUT
493  case QVariant::Int:
494  if (d->type == QVariant::KeySequence) {
495  *static_cast<int *>(result) = (int)(*(v_cast<QKeySequence>(d)));
496  return true;
497  }
498  break;
499 #endif
500  case QVariant::Font:
501  if (d->type == QVariant::String) {
502  QFont *f = static_cast<QFont *>(result);
503  f->fromString(*v_cast<QString>(d));
504  return true;
505  }
506  break;
507  case QVariant::Color:
508  if (d->type == QVariant::String) {
509  static_cast<QColor *>(result)->setNamedColor(*v_cast<QString>(d));
510  return static_cast<QColor *>(result)->isValid();
511  } else if (d->type == QVariant::ByteArray) {
512  static_cast<QColor *>(result)->setNamedColor(QString::fromLatin1(
513  *v_cast<QByteArray>(d)));
514  return true;
515  } else if (d->type == QVariant::Brush) {
516  if (v_cast<QBrush>(d)->style() == Qt::SolidPattern) {
517  *static_cast<QColor *>(result) = v_cast<QBrush>(d)->color();
518  return true;
519  }
520  }
521  break;
522  case QVariant::Brush:
523  if (d->type == QVariant::Color) {
524  *static_cast<QBrush *>(result) = QBrush(*v_cast<QColor>(d));
525  return true;
526  } else if (d->type == QVariant::Pixmap) {
527  *static_cast<QBrush *>(result) = QBrush(*v_cast<QPixmap>(d));
528  return true;
529  }
530  break;
531 #ifndef QT_NO_SHORTCUT
532  case QVariant::KeySequence: {
533  QKeySequence *seq = static_cast<QKeySequence *>(result);
534  switch (d->type) {
535  case QVariant::String:
536  *seq = QKeySequence(*v_cast<QString>(d));
537  return true;
538  case QVariant::Int:
539  *seq = QKeySequence(d->data.i);
540  return true;
541  default:
542  break;
543  }
544  }
545 #endif
546  default:
547  break;
548  }
549  return qcoreVariantHandler()->convert(d, t, result, ok);
550 }
551 
552 #if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
553 static void streamDebug(QDebug dbg, const QVariant &v)
554 {
555  switch(v.type()) {
556  case QVariant::Cursor:
557 #ifndef QT_NO_CURSOR
558 // dbg.nospace() << qvariant_cast<QCursor>(v); //FIXME
559 #endif
560  break;
561  case QVariant::Bitmap:
562 // dbg.nospace() << qvariant_cast<QBitmap>(v); //FIXME
563  break;
564  case QVariant::Polygon:
565  dbg.nospace() << qvariant_cast<QPolygon>(v);
566  break;
567  case QVariant::Region:
568  dbg.nospace() << qvariant_cast<QRegion>(v);
569  break;
570  case QVariant::Font:
571 // dbg.nospace() << qvariant_cast<QFont>(v); //FIXME
572  break;
573  case QVariant::Matrix:
574  dbg.nospace() << qvariant_cast<QMatrix>(v);
575  break;
576  case QVariant::Transform:
577  dbg.nospace() << qvariant_cast<QTransform>(v);
578  break;
579  case QVariant::Pixmap:
580 // dbg.nospace() << qvariant_cast<QPixmap>(v); //FIXME
581  break;
582  case QVariant::Image:
583 // dbg.nospace() << qvariant_cast<QImage>(v); //FIXME
584  break;
585  case QVariant::Brush:
586  dbg.nospace() << qvariant_cast<QBrush>(v);
587  break;
588  case QVariant::Color:
589  dbg.nospace() << qvariant_cast<QColor>(v);
590  break;
591  case QVariant::Palette:
592 // dbg.nospace() << qvariant_cast<QPalette>(v); //FIXME
593  break;
594 #ifndef QT_NO_ICON
595  case QVariant::Icon:
596 // dbg.nospace() << qvariant_cast<QIcon>(v); // FIXME
597  break;
598 #endif
600 // dbg.nospace() << qvariant_cast<QSizePolicy>(v); //FIXME
601  break;
602 #ifndef QT_NO_SHORTCUT
604  dbg.nospace() << qvariant_cast<QKeySequence>(v);
605  break;
606 #endif
607  case QVariant::Pen:
608  dbg.nospace() << qvariant_cast<QPen>(v);
609  break;
610 #ifndef QT_NO_MATRIX4X4
611  case QVariant::Matrix4x4:
612  dbg.nospace() << qvariant_cast<QMatrix4x4>(v);
613  break;
614 #endif
615 #ifndef QT_NO_VECTOR2D
616  case QVariant::Vector2D:
617  dbg.nospace() << qvariant_cast<QVector2D>(v);
618  break;
619 #endif
620 #ifndef QT_NO_VECTOR3D
621  case QVariant::Vector3D:
622  dbg.nospace() << qvariant_cast<QVector3D>(v);
623  break;
624 #endif
625 #ifndef QT_NO_VECTOR4D
626  case QVariant::Vector4D:
627  dbg.nospace() << qvariant_cast<QVector4D>(v);
628  break;
629 #endif
630 #ifndef QT_NO_QUATERNION
632  dbg.nospace() << qvariant_cast<QQuaternion>(v);
633  break;
634 #endif
635  default:
636  qcoreVariantHandler()->debugStream(dbg, v);
637  break;
638  }
639 }
640 #endif
641 
642 const QVariant::Handler qt_gui_variant_handler = {
643  construct,
644  clear,
645  isNull,
646 #ifndef QT_NO_DATASTREAM
647  0,
648  0,
649 #endif
650  compare,
651  convert,
652  0,
653 #if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
655 #else
656  0
657 #endif
658 };
659 
660 struct QMetaTypeGuiHelper
661 {
664 #ifndef QT_NO_DATASTREAM
667 #endif
668 };
669 
671 
672 
673 #ifdef QT_NO_DATASTREAM
674 # define Q_DECL_METATYPE_HELPER(TYPE) \
675  typedef void *(*QConstruct##TYPE)(const TYPE *); \
676  static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
677  typedef void (*QDestruct##TYPE)(TYPE *); \
678  static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
679 #else
680 # define Q_DECL_METATYPE_HELPER(TYPE) \
681  typedef void *(*QConstruct##TYPE)(const TYPE *); \
682  static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
683  typedef void (*QDestruct##TYPE)(TYPE *); \
684  static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
685  typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
686  static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
687  typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
688  static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>;
689 #endif
690 
691 #ifdef QT3_SUPPORT
693 #endif
699 #ifndef QT_NO_ICON
701 #endif
706 #ifndef QT_NO_CURSOR
708 #endif
710 #ifndef QT_NO_SHORTCUT
712 #endif
718 #ifndef QT_NO_MATRIX4X4
720 #endif
721 #ifndef QT_NO_VECTOR2D
723 #endif
724 #ifndef QT_NO_VECTOR3D
726 #endif
727 #ifndef QT_NO_VECTOR4D
729 #endif
730 #ifndef QT_NO_QUATERNION
732 #endif
733 
734 #ifdef QT_NO_DATASTREAM
735 # define Q_IMPL_METATYPE_HELPER(TYPE) \
736  { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
737  reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
738 #else
739 # define Q_IMPL_METATYPE_HELPER(TYPE) \
740  { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
741  reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
742  reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
743  reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
744  }
745 #endif
746 
748 #ifdef QT3_SUPPORT
750 #else
751  {0, 0, 0, 0},
752 #endif
758 #ifdef QT_NO_ICON
759  {0, 0, 0, 0},
760 #else
762 #endif
767 #ifdef QT_NO_CURSOR
768  {0, 0, 0, 0},
769 #else
771 #endif
773 #ifdef QT_NO_SHORTCUT
774  {0, 0, 0, 0},
775 #else
777 #endif
783 #ifndef QT_NO_MATRIX4X4
785 #else
786  {0, 0, 0, 0},
787 #endif
788 #ifndef QT_NO_VECTOR2D
790 #else
791  {0, 0, 0, 0},
792 #endif
793 #ifndef QT_NO_VECTOR3D
795 #else
796  {0, 0, 0, 0},
797 #endif
798 #ifndef QT_NO_VECTOR4D
800 #else
801  {0, 0, 0, 0},
802 #endif
803 #ifndef QT_NO_QUATERNION
805 #else
806  {0, 0, 0, 0}
807 #endif
808 };
809 
810 static const QVariant::Handler *qt_guivariant_last_handler = 0;
812 {
813  qt_guivariant_last_handler = QVariant::handler;
816  return 1;
817 }
819 
821 {
823  qMetaTypeGuiHelper = 0;
824  return 1;
825 }
827 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int qUnregisterGuiVariant()
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
bool fromString(const QString &)
Sets this font to match the description descrip.
Definition: qfont.cpp:2367
#define Q_IMPL_METATYPE_HELPER(TYPE)
Q_CORE_EXPORT const QVariant::Handler * qcoreVariantHandler()
Definition: qvariant.cpp:1193
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaType::Constructor constr
Definition: qmetatype.cpp:339
The QVector4D class represents a vector or vertex in 4D space.
Definition: qvector4d.h:60
const QVariant::Handler qt_gui_variant_handler
void *(* Constructor)(const void *)
Definition: qmetatype.h:105
int qRegisterGuiVariant()
long ASN1_INTEGER_get ASN1_INTEGER * a
void(* LoadOperator)(QDataStream &, void *)
Definition: qmetatype.h:109
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_DESTRUCTOR_FUNCTION(AFUNC)
Definition: qglobal.h:839
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_CONSTRUCTOR_FUNCTION(AFUNC)
Definition: qglobal.h:829
static const QMetaTypeGuiHelper qVariantGuiHelper[]
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void(* Destructor)(void *)
Definition: qmetatype.h:104
const T * v_cast(const QVariant::Private *d, T *=0)
Definition: qvariant_p.h:78
Q_CORE_EXPORT const QMetaTypeGuiHelper * qMetaTypeGuiHelper
Definition: qmetatype.cpp:346
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
static QString toString(Register *reg, int type, bool *ok=0)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool isEmpty(const char *str)
static const Handler * handler
Definition: qvariant.h:419
static void clear(QVariant::Private *d)
The QTextFormat class provides formatting information for a QTextDocument.
Definition: qtextformat.h:129
const char * name
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QVector2D class represents a vector or vertex in 2D space.
Definition: qvector2d.h:60
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void(* SaveOperator)(QDataStream &, const void *)
Definition: qmetatype.h:108
QMetaType::SaveOperator saveOp
Definition: qmetatype.cpp:342
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
static bool isNull(const QVariant::Private *d)
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
The QTextLength class encapsulates the different types of length used in a QTextDocument.
Definition: qtextformat.h:84
The QColorGroup class contains color groups for each widget state.
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static const QVariant::Handler * qt_guivariant_last_handler
static QBitmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Returns a copy of the given image converted to a bitmap using the specified image conversion flags...
Definition: qbitmap.cpp:281
QMetaType::Destructor destr
Definition: qmetatype.cpp:340
QMetaType::LoadOperator loadOp
Definition: qmetatype.cpp:343
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
static void streamDebug(QDebug dbg, const QVariant &v)
#define Q_DECL_METATYPE_HELPER(TYPE)
static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, bool *ok)
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
T qvariant_cast(const QVariant &value)
Returns the given value converted to the template type T.
Definition: qvariant.h:571
static void construct(QVariant::Private *x, const void *copy)
Definition: qguivariant.cpp:80
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60
static bool compare(const QVariant::Private *a, const QVariant::Private *b)