File indexing completed on 2025-09-14 04:14:49
0001 /* 0002 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 /** \file KChartGlobal.h 0009 \brief Contains KChart macros. 0010 0011 Contains KChart macros. */ 0012 0013 #ifndef __KCHARTGLOBAL_H__ 0014 #define __KCHARTGLOBAL_H__ 0015 0016 #include <qglobal.h> 0017 0018 #include "kchart_export.h" 0019 0020 #ifndef KDAB_SET_OBJECT_NAME 0021 template <typename T> 0022 inline T & __kdab__dereference_for_methodcall( T & o ) { 0023 return o; 0024 } 0025 0026 template <typename T> 0027 inline T & __kdab__dereference_for_methodcall( T * o ) { 0028 return *o; 0029 } 0030 0031 #define KDAB_SET_OBJECT_NAME( x ) __kdab__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) ) 0032 #endif 0033 0034 #define KCHART_DECLARE_PRIVATE_DERIVED( X ) \ 0035 public: \ 0036 class Private; \ 0037 protected: \ 0038 inline Private * d_func(); \ 0039 inline const Private * d_func() const; \ 0040 explicit inline X( Private * ); \ 0041 private: \ 0042 void init(); 0043 0044 #define KCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType ) \ 0045 public: \ 0046 class Private; \ 0047 protected: \ 0048 inline Private * d_func(); \ 0049 inline const Private * d_func() const; \ 0050 explicit inline X( Private *, ParentType ); \ 0051 private: \ 0052 void init(); 0053 0054 #define KCHART_DECLARE_PRIVATE_DERIVED_QWIDGET( X ) \ 0055 KCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, QWidget* ) 0056 0057 #define KCHART_DECLARE_PRIVATE_BASE_VALUE( X ) \ 0058 public: \ 0059 inline void swap( X & other ) { qSwap( _d, other._d ); } \ 0060 protected: \ 0061 class Private; \ 0062 Private * d_func() { return _d; } \ 0063 const Private * d_func() const { return _d; } \ 0064 private: \ 0065 void init(); \ 0066 Private * _d; 0067 0068 #define KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \ 0069 public: \ 0070 class Private; \ 0071 protected: \ 0072 Private * d_func() { return _d; } \ 0073 const Private * d_func() const { return _d; } \ 0074 explicit inline X( Private * ); \ 0075 private: \ 0076 void init(); \ 0077 Private * _d; 0078 0079 #define KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \ 0080 public: \ 0081 class Private; \ 0082 protected: \ 0083 Private * d_func() { return _d; } \ 0084 const Private * d_func() const { return _d; } \ 0085 explicit inline X( Private *, QWidget* ); \ 0086 private: \ 0087 void init(); \ 0088 Private * _d; 0089 0090 #define KCHART_DERIVED_PRIVATE_FOOTER( CLASS, PARENT ) \ 0091 inline CLASS::CLASS( Private * p ) \ 0092 : PARENT( p ) { init(); } \ 0093 inline CLASS::Private * CLASS::d_func() \ 0094 { return static_cast<Private*>( PARENT::d_func() ); } \ 0095 inline const CLASS::Private * CLASS::d_func() const \ 0096 { return static_cast<const Private*>( PARENT::d_func() ); } 0097 0098 0099 #define KCHART_DECLARE_DERIVED_DIAGRAM( X, PLANE ) \ 0100 public: \ 0101 class Private; \ 0102 protected: \ 0103 inline Private * d_func(); \ 0104 inline const Private * d_func() const; \ 0105 explicit inline X( Private * ); \ 0106 explicit inline X( Private *, QWidget *, PLANE * ); \ 0107 private: \ 0108 void init(); 0109 0110 #define KCHART_IMPL_DERIVED_DIAGRAM( CLASS, PARENT, PLANE ) \ 0111 inline CLASS::CLASS( Private * p ) \ 0112 : PARENT( p ) { init(); } \ 0113 inline CLASS::CLASS( \ 0114 Private * p, QWidget* parent, PLANE * plane ) \ 0115 : PARENT( p, parent, plane ) { init(); } \ 0116 inline CLASS::Private * CLASS::d_func() \ 0117 { return static_cast<Private *>( PARENT::d_func() ); } \ 0118 inline const CLASS::Private * CLASS::d_func() const \ 0119 { return static_cast<const Private *>( PARENT::d_func() ); } 0120 0121 0122 #define KCHART_IMPL_DERIVED_PLANE( CLASS, BASEPLANE ) \ 0123 inline CLASS::CLASS( Private * p, Chart* parent ) \ 0124 : BASEPLANE( p, parent ) { init(); } \ 0125 inline CLASS::Private * CLASS::d_func() \ 0126 { return static_cast<Private *>( BASEPLANE::d_func() ); } \ 0127 inline const CLASS::Private * CLASS::d_func() const \ 0128 { return static_cast<const Private *>( BASEPLANE::d_func() ); } 0129 0130 0131 #include <QtAlgorithms> // qSwap 0132 #ifndef QT_NO_STL 0133 #include <algorithm> 0134 #define KCHART_DECLARE_SWAP_SPECIALISATION( X ) \ 0135 QT_BEGIN_NAMESPACE \ 0136 template <> inline void qSwap<X>( X & lhs, X & rhs ) \ 0137 { lhs.swap( rhs ); } \ 0138 QT_END_NAMESPACE \ 0139 namespace std { \ 0140 template <> inline void swap<X>( X & lhs, X & rhs ) \ 0141 { lhs.swap( rhs ); } \ 0142 } 0143 #else 0144 #define KCHART_DECLARE_SWAP_SPECIALISATION( X ) \ 0145 QT_BEGIN_NAMESPACE \ 0146 template <> inline void qSwap<X>( X & lhs, X & rhs ) \ 0147 { lhs.swap( rhs ); } \ 0148 QT_END_NAMESPACE 0149 #endif 0150 0151 #define KCHART_DECLARE_SWAP_SPECIALISATION_DERIVED( X ) \ 0152 KCHART_DECLARE_SWAP_SPECIALISATION( X ) 0153 0154 #define KCHART_DECLARE_SWAP_BASE( X ) \ 0155 protected: \ 0156 void doSwap( X& other ) \ 0157 { qSwap( _d, other._d); } 0158 0159 #define KCHART_DECLARE_SWAP_DERIVED( X ) \ 0160 void swap( X& other ) { doSwap( other ); } 0161 0162 #if defined(Q_OS_WIN) && defined(QT_DLL) 0163 #if defined(_MSC_VER) && _MSC_VER >= 1300 0164 // workaround http://support.microsoft.com/default.aspx?scid=kb;en-us;309801 0165 #include <QPointF> 0166 #include <QVector> 0167 template class Q_DECL_IMPORT QVector<QPointF>; 0168 #endif 0169 #endif 0170 0171 #include <Qt> 0172 0173 /** 0174 \namespace KChart 0175 \brief Global namespace 0176 */ 0177 namespace KChart { 0178 0179 enum DisplayRoles { 0180 DatasetPenRole = 0x0A79EF95, 0181 DatasetBrushRole, 0182 DataValueLabelAttributesRole, 0183 ThreeDAttributesRole, 0184 LineAttributesRole, 0185 ThreeDLineAttributesRole, 0186 BarAttributesRole, 0187 StockBarAttributesRole, 0188 ThreeDBarAttributesRole, 0189 PieAttributesRole, 0190 ThreeDPieAttributesRole, 0191 DataHiddenRole, 0192 ValueTrackerAttributesRole, 0193 CommentRole 0194 }; 0195 } 0196 0197 #endif // __KCHARTGLOBAL_H__