KDChartBackgroundAttributes.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2007 Klarälvdalens Datakonsult AB.  All rights reserved.
00003  **
00004  ** This file is part of the KD Chart library.
00005  **
00006  ** This file may be distributed and/or modified under the terms of the
00007  ** GNU General Public License version 2 as published by the Free Software
00008  ** Foundation and appearing in the file LICENSE.GPL included in the
00009  ** packaging of this file.
00010  **
00011  ** Licensees holding valid commercial KD Chart licenses may use this file in
00012  ** accordance with the KD Chart Commercial License Agreement provided with
00013  ** the Software.
00014  **
00015  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017  **
00018  ** See http://www.kdab.net/kdchart for
00019  **   information about KDChart Commercial License Agreements.
00020  **
00021  ** Contact info@kdab.net if any conditions of this
00022  ** licensing are not clear to you.
00023  **
00024  **********************************************************************/
00025 
00026 #include "KDChartBackgroundAttributes.h"
00027 #include <QPixmap>
00028 
00029 #include <KDABLibFakes>
00030 
00031 #define d d_func()
00032 
00033 
00034 using namespace KDChart;
00035 
00036 class BackgroundAttributes::Private
00037 {
00038     friend class KDChart::BackgroundAttributes;
00039 public:
00040     Private();
00041 private:
00042     bool visible;
00043     QBrush brush;
00044     BackgroundPixmapMode pixmapMode;
00045     QPixmap pixmap;
00046 };
00047 
00048 BackgroundAttributes::Private::Private() :
00049     visible( false ),
00050     pixmapMode( BackgroundAttributes::BackgroundPixmapModeNone )
00051 {
00052 }
00053 
00054 
00055 BackgroundAttributes::BackgroundAttributes()
00056     : _d( new Private() )
00057 {
00058 }
00059 
00060 BackgroundAttributes::BackgroundAttributes( const BackgroundAttributes& r )
00061     : _d( new Private( *r.d ) )
00062 {
00063 }
00064 
00065 BackgroundAttributes & BackgroundAttributes::operator=( const BackgroundAttributes& r )
00066 {
00067     if( this == &r )
00068         return *this;
00069 
00070     *d = *r.d;
00071 
00072     return *this;
00073 }
00074 
00075 bool BackgroundAttributes::operator==( const BackgroundAttributes& r ) const
00076 {
00077     return isEqualTo( r );
00078 }
00079 
00080 
00081 bool BackgroundAttributes::isEqualTo(
00082         const BackgroundAttributes& other, bool ignorePixmap ) const
00083 {
00084     /*
00085     qDebug() << "BackgroundAttributes::operator==";
00086     qDebug() << "isVisible" << (isVisible() == other.isVisible());
00087     qDebug() << "brush"     << (brush() == other.brush());
00088     qDebug() << "pixmapMode"<< (pixmapMode() == other.pixmapMode());
00089     qDebug() << "pixmap"    << (pixmap().serialNumber() == other.pixmap().serialNumber());
00090     */
00091     return (
00092             isVisible()  == other.isVisible() &&
00093             brush()      == other.brush() &&
00094             pixmapMode() == other.pixmapMode() &&
00095             (ignorePixmap ||
00096             pixmap().serialNumber() == other.pixmap().serialNumber()) );
00097 }
00098 
00099 
00100 BackgroundAttributes::~BackgroundAttributes()
00101 {
00102     delete _d; _d = 0;
00103 }
00104 
00105 
00106 
00107 
00108 void BackgroundAttributes::setVisible( bool visible )
00109 {
00110     d->visible = visible;
00111 }
00112 
00113 
00114 bool BackgroundAttributes::isVisible() const
00115 {
00116     return d->visible;
00117 }
00118 
00119 void BackgroundAttributes::setBrush( const QBrush &brush )
00120 {
00121     d->brush = brush;
00122 }
00123 
00124 QBrush BackgroundAttributes::brush() const
00125 {
00126     return d->brush;
00127 }
00128 
00129 void BackgroundAttributes::setPixmapMode( BackgroundPixmapMode mode )
00130 {
00131     d->pixmapMode = mode;
00132 }
00133 
00134 BackgroundAttributes::BackgroundPixmapMode BackgroundAttributes::pixmapMode() const
00135 {
00136     return d->pixmapMode;
00137 }
00138 
00139 void BackgroundAttributes::setPixmap( const QPixmap &backPixmap )
00140 {
00141     d->pixmap = backPixmap;
00142 }
00143 
00144 QPixmap BackgroundAttributes::pixmap() const
00145 {
00146     return d->pixmap;
00147 }
00148 
00149 #if !defined(QT_NO_DEBUG_STREAM)
00150 QDebug operator<<(QDebug dbg, const KDChart::BackgroundAttributes& ba)
00151 {
00152     dbg << "KDChart::BackgroundAttributes("
00153         << "visible="<<ba.isVisible()
00154         << "brush="<<ba.brush()
00155         << "pixmapmode="<<ba.pixmapMode()
00156         << "pixmap="<<ba.pixmap()
00157         << ")";
00158     return dbg;
00159 }
00160 #endif /* QT_NO_DEBUG_STREAM */

Generated on Thu Mar 4 23:19:10 2010 for KD Chart 2 by  doxygen 1.5.4