From f4427db93e7012211be282278b95a4b7fd3529bb Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Fri, 23 Oct 2009 10:32:19 +0000 Subject: [PATCH] server logging: use thicker grid lines for weekends in history graph --- src/serverlogging.cpp | 30 +++++++++++++++++++++++------- src/serverlogging.h | 1 + 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/serverlogging.cpp b/src/serverlogging.cpp index 028e4ef4..b5820107 100755 --- a/src/serverlogging.cpp +++ b/src/serverlogging.cpp @@ -36,6 +36,7 @@ CHistoryGraph::CHistoryGraph() : iYAxisEnd ( 24 ), iNumTicksY ( 5 ), iGridFrameOffset ( 10 ), + iGridWidthWeekend ( 4 ), // should be even iTextOffsetToGrid ( 3 ), iXAxisTextHeight ( 22 ), iMarkerSizeNewCon ( 11 ), @@ -116,8 +117,9 @@ void CHistoryGraph::DrawFrame ( const int iNewNumTicksX ) iXSpace = PlotGridFrame.width() / ( iNumTicksX + 1 ); for ( i = 0; i < iNumTicksX; i++ ) { - int iBottomExtraTickLen = 0; - const int iCurX = PlotGridFrame.x() + iXSpace * ( i + 1 ); + int iBottomExtraTickLen = 0; + const int iCurX = PlotGridFrame.x() + iXSpace * ( i + 1 ); + const QDate curXAxisDate = curDate.addDays ( i - iNumTicksX + 1 ); // text (print only every "iXAxisTickStep" tick) if ( !( i % iXAxisTickStep ) ) @@ -127,15 +129,29 @@ void CHistoryGraph::DrawFrame ( const int iNewNumTicksX ) PlotPainter.drawText ( QPoint ( iCurX - iTextOffsetX, PlotGridFrame.bottom() + iXAxisTextHeight + iTextOffsetToGrid ), - curDate.addDays ( i - iNumTicksX + 1 ).toString ( "dd.MM." ) ); + curXAxisDate.toString ( "dd.MM." ) ); iBottomExtraTickLen = 5; } - // grid - PlotPainter.setPen ( PlotGridColor ); - PlotPainter.drawLine ( iCurX, PlotGridFrame.y(), - iCurX, PlotGridFrame.bottom() + iBottomExtraTickLen ); + // grid (different grid width for weekends) + if ( ( curXAxisDate.dayOfWeek() == 6 ) || + ( curXAxisDate.dayOfWeek() == 7 ) ) + { + const int iGridWidthWeekendHalf = iGridWidthWeekend / 2; + + PlotPainter.setPen ( QPen ( PlotGridColor, iGridWidthWeekend ) ); + PlotPainter.drawLine ( iCurX, 1 + PlotGridFrame.y() + iGridWidthWeekendHalf, + iCurX, PlotGridFrame.bottom() - iGridWidthWeekendHalf + 1 + + iBottomExtraTickLen ); + } + else + { + // regular grid + PlotPainter.setPen ( PlotGridColor ); + PlotPainter.drawLine ( iCurX, 1 + PlotGridFrame.y(), + iCurX, PlotGridFrame.bottom() + iBottomExtraTickLen ); + } } // grid (ticks) for y-axis, draw iNumTicksY - 2 grid lines and diff --git a/src/serverlogging.h b/src/serverlogging.h index 1399896b..45d7189b 100755 --- a/src/serverlogging.h +++ b/src/serverlogging.h @@ -76,6 +76,7 @@ protected: int iNumTicksX; int iNumTicksY; int iGridFrameOffset; + int iGridWidthWeekend; int iTextOffsetToGrid; int iTextOffsetX; int iXAxisTextHeight;