summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-05-06 23:52:43 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-05-06 23:52:43 +0200
commit32ce4fe9e6a94e77828e976776cf08da85254ff2 (patch)
tree26eb7e7554f4cd62c6c1f112faf3e2b32d1aa211 /src/gui
parent7ff1d396e74457eced141abd019fc62a5858ac75 (diff)
split up qguivariant into two files
Move everything that will end up in QtWidgets into a qwidgetsvariant.cpp file. Currently this is QIcon and QSizePolicy only.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/guikernel/qguivariant.cpp59
-rw-r--r--src/gui/kernel/kernel.pri5
-rw-r--r--src/gui/kernel/qwidgetsvariant.cpp213
3 files changed, 240 insertions, 37 deletions
diff --git a/src/gui/guikernel/qguivariant.cpp b/src/gui/guikernel/qguivariant.cpp
index ef0cfc987c..c1e07e55a5 100644
--- a/src/gui/guikernel/qguivariant.cpp
+++ b/src/gui/guikernel/qguivariant.cpp
@@ -48,7 +48,6 @@
#include "qdatastream.h"
#include "qdebug.h"
#include "qfont.h"
-#include "qicon.h"
#include "qimage.h"
#include "qkeysequence.h"
#include "qtransform.h"
@@ -58,7 +57,6 @@
#include "qpixmap.h"
#include "qpolygon.h"
#include "qregion.h"
-#include "qsizepolicy.h"
#include "qtextformat.h"
#include "qmatrix4x4.h"
#include "qvector2d.h"
@@ -70,6 +68,7 @@
QT_BEGIN_NAMESPACE
+Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler = 0;
Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();
@@ -103,11 +102,6 @@ static void construct(QVariant::Private *x, const void *copy)
case QVariant::Palette:
v_construct<QPalette>(x, copy);
break;
-#ifndef QT_NO_ICON
- case QVariant::Icon:
- v_construct<QIcon>(x, copy);
- break;
-#endif
case QVariant::Matrix:
v_construct<QMatrix>(x, copy);
break;
@@ -128,9 +122,6 @@ static void construct(QVariant::Private *x, const void *copy)
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);
@@ -169,6 +160,13 @@ static void construct(QVariant::Private *x, const void *copy)
v_construct<QQuaternion>(x, copy);
break;
#endif
+ case QVariant::SizePolicy:
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler) {
+ qt_widgets_variant_handler->construct(x, copy);
+ return;
+ }
+ break;
default:
qcoreVariantHandler()->construct(x, copy);
return;
@@ -209,11 +207,6 @@ static void clear(QVariant::Private *d)
case QVariant::Palette:
v_clear<QPalette>(d);
break;
-#ifndef QT_NO_ICON
- case QVariant::Icon:
- v_clear<QIcon>(d);
- break;
-#endif
case QVariant::Matrix:
v_clear<QMatrix>(d);
break;
@@ -226,9 +219,6 @@ static void clear(QVariant::Private *d)
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);
@@ -262,6 +252,13 @@ static void clear(QVariant::Private *d)
v_clear<QVector4D>(d);
break;
#endif
+ case QVariant::SizePolicy:
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler) {
+ qt_widgets_variant_handler->clear(d);
+ return;
+ }
+ break;
default:
qcoreVariantHandler()->clear(d);
return;
@@ -286,10 +283,6 @@ static bool isNull(const QVariant::Private *d)
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:
@@ -324,6 +317,10 @@ static bool isNull(const QVariant::Private *d)
case QVariant::Quaternion:
return v_cast<QQuaternion>(d)->isNull();
#endif
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler)
+ return qt_widgets_variant_handler->isNull(d);
+ break;
default:
return qcoreVariantHandler()->isNull(d);
}
@@ -371,8 +368,6 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
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);
@@ -399,6 +394,10 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
case QVariant::Quaternion:
return *v_cast<QQuaternion>(a) == *v_cast<QQuaternion>(b);
#endif
+ case QVariant::SizePolicy:
+ if (qt_widgets_variant_handler)
+ return qt_widgets_variant_handler->compare(a, b);
+ break;
default:
break;
}
@@ -672,9 +671,6 @@ Q_DECL_METATYPE_HELPER(QPixmap)
Q_DECL_METATYPE_HELPER(QBrush)
Q_DECL_METATYPE_HELPER(QColor)
Q_DECL_METATYPE_HELPER(QPalette)
-#ifndef QT_NO_ICON
-Q_DECL_METATYPE_HELPER(QIcon)
-#endif
Q_DECL_METATYPE_HELPER(QImage)
Q_DECL_METATYPE_HELPER(QPolygon)
Q_DECL_METATYPE_HELPER(QRegion)
@@ -682,7 +678,6 @@ Q_DECL_METATYPE_HELPER(QBitmap)
#ifndef QT_NO_CURSOR
Q_DECL_METATYPE_HELPER(QCursor)
#endif
-Q_DECL_METATYPE_HELPER(QSizePolicy)
#ifndef QT_NO_SHORTCUT
Q_DECL_METATYPE_HELPER(QKeySequence)
#endif
@@ -721,17 +716,11 @@ Q_DECL_METATYPE_HELPER(QQuaternion)
#endif
static const QMetaTypeGuiHelper qVariantGuiHelper[] = {
- {0, 0, 0, 0},
Q_IMPL_METATYPE_HELPER(QFont),
Q_IMPL_METATYPE_HELPER(QPixmap),
Q_IMPL_METATYPE_HELPER(QBrush),
Q_IMPL_METATYPE_HELPER(QColor),
Q_IMPL_METATYPE_HELPER(QPalette),
-#ifdef QT_NO_ICON
- {0, 0, 0, 0},
-#else
- Q_IMPL_METATYPE_HELPER(QIcon),
-#endif
Q_IMPL_METATYPE_HELPER(QImage),
Q_IMPL_METATYPE_HELPER(QPolygon),
Q_IMPL_METATYPE_HELPER(QRegion),
@@ -741,7 +730,6 @@ static const QMetaTypeGuiHelper qVariantGuiHelper[] = {
#else
Q_IMPL_METATYPE_HELPER(QCursor),
#endif
- Q_IMPL_METATYPE_HELPER(QSizePolicy),
#ifdef QT_NO_SHORTCUT
{0, 0, 0, 0},
#else
@@ -797,4 +785,5 @@ int qUnregisterGuiVariant()
}
Q_DESTRUCTOR_FUNCTION(qUnregisterGuiVariant)
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 4788252285..d085bff146 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -67,8 +67,9 @@ SOURCES += \
kernel/qgesturerecognizer.cpp \
kernel/qgesturemanager.cpp \
kernel/qsoftkeymanager.cpp \
- kernel/qdesktopwidget.cpp \
- kernel/qguiplatformplugin.cpp
+ kernel/qdesktopwidget.cpp \
+ kernel/qguiplatformplugin.cpp \
+ kernel/qwidgetsvariant.cpp
win32 {
DEFINES += QT_NO_DIRECTDRAW
diff --git a/src/gui/kernel/qwidgetsvariant.cpp b/src/gui/kernel/qwidgetsvariant.cpp
new file mode 100644
index 0000000000..680c8f9cfa
--- /dev/null
+++ b/src/gui/kernel/qwidgetsvariant.cpp
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvariant.h"
+
+#include "qicon.h"
+#include "qsizepolicy.h"
+
+#include "private/qvariant_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+static void construct(QVariant::Private *x, const void *copy)
+{
+ switch (x->type) {
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+ v_construct<QIcon>(x, copy);
+ break;
+#endif
+ case QVariant::SizePolicy:
+ v_construct<QSizePolicy>(x, copy);
+ break;
+ default:
+ Q_ASSERT(false);
+ return;
+ }
+ x->is_null = !copy;
+}
+
+static void clear(QVariant::Private *d)
+{
+ switch (d->type) {
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+ v_clear<QIcon>(d);
+ break;
+#endif
+ case QVariant::SizePolicy:
+ v_clear<QSizePolicy>(d);
+ break;
+ default:
+ Q_ASSERT(false);
+ return;
+ }
+
+ d->type = QVariant::Invalid;
+ d->is_null = true;
+ d->is_shared = false;
+}
+
+
+static bool isNull(const QVariant::Private *d)
+{
+ switch(d->type) {
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+ return v_cast<QIcon>(d)->isNull();
+#endif
+ default:
+ Q_ASSERT(false);
+ }
+ return true;
+}
+
+static bool compare(const QVariant::Private *a, const QVariant::Private *b)
+{
+ Q_ASSERT(a->type == b->type);
+ switch(a->type) {
+ case QVariant::SizePolicy:
+ return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
+ default:
+ Q_ASSERT(false);
+ }
+ return false;
+}
+
+
+static const QVariant::Handler widgets_handler = {
+ construct,
+ clear,
+ isNull,
+#ifndef QT_NO_DATASTREAM
+ 0,
+ 0,
+#endif
+ compare,
+ 0,
+ 0,
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+ 0
+#else
+ 0
+#endif
+};
+
+struct QMetaTypeGuiHelper
+{
+ QMetaType::Constructor constr;
+ QMetaType::Destructor destr;
+#ifndef QT_NO_DATASTREAM
+ QMetaType::SaveOperator saveOp;
+ QMetaType::LoadOperator loadOp;
+#endif
+};
+
+extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper;
+
+
+#ifdef QT_NO_DATASTREAM
+# define Q_DECL_METATYPE_HELPER(TYPE) \
+ typedef void *(*QConstruct##TYPE)(const TYPE *); \
+ static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
+ typedef void (*QDestruct##TYPE)(TYPE *); \
+ static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
+#else
+# define Q_DECL_METATYPE_HELPER(TYPE) \
+ typedef void *(*QConstruct##TYPE)(const TYPE *); \
+ static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
+ typedef void (*QDestruct##TYPE)(TYPE *); \
+ static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
+ typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
+ static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
+ typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
+ static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>;
+#endif
+
+#ifndef QT_NO_ICON
+Q_DECL_METATYPE_HELPER(QIcon)
+#endif
+Q_DECL_METATYPE_HELPER(QSizePolicy)
+
+#ifdef QT_NO_DATASTREAM
+# define Q_IMPL_METATYPE_HELPER(TYPE) \
+ { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
+ reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
+#else
+# define Q_IMPL_METATYPE_HELPER(TYPE) \
+ { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
+ reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
+ reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
+ reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
+ }
+#endif
+
+static const QMetaTypeGuiHelper qVariantWidgetsHelper[] = {
+#ifdef QT_NO_ICON
+ {0, 0, 0, 0},
+#else
+ Q_IMPL_METATYPE_HELPER(QIcon),
+#endif
+ Q_IMPL_METATYPE_HELPER(QSizePolicy),
+};
+
+extern Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler;
+
+int qRegisterWidgetsVariant()
+{
+ qt_widgets_variant_handler = &widgets_handler;
+ qMetaTypeWidgetsHelper = qVariantWidgetsHelper;
+ return 1;
+}
+Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant)
+
+int qUnregisterWidgetsVariant()
+{
+ qt_widgets_variant_handler = 0;
+ qMetaTypeWidgetsHelper = 0;
+ return 1;
+}
+Q_DESTRUCTOR_FUNCTION(qUnregisterWidgetsVariant)
+
+
+QT_END_NAMESPACE