File indexing completed on 2024-05-12 04:20:31
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 0009 #include "KChartBackgroundAttributes.h" 0010 0011 #include "KChartMath_p.h" 0012 0013 #include <QPixmap> 0014 0015 #define d d_func() 0016 0017 0018 using namespace KChart; 0019 0020 class Q_DECL_HIDDEN BackgroundAttributes::Private 0021 { 0022 friend class KChart::BackgroundAttributes; 0023 public: 0024 Private(); 0025 private: 0026 bool visible; 0027 QBrush brush; 0028 BackgroundPixmapMode pixmapMode; 0029 QPixmap pixmap; 0030 }; 0031 0032 BackgroundAttributes::Private::Private() : 0033 visible( false ), 0034 pixmapMode( BackgroundAttributes::BackgroundPixmapModeNone ) 0035 { 0036 } 0037 0038 0039 BackgroundAttributes::BackgroundAttributes() 0040 : _d( new Private() ) 0041 { 0042 } 0043 0044 BackgroundAttributes::BackgroundAttributes( const BackgroundAttributes& r ) 0045 : _d( new Private( *r.d ) ) 0046 { 0047 } 0048 0049 BackgroundAttributes & BackgroundAttributes::operator=( const BackgroundAttributes& r ) 0050 { 0051 if ( this == &r ) 0052 return *this; 0053 0054 *d = *r.d; 0055 0056 return *this; 0057 } 0058 0059 bool BackgroundAttributes::operator==( const BackgroundAttributes& r ) const 0060 { 0061 return isEqualTo( r ); 0062 } 0063 0064 0065 bool BackgroundAttributes::isEqualTo( 0066 const BackgroundAttributes& other, bool ignorePixmap ) const 0067 { 0068 /* 0069 qDebug() << "BackgroundAttributes::operator=="; 0070 qDebug() << "isVisible" << (isVisible() == other.isVisible()); 0071 qDebug() << "brush" << (brush() == other.brush()); 0072 qDebug() << "pixmapMode"<< (pixmapMode() == other.pixmapMode()); 0073 qDebug() << "pixmap" << (pixmap().serialNumber() == other.pixmap().serialNumber()); 0074 */ 0075 return ( 0076 isVisible() == other.isVisible() && 0077 brush() == other.brush() && 0078 pixmapMode() == other.pixmapMode() && 0079 (ignorePixmap || 0080 pixmap().cacheKey() == other.pixmap().cacheKey()) ); 0081 } 0082 0083 0084 BackgroundAttributes::~BackgroundAttributes() 0085 { 0086 delete _d; _d = nullptr; 0087 } 0088 0089 0090 0091 0092 void BackgroundAttributes::setVisible( bool visible ) 0093 { 0094 d->visible = visible; 0095 } 0096 0097 0098 bool BackgroundAttributes::isVisible() const 0099 { 0100 return d->visible; 0101 } 0102 0103 void BackgroundAttributes::setBrush( const QBrush &brush ) 0104 { 0105 d->brush = brush; 0106 } 0107 0108 QBrush BackgroundAttributes::brush() const 0109 { 0110 return d->brush; 0111 } 0112 0113 void BackgroundAttributes::setPixmapMode( BackgroundPixmapMode mode ) 0114 { 0115 d->pixmapMode = mode; 0116 } 0117 0118 BackgroundAttributes::BackgroundPixmapMode BackgroundAttributes::pixmapMode() const 0119 { 0120 return d->pixmapMode; 0121 } 0122 0123 void BackgroundAttributes::setPixmap( const QPixmap &backPixmap ) 0124 { 0125 d->pixmap = backPixmap; 0126 } 0127 0128 QPixmap BackgroundAttributes::pixmap() const 0129 { 0130 return d->pixmap; 0131 } 0132 0133 #if !defined(QT_NO_DEBUG_STREAM) 0134 QDebug operator<<(QDebug dbg, const KChart::BackgroundAttributes& ba) 0135 { 0136 dbg << "KChart::BackgroundAttributes(" 0137 << "visible="<<ba.isVisible() 0138 << "brush="<<ba.brush() 0139 << "pixmapmode="<<ba.pixmapMode() 0140 << "pixmap="<<ba.pixmap().cacheKey() 0141 << ")"; 0142 return dbg; 0143 } 0144 #endif /* QT_NO_DEBUG_STREAM */