code style changes

This commit is contained in:
Volker Fischer 2019-05-27 18:04:24 +02:00
parent 4deae974c3
commit d605ef6f9b
3 changed files with 132 additions and 108 deletions

View file

@ -25,12 +25,13 @@
#include "historygraph.h" #include "historygraph.h"
/* Abstract class *************************************************************/ /* Abstract class *************************************************************/
AHistoryGraph::AHistoryGraph() : AHistoryGraph::AHistoryGraph() :
sFileName ( "" ), sFileName ( "" ),
bDoHistory ( false ), bDoHistory ( false ),
vHistoryDataFifo ( NUM_ITEMS_HISTORY ), vHistoryDataFifo ( NUM_ITEMS_HISTORY ),
iNumTicksX ( 0 ), // number of days in history iNumTicksX ( 0 ), // number of days in history
BackgroundColor ( "white" ), // background BackgroundColor ( "white" ), // background
FrameColor ( "black" ), // frame FrameColor ( "black" ), // frame
@ -40,41 +41,42 @@ AHistoryGraph::AHistoryGraph() :
MarkerNewLocalColor ( "blue" ), // marker for new local connection MarkerNewLocalColor ( "blue" ), // marker for new local connection
MarkerStopColor ( "red" ), // marker for server stop MarkerStopColor ( "red" ), // marker for server stop
canvasRectX ( 0 ), canvasRectX ( 0 ),
canvasRectY ( 0 ), canvasRectY ( 0 ),
canvasRectWidth ( 640 ), canvasRectWidth ( 640 ),
canvasRectHeight ( 450 ), canvasRectHeight ( 450 ),
iGridFrameOffset ( 10 ), iGridFrameOffset ( 10 ),
iGridWidthWeekend ( 3 ), // should be an odd value iGridWidthWeekend ( 3 ), // should be an odd value
iXAxisTextHeight ( 22 ), iXAxisTextHeight ( 22 ),
gridFrameX ( canvasRectX + iGridFrameOffset ), gridFrameX ( canvasRectX + iGridFrameOffset ),
gridFrameY ( canvasRectY + iGridFrameOffset ), gridFrameY ( canvasRectY + iGridFrameOffset ),
gridFrameWidth ( canvasRectWidth - 2 * iGridFrameOffset ), gridFrameWidth ( canvasRectWidth - 2 * iGridFrameOffset ),
gridFrameHeight ( canvasRectHeight - 2 * iGridFrameOffset - iXAxisTextHeight ), gridFrameHeight ( canvasRectHeight - 2 * iGridFrameOffset - iXAxisTextHeight ),
gridFrameRight ( gridFrameX + gridFrameWidth - 1 ), gridFrameRight ( gridFrameX + gridFrameWidth - 1 ),
gridFrameBottom ( gridFrameY + gridFrameHeight - 1 ), gridFrameBottom ( gridFrameY + gridFrameHeight - 1 ),
axisFontFamily ( "Arial" ), axisFontFamily ( "Arial" ),
axisFontWeight ( "100" ), axisFontWeight ( "100" ),
axisFontSize ( 12 ), axisFontSize ( 12 ),
iYAxisStart ( 0 ), iYAxisStart ( 0 ),
iYAxisEnd ( 24 ), iYAxisEnd ( 24 ),
iNumTicksY ( 5 ), iNumTicksY ( 5 ),
iTextOffsetToGrid ( 3 ), iTextOffsetToGrid ( 3 ),
iTextOffsetX ( 18 ), iTextOffsetX ( 18 ),
iMarkerSizeNewCon ( 11 ), iMarkerSizeNewCon ( 11 ),
iMarkerSizeServSt ( 8 ) iMarkerSizeServSt ( 8 )
{ {
} }
void AHistoryGraph::Start ( const QString& sNewFileName ) void AHistoryGraph::Start ( const QString& sNewFileName )
{ {
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() ); QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
tsConsoleStream << QString("AHistoryGraph::Start ( %1 )").arg(sNewFileName) << endl; // on console tsConsoleStream << QString ( "AHistoryGraph::Start ( %1 )" ).arg ( sNewFileName ) << endl; // on console
if ( !sNewFileName.isEmpty() ) if ( !sNewFileName.isEmpty() )
{ {
// save file name // save file name
@ -134,8 +136,9 @@ void AHistoryGraph::Update ( )
curDate = QDate::currentDate(); curDate = QDate::currentDate();
// get oldest date in history // get oldest date in history
QDate oldestDate = curDate.addDays ( 1 ); // one day in the future QDate oldestDate = curDate.addDays ( 1 ); // one day in the future
const int iNumItemsForHistory = vHistoryDataFifo.Size(); const int iNumItemsForHistory = vHistoryDataFifo.Size();
for ( i = 0; i < iNumItemsForHistory; i++ ) for ( i = 0; i < iNumItemsForHistory; i++ )
{ {
// only use valid dates // only use valid dates
@ -190,22 +193,23 @@ void AHistoryGraph::DrawFrame ( const int iNewNumTicksX )
// grid (ticks) for x-axis // grid (ticks) for x-axis
dayXSpace = static_cast<double> ( gridFrameWidth ) / ( iNumTicksX + 1 ); dayXSpace = static_cast<double> ( gridFrameWidth ) / ( iNumTicksX + 1 );
for ( i = 0; i < static_cast<int>(iNumTicksX); i++ )
for ( i = 0; i < static_cast<int> ( iNumTicksX ); i++ )
{ {
int iBottomExtraTickLen = 0; int iBottomExtraTickLen = 0;
const int iCurX = gridFrameX + static_cast<int> ( dayXSpace * ( i + 1 ) ); const int iCurX = gridFrameX + static_cast<int> ( dayXSpace * ( i + 1 ) );
const QDate curXAxisDate = curDate.addDays ( 0 - static_cast<signed>( iNumTicksX ) + i + 1 ); const QDate curXAxisDate = curDate.addDays ( 0 - static_cast<signed> ( iNumTicksX ) + i + 1 );
// text (print only every "iXAxisTickStep" tick) // text (print only every "iXAxisTickStep" tick)
if ( !( i % iXAxisTickStep ) ) if ( !( i % iXAxisTickStep ) )
{ {
text( iCurX - iTextOffsetX, gridFrameBottom + iXAxisTextHeight + iTextOffsetToGrid, curXAxisDate.toString ( "dd.MM." ) ); text ( iCurX - iTextOffsetX, gridFrameBottom + iXAxisTextHeight + iTextOffsetToGrid, curXAxisDate.toString ( "dd.MM." ) );
iBottomExtraTickLen = 5; iBottomExtraTickLen = 5;
} }
// regular grid // regular grid
line( iCurX, 1 + gridFrameY, iCurX, gridFrameBottom + iBottomExtraTickLen ); line ( iCurX, 1 + gridFrameY, iCurX, gridFrameBottom + iBottomExtraTickLen );
// different grid width for weekends (overwrite regular grid) // different grid width for weekends (overwrite regular grid)
if ( ( curXAxisDate.dayOfWeek() == 6 ) || // check for Saturday if ( ( curXAxisDate.dayOfWeek() == 6 ) || // check for Saturday
@ -213,26 +217,27 @@ void AHistoryGraph::DrawFrame ( const int iNewNumTicksX )
{ {
const int iGridWidthWeekendHalf = iGridWidthWeekend / 2; const int iGridWidthWeekendHalf = iGridWidthWeekend / 2;
line( iCurX, 1 + gridFrameY + iGridWidthWeekendHalf, iCurX, gridFrameBottom - iGridWidthWeekendHalf, iGridWidthWeekend ); line ( iCurX, 1 + gridFrameY + iGridWidthWeekendHalf, iCurX, gridFrameBottom - iGridWidthWeekendHalf, iGridWidthWeekend );
} }
} }
// grid (ticks) for y-axis, draw iNumTicksY - 2 grid lines and // grid (ticks) for y-axis, draw iNumTicksY - 2 grid lines and
// iNumTicksY - 1 text labels (the lowest grid line is the grid frame) // iNumTicksY - 1 text labels (the lowest grid line is the grid frame)
iYSpace = gridFrameHeight / ( iNumTicksY - 1 ); iYSpace = gridFrameHeight / ( iNumTicksY - 1 );
for ( i = 0; i < ( static_cast<int>(iNumTicksY) - 1 ); i++ )
for ( i = 0; i < ( static_cast<int> ( iNumTicksY ) - 1 ); i++ )
{ {
const int iCurY = gridFrameY + iYSpace * ( i + 1 ); const int iCurY = gridFrameY + iYSpace * ( i + 1 );
// text // text
text( gridFrameX + iTextOffsetToGrid, text ( gridFrameX + iTextOffsetToGrid,
iCurY - iTextOffsetToGrid, iCurY - iTextOffsetToGrid,
QString ( "%1:00" ).arg ( ( iYAxisEnd - iYAxisStart ) / ( iNumTicksY - 1 ) * ( ( iNumTicksY - 2 ) - i ) ) ); QString ( "%1:00" ).arg ( ( iYAxisEnd - iYAxisStart ) / ( iNumTicksY - 1 ) * ( ( iNumTicksY - 2 ) - i ) ) );
// grid (do not overwrite frame) // grid (do not overwrite frame)
if ( i < ( static_cast<int>(iNumTicksY) - 2 ) ) if ( i < ( static_cast<int> ( iNumTicksY ) - 2 ) )
{ {
line( gridFrameX, iCurY, gridFrameRight, iCurY ); line ( gridFrameX, iCurY, gridFrameRight, iCurY );
} }
} }
} }
@ -245,7 +250,7 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
curDate.daysTo ( curHistoryData.DateTime.date() ); curDate.daysTo ( curHistoryData.DateTime.date() );
// check range, if out of range, do not plot anything // check range, if out of range, do not plot anything
if ( -iXAxisOffs > ( static_cast<signed>( iNumTicksX ) - 1 ) ) if ( -iXAxisOffs > ( static_cast<signed> ( iNumTicksX ) - 1 ) )
{ {
return; return;
} }
@ -255,18 +260,19 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
static_cast<double> ( curHistoryData.DateTime.time().minute() ) / 60; static_cast<double> ( curHistoryData.DateTime.time().minute() ) / 60;
// calculate the actual point in the graph (in pixels) // calculate the actual point in the graph (in pixels)
int curPointX = gridFrameX + static_cast<int> ( dayXSpace * ( static_cast<signed>( iNumTicksX ) + iXAxisOffs ) ); int curPointX = gridFrameX + static_cast<int> ( dayXSpace * ( static_cast<signed> ( iNumTicksX ) + iXAxisOffs ) );
int curPointY = gridFrameY + static_cast<int> ( static_cast<double> ( int curPointY = gridFrameY + static_cast<int> ( static_cast<double> (
gridFrameHeight ) / ( iYAxisEnd - iYAxisStart ) * dYAxisOffs ); gridFrameHeight ) / ( iYAxisEnd - iYAxisStart ) * dYAxisOffs );
QString curPointColour = MarkerNewColor; QString curPointColour = MarkerNewColor;
int curPointSize = iMarkerSizeNewCon; int curPointSize = iMarkerSizeNewCon;
// we use different markers for new connection and server stop items // we use different markers for new connection and server stop items
switch ( curHistoryData.Type ) switch ( curHistoryData.Type )
{ {
case HIT_SERVER_STOP: case HIT_SERVER_STOP:
curPointColour = MarkerStopColor; curPointColour = MarkerStopColor;
curPointSize = iMarkerSizeServSt; curPointSize = iMarkerSizeServSt;
break; break;
case HIT_LOCAL_CONNECTION: case HIT_LOCAL_CONNECTION:
@ -278,9 +284,10 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
break; break;
} }
point( curPointX - curPointSize / 2, curPointY - curPointSize / 2, curPointSize, curPointColour ); point ( curPointX - curPointSize / 2, curPointY - curPointSize / 2, curPointSize, curPointColour );
} }
/* JPEG History Graph implementation ******************************************/ /* JPEG History Graph implementation ******************************************/
CJpegHistoryGraph::CJpegHistoryGraph() : CJpegHistoryGraph::CJpegHistoryGraph() :
AHistoryGraph(), AHistoryGraph(),
@ -302,28 +309,36 @@ CJpegHistoryGraph::CJpegHistoryGraph() :
// Black = 87 // 900 // Black = 87 // 900
bool ok; bool ok;
int weight = axisFontWeight.toInt( &ok ); int weight = axisFontWeight.toInt( &ok );
if (!ok)
if ( !ok )
{ {
if (!QString("normal").compare(axisFontWeight, Qt::CaseSensitivity::CaseInsensitive)) { iAxisFontWeight = 50; } if ( !QString ( "normal" ).compare ( axisFontWeight, Qt::CaseSensitivity::CaseInsensitive ) )
else if (!QString("bold").compare(axisFontWeight, Qt::CaseSensitivity::CaseInsensitive)) { weight = 75; } {
iAxisFontWeight = 50;
}
else if ( !QString ( "bold" ).compare ( axisFontWeight, Qt::CaseSensitivity::CaseInsensitive ) )
{
weight = 75;
}
} }
else else
{ {
if (weight <= 100) { iAxisFontWeight = 0; } if ( weight <= 100 ) { iAxisFontWeight = 0; }
else if (weight <= 200) { iAxisFontWeight = 12; } else if ( weight <= 200 ) { iAxisFontWeight = 12; }
else if (weight <= 300) { iAxisFontWeight = 25; } else if ( weight <= 300 ) { iAxisFontWeight = 25; }
else if (weight <= 400) { iAxisFontWeight = 50; } else if ( weight <= 400 ) { iAxisFontWeight = 50; }
else if (weight <= 500) { iAxisFontWeight = 57; } else if ( weight <= 500 ) { iAxisFontWeight = 57; }
else if (weight <= 600) { iAxisFontWeight = 63; } else if ( weight <= 600 ) { iAxisFontWeight = 63; }
else if (weight <= 700) { iAxisFontWeight = 75; } else if ( weight <= 700 ) { iAxisFontWeight = 75; }
else if (weight <= 800) { iAxisFontWeight = 81; } else if ( weight <= 800 ) { iAxisFontWeight = 81; }
else if (weight <= 900) { iAxisFontWeight = 87; } else if ( weight <= 900 ) { iAxisFontWeight = 87; }
} }
// if all else fails, it's left at -1 // if all else fails, it's left at -1
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() ); QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
tsConsoleStream << "CJpegHistoryGraph" << endl; // on console tsConsoleStream << "CJpegHistoryGraph" << endl; // on console
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ), QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
this, SLOT ( OnTimerDailyUpdate() ) ); this, SLOT ( OnTimerDailyUpdate() ) );
@ -359,7 +374,7 @@ void CJpegHistoryGraph::text ( const unsigned int x, const unsigned int y, const
QPainter PlotPainter ( &PlotPixmap ); QPainter PlotPainter ( &PlotPixmap );
PlotPainter.setPen ( TextColor ); PlotPainter.setPen ( TextColor );
// QFont(const QString &family, int pointSize = -1, int weight = -1, bool italic = false); // QFont(const QString &family, int pointSize = -1, int weight = -1, bool italic = false);
PlotPainter.setFont ( QFont( axisFontFamily, static_cast<int>(axisFontSize), iAxisFontWeight ) ); PlotPainter.setFont ( QFont( axisFontFamily, static_cast<int> ( axisFontSize ), iAxisFontWeight ) );
PlotPainter.drawText ( QPoint ( x, y ), value ); PlotPainter.drawText ( QPoint ( x, y ), value );
} }
@ -377,27 +392,29 @@ void CJpegHistoryGraph::point ( const unsigned int x, const unsigned int y, cons
PlotPainter.drawPoint ( x, y ); PlotPainter.drawPoint ( x, y );
} }
/* SVG History Graph implementation *******************************************/ /* SVG History Graph implementation *******************************************/
CSvgHistoryGraph::CSvgHistoryGraph() : CSvgHistoryGraph::CSvgHistoryGraph() :
AHistoryGraph(), AHistoryGraph(),
svgImage( "" ), svgImage ( "" ),
svgStreamWriter( &svgImage ) svgStreamWriter ( &svgImage )
{ {
// set SVG veiwBox to correct size to ensure correct scaling // set SVG veiwBox to correct size to ensure correct scaling
svgRootAttributes.append("viewBox", svgRootAttributes.append ( "viewBox",
QString("%1, %2, %3, %4") QString ( "%1, %2, %3, %4" )
.arg(canvasRectX) .arg ( canvasRectX )
.arg(canvasRectY) .arg ( canvasRectY )
.arg(canvasRectWidth) .arg ( canvasRectWidth )
.arg(canvasRectHeight) .arg ( canvasRectHeight )
); );
svgRootAttributes.append("xmlns", "http://www.w3.org/2000/svg"); svgRootAttributes.append ( "xmlns", "http://www.w3.org/2000/svg" );
svgRootAttributes.append("xmlns:xlink", "http://www.w3.org/1999/xlink"); svgRootAttributes.append ( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() ); QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
tsConsoleStream << "CSvgHistoryGraph" << endl; // on console tsConsoleStream << "CSvgHistoryGraph" << endl; // on console
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ), QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
this, SLOT ( OnTimerDailyUpdate() ) ); this, SLOT ( OnTimerDailyUpdate() ) );
@ -411,10 +428,10 @@ void CSvgHistoryGraph::Update()
// create SVG document // create SVG document
svgImage = ""; svgImage = "";
svgStreamWriter.setAutoFormatting(true); svgStreamWriter.setAutoFormatting ( true );
svgStreamWriter.writeStartDocument(); svgStreamWriter.writeStartDocument();
svgStreamWriter.writeStartElement("svg"); svgStreamWriter.writeStartElement ( "svg" );
svgStreamWriter.writeAttributes(svgRootAttributes); svgStreamWriter.writeAttributes ( svgRootAttributes );
AHistoryGraph::Update(); AHistoryGraph::Update();
} }
@ -424,36 +441,38 @@ void CSvgHistoryGraph::Save ( const QString sFileName )
{ {
svgStreamWriter.writeEndDocument(); svgStreamWriter.writeEndDocument();
QFile outf (sFileName); QFile outf ( sFileName );
if (!outf.open(QFile::WriteOnly)) {
throw std::runtime_error( (sFileName + " could not be written. Aborting.").toStdString() ); if ( !outf.open ( QFile::WriteOnly ) )
{
throw std::runtime_error ( ( sFileName + " could not be written. Aborting." ).toStdString() );
} }
QTextStream out(&outf); QTextStream out ( &outf );
out << svgImage << endl; out << svgImage << endl;
} }
void CSvgHistoryGraph::rect ( const unsigned int x, const unsigned int y, const unsigned int width, const unsigned int height ) void CSvgHistoryGraph::rect ( const unsigned int x, const unsigned int y, const unsigned int width, const unsigned int height )
{ {
svgStreamWriter.writeEmptyElement("rect"); svgStreamWriter.writeEmptyElement ( "rect" );
svgStreamWriter.writeAttribute("x", QString("%1").arg(x)); svgStreamWriter.writeAttribute ( "x", QString ( "%1" ).arg ( x ) );
svgStreamWriter.writeAttribute("y", QString("%1").arg(y)); svgStreamWriter.writeAttribute ( "y", QString ( "%1" ).arg ( y ) );
svgStreamWriter.writeAttribute("width", QString("%1").arg(width)); svgStreamWriter.writeAttribute ( "width", QString ( "%1" ).arg ( width ) );
svgStreamWriter.writeAttribute("height", QString("%1").arg(height)); svgStreamWriter.writeAttribute ( "height", QString ( "%1" ).arg ( height ) );
svgStreamWriter.writeAttribute("stroke", FrameColor); svgStreamWriter.writeAttribute ( "stroke", FrameColor );
svgStreamWriter.writeAttribute("stroke-width", QString("1")); svgStreamWriter.writeAttribute ( "stroke-width", QString ( "1" ) );
svgStreamWriter.writeAttribute("style", QString("fill: none;")); svgStreamWriter.writeAttribute ( "style", QString ( "fill: none;" ) );
} }
void CSvgHistoryGraph::text ( const unsigned int x, const unsigned int y, const QString& value ) void CSvgHistoryGraph::text ( const unsigned int x, const unsigned int y, const QString& value )
{ {
svgStreamWriter.writeStartElement("text"); svgStreamWriter.writeStartElement ( "text" );
svgStreamWriter.writeAttribute("x", QString("%1").arg(x)); svgStreamWriter.writeAttribute ( "x", QString ( "%1" ).arg ( x ) );
svgStreamWriter.writeAttribute("y", QString("%1").arg(y)); svgStreamWriter.writeAttribute ( "y", QString ( "%1" ).arg ( y ) );
svgStreamWriter.writeAttribute("stroke", TextColor); svgStreamWriter.writeAttribute ( "stroke", TextColor );
svgStreamWriter.writeAttribute("font-family", axisFontFamily); svgStreamWriter.writeAttribute ( "font-family", axisFontFamily );
svgStreamWriter.writeAttribute("font-weight", axisFontWeight); svgStreamWriter.writeAttribute ( "font-weight", axisFontWeight );
svgStreamWriter.writeAttribute("font-size", QString("%1").arg(axisFontSize)); svgStreamWriter.writeAttribute ( "font-size", QString ( "%1" ).arg ( axisFontSize ) );
svgStreamWriter.writeCharacters( value ); svgStreamWriter.writeCharacters( value );
svgStreamWriter.writeEndElement(); svgStreamWriter.writeEndElement();
@ -461,22 +480,22 @@ void CSvgHistoryGraph::text ( const unsigned int x, const unsigned int y, const
void CSvgHistoryGraph::line ( const unsigned int x1, const unsigned int y1, const unsigned int x2, const unsigned int y2, const unsigned int strokeWidth ) void CSvgHistoryGraph::line ( const unsigned int x1, const unsigned int y1, const unsigned int x2, const unsigned int y2, const unsigned int strokeWidth )
{ {
svgStreamWriter.writeEmptyElement("line"); svgStreamWriter.writeEmptyElement ( "line" );
svgStreamWriter.writeAttribute("x1", QString("%1").arg(x1)); svgStreamWriter.writeAttribute ( "x1", QString ( "%1" ).arg ( x1 ) );
svgStreamWriter.writeAttribute("y1", QString("%1").arg(y1)); svgStreamWriter.writeAttribute ( "y1", QString ( "%1" ).arg ( y1 ) );
svgStreamWriter.writeAttribute("x2", QString("%1").arg(x2)); svgStreamWriter.writeAttribute ( "x2", QString ( "%1" ).arg ( x2 ) );
svgStreamWriter.writeAttribute("y2", QString("%1").arg(y2)); svgStreamWriter.writeAttribute ( "y2", QString ( "%1" ).arg ( y2 ) );
svgStreamWriter.writeAttribute("stroke", GridColor); svgStreamWriter.writeAttribute ( "stroke", GridColor );
svgStreamWriter.writeAttribute("stroke-width", QString("%1").arg(strokeWidth)); svgStreamWriter.writeAttribute ( "stroke-width", QString ( "%1" ).arg ( strokeWidth ) );
} }
void CSvgHistoryGraph::point ( const unsigned int x, const unsigned int y, const unsigned int size, const QString& colour ) void CSvgHistoryGraph::point ( const unsigned int x, const unsigned int y, const unsigned int size, const QString& colour )
{ {
svgStreamWriter.writeEmptyElement("rect"); svgStreamWriter.writeEmptyElement ( "rect" );
svgStreamWriter.writeAttribute("x", QString("%1").arg(x)); svgStreamWriter.writeAttribute ( "x", QString ( "%1" ).arg ( x ) );
svgStreamWriter.writeAttribute("y", QString("%1").arg(y)); svgStreamWriter.writeAttribute ( "y", QString ( "%1" ).arg ( y ) );
svgStreamWriter.writeAttribute("width", QString("%1").arg(size)); svgStreamWriter.writeAttribute ( "width", QString ( "%1" ).arg ( size ) );
svgStreamWriter.writeAttribute("height", QString("%1").arg(size)); svgStreamWriter.writeAttribute ( "height", QString ( "%1" ).arg ( size ) );
svgStreamWriter.writeAttribute("stroke-opacity", "0"); svgStreamWriter.writeAttribute ( "stroke-opacity", "0" );
svgStreamWriter.writeAttribute("fill", colour); svgStreamWriter.writeAttribute ( "fill", colour );
} }

View file

@ -42,10 +42,12 @@
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QXmlStreamAttributes> #include <QXmlStreamAttributes>
/* Definitions ****************************************************************/ /* Definitions ****************************************************************/
// number of history items to store // number of history items to store
#define NUM_ITEMS_HISTORY 600 #define NUM_ITEMS_HISTORY 600
/* Interface ******************************************************************/ /* Interface ******************************************************************/
class AHistoryGraph class AHistoryGraph
{ {
@ -124,12 +126,13 @@ protected:
const unsigned int iMarkerSizeServSt; const unsigned int iMarkerSizeServSt;
// others // others
double dayXSpace; double dayXSpace;
unsigned int iYSpace; unsigned int iYSpace;
QDate curDate; QDate curDate;
QTimer TimerDailyUpdate; QTimer TimerDailyUpdate;
}; };
/* Implementations ************************************************************/ /* Implementations ************************************************************/
class CJpegHistoryGraph : public QObject, virtual public AHistoryGraph class CJpegHistoryGraph : public QObject, virtual public AHistoryGraph
{ {

View file

@ -38,6 +38,7 @@ void CServerLogging::Start ( const QString& strLoggingFileName )
{ {
// open file // open file
File.setFileName ( strLoggingFileName ); File.setFileName ( strLoggingFileName );
if ( File.open ( QIODevice::Append | QIODevice::Text ) ) if ( File.open ( QIODevice::Append | QIODevice::Text ) )
{ {
bDoLogging = true; bDoLogging = true;
@ -46,7 +47,7 @@ void CServerLogging::Start ( const QString& strLoggingFileName )
void CServerLogging::EnableHistory ( const QString& strHistoryFileName ) void CServerLogging::EnableHistory ( const QString& strHistoryFileName )
{ {
if ( strHistoryFileName.right(4).compare(".svg", Qt::CaseInsensitive) == 0 ) if ( strHistoryFileName.right ( 4 ).compare ( ".svg", Qt::CaseInsensitive ) == 0 )
{ {
SvgHistoryGraph.Start ( strHistoryFileName ); SvgHistoryGraph.Start ( strHistoryFileName );
} }
@ -114,7 +115,7 @@ void CServerLogging::ParseLogFile ( const QString& strFileName )
QString strCurLine = inStream.readLine(); QString strCurLine = inStream.readLine();
// parse log file line // parse log file line
QStringList strlistCurLine = strCurLine.split( "," ); QStringList strlistCurLine = strCurLine.split ( "," );
// check number of separated strings condition // check number of separated strings condition
if ( strlistCurLine.size() == 4 ) if ( strlistCurLine.size() == 4 )
@ -135,11 +136,12 @@ void CServerLogging::ParseLogFile ( const QString& strFileName )
// check if server stop or new client connection // check if server stop or new client connection
QString strAddress = strlistCurLine.at ( 2 ).trimmed(); QString strAddress = strlistCurLine.at ( 2 ).trimmed();
if ( strAddress.isEmpty() ) if ( strAddress.isEmpty() )
{ {
// server stop // server stop
JpegHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP ); JpegHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP );
SvgHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP ); SvgHistoryGraph.Add ( curDateTime, CSvgHistoryGraph::HIT_SERVER_STOP );
} }
else else
{ {