]> Git trees. - libqmvoc.git/commitdiff
only look for the proper axis only once, not even 3!
authorPino Toscano <pino@kde.org>
Fri, 16 Feb 2007 16:57:25 +0000 (16:57 +0000)
committerPino Toscano <pino@kde.org>
Fri, 16 Feb 2007 16:57:25 +0000 (16:57 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=634221

kdeeduplot/kplotwidget.cpp

index 83a290de9e779fca84da70328fc8d2adad64af3c..5f1be0a817a455a4ee3306519ca6f736bd7f93b8 100644 (file)
@@ -701,42 +701,50 @@ void KPlotWidget::drawAxes( QPainter *p ) {
 
 int KPlotWidget::leftPadding() const
 {
-       if ( d->leftPadding >= 0 ) return d->leftPadding;
-       if ( axis(LeftAxis)->isVisible() && axis(LeftAxis)->showTickLabels() ) {
-               if ( ! axis(LeftAxis)->label().isEmpty() ) return 3*XPADDING;
-               else return 2*XPADDING;
-       }
-       return XPADDING;
+    if ( d->leftPadding >= 0 )
+        return d->leftPadding;
+    const KPlotAxis *a = axis( LeftAxis );
+    if ( a && a->isVisible() && a->showTickLabels() )
+    {
+        return !a->label().isEmpty() ? 3 * XPADDING : 2 * XPADDING;
+    }
+    return XPADDING;
 }
 
 int KPlotWidget::rightPadding() const
 {
-       if ( d->rightPadding >= 0 ) return d->rightPadding;
-       if ( axis(RightAxis)->isVisible() && axis(RightAxis)->showTickLabels() ) {
-               if ( ! axis(RightAxis)->label().isEmpty() ) return 3*XPADDING;
-               else return 2*XPADDING;
-       }
-       return XPADDING;
+    if ( d->rightPadding >= 0 )
+        return d->rightPadding;
+    const KPlotAxis *a = axis( RightAxis );
+    if ( a && a->isVisible() && a->showTickLabels() )
+    {
+        return !a->label().isEmpty() ? 3 * XPADDING : 2 * XPADDING;
+    }
+    return XPADDING;
 }
 
 int KPlotWidget::topPadding() const
 {
-       if ( d->topPadding >= 0 ) return d->topPadding;
-       if ( axis(TopAxis)->isVisible() && axis(TopAxis)->showTickLabels() ) {
-               if ( ! axis(TopAxis)->label().isEmpty() ) return 3*YPADDING;
-               else return 2*YPADDING;
-       }
-       return YPADDING;
+    if ( d->topPadding >= 0 )
+        return d->topPadding;
+    const KPlotAxis *a = axis( TopAxis );
+    if ( a && a->isVisible() && a->showTickLabels() )
+    {
+        return !a->label().isEmpty() ? 3 * YPADDING : 2 * YPADDING;
+    }
+    return YPADDING;
 }
 
 int KPlotWidget::bottomPadding() const
 {
-       if ( d->bottomPadding >= 0 ) return d->bottomPadding;
-       if ( axis(BottomAxis)->isVisible() && axis(BottomAxis)->showTickLabels() ) {
-               if ( ! axis(BottomAxis)->label().isEmpty() ) return 3*YPADDING;
-               else return 2*YPADDING;
-       }
-       return YPADDING;
+    if ( d->bottomPadding >= 0 )
+        return d->bottomPadding;
+    const KPlotAxis *a = axis( BottomAxis );
+    if ( a && a->isVisible() && a->showTickLabels() )
+    {
+        return !a->label().isEmpty() ? 3 * YPADDING : 2 * YPADDING;
+    }
+    return YPADDING;
 }
 
 void KPlotWidget::setLeftPadding( int padding )