Improvements and fixes

Code improvements.
Fixed compiler warnings.
This commit is contained in:
Valentino Orlandi 2023-09-24 20:50:10 +02:00
parent 15c945f854
commit 103d46f206
Signed by: elB4RTO
GPG key ID: 1719E976DB2D4E71
11 changed files with 111 additions and 77 deletions

View file

@ -40,6 +40,7 @@ SnakeGame::SnakeGame( const QFont& term_font, QWidget* parent )
void SnakeGame::closeEvent( QCloseEvent* event )
{
Q_UNUSED(event)
if (this->game_loop) {
this->game_loop->stop();
}

View file

@ -19,7 +19,7 @@ Snake::Snake( const bool is_adversary )
{
if ( is_adversary ) {
// only AI needs to keep track of the field state
this->field_map.fill( std::array<Tile, 16ul>({Entity::N, 0}) );
this->field_map.fill( std::array<Tile, 16ul>{} );
}
}
@ -780,10 +780,10 @@ bool Snake::inTileMinusSteps(const unsigned x, const unsigned y, const unsigned
if ( this->field_map.at(x).at(y).s_index > steps ) {
return true;
}
return false;
default:
return false;
}
return false;
}

View file

@ -268,7 +268,7 @@ MainWindow::MainWindow(QWidget *parent)
this->ui->chart_StatsDay,
this->ui->chart_StatsRelat
};
for ( auto* chart : charts ) {
for ( auto chart : charts ) {
ColorSec::applyChartTheme(
this->FONTS, chart );
}
@ -286,6 +286,7 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::closeEvent( QCloseEvent *event )
{
Q_UNUSED(event)
// save actual configurations
this->writeConfigs();
// backup the database
@ -1012,13 +1013,13 @@ std::string MainWindow::list2string( const std::vector<std::string>& list, const
return std::accumulate(
list.begin(), list.end(), std::string{},
[&]( auto s, auto str ) -> std::string
{ return s + StringOps::replace( str, " ", "%@#" ) + " "; } );
{ return std::move(s) + StringOps::replace( str, " ", "%@#" ) + " "; } );
} else {
return std::accumulate(
list.begin(), list.end(), std::string{},
[]( auto s, auto str ) -> std::string
{ return s + str + " "; } );
{ return std::move(s) + std::move(str) + " "; } );
}
}
std::vector<std::string> MainWindow::string2list( const std::string& string, const bool user_agent ) const
@ -1029,7 +1030,8 @@ std::vector<std::string> MainWindow::string2list( const std::string& string, con
list.reserve( aux.size() );
std::transform( aux.cbegin(), aux.cend(),
std::back_inserter( list ),
[](auto str){ return StringOps::replace( str, "%@#", " " ); } );
[&]( auto str )
{ return StringOps::replace( str, "%@#", " " ); } );
return list;
} else {
return aux;
@ -2658,12 +2660,16 @@ void MainWindow::on_button_LogFiles_ViewFile_clicked()
void MainWindow::on_listLogFiles_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
Q_UNUSED(item)
Q_UNUSED(column)
this->on_button_LogFiles_ViewFile_clicked();
}
void MainWindow::on_listLogFiles_itemChanged(QTreeWidgetItem *item, int column)
{
Q_UNUSED(item)
Q_UNUSED(column)
// control checked
size_t n_checked{ 0ul };
QTreeWidgetItemIterator i(this->ui->listLogFiles);
@ -2967,6 +2973,7 @@ void MainWindow::on_checkBox_StatsWarn_Hour_stateChanged(int state)
void MainWindow::on_box_StatsWarn_Hour_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->checkStatsWarnDrawable();
}
@ -3098,6 +3105,7 @@ void MainWindow::on_box_StatsSpeed_Month_currentIndexChanged(int index)
void MainWindow::on_box_StatsSpeed_Day_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->checkStatsSpeedDrawable();
}
@ -3281,6 +3289,7 @@ void MainWindow::on_box_StatsCount_Month_currentIndexChanged(int index)
void MainWindow::on_box_StatsCount_Day_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->checkStatsCountDrawable();
}
@ -3547,6 +3556,7 @@ void MainWindow::on_box_StatsDay_WebServer_currentIndexChanged(int index)
void MainWindow::on_box_StatsDay_LogsField_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->ui->inLine_StatsDay_Filter->clear();
this->checkStatsDayDrawable();
}
@ -3596,6 +3606,7 @@ void MainWindow::on_box_StatsDay_FromMonth_currentIndexChanged(int index)
void MainWindow::on_box_StatsDay_FromDay_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->checkStatsDayDrawable();
}
@ -3673,11 +3684,13 @@ void MainWindow::on_box_StatsDay_ToMonth_currentIndexChanged(int index)
void MainWindow::on_box_StatsDay_ToDay_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->checkStatsDayDrawable();
}
void MainWindow::on_inLine_StatsDay_Filter_textChanged(const QString& arg1)
{
Q_UNUSED(arg1)
if ( this->getStatsDayParsedFilter().has_value() ) {
this->ui->inLine_StatsDay_Filter->setStyleSheet(
this->stylesheet_lineedit );
@ -3839,12 +3852,14 @@ void MainWindow::on_box_StatsRelat_WebServer_currentIndexChanged(int index)
void MainWindow::on_box_StatsRelat_LogsField_1_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->ui->inLine_StatsRelat_Filter_1->clear();
this->checkStatsRelatDrawable();
}
void MainWindow::on_box_StatsRelat_LogsField_2_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->ui->inLine_StatsRelat_Filter_2->clear();
this->checkStatsRelatDrawable();
}
@ -3894,6 +3909,7 @@ void MainWindow::on_box_StatsRelat_FromMonth_currentIndexChanged(int index)
void MainWindow::on_box_StatsRelat_FromDay_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->checkStatsRelatDrawable();
}
@ -3942,11 +3958,13 @@ void MainWindow::on_box_StatsRelat_ToMonth_currentIndexChanged(int index)
void MainWindow::on_box_StatsRelat_ToDay_currentIndexChanged(int index)
{
Q_UNUSED(index)
this->checkStatsRelatDrawable();
}
void MainWindow::on_inLine_StatsRelat_Filter_1_textChanged(const QString &arg1)
{
Q_UNUSED(arg1)
if ( this->getStatsRelatParsedFilter( 1 ).has_value() ) {
this->ui->inLine_StatsRelat_Filter_1->setStyleSheet(
this->stylesheet_lineedit );
@ -3959,6 +3977,7 @@ void MainWindow::on_inLine_StatsRelat_Filter_1_textChanged(const QString &arg1)
void MainWindow::on_inLine_StatsRelat_Filter_2_textChanged(const QString &arg1)
{
Q_UNUSED(arg1)
if ( this->getStatsRelatParsedFilter( 2 ).has_value() ) {
this->ui->inLine_StatsRelat_Filter_2->setStyleSheet(
this->stylesheet_lineedit );
@ -4157,6 +4176,7 @@ void MainWindow::on_button_StatsGlob_Iis_clicked()
void MainWindow::on_tree_ConfSections_itemClicked(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column)
const QString section{ item->text(0) };
if ( section == tr("General") ) {
return;
@ -4557,14 +4577,17 @@ void MainWindow::on_spinBox_ConfDatabases_NumBackups_valueChanged(int arg1)
//// DEFAULTS ////
void MainWindow::on_radio_ConfDefaults_Apache_toggled(bool checked)
{
Q_UNUSED(checked)
this->default_ws = APACHE_ID;
}
void MainWindow::on_radio_ConfDefaults_Nginx_toggled(bool checked)
{
Q_UNUSED(checked)
this->default_ws = NGINX_ID;
}
void MainWindow::on_radio_ConfDefaults_Iis_toggled(bool checked)
{
Q_UNUSED(checked)
this->default_ws = IIS_ID;
}
@ -4599,7 +4622,7 @@ void MainWindow::on_spinBox_ConfControl_Size_editingFinished()
// paths
void MainWindow::on_inLine_ConfApache_Path_String_textChanged(const QString& arg1)
{
if ( arg1.size() > 0ul ) {
if ( arg1.size() > 0 ) {
std::string path{ this->resolvePath( arg1.toStdString() ) };
if ( IOutils::checkDir( path ) ) {
this->ui->icon_ConfApache_Path_Wrong->setVisible( false );
@ -4637,6 +4660,7 @@ void MainWindow::on_button_ConfApache_Path_Save_clicked()
// formats
void MainWindow::on_inLine_ConfApache_Format_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfApache_Format_Save->setEnabled( true );
} else {
@ -4717,6 +4741,7 @@ void MainWindow::on_checkBox_ConfApache_Warnlist_Used_clicked(bool checked)
void MainWindow::on_inLine_ConfApache_Warnlist_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfApache_Warnlist_Add->setEnabled( true );
} else {
@ -4756,7 +4781,7 @@ void MainWindow::on_list_ConfApache_Warnlist_List_itemSelectionChanged()
this->ui->button_ConfApache_Warnlist_Up->setEnabled( true );
this->ui->button_ConfApache_Warnlist_Down->setEnabled( true );
// polishing
const auto& item{ this->ui->list_ConfApache_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfApache_Warnlist_List->selectedItems().at(0) };
const int max{ this->ui->list_ConfApache_Warnlist_List->count() -1 };
if ( max == 0 ) {
this->ui->button_ConfApache_Warnlist_Up->setEnabled( false );
@ -4780,7 +4805,7 @@ void MainWindow::on_list_ConfApache_Warnlist_List_itemSelectionChanged()
}
void MainWindow::on_button_ConfApache_Warnlist_Remove_clicked()
{
const auto& item{ this->ui->list_ConfApache_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfApache_Warnlist_List->selectedItems().at(0) };
this->craplog.warnlistRemove(
APACHE_ID,
this->crapview.getLogFieldID( this->ui->box_ConfApache_Warnlist_Field->currentText() ),
@ -4790,7 +4815,7 @@ void MainWindow::on_button_ConfApache_Warnlist_Remove_clicked()
}
void MainWindow::on_button_ConfApache_Warnlist_Up_clicked()
{
const auto& item{ this->ui->list_ConfApache_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfApache_Warnlist_List->selectedItems().at(0) };
const int i{ this->craplog.warnlistMoveUp(
APACHE_ID,
this->crapview.getLogFieldID( this->ui->box_ConfApache_Warnlist_Field->currentText() ),
@ -4803,7 +4828,7 @@ void MainWindow::on_button_ConfApache_Warnlist_Up_clicked()
}
void MainWindow::on_button_ConfApache_Warnlist_Down_clicked()
{
const auto& item{ this->ui->list_ConfApache_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfApache_Warnlist_List->selectedItems().at(0) };
const int i{ this->craplog.warnlistMoveDown(
APACHE_ID,
this->crapview.getLogFieldID( this->ui->box_ConfApache_Warnlist_Field->currentText() ),
@ -4863,6 +4888,7 @@ void MainWindow::on_checkBox_ConfApache_Blacklist_Used_clicked(bool checked)
void MainWindow::on_inLine_ConfApache_Blacklist_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfApache_Blacklist_Add->setEnabled( true );
} else {
@ -4902,7 +4928,7 @@ void MainWindow::on_list_ConfApache_Blacklist_List_itemSelectionChanged()
this->ui->button_ConfApache_Blacklist_Up->setEnabled( true );
this->ui->button_ConfApache_Blacklist_Down->setEnabled( true );
// polishing
const auto& item{ this->ui->list_ConfApache_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfApache_Blacklist_List->selectedItems().at(0) };
const int max{ this->ui->list_ConfApache_Blacklist_List->count() -1 };
if ( max == 0 ) {
this->ui->button_ConfApache_Blacklist_Up->setEnabled( false );
@ -4926,7 +4952,7 @@ void MainWindow::on_list_ConfApache_Blacklist_List_itemSelectionChanged()
}
void MainWindow::on_button_ConfApache_Blacklist_Remove_clicked()
{
const auto& item{ this->ui->list_ConfApache_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfApache_Blacklist_List->selectedItems().at(0) };
this->craplog.blacklistRemove(
APACHE_ID,
this->crapview.getLogFieldID( this->ui->box_ConfApache_Blacklist_Field->currentText() ),
@ -4936,7 +4962,7 @@ void MainWindow::on_button_ConfApache_Blacklist_Remove_clicked()
}
void MainWindow::on_button_ConfApache_Blacklist_Up_clicked()
{
const auto& item{ this->ui->list_ConfApache_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfApache_Blacklist_List->selectedItems().at(0) };
const int i{ this->craplog.blacklistMoveUp(
APACHE_ID,
this->crapview.getLogFieldID( this->ui->box_ConfApache_Blacklist_Field->currentText() ),
@ -4949,7 +4975,7 @@ void MainWindow::on_button_ConfApache_Blacklist_Up_clicked()
}
void MainWindow::on_button_ConfApache_Blacklist_Down_clicked()
{
const auto& item{ this->ui->list_ConfApache_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfApache_Blacklist_List->selectedItems().at(0) };
const int i{ this->craplog.blacklistMoveDown(
APACHE_ID,
this->crapview.getLogFieldID( this->ui->box_ConfApache_Blacklist_Field->currentText() ),
@ -5005,6 +5031,7 @@ void MainWindow::on_button_ConfNginx_Path_Save_clicked()
// formats
void MainWindow::on_inLine_ConfNginx_Format_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfNginx_Format_Save->setEnabled( true );
} else {
@ -5085,6 +5112,7 @@ void MainWindow::on_checkBox_ConfNginx_Warnlist_Used_clicked(bool checked)
void MainWindow::on_inLine_ConfNginx_Warnlist_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfNginx_Warnlist_Add->setEnabled( true );
} else {
@ -5124,7 +5152,7 @@ void MainWindow::on_list_ConfNginx_Warnlist_List_itemSelectionChanged()
this->ui->button_ConfNginx_Warnlist_Up->setEnabled( true );
this->ui->button_ConfNginx_Warnlist_Down->setEnabled( true );
// polishing
const auto& item{ this->ui->list_ConfNginx_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfNginx_Warnlist_List->selectedItems().at(0) };
const int max{ this->ui->list_ConfNginx_Warnlist_List->count() -1 };
if ( max == 0 ) {
this->ui->button_ConfNginx_Warnlist_Up->setEnabled( false );
@ -5148,7 +5176,7 @@ void MainWindow::on_list_ConfNginx_Warnlist_List_itemSelectionChanged()
}
void MainWindow::on_button_ConfNginx_Warnlist_Remove_clicked()
{
const auto& item{ this->ui->list_ConfNginx_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfNginx_Warnlist_List->selectedItems().at(0) };
this->craplog.warnlistRemove(
NGINX_ID,
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Warnlist_Field->currentText() ),
@ -5158,7 +5186,7 @@ void MainWindow::on_button_ConfNginx_Warnlist_Remove_clicked()
}
void MainWindow::on_button_ConfNginx_Warnlist_Up_clicked()
{
const auto& item{ this->ui->list_ConfNginx_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfNginx_Warnlist_List->selectedItems().at(0) };
const int i{ this->craplog.warnlistMoveUp(
NGINX_ID,
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Warnlist_Field->currentText() ),
@ -5171,7 +5199,7 @@ void MainWindow::on_button_ConfNginx_Warnlist_Up_clicked()
}
void MainWindow::on_button_ConfNginx_Warnlist_Down_clicked()
{
const auto& item{ this->ui->list_ConfNginx_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfNginx_Warnlist_List->selectedItems().at(0) };
const int i{ this->craplog.warnlistMoveDown(
NGINX_ID,
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Warnlist_Field->currentText() ),
@ -5231,6 +5259,7 @@ void MainWindow::on_checkBox_ConfNginx_Blacklist_Used_clicked(bool checked)
void MainWindow::on_inLine_ConfNginx_Blacklist_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfNginx_Blacklist_Add->setEnabled( true );
} else {
@ -5270,7 +5299,7 @@ void MainWindow::on_list_ConfNginx_Blacklist_List_itemSelectionChanged()
this->ui->button_ConfNginx_Blacklist_Up->setEnabled( true );
this->ui->button_ConfNginx_Blacklist_Down->setEnabled( true );
// polishing
const auto& item{ this->ui->list_ConfNginx_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfNginx_Blacklist_List->selectedItems().at(0) };
const int max{ this->ui->list_ConfNginx_Blacklist_List->count() -1 };
if ( max == 0 ) {
this->ui->button_ConfNginx_Blacklist_Up->setEnabled( false );
@ -5294,7 +5323,7 @@ void MainWindow::on_list_ConfNginx_Blacklist_List_itemSelectionChanged()
}
void MainWindow::on_button_ConfNginx_Blacklist_Remove_clicked()
{
const auto& item{ this->ui->list_ConfNginx_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfNginx_Blacklist_List->selectedItems().at(0) };
this->craplog.blacklistRemove(
NGINX_ID,
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Blacklist_Field->currentText() ),
@ -5304,7 +5333,7 @@ void MainWindow::on_button_ConfNginx_Blacklist_Remove_clicked()
}
void MainWindow::on_button_ConfNginx_Blacklist_Up_clicked()
{
const auto& item{ this->ui->list_ConfNginx_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfNginx_Blacklist_List->selectedItems().at(0) };
const int i{ this->craplog.blacklistMoveUp(
NGINX_ID,
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Blacklist_Field->currentText() ),
@ -5317,7 +5346,7 @@ void MainWindow::on_button_ConfNginx_Blacklist_Up_clicked()
}
void MainWindow::on_button_ConfNginx_Blacklist_Down_clicked()
{
const auto& item{ this->ui->list_ConfNginx_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfNginx_Blacklist_List->selectedItems().at(0) };
const int i{ this->craplog.blacklistMoveDown(
NGINX_ID,
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Blacklist_Field->currentText() ),
@ -5435,6 +5464,7 @@ void MainWindow::on_radio_ConfIis_Format_IIS_toggled(bool checked)
void MainWindow::on_inLine_ConfIis_Format_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfIis_Format_Save->setEnabled( true );
} else {
@ -5516,6 +5546,7 @@ void MainWindow::on_checkBox_ConfIis_Warnlist_Used_clicked(bool checked)
void MainWindow::on_inLine_ConfIis_Warnlist_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfIis_Warnlist_Add->setEnabled( true );
} else {
@ -5555,7 +5586,7 @@ void MainWindow::on_list_ConfIis_Warnlist_List_itemSelectionChanged()
this->ui->button_ConfIis_Warnlist_Up->setEnabled( true );
this->ui->button_ConfIis_Warnlist_Down->setEnabled( true );
// polishing
const auto& item{ this->ui->list_ConfIis_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfIis_Warnlist_List->selectedItems().at(0) };
const int max{ this->ui->list_ConfIis_Warnlist_List->count() -1 };
if ( max == 0 ) {
this->ui->button_ConfIis_Warnlist_Up->setEnabled( false );
@ -5579,7 +5610,7 @@ void MainWindow::on_list_ConfIis_Warnlist_List_itemSelectionChanged()
}
void MainWindow::on_button_ConfIis_Warnlist_Remove_clicked()
{
const auto& item{ this->ui->list_ConfIis_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfIis_Warnlist_List->selectedItems().at(0) };
this->craplog.warnlistRemove(
IIS_ID,
this->crapview.getLogFieldID( this->ui->box_ConfIis_Warnlist_Field->currentText() ),
@ -5589,7 +5620,7 @@ void MainWindow::on_button_ConfIis_Warnlist_Remove_clicked()
}
void MainWindow::on_button_ConfIis_Warnlist_Up_clicked()
{
const auto& item{ this->ui->list_ConfIis_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfIis_Warnlist_List->selectedItems().at(0) };
const int i{ this->craplog.warnlistMoveUp(
IIS_ID,
this->crapview.getLogFieldID( this->ui->box_ConfIis_Warnlist_Field->currentText() ),
@ -5602,7 +5633,7 @@ void MainWindow::on_button_ConfIis_Warnlist_Up_clicked()
}
void MainWindow::on_button_ConfIis_Warnlist_Down_clicked()
{
const auto& item{ this->ui->list_ConfIis_Warnlist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfIis_Warnlist_List->selectedItems().at(0) };
const int i{ this->craplog.warnlistMoveDown(
IIS_ID,
this->crapview.getLogFieldID( this->ui->box_ConfIis_Warnlist_Field->currentText() ),
@ -5662,6 +5693,7 @@ void MainWindow::on_checkBox_ConfIis_Blacklist_Used_clicked(bool checked)
void MainWindow::on_inLine_ConfIis_Blacklist_String_cursorPositionChanged(int arg1, int arg2)
{
Q_UNUSED(arg1)
if ( arg2 > 0 ) {
this->ui->button_ConfIis_Blacklist_Add->setEnabled( true );
} else {
@ -5701,7 +5733,7 @@ void MainWindow::on_list_ConfIis_Blacklist_List_itemSelectionChanged()
this->ui->button_ConfIis_Blacklist_Up->setEnabled( true );
this->ui->button_ConfIis_Blacklist_Down->setEnabled( true );
// polishing
const auto& item{ this->ui->list_ConfIis_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfIis_Blacklist_List->selectedItems().at(0) };
const int max{ this->ui->list_ConfIis_Blacklist_List->count() -1 };
if ( max == 0 ) {
this->ui->button_ConfIis_Blacklist_Up->setEnabled( false );
@ -5725,7 +5757,7 @@ void MainWindow::on_list_ConfIis_Blacklist_List_itemSelectionChanged()
}
void MainWindow::on_button_ConfIis_Blacklist_Remove_clicked()
{
const auto& item{ this->ui->list_ConfIis_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfIis_Blacklist_List->selectedItems().at(0) };
this->craplog.blacklistRemove(
IIS_ID,
this->crapview.getLogFieldID( this->ui->box_ConfIis_Blacklist_Field->currentText() ),
@ -5735,7 +5767,7 @@ void MainWindow::on_button_ConfIis_Blacklist_Remove_clicked()
}
void MainWindow::on_button_ConfIis_Blacklist_Up_clicked()
{
const auto& item{ this->ui->list_ConfIis_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfIis_Blacklist_List->selectedItems().at(0) };
const int i{ this->craplog.blacklistMoveUp(
IIS_ID,
this->crapview.getLogFieldID( this->ui->box_ConfIis_Blacklist_Field->currentText() ),
@ -5748,7 +5780,7 @@ void MainWindow::on_button_ConfIis_Blacklist_Up_clicked()
}
void MainWindow::on_button_ConfIis_Blacklist_Down_clicked()
{
const auto& item{ this->ui->list_ConfIis_Blacklist_List->selectedItems().at(0) };
const auto item{ this->ui->list_ConfIis_Blacklist_List->selectedItems().at(0) };
const int i{ this->craplog.blacklistMoveDown(
IIS_ID,
this->crapview.getLogFieldID( this->ui->box_ConfIis_Blacklist_Field->currentText() ),

View file

@ -18,12 +18,12 @@ Crapinfo::Crapinfo( const QString& version, const QString& exec_path, const QStr
this->setStyleSheet( stylesheet );
// fonts
const QString& ff{ QFontDatabase::applicationFontFamilies(
const QString ff{ QFontDatabase::applicationFontFamilies(
QFontDatabase::addApplicationFont(":/fonts/Metropolis")).at(0) };
const QFont font{ ff, 13 };
const QFont font_big{ ff, 15 };
const QFont font_bigger{ ff, 17 };
const QString& ff_s{ QFontDatabase::applicationFontFamilies(
const QString ff_s{ QFontDatabase::applicationFontFamilies(
QFontDatabase::addApplicationFont(":/fonts/Hack")).at(0) };
const QFont font_script{ ff_s, 12 };
const QFont font_script_small{ ff_s, 10 };

View file

@ -155,7 +155,6 @@ void CraplogParser::joinLogLines()
// append to the relative list
this->logs_lines.insert( this->logs_lines.end(), content.begin(), content.end() );
}
this->files_to_use.clear();
if ( this->logs_lines.empty() ) {
this->proceed &= false;
}

View file

@ -1,6 +1,7 @@
#include "parser_interface.h"
CraplogParserInterface::CraplogParserInterface( const unsigned web_server_id, const unsigned dialogs_level, const std::string& db_data_path, const std::string& db_hashes_path, const LogsFormat& logs_format, const bw_lists_t& blacklists, const bw_lists_t& warnlists, const worker_files_t& log_files, QObject* parent )
: QObject { parent }
, wsID { web_server_id }
@ -8,9 +9,9 @@ CraplogParserInterface::CraplogParserInterface( const unsigned web_server_id, co
, db_data_path { db_data_path }
, db_hashes_path { db_hashes_path }
, logs_format { logs_format }
, files_to_use { log_files }
, blacklists { blacklists }
, warnlists { warnlists }
, files_to_use { log_files }
{
}

View file

@ -89,7 +89,7 @@ protected:
LogsFormat logs_format;
// the selected log files to be parsed during the process
worker_files_t files_to_use;
const worker_files_t files_to_use;
// collection of logs items, each item results from a log line
/* structure
@ -118,8 +118,8 @@ protected:
//// BLACKLIST / WARNLIST ////
// { log_field_id : BWlist }
bw_lists_t blacklists;
bw_lists_t warnlists;
const bw_lists_t blacklists;
const bw_lists_t warnlists;
////////////////////////
//// LOG FIELDS IDs ////

View file

@ -43,7 +43,7 @@ Crapup::Crapup( QWidget* parent )
this->setStyleSheet( stylesheet );
// fonts
const QString& ff{ QFontDatabase::applicationFontFamilies(
const QString ff{ QFontDatabase::applicationFontFamilies(
QFontDatabase::addApplicationFont(":/fonts/Metropolis")).at(0) };
const QFont font{ ff, 13 };
const QFont font_big{ ff, 16 };
@ -65,6 +65,7 @@ Crapup::~Crapup()
void Crapup::closeEvent( QCloseEvent* event )
{
Q_UNUSED(event)
this->quitting |= true;
if ( !this->img_timer.isNull() ) {
if ( this->img_timer->isActive() ) {

View file

@ -25,7 +25,7 @@ void Crapview::setDbPath( const std::string& path )
QString Crapview::getLogFieldString ( const int field_id ) const
QString Crapview::getLogFieldString ( const size_t field_id ) const
{
return TR::tr( this->dbQuery.FIELDS.at( field_id ).c_str() );
}
@ -200,7 +200,7 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
for ( const std::vector<QString>& line : data ) {
table->insertRow( n_rows );
table->setItem( n_rows, 0, new QTableWidgetItem( PrintSec::printableBool( line.at( 0 ).toInt() )));
if ( line.at( 0 ).toInt() != 0 ) {
if ( line.at( 0ul ).toInt() != 0 ) {
table->item( n_rows, 0 )->setForeground( warn_col );
table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Checked );
} else {
@ -210,7 +210,7 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
table->setItem( n_rows, 2, new QTableWidgetItem( PrintSec::printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() )));
int col{ 3 };
const size_t max{ line.size() };
for ( size_t i{7}; i<max; i++ ) {
for ( size_t i{7ul}; i<max; i++ ) {
QTableWidgetItem* itm;
if ( (col == 7 || col >= 12) && !line.at(i).isEmpty() ) {
itm = new QTableWidgetItem();
@ -221,15 +221,15 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
table->setItem( n_rows, col, itm );
col ++;
}
if ( line.at( 0 ) == "0" ) {
if ( line.at( 0ul ) == "0" ) {
norm_count ++;
} else {
warn_count ++;
}
n_rows ++;
}
sets.at( m ).at( 0 )->append( norm_count );
sets.at( m ).at( 1 )->append( warn_count );
sets.at( m ).at( 0ul )->append( norm_count );
sets.at( m ).at( 1ul )->append( warn_count );
sum_count = norm_count + warn_count;
if ( sum_count > max_count ) {
max_count = sum_count;
@ -244,15 +244,15 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
sets.back().push_back( new QBarSet("") );
sets.back().push_back( new QBarSet("") );
}
for ( size_t g{0}; g<6ul; g++ ) {
for ( size_t m{0}; m<10ul; m++ ) {
for ( size_t g{0ul}; g<6ul; g++ ) {
for ( size_t m{0ul}; m<10ul; m++ ) {
const auto& data{ items.at( g ).at( m ) };
norm_count = warn_count = 0;
for ( const std::vector<QString>& line : data ) {
n_rows = table->rowCount();
table->insertRow( n_rows );
table->setItem( n_rows, 0, new QTableWidgetItem( PrintSec::printableBool( line.at( 0 ).toInt() )));
if ( line.at( 0 ).toInt() != 0 ) {
if ( line.at( 0ul ).toInt() != 0 ) {
table->item( n_rows, 0 )->setForeground( warn_col );
table->item( n_rows, 0 )->setCheckState( Qt::CheckState::Checked );
} else {
@ -260,17 +260,17 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
}
table->setItem( n_rows, 1, new QTableWidgetItem( PrintSec::printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() )));
table->setItem( n_rows, 2, new QTableWidgetItem( PrintSec::printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() )));
for ( int i=7; i<line.size(); i++ ) {
for ( size_t i{7ul}; i<line.size(); i++ ) {
table->setItem( n_rows, i-4, new QTableWidgetItem( line.at( i ) ));
}
if ( line.at( 0 ) == "0" ) {
if ( line.at( 0ul ) == "0" ) {
norm_count ++;
} else {
warn_count ++;
}
}
sets.at( m ).at( 0 )->append( norm_count );
sets.at( m ).at( 1 )->append( warn_count );
sets.at( m ).at( 0ul )->append( norm_count );
sets.at( m ).at( 1ul )->append( warn_count );
sum_count = norm_count + warn_count;
if ( sum_count > max_count ) {
max_count = sum_count;
@ -370,7 +370,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart::
int value{0}, aux_value, max_value{0}, n_rows{0};
long long time /* xD */, aux_time, count{1};
bool first_count{ true };
time = std::get<0>(items.at(0));
time = std::get<0>(items.at(0ul));
QDateTime dt;
std::vector<QString> data;
for ( const auto& item : items ) {
@ -378,7 +378,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart::
// append a value to the chart
aux_time = std::get<0>(item);
data = std::get<1>(item);
aux_value = data.at( 0 ).toInt();
aux_value = data.at( 0ul ).toInt();
// append only if the second is different, else sum
if ( aux_time > time ) {
value = value/count;
@ -414,16 +414,16 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart::
}
}
// fill the teble with data
if ( !data.at(0).isEmpty() || !data.at(1).isEmpty() || !data.at(2).isEmpty() || !data.at(3).isEmpty() || !data.at(4).isEmpty() || !data.at(5).isEmpty() ) {
if ( !data.at(0ul).isEmpty() || !data.at(1ul).isEmpty() || !data.at(2ul).isEmpty() || !data.at(3ul).isEmpty() || !data.at(4ul).isEmpty() || !data.at(5ul).isEmpty() ) {
table->insertRow( n_rows );
auto* tt{ new QTableWidgetItem() };
tt->setData( Qt::DisplayRole, aux_value );
table->setItem( n_rows, 0, tt );
table->setItem( n_rows, 1, new QTableWidgetItem( data.at(1) ));
table->setItem( n_rows, 2, new QTableWidgetItem( data.at(2) ));
table->setItem( n_rows, 3, new QTableWidgetItem( data.at(3) ));
table->setItem( n_rows, 4, new QTableWidgetItem( data.at(4) ));
table->setItem( n_rows, 5, new QTableWidgetItem( data.at(5) ));
table->setItem( n_rows, 1, new QTableWidgetItem( data.at(1ul) ));
table->setItem( n_rows, 2, new QTableWidgetItem( data.at(2ul) ));
table->setItem( n_rows, 3, new QTableWidgetItem( data.at(3ul) ));
table->setItem( n_rows, 4, new QTableWidgetItem( data.at(4ul) ));
table->setItem( n_rows, 5, new QTableWidgetItem( data.at(5ul) ));
dt = QDateTime::fromMSecsSinceEpoch( aux_time );
table->setItem( n_rows, 6, new QTableWidgetItem( dt.time().toString("hh:mm:ss") ));
n_rows ++;
@ -594,34 +594,34 @@ void Crapview::drawDay( QChartView* chart, const QChart::ChartTheme& theme, cons
// build the bars upon data
int count, max_count{0};
for ( int h{0}; h<24; h++ ) {
for ( size_t h{0ul}; h<24ul; h++ ) {
auto& data = items.at( h );
count = data.at( 0 );
count = data.at( 0ul );
*b_10 << count;
if ( count > max_count ) {
max_count = count;
}
count = data.at( 10 );
count = data.at( 10ul );
*b_20 << count;
if ( count > max_count ) {
max_count = count;
}
count = data.at( 20 );
count = data.at( 20ul );
*b_30 << count;
if ( count > max_count ) {
max_count = count;
}
count = data.at( 30 );
count = data.at( 30ul );
*b_40 << count;
if ( count > max_count ) {
max_count = count;
}
count = data.at( 40 );
count = data.at( 40ul );
*b_50 << count;
if ( count > max_count ) {
max_count = count;
}
count = data.at( 50 );
count = data.at( 50ul );
*b_60 << count;
if ( count > max_count ) {
max_count = count;
@ -884,19 +884,19 @@ bool Crapview::calcGlobals( std::vector<std::tuple<QString,QString>>& recur_list
// mean/max time-taken
perf_list.push_back( std::make_tuple(
QString("%1 ms").arg( (perf_time.at(2)>0ll) ? perf_time.at(1)/perf_time.at(2) : perf_time.at(1) ),
QString("%1 ms").arg( perf_time.at(0) ) ));
QString("%1 ms").arg( (perf_time.at(2ul)>0ll) ? perf_time.at(1ul)/perf_time.at(2ul) : perf_time.at(1ul) ),
QString("%1 ms").arg( perf_time.at(0ul) ) ));
perf_list.push_back( std::make_tuple(
QString("%1 B").arg( (perf_sent.at(2)>0ll) ? perf_sent.at(1)/perf_sent.at(2) : perf_time.at(1) ),
QString("%1 B").arg( perf_sent.at(0) ) ));
QString("%1 B").arg( (perf_sent.at(2ul)>0ll) ? perf_sent.at(1ul)/perf_sent.at(2ul) : perf_time.at(1ul) ),
QString("%1 B").arg( perf_sent.at(0ul) ) ));
perf_list.push_back( std::make_tuple(
QString("%1 B").arg( (perf_receiv.at(2)>0ll) ? perf_receiv.at(1)/perf_receiv.at(2) : perf_receiv.at(1) ),
QString("%1 B").arg( perf_receiv.at(0) ) ));
QString("%1 B").arg( (perf_receiv.at(2ul)>0ll) ? perf_receiv.at(1ul)/perf_receiv.at(2ul) : perf_receiv.at(1ul) ),
QString("%1 B").arg( perf_receiv.at(0ul) ) ));
// overall work list
work_list.push_back( QString("%1").arg( req_count ) );
float t = static_cast<float>( perf_time.at(1) );
float t = static_cast<float>( perf_time.at(1ul) );
if ( t < 0.f ) {
work_list.push_back( "0" );
} else {
@ -920,7 +920,7 @@ bool Crapview::calcGlobals( std::vector<std::tuple<QString,QString>>& recur_list
work_list.push_back( QString("%1 h %2 m %3.%4 s").arg(h).arg(m).arg(s).arg(ms) );
}
float b = static_cast<float>( perf_sent.at(1) );
float b = static_cast<float>( perf_sent.at(1ul) );
if ( b < 0.f ) {
work_list.push_back( "0" );
} else {

View file

@ -47,7 +47,7 @@ public:
\param field_id The ID of the log fiels
\return The printable field
*/
QString getLogFieldString ( const int field_id ) const;
QString getLogFieldString ( const size_t field_id ) const;
//! Returns the log field ID corresponding to the given printable field
/*!

View file

@ -126,7 +126,7 @@ QString printableDate( const QString& year, const int month, const QString& day
(month<10)
? QString("0%1").arg( month )
: QString::number( month ),
(day.size()<2ul)
(day.size()<2)
? QString("0%1").arg( day )
: day
);