This commit is contained in:
Valentino Orlandi 2024-01-22 01:49:22 +01:00
parent 3ce62bb760
commit 82de6c4ca4
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
12 changed files with 92 additions and 89 deletions

View File

@ -2,9 +2,9 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "globals/global_configs.h"
#include "main_lib.h"
#include "defines/web_servers.h"
#include "globals/global_configs.h"
#include "customs/treewidgetitems.h"
@ -194,9 +194,9 @@ MainWindow::MainWindow(QWidget *parent)
this->ui->box_ConfWindow_Theme->setCurrentIndex( static_cast<int>(GlobalConfigs::window_theme) );
this->ui->box_ConfWindow_Icons->setCurrentIndex( static_cast<int>(GlobalConfigs::icons_theme) );
// dialogs
this->ui->slider_ConfDialogs_General->setValue( this->dialogs_level );
this->ui->slider_ConfDialogs_Logs->setValue( this->craplog.getDialogsLevel() );
this->ui->slider_ConfDialogs_Stats->setValue( this->crapview.getDialogsLevel() );
this->ui->slider_ConfDialogs_General->setValue( static_cast<int>(this->dialogs_level) );
this->ui->slider_ConfDialogs_Logs->setValue( static_cast<int>(this->craplog.getDialogsLevel()) );
this->ui->slider_ConfDialogs_Stats->setValue( static_cast<int>(this->crapview.getDialogsLevel()) );
// text browser
this->ui->box_ConfTextBrowser_Font->setCurrentText( this->TB.getFontFamily() );
this->ui->checkBox_ConfTextBrowser_WideLines->setChecked( this->TB.getWideLinesUsage() );
@ -342,7 +342,7 @@ void MainWindow::readConfigs()
if ( err.value() ) {
proceed &= false;
QString file;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
file = QString::fromStdString( this->configs_path );
err_msg = QString::fromStdString( err.message() );
}
@ -356,7 +356,7 @@ void MainWindow::readConfigs()
proceed = IOutils::renameAsCopy( this->configs_path, err );
if ( ! proceed ) {
QString path;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
path = QString::fromStdString( this->configs_path );
if ( err.value() ) {
err_msg = QString::fromStdString( err.message() );
@ -370,7 +370,7 @@ void MainWindow::readConfigs()
// configuration file not found
proceed &= false;
QString file;
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
file = QString::fromStdString( this->configs_path );
}
DialogSec::warnConfFileNotFound( file );
@ -439,7 +439,7 @@ void MainWindow::readConfigs()
GlobalConfigs::charts_theme = static_cast<ChartsTheme>( std::stoi( val ) );
} else if ( var == "MainDialogsLevel" ) {
this->dialogs_level = std::stoi( val );
this->dialogs_level = fromInt( std::stoi( val ) );
} else if ( var == "DefaultWebServer" ) {
this->default_web_server = fromString( val );
@ -466,7 +466,7 @@ void MainWindow::readConfigs()
this->on_box_ConfTextBrowser_ColorScheme_currentIndexChanged( std::stoi( val ) );
} else if ( var == "CraplogDialogsLevel" ) {
this->craplog.setDialogsLevel( std::stoi( val ) );
this->craplog.setDialogsLevel( fromInt( std::stoi( val ) ) );
} else if ( var == "HideUsedFiles" ) {
hide_used_files = this->s2b.at( val );
@ -632,7 +632,7 @@ void MainWindow::readConfigs()
this->craplog.setBlacklistUsed( WS_IIS, 20, this->s2b.at( val ) );
} else if ( var == "CrapviewDialogsLevel" ) {
this->crapview.setDialogsLevel( std::stoi( val ) );
this->crapview.setDialogsLevel( fromInt( std::stoi( val ) ) );
}/* else {
// not valid
@ -679,7 +679,7 @@ void MainWindow::writeConfigs()
if ( err.value() ) {
proceed &= false;
QString file;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
file = QString::fromStdString( this->configs_path );
err_msg = QString::fromStdString( err.message() );
}
@ -694,7 +694,7 @@ void MainWindow::writeConfigs()
proceed = IOutils::renameAsCopy( this->configs_path, err );
if ( ! proceed ) {
QString path;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
path = QString::fromStdString( this->configs_path );
if ( err.value() ) {
err_msg = QString::fromStdString( err.message() );
@ -719,7 +719,7 @@ void MainWindow::writeConfigs()
if ( err.value() ) {
proceed &= false;
QString file;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
file = QString::fromStdString( base_path );
err_msg = QString::fromStdString( err.message() );
}
@ -734,7 +734,7 @@ void MainWindow::writeConfigs()
proceed = IOutils::renameAsCopy( base_path, err );
if ( ! proceed ) {
QString path;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
path = QString::fromStdString( base_path );
err_msg = QString::fromStdString( err.message() );
}
@ -745,7 +745,7 @@ void MainWindow::writeConfigs()
proceed = IOutils::makeDir( base_path, err );
if ( ! proceed ) {
msg = DialogSec::tr("Failed to create the configuration file's directory");
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( base_path );
err_msg = QString::fromStdString( err.message() );
}
@ -758,7 +758,7 @@ void MainWindow::writeConfigs()
proceed = IOutils::makeDir( base_path, err );
if ( ! proceed ) {
msg = DialogSec::tr("Failed to create the configuration file's directory");
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( base_path );
err_msg = QString::fromStdString( err.message() );
}
@ -779,7 +779,7 @@ void MainWindow::writeConfigs()
configs += "\nWindowTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::window_theme) );
configs += "\nIconsTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::icons_theme) );
configs += "\nChartsTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::charts_theme) );
configs += "\nMainDialogsLevel=" + std::to_string( this->dialogs_level );
configs += "\nMainDialogsLevel=" + toString( this->dialogs_level );
configs += "\nDefaultWebServer=" + toString( this->default_web_server );
configs += "\nDatabaseDataPath=" + this->db_data_path;
configs += "\nDatabaseHashesPath=" + this->db_hashes_path;
@ -792,7 +792,7 @@ void MainWindow::writeConfigs()
configs += "\nColorScheme=" + std::to_string( this->TB.getColorSchemeID() );
//// CRAPLOG ////
configs += "\n\n[Craplog]";
configs += "\nCraplogDialogsLevel=" + std::to_string( this->craplog.getDialogsLevel() );
configs += "\nCraplogDialogsLevel=" + toString( this->craplog.getDialogsLevel() );
configs += "\nHideUsedFiles=" + this->b2s.at( this->hide_used_files );
configs += "\nWarningSize=" + std::to_string( this->craplog.getWarningSize() );
//// APACHE2 ////
@ -846,7 +846,7 @@ void MainWindow::writeConfigs()
configs += "\nIisBlacklistClientUsed=" + this->b2s.at( this->craplog.isBlacklistUsed( WS_IIS, 20 ) );
//// CRAPVIEW ////
configs += "\n\n[Crapview]";
configs += "\nCrapviewDialogsLevel=" + std::to_string( this->crapview.getDialogsLevel() );
configs += "\nCrapviewDialogsLevel=" + toString( this->crapview.getDialogsLevel() );
// write on file
try {
@ -879,7 +879,7 @@ void MainWindow::backupDatabase() const
proceed = IOutils::renameAsCopy( path, err );
if ( ! proceed ) {
QString p;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
p = QString::fromStdString( path );
if ( err.value() ) {
err_msg = QString::fromStdString( err.message() );
@ -891,7 +891,7 @@ void MainWindow::backupDatabase() const
proceed = IOutils::makeDir( path, err );
if ( ! proceed ) {
QString msg = DialogSec::tr("Failed to create the database backups' directory");
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( path );
if ( err.value() ) {
err_msg = QString::fromStdString( err.message() );
@ -907,7 +907,7 @@ void MainWindow::backupDatabase() const
proceed = IOutils::makeDir( path, err );
if ( ! proceed ) {
QString msg = DialogSec::tr("Failed to create the database backups' directory");
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( path );
if ( err.value() ) {
err_msg = QString::fromStdString( err.message() );
@ -1739,7 +1739,7 @@ void MainWindow::makeInitialChecks()
ok = IOutils::renameAsCopy( path, err );
if ( ! ok ) {
QString p;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
p = QString::fromStdString( path );
if ( err.value() ) {
err_msg = QString::fromStdString( err.message() );
@ -1750,7 +1750,7 @@ void MainWindow::makeInitialChecks()
ok = IOutils::makeDir( path, err );
if ( ! ok ) {
QString msg = DialogSec::tr("Failed to create the directory");
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( path );
if ( err.value() ) {
err_msg = QString::fromStdString( err.message() );
@ -1766,7 +1766,7 @@ void MainWindow::makeInitialChecks()
ok = IOutils::makeDir( path, err );
if ( ! ok ) {
QString msg = DialogSec::tr("Failed to create the directory");
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( path );
if ( err.value() ) {
err_msg = QString::fromStdString( err.message() );
@ -2575,11 +2575,11 @@ void MainWindow::on_button_LogFiles_ViewFile_clicked()
if ( item.size() > warn_size ) {
// exceeds the warning size
QString msg{ item.name() };
if ( this->dialogs_level >= 1 ) {
if ( this->dialogs_level >= DL_NORMAL ) {
msg += QString("\n\n%1:\n%2").arg(
DialogSec::tr("Size of the file"),
PrintSec::printableSize( item.size() ) );
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += QString("\n\n%1:\n%2").arg(
DialogSec::tr("Warning size parameter"),
PrintSec::printableSize( warn_size ) );
@ -4257,15 +4257,15 @@ void MainWindow::on_box_ConfWindow_Icons_currentIndexChanged(int index)
//// DIALOGS ////
void MainWindow::on_slider_ConfDialogs_General_sliderReleased()
{
this->dialogs_level = this->ui->slider_ConfDialogs_General->value();
this->dialogs_level = fromInt( this->ui->slider_ConfDialogs_General->value() );
}
void MainWindow::on_slider_ConfDialogs_Logs_sliderReleased()
{
this->craplog.setDialogsLevel( this->ui->slider_ConfDialogs_Logs->value() );
this->craplog.setDialogsLevel( fromInt( this->ui->slider_ConfDialogs_Logs->value() ) );
}
void MainWindow::on_slider_ConfDialogs_Stats_sliderReleased()
{
this->crapview.setDialogsLevel( this->ui->slider_ConfDialogs_Stats->value() );
this->crapview.setDialogsLevel( fromInt( this->ui->slider_ConfDialogs_Stats->value() ) );
}

View File

@ -633,7 +633,7 @@ private:
//// GENERAL ////
// quantoty of informational dialogs to display
int dialogs_level{ 2 }; // 0: essential, 1: usefull, 2: explanatory
DialogsLevel dialogs_level{ DL_NORMAL };
// default web server
WebServer default_web_server{ WS_APACHE };

View File

@ -86,11 +86,11 @@ Craplog::Craplog()
//////////////////
//// SETTINGS ////
int Craplog::getDialogsLevel() const noexcept
DialogsLevel Craplog::getDialogsLevel() const noexcept
{
return this->dialogs_level;
}
void Craplog::setDialogsLevel( const int new_level ) noexcept
void Craplog::setDialogsLevel( const DialogsLevel new_level ) noexcept
{
this->dialogs_level = new_level;
this->hashOps.setDialogLevel( new_level );
@ -657,7 +657,7 @@ bool Craplog::checkStuff()
if ( file.hasBeenUsed() ) {
// already used
QString msg{ file.name() };
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += "\n" + QString::fromStdString( file.hash() );
}
const int choice = DialogSec::choiceFileAlreadyUsed( msg );
@ -680,7 +680,7 @@ bool Craplog::checkStuff()
if ( VecOps::contains( this->used_files_hashes, file.hash() ) ) {
// appears twice in the list
QString msg{ file.name() };
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += "\n" + QString::fromStdString( file.hash() );
}
const int choice = DialogSec::choiceDuplicateFile( msg );
@ -706,11 +706,11 @@ bool Craplog::checkStuff()
if ( file.size() > this->warning_size ) {
// exceeds the warning size
QString msg{ file.name() };
if ( this->dialogs_level >= 1 ) {
if ( this->dialogs_level >= DL_NORMAL ) {
msg += QString("\n\n%1:\n%2").arg(
DialogSec::tr("Size of the file"),
PrintSec::printableSize( file.size() ) );
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += QString("\n\n%1:\n%2").arg(
DialogSec::tr("Warning size parameter"),
PrintSec::printableSize( this->warning_size ) );
@ -764,11 +764,11 @@ bool Craplog::checkStuff()
if ( this->proceed && logs_size >= MemOps::availableMemory() ) {
// no files left, abort
QString msg;
if ( this->dialogs_level >= 1 ) {
if ( this->dialogs_level >= DL_NORMAL ) {
msg += QString("\n\n%1: %2").arg(
DialogSec::tr("Available memory"),
PrintSec::printableSize( MemOps::availableMemory() ) );
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += QString("\n%1: %2").arg(
DialogSec::tr("Size of the logs"),
PrintSec::printableSize( logs_size ) );

View File

@ -4,7 +4,7 @@
#include <QtCharts>
#include "defines/web_servers.h"
#include "main_lib.h"
#include "modules/craplog/modules/lib.h"
#include "modules/craplog/modules/hash.h"
@ -29,10 +29,10 @@ public:
//// DIALOGS ////
//! Returns the Dialogs level
int getDialogsLevel() const noexcept;
DialogsLevel getDialogsLevel() const noexcept;
//! Sets the new Dialogs level
void setDialogsLevel( const int new_level ) noexcept;
void setDialogsLevel( const DialogsLevel new_level ) noexcept;
///////////////////
//// DATABASES ////
@ -464,7 +464,7 @@ private:
//// DIALOGS ////
// quantity of information to display throught dialogs
int dialogs_level{ 2 }; // 0: essential, 1: usefull, 2: explanatory
DialogsLevel dialogs_level{ DL_NORMAL };
///////////////////

View File

@ -19,9 +19,9 @@
#include <QSqlError>
void HashOps::setDialogLevel( const int new_level ) noexcept
void HashOps::setDialogLevel( const DialogsLevel new_level ) noexcept
{
this->dialog_level = new_level;
this->dialogs_level = new_level;
}
@ -46,7 +46,7 @@ bool HashOps::loadUsedHashesLists( const std::string& db_path ) noexcept
// error opening database
successful &= false;
QString err_msg;
if ( this->dialog_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text();
}
DialogSec::errDatabaseFailedOpening( db_name, err_msg );
@ -160,9 +160,9 @@ bool HashOps::insertUsedHash( QSqlQuery& query, const QString& db_name, const st
// error opening database
successful &= false;
QString query_msg, err_msg;
if ( this->dialog_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
query_msg = "query.exec()";
if ( this->dialog_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = query.lastError().text();
}
}
@ -195,7 +195,7 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
// error opening database
successful &= false;
QString err_msg;
if ( this->dialog_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text();
}
DialogSec::errDatabaseFailedOpening( db_name, err_msg );
@ -206,9 +206,9 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
// error opening database
successful &= false;
QString stmt_msg, err_msg;
if ( this->dialog_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.transaction()";
if ( this->dialog_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text();
}
}
@ -231,9 +231,9 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
// error opening database
successful &= false;
QString stmt_msg, err_msg;
if ( this->dialog_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.commit()";
if ( this->dialog_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg= db.lastError().text();
}
}
@ -253,9 +253,9 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
if ( ! db.rollback() ) {
// error rolling back commits
QString stmt_msg, err_msg;
if ( this->dialog_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.rollback()";
if ( this->dialog_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text();
}
}

View File

@ -2,7 +2,7 @@
#define LOGDOCTOR__CRAPLOG__HASH_H
#include "defines/web_servers.h"
#include "main_lib.h"
#include <vector>
#include <unordered_map>
@ -24,7 +24,7 @@ class HashOps final
public:
//! Sets the new Dialogs level
void setDialogLevel( const int new_level ) noexcept;
void setDialogLevel( const DialogsLevel new_level ) noexcept;
//! Retrieves the lists of hashes from the database file
/*!
@ -62,7 +62,7 @@ public:
private:
// Quantity of information to display throught dialogs
int dialog_level{ 2 };
DialogsLevel dialogs_level{ DL_NORMAL };
// List of Web Servers names for database tables
const std::unordered_map<WebServer, QString> ws_names{

View File

@ -13,7 +13,7 @@
#include "modules/craplog/modules/workers/lib.h"
CraplogLister::CraplogLister( const WebServer web_server, const unsigned dialogs_level, const std::string& logs_path, const LogsFormat& logs_format, const HashOps& hashOps, const std::function<bool(const std::string&)> check_filename, QObject* parent )
CraplogLister::CraplogLister( const WebServer web_server, const DialogsLevel dialogs_level, const std::string& logs_path, const LogsFormat& logs_format, const HashOps& hashOps, const std::function<bool(const std::string&)> check_filename, QObject* parent )
: QObject { parent }
, web_server { web_server }
, dialogs_level { dialogs_level }
@ -61,7 +61,7 @@ void CraplogLister::work()
// it's a file, check the readability
if ( ! IOutils::checkFile( path, true ) ) {
// not readable, skip
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
emit this->showDialog( WorkerDialog::warnFileNotReadable,
{name} );
}
@ -86,7 +86,7 @@ void CraplogLister::work()
}
if ( content.empty() ) {
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
emit this->showDialog( WorkerDialog::warnEmptyFile,
{name} );
}

View File

@ -2,13 +2,14 @@
#define LOGDOCTOR__CRAPLOG__WORKERS__LISTER_H
#include "main_lib.h"
#include <QObject>
struct LogsFormat;
struct LogFile;
class HashOps;
enum class WebServer;
enum class WorkerDialog;
@ -20,7 +21,7 @@ public:
explicit CraplogLister(
const WebServer web_server,
const unsigned dialogs_level,
const DialogsLevel dialogs_level,
const std::string& logs_path,
const LogsFormat& logs_format,
const HashOps& hashOps,
@ -48,7 +49,7 @@ private:
const WebServer web_server;
const unsigned dialogs_level;
const DialogsLevel dialogs_level;
const std::string& logs_path;

View File

@ -1,8 +1,6 @@
#include "parser.h"
#include "defines/web_servers.h"
#include "utilities/checks.h"
#include "utilities/gzip.h"
#include "utilities/io.h"
@ -19,7 +17,7 @@
#include <QSqlError>
CraplogParser::CraplogParser( const WebServer web_server, 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 )
CraplogParser::CraplogParser( const WebServer web_server, const DialogsLevel 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 }
, web_server { web_server }
, dialogs_level { dialogs_level }
@ -254,7 +252,7 @@ void CraplogParser::storeLogLines()
// error opening database
this->proceed &= false;
QString err_msg;
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text();
}
emit this->showDialog( WorkerDialog::errDatabaseFailedOpening,
@ -268,9 +266,9 @@ void CraplogParser::storeLogLines()
// error opening database
this->proceed &= false;
QString stmt_msg, err_msg;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.transaction()";
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text();
}
}
@ -288,9 +286,9 @@ void CraplogParser::storeLogLines()
// error opening database
this->proceed &= false;
QString stmt_msg, err_msg;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.commit()";
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg= db.lastError().text();
}
}
@ -311,9 +309,9 @@ void CraplogParser::storeLogLines()
if ( ! db.rollback() ) {
// error rolling back commits
QString stmt_msg, err_msg;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.rollback()";
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text();
}
}
@ -511,9 +509,9 @@ bool CraplogParser::storeData( QSqlDatabase& db )
if ( ! query.prepare( query_stmt ) ) {
// error opening database
QString query_msg, err_msg;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
query_msg = "query.prepare()";
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = query.lastError().text();
}
}
@ -526,9 +524,9 @@ bool CraplogParser::storeData( QSqlDatabase& db )
if ( ! query.exec() ) {
// error finalizing step
QString query_msg, err_msg;
if ( this->dialogs_level > 0 ) {
if ( this->dialogs_level > DL_ESSENTIAL ) {
query_msg = "query.exec()";
if ( this->dialogs_level == 2 ) {
if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = query.lastError().text();
}
}

View File

@ -2,6 +2,8 @@
#define LOGDOCTOR__CRAPLOG__WORKERS__PARSER_H
#include "main_lib.h"
#include "modules/craplog/modules/lib.h"
#include <QObject>
@ -12,7 +14,6 @@
struct BWlist;
struct LogLineData;
enum class WebServer;
enum class WorkerDialog;
class QSqlDatabase;
@ -30,7 +31,7 @@ public:
explicit CraplogParser(
const WebServer web_server,
const unsigned dialogs_level,
const DialogsLevel dialogs_level,
const std::string& db_data_path,
const std::string& db_hashes_path,
const LogsFormat& logs_format,
@ -76,7 +77,7 @@ private:
const WebServer web_server;
const unsigned dialogs_level;
const DialogsLevel dialogs_level;
bool proceed{ true };

View File

@ -8,11 +8,11 @@
#include <QTableWidget>
int Crapview::getDialogsLevel() const noexcept
DialogsLevel Crapview::getDialogsLevel() const noexcept
{
return this->dialogs_level;
}
void Crapview::setDialogsLevel( const int new_level ) noexcept
void Crapview::setDialogsLevel( const DialogsLevel new_level ) noexcept
{
this->dialogs_level = new_level;
}

View File

@ -2,13 +2,16 @@
#define LOGDOCTOR__CRAPVIEW_H
#include <QHash>
#include <QtCharts>
#include "main_lib.h"
#include "modules/crapview/modules/query.h"
#include <QHash>
#include <QtCharts>
#include <string>
class QTableWidget;
@ -24,10 +27,10 @@ class Crapview final : public QObject
public:
//! Returns the Dialogs level
int getDialogsLevel() const noexcept;
DialogsLevel getDialogsLevel() const noexcept;
//! Sets the new Dialogs level
void setDialogsLevel( const int new_level ) noexcept;
void setDialogsLevel( const DialogsLevel new_level ) noexcept;
/*//! Sets the new charts theme to use
@ -262,7 +265,7 @@ private slots:
private:
// quantity of information to display throught dialogs
int dialogs_level{ 2 }; // 0: essential, 1: usefull, 2: explanatory
DialogsLevel dialogs_level{ DL_NORMAL };
// charts theme ID
int charts_theme{ 0 };