2022-06-28 20:51:28 +02:00
|
|
|
|
2022-06-21 21:07:06 +02:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "./ui_mainwindow.h"
|
2022-06-20 21:44:58 +02:00
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
#include "qtimer.h"
|
|
|
|
|
|
|
|
#include <chrono>
|
2022-06-24 19:56:34 +02:00
|
|
|
|
2022-07-21 21:45:52 +02:00
|
|
|
#include <iostream> // !!! REMOVE !!!
|
|
|
|
|
2022-06-28 20:51:28 +02:00
|
|
|
|
2022-07-04 21:08:23 +02:00
|
|
|
MainWindow::MainWindow( QWidget *parent )
|
2022-06-20 21:44:58 +02:00
|
|
|
: QMainWindow(parent)
|
2022-06-21 21:07:06 +02:00
|
|
|
, ui(new Ui::MainWindow)
|
2022-06-20 21:44:58 +02:00
|
|
|
{
|
2022-06-27 19:49:09 +02:00
|
|
|
//////////////////
|
|
|
|
//// GRAPHICS ////
|
2022-06-22 21:37:35 +02:00
|
|
|
this->ui->setupUi(this);
|
2022-06-24 01:26:00 +02:00
|
|
|
|
2022-06-27 21:55:14 +02:00
|
|
|
// initialize the color-schemes map
|
|
|
|
this->TB_COLOR_SCHEMES = ColorSec::getColorSchemes();
|
2022-06-22 21:37:35 +02:00
|
|
|
// initialize the colors map
|
2022-06-27 21:55:14 +02:00
|
|
|
this->COLORS = ColorSec::getColors();
|
2022-06-27 19:49:09 +02:00
|
|
|
|
2022-06-22 21:37:35 +02:00
|
|
|
// load the main font
|
2022-06-25 18:48:08 +02:00
|
|
|
this->main_font_family = QFontDatabase::applicationFontFamilies(
|
2022-06-22 21:37:35 +02:00
|
|
|
QFontDatabase::addApplicationFont(":/fonts/Metropolis")).at(0);
|
|
|
|
// load the script font
|
2022-06-25 18:48:08 +02:00
|
|
|
this->script_font_family = QFontDatabase::applicationFontFamilies(
|
2022-06-22 21:37:35 +02:00
|
|
|
QFontDatabase::addApplicationFont(":/fonts/3270")).at(0);
|
|
|
|
// initialize the fonts map
|
2022-06-25 18:48:08 +02:00
|
|
|
this->FONTS["main"] = QFont(
|
|
|
|
this->main_font_family,
|
|
|
|
this->font_size );
|
|
|
|
this->FONTS["main_italic"] = QFont(
|
|
|
|
this->main_font_family,
|
|
|
|
this->font_size,
|
|
|
|
-1, true );
|
|
|
|
this->FONTS["main_bold"] = QFont(
|
|
|
|
this->main_font_family,
|
|
|
|
this->font_size,
|
|
|
|
1 );
|
|
|
|
this->FONTS["main_big"] = QFont(
|
|
|
|
this->main_font_family,
|
|
|
|
this->font_size_big );
|
|
|
|
this->FONTS["main_small"] = QFont(
|
|
|
|
this->main_font_family,
|
|
|
|
this->font_size_small );
|
|
|
|
this->FONTS["script"] = QFont(
|
|
|
|
this->script_font_family,
|
|
|
|
this->font_size );
|
|
|
|
|
2022-06-25 21:17:40 +02:00
|
|
|
// parent font for every tab
|
2022-07-10 18:14:00 +02:00
|
|
|
this->ui->CrapTabs->setFont( this->FONTS.at("main_big") );
|
2022-06-25 21:17:40 +02:00
|
|
|
|
2022-07-20 21:43:38 +02:00
|
|
|
// WebServers buttons for the LogFiles
|
|
|
|
this->ui->button_LogFiles_Apache->setFont( this->FONTS.at("main") );
|
|
|
|
this->ui->button_LogFiles_Nginx->setFont( this->FONTS.at("main") );
|
|
|
|
this->ui->button_LogFiles_Iis->setFont( this->FONTS.at("main") );
|
2022-06-25 18:48:08 +02:00
|
|
|
// TreeView for the LogFiles
|
2022-07-10 18:14:00 +02:00
|
|
|
this->ui->checkBox_LogFiles_CheckAll->setFont( this->FONTS.at("main_small") );
|
|
|
|
this->ui->listLogFiles->setFont( this->FONTS.at("main") );
|
2022-06-25 21:17:40 +02:00
|
|
|
// TextBrowser for the LogFiles
|
2022-07-10 18:14:00 +02:00
|
|
|
this->TB.setColorScheme( 1, this->TB_COLOR_SCHEMES.at(1) );
|
2022-06-27 21:55:14 +02:00
|
|
|
this->TB.setFontFamily( this->main_font_family );
|
2022-07-10 18:14:00 +02:00
|
|
|
this->TB.setFont( this->FONTS.at("main") );
|
2022-06-27 21:55:14 +02:00
|
|
|
this->ui->textLogFiles->setFont( this->TB.getFont() );
|
2022-07-10 18:14:00 +02:00
|
|
|
// MakeStats labels
|
|
|
|
this->ui->label_MakeStats_Size->setFont( this->FONTS.at("main") );
|
|
|
|
this->ui->label_MakeStats_Lines->setFont( this->FONTS.at("main") );
|
|
|
|
this->ui->label_MakeStats_Time->setFont( this->FONTS.at("main") );
|
|
|
|
this->ui->label_MakeStats_Speed->setFont( this->FONTS.at("main") );
|
2022-06-27 19:49:09 +02:00
|
|
|
|
2022-07-21 21:45:52 +02:00
|
|
|
// StatsSpeed table
|
|
|
|
this->ui->table_StatsSpeed_Fields->setFont( this->FONTS.at("main") );
|
|
|
|
|
|
|
|
// adjust LogsList headers width
|
|
|
|
this->ui->listLogFiles->header()->resizeSection(0,200);
|
|
|
|
this->ui->listLogFiles->header()->resizeSection(1,100);
|
|
|
|
|
2022-06-27 19:49:09 +02:00
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
//// INITIALIZATION ////
|
2022-07-06 21:03:58 +02:00
|
|
|
// sqlite databases paths
|
2022-07-09 18:16:09 +02:00
|
|
|
this->db_stats_path = "collection.db";//"~/.craplog/collection.db"; !!! RESTORE
|
|
|
|
this->db_hashes_path = "hashes.db";//"~/.craplog/hashes.db"; !!! RESTORE
|
2022-07-21 21:45:52 +02:00
|
|
|
this->crapview.setDbPath( this->db_stats_path );
|
2022-06-27 19:49:09 +02:00
|
|
|
// WebServers for the LogsList
|
|
|
|
this->allowed_web_servers[11] = true; // apache2
|
|
|
|
this->allowed_web_servers[12] = true; // nginx
|
|
|
|
this->allowed_web_servers[13] = true; // iis
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////
|
|
|
|
//// CONFIGS ////
|
2022-07-09 18:16:09 +02:00
|
|
|
this->craplog.setDialogLevel( 1 ); // !!! REPLACE WITH CONFIGURATION VALUE !!!
|
2022-07-06 21:03:58 +02:00
|
|
|
|
|
|
|
|
2022-06-27 19:49:09 +02:00
|
|
|
///////////////////
|
|
|
|
//// POLISHING ////
|
|
|
|
// disable the unallowed WebServers
|
|
|
|
int ws = 14;
|
2022-07-21 21:45:52 +02:00
|
|
|
for ( int id=13; id>10; id-- ) {
|
2022-07-20 21:43:38 +02:00
|
|
|
if ( this->allowed_web_servers.at( id ) == true ) {
|
2022-06-27 19:49:09 +02:00
|
|
|
ws = ( id < ws ) ? id : ws;
|
|
|
|
} else {
|
|
|
|
switch (id) {
|
2022-07-21 21:45:52 +02:00
|
|
|
case 11:
|
|
|
|
this->ui->button_LogFiles_Apache->setEnabled( false );
|
|
|
|
this->ui->box_StatsCount_WebServer->removeItem( 0 );
|
|
|
|
this->ui->box_StatsSpeed_WebServer->removeItem( 0 );
|
|
|
|
this->ui->box_StatsDay_WebServer->removeItem( 0 );
|
|
|
|
this->ui->box_StatsRelat_WebServer->removeItem( 0 );
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
this->ui->button_LogFiles_Nginx->setEnabled( false );
|
|
|
|
this->ui->box_StatsCount_WebServer->removeItem( 1 );
|
|
|
|
this->ui->box_StatsSpeed_WebServer->removeItem( 1 );
|
|
|
|
this->ui->box_StatsDay_WebServer->removeItem( 1 );
|
|
|
|
this->ui->box_StatsRelat_WebServer->removeItem( 1 );
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
this->ui->button_LogFiles_Iis->setEnabled( false );
|
|
|
|
this->ui->box_StatsCount_WebServer->removeItem( 2 );
|
|
|
|
this->ui->box_StatsSpeed_WebServer->removeItem( 2 );
|
|
|
|
this->ui->box_StatsDay_WebServer->removeItem( 2 );
|
|
|
|
this->ui->box_StatsRelat_WebServer->removeItem( 2 );
|
|
|
|
break;
|
2022-06-27 19:49:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( ws == 14 ) {
|
|
|
|
// no WS is allowed (???), fallback to the default one
|
|
|
|
ws = 11;
|
2022-07-21 21:45:52 +02:00
|
|
|
this->craplog.setCurrentWSID( ws );
|
|
|
|
this->allowed_web_servers.at( ws ) = true;
|
2022-06-27 19:49:09 +02:00
|
|
|
this->on_button_LogFiles_Apache_clicked();
|
|
|
|
this->ui->button_LogFiles_Apache->setEnabled( true );
|
2022-07-21 21:45:52 +02:00
|
|
|
this->ui->box_StatsCount_WebServer->addItem( "Apache2" );
|
|
|
|
this->ui->box_StatsSpeed_WebServer->addItem( "Apache2" );
|
|
|
|
this->ui->box_StatsDay_WebServer->addItem( "Apache2" );
|
|
|
|
this->ui->box_StatsRelat_WebServer->addItem( "Apache2" );
|
2022-06-27 19:49:09 +02:00
|
|
|
}
|
|
|
|
// set the LogList to the current WebServer
|
2022-07-21 21:45:52 +02:00
|
|
|
if ( this->allowed_web_servers.at( this->craplog.getCurrentWSID() ) == false ) {
|
|
|
|
// the current craplog's WS is not allowed, fallback to the default one
|
2022-06-27 19:49:09 +02:00
|
|
|
this->craplog.setCurrentWSID( ws );
|
|
|
|
}
|
|
|
|
// set the current WS for the LogList
|
|
|
|
switch ( this->craplog.getCurrentWSID() ) {
|
|
|
|
case 11:
|
|
|
|
this->ui->button_LogFiles_Apache->setFlat( false );
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
this->ui->button_LogFiles_Nginx->setFlat( false );
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
this->ui->button_LogFiles_Iis->setFlat( false );
|
|
|
|
break;
|
2022-07-21 21:45:52 +02:00
|
|
|
default:
|
|
|
|
// shouldn't be here
|
|
|
|
throw( &"Unexpected WebServer ID for Craplog: "[this->craplog.getCurrentWSID()] );
|
|
|
|
}
|
|
|
|
// set the current WS for the ViewStats
|
|
|
|
switch ( ws ) {
|
|
|
|
case 11:
|
|
|
|
// already set to index 0 by default
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
for ( int i=0; i<this->ui->box_StatsCount_WebServer->count(); i++ ) {
|
|
|
|
if ( this->ui->box_StatsCount_WebServer->itemText( i ) == "Nginx" ) {
|
|
|
|
this->ui->box_StatsCount_WebServer->setCurrentIndex( i );
|
|
|
|
this->ui->box_StatsSpeed_WebServer->setCurrentIndex( i );
|
|
|
|
this->ui->box_StatsDay_WebServer->setCurrentIndex( i );
|
|
|
|
this->ui->box_StatsRelat_WebServer->setCurrentIndex( i );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
for ( int i=0; i<this->ui->box_StatsCount_WebServer->count(); i++ ) {
|
|
|
|
if ( this->ui->box_StatsCount_WebServer->itemText( i ) == "IIS" ) {
|
|
|
|
this->ui->box_StatsCount_WebServer->setCurrentIndex( i );
|
|
|
|
this->ui->box_StatsSpeed_WebServer->setCurrentIndex( i );
|
|
|
|
this->ui->box_StatsDay_WebServer->setCurrentIndex( i );
|
|
|
|
this->ui->box_StatsRelat_WebServer->setCurrentIndex( i );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// shouldn't be here
|
|
|
|
throw( &"Unexpected WebServer ID: "[ws] );
|
2022-06-27 19:49:09 +02:00
|
|
|
}
|
2022-07-21 21:45:52 +02:00
|
|
|
|
|
|
|
|
2022-06-25 21:17:40 +02:00
|
|
|
// get a fresh list of LogFiles
|
2022-07-09 18:16:09 +02:00
|
|
|
this->craplog_timer = new QTimer(this);
|
|
|
|
connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(wait_ActiveWindow()));
|
|
|
|
this->craplog_timer->start(250);
|
2022-06-20 21:44:58 +02:00
|
|
|
}
|
|
|
|
|
2022-06-21 21:07:06 +02:00
|
|
|
MainWindow::~MainWindow()
|
2022-06-20 21:44:58 +02:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2022-06-24 01:26:00 +02:00
|
|
|
|
2022-07-09 18:16:09 +02:00
|
|
|
//////////////////////////
|
|
|
|
//// INTEGRITY CHECKS ////
|
|
|
|
void MainWindow::wait_ActiveWindow()
|
|
|
|
{
|
|
|
|
if ( this->isActiveWindow() == false ) {
|
|
|
|
std::this_thread::sleep_for( std::chrono::milliseconds(250) );
|
|
|
|
} else {
|
|
|
|
this->craplog_timer->stop();
|
|
|
|
this->makeInitialChecks();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void MainWindow::makeInitialChecks()
|
|
|
|
{
|
|
|
|
bool ok = true;
|
|
|
|
// check that the sqlite plugin is available
|
|
|
|
if ( QSqlDatabase::drivers().contains("QSQLITE") == false ) {
|
|
|
|
// checks failed, abort
|
|
|
|
DialogSec::errSqlDriverNotFound( nullptr, "QSQLITE" );
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ok == true ) {
|
|
|
|
// statistics' database
|
|
|
|
if ( CheckSec::checkStatsDatabase( this->db_stats_path ) == false ) {
|
|
|
|
// checks failed, abort
|
|
|
|
ok = false;
|
|
|
|
} else {
|
|
|
|
this->craplog.setStatsDatabasePath( this->db_stats_path );
|
|
|
|
// used-files' hashes' database
|
|
|
|
if ( CheckSec::checkHashesDatabase( this->db_hashes_path ) == false ) {
|
|
|
|
// checks failed, abort
|
|
|
|
ok = false;
|
|
|
|
} else {
|
|
|
|
this->craplog.setHashesDatabasePath( this->db_hashes_path );
|
|
|
|
if ( this->craplog.hashOps.loadUsedHashesLists( this->db_hashes_path ) == false ) {
|
|
|
|
// failed to load the list, abort
|
|
|
|
ok = false;
|
|
|
|
} else {
|
|
|
|
// craplog variables
|
|
|
|
if ( CheckSec::checkCraplog( this->craplog ) == false ) {
|
|
|
|
// checks failed, abort
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( ok == false ) {
|
|
|
|
this->close();
|
|
|
|
//QCoreApplication::exit(0);
|
|
|
|
//this->destroy();
|
|
|
|
} else {
|
2022-07-21 21:45:52 +02:00
|
|
|
// get available stats dates
|
|
|
|
this->refreshStatsDates();
|
2022-07-22 22:56:49 +02:00
|
|
|
// initialize logs fields boxes
|
|
|
|
this->on_box_StatsDay_LogsType_currentIndexChanged(0);
|
|
|
|
this->on_box_StatsRelat_LogsType_currentIndexChanged(0);
|
2022-07-21 21:45:52 +02:00
|
|
|
// get a fresh list of log files
|
2022-07-09 18:16:09 +02:00
|
|
|
this->on_button_LogFiles_RefreshList_clicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
/////////////////////
|
|
|
|
//// GENERAL USE ////
|
|
|
|
/////////////////////
|
|
|
|
// printable size with suffix and limited decimals
|
2022-07-04 21:08:23 +02:00
|
|
|
QString MainWindow::printableSize( const int bytes )
|
2022-06-30 20:47:05 +02:00
|
|
|
{
|
|
|
|
std::string size_str, size_sfx=" B";
|
|
|
|
float size = (float)bytes;
|
|
|
|
if (size > 1024) {
|
|
|
|
size /= 1024;
|
|
|
|
size_sfx = " KiB";
|
|
|
|
if (size > 1024) {
|
|
|
|
size /= 1024;
|
|
|
|
size_sfx = " MiB";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// cut decimals depending on how big the floor is
|
|
|
|
size_str = std::to_string( size );
|
|
|
|
int cut_index = size_str.find('.')+1;
|
|
|
|
if ( cut_index == 0 ) {
|
|
|
|
cut_index = size_str.find(',')+1;
|
|
|
|
}
|
|
|
|
int n_decimals = 3;
|
|
|
|
if ( size >= 100 ) {
|
|
|
|
n_decimals = 2;
|
|
|
|
if ( size >= 1000 ) {
|
|
|
|
n_decimals = 1;
|
|
|
|
if ( size >= 10000 ) {
|
|
|
|
n_decimals = 0;
|
|
|
|
cut_index --;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( cut_index >= 1 ) {
|
|
|
|
cut_index += n_decimals;
|
|
|
|
if ( cut_index > size_str.size()-1 ) {
|
|
|
|
cut_index = size_str.size()-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString::fromStdString( size_str.substr(0, cut_index ) + size_sfx );
|
|
|
|
}
|
|
|
|
|
|
|
|
// printable speed with suffix and limited decimals
|
2022-07-04 21:08:23 +02:00
|
|
|
QString MainWindow::printableSpeed( const int bytes, const int secs_ )
|
2022-06-30 20:47:05 +02:00
|
|
|
{
|
|
|
|
std::string speed_str, speed_sfx=" B/s";
|
2022-07-04 21:08:23 +02:00
|
|
|
int secs = secs_;
|
|
|
|
if ( secs == 0 ) {
|
|
|
|
secs = 1;
|
|
|
|
}
|
|
|
|
float speed = (float)bytes / (float)secs;
|
|
|
|
if (speed > 1024) {
|
|
|
|
speed /= 1024;
|
2022-06-30 20:47:05 +02:00
|
|
|
speed_sfx = " KiB/s";
|
2022-07-04 21:08:23 +02:00
|
|
|
if (speed > 1024) {
|
|
|
|
speed /= 1024;
|
2022-06-30 20:47:05 +02:00
|
|
|
speed_sfx = " MiB/s";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// cut decimals depending on how big the floor is
|
2022-07-04 21:08:23 +02:00
|
|
|
speed_str = std::to_string( speed );
|
2022-06-30 20:47:05 +02:00
|
|
|
int cut_index = speed_str.find('.')+1;
|
|
|
|
if ( cut_index == 0 ) {
|
|
|
|
cut_index = speed_str.find(',')+1;
|
|
|
|
}
|
|
|
|
int n_decimals = 3;
|
2022-07-04 21:08:23 +02:00
|
|
|
if ( speed >= 100 ) {
|
2022-06-30 20:47:05 +02:00
|
|
|
n_decimals = 2;
|
2022-07-04 21:08:23 +02:00
|
|
|
if ( speed >= 1000 ) {
|
2022-06-30 20:47:05 +02:00
|
|
|
n_decimals = 1;
|
2022-07-04 21:08:23 +02:00
|
|
|
if ( speed >= 10000 ) {
|
2022-06-30 20:47:05 +02:00
|
|
|
n_decimals = 0;
|
|
|
|
cut_index --;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( cut_index >= 1 ) {
|
|
|
|
cut_index += n_decimals;
|
|
|
|
if ( cut_index > speed_str.size()-1 ) {
|
|
|
|
cut_index = speed_str.size()-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString::fromStdString( speed_str.substr(0, cut_index ) + speed_sfx );
|
|
|
|
}
|
|
|
|
|
2022-07-04 21:08:23 +02:00
|
|
|
QString MainWindow::printableTime( const int secs_ )
|
2022-06-30 20:47:05 +02:00
|
|
|
{
|
2022-07-04 21:08:23 +02:00
|
|
|
int secs = secs_;
|
2022-06-30 20:47:05 +02:00
|
|
|
int mins = secs / 60;
|
|
|
|
secs = secs - (mins*60);
|
|
|
|
std::string mins_str = (mins<10) ? "0"+std::to_string(mins) : std::to_string(mins);
|
|
|
|
std::string secs_str = (secs<10) ? "0"+std::to_string(secs) : std::to_string(secs);
|
|
|
|
return QString::fromStdString( mins_str +":"+ secs_str );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-21 21:07:06 +02:00
|
|
|
//////////////
|
|
|
|
//// LOGS ////
|
|
|
|
//////////////
|
2022-06-27 19:49:09 +02:00
|
|
|
// switch to apache web server
|
2022-06-26 23:12:57 +02:00
|
|
|
void MainWindow::on_button_LogFiles_Apache_clicked()
|
|
|
|
{
|
2022-06-27 19:49:09 +02:00
|
|
|
if ( this->craplog.getCurrentWSID() != 11
|
2022-07-03 19:12:42 +02:00
|
|
|
&& this->allowed_web_servers.at( 11 ) == true ) {
|
2022-06-27 19:49:09 +02:00
|
|
|
// enable the enables
|
2022-06-26 23:12:57 +02:00
|
|
|
this->ui->button_LogFiles_Apache->setFlat( false );
|
|
|
|
this->ui->button_LogFiles_Nginx->setFlat( true );
|
|
|
|
this->ui->button_LogFiles_Iis->setFlat( true );
|
2022-06-27 19:49:09 +02:00
|
|
|
// load the list
|
|
|
|
this->craplog.setCurrentWSID( 11 );
|
2022-06-30 20:47:05 +02:00
|
|
|
this->on_button_LogFiles_RefreshList_clicked();
|
2022-07-23 22:16:34 +02:00
|
|
|
QString rich_text;
|
|
|
|
RichText::richLogsDefault( rich_text );
|
|
|
|
this->ui->textLogFiles->setText( rich_text );
|
2022-07-01 21:30:15 +02:00
|
|
|
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
|
2022-07-23 22:16:34 +02:00
|
|
|
rich_text.clear();
|
2022-06-26 23:12:57 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-27 19:49:09 +02:00
|
|
|
// switch to nginx web server
|
2022-06-26 23:12:57 +02:00
|
|
|
void MainWindow::on_button_LogFiles_Nginx_clicked()
|
|
|
|
{
|
2022-06-27 19:49:09 +02:00
|
|
|
if ( this->craplog.getCurrentWSID() != 12
|
2022-07-03 19:12:42 +02:00
|
|
|
&& this->allowed_web_servers.at( 12 ) == true) {
|
2022-06-27 19:49:09 +02:00
|
|
|
// enable the enables
|
2022-06-26 23:12:57 +02:00
|
|
|
this->ui->button_LogFiles_Nginx->setFlat( false );
|
|
|
|
this->ui->button_LogFiles_Apache->setFlat( true );
|
|
|
|
this->ui->button_LogFiles_Iis->setFlat( true );
|
2022-06-27 19:49:09 +02:00
|
|
|
// load the list
|
|
|
|
this->craplog.setCurrentWSID( 12 );
|
2022-06-30 20:47:05 +02:00
|
|
|
this->on_button_LogFiles_RefreshList_clicked();
|
2022-07-23 22:16:34 +02:00
|
|
|
QString rich_text;
|
|
|
|
RichText::richLogsDefault( rich_text );
|
|
|
|
this->ui->textLogFiles->setText( rich_text );
|
2022-07-01 21:30:15 +02:00
|
|
|
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
|
2022-07-23 22:16:34 +02:00
|
|
|
rich_text.clear();
|
2022-06-26 23:12:57 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-27 19:49:09 +02:00
|
|
|
// switch to iis web server
|
2022-06-26 23:12:57 +02:00
|
|
|
void MainWindow::on_button_LogFiles_Iis_clicked()
|
|
|
|
{
|
2022-06-27 19:49:09 +02:00
|
|
|
if ( this->craplog.getCurrentWSID() != 13
|
2022-07-03 19:12:42 +02:00
|
|
|
&& this->allowed_web_servers.at( 13 ) == true ) {
|
2022-06-27 19:49:09 +02:00
|
|
|
// load the list
|
2022-06-26 23:12:57 +02:00
|
|
|
this->ui->button_LogFiles_Iis->setFlat( false );
|
|
|
|
this->ui->button_LogFiles_Apache->setFlat( true );
|
|
|
|
this->ui->button_LogFiles_Nginx->setFlat( true );
|
2022-06-27 19:49:09 +02:00
|
|
|
// load the list
|
|
|
|
this->craplog.setCurrentWSID( 13 );
|
2022-06-30 20:47:05 +02:00
|
|
|
this->on_button_LogFiles_RefreshList_clicked();
|
2022-07-23 22:16:34 +02:00
|
|
|
QString rich_text;
|
|
|
|
RichText::richLogsDefault( rich_text );
|
|
|
|
this->ui->textLogFiles->setText( rich_text );
|
2022-07-01 21:30:15 +02:00
|
|
|
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
|
2022-07-23 22:16:34 +02:00
|
|
|
rich_text.clear();
|
2022-06-26 23:12:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-21 21:07:06 +02:00
|
|
|
// refresh the log files list
|
2022-06-30 20:47:05 +02:00
|
|
|
void MainWindow::on_button_LogFiles_RefreshList_clicked()
|
2022-06-21 21:07:06 +02:00
|
|
|
{
|
2022-06-27 19:49:09 +02:00
|
|
|
std::string col;
|
2022-06-21 21:07:06 +02:00
|
|
|
// clear the current tree
|
|
|
|
this->ui->listLogFiles->clear();
|
2022-06-27 19:49:09 +02:00
|
|
|
this->ui->checkBox_LogFiles_CheckAll->setCheckState( Qt::CheckState::Unchecked );
|
2022-06-21 21:07:06 +02:00
|
|
|
// iterate over elements of list
|
2022-06-23 04:00:37 +02:00
|
|
|
for ( const Craplog::LogFile& log_file : this->craplog.getLogsList(true) ) {
|
2022-06-21 21:07:06 +02:00
|
|
|
// new entry for the tree widget
|
|
|
|
QTreeWidgetItem * item = new QTreeWidgetItem();
|
2022-07-01 21:30:15 +02:00
|
|
|
|
|
|
|
// preliminary check for file-type display
|
|
|
|
if ( this->display_access_logs == false && log_file.type == LogOps::LogType::Access ) {
|
|
|
|
// do not display
|
|
|
|
delete item; // possible memory leak, says cppcheck
|
|
|
|
continue;
|
|
|
|
} else if ( this->display_error_logs == false && log_file.type == LogOps::LogType::Error ) {
|
|
|
|
// do not display
|
|
|
|
delete item; // possible memory leak, says cppcheck
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// preliminary check for file usage display
|
|
|
|
if ( log_file.used_already == true ) {
|
2022-06-27 19:49:09 +02:00
|
|
|
if ( this->display_used_files == false ) {
|
|
|
|
// do not display
|
2022-07-01 21:30:15 +02:00
|
|
|
delete item; // possible memory leak, says cppcheck
|
2022-06-27 19:49:09 +02:00
|
|
|
continue;
|
|
|
|
}
|
2022-07-01 21:30:15 +02:00
|
|
|
// display with red foreground
|
2022-07-03 19:12:42 +02:00
|
|
|
item->setForeground( 0, this->COLORS.at( "red" ) );
|
2022-06-27 19:49:09 +02:00
|
|
|
}
|
2022-07-01 21:30:15 +02:00
|
|
|
|
|
|
|
// preliminary check on file size
|
2022-06-27 19:49:09 +02:00
|
|
|
col = "grey";
|
|
|
|
if ( log_file.size > this->craplog.getWarningSize() ) {
|
|
|
|
if ( this->display_warnsize_files == false ) {
|
|
|
|
// do not display
|
2022-07-01 21:30:15 +02:00
|
|
|
delete item; // possible memory leak, says cppcheck
|
2022-06-27 19:49:09 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
col = "orange";
|
|
|
|
}
|
2022-07-03 19:12:42 +02:00
|
|
|
item->setForeground( 1, this->COLORS.at( col ) );
|
2022-07-01 21:30:15 +02:00
|
|
|
|
|
|
|
// set the name
|
|
|
|
item->setText( 0, log_file.name );
|
|
|
|
// set the size
|
|
|
|
item->setText( 1, this->printableSize( log_file.size ) );
|
2022-07-03 19:12:42 +02:00
|
|
|
item->setFont( 1, this->FONTS.at("main_italic") );
|
2022-06-21 21:07:06 +02:00
|
|
|
// append the item (on top, forced)
|
2022-06-27 19:49:09 +02:00
|
|
|
item->setCheckState(0, Qt::CheckState::Unchecked );
|
2022-06-21 21:07:06 +02:00
|
|
|
this->ui->listLogFiles->addTopLevelItem( item );
|
|
|
|
}
|
2022-06-27 19:49:09 +02:00
|
|
|
if ( this->craplog.getLogsListSize() > 0 ) {
|
|
|
|
// sort the list alphabetically
|
|
|
|
this->ui->listLogFiles->sortByColumn(0, Qt::SortOrder::AscendingOrder );
|
|
|
|
this->ui->checkBox_LogFiles_CheckAll->setEnabled( true );
|
|
|
|
} else {
|
|
|
|
this->ui->checkBox_LogFiles_CheckAll->setCheckState( Qt::CheckState::Unchecked );
|
|
|
|
this->ui->checkBox_LogFiles_CheckAll->setEnabled( false );
|
|
|
|
}
|
2022-06-21 21:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-25 21:17:40 +02:00
|
|
|
void MainWindow::on_checkBox_LogFiles_CheckAll_stateChanged(int arg1)
|
2022-06-21 21:07:06 +02:00
|
|
|
{
|
2022-06-22 21:37:35 +02:00
|
|
|
Qt::CheckState new_state;
|
2022-06-25 21:17:40 +02:00
|
|
|
if ( this->ui->checkBox_LogFiles_CheckAll->checkState() == Qt::CheckState::Checked ) {
|
2022-06-22 21:37:35 +02:00
|
|
|
// check all
|
|
|
|
new_state = Qt::CheckState::Checked;
|
2022-06-30 20:47:05 +02:00
|
|
|
this->ui->button_MakeStats_Start->setEnabled(true);
|
2022-06-25 21:17:40 +02:00
|
|
|
} else if ( this->ui->checkBox_LogFiles_CheckAll->checkState() == Qt::CheckState::Unchecked ) {
|
2022-06-22 21:37:35 +02:00
|
|
|
// un-check all
|
|
|
|
new_state = Qt::CheckState::Unchecked;
|
2022-06-30 20:47:05 +02:00
|
|
|
this->ui->button_MakeStats_Start->setEnabled(false);
|
2022-06-22 21:37:35 +02:00
|
|
|
} else {
|
|
|
|
// do nothing
|
2022-06-30 20:47:05 +02:00
|
|
|
this->ui->button_MakeStats_Start->setEnabled(true);
|
2022-06-22 21:37:35 +02:00
|
|
|
return;
|
|
|
|
}
|
2022-06-21 21:07:06 +02:00
|
|
|
QTreeWidgetItemIterator i(this->ui->listLogFiles);
|
|
|
|
while ( *i ) {
|
2022-06-22 21:37:35 +02:00
|
|
|
(*i)->setCheckState( 0, new_state );
|
|
|
|
++i;
|
2022-06-21 21:07:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
void MainWindow::on_button_LogFiles_ViewFile_clicked()
|
2022-06-21 21:07:06 +02:00
|
|
|
{
|
2022-06-25 18:48:08 +02:00
|
|
|
if ( this->ui->listLogFiles->selectedItems().size() > 0 ) {
|
2022-07-01 21:30:15 +02:00
|
|
|
bool proceed = true;
|
2022-06-25 18:48:08 +02:00
|
|
|
// display the selected item
|
|
|
|
Craplog::LogFile item = this->craplog.getLogFileItem(
|
|
|
|
this->ui->listLogFiles->selectedItems().takeFirst()->text(0) );
|
2022-06-26 22:31:45 +02:00
|
|
|
FormatOps::LogsFormat format;
|
2022-06-26 23:28:54 +02:00
|
|
|
if ( item.type == LogOps::LogType::Access ) {
|
2022-06-26 22:31:45 +02:00
|
|
|
format = this->craplog.getCurrentALF();
|
2022-06-26 23:28:54 +02:00
|
|
|
} else if ( item.type == LogOps::LogType::Error ) {
|
2022-06-26 22:31:45 +02:00
|
|
|
format = this->craplog.getCurrentELF();
|
2022-06-25 18:48:08 +02:00
|
|
|
} else {
|
2022-07-01 21:30:15 +02:00
|
|
|
// this shouldn't be reached, but...
|
|
|
|
proceed = false;
|
2022-07-03 19:12:42 +02:00
|
|
|
DialogSec::errUndefinedLogType( nullptr, item.name );
|
2022-07-01 21:30:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( proceed == true ) {
|
|
|
|
std::string content;
|
|
|
|
try {
|
|
|
|
content = IOutils::readFile( item.path );
|
|
|
|
} catch (const std::ios_base::failure& err) {
|
|
|
|
// failed reading
|
|
|
|
proceed = false;
|
|
|
|
// >> err.what() << //
|
2022-07-03 19:12:42 +02:00
|
|
|
DialogSec::errFailedReadFile( nullptr, item.name );
|
2022-07-01 21:30:15 +02:00
|
|
|
} catch (...) {
|
|
|
|
// failed somehow
|
|
|
|
proceed = false;
|
2022-07-03 19:12:42 +02:00
|
|
|
DialogSec::errFailedReadFile( nullptr, item.name );
|
2022-07-01 21:30:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( proceed == true ) {
|
|
|
|
// succesfully read, now enriched and display
|
2022-07-23 22:16:34 +02:00
|
|
|
QString rich_content;
|
|
|
|
RichText::enrichLogs(
|
|
|
|
rich_content, content,
|
|
|
|
format, this->TB );
|
|
|
|
this->ui->textLogFiles->setText( rich_content );
|
|
|
|
rich_content.clear();
|
2022-07-01 21:30:15 +02:00
|
|
|
}
|
2022-07-23 22:16:34 +02:00
|
|
|
content.clear();
|
2022-07-01 21:30:15 +02:00
|
|
|
}
|
|
|
|
if ( proceed == false ) {
|
|
|
|
// failed to read
|
2022-07-23 22:16:34 +02:00
|
|
|
QString rich_text;
|
|
|
|
RichText::richLogsFailure( rich_text );
|
|
|
|
this->ui->textLogFiles->setText( rich_text );
|
2022-07-01 21:30:15 +02:00
|
|
|
this->ui->textLogFiles->setAlignment( Qt::AlignHCenter );
|
2022-06-25 18:48:08 +02:00
|
|
|
}
|
2022-06-24 19:56:34 +02:00
|
|
|
}
|
2022-06-21 21:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_listLogFiles_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
2022-06-30 20:47:05 +02:00
|
|
|
this->on_button_LogFiles_ViewFile_clicked();
|
2022-06-22 21:37:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_listLogFiles_itemChanged(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
|
|
|
// control checked
|
|
|
|
int n_checked = 0;
|
|
|
|
QTreeWidgetItemIterator i(this->ui->listLogFiles);
|
|
|
|
while ( *i ) {
|
|
|
|
if ( (*i)->checkState(0) == Qt::CheckState::Checked ) {
|
|
|
|
n_checked++;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if ( n_checked == 0 ) {
|
2022-06-25 21:17:40 +02:00
|
|
|
this->ui->checkBox_LogFiles_CheckAll->setCheckState(Qt::CheckState::Unchecked);
|
2022-06-22 21:37:35 +02:00
|
|
|
} else if ( n_checked == this->craplog.getLogsListSize() ) {
|
2022-06-25 21:17:40 +02:00
|
|
|
this->ui->checkBox_LogFiles_CheckAll->setCheckState(Qt::CheckState::Checked);
|
2022-06-22 21:37:35 +02:00
|
|
|
} else {
|
2022-06-25 21:17:40 +02:00
|
|
|
this->ui->checkBox_LogFiles_CheckAll->setCheckState(Qt::CheckState::PartiallyChecked);
|
2022-06-22 21:37:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
void MainWindow::on_button_MakeStats_Start_clicked()
|
2022-06-22 21:37:35 +02:00
|
|
|
{
|
2022-06-30 20:47:05 +02:00
|
|
|
// take actions on Craplog's start
|
|
|
|
this->craplogStarted();
|
|
|
|
|
|
|
|
// feed craplog with the checked files
|
2022-06-22 21:37:35 +02:00
|
|
|
bool proceed = true;
|
|
|
|
QTreeWidgetItemIterator i(this->ui->listLogFiles);
|
|
|
|
while ( *i ) {
|
|
|
|
if ( (*i)->checkState(0) == Qt::CheckState::Checked ) {
|
|
|
|
// tell Craplog to set this file as selected
|
2022-06-27 19:49:09 +02:00
|
|
|
if ( this->craplog.setLogFileSelected( (*i)->text(0) ) == false ) {
|
2022-06-22 21:37:35 +02:00
|
|
|
// this shouldn't be, but...
|
2022-07-01 21:30:15 +02:00
|
|
|
if ( DialogSec::choiceSelectedFileNotFound( nullptr, (*i)->text(0) ) == false ) {
|
2022-06-30 20:47:05 +02:00
|
|
|
proceed = false;
|
2022-06-22 21:37:35 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
2022-06-30 20:47:05 +02:00
|
|
|
|
2022-07-08 21:40:58 +02:00
|
|
|
if ( proceed == true ) {
|
|
|
|
// check files to be used before to start
|
2022-07-09 18:16:09 +02:00
|
|
|
proceed = this->craplog.checkStuff();
|
2022-07-08 21:40:58 +02:00
|
|
|
} else {
|
|
|
|
this->craplogFinished();
|
|
|
|
}
|
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
if ( proceed == true ) {
|
2022-07-01 21:30:15 +02:00
|
|
|
// periodically update perfs
|
2022-06-30 20:47:05 +02:00
|
|
|
this->craplog_timer = new QTimer(this);
|
2022-07-04 21:08:23 +02:00
|
|
|
connect(this->craplog_timer, SIGNAL(timeout()), this, SLOT(update_Craplog_PerfData()));
|
2022-06-30 20:47:05 +02:00
|
|
|
this->craplog_timer->start(250);
|
2022-07-01 21:30:15 +02:00
|
|
|
// run craplog as thread
|
|
|
|
this->craplog_timer_start = std::chrono::system_clock::now();
|
2022-06-30 20:47:05 +02:00
|
|
|
this->craplog_thread = std::thread( &Craplog::run, &this->craplog );
|
|
|
|
} else {
|
|
|
|
this->craplogFinished();
|
2022-06-22 21:37:35 +02:00
|
|
|
}
|
2022-06-30 20:47:05 +02:00
|
|
|
}
|
2022-06-24 01:26:00 +02:00
|
|
|
|
2022-07-01 21:30:15 +02:00
|
|
|
void MainWindow::reset_MakeStats_labels()
|
|
|
|
{
|
|
|
|
// reset to default
|
|
|
|
this->ui->label_MakeStats_Size->setText( "0 B" );
|
|
|
|
this->ui->label_MakeStats_Lines->setText( "0" );
|
|
|
|
// time and speed
|
|
|
|
this->ui->label_MakeStats_Time->setText( "00:00" );
|
|
|
|
this->ui->label_MakeStats_Speed->setText( "0 B/s" );
|
|
|
|
}
|
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
void MainWindow::update_MakeStats_labels()
|
|
|
|
{
|
|
|
|
// update values
|
2022-07-04 21:08:23 +02:00
|
|
|
int size, secs;
|
2022-06-30 20:47:05 +02:00
|
|
|
// size and lines
|
2022-07-05 21:50:51 +02:00
|
|
|
if ( this->craplog.isParsing() == true ) {
|
|
|
|
this->craplog.collectPerfData();
|
|
|
|
}
|
2022-06-30 20:47:05 +02:00
|
|
|
size = this->craplog.getParsedSize();
|
|
|
|
this->ui->label_MakeStats_Size->setText( this->printableSize( size ) );
|
|
|
|
this->ui->label_MakeStats_Lines->setText( QString::fromStdString(std::to_string(this->craplog.getParsedLines())) );
|
|
|
|
// time and speed
|
|
|
|
this->craplog_timer_elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
|
2022-07-08 21:40:58 +02:00
|
|
|
this->craplog_timer_start - std::chrono::system_clock::now()
|
2022-06-30 20:47:05 +02:00
|
|
|
);
|
2022-07-05 21:50:51 +02:00
|
|
|
size = this->craplog.getPerfSize();
|
2022-06-30 20:47:05 +02:00
|
|
|
secs = this->craplog_timer_elapsed.count() / -1000000000;
|
|
|
|
this->ui->label_MakeStats_Time->setText( this->printableTime( secs ));
|
|
|
|
this->ui->label_MakeStats_Speed->setText( this->printableSpeed( size, secs ));
|
2022-07-04 21:08:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::update_Craplog_PerfData()
|
|
|
|
{
|
|
|
|
// craplog is running as thread, update the values meanwhile
|
|
|
|
this->update_MakeStats_labels();
|
|
|
|
// check if Craplog has finished working
|
2022-06-30 20:47:05 +02:00
|
|
|
if ( this->craplog.isWorking() == false ) {
|
|
|
|
this->craplog_timer->stop();
|
|
|
|
this->craplog_thread.join();
|
|
|
|
this->craplogFinished();
|
|
|
|
}
|
|
|
|
}
|
2022-06-24 01:26:00 +02:00
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
void MainWindow::craplogStarted()
|
|
|
|
{
|
2022-07-04 21:08:23 +02:00
|
|
|
// reset perfs
|
|
|
|
this->reset_MakeStats_labels();
|
|
|
|
this->craplog.logOps.resetPerfData();
|
2022-06-30 20:47:05 +02:00
|
|
|
// disable the LogFiles section
|
|
|
|
this->ui->LogBoxFiles->setEnabled(false);
|
|
|
|
// disable the start button
|
|
|
|
this->ui->button_MakeStats_Start->setEnabled(false);
|
|
|
|
// enable all labels (needed only the first time)
|
|
|
|
this->ui->icon_MakeStats_Size->setEnabled(false);
|
|
|
|
this->ui->label_MakeStats_Size->setEnabled(true);
|
|
|
|
this->ui->icon_MakeStats_Lines->setEnabled(false);
|
|
|
|
this->ui->label_MakeStats_Lines->setEnabled(true);
|
|
|
|
this->ui->icon_MakeStats_Time->setEnabled(false);
|
|
|
|
this->ui->label_MakeStats_Time->setEnabled(true);
|
|
|
|
this->ui->icon_MakeStats_Speed->setEnabled(false);
|
|
|
|
this->ui->label_MakeStats_Speed->setEnabled(true);
|
2022-07-21 21:45:52 +02:00
|
|
|
// disable the stats/settings tab
|
|
|
|
this->ui->View->setEnabled(false);
|
2022-07-05 21:50:51 +02:00
|
|
|
this->ui->Set->setEnabled(false);
|
2022-06-30 20:47:05 +02:00
|
|
|
}
|
2022-06-24 01:26:00 +02:00
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
void MainWindow::craplogFinished()
|
|
|
|
{
|
2022-07-04 21:08:23 +02:00
|
|
|
// update the perf data one last time, just in case
|
|
|
|
this->update_MakeStats_labels();
|
2022-07-22 22:56:49 +02:00
|
|
|
this->craplog.makeGraphs( this->FONTS, this->ui->chart_MakeStats_Access, this->ui->chart_MakeStats_Error, this->ui->chart_MakeStats_Traffic );
|
2022-07-04 21:08:23 +02:00
|
|
|
// clean up temp vars
|
2022-07-10 18:14:00 +02:00
|
|
|
this->craplog.clearDataCollection();
|
2022-07-04 21:08:23 +02:00
|
|
|
this->craplog.logOps.resetPerfData();
|
|
|
|
|
2022-06-30 20:47:05 +02:00
|
|
|
// refresh the logs list
|
|
|
|
this->on_button_LogFiles_RefreshList_clicked();
|
|
|
|
// enable the LogFiles section
|
|
|
|
this->ui->LogBoxFiles->setEnabled(true);
|
2022-07-05 21:50:51 +02:00
|
|
|
// enable all labels (needed only the first time each session)
|
2022-06-30 20:47:05 +02:00
|
|
|
this->ui->icon_MakeStats_Size->setEnabled(true);
|
|
|
|
this->ui->icon_MakeStats_Lines->setEnabled(true);
|
|
|
|
this->ui->icon_MakeStats_Time->setEnabled(true);
|
|
|
|
this->ui->icon_MakeStats_Speed->setEnabled(true);
|
2022-07-21 21:45:52 +02:00
|
|
|
// enable back the stats/settings tab
|
|
|
|
this->ui->View->setEnabled(true);
|
2022-07-05 21:50:51 +02:00
|
|
|
this->ui->Set->setEnabled(true);
|
2022-07-21 21:45:52 +02:00
|
|
|
// get a fresh collection of available stats dates
|
|
|
|
this->refreshStatsDates();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
//// STATS ////
|
|
|
|
///////////////
|
|
|
|
// refresh all the dates boxes
|
|
|
|
void MainWindow::refreshStatsDates()
|
|
|
|
{
|
|
|
|
this->crapview.refreshDates();
|
2022-07-22 22:56:49 +02:00
|
|
|
this->on_box_StatsSpeed_WebServer_currentIndexChanged(0);
|
|
|
|
this->on_box_StatsCount_WebServer_currentIndexChanged(0);
|
|
|
|
this->on_box_StatsDay_WebServer_currentIndexChanged(0);
|
|
|
|
this->on_box_StatsRelat_WebServer_currentIndexChanged(0);
|
2022-07-21 21:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
//// SPEED ////
|
2022-07-22 22:56:49 +02:00
|
|
|
void MainWindow::checkStatsSpeedDrawable()
|
|
|
|
{
|
|
|
|
if ( this->ui->box_StatsSpeed_Year->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsSpeed_Month->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsSpeed_Day->currentIndex() >= 0 ) {
|
|
|
|
// enable the draw buttpn
|
|
|
|
this->ui->button_StatsSpeed_Draw->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
// disable the draw button
|
|
|
|
this->ui->button_StatsSpeed_Draw->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-21 21:45:52 +02:00
|
|
|
void MainWindow::on_box_StatsSpeed_WebServer_currentIndexChanged( int index )
|
|
|
|
{
|
|
|
|
this->ui->box_StatsSpeed_Year->clear();
|
|
|
|
this->ui->box_StatsSpeed_Year->addItems(
|
|
|
|
this->crapview.getYears(
|
|
|
|
this->ui->box_StatsSpeed_WebServer->currentText(),
|
|
|
|
"Access" ) );
|
|
|
|
this->ui->box_StatsSpeed_Year->setCurrentIndex( 0 );
|
2022-07-22 22:56:49 +02:00
|
|
|
this->checkStatsSpeedDrawable();
|
2022-07-21 21:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsSpeed_Year_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsSpeed_Month->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsSpeed_Month->addItems(
|
|
|
|
this->crapview.getMonths(
|
|
|
|
this->ui->box_StatsSpeed_WebServer->currentText(),
|
|
|
|
"Access",
|
|
|
|
this->ui->box_StatsSpeed_Year->currentText() ) );
|
|
|
|
this->ui->box_StatsSpeed_Month->setCurrentIndex( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsSpeed_Month_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsSpeed_Day->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsSpeed_Day->addItems(
|
|
|
|
this->crapview.getDays(
|
|
|
|
this->ui->box_StatsSpeed_WebServer->currentText(),
|
|
|
|
"Access",
|
|
|
|
this->ui->box_StatsSpeed_Year->currentText(),
|
|
|
|
this->ui->box_StatsSpeed_Month->currentText() ) );
|
|
|
|
this->ui->box_StatsSpeed_Day->setCurrentIndex( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsSpeed_Draw_clicked()
|
|
|
|
{
|
2022-07-22 22:56:49 +02:00
|
|
|
this->crapview.drawSpeed(
|
|
|
|
this->ui->table_StatsSpeed_Fields,
|
|
|
|
this->ui->chart_SatsSpeed,
|
|
|
|
this->FONTS,
|
|
|
|
this->ui->box_StatsSpeed_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsSpeed_Year->currentText(),
|
|
|
|
this->ui->box_StatsSpeed_Month->currentText(),
|
|
|
|
this->ui->box_StatsSpeed_Day->currentText(),
|
|
|
|
this->ui->inLine_StatsSpeed_Protocol->text(),
|
|
|
|
this->ui->inLine_StatsSpeed_Method->text(),
|
|
|
|
this->ui->inLine_StatsSpeed_Uri->text(),
|
|
|
|
this->ui->inLine_StatsSpeed_Query->text(),
|
|
|
|
this->ui->inLine_StatsSpeed_Response->text() );
|
2022-06-21 21:07:06 +02:00
|
|
|
}
|
|
|
|
|
2022-07-21 21:45:52 +02:00
|
|
|
|
|
|
|
///////////////
|
|
|
|
//// COUNT ////
|
2022-07-22 22:56:49 +02:00
|
|
|
void MainWindow::checkStatsCountDrawable()
|
|
|
|
{
|
|
|
|
if ( this->ui->box_StatsCount_Year->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsCount_Month->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsCount_Day->currentIndex() >= 0 ) {
|
|
|
|
// enable the draw buttpn
|
|
|
|
this->ui->scrollArea_StatsCount_Access->setEnabled(true);
|
|
|
|
this->ui->scrollArea_StatsCount_Error->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
// disable the draw button
|
|
|
|
this->ui->scrollArea_StatsCount_Access->setEnabled(false);
|
|
|
|
this->ui->scrollArea_StatsCount_Error->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsCount_WebServer_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsCount_Year->clear();
|
|
|
|
this->ui->box_StatsCount_Year->addItems(
|
|
|
|
this->crapview.getYears(
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(),
|
|
|
|
this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() )));
|
|
|
|
this->ui->box_StatsCount_Year->setCurrentIndex( 0 );
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->checkStatsCountDrawable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_tabs_StatsCount_AccErr_currentChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsCount_Year->clear();
|
|
|
|
this->ui->box_StatsCount_Year->addItems(
|
|
|
|
this->crapview.getYears(
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(),
|
|
|
|
this->ui->tabs_StatsCount_AccErr->tabText( index ) ));
|
|
|
|
this->ui->box_StatsCount_Year->setCurrentIndex( 0 );
|
|
|
|
this->checkStatsCountDrawable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsCount_Year_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsCount_Month->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsCount_Month->addItems(
|
|
|
|
this->crapview.getMonths(
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(),
|
|
|
|
this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText() ) );
|
|
|
|
this->ui->box_StatsCount_Month->setCurrentIndex( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsCount_Month_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsCount_Day->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsCount_Day->addItems(
|
|
|
|
this->crapview.getDays(
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(),
|
|
|
|
this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(),
|
|
|
|
this->ui->box_StatsCount_Month->currentText() ) );
|
|
|
|
this->ui->box_StatsCount_Day->setCurrentIndex( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::resetStatsCountAccButtons()
|
|
|
|
{
|
|
|
|
this->ui->button_StatsCount_Protocol->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Method->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Request->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Query->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Response->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Referrer->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Cookie->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_UserAgent->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_AccClient->setFlat( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::resetStatsCountErrButtons()
|
|
|
|
{
|
|
|
|
this->ui->button_StatsCount_Level->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Message->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Source->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_Port->setFlat( true );
|
|
|
|
this->ui->button_StatsCount_ErrClient->setFlat( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Protocol_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Protocol->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_Protocol->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Method_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Method->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_Method->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Request_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Request->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_Request->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Query_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Query->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_Query->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Response_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Response->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_Response->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Referrer_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Referrer->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_Referrer->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Cookie_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Cookie->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_Cookie->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_UserAgent_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_UserAgent->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_UserAgent->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_AccClient_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_AccClient->text() );
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->ui->button_StatsCount_AccClient->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Level_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Level->text() );
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->ui->button_StatsCount_Level->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Message_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Message->text() );
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->ui->button_StatsCount_Message->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Source_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Source->text() );
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->ui->button_StatsCount_Source->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_Port_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_Port->text() );
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->ui->button_StatsCount_Port->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsCount_ErrClient_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawCount(
|
|
|
|
this->ui->chart_StatsCount, this->FONTS,
|
|
|
|
this->ui->box_StatsCount_WebServer->currentText(), this->ui->tabs_StatsCount_AccErr->tabText( this->ui->tabs_StatsCount_AccErr->currentIndex() ),
|
|
|
|
this->ui->box_StatsCount_Year->currentText(), this->ui->box_StatsCount_Month->currentText(), this->ui->box_StatsCount_Day->currentText(),
|
|
|
|
this->ui->button_StatsCount_ErrClient->text() );
|
|
|
|
this->resetStatsCountAccButtons();
|
|
|
|
this->resetStatsCountErrButtons();
|
|
|
|
this->ui->button_StatsCount_ErrClient->setFlat( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
//// DAY ////
|
|
|
|
void MainWindow::checkStatsDayDrawable()
|
|
|
|
{
|
|
|
|
bool aux = true;
|
|
|
|
// secondary date (period)
|
|
|
|
if ( this->ui->checkBox_StatsDay_Period->isChecked() == true ) {
|
|
|
|
if ( this->ui->box_StatsDay_ToYear->currentIndex() < 0
|
|
|
|
&& this->ui->box_StatsDay_ToMonth->currentIndex() < 0
|
|
|
|
&& this->ui->box_StatsDay_ToDay->currentIndex() < 0 ) {
|
|
|
|
aux = false;
|
|
|
|
} else {
|
2022-07-23 15:11:55 +02:00
|
|
|
int a,b;
|
|
|
|
a = this->ui->box_StatsDay_ToYear->currentText().toInt();
|
|
|
|
b = this->ui->box_StatsDay_FromYear->currentText().toInt();
|
|
|
|
if ( a < b ) {
|
2022-07-22 22:56:49 +02:00
|
|
|
// year 'to' is less than 'from'
|
|
|
|
aux = false;
|
2022-07-23 15:11:55 +02:00
|
|
|
} else if ( a == b ) {
|
|
|
|
a = this->crapview.getMonthNumber( this->ui->box_StatsDay_ToMonth->currentText() );
|
|
|
|
b = this->crapview.getMonthNumber( this->ui->box_StatsDay_FromMonth->currentText() );
|
|
|
|
if ( a < b ) {
|
2022-07-22 22:56:49 +02:00
|
|
|
// month 'to' is less than 'from'
|
|
|
|
aux = false;
|
2022-07-23 15:11:55 +02:00
|
|
|
} else if ( a == b ) {
|
|
|
|
a = this->ui->box_StatsDay_ToDay->currentText().toInt();
|
|
|
|
b = this->ui->box_StatsDay_FromDay->currentText().toInt();
|
|
|
|
if ( a < b ) {
|
2022-07-22 22:56:49 +02:00
|
|
|
// day 'to' is less than 'from'
|
|
|
|
aux = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// primary date
|
|
|
|
if ( this->ui->box_StatsDay_FromYear->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsDay_FromMonth->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsDay_FromDay->currentIndex() >= 0
|
|
|
|
&& aux == true ) {
|
|
|
|
// enable the draw buttpn
|
|
|
|
this->ui->button_StatsDay_Draw->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
// disable the draw button
|
|
|
|
this->ui->button_StatsDay_Draw->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsDay_WebServer_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
QStringList years = this->crapview.getYears(
|
|
|
|
this->ui->box_StatsDay_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsDay_LogsType->currentText() );
|
|
|
|
|
|
|
|
this->ui->box_StatsDay_FromYear->clear();
|
|
|
|
this->ui->box_StatsDay_FromYear->addItems( years );
|
|
|
|
this->ui->box_StatsDay_FromYear->setCurrentIndex( 0 );
|
|
|
|
if ( this->ui->checkBox_StatsDay_Period->isChecked() == true ) {
|
|
|
|
this->ui->box_StatsDay_ToYear->clear();
|
|
|
|
this->ui->box_StatsDay_ToYear->addItems( years );
|
|
|
|
this->ui->box_StatsDay_ToYear->setCurrentIndex( 0 );
|
|
|
|
}
|
|
|
|
years.clear();
|
|
|
|
this->checkStatsDayDrawable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsDay_LogsType_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->on_box_StatsDay_WebServer_currentIndexChanged(0);
|
|
|
|
this->ui->box_StatsDay_LogsField->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsDay_LogsField->addItems(
|
|
|
|
this->crapview.getFields(
|
|
|
|
"Daytime",
|
|
|
|
this->ui->box_StatsDay_LogsType->currentText() ));
|
|
|
|
this->ui->box_StatsDay_LogsField->setCurrentIndex( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsDay_LogsField_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->inLine_StatsDay_Filter->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsDay_FromYear_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsDay_FromMonth->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsDay_FromMonth->addItems(
|
|
|
|
this->crapview.getMonths(
|
|
|
|
this->ui->box_StatsDay_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsDay_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsDay_FromYear->currentText() ) );
|
|
|
|
this->ui->box_StatsDay_FromMonth->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 15:11:55 +02:00
|
|
|
this->checkStatsDayDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsDay_FromMonth_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsDay_FromDay->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsDay_FromDay->addItems(
|
|
|
|
this->crapview.getDays(
|
|
|
|
this->ui->box_StatsDay_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsDay_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsDay_FromYear->currentText(),
|
|
|
|
this->ui->box_StatsDay_FromMonth->currentText() ) );
|
|
|
|
this->ui->box_StatsDay_FromDay->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 15:11:55 +02:00
|
|
|
this->checkStatsDayDrawable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsDay_FromDay_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->checkStatsDayDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_checkBox_StatsDay_Period_stateChanged(int state)
|
|
|
|
{
|
|
|
|
if ( state == Qt::CheckState::Checked ) {
|
|
|
|
this->ui->box_StatsDay_ToYear->setEnabled( true );
|
|
|
|
this->ui->box_StatsDay_ToMonth->setEnabled( true );
|
|
|
|
this->ui->box_StatsDay_ToDay->setEnabled( true );
|
|
|
|
// add available dates
|
|
|
|
this->ui->box_StatsDay_ToYear->addItems( this->crapview.getYears(
|
|
|
|
this->ui->box_StatsDay_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsDay_LogsType->currentText() ) );
|
|
|
|
this->ui->box_StatsDay_ToYear->setCurrentIndex( 0 );
|
|
|
|
} else {
|
|
|
|
this->ui->box_StatsDay_ToYear->clear();
|
|
|
|
this->ui->box_StatsDay_ToYear->setEnabled( false );
|
|
|
|
this->ui->box_StatsDay_ToMonth->clear();
|
|
|
|
this->ui->box_StatsDay_ToMonth->setEnabled( false );
|
|
|
|
this->ui->box_StatsDay_ToDay->clear();
|
|
|
|
this->ui->box_StatsDay_ToDay->setEnabled( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsDay_ToYear_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsDay_ToMonth->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsDay_ToMonth->addItems(
|
|
|
|
this->crapview.getMonths(
|
|
|
|
this->ui->box_StatsDay_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsDay_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsDay_ToYear->currentText() ) );
|
|
|
|
this->ui->box_StatsDay_ToMonth->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 15:11:55 +02:00
|
|
|
this->checkStatsDayDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsDay_ToMonth_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsDay_ToDay->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsDay_ToDay->addItems(
|
|
|
|
this->crapview.getDays(
|
|
|
|
this->ui->box_StatsDay_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsDay_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsDay_ToYear->currentText(),
|
|
|
|
this->ui->box_StatsDay_ToMonth->currentText() ) );
|
|
|
|
this->ui->box_StatsDay_ToDay->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 15:11:55 +02:00
|
|
|
this->checkStatsDayDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
void MainWindow::on_box_StatsDay_ToDay_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->checkStatsDayDrawable();
|
|
|
|
}
|
2022-07-22 22:56:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_button_StatsDay_Draw_clicked()
|
|
|
|
{
|
2022-07-23 15:11:55 +02:00
|
|
|
std::cout << this->ui->inLine_StatsDay_Filter->text().toStdString() << std::endl;
|
2022-07-22 22:56:49 +02:00
|
|
|
this->crapview.drawDay(
|
|
|
|
this->ui->chart_StatsDay,
|
|
|
|
this->FONTS,
|
|
|
|
this->ui->box_StatsDay_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsDay_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsDay_FromYear->currentText(),
|
|
|
|
this->ui->box_StatsDay_FromMonth->currentText(),
|
|
|
|
this->ui->box_StatsDay_FromDay->currentText(),
|
|
|
|
( this->ui->checkBox_StatsDay_Period->isChecked() ) ? this->ui->box_StatsDay_ToYear->currentText() : "",
|
|
|
|
( this->ui->checkBox_StatsDay_Period->isChecked() ) ? this->ui->box_StatsDay_ToMonth->currentText() : "",
|
|
|
|
( this->ui->checkBox_StatsDay_Period->isChecked() ) ? this->ui->box_StatsDay_ToDay->currentText() : "",
|
|
|
|
this->ui->box_StatsDay_LogsField->currentText(),
|
|
|
|
this->ui->inLine_StatsDay_Filter->text() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
////////////////////
|
|
|
|
//// RELATIONAL ////
|
|
|
|
void MainWindow::checkStatsRelatDrawable()
|
|
|
|
{
|
2022-07-23 15:11:55 +02:00
|
|
|
bool aux = true;
|
2022-07-22 22:56:49 +02:00
|
|
|
if ( this->ui->box_StatsRelat_FromYear->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsRelat_FromMonth->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsRelat_FromDay->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsRelat_ToYear->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsRelat_ToMonth->currentIndex() >= 0
|
|
|
|
&& this->ui->box_StatsRelat_ToDay->currentIndex() >= 0 ) {
|
2022-07-23 15:11:55 +02:00
|
|
|
// check period validity
|
|
|
|
int a,b;
|
|
|
|
a = this->ui->box_StatsRelat_ToYear->currentText().toInt();
|
|
|
|
b = this->ui->box_StatsRelat_FromYear->currentText().toInt();
|
|
|
|
if ( a < b ) {
|
|
|
|
// year 'to' is less than 'from'
|
|
|
|
aux = false;
|
|
|
|
} else if ( a == b ) {
|
|
|
|
a = this->crapview.getMonthNumber( this->ui->box_StatsRelat_ToMonth->currentText() );
|
|
|
|
b = this->crapview.getMonthNumber( this->ui->box_StatsRelat_FromMonth->currentText() );
|
|
|
|
if ( a < b ) {
|
|
|
|
// month 'to' is less than 'from'
|
|
|
|
aux = false;
|
|
|
|
} else if ( a == b ) {
|
|
|
|
a = this->ui->box_StatsRelat_ToDay->currentText().toInt();
|
|
|
|
b = this->ui->box_StatsRelat_FromDay->currentText().toInt();
|
|
|
|
if ( a < b ) {
|
|
|
|
// day 'to' is less than 'from'
|
|
|
|
aux = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-22 22:56:49 +02:00
|
|
|
} else {
|
|
|
|
// disable the draw button
|
2022-07-23 15:11:55 +02:00
|
|
|
aux = false;
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
2022-07-23 15:11:55 +02:00
|
|
|
this->ui->button_StatsRelat_Draw->setEnabled( aux );
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsRelat_WebServer_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
QStringList years = this->crapview.getYears(
|
|
|
|
this->ui->box_StatsRelat_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsRelat_LogsType->currentText() );
|
|
|
|
// from
|
|
|
|
this->ui->box_StatsRelat_FromYear->clear();
|
|
|
|
this->ui->box_StatsRelat_FromYear->addItems( years );
|
|
|
|
this->ui->box_StatsRelat_FromYear->setCurrentIndex( 0 );
|
|
|
|
// to
|
|
|
|
this->ui->box_StatsRelat_ToYear->clear();
|
|
|
|
this->ui->box_StatsRelat_ToYear->addItems( years );
|
|
|
|
this->ui->box_StatsRelat_ToYear->setCurrentIndex( 0 );
|
|
|
|
years.clear();
|
|
|
|
this->checkStatsRelatDrawable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsRelat_LogsType_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->on_box_StatsRelat_WebServer_currentIndexChanged(0);
|
|
|
|
this->ui->box_StatsRelat_LogsField_1->clear();
|
|
|
|
this->ui->box_StatsRelat_LogsField_2->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
QStringList fields = this->crapview.getFields(
|
|
|
|
"Relational",
|
|
|
|
this->ui->box_StatsRelat_LogsType->currentText() );
|
|
|
|
this->ui->box_StatsRelat_LogsField_1->addItems( fields );
|
|
|
|
this->ui->box_StatsRelat_LogsField_2->addItems( fields );
|
|
|
|
this->ui->box_StatsRelat_LogsField_1->setCurrentIndex( 0 );
|
|
|
|
this->ui->box_StatsRelat_LogsField_2->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 22:16:34 +02:00
|
|
|
this->checkStatsRelatDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsRelat_LogsField_1_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->inLine_StatsRelat_Filter_1->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsRelat_LogsField_2_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->inLine_StatsRelat_Filter_2->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsRelat_FromYear_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsRelat_FromMonth->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsRelat_FromMonth->addItems(
|
|
|
|
this->crapview.getMonths(
|
|
|
|
this->ui->box_StatsRelat_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsRelat_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromYear->currentText() ) );
|
|
|
|
this->ui->box_StatsRelat_FromMonth->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 22:16:34 +02:00
|
|
|
this->checkStatsRelatDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsRelat_FromMonth_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsRelat_FromDay->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsRelat_FromDay->addItems(
|
|
|
|
this->crapview.getDays(
|
|
|
|
this->ui->box_StatsRelat_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsRelat_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromYear->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromMonth->currentText() ) );
|
|
|
|
this->ui->box_StatsRelat_FromDay->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 22:16:34 +02:00
|
|
|
this->checkStatsRelatDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
void MainWindow::on_box_StatsRelat_FromDay_currentIndexChanged(int index)
|
|
|
|
{
|
2022-07-23 22:16:34 +02:00
|
|
|
this->checkStatsRelatDrawable();
|
2022-07-23 15:11:55 +02:00
|
|
|
}
|
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
void MainWindow::on_box_StatsRelat_ToYear_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsRelat_ToMonth->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsRelat_ToMonth->addItems(
|
|
|
|
this->crapview.getMonths(
|
|
|
|
this->ui->box_StatsRelat_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsRelat_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromYear->currentText() ) );
|
|
|
|
this->ui->box_StatsRelat_ToMonth->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 22:16:34 +02:00
|
|
|
this->checkStatsRelatDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_box_StatsRelat_ToMonth_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
this->ui->box_StatsRelat_ToDay->clear();
|
|
|
|
if ( index != -1 ) {
|
|
|
|
this->ui->box_StatsRelat_ToDay->addItems(
|
|
|
|
this->crapview.getDays(
|
|
|
|
this->ui->box_StatsRelat_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsRelat_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromYear->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromMonth->currentText() ) );
|
|
|
|
this->ui->box_StatsRelat_ToDay->setCurrentIndex( 0 );
|
|
|
|
}
|
2022-07-23 22:16:34 +02:00
|
|
|
this->checkStatsRelatDrawable();
|
2022-07-22 22:56:49 +02:00
|
|
|
}
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
void MainWindow::on_box_StatsRelat_ToDay_currentIndexChanged(int index)
|
|
|
|
{
|
2022-07-23 22:16:34 +02:00
|
|
|
this->checkStatsRelatDrawable();
|
2022-07-23 15:11:55 +02:00
|
|
|
}
|
|
|
|
|
2022-07-22 22:56:49 +02:00
|
|
|
|
|
|
|
void MainWindow::on_button_StatsRelat_Draw_clicked()
|
|
|
|
{
|
|
|
|
this->crapview.drawRelat(
|
|
|
|
this->ui->chart_StatsRelat,
|
|
|
|
this->FONTS,
|
|
|
|
this->ui->box_StatsRelat_WebServer->currentText(),
|
|
|
|
this->ui->box_StatsRelat_LogsType->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromYear->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromMonth->currentText(),
|
|
|
|
this->ui->box_StatsRelat_FromDay->currentText(),
|
|
|
|
this->ui->box_StatsRelat_ToYear->currentText(),
|
|
|
|
this->ui->box_StatsRelat_ToMonth->currentText(),
|
|
|
|
this->ui->box_StatsRelat_ToDay->currentText(),
|
|
|
|
this->ui->box_StatsRelat_LogsField_1->currentText(),
|
|
|
|
this->ui->inLine_StatsRelat_Filter_1->text(),
|
|
|
|
this->ui->box_StatsRelat_LogsField_2->currentText(),
|
|
|
|
this->ui->inLine_StatsRelat_Filter_2->text() );
|
|
|
|
}
|
|
|
|
|
2022-07-23 15:11:55 +02:00
|
|
|
|
|
|
|
|