KChart

KChartLeveyJenningsGridAttributes.cpp
1 /*
2  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #include "KChartLeveyJenningsGridAttributes.h"
10 
11 #include "KChartMath_p.h"
12 
13 #include <QBrush>
14 #include <QMap>
15 #include <QPen>
16 
17 #define d d_func()
18 
19 using namespace KChart;
20 
21 class Q_DECL_HIDDEN LeveyJenningsGridAttributes::Private
22 {
23  friend class LeveyJenningsGridAttributes;
24 public:
25  Private();
26 private:
27  QMap< GridType, bool > visible;
30 };
31 
32 LeveyJenningsGridAttributes::Private::Private()
33 {
34  pens[ Calculated ].setCapStyle( Qt::FlatCap );
35  pens[ Calculated ].setColor( Qt::blue );
36  pens[ Expected ].setCapStyle( Qt::FlatCap );
37  pens[ Expected ].setColor( Qt::black );
38 
39  visible[ Calculated ] = true;
40  visible[ Expected ] = true;
41 
42  rangeBrushes[ LeveyJenningsGridAttributes::CriticalRange ] = QBrush( QColor( 255, 255, 192 ) );
43  rangeBrushes[ LeveyJenningsGridAttributes::OutOfRange ] = QBrush( QColor( 255, 128, 128 ) );
44 }
45 
46 
47 LeveyJenningsGridAttributes::LeveyJenningsGridAttributes()
48  : _d( new Private() )
49 {
50  // this block left empty intentionally
51 }
52 
53 LeveyJenningsGridAttributes::LeveyJenningsGridAttributes( const LeveyJenningsGridAttributes& r )
54  : _d( new Private( *r.d ) )
55 {
56 }
57 
58 LeveyJenningsGridAttributes & LeveyJenningsGridAttributes::operator=( const LeveyJenningsGridAttributes& r )
59 {
60  if ( this == &r )
61  return *this;
62 
63  *d = *r.d;
64 
65  return *this;
66 }
67 
68 LeveyJenningsGridAttributes::~LeveyJenningsGridAttributes()
69 {
70  delete _d; _d = nullptr;
71 }
72 
73 
74 bool LeveyJenningsGridAttributes::operator==( const LeveyJenningsGridAttributes& r ) const
75 {
76  return isGridVisible( Expected ) == r.isGridVisible( Expected ) &&
77  isGridVisible( Calculated ) == r.isGridVisible( Calculated ) &&
78  gridPen( Expected ) == r.gridPen( Expected ) &&
79  gridPen( Calculated ) == r.gridPen( Calculated );
80 }
81 
82 void LeveyJenningsGridAttributes::setRangeBrush( Range range, const QBrush& brush )
83 {
84  d->rangeBrushes[ range ] = brush;
85 }
86 
87 QBrush LeveyJenningsGridAttributes::rangeBrush( Range range ) const
88 {
89  return d->rangeBrushes[ range ];
90 }
91 
92 
93 void LeveyJenningsGridAttributes::setGridVisible( GridType type, bool visible )
94 {
95  d->visible[ type ] = visible;
96 }
97 
98 bool LeveyJenningsGridAttributes::isGridVisible( GridType type ) const
99 {
100  return d->visible[ type ];
101 }
102 
103 void LeveyJenningsGridAttributes::setGridPen( GridType type, const QPen& pen )
104 {
105  d->pens[ type ] = pen;
106  d->pens[ type ].setCapStyle( Qt::FlatCap );
107 }
108 
109 QPen LeveyJenningsGridAttributes::gridPen( GridType type ) const
110 {
111  return d->pens[ type ];
112 }
Type type(const QSqlDatabase &db)
A set of attributes controlling the appearance of grids.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Jul 1 2022 05:09:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.