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,6 +25,7 @@
#include "historygraph.h"
/* Abstract class *************************************************************/
AHistoryGraph::AHistoryGraph() :
sFileName ( "" ),
@ -75,6 +76,7 @@ void AHistoryGraph::Start ( const QString& sNewFileName )
{
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
tsConsoleStream << QString ( "AHistoryGraph::Start ( %1 )" ).arg ( sNewFileName ) << endl; // on console
if ( !sNewFileName.isEmpty() )
{
// save file name
@ -136,6 +138,7 @@ void AHistoryGraph::Update ( )
// get oldest date in history
QDate oldestDate = curDate.addDays ( 1 ); // one day in the future
const int iNumItemsForHistory = vHistoryDataFifo.Size();
for ( i = 0; i < iNumItemsForHistory; i++ )
{
// only use valid dates
@ -190,6 +193,7 @@ void AHistoryGraph::DrawFrame ( const int iNewNumTicksX )
// grid (ticks) for x-axis
dayXSpace = static_cast<double> ( gridFrameWidth ) / ( iNumTicksX + 1 );
for ( i = 0; i < static_cast<int> ( iNumTicksX ); i++ )
{
int iBottomExtraTickLen = 0;
@ -220,6 +224,7 @@ void AHistoryGraph::DrawFrame ( const int iNewNumTicksX )
// grid (ticks) for y-axis, draw iNumTicksY - 2 grid lines and
// iNumTicksY - 1 text labels (the lowest grid line is the grid frame)
iYSpace = gridFrameHeight / ( iNumTicksY - 1 );
for ( i = 0; i < ( static_cast<int> ( iNumTicksY ) - 1 ); i++ )
{
const int iCurY = gridFrameY + iYSpace * ( i + 1 );
@ -258,6 +263,7 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
int curPointX = gridFrameX + static_cast<int> ( dayXSpace * ( static_cast<signed> ( iNumTicksX ) + iXAxisOffs ) );
int curPointY = gridFrameY + static_cast<int> ( static_cast<double> (
gridFrameHeight ) / ( iYAxisEnd - iYAxisStart ) * dYAxisOffs );
QString curPointColour = MarkerNewColor;
int curPointSize = iMarkerSizeNewCon;
@ -281,6 +287,7 @@ void AHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
point ( curPointX - curPointSize / 2, curPointY - curPointSize / 2, curPointSize, curPointColour );
}
/* JPEG History Graph implementation ******************************************/
CJpegHistoryGraph::CJpegHistoryGraph() :
AHistoryGraph(),
@ -302,10 +309,17 @@ CJpegHistoryGraph::CJpegHistoryGraph() :
// Black = 87 // 900
bool ok;
int weight = axisFontWeight.toInt( &ok );
if ( !ok )
{
if (!QString("normal").compare(axisFontWeight, Qt::CaseSensitivity::CaseInsensitive)) { iAxisFontWeight = 50; }
else if (!QString("bold").compare(axisFontWeight, Qt::CaseSensitivity::CaseInsensitive)) { weight = 75; }
if ( !QString ( "normal" ).compare ( axisFontWeight, Qt::CaseSensitivity::CaseInsensitive ) )
{
iAxisFontWeight = 50;
}
else if ( !QString ( "bold" ).compare ( axisFontWeight, Qt::CaseSensitivity::CaseInsensitive ) )
{
weight = 75;
}
}
else
{
@ -324,6 +338,7 @@ CJpegHistoryGraph::CJpegHistoryGraph() :
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
tsConsoleStream << "CJpegHistoryGraph" << endl; // on console
// Connections -------------------------------------------------------------
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
this, SLOT ( OnTimerDailyUpdate() ) );
@ -377,6 +392,7 @@ void CJpegHistoryGraph::point ( const unsigned int x, const unsigned int y, cons
PlotPainter.drawPoint ( x, y );
}
/* SVG History Graph implementation *******************************************/
CSvgHistoryGraph::CSvgHistoryGraph() :
AHistoryGraph(),
@ -398,6 +414,7 @@ CSvgHistoryGraph::CSvgHistoryGraph() :
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
tsConsoleStream << "CSvgHistoryGraph" << endl; // on console
// Connections -------------------------------------------------------------
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
this, SLOT ( OnTimerDailyUpdate() ) );
@ -425,7 +442,9 @@ void CSvgHistoryGraph::Save ( const QString sFileName )
svgStreamWriter.writeEndDocument();
QFile outf ( sFileName );
if (!outf.open(QFile::WriteOnly)) {
if ( !outf.open ( QFile::WriteOnly ) )
{
throw std::runtime_error ( ( sFileName + " could not be written. Aborting." ).toStdString() );
}
QTextStream out ( &outf );

View file

@ -42,10 +42,12 @@
#include <QXmlStreamWriter>
#include <QXmlStreamAttributes>
/* Definitions ****************************************************************/
// number of history items to store
#define NUM_ITEMS_HISTORY 600
/* Interface ******************************************************************/
class AHistoryGraph
{
@ -130,6 +132,7 @@ protected:
QTimer TimerDailyUpdate;
};
/* Implementations ************************************************************/
class CJpegHistoryGraph : public QObject, virtual public AHistoryGraph
{

View file

@ -38,6 +38,7 @@ void CServerLogging::Start ( const QString& strLoggingFileName )
{
// open file
File.setFileName ( strLoggingFileName );
if ( File.open ( QIODevice::Append | QIODevice::Text ) )
{
bDoLogging = true;
@ -135,11 +136,12 @@ void CServerLogging::ParseLogFile ( const QString& strFileName )
// check if server stop or new client connection
QString strAddress = strlistCurLine.at ( 2 ).trimmed();
if ( strAddress.isEmpty() )
{
// server stop
JpegHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP );
SvgHistoryGraph.Add ( curDateTime, CJpegHistoryGraph::HIT_SERVER_STOP );
SvgHistoryGraph.Add ( curDateTime, CSvgHistoryGraph::HIT_SERVER_STOP );
}
else
{