1 /*
2 * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19 /** \file KChartGlobal.h
20 \brief Contains KChart macros.
21
22 Contains KChart macros. */
23
24 #ifndef __KCHARTGLOBAL_H__
25 #define __KCHARTGLOBAL_H__
26
27 #include <qglobal.h>
28
29 #include "kchart_export.h"
30
31 #ifndef KDAB_SET_OBJECT_NAME
32 template <typename T>
__kdab__dereference_for_methodcall(T & o)33 inline T & __kdab__dereference_for_methodcall( T & o ) {
34 return o;
35 }
36
37 template <typename T>
__kdab__dereference_for_methodcall(T * o)38 inline T & __kdab__dereference_for_methodcall( T * o ) {
39 return *o;
40 }
41
42 #define KDAB_SET_OBJECT_NAME( x ) __kdab__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
43 #endif
44
45 #define KCHART_DECLARE_PRIVATE_DERIVED( X ) \
46 public: \
47 class Private; \
48 protected: \
49 inline Private * d_func(); \
50 inline const Private * d_func() const; \
51 explicit inline X( Private * ); \
52 private: \
53 void init();
54
55 #define KCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType ) \
56 public: \
57 class Private; \
58 protected: \
59 inline Private * d_func(); \
60 inline const Private * d_func() const; \
61 explicit inline X( Private *, ParentType ); \
62 private: \
63 void init();
64
65 #define KCHART_DECLARE_PRIVATE_DERIVED_QWIDGET( X ) \
66 KCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, QWidget* )
67
68 #define KCHART_DECLARE_PRIVATE_BASE_VALUE( X ) \
69 public: \
70 inline void swap( X & other ) { qSwap( _d, other._d ); } \
71 protected: \
72 class Private; \
73 Private * d_func() { return _d; } \
74 const Private * d_func() const { return _d; } \
75 private: \
76 void init(); \
77 Private * _d;
78
79 #define KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \
80 public: \
81 class Private; \
82 protected: \
83 Private * d_func() { return _d; } \
84 const Private * d_func() const { return _d; } \
85 explicit inline X( Private * ); \
86 private: \
87 void init(); \
88 Private * _d;
89
90 #define KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \
91 public: \
92 class Private; \
93 protected: \
94 Private * d_func() { return _d; } \
95 const Private * d_func() const { return _d; } \
96 explicit inline X( Private *, QWidget* ); \
97 private: \
98 void init(); \
99 Private * _d;
100
101 #define KCHART_DERIVED_PRIVATE_FOOTER( CLASS, PARENT ) \
102 inline CLASS::CLASS( Private * p ) \
103 : PARENT( p ) { init(); } \
104 inline CLASS::Private * CLASS::d_func() \
105 { return static_cast<Private*>( PARENT::d_func() ); } \
106 inline const CLASS::Private * CLASS::d_func() const \
107 { return static_cast<const Private*>( PARENT::d_func() ); }
108
109
110 #define KCHART_DECLARE_DERIVED_DIAGRAM( X, PLANE ) \
111 public: \
112 class Private; \
113 protected: \
114 inline Private * d_func(); \
115 inline const Private * d_func() const; \
116 explicit inline X( Private * ); \
117 explicit inline X( Private *, QWidget *, PLANE * ); \
118 private: \
119 void init();
120
121 #define KCHART_IMPL_DERIVED_DIAGRAM( CLASS, PARENT, PLANE ) \
122 inline CLASS::CLASS( Private * p ) \
123 : PARENT( p ) { init(); } \
124 inline CLASS::CLASS( \
125 Private * p, QWidget* parent, PLANE * plane ) \
126 : PARENT( p, parent, plane ) { init(); } \
127 inline CLASS::Private * CLASS::d_func() \
128 { return static_cast<Private *>( PARENT::d_func() ); } \
129 inline const CLASS::Private * CLASS::d_func() const \
130 { return static_cast<const Private *>( PARENT::d_func() ); }
131
132
133 #define KCHART_IMPL_DERIVED_PLANE( CLASS, BASEPLANE ) \
134 inline CLASS::CLASS( Private * p, Chart* parent ) \
135 : BASEPLANE( p, parent ) { init(); } \
136 inline CLASS::Private * CLASS::d_func() \
137 { return static_cast<Private *>( BASEPLANE::d_func() ); } \
138 inline const CLASS::Private * CLASS::d_func() const \
139 { return static_cast<const Private *>( BASEPLANE::d_func() ); }
140
141
142 #include <QtAlgorithms> // qSwap
143 #ifndef QT_NO_STL
144 #include <algorithm>
145 #define KCHART_DECLARE_SWAP_SPECIALISATION( X ) \
146 QT_BEGIN_NAMESPACE \
147 template <> inline void qSwap<X>( X & lhs, X & rhs ) \
148 { lhs.swap( rhs ); } \
149 QT_END_NAMESPACE \
150 namespace std { \
151 template <> inline void swap<X>( X & lhs, X & rhs ) \
152 { lhs.swap( rhs ); } \
153 }
154 #else
155 #define KCHART_DECLARE_SWAP_SPECIALISATION( X ) \
156 QT_BEGIN_NAMESPACE \
157 template <> inline void qSwap<X>( X & lhs, X & rhs ) \
158 { lhs.swap( rhs ); } \
159 QT_END_NAMESPACE
160 #endif
161
162 #define KCHART_DECLARE_SWAP_SPECIALISATION_DERIVED( X ) \
163 KCHART_DECLARE_SWAP_SPECIALISATION( X )
164
165 #define KCHART_DECLARE_SWAP_BASE( X ) \
166 protected: \
167 void doSwap( X& other ) \
168 { qSwap( _d, other._d); }
169
170 #define KCHART_DECLARE_SWAP_DERIVED( X ) \
171 void swap( X& other ) { doSwap( other ); }
172
173 #if defined(Q_OS_WIN) && defined(QT_DLL)
174 #if defined(_MSC_VER) && _MSC_VER >= 1300
175 // workaround http://support.microsoft.com/default.aspx?scid=kb;en-us;309801
176 #include <QPointF>
177 #include <QVector>
178 template class Q_DECL_IMPORT QVector<QPointF>;
179 #endif
180 #endif
181
182 #include <Qt>
183
184 /**
185 \namespace KChart
186 \brief Global namespace
187 */
188 namespace KChart {
189
190 enum DisplayRoles {
191 DatasetPenRole = 0x0A79EF95,
192 DatasetBrushRole,
193 DataValueLabelAttributesRole,
194 ThreeDAttributesRole,
195 LineAttributesRole,
196 ThreeDLineAttributesRole,
197 BarAttributesRole,
198 StockBarAttributesRole,
199 ThreeDBarAttributesRole,
200 PieAttributesRole,
201 ThreeDPieAttributesRole,
202 DataHiddenRole,
203 ValueTrackerAttributesRole,
204 CommentRole
205 };
206 }
207
208 #endif // __KCHARTGLOBAL_H__
209