00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "KDChartLeveyJenningsGridAttributes.h"
00027
00028 #include <QBrush>
00029 #include <QMap>
00030 #include <QPen>
00031
00032 #include <KDABLibFakes>
00033
00034 #define d d_func()
00035
00036 using namespace KDChart;
00037
00038 class LeveyJenningsGridAttributes::Private
00039 {
00040 friend class LeveyJenningsGridAttributes;
00041 public:
00042 Private();
00043 private:
00044 QMap< GridType, bool > visible;
00045 QMap< GridType, QPen > pens;
00046 QMap< LeveyJenningsGridAttributes::Range, QBrush > rangeBrushes;
00047 };
00048
00049 LeveyJenningsGridAttributes::Private::Private()
00050 {
00051 pens[ Calculated ].setCapStyle( Qt::FlatCap );
00052 pens[ Calculated ].setColor( Qt::blue );
00053 pens[ Expected ].setCapStyle( Qt::FlatCap );
00054 pens[ Expected ].setColor( Qt::black );
00055
00056 visible[ Calculated ] = true;
00057 visible[ Expected ] = true;
00058
00059 rangeBrushes[ LeveyJenningsGridAttributes::CriticalRange ] = QBrush( QColor( 255, 255, 192 ) );
00060 rangeBrushes[ LeveyJenningsGridAttributes::OutOfRange ] = QBrush( QColor( 255, 128, 128 ) );
00061 }
00062
00063
00064 LeveyJenningsGridAttributes::LeveyJenningsGridAttributes()
00065 : _d( new Private() )
00066 {
00067
00068 }
00069
00070 LeveyJenningsGridAttributes::LeveyJenningsGridAttributes( const LeveyJenningsGridAttributes& r )
00071 : _d( new Private( *r.d ) )
00072 {
00073 }
00074
00075 LeveyJenningsGridAttributes & LeveyJenningsGridAttributes::operator=( const LeveyJenningsGridAttributes& r )
00076 {
00077 if( this == &r )
00078 return *this;
00079
00080 *d = *r.d;
00081
00082 return *this;
00083 }
00084
00085 LeveyJenningsGridAttributes::~LeveyJenningsGridAttributes()
00086 {
00087 delete _d; _d = 0;
00088 }
00089
00090
00091 bool LeveyJenningsGridAttributes::operator==( const LeveyJenningsGridAttributes& r ) const
00092 {
00093 return isGridVisible( Expected ) == r.isGridVisible( Expected ) &&
00094 isGridVisible( Calculated ) == r.isGridVisible( Calculated ) &&
00095 gridPen( Expected ) == r.gridPen( Expected ) &&
00096 gridPen( Calculated ) == r.gridPen( Calculated );
00097 }
00098
00099 void LeveyJenningsGridAttributes::setRangeBrush( Range range, const QBrush& brush )
00100 {
00101 d->rangeBrushes[ range ] = brush;
00102 }
00103
00104 QBrush LeveyJenningsGridAttributes::rangeBrush( Range range ) const
00105 {
00106 return d->rangeBrushes[ range ];
00107 }
00108
00109
00110 void LeveyJenningsGridAttributes::setGridVisible( GridType type, bool visible )
00111 {
00112 d->visible[ type ] = visible;
00113 }
00114
00115 bool LeveyJenningsGridAttributes::isGridVisible( GridType type ) const
00116 {
00117 return d->visible[ type ];
00118 }
00119
00120 void LeveyJenningsGridAttributes::setGridPen( GridType type, const QPen& pen )
00121 {
00122 d->pens[ type ] = pen;
00123 d->pens[ type ].setCapStyle( Qt::FlatCap );
00124 }
00125
00126 QPen LeveyJenningsGridAttributes::gridPen( GridType type ) const
00127 {
00128 return d->pens[ type ];
00129 }