author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 15 Mar 2010 12:43:09 +0200 | |
branch | RCL_3 |
changeset 6 | dee5afe5301f |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Designer of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
// |
|
43 |
// W A R N I N G |
|
44 |
// ------------- |
|
45 |
// |
|
46 |
// This file is not part of the Qt API. It exists for the convenience |
|
47 |
// of Qt Designer. This header |
|
48 |
// file may change from version to version without notice, or even be removed. |
|
49 |
// |
|
50 |
// We mean it. |
|
51 |
// |
|
52 |
||
53 |
#ifndef UILIBPROPERTIES_H |
|
54 |
#define UILIBPROPERTIES_H |
|
55 |
||
56 |
#include <QtDesigner/uilib_global.h> |
|
57 |
||
58 |
#include <QtCore/QObject> |
|
59 |
#include <QtCore/QMetaProperty> |
|
60 |
#include <QtCore/QLocale> |
|
61 |
#include <QtCore/QCoreApplication> |
|
62 |
||
63 |
#include <QtGui/QWidget> |
|
64 |
||
65 |
#include "formbuilderextra_p.h" |
|
66 |
||
67 |
QT_BEGIN_NAMESPACE |
|
68 |
||
69 |
#ifdef QFORMINTERNAL_NAMESPACE |
|
70 |
namespace QFormInternal |
|
71 |
{ |
|
72 |
#endif |
|
73 |
||
74 |
class QAbstractFormBuilder; |
|
75 |
class DomProperty; |
|
76 |
||
77 |
QDESIGNER_UILIB_EXPORT DomProperty *variantToDomProperty(QAbstractFormBuilder *abstractFormBuilder, const QMetaObject *meta, const QString &propertyName, const QVariant &value); |
|
78 |
||
79 |
||
80 |
QDESIGNER_UILIB_EXPORT QVariant domPropertyToVariant(const DomProperty *property); |
|
81 |
QDESIGNER_UILIB_EXPORT QVariant domPropertyToVariant(QAbstractFormBuilder *abstractFormBuilder, const QMetaObject *meta, const DomProperty *property); |
|
82 |
||
83 |
// This class exists to provide meta information |
|
84 |
// for enumerations only. |
|
85 |
class QAbstractFormBuilderGadget: public QWidget |
|
86 |
{ |
|
87 |
Q_OBJECT |
|
88 |
Q_PROPERTY(Qt::ItemFlags itemFlags READ fakeItemFlags) |
|
89 |
Q_PROPERTY(Qt::CheckState checkState READ fakeCheckState) |
|
90 |
Q_PROPERTY(Qt::Alignment textAlignment READ fakeAlignment) |
|
91 |
Q_PROPERTY(Qt::Orientation orientation READ fakeOrientation) |
|
92 |
Q_PROPERTY(QSizePolicy::Policy sizeType READ fakeSizeType) |
|
93 |
Q_PROPERTY(QPalette::ColorRole colorRole READ fakeColorRole) |
|
94 |
Q_PROPERTY(QPalette::ColorGroup colorGroup READ fakeColorGroup) |
|
95 |
Q_PROPERTY(QFont::StyleStrategy styleStrategy READ fakeStyleStrategy) |
|
96 |
Q_PROPERTY(Qt::CursorShape cursorShape READ fakeCursorShape) |
|
97 |
Q_PROPERTY(Qt::BrushStyle brushStyle READ fakeBrushStyle) |
|
98 |
Q_PROPERTY(Qt::ToolBarArea toolBarArea READ fakeToolBarArea) |
|
99 |
Q_PROPERTY(QGradient::Type gradientType READ fakeGradientType) |
|
100 |
Q_PROPERTY(QGradient::Spread gradientSpread READ fakeGradientSpread) |
|
101 |
Q_PROPERTY(QGradient::CoordinateMode gradientCoordinate READ fakeGradientCoordinate) |
|
102 |
Q_PROPERTY(QLocale::Language language READ fakeLanguage) |
|
103 |
Q_PROPERTY(QLocale::Country country READ fakeCountry) |
|
104 |
public: |
|
105 |
QAbstractFormBuilderGadget() { Q_ASSERT(0); } |
|
106 |
||
107 |
Qt::Orientation fakeOrientation() const { Q_ASSERT(0); return Qt::Horizontal; } |
|
108 |
QSizePolicy::Policy fakeSizeType() const { Q_ASSERT(0); return QSizePolicy::Expanding; } |
|
109 |
QPalette::ColorGroup fakeColorGroup() const { Q_ASSERT(0); return static_cast<QPalette::ColorGroup>(0); } |
|
110 |
QPalette::ColorRole fakeColorRole() const { Q_ASSERT(0); return static_cast<QPalette::ColorRole>(0); } |
|
111 |
QFont::StyleStrategy fakeStyleStrategy() const { Q_ASSERT(0); return QFont::PreferDefault; } |
|
112 |
Qt::CursorShape fakeCursorShape() const { Q_ASSERT(0); return Qt::ArrowCursor; } |
|
113 |
Qt::BrushStyle fakeBrushStyle() const { Q_ASSERT(0); return Qt::NoBrush; } |
|
114 |
Qt::ToolBarArea fakeToolBarArea() const { Q_ASSERT(0); return Qt::NoToolBarArea; } |
|
115 |
QGradient::Type fakeGradientType() const { Q_ASSERT(0); return QGradient::NoGradient; } |
|
116 |
QGradient::Spread fakeGradientSpread() const { Q_ASSERT(0); return QGradient::PadSpread; } |
|
117 |
QGradient::CoordinateMode fakeGradientCoordinate() const { Q_ASSERT(0); return QGradient::LogicalMode; } |
|
118 |
QLocale::Language fakeLanguage() const { Q_ASSERT(0); return QLocale::C; } |
|
119 |
QLocale::Country fakeCountry() const { Q_ASSERT(0); return QLocale::AnyCountry; } |
|
120 |
Qt::ItemFlags fakeItemFlags() const { Q_ASSERT(0); return Qt::NoItemFlags; } |
|
121 |
Qt::CheckState fakeCheckState() const { Q_ASSERT(0); return Qt::Unchecked; } |
|
122 |
Qt::Alignment fakeAlignment() const { Q_ASSERT(0); return Qt::AlignLeft; } |
|
123 |
}; |
|
124 |
||
125 |
// Convert key to value for a given QMetaEnum |
|
126 |
template <class EnumType> |
|
127 |
inline EnumType enumKeyToValue(const QMetaEnum &metaEnum,const char *key, const EnumType* = 0) |
|
128 |
{ |
|
129 |
int val = metaEnum.keyToValue(key); |
|
130 |
if (val == -1) { |
|
131 |
||
132 |
uiLibWarning(QCoreApplication::translate("QFormBuilder", "The enumeration-value '%1' is invalid. The default value '%2' will be used instead.") |
|
133 |
.arg(QString::fromUtf8(key)).arg(QString::fromUtf8(metaEnum.key(0)))); |
|
134 |
val = metaEnum.value(0); |
|
135 |
} |
|
136 |
return static_cast<EnumType>(val); |
|
137 |
} |
|
138 |
||
139 |
// Convert keys to value for a given QMetaEnum |
|
140 |
template <class EnumType> |
|
141 |
inline EnumType enumKeysToValue(const QMetaEnum &metaEnum,const char *keys, const EnumType* = 0) |
|
142 |
{ |
|
143 |
int val = metaEnum.keysToValue(keys); |
|
144 |
if (val == -1) { |
|
145 |
||
146 |
uiLibWarning(QCoreApplication::translate("QFormBuilder", "The flag-value '%1' is invalid. Zero will be used instead.") |
|
147 |
.arg(QString::fromUtf8(keys))); |
|
148 |
val = 0; |
|
149 |
} |
|
150 |
return static_cast<EnumType>(QFlag(val)); |
|
151 |
} |
|
152 |
||
153 |
// Access meta enumeration object of a qobject |
|
154 |
template <class QObjectType> |
|
155 |
inline QMetaEnum metaEnum(const char *name, const QObjectType* = 0) |
|
156 |
{ |
|
157 |
const int e_index = QObjectType::staticMetaObject.indexOfProperty(name); |
|
158 |
Q_ASSERT(e_index != -1); |
|
159 |
return QObjectType::staticMetaObject.property(e_index).enumerator(); |
|
160 |
} |
|
161 |
||
162 |
// Convert key to value for enumeration by name |
|
163 |
template <class QObjectType, class EnumType> |
|
164 |
inline EnumType enumKeyOfObjectToValue(const char *enumName, const char *key, const QObjectType* = 0, const EnumType* = 0) |
|
165 |
{ |
|
166 |
const QMetaEnum me = metaEnum<QObjectType>(enumName); |
|
167 |
return enumKeyToValue<EnumType>(me, key); |
|
168 |
} |
|
169 |
||
170 |
#ifdef QFORMINTERNAL_NAMESPACE |
|
171 |
} |
|
172 |
#endif |
|
173 |
||
174 |
QT_END_NAMESPACE |
|
175 |
||
176 |
#endif // UILIBPROPERTIES_H |