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
19using namespace KChart;
20
21class Q_DECL_HIDDEN LeveyJenningsGridAttributes::Private
22{
23 friend class LeveyJenningsGridAttributes;
24public:
25 Private();
26private:
30};
31
32LeveyJenningsGridAttributes::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
47LeveyJenningsGridAttributes::LeveyJenningsGridAttributes()
48 : _d( new Private() )
49{
50 // this block left empty intentionally
51}
52
53LeveyJenningsGridAttributes::LeveyJenningsGridAttributes( const LeveyJenningsGridAttributes& r )
54 : _d( new Private( *r.d ) )
55{
56}
57
58LeveyJenningsGridAttributes & LeveyJenningsGridAttributes::operator=( const LeveyJenningsGridAttributes& r )
59{
60 if ( this == &r )
61 return *this;
62
63 *d = *r.d;
64
65 return *this;
66}
67
68LeveyJenningsGridAttributes::~LeveyJenningsGridAttributes()
69{
70 delete _d; _d = nullptr;
71}
72
73
74bool 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
82void LeveyJenningsGridAttributes::setRangeBrush( Range range, const QBrush& brush )
83{
84 d->rangeBrushes[ range ] = brush;
85}
86
87QBrush LeveyJenningsGridAttributes::rangeBrush( Range range ) const
88{
89 return d->rangeBrushes[ range ];
90}
91
92
93void LeveyJenningsGridAttributes::setGridVisible( GridType type, bool visible )
94{
95 d->visible[ type ] = visible;
96}
97
98bool LeveyJenningsGridAttributes::isGridVisible( GridType type ) const
99{
100 return d->visible[ type ];
101}
102
103void LeveyJenningsGridAttributes::setGridPen( GridType type, const QPen& pen )
104{
105 d->pens[ type ] = pen;
106 d->pens[ type ].setCapStyle( Qt::FlatCap );
107}
108
109QPen LeveyJenningsGridAttributes::gridPen( GridType type ) const
110{
111 return d->pens[ type ];
112}
A set of attributes controlling the appearance of grids.
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:04:16 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.