From dafd505adf9557d1c09a6a35d9c33fa7329be86a Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sat, 17 Feb 2007 14:10:34 +0000 Subject: [PATCH] API change: - move all the private stuff of KPlotPoint to the Private class svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=634529 --- kdeeduplot/kplotobject.cpp | 78 +++++++++++++++++++++++++++++++++++--- kdeeduplot/kplotobject.h | 33 ++++++++-------- 2 files changed, 90 insertions(+), 21 deletions(-) diff --git a/kdeeduplot/kplotobject.cpp b/kdeeduplot/kplotobject.cpp index c395254..2959ed1 100644 --- a/kdeeduplot/kplotobject.cpp +++ b/kdeeduplot/kplotobject.cpp @@ -23,6 +23,22 @@ #include "kplotobject.h" #include "kplotwidget.h" +class KPlotPoint::Private +{ + public: + Private( KPlotPoint * qq, const QPointF &p, const QString &l, double bw ) + : q( qq ), point( p ), label( l ), barWidth( bw ) + { + } + + KPlotPoint *q; + + QPointF point; + QString label; + double barWidth; +}; + + class KPlotObject::Private { public: @@ -48,24 +64,76 @@ class KPlotObject::Private KPlotPoint::KPlotPoint() - : X(0), Y(0), Label(QString()), BarWidth(0.0) + : d( new Private( this, QPointF(), QString(), 0.0 ) ) { } -KPlotPoint::KPlotPoint( double x, double y, const QString &label, double barWidth ) - : X( x ), Y( y ), Label( label ), BarWidth( barWidth ) +KPlotPoint::KPlotPoint( double x, double y, const QString &label, double barWidth ) + : d( new Private( this, QPointF( x, y ), label, barWidth ) ) { } KPlotPoint::KPlotPoint( const QPointF &p, const QString &label, double barWidth ) - : X( p.x() ), Y( p.y() ), Label( label ), BarWidth( barWidth ) + : d( new Private( this, p, label, barWidth ) ) { } -KPlotPoint::~KPlotPoint() +KPlotPoint::~KPlotPoint() { + delete d; } +QPointF KPlotPoint::position() const +{ + return d->point; +} + +void KPlotPoint::setPosition( const QPointF &pos ) +{ + d->point = pos; +} + +double KPlotPoint::x() const +{ + return d->point.x(); +} + +void KPlotPoint::setX( double x ) +{ + d->point.setX( x ); +} + +double KPlotPoint::y() const +{ + return d->point.y(); +} + +void KPlotPoint::setY( double y ) +{ + d->point.setY( y ); +} + +QString KPlotPoint::label() const +{ + return d->label; +} + +void KPlotPoint::setLabel( const QString &label ) +{ + d->label = label; +} + +double KPlotPoint::barWidth() const +{ + return d->barWidth; +} + +void KPlotPoint::setBarWidth( double w ) +{ + d->barWidth = w; +} + + KPlotObject::KPlotObject( const QColor &c, PlotType t, double size, PointStyle ps ) : d( new Private( this ) ) { diff --git a/kdeeduplot/kplotobject.h b/kdeeduplot/kplotobject.h index d8334d8..d685fcb 100644 --- a/kdeeduplot/kplotobject.h +++ b/kdeeduplot/kplotobject.h @@ -44,7 +44,7 @@ class KDEEDUPLOT_EXPORT KPlotPoint { /** *Default constructor. */ - KPlotPoint(); + explicit KPlotPoint(); /** * Constructor. Sets the KPlotPoint according to the given arguments * @param x the X-position for the point, in Data units @@ -54,7 +54,7 @@ class KDEEDUPLOT_EXPORT KPlotPoint { * @param width the BarWidth to use for this point (only used for * plots of type KPlotObject::BARS) */ - KPlotPoint( double x, double y, const QString &label="", double width=0.0 ); + KPlotPoint( double x, double y, const QString &label = QString(), double width = 0.0 ); /** * Constructor. Sets the KPlotPoint according to the given arguments * @param p the position for the point, in Data units @@ -63,7 +63,7 @@ class KDEEDUPLOT_EXPORT KPlotPoint { * @param width the BarWidth to use for this point (only used for * plots of type KPlotObject::BARS) */ - KPlotPoint( const QPointF &p, const QString &label="", double width=0.0 ); + explicit KPlotPoint( const QPointF &p, const QString &label = QString(), double width = 0.0 ); /** * Destructor */ @@ -72,51 +72,52 @@ class KDEEDUPLOT_EXPORT KPlotPoint { /** * @return the position of the point, in data units */ - QPointF position() const { return QPointF( X, Y ); } + QPointF position() const; /** * Set the position of the point, in data units * @param pos the new position for the point. */ - void setPosition( const QPointF &pos ) { X = pos.x(); Y = pos.y(); } + void setPosition( const QPointF &pos ); /** * @return the X-position of the point, in data units */ - double x() const { return X; } + double x() const; /** * Set the X-position of the point, in Data units */ - void setX( double x ) { X = x; } + void setX( double x ); /** * @return the Y-position of the point, in data units */ - double y() const { return Y; } + double y() const; /** * Set the Y-position of the point, in Data units */ - void setY( double y ) { Y = y; } + void setY( double y ); /** * @return the label for the point */ - const QString& label() const { return Label; } + QString label() const; /** * Set the label for the point */ - void setLabel( const QString &label ) { Label = label; } + void setLabel( const QString &label ); /** * @return the bar-width for the point */ - double barWidth() const { return BarWidth; } + double barWidth() const; /** * Set the bar-width for the point */ - void setBarWidth( double w ) { BarWidth = w; } + void setBarWidth( double w ); private: - double X, Y; - QString Label; - double BarWidth; + class Private; + Private * const d; + + Q_DISABLE_COPY( KPlotPoint ) }; /** -- 2.47.3