From 1b2e5b017fadffd5bce18254f467f4421a4ce97a Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 16 Feb 2007 16:57:25 +0000 Subject: [PATCH] only look for the proper axis only once, not even 3! svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=634221 --- kdeeduplot/kplotwidget.cpp | 56 ++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/kdeeduplot/kplotwidget.cpp b/kdeeduplot/kplotwidget.cpp index 83a290d..5f1be0a 100644 --- a/kdeeduplot/kplotwidget.cpp +++ b/kdeeduplot/kplotwidget.cpp @@ -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 ) -- 2.47.3