From b840aa8def782c16a76cca083953300e242efa8f Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Fri, 19 Aug 2022 22:37:48 +0200 Subject: [PATCH] Code improvements and updates --- logdoctor/tools/crapview/crapview.cpp | 18 ++++----- logdoctor/tools/crapview/crapview.h | 56 +++++++++++++-------------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/logdoctor/tools/crapview/crapview.cpp b/logdoctor/tools/crapview/crapview.cpp index b9ca76d5..76777487 100644 --- a/logdoctor/tools/crapview/crapview.cpp +++ b/logdoctor/tools/crapview/crapview.cpp @@ -92,11 +92,11 @@ const QString Crapview::printableTime( const int& hour, const int& minute, const const QStringList Crapview::getWarnHeader() { return QStringList({ - FIELDS.value(0), + this->dbQuery.FIELDS.value(0), this->DATE,this->TIME, - FIELDS.value(10),FIELDS.value(11),FIELDS.value(12),FIELDS.value(13),FIELDS.value(14), - FIELDS.value(18),FIELDS.value(22),FIELDS.value(21),FIELDS.value(20), - FIELDS.value(17),FIELDS.value(16),FIELDS.value(15),"rowid" }); + this->dbQuery.FIELDS.value(10),this->dbQuery.FIELDS.value(11),this->dbQuery.FIELDS.value(12),this->dbQuery.FIELDS.value(13),this->dbQuery.FIELDS.value(14), + this->dbQuery.FIELDS.value(18),this->dbQuery.FIELDS.value(22),this->dbQuery.FIELDS.value(21),this->dbQuery.FIELDS.value(20), + this->dbQuery.FIELDS.value(17),this->dbQuery.FIELDS.value(16),this->dbQuery.FIELDS.value(15),"rowid" }); } @@ -232,7 +232,7 @@ const QStringList Crapview::getMonths( const QString& web_server, const QString& const int y = year.toInt(); if ( this->dates.at( ws ).at( y ).size() ) { for ( const auto& [month, data] : this->dates.at( ws ).at( y ) ) { - months.push_back( MONTHS.value( month ) ); + months.push_back( this->dbQuery.MONTHS.value( month ) ); } } } @@ -428,8 +428,7 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const //b_chart->legend()->setVisible( false ); b_chart->legend()->setFont( fonts.at("main_small") ); b_chart->legend()->setAlignment( Qt::AlignBottom ); - b_chart->setAnimationOptions( QChart::SeriesAnimations ); - //b_chart->setBackgroundBrush( Qt::darkGray ); + //b_chart->setAnimationOptions( QChart::SeriesAnimations ); // craft the X-axis labels QStringList categories; @@ -750,8 +749,7 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t b_chart->legend()->setFont( fonts.at("main_small") ); //b_chart->legend()->setVisible( true ); b_chart->legend()->setAlignment( Qt::AlignBottom ); - b_chart->setAnimationOptions( QChart::SeriesAnimations ); - //b_chart->setBackgroundBrush( Qt::darkGray ); + //b_chart->setAnimationOptions( QChart::SeriesAnimations ); // craft the X-axis labels QStringList categories; @@ -969,7 +967,7 @@ const bool Crapview::calcGlobals( std::vector>& recu if ( max_ == 0 ) { traffic_list.push_back( std::make_tuple( "", "0" ) ); } else { - traffic_list.push_back( std::make_tuple( DAYS.value(max_), QString("%1").arg(max) ) ); + traffic_list.push_back( std::make_tuple( this->dbQuery.DAYS.value(max_), QString("%1").arg(max) ) ); } // max hour of the day diff --git a/logdoctor/tools/crapview/crapview.h b/logdoctor/tools/crapview/crapview.h index e4fa05bc..9fe8a6c1 100644 --- a/logdoctor/tools/crapview/crapview.h +++ b/logdoctor/tools/crapview/crapview.h @@ -101,16 +101,16 @@ private: DbQuery dbQuery; - QString TITLE_WARN = QMessageBox::tr("Log Lines Marked as Warning"), - TITLE_SPEED = QMessageBox::tr("Time Taken to Serve Requests"), - TEXT_COUNT_OTHERS = QMessageBox::tr("Others"), - TITLE_DAY = QMessageBox::tr("Time of Day Count"), - TITLE_RELAT = QMessageBox::tr("Relational Count"), - LEGEND_FROM = QMessageBox::tr("from"), - LEGEND_TO = QMessageBox::tr("to"), + const QString TITLE_WARN = QMessageBox::tr("Log Lines Marked as Warning"); + const QString TITLE_SPEED = QMessageBox::tr("Time Taken to Serve Requests"); + const QString TEXT_COUNT_OTHERS = QMessageBox::tr("Others"); + const QString TITLE_DAY = QMessageBox::tr("Time of Day Count"); + const QString TITLE_RELAT = QMessageBox::tr("Relational Count"); + const QString LEGEND_FROM = QMessageBox::tr("from"); + const QString LEGEND_TO = QMessageBox::tr("to"); - DATE = QMessageBox::tr("Date"), - TIME = QMessageBox::tr("Time"); + const QString DATE = QMessageBox::tr("Date"); + const QString TIME = QMessageBox::tr("Time"); // collection of available dates // { web_server_id : { year : { month_str : [ days ] } } } @@ -120,9 +120,9 @@ private: // { tab : [ fields ] } const QHash fields = { {"Daytime", { - FIELDS.value(0),FIELDS.value(10),FIELDS.value(11),FIELDS.value(12),FIELDS.value(13),FIELDS.value(14),FIELDS.value(18),FIELDS.value(22),FIELDS.value(21),FIELDS.value(20)} }, + this->dbQuery.FIELDS.value(0),this->dbQuery.FIELDS.value(10),this->dbQuery.FIELDS.value(11),this->dbQuery.FIELDS.value(12),this->dbQuery.FIELDS.value(13),this->dbQuery.FIELDS.value(14),this->dbQuery.FIELDS.value(18),this->dbQuery.FIELDS.value(22),this->dbQuery.FIELDS.value(21),this->dbQuery.FIELDS.value(20)} }, {"Relational", { - FIELDS.value(0),FIELDS.value(10),FIELDS.value(11),FIELDS.value(12),FIELDS.value(13),FIELDS.value(14),FIELDS.value(15),FIELDS.value(16),FIELDS.value(17),FIELDS.value(18),FIELDS.value(22),FIELDS.value(21),FIELDS.value(20)} } + this->dbQuery.FIELDS.value(0),this->dbQuery.FIELDS.value(10),this->dbQuery.FIELDS.value(11),this->dbQuery.FIELDS.value(12),this->dbQuery.FIELDS.value(13),this->dbQuery.FIELDS.value(14),this->dbQuery.FIELDS.value(15),this->dbQuery.FIELDS.value(16),this->dbQuery.FIELDS.value(17),this->dbQuery.FIELDS.value(18),this->dbQuery.FIELDS.value(22),this->dbQuery.FIELDS.value(21),this->dbQuery.FIELDS.value(20)} } }; const QString printableDate( const QString& year, const int& month, const QString& day ); @@ -137,25 +137,25 @@ private: WebServer_s2i = { {"Apache2",11}, {"Nginx",12}, {"IIS",13} }, LogFields_s2i = { - {FIELDS.value(0), 0}, - {FIELDS.value(10),10}, - {FIELDS.value(11),11}, - {FIELDS.value(12),12}, - {FIELDS.value(13),13}, - {FIELDS.value(14),14}, - {FIELDS.value(15),15}, - {FIELDS.value(16),16}, - {FIELDS.value(17),17}, - {FIELDS.value(18),18}, - {FIELDS.value(20),20}, - {FIELDS.value(21),21}, - {FIELDS.value(22),22} + {this->dbQuery.FIELDS.value(0), 0}, + {this->dbQuery.FIELDS.value(10),10}, + {this->dbQuery.FIELDS.value(11),11}, + {this->dbQuery.FIELDS.value(12),12}, + {this->dbQuery.FIELDS.value(13),13}, + {this->dbQuery.FIELDS.value(14),14}, + {this->dbQuery.FIELDS.value(15),15}, + {this->dbQuery.FIELDS.value(16),16}, + {this->dbQuery.FIELDS.value(17),17}, + {this->dbQuery.FIELDS.value(18),18}, + {this->dbQuery.FIELDS.value(20),20}, + {this->dbQuery.FIELDS.value(21),21}, + {this->dbQuery.FIELDS.value(22),22} }, Months_s2i = { - {MONTHS.value(1),1}, {MONTHS.value(2),2}, {MONTHS.value(3),3}, - {MONTHS.value(4),4}, {MONTHS.value(5),5}, {MONTHS.value(6),6}, - {MONTHS.value(7),7}, {MONTHS.value(8),8}, {MONTHS.value(9),9}, - {MONTHS.value(10),10}, {MONTHS.value(11),11}, {MONTHS.value(12),12} }; + {this->dbQuery.MONTHS.value(1),1}, {this->dbQuery.MONTHS.value(2),2}, {this->dbQuery.MONTHS.value(3),3}, + {this->dbQuery.MONTHS.value(4),4}, {this->dbQuery.MONTHS.value(5),5}, {this->dbQuery.MONTHS.value(6),6}, + {this->dbQuery.MONTHS.value(7),7}, {this->dbQuery.MONTHS.value(8),8}, {this->dbQuery.MONTHS.value(9),9}, + {this->dbQuery.MONTHS.value(10),10}, {this->dbQuery.MONTHS.value(11),11}, {this->dbQuery.MONTHS.value(12),12} }; }; #endif // CRAPVIEW_H