Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativevaluetypes / testtypes.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #ifndef TESTTYPES_H
42 #define TESTTYPES_H
43
44 #include <QObject>
45 #include <QPoint>
46 #include <QPointF>
47 #include <QSize>
48 #include <QSizeF>
49 #include <QRect>
50 #include <QRectF>
51 #include <QVector2D>
52 #include <QVector3D>
53 #include <QVector4D>
54 #include <QQuaternion>
55 #include <QMatrix4x4>
56 #include <QFont>
57 #include <QColor>
58 #include <qdeclarative.h>
59 #include <QDeclarativePropertyValueSource>
60 #include <QDeclarativeProperty>
61 #include <private/qdeclarativeproperty_p.h>
62 #include <private/qdeclarativepropertyvalueinterceptor_p.h>
63
64 class MyTypeObject : public QObject
65 {
66     Q_OBJECT
67
68     Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed)
69     Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed)
70     Q_PROPERTY(QPointF pointfpoint READ pointfpoint WRITE setPointfpoint NOTIFY changed)
71     Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed)
72     Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed)
73     Q_PROPERTY(QSizeF sizefsize READ sizefsize WRITE setSizefsize NOTIFY changed)
74     Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed)
75     Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed)
76     Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed)
77     Q_PROPERTY(QRectF rectfrect READ rectfrect WRITE setRectfrect NOTIFY changed)
78     Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed)
79     Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed)
80     Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed)
81     Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed)
82     Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed)
83     Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
84     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed)
85     Q_PROPERTY(QVariant variant READ variant NOTIFY changed)
86
87 public:
88     MyTypeObject() :
89         m_point(10, 4),
90         m_pointf(11.3, -10.9),
91         m_pointfpoint(10.0, 4.0),
92         m_size(1912, 1913),
93         m_sizef(0.1, 100923.2),
94         m_sizefsize(1912.0, 1913.0),
95         m_rect(2, 3, 109, 102),
96         m_rectf(103.8, 99.2, 88.1, 77.6),
97         m_rectfrect(2.0, 3.0, 109.0, 102.0),
98         m_vector2(32.88, 1.3),
99         m_vector(23.88, 3.1, 4.3),
100         m_vector4(54.2, 23.88, 3.1, 4.3),
101         m_quaternion(4.3, 54.2, 23.88, 3.1),
102         m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
103     {
104         m_font.setFamily("Arial");
105         m_font.setBold(true);
106         m_font.setWeight(QFont::DemiBold);
107         m_font.setItalic(true);
108         m_font.setUnderline(true);
109         m_font.setOverline(true);
110         m_font.setStrikeOut(true);
111         m_font.setPointSize(29);
112         m_font.setCapitalization(QFont::AllLowercase);
113         m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
114         m_font.setWordSpacing(19.7);
115         m_color.setRedF(0.2);
116         m_color.setGreenF(0.88);
117         m_color.setBlueF(0.6);
118         m_color.setAlphaF(0.34);
119     }
120
121     QPoint m_point;
122     QPoint point() const { return m_point; }
123     void setPoint(const QPoint &v) { m_point = v; emit changed(); }
124
125     QPointF m_pointf;
126     QPointF pointf() const { return m_pointf; }
127     void setPointf(const QPointF &v) { m_pointf = v; emit changed(); }
128
129     QPointF m_pointfpoint;
130     QPointF pointfpoint() const { return m_pointfpoint; }
131     void setPointfpoint(const QPointF &v) { m_pointfpoint = v; emit changed(); }
132
133     QSize m_size;
134     QSize size() const { return m_size; }
135     void setSize(const QSize &v) { m_size = v; emit changed(); }
136
137     QSizeF m_sizef;
138     QSizeF sizef() const { return m_sizef; }
139     void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); }
140
141     QSizeF m_sizefsize;
142     QSizeF sizefsize() const { return m_sizefsize; }
143     void setSizefsize(const QSizeF &v) { m_sizefsize = v; emit changed(); }
144
145     QRect m_rect;
146     QRect rect() const { return m_rect; }
147     void setRect(const QRect &v) { m_rect = v; emit changed(); }
148
149     QRectF m_rectf;
150     QRectF rectf() const { return m_rectf; }
151     void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
152
153     QRectF m_rectfrect;
154     QRectF rectfrect() const { return m_rectfrect; }
155     void setRectfrect(const QRectF &v) { m_rectfrect = v; emit changed(); }
156
157     QVector2D m_vector2;
158     QVector2D vector2() const { return m_vector2; }
159     void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); }
160
161     QVector3D m_vector;
162     QVector3D vector() const { return m_vector; }
163     void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
164
165     QVector4D m_vector4;
166     QVector4D vector4() const { return m_vector4; }
167     void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); }
168
169     QQuaternion m_quaternion;
170     QQuaternion quaternion() const { return m_quaternion; }
171     void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); }
172
173     QMatrix4x4 m_matrix;
174     QMatrix4x4 matrix() const { return m_matrix; }
175     void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); }
176
177     QFont m_font;
178     QFont font() const { return m_font; }
179     void setFont(const QFont &v) { m_font = v; emit changed(); }
180
181     QColor m_color;
182     QColor color() const { return m_color; }
183     void setColor(const QColor &v) { m_color = v; emit changed(); }
184
185     QVariant variant() const { return sizef(); }
186
187     void emitRunScript() { emit runScript(); }
188
189 signals:
190     void changed();
191     void runScript();
192
193 public slots:
194     QSize method() { return QSize(13, 14); }
195 };
196
197 class MyConstantValueSource : public QObject, public QDeclarativePropertyValueSource
198 {
199     Q_OBJECT
200     Q_INTERFACES(QDeclarativePropertyValueSource)
201 public:
202     virtual void setTarget(const QDeclarativeProperty &p) { p.write(3345); }
203 };
204
205 class MyOffsetValueInterceptor : public QObject, public QDeclarativePropertyValueInterceptor
206 {
207     Q_OBJECT
208     Q_INTERFACES(QDeclarativePropertyValueInterceptor)
209 public:
210     virtual void setTarget(const QDeclarativeProperty &p) { prop = p; }
211     virtual void write(const QVariant &value) { QDeclarativePropertyPrivate::write(prop, value.toInt() + 13, QDeclarativePropertyPrivate::BypassInterceptor); }
212
213 private:
214     QDeclarativeProperty prop;
215 };
216
217 void registerTypes();
218
219 #endif // TESTTYPES_H