]> Git trees. - libqmvoc.git/commitdiff
API change: move the axis in the Private class
authorPino Toscano <pino@kde.org>
Fri, 16 Feb 2007 17:10:21 +0000 (17:10 +0000)
committerPino Toscano <pino@kde.org>
Fri, 16 Feb 2007 17:10:21 +0000 (17:10 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=634230

kdeeduplot/kplotwidget.cpp
kdeeduplot/kplotwidget.h

index 5f1be0a817a455a4ee3306519ca6f736bd7f93b8..6d987e5ca69c2474c67e0548059cd114f16ea4dd 100644 (file)
@@ -46,6 +46,22 @@ class KPlotWidget::Private
             cBackground( Qt::white ), cForeground( Qt::white ), cGrid( Qt::gray ),
             showGrid( false ), showObjectToolTips( true ), useAntialias( false )
         {
+            // create the axes and setting their default properties
+            KPlotAxis *leftAxis = new KPlotAxis();
+            leftAxis->setShowTickLabels( true );
+            axes.insert( LeftAxis, leftAxis );
+            KPlotAxis *bottomAxis = new KPlotAxis();
+            bottomAxis->setShowTickLabels( true );
+            axes.insert( BottomAxis, bottomAxis );
+            KPlotAxis *rightAxis = new KPlotAxis();
+            axes.insert( RightAxis, rightAxis );
+            KPlotAxis *topAxis = new KPlotAxis();
+            axes.insert( TopAxis, topAxis );
+        }
+
+        Private()
+        {
+            qDeleteAll( axes );
         }
 
         KPlotWidget *q;
@@ -56,6 +72,8 @@ class KPlotWidget::Private
         bool showGrid, showObjectToolTips, useAntialias;
         //padding
         int leftPadding, rightPadding, topPadding, bottomPadding;
+        // hashmap with the axes we have
+        QHash<Axis, KPlotAxis*> axes;
 };
 
 KPlotWidget::KPlotWidget( QWidget *parent, double x1, double x2, double y1, double y2 )
@@ -63,20 +81,10 @@ KPlotWidget::KPlotWidget( QWidget *parent, double x1, double x2, double y1, doub
 {
        setAttribute( Qt::WA_NoBackground, true );
 
-       // create the axes
-       mAxes[LeftAxis] = new KPlotAxis();
-       mAxes[BottomAxis] = new KPlotAxis();
-       mAxes[RightAxis] = new KPlotAxis();
-       mAxes[TopAxis] = new KPlotAxis();
-
        //set DataRect
        setLimits( x1, x2, y1, y2 );
        SecondDataRect = QRect(); //default: no secondary data rect
 
-       //By default, the left and bottom axes have tickmark labels
-       axis(LeftAxis)->setShowTickLabels( true );
-       axis(BottomAxis)->setShowTickLabels( true );
-
        setDefaultPaddings();
 
        setMinimumSize( 150, 150 );
@@ -86,8 +94,6 @@ KPlotWidget::~KPlotWidget()
 {
        qDeleteAll( ObjectList );
        ObjectList.clear();
-       qDeleteAll( mAxes );
-       mAxes.clear();
 
     delete d;
 }
@@ -273,14 +279,14 @@ void KPlotWidget::setShowObjectToolTips( bool show )
 
 
 KPlotAxis* KPlotWidget::axis( Axis a ) {
-    QHash<Axis, KPlotAxis*>::Iterator it = mAxes.find( a );
-    return it != mAxes.end() ? it.value() : 0;
+    QHash<Axis, KPlotAxis*>::Iterator it = d->axes.find( a );
+    return it != d->axes.end() ? it.value() : 0;
 }
 
 const KPlotAxis* KPlotWidget::axis( Axis a ) const
 {
-    QHash<Axis, KPlotAxis*>::ConstIterator it = mAxes.find( a );
-    return it != mAxes.end() ? it.value() : 0;
+    QHash<Axis, KPlotAxis*>::ConstIterator it = d->axes.find( a );
+    return it != d->axes.end() ? it.value() : 0;
 }
 
 QList<KPlotPoint*> KPlotWidget::pointsUnderPoint( const QPoint& p ) const {
index 3b6a8fade8b87c7bd30947d70c30397c2ede25b4..c0b5d5a15b7560be72c0bd6a11491cece96a0ccc 100644 (file)
@@ -445,11 +445,6 @@ protected:
         */
        QList<KPlotObject*> ObjectList;
 
-       /**
-        * Hashmap with the axes we have
-        */
-       QHash<Axis, KPlotAxis*> mAxes;
-
        //Grid of bools to mask "used" regions of the plot
        float PlotMask[100][100];
        double px[100], py[100];