⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qguivariant.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qvariant.h"#include "qbitmap.h"#include "qbrush.h"#include "qcolor.h"#include "qcursor.h"#include "qdatastream.h"#include "qdebug.h"#include "qfont.h"#include "qicon.h"#include "qimage.h"#include "qkeysequence.h"#include "qtransform.h"#include "qmatrix.h"#include "qpalette.h"#include "qpen.h"#include "qpixmap.h"#include "qpolygon.h"#include "qregion.h"#include "qsizepolicy.h"#include "qtextformat.h"#include "private/qvariant_p.h"#ifdef QT3_SUPPORTextern QDataStream &qt_stream_out_qcolorgroup(QDataStream &s, const QColorGroup &g);extern QDataStream &qt_stream_in_qcolorgroup(QDataStream &s, QColorGroup &g);#endifQ_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();static void construct(QVariant::Private *x, const void *copy){    switch (x->type) {    case QVariant::Bitmap:        v_construct<QBitmap>(x, copy);        break;    case QVariant::Region:        v_construct<QRegion>(x, copy);        break;    case QVariant::Polygon:        v_construct<QPolygon>(x, copy);        break;    case QVariant::Font:        v_construct<QFont>(x, copy);        break;    case QVariant::Pixmap:        v_construct<QPixmap>(x, copy);        break;    case QVariant::Image:        v_construct<QImage>(x, copy);        break;    case QVariant::Brush:        v_construct<QBrush>(x, copy);        break;    case QVariant::Color:        v_construct<QColor>(x, copy);        break;    case QVariant::Palette:        v_construct<QPalette>(x, copy);        break;#ifdef QT3_SUPPORT    case QVariant::ColorGroup:        v_construct<QColorGroup>(x, copy);        break;#endif#ifndef QT_NO_ICON    case QVariant::Icon:        v_construct<QIcon>(x, copy);        break;#endif    case QVariant::Matrix:        v_construct<QMatrix>(x, copy);        break;    case QVariant::Transform:        v_construct<QTransform>(x, copy);        break;    case QVariant::TextFormat:        v_construct<QTextFormat>(x, copy);        break;    case QVariant::TextLength:        v_construct<QTextLength>(x, copy);        break;#ifndef QT_NO_SHORTCUT    case QVariant::KeySequence:        v_construct<QKeySequence>(x, copy);        break;#endif    case QVariant::Pen:        v_construct<QPen>(x, copy);        break;    case QVariant::SizePolicy:        v_construct<QSizePolicy>(x, copy);        break;#ifndef QT_NO_CURSOR    case QVariant::Cursor:        v_construct<QCursor>(x, copy);        break;#endif    case 62: {        // small 'trick' to let a QVariant(Qt::blue) create a variant        // of type QColor        x->type = QVariant::Color;        QColor color(*reinterpret_cast<const Qt::GlobalColor *>(copy));        v_construct<QColor>(x, &color);        break;    }    default:        qcoreVariantHandler()->construct(x, copy);        return;    }    x->is_null = !copy;}static void clear(QVariant::Private *d){    switch (d->type) {    case QVariant::Bitmap:        v_clear<QBitmap>(d);        break;    case QVariant::Cursor:        v_clear<QCursor>(d);        break;    case QVariant::Region:        v_clear<QRegion>(d);        break;    case QVariant::Polygon:        v_clear<QPolygon>(d);        break;    case QVariant::Font:        v_clear<QFont>(d);        break;    case QVariant::Pixmap:        v_clear<QPixmap>(d);        break;    case QVariant::Image:        v_clear<QImage>(d);        break;    case QVariant::Brush:        v_clear<QBrush>(d);        break;    case QVariant::Color:        v_clear<QColor>(d);        break;    case QVariant::Palette:        v_clear<QPalette>(d);        break;#ifdef QT3_SUPPORT    case QVariant::ColorGroup:        v_clear<QColorGroup>(d);        break;#endif#ifndef QT_NO_ICON    case QVariant::Icon:        v_clear<QIcon>(d);        break;#endif    case QVariant::Matrix:        v_clear<QMatrix>(d);        break;    case QVariant::Transform:        v_clear<QTransform>(d);        break;    case QVariant::TextFormat:        v_clear<QTextFormat>(d);        break;    case QVariant::TextLength:        v_clear<QTextLength>(d);        break;    case QVariant::SizePolicy:        v_clear<QSizePolicy>(d);        break;#ifndef QT_NO_SHORTCUT    case QVariant::KeySequence:        v_clear<QKeySequence>(d);        break;#endif    case QVariant::Pen:        v_clear<QPen>(d);        break;    default:        qcoreVariantHandler()->clear(d);        return;    }    d->type = QVariant::Invalid;    d->is_null = true;    d->is_shared = false;}static bool isNull(const QVariant::Private *d){    switch(d->type) {    case QVariant::Bitmap:        return v_cast<QBitmap>(d)->isNull();    case QVariant::Region:        return v_cast<QRegion>(d)->isEmpty();    case QVariant::Polygon:        return v_cast<QPolygon>(d)->isEmpty();    case QVariant::Pixmap:        return v_cast<QPixmap>(d)->isNull();    case QVariant::Image:        return v_cast<QImage>(d)->isNull();#ifndef QT_NO_ICON    case QVariant::Icon:        return v_cast<QIcon>(d)->isNull();#endif    case QVariant::Matrix:    case QVariant::TextFormat:    case QVariant::TextLength:    case QVariant::Cursor:    case QVariant::StringList:    case QVariant::Font:    case QVariant::Brush:    case QVariant::Color:    case QVariant::Palette:#ifdef QT3_SUPPORT    case QVariant::ColorGroup:#endif    case QVariant::SizePolicy:#ifndef QT_NO_SHORTCUT    case QVariant::KeySequence:#endif    case QVariant::Pen:        break;    default:        return qcoreVariantHandler()->isNull(d);    }    return d->is_null;}static bool compare(const QVariant::Private *a, const QVariant::Private *b){    Q_ASSERT(a->type == b->type);    switch(a->type) {    case QVariant::Cursor:#ifndef QT_NO_CURSOR        return v_cast<QCursor>(a)->shape() == v_cast<QCursor>(b)->shape();#endif    case QVariant::Bitmap:        return v_cast<QBitmap>(a)->cacheKey()            == v_cast<QBitmap>(b)->cacheKey();    case QVariant::Polygon:        return *v_cast<QPolygon>(a) == *v_cast<QPolygon>(b);    case QVariant::Region:        return *v_cast<QRegion>(a) == *v_cast<QRegion>(b);    case QVariant::Font:        return *v_cast<QFont>(a) == *v_cast<QFont>(b);    case QVariant::Pixmap:        return v_cast<QPixmap>(a)->cacheKey() == v_cast<QPixmap>(b)->cacheKey();    case QVariant::Image:        return *v_cast<QImage>(a) == *v_cast<QImage>(b);    case QVariant::Brush:        return *v_cast<QBrush>(a) == *v_cast<QBrush>(b);    case QVariant::Color:        return *v_cast<QColor>(a) == *v_cast<QColor>(b);    case QVariant::Palette:        return *v_cast<QPalette>(a) == *v_cast<QPalette>(b);#ifdef QT3_SUPPORT    case QVariant::ColorGroup:        return *v_cast<QColorGroup>(a) == *v_cast<QColorGroup>(b);#endif#ifndef QT_NO_ICON    case QVariant::Icon:        /* QIcon::operator==() cannot be reasonably implemented for QIcon,         * so we always return false. */        return false;#endif    case QVariant::Matrix:        return *v_cast<QMatrix>(a) == *v_cast<QMatrix>(b);    case QVariant::Transform:        return *v_cast<QTransform>(a) == *v_cast<QTransform>(b);    case QVariant::TextFormat:        return *v_cast<QTextFormat>(a) == *v_cast<QTextFormat>(b);    case QVariant::TextLength:        return *v_cast<QTextLength>(a) == *v_cast<QTextLength>(b);    case QVariant::SizePolicy:        return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);#ifndef QT_NO_SHORTCUT    case QVariant::KeySequence:        return *v_cast<QKeySequence>(a) == *v_cast<QKeySequence>(b);#endif    case QVariant::Pen:        return *v_cast<QPen>(a) == *v_cast<QPen>(b);    default:        break;    }    return qcoreVariantHandler()->compare(a, b);}static bool convert(const QVariant::Private *d, QVariant::Type t,                 void *result, bool *ok){    switch (t) {    case QVariant::ByteArray:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -