]> Git trees. - libqmvoc.git/commitdiff
Use a QColor instead of a QString for the KPlotObject color.
authorPino Toscano <pino@kde.org>
Mon, 31 Oct 2005 09:48:26 +0000 (09:48 +0000)
committerPino Toscano <pino@kde.org>
Mon, 31 Oct 2005 09:48:26 +0000 (09:48 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=476013

kdeeduplot/kplotobject.cpp
kdeeduplot/kplotobject.h
kdeeduplot/kplotwidget.cpp

index 361191d923f6f73b14922f9c683245df1e4c9c44..2ca2780cbff78f62d4f003e6ac79fb627089c922 100644 (file)
 #include "kplotobject.h"
 
 KPlotObject::KPlotObject() {
-       KPlotObject( "", "white", POINTS );
+       KPlotObject( "", Qt::white, POINTS );
 }
 
-KPlotObject::KPlotObject( const QString &n, const QString &c, PTYPE t, unsigned int s, unsigned int p ) {
+KPlotObject::KPlotObject( const QString &n, const QColor &c, PTYPE t, unsigned int s, unsigned int p ) {
        //We use the set functions because they may include data validation
        setName( n );
        setColor( c );
index ae76bf96474f1548508f509377f6939bf1666c79..ae01e442f4c9b03cc40049d7dbdd52faa11d2c25 100644 (file)
@@ -65,7 +65,7 @@ public:
        /**
         * Constructor. Create a KPlotObject according to the arguments.
         */
-       KPlotObject( const QString &name, const QString &color, PTYPE otype, unsigned int size=2, unsigned int param=0 );
+       KPlotObject( const QString &name, const QColor &color, PTYPE otype, unsigned int size=2, unsigned int param=0 );
 
        /**
         * Destructor (empty)
@@ -86,13 +86,13 @@ public:
        /**
         * @return the KPlotObject's Color
         */
-       QString color() const { return Color; }
+       QColor color() const { return Color; }
 
        /**
         * Set the KPlotObject's Color
         * @param c the new color
         */
-       void setColor( const QString &c ) { Color = c; }
+       void setColor( const QColor &c ) { Color = c; }
 
        /**
         * @return the KPlotObject's Type
@@ -170,7 +170,8 @@ private:
        QList<QPointF*> pList;
        PTYPE Type;
        unsigned int Size, Parameter;
-       QString Color, Name;
+       QString Name;
+       QColor Color;
 };
 
 #endif
index bafc0028e42f8cec00e562183781420f58c47548..c17e9a597e7b0fb61c6da5a7ba64d975706d740d 100644 (file)
@@ -159,12 +159,12 @@ void KPlotWidget::drawObjects( QPainter *p ) {
                KPlotObject *po = ( *it );
                if ( po->points()->count() ) {
                        //draw the plot object
-                       p->setPen( QColor( po->color() ) );
+                       p->setPen( po->color() );
 
                        switch ( po->type() ) {
                                case KPlotObject::POINTS :
                                {
-                                       p->setBrush( QColor( po->color() ) );
+                                       p->setBrush( po->color() );
 
                                        for ( QList<QPointF*>::ConstIterator dpit = po->points()->begin(); dpit != po->points()->constEnd(); ++dpit )
                                        {
@@ -186,7 +186,7 @@ void KPlotWidget::drawObjects( QPainter *p ) {
 
                                case KPlotObject::CURVE :
                                {
-                                       p->setPen( QPen( QColor( po->color() ), po->size(), (Qt::PenStyle)po->param() ) );
+                                       p->setPen( QPen( po->color(), po->size(), (Qt::PenStyle)po->param() ) );
                                        QPolygon poly;
                                        for ( QList<QPointF*>::ConstIterator dpit = po->points()->begin(); dpit != po->points()->constEnd(); ++dpit )
                                                poly << mapToPoint( **dpit );
@@ -203,9 +203,8 @@ void KPlotWidget::drawObjects( QPainter *p ) {
 
                                case KPlotObject::POLYGON :
                                {
-                                       QColor co( po->color() );
-                                       p->setPen( QPen( co, po->size(), (Qt::PenStyle)po->param() ) );
-                                       p->setBrush( co );
+                                       p->setPen( QPen( po->color(), po->size(), (Qt::PenStyle)po->param() ) );
+                                       p->setBrush( po->color() );
 
                                        QPolygon a( po->count() );