From: Pino Toscano Date: Sat, 17 Feb 2007 13:39:33 +0000 (+0000) Subject: API changes: X-Git-Tag: v3.80.3~32 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=4a8e143b1af05b55c8ea447c8f12b61540426220;p=libqmvoc.git API changes: - remove point(int) and count(), just use points() - rename PStyle to PointStyle - CamelCasing the enums svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=634514 --- diff --git a/kdeeduplot/kplotobject.cpp b/kdeeduplot/kplotobject.cpp index 54d73ec..c395254 100644 --- a/kdeeduplot/kplotobject.cpp +++ b/kdeeduplot/kplotobject.cpp @@ -40,7 +40,7 @@ class KPlotObject::Private QList pList; int type; - PStyle pointStyle; + PointStyle pointStyle; double size; QPen pen, linePen, barPen, labelPen; QBrush brush, barBrush; @@ -66,7 +66,7 @@ KPlotPoint::~KPlotPoint() { } -KPlotObject::KPlotObject( const QColor &c, PlotType t, double size, PStyle ps ) +KPlotObject::KPlotObject( const QColor &c, PlotType t, double size, PointStyle ps ) : d( new Private( this ) ) { //By default, all pens and brushes are set to the given color @@ -105,28 +105,28 @@ void KPlotObject::setLabel( int i, const QString &n ) bool KPlotObject::showPoints() const { - return d->type & KPlotObject::POINTS; + return d->type & KPlotObject::Points; } bool KPlotObject::showLines() const { - return d->type & KPlotObject::LINES; + return d->type & KPlotObject::Lines; } bool KPlotObject::showBars() const { - return d->type & KPlotObject::BARS; + return d->type & KPlotObject::Bars; } void KPlotObject::setShowPoints( bool b ) { if ( b ) { - d->type = d->type | KPlotObject::POINTS; + d->type = d->type | KPlotObject::Points; } else { - d->type = d->type & ~KPlotObject::POINTS; + d->type = d->type & ~KPlotObject::Points; } } @@ -134,11 +134,11 @@ void KPlotObject::setShowLines( bool b ) { if ( b ) { - d->type = d->type | KPlotObject::LINES; + d->type = d->type | KPlotObject::Lines; } else { - d->type = d->type & ~KPlotObject::LINES; + d->type = d->type & ~KPlotObject::Lines; } } @@ -146,11 +146,11 @@ void KPlotObject::setShowBars( bool b ) { if ( b ) { - d->type = d->type | KPlotObject::BARS; + d->type = d->type | KPlotObject::Bars; } else { - d->type = d->type & ~KPlotObject::BARS; + d->type = d->type & ~KPlotObject::Bars; } } @@ -164,12 +164,12 @@ void KPlotObject::setSize( double s ) d->size = s; } -unsigned int KPlotObject::pointStyle() const +KPlotObject::PointStyle KPlotObject::pointStyle() const { return d->pointStyle; } -void KPlotObject::setPointStyle( PStyle p ) +void KPlotObject::setPointStyle( PointStyle p ) { d->pointStyle = p; } @@ -267,16 +267,6 @@ void KPlotObject::removePoint( int index ) { d->pList.removeAt( index ); } -KPlotPoint* KPlotObject::point( int index ) -{ - return d->pList[index]; -} - -int KPlotObject::count() const -{ - return d->pList.count(); -} - void KPlotObject::clearPoints() { qDeleteAll( d->pList ); @@ -351,15 +341,15 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) { painter->setBrush( brush() ); switch ( pointStyle() ) { - case CIRCLE: + case Circle: painter->drawEllipse( qr ); break; - case LETTER: + case Letter: painter->drawText( qr, Qt::AlignCenter, pp->label().left(1) ); break; - case TRIANGLE: + case Triangle: { QPolygonF tri; tri << QPointF( q.x() - size(), q.y() + size() ) @@ -369,11 +359,11 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) { break; } - case SQUARE: + case Square: painter->drawRect( qr ); break; - case PENTAGON: + case Pentagon: { QPolygonF pent; pent << QPointF( q.x(), q.y() - size() ) @@ -385,7 +375,7 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) { break; } - case HEXAGON: + case Hexagon: { QPolygonF hex; hex << QPointF( q.x(), q.y() + size() ) @@ -398,7 +388,7 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) { break; } - case ASTERISK: + case Asterisk: painter->drawLine( q, QPointF( q.x(), q.y() + size() ) ); painter->drawLine( q, QPointF( q.x() + size(), q.y() + 0.5*size() ) ); painter->drawLine( q, QPointF( q.x() + size(), q.y() - 0.5*size() ) ); @@ -407,7 +397,7 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) { painter->drawLine( q, QPointF( q.x() - size(), q.y() - 0.5*size() ) ); break; - case STAR: + case Star: { QPolygonF star; star << QPointF( q.x(), q.y() - size() ) diff --git a/kdeeduplot/kplotobject.h b/kdeeduplot/kplotobject.h index 728bcff..d8334d8 100644 --- a/kdeeduplot/kplotobject.h +++ b/kdeeduplot/kplotobject.h @@ -150,7 +150,13 @@ public: * These are bitmask values that can be OR'd together, so that a set * of points can be represented in the plot in multiple ways. */ - enum PlotType { POINTS=1, LINES=2, BARS=4, UNKNOWN_TYPE }; + enum PlotType + { + UnknownType = 0, + Points = 1, + Lines = 2, + Bars = 4 + }; /** * @enum PStyle @@ -164,7 +170,19 @@ public: * @li ASTERISK * @li STAR */ - enum PStyle { NOPOINTS=0, CIRCLE=1, LETTER=2, TRIANGLE=3, SQUARE=4, PENTAGON=5, HEXAGON=6, ASTERISK=7, STAR=8, UNKNOWN_POINT }; + enum PointStyle + { + NoPoints = 0, + Circle = 1, + Letter = 2, + Triangle = 3, + Square = 4, + Pentagon = 5, + Hexagon = 6, + Asterisk = 7, + Star = 8, + UnknwonPoint + }; /** * Constructor. Create a KPlotObject according to the arguments. @@ -175,7 +193,7 @@ public: * @param size the size to use for the drawn points, in pixels * @param ps The PStyle describing the shape for the drawn points */ - explicit KPlotObject( const QColor &color = Qt::white, PlotType otype = POINTS, double size = 2, PStyle ps = CIRCLE ); + explicit KPlotObject( const QColor &color = Qt::white, PlotType otype = Points, double size = 2, PointStyle ps = Circle ); /** * Destructor. @@ -240,13 +258,13 @@ public: /** * @return the KPlotObject's PointStyle value */ - unsigned int pointStyle() const; + PointStyle pointStyle() const; /** * Set the KPlotObject's type-specific Parameter * @param p the new parameter */ - void setPointStyle( PStyle p ); + void setPointStyle( PointStyle p ); /** * @return the default pen for this Object. @@ -346,17 +364,6 @@ public: */ void removePoint( int index ); - /** - * @return a pointer to the KPlotPoint at the given position in the list - * @param index the index of the point in the list - */ - KPlotPoint* point( int index ); - - /** - * @return the number of QPoints currently in the list - */ - int count() const; - /** * Clear the Object's points list */ diff --git a/kdeeduplot/tests/testplot_widget.cpp b/kdeeduplot/tests/testplot_widget.cpp index c637338..df3d5cd 100644 --- a/kdeeduplot/tests/testplot_widget.cpp +++ b/kdeeduplot/tests/testplot_widget.cpp @@ -58,8 +58,8 @@ void TestPlot::slotSelectPlot( int n ) { { plot->setLimits( -6.0, 11.0, -10.0, 110.0 ); - po1 = new KPlotObject( Qt::white, KPlotObject::POINTS, 4, KPlotObject::ASTERISK ); - po2 = new KPlotObject( Qt::green, KPlotObject::POINTS, 4, KPlotObject::TRIANGLE ); + po1 = new KPlotObject( Qt::white, KPlotObject::Points, 4, KPlotObject::Asterisk ); + po2 = new KPlotObject( Qt::green, KPlotObject::Points, 4, KPlotObject::Triangle ); for ( float x=-5.0; x<=10.0; x+=1.0 ) { po1->addPoint( x, x*x ); @@ -81,8 +81,8 @@ void TestPlot::slotSelectPlot( int n ) { plot->axis(KPlotWidget::BottomAxis)->setLabel("Angle [radians]"); plot->axis(KPlotWidget::TopAxis)->setLabel("Angle [degrees]"); - po1 = new KPlotObject( Qt::red, KPlotObject::LINES, 2 ); - po2 = new KPlotObject( Qt::cyan, KPlotObject::LINES, 2 ); + po1 = new KPlotObject( Qt::red, KPlotObject::Lines, 2 ); + po2 = new KPlotObject( Qt::cyan, KPlotObject::Lines, 2 ); for ( float t=0.0; t<=6.28; t+=0.04 ) { po1->addPoint( t, sin(t) ); @@ -100,7 +100,7 @@ void TestPlot::slotSelectPlot( int n ) { { plot->setLimits( -7.0, 7.0, -5.0, 105.0 ); - po1 = new KPlotObject( Qt::white, KPlotObject::BARS, 2 ); + po1 = new KPlotObject( Qt::white, KPlotObject::Bars, 2 ); po1->setBarBrush( QBrush(Qt::green, Qt::Dense4Pattern) ); for ( float x=-6.5; x<=6.5; x+=0.5 ) { @@ -117,7 +117,7 @@ void TestPlot::slotSelectPlot( int n ) { { plot->setLimits( -1.1, 1.1, -1.1, 1.1 ); - po1 = new KPlotObject( Qt::yellow, KPlotObject::POINTS, 10, KPlotObject::STAR ); + po1 = new KPlotObject( Qt::yellow, KPlotObject::Points, 10, KPlotObject::Star ); po1->setLabelPen( QPen(Qt::green) ); po1->addPoint( 0.0, 0.8, "North" ); @@ -139,7 +139,7 @@ void TestPlot::slotSelectPlot( int n ) { { plot->setLimits( -2.1, 2.1, -0.1, 4.1 ); - po1 = new KPlotObject( Qt::white, KPlotObject::POINTS, 10, KPlotObject::PENTAGON ); + po1 = new KPlotObject( Qt::white, KPlotObject::Points, 10, KPlotObject::Pentagon ); po1->setShowLines( true ); po1->setShowBars( true ); @@ -166,7 +166,7 @@ void TestPlot::slotSelectPlot( int n ) { { plot->setLimits( -2.1, 2.1, -0.1, 4.1 ); - po1 = new KPlotObject( Qt::white, KPlotObject::POINTS, 10, KPlotObject::PENTAGON ); + po1 = new KPlotObject( Qt::white, KPlotObject::Points, 10, KPlotObject::Pentagon ); po1->setShowLines( true ); po1->setShowBars( true );