Code improvements
This commit is contained in:
parent
4068b8f004
commit
468eff628d
|
@ -179,7 +179,7 @@ void CrissCross::nextTurn()
|
|||
|
||||
const bool CrissCross::checkVictory()
|
||||
{
|
||||
bool victory = false;
|
||||
bool result = false;
|
||||
unsigned int streak;
|
||||
for ( const auto& sequence : this->sequences ) {
|
||||
streak = 0;
|
||||
|
@ -193,13 +193,13 @@ const bool CrissCross::checkVictory()
|
|||
}
|
||||
if ( streak == 3 ) {
|
||||
// victory
|
||||
victory = true;
|
||||
result = true;
|
||||
break;
|
||||
} else {
|
||||
this->victory_sequence.clear();
|
||||
}
|
||||
}
|
||||
return victory;
|
||||
return result;
|
||||
}
|
||||
|
||||
void CrissCross::victory()
|
||||
|
@ -241,7 +241,7 @@ void CrissCross::victory()
|
|||
|
||||
const bool CrissCross::gameDraw()
|
||||
{
|
||||
bool draw = false;
|
||||
bool result = false;
|
||||
unsigned int empty_tiles = 9;
|
||||
for ( const auto& tile : this->board ) {
|
||||
if ( tile > 0 ) {
|
||||
|
@ -250,9 +250,9 @@ const bool CrissCross::gameDraw()
|
|||
}
|
||||
if ( empty_tiles == 0 ) {
|
||||
// no movement left
|
||||
draw = true;
|
||||
result = true;
|
||||
}
|
||||
return draw;
|
||||
return result;
|
||||
}
|
||||
|
||||
void CrissCross::draw()
|
||||
|
@ -345,4 +345,3 @@ const unsigned int CrissCross::AI_makeChoice()
|
|||
}
|
||||
return next_move;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>LogDoctor - CrissCross</string>
|
||||
<string notr="true">LogDoctor - CrissCross</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../resources/resources.qrc">
|
||||
|
|
|
@ -505,7 +505,7 @@ void Snake::updateSnakePosition( const bool& dry )
|
|||
void Snake::increaseSnakeBody( const bool& initial )
|
||||
{
|
||||
// build from the tail
|
||||
BodyPart& tail = this->snake.back();
|
||||
const BodyPart& tail = this->snake.back();
|
||||
unsigned int x = tail.x;
|
||||
unsigned int y = tail.y;
|
||||
const Direction d = tail.direction;
|
||||
|
@ -601,5 +601,3 @@ void Snake::checkCollision()
|
|||
this->spawn_food = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>LogDoctor - Snake</string>
|
||||
<string notr="true">LogDoctor - Snake</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
|
|
@ -244,7 +244,6 @@ MainWindow::~MainWindow()
|
|||
delete this->crapinfo;
|
||||
delete this->crisscross;
|
||||
delete this->snake;
|
||||
//delete this->translator;
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent( QCloseEvent *event )
|
||||
|
@ -604,13 +603,13 @@ void MainWindow::readConfigs()
|
|||
}*/
|
||||
}
|
||||
|
||||
} catch ( const std::ios_base::failure/*& err*/ ) {
|
||||
} catch ( const std::ios_base::failure&/* err*/ ) {
|
||||
// failed reading
|
||||
proceed = false;
|
||||
err_msg = DialogSec::tr("An error occured while reading the configuration file");
|
||||
} catch ( const LogFormatException ) {
|
||||
} catch ( const LogFormatException& ) {
|
||||
proceed = false; // message already shown
|
||||
} catch ( const BWlistException ) {
|
||||
} catch ( const BWlistException& ) {
|
||||
proceed = false;
|
||||
err_msg = QString("%1:\n%2").arg(
|
||||
DialogSec::tr("One of the lists has an invalid item"),
|
||||
|
@ -809,7 +808,7 @@ void MainWindow::writeConfigs()
|
|||
try {
|
||||
IOutils::writeOnFile( this->configs_path, configs );
|
||||
|
||||
} catch (const std::ios_base::failure& err) {
|
||||
} catch ( const std::ios_base::failure&/* err*/ ) {
|
||||
// failed writing
|
||||
DialogSec::errGeneric( DialogSec::tr("An error occured while writing the configuration file") );
|
||||
} catch (...) {
|
||||
|
@ -1375,10 +1374,10 @@ const QString MainWindow::printableTime( const int& secs_ )
|
|||
//////////////
|
||||
//// HELP ////
|
||||
//////////////
|
||||
void MainWindow::showHelp( const std::string& filename )
|
||||
void MainWindow::showHelp( const std::string& file_name )
|
||||
{
|
||||
const std::string link = "https://github.com/elB4RTO/LogDoctor/tree/main/installation_stuff/logdocdata/help/";
|
||||
const std::string path = this->logdoc_path+"/help/"+this->language+"/"+filename+".html";
|
||||
const std::string path = this->logdoc_path+"/help/"+this->language+"/"+file_name+".html";
|
||||
if ( IOutils::exists( path ) ) {
|
||||
if ( IOutils::isFile( path ) ) {
|
||||
if ( IOutils::checkFile( path, true ) ) {
|
||||
|
@ -1474,18 +1473,18 @@ void MainWindow::menu_actionBlockNote_triggered()
|
|||
|
||||
void MainWindow::menu_actionInfos_triggered()
|
||||
{
|
||||
std::string version = std::to_string( this->version );
|
||||
size_t cut = version.find('.');
|
||||
std::string version_ = std::to_string( this->version );
|
||||
size_t cut = version_.find('.');
|
||||
if ( cut == std::string::npos ) {
|
||||
cut = version.find(',');
|
||||
cut = version_.find(',');
|
||||
if ( cut == std::string::npos ) {
|
||||
cut = version.size()-3;
|
||||
cut = version_.size()-3;
|
||||
}
|
||||
}
|
||||
version = version.substr( 0, cut+3 );
|
||||
version_ = version_.substr( 0, cut+3 );
|
||||
delete this->crapinfo;
|
||||
this->crapinfo = new Crapinfo(
|
||||
QString::fromStdString( version ),
|
||||
QString::fromStdString( version_ ),
|
||||
QString::fromStdString( this->resolvePath( "./" ) ),
|
||||
QString::fromStdString( this->logdoc_path ),
|
||||
QString::fromStdString( this->configs_path ) );
|
||||
|
@ -1808,9 +1807,9 @@ void MainWindow::on_button_LogFiles_ViewFile_clicked()
|
|||
// try reading as gzip compressed file
|
||||
GZutils::readFile( item.path, content );
|
||||
|
||||
} catch (const GenericException& e) {
|
||||
} catch (const GenericException) {
|
||||
// failed closing file pointer
|
||||
throw e;
|
||||
throw;
|
||||
|
||||
} catch (...) {
|
||||
// failed as gzip, try as text file
|
||||
|
@ -3531,7 +3530,7 @@ void MainWindow::on_button_ConfApache_Warnlist_Add_clicked()
|
|||
this->crapview.getLogFieldID( this->ui->box_ConfApache_Warnlist_Field->currentText() ),
|
||||
item.toStdString() );
|
||||
this->ui->list_ConfApache_Warnlist_List->addItem( item );
|
||||
} catch ( const BWlistException ) {
|
||||
} catch ( const BWlistException& ) {
|
||||
DialogSec::warnInvalidItemBW();
|
||||
return;
|
||||
}
|
||||
|
@ -3669,7 +3668,7 @@ void MainWindow::on_button_ConfApache_Blacklist_Add_clicked()
|
|||
this->crapview.getLogFieldID( this->ui->box_ConfApache_Blacklist_Field->currentText() ),
|
||||
item.toStdString() );
|
||||
this->ui->list_ConfApache_Blacklist_List->addItem( item );
|
||||
} catch ( const BWlistException ) {
|
||||
} catch ( const BWlistException& ) {
|
||||
DialogSec::warnInvalidItemBW();
|
||||
return;
|
||||
}
|
||||
|
@ -3880,7 +3879,7 @@ void MainWindow::on_button_ConfNginx_Warnlist_Add_clicked()
|
|||
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Warnlist_Field->currentText() ),
|
||||
item.toStdString() );
|
||||
this->ui->list_ConfNginx_Warnlist_List->addItem( item );
|
||||
} catch ( const BWlistException ) {
|
||||
} catch ( const BWlistException& ) {
|
||||
DialogSec::warnInvalidItemBW();
|
||||
return;
|
||||
}
|
||||
|
@ -4018,7 +4017,7 @@ void MainWindow::on_button_ConfNginx_Blacklist_Add_clicked()
|
|||
this->crapview.getLogFieldID( this->ui->box_ConfNginx_Blacklist_Field->currentText() ),
|
||||
item.toStdString() );
|
||||
this->ui->list_ConfNginx_Blacklist_List->addItem( item );
|
||||
} catch ( const BWlistException ) {
|
||||
} catch ( const BWlistException& ) {
|
||||
DialogSec::warnInvalidItemBW();
|
||||
return;
|
||||
}
|
||||
|
@ -4281,7 +4280,7 @@ void MainWindow::on_button_ConfIis_Warnlist_Add_clicked()
|
|||
this->crapview.getLogFieldID( this->ui->box_ConfIis_Warnlist_Field->currentText() ),
|
||||
item.toStdString() );
|
||||
this->ui->list_ConfIis_Warnlist_List->addItem( item );
|
||||
} catch ( const BWlistException ) {
|
||||
} catch ( const BWlistException& ) {
|
||||
DialogSec::warnInvalidItemBW();
|
||||
return;
|
||||
}
|
||||
|
@ -4419,7 +4418,7 @@ void MainWindow::on_button_ConfIis_Blacklist_Add_clicked()
|
|||
this->crapview.getLogFieldID( this->ui->box_ConfIis_Blacklist_Field->currentText() ),
|
||||
item.toStdString() );
|
||||
this->ui->list_ConfIis_Blacklist_List->addItem( item );
|
||||
} catch ( const BWlistException ) {
|
||||
} catch ( const BWlistException& ) {
|
||||
DialogSec::warnInvalidItemBW();
|
||||
return;
|
||||
}
|
||||
|
@ -4495,4 +4494,3 @@ void MainWindow::on_button_ConfIis_Blacklist_Down_clicked()
|
|||
this->ui->list_ConfIis_Blacklist_List->item( i )->setSelected( true );
|
||||
this->ui->list_ConfIis_Blacklist_List->setFocus();
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>858</width>
|
||||
<height>484</height>
|
||||
<height>473</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -229,10 +229,13 @@
|
|||
</property>
|
||||
<property name="html">
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans'; font-size:16pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans';"><br /></p></body></html></string>
|
||||
hr { height: 1px; border-width: 0; }
|
||||
li.unchecked::marker { content: "\2610"; }
|
||||
li.checked::marker { content: "\2612"; }
|
||||
</style></head><body style=" font-family:'Noto Sans'; font-size:16pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
|
@ -433,7 +436,7 @@ p, li { white-space: pre-wrap; }
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>858</width>
|
||||
<height>484</height>
|
||||
<height>473</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -2515,7 +2518,7 @@ Use '!', '=','<' or '>' to declare what to use</string>
|
|||
<widget class="QWidget" name="scrollAreaContent_StatsCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<x>13</x>
|
||||
<y>0</y>
|
||||
<width>263</width>
|
||||
<height>402</height>
|
||||
|
@ -4026,8 +4029,8 @@ With numbers, use '!', '=','<' or '>' to declare what to use</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>184</width>
|
||||
<height>324</height>
|
||||
<width>173</width>
|
||||
<height>348</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_31">
|
||||
|
@ -4382,8 +4385,8 @@ With numbers, use '!', '=','<' or '>' to declare what to use</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>175</width>
|
||||
<height>324</height>
|
||||
<width>157</width>
|
||||
<height>348</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_36">
|
||||
|
@ -4637,8 +4640,8 @@ With numbers, use '!', '=','<' or '>' to declare what to use</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>162</width>
|
||||
<height>255</height>
|
||||
<width>145</width>
|
||||
<height>276</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_46">
|
||||
|
@ -4902,8 +4905,8 @@ With numbers, use '!', '=','<' or '>' to declare what to use</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>193</width>
|
||||
<height>255</height>
|
||||
<width>173</width>
|
||||
<height>276</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_42">
|
||||
|
@ -6135,10 +6138,13 @@ With numbers, use '!', '=','<' or '>' to declare what to use</string>
|
|||
</property>
|
||||
<property name="html">
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans'; font-size:13pt; font-weight:400; font-style:normal;">
|
||||
<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans';"><br /></p></body></html></string>
|
||||
hr { height: 1px; border-width: 0; }
|
||||
li.unchecked::marker { content: "\2610"; }
|
||||
li.checked::marker { content: "\2612"; }
|
||||
</style></head><body style=" font-family:'Noto Sans'; font-size:13pt; font-weight:400; font-style:normal;">
|
||||
<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>true</bool>
|
||||
|
@ -7523,7 +7529,7 @@ Any field not considered by LogDoctor will apear as 'DISCARDED'</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>98</width>
|
||||
<width>62</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -8524,7 +8530,7 @@ Any field not considered by LogDoctor will apear as 'DISCARDED'</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>98</width>
|
||||
<width>62</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -9603,7 +9609,7 @@ Any field not considered by LogDoctor will apear as 'DISCARDED'</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>98</width>
|
||||
<width>62</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -10327,7 +10333,7 @@ Fields marked as 'DISCARDED' got parsed correctly, but are not considered by Log
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>952</width>
|
||||
<height>26</height>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
|
@ -10476,6 +10482,9 @@ Fields marked as 'DISCARDED' got parsed correctly, but are not considered by Log
|
|||
<property name="text">
|
||||
<string>Snake</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Play Snake</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class Craphelp;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class Crapinfo;
|
||||
}
|
||||
|
|
|
@ -446,18 +446,6 @@ const Craplog::LogFile& Craplog::getLogFileItem( const QString& file_name )
|
|||
}
|
||||
|
||||
|
||||
// return the path of the file matching the given name
|
||||
/*const std::string& Craplog::getLogFilePath( const QString& file_name )
|
||||
{
|
||||
for ( const Craplog::LogFile& item : this->logs_list ) {
|
||||
if ( item.name == file_name ) {
|
||||
return item.path;
|
||||
}
|
||||
}
|
||||
// should be unreachable
|
||||
throw GenericException("File item not found");
|
||||
}*/
|
||||
|
||||
// set a file as selected
|
||||
const bool Craplog::setLogFileSelected( const QString& file_name )
|
||||
{
|
||||
|
@ -924,9 +912,9 @@ void Craplog::joinLogLines()
|
|||
// try as gzip compressed archive first
|
||||
GZutils::readFile( file.path, aux );
|
||||
|
||||
} catch ( const GenericException& e ) {
|
||||
} catch ( const GenericException& ) {
|
||||
// failed closing file pointer
|
||||
throw e;
|
||||
throw;
|
||||
|
||||
} catch (...) {
|
||||
// fallback on reading as normal file
|
||||
|
@ -941,7 +929,7 @@ void Craplog::joinLogLines()
|
|||
}
|
||||
|
||||
// re-catched in run()
|
||||
} catch ( const GenericException ) {
|
||||
} catch ( const GenericException& ) {
|
||||
// failed closing gzip file pointer
|
||||
throw GenericException( QString("%1:\n%2").arg(
|
||||
DialogSec::tr("An error accured while reading the gzipped file"),
|
||||
|
@ -1127,23 +1115,6 @@ const QString Craplog::printableSize( const unsigned& bytes )
|
|||
}
|
||||
|
||||
|
||||
/*const std::vector<int> Craplog::calcDayTraffic()
|
||||
{
|
||||
std::vector<int> traffic = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
if ( this->data_collection.size() > 0 ) {
|
||||
for ( const auto& data : this->data_collection ) {
|
||||
if ( data.find( 4 ) != data.end() ) {
|
||||
try {
|
||||
traffic.at( std::stoi(data.at(4)) ) ++;
|
||||
} catch (...) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return traffic;
|
||||
}*/
|
||||
|
||||
void Craplog::makeCharts( const QChart::ChartTheme& theme, const std::unordered_map<std::string, QFont>& fonts, QChartView* size_chart )
|
||||
{
|
||||
const QString
|
||||
|
@ -1151,9 +1122,7 @@ void Craplog::makeCharts( const QChart::ChartTheme& theme, const std::unordered_
|
|||
ignored_slice_name = TR::tr("Ignored"),
|
||||
parsed_slice_name = TR::tr("Parsed"),
|
||||
warning_slice_name = TR::tr("Warnings"),
|
||||
blacklisted_slice_name = TR::tr("Blacklisted");/*,
|
||||
traffic_chart_name = TR::tr("Time of Day Logs Traffic Ensemble"),
|
||||
access_bar_name = TR::tr("Access Logs");*/
|
||||
blacklisted_slice_name = TR::tr("Blacklisted");
|
||||
|
||||
// logs size donut chart
|
||||
QPieSeries *parsedSize_donut = new QPieSeries();
|
||||
|
@ -1186,10 +1155,6 @@ void Craplog::makeCharts( const QChart::ChartTheme& theme, const std::unordered_
|
|||
sizeBreakdown->addBreakdownSeries( parsedSize_donut, Qt::GlobalColor::darkCyan, fonts.at("main_small") );
|
||||
sizeBreakdown->addBreakdownSeries( ignoredSize_donut, Qt::GlobalColor::gray, fonts.at("main_small") );
|
||||
} else {
|
||||
/*sizeBreakdown->addBreakdownSeries( parsedSize_donut, Qt::GlobalColor::white, fonts.at("main_small") );
|
||||
parsedSize_donut->setVisible( false );
|
||||
sizeBreakdown->addBreakdownSeries( ignoredSize_donut, Qt::GlobalColor::white, fonts.at("main_small") );
|
||||
ignoredSize_donut->setVisible( false );*/
|
||||
sizeBreakdown->legend()->setVisible( false );
|
||||
sizeBreakdown->setTitle("");
|
||||
}
|
||||
|
@ -1197,56 +1162,4 @@ void Craplog::makeCharts( const QChart::ChartTheme& theme, const std::unordered_
|
|||
|
||||
size_chart->setChart( sizeBreakdown );
|
||||
size_chart->setRenderHint( QPainter::Antialiasing );
|
||||
|
||||
|
||||
// logs traffic bars chart
|
||||
/*QColor col;
|
||||
QBarSet *access_bars = new QBarSet( access_bar_name );
|
||||
col = Qt::GlobalColor::darkCyan;
|
||||
access_bars->setColor( col.lighter( 130 ) );
|
||||
|
||||
int max_traf = 0;
|
||||
for ( const int& tfc : this->calcDayTraffic() ) {
|
||||
*access_bars << tfc;
|
||||
if ( tfc > max_traf ) {
|
||||
max_traf = tfc;
|
||||
}
|
||||
}
|
||||
|
||||
QBarSeries *bars = new QBarSeries();
|
||||
bars->append( access_bars );
|
||||
|
||||
QChart *t_chart = new QChart();
|
||||
t_chart->setTheme( theme );
|
||||
t_chart->addSeries( bars );
|
||||
t_chart->setTitle( traffic_chart_name );
|
||||
t_chart->setTitleFont( fonts.at("main") );
|
||||
t_chart->legend()->setFont( fonts.at("main_small") );
|
||||
t_chart->setAnimationOptions( QChart::SeriesAnimations );
|
||||
//t_chart->setBackgroundBrush( Qt::darkGray );
|
||||
|
||||
QStringList categories;
|
||||
categories << "00" << "01" << "02" << "03" << "04" << "05" << "06" << "07" << "08" << "09" << "10" << "11"
|
||||
<< "12" << "13" << "14" << "15" << "16" << "17" << "18" << "19" << "20" << "21" << "22" << "23";
|
||||
|
||||
QBarCategoryAxis *axisX = new QBarCategoryAxis();
|
||||
axisX->append( categories );
|
||||
axisX->setLabelsFont( fonts.at( "main_small" ) );
|
||||
t_chart->addAxis( axisX, Qt::AlignBottom );
|
||||
bars->attachAxis( axisX );
|
||||
|
||||
QValueAxis *axisY = new QValueAxis();
|
||||
axisY->setLabelFormat( "%d" );
|
||||
axisY->setRange( 0, max_traf );
|
||||
axisY->setLabelsFont( fonts.at( "main_small" ) );
|
||||
t_chart->addAxis( axisY, Qt::AlignLeft );
|
||||
bars->attachAxis( axisY) ;
|
||||
|
||||
t_chart->legend()->setVisible( true );
|
||||
t_chart->legend()->setAlignment( Qt::AlignBottom );
|
||||
|
||||
traf_chart->setChart( t_chart );
|
||||
traf_chart->setRenderHint( QPainter::Antialiasing );*/
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
setWarnlist( const int& web_server_id, const int& log_field_id, const std::vector<std::string>& new_list );
|
||||
void blacklistAdd( const int& web_server_id, const int& log_field_id, const std::string& new_item ),
|
||||
warnlistAdd( const int& web_server_id, const int& log_field_id, const std::string& new_item ),
|
||||
blacklistRemove( const int& web_server_id, const int& log_field_id, const std::string& new_item ),
|
||||
blacklistRemove( const int& web_server_id, const int& log_field_id, const std::string& item ),
|
||||
warnlistRemove( const int& web_server_id, const int& log_field_id, const std::string& item );
|
||||
const int
|
||||
blacklistMoveUp( const int& web_server_id, const int& log_field_id, const std::string& item ),
|
||||
|
|
|
@ -125,12 +125,6 @@ const std::vector<std::string> DateTimeOps::processDateTime( const std::string&
|
|||
QDateTime e = QDateTime::fromSecsSinceEpoch( std::stoi( datetime ) );
|
||||
datetime = e.toString( "yyyy-MM-dd HH:mm:ss" ).toStdString();
|
||||
|
||||
/*const char* c = datetime.c_str();
|
||||
struct tm t;
|
||||
char d[32];
|
||||
strptime( c, "%s", &t );
|
||||
strftime( d, sizeof(d), "%Y-%m-%d %H:%M:%S", &t);
|
||||
datetime = std::string( d );*/
|
||||
// parse
|
||||
year = datetime.substr( 0, 4 );
|
||||
month = datetime.substr( 5, 2 );
|
||||
|
@ -151,22 +145,22 @@ const std::vector<std::string> DateTimeOps::processDateTime( const std::string&
|
|||
year = "20" + datetime.substr( 6, 2 );
|
||||
|
||||
} else if ( format == "MDYY" ) {
|
||||
int aux;
|
||||
int aux_;
|
||||
if ( datetime.at(2) == '/' ) {
|
||||
month = datetime.substr( 0, 2 );
|
||||
aux = 3;
|
||||
aux_ = 3;
|
||||
} else {
|
||||
month = "0" + datetime.substr( 0, 1 );
|
||||
aux = 2;
|
||||
aux_ = 2;
|
||||
}
|
||||
if ( datetime.at(aux+2) == '/' ) {
|
||||
day = datetime.substr( aux, 2 );
|
||||
aux += 3;
|
||||
if ( datetime.at(aux_+2) == '/' ) {
|
||||
day = datetime.substr( aux_, 2 );
|
||||
aux_ += 3;
|
||||
} else {
|
||||
day = "0" + datetime.substr( aux, 1 );
|
||||
aux = +2;
|
||||
day = "0" + datetime.substr( aux_, 1 );
|
||||
aux_ = +2;
|
||||
}
|
||||
year = "20" + datetime.substr( aux );
|
||||
year = "20" + datetime.substr( aux_ );
|
||||
|
||||
} else if ( StringOps::startsWith( format, "year" ) ) {
|
||||
year = datetime;
|
||||
|
|
|
@ -211,7 +211,7 @@ const FormatOps::LogsFormat FormatOps::processApacheFormatString( const std::str
|
|||
int n_fld=0;
|
||||
size_t start, stop=0, aux, aux_start, aux_stop;
|
||||
const size_t max=f_str.size()-1;
|
||||
std::string aux_fld, aux_fld_v, cur_fld, cur_sep="";
|
||||
std::string aux_fld, aux_fld_v, cur_fld, cur_sep;
|
||||
// find and convert any field
|
||||
while (true) {
|
||||
// start after the last found field
|
||||
|
@ -285,7 +285,6 @@ const FormatOps::LogsFormat FormatOps::processApacheFormatString( const std::str
|
|||
} else {
|
||||
// stop
|
||||
aux = aux_aux;
|
||||
aux_fld = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -385,8 +384,8 @@ const FormatOps::LogsFormat FormatOps::processApacheFormatString( const std::str
|
|||
// check if false positive
|
||||
if ( aux_aux != std::string::npos ) {
|
||||
// same escape rules as before, but single percent-signs are considered valid and treated as text
|
||||
const char c = aux_fld.at( aux_aux+1 );
|
||||
if ( c == '%' || c == 'n' || c == 't' ) {
|
||||
const char c_ = aux_fld.at( aux_aux+1 );
|
||||
if ( c_ == '%' || c_ == 'n' || c_ == 't' ) {
|
||||
// control characters, will be used as separator, skip
|
||||
aux_aux_stop = aux_aux + 2;
|
||||
continue;
|
||||
|
|
|
@ -36,7 +36,7 @@ private:
|
|||
const std::string parseApacheEscapes( const std::string& string, const bool& strftime=false );
|
||||
const std::string parseNginxEscapes( const std::string& string );
|
||||
|
||||
const int countNewLines( const std::string& initial, const std::string& final, const std::vector<std::string>& separatprs );
|
||||
const int countNewLines( const std::string& initial, const std::string& final, const std::vector<std::string>& separators );
|
||||
|
||||
const size_t findNginxFieldEnd( const std::string& string, const int& start );
|
||||
void checkIisString( const std::string& string );
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
#include "hash.h"
|
||||
|
||||
|
||||
#include "utilities/gzip.h"
|
||||
#include "utilities/io.h"
|
||||
#include "utilities/vectors.h"
|
||||
|
@ -11,7 +10,6 @@
|
|||
#include "modules/craplog/modules/sha256.h"
|
||||
|
||||
|
||||
|
||||
HashOps::HashOps()
|
||||
{
|
||||
|
||||
|
@ -82,9 +80,9 @@ std::string HashOps::digestFile( const std::string& file_path )
|
|||
// try reading as gzip compressed file
|
||||
GZutils::readFile( file_path, content );
|
||||
|
||||
} catch ( const GenericException& e ) {
|
||||
} catch ( const GenericException& ) {
|
||||
// failed closing file pointer
|
||||
throw e;
|
||||
throw;
|
||||
|
||||
} catch (...) {
|
||||
// failed as gzip, try as text file
|
||||
|
@ -95,7 +93,7 @@ std::string HashOps::digestFile( const std::string& file_path )
|
|||
}
|
||||
|
||||
// re-catched in craplog
|
||||
} catch ( const GenericException ) {
|
||||
} catch ( const GenericException& ) {
|
||||
// failed closing gzip file pointer
|
||||
throw GenericException( QString("%1:\n%2").arg(
|
||||
DialogSec::tr("An error accured while reading the gzipped file"),
|
||||
|
@ -269,4 +267,3 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
|
|||
db.close();
|
||||
return proceed;
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ const std::unordered_map<int, std::string> LogOps::parseLine( const std::string&
|
|||
{
|
||||
std::unordered_map<int, std::string> data;
|
||||
std::string sep, fld, fld_str;
|
||||
bool missing=false, add_pm=false;
|
||||
bool add_pm=false;
|
||||
size_t start, stop=0, aux_start, aux_stop,
|
||||
line_size = line.size()-1;
|
||||
int i=0, n_sep=format.separators.size()-1;
|
||||
|
@ -389,13 +389,8 @@ const std::unordered_map<int, std::string> LogOps::parseLine( const std::string&
|
|||
|
||||
|
||||
// update the stop for the next start
|
||||
if ( missing ) {
|
||||
missing = false;
|
||||
stop = aux_stop;
|
||||
} else {
|
||||
stop = stop + sep.size();
|
||||
i++;
|
||||
}
|
||||
stop += sep.size();
|
||||
i++;
|
||||
if ( stop > line_size ) {
|
||||
// this was the final separator
|
||||
break;
|
||||
|
@ -466,4 +461,3 @@ const unsigned LogOps::getParsedLines()
|
|||
{
|
||||
return this->parsed_lines;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ bool StoreOps::storeData( QSqlDatabase& db, Craplog& craplog, const std::vector<
|
|||
check_wl_req = craplog.isWarnlistUsed( wsID, 12 );
|
||||
check_wl_cli = craplog.isWarnlistUsed( wsID, 20 );
|
||||
check_wl_ua = craplog.isWarnlistUsed( wsID, 21 );
|
||||
std::vector<std::string> bl_cli_list, bl_err_list, wl_cli_list, wl_ua_list, wl_met_list, wl_req_list, wl_err_list;
|
||||
std::vector<std::string> bl_cli_list, wl_cli_list, wl_ua_list, wl_met_list, wl_req_list;
|
||||
if ( check_bl_cli ) {
|
||||
bl_cli_list = craplog.getBlacklist( wsID, 20 );
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class StoreOps
|
|||
public:
|
||||
StoreOps();
|
||||
|
||||
static bool storeData( QSqlDatabase& db, Craplog& caplog, const std::vector<std::unordered_map<int, std::string>>& data );
|
||||
static bool storeData( QSqlDatabase& db, Craplog& craplog, const std::vector<std::unordered_map<int, std::string>>& data );
|
||||
};
|
||||
|
||||
#endif // STORE_H
|
||||
|
|
|
@ -79,7 +79,7 @@ void Crapup::versionCheck( const float& v, const int& dialog_level )
|
|||
successful = true;
|
||||
break;
|
||||
|
||||
} catch (std::invalid_argument& e) {
|
||||
} catch ( const std::invalid_argument&/*& e*/ ) {
|
||||
// failed to convert string to float
|
||||
err = 11;
|
||||
}
|
||||
|
@ -110,8 +110,10 @@ void Crapup::versionCheck( const float& v, const int& dialog_level )
|
|||
} else {
|
||||
// something went wrong, can't be successful if version is less than 0
|
||||
successful = false;
|
||||
err = 20;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if ( ! successful ) {
|
||||
DialogSec::errVersionCheckFailed( err );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const
|
|||
}
|
||||
for ( int h=0; h<24; h++ ) {
|
||||
for ( int m=0; m<6; m++ ) {
|
||||
auto& data = items.at( h ).at( m );
|
||||
const auto& data = items.at( h ).at( m );
|
||||
norm_count = warn_count = 0;
|
||||
for ( const std::vector<QString>& line : data ) {
|
||||
aux = table->rowCount();
|
||||
|
@ -368,7 +368,7 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const
|
|||
}
|
||||
for ( int g=0; g<6; g++ ) {
|
||||
for ( int m=0; m<10; m++ ) {
|
||||
auto& data = items.at( g ).at( m );
|
||||
const auto& data = items.at( g ).at( m );
|
||||
norm_count = warn_count = 0;
|
||||
for ( const std::vector<QString>& line : data ) {
|
||||
aux = table->rowCount();
|
||||
|
@ -428,8 +428,7 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const
|
|||
foreach ( auto& bars, b_series ) {
|
||||
b_chart->addSeries( bars );
|
||||
}
|
||||
//b_chart->setTitle( QString("%1: %2").arg( this->TITLE_WARN ) );
|
||||
b_chart->setTitle( TR::tr( this->TITLE_WARN.c_str() ) );
|
||||
b_chart->setTitle( TR::tr( "Log Lines Marked as Warning" ) );
|
||||
b_chart->setTitleFont( fonts.at("main") );
|
||||
//b_chart->legend()->setVisible( false );
|
||||
b_chart->legend()->setFont( fonts.at("main_small") );
|
||||
|
@ -587,7 +586,7 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons
|
|||
l_chart->setTheme( theme );
|
||||
l_chart->addSeries( line );
|
||||
l_chart->addSeries( line_ );
|
||||
l_chart->setTitle( TR::tr( this->TITLE_SPEED.c_str() ) );
|
||||
l_chart->setTitle( TR::tr( "Time Taken to Serve Requests" ) );
|
||||
l_chart->setTitleFont( fonts.at("main") );
|
||||
l_chart->legend()->setFont( fonts.at( "main_small" ) );
|
||||
l_chart->legend()->setAlignment( Qt::AlignBottom );
|
||||
|
@ -647,7 +646,6 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons
|
|||
oth_count += count;
|
||||
} else {
|
||||
pie->append( item, count );
|
||||
//items.push_back( aux_items.at( i ) );
|
||||
}
|
||||
aux = table->rowCount();
|
||||
table->insertRow( aux );
|
||||
|
@ -658,7 +656,7 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons
|
|||
aux_items.clear();
|
||||
|
||||
if ( oth_count > 0 ) {
|
||||
pie->append( TR::tr( this->TEXT_COUNT_OTHERS.c_str() ), oth_count );
|
||||
pie->append( TR::tr( "Others" ), oth_count );
|
||||
QPieSlice *slice = pie->slices().at( pie->count()-1 );
|
||||
slice->setBrush( Qt::gray );
|
||||
}
|
||||
|
@ -703,9 +701,9 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t
|
|||
b_30->setLabel( this->printableDate( from_year, this->getMonthNumber(from_month), from_day ) );
|
||||
} else {
|
||||
b_30->setLabel( QString("%1 %2 %3 %4")
|
||||
.arg( TR::tr( this->LEGEND_FROM.c_str() ),
|
||||
.arg( TR::tr( "from" ),
|
||||
this->printableDate( from_year, this->getMonthNumber(from_month), from_day ),
|
||||
TR::tr( this->LEGEND_TO.c_str() ),
|
||||
TR::tr( "to" ),
|
||||
this->printableDate( to_year, this->getMonthNumber(to_month), to_day ) ));
|
||||
}
|
||||
b_30->setColor( col );
|
||||
|
@ -762,7 +760,7 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t
|
|||
QChart *b_chart = new QChart();
|
||||
b_chart->setTheme( theme );
|
||||
b_chart->addSeries( bars );
|
||||
b_chart->setTitle( QString("%1: %2").arg( TR::tr( this->TITLE_DAY.c_str() ), field ) );
|
||||
b_chart->setTitle( QString("%1: %2").arg( TR::tr( "Time of Day Count" ), field ) );
|
||||
b_chart->setTitleFont( fonts.at("main") );
|
||||
b_chart->legend()->setFont( fonts.at("main_small") );
|
||||
//b_chart->legend()->setVisible( true );
|
||||
|
@ -838,7 +836,6 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme&
|
|||
time = std::get<0>(item);
|
||||
count = std::get<1>(item);
|
||||
line->append( time, (double)count );
|
||||
//*line << QPoint( time, (double)count );
|
||||
if ( count > max_count ) {
|
||||
max_count = count;
|
||||
}
|
||||
|
@ -850,9 +847,9 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme&
|
|||
area->setName( this->printableDate( from_year, this->getMonthNumber(from_month), from_day ));
|
||||
} else {
|
||||
area->setName(QString("%1 %2 %3 %4")
|
||||
.arg( TR::tr( this->LEGEND_FROM.c_str() ),
|
||||
.arg( TR::tr( "from" ),
|
||||
this->printableDate( from_year, this->getMonthNumber(from_month), from_day ),
|
||||
TR::tr( this->LEGEND_TO.c_str() ),
|
||||
TR::tr( "to" ),
|
||||
this->printableDate( to_year, this->getMonthNumber(to_month), to_day )) );
|
||||
}
|
||||
|
||||
|
@ -879,7 +876,7 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme&
|
|||
a_chart->setTheme( theme );
|
||||
a_chart->addSeries( area );
|
||||
a_chart->addSeries( area_ );
|
||||
a_chart->setTitle( QString("%1: %2 -> %3").arg( TR::tr( this->TITLE_RELAT.c_str() ), field_1, field_2) );
|
||||
a_chart->setTitle( QString("%1: %2 -> %3").arg( TR::tr( "Time of Day Count" ), field_1, field_2) );
|
||||
a_chart->setTitleFont( fonts.at("main") );
|
||||
a_chart->legend()->setFont( fonts.at( "main_small" ) );
|
||||
a_chart->legend()->setAlignment( Qt::AlignBottom );
|
||||
|
@ -961,7 +958,7 @@ const bool Crapview::calcGlobals( std::vector<std::tuple<QString,QString>>& recu
|
|||
for ( int i=0; i<4; i++ ) {
|
||||
int max=0;
|
||||
QString max_str="";
|
||||
std::unordered_map<QString, int>& aux = recurs.at( i );
|
||||
const auto& aux = recurs.at( i );
|
||||
for ( const auto& [s,c] : aux ) {
|
||||
if ( c > max ) {
|
||||
max = c;
|
||||
|
|
|
@ -102,14 +102,6 @@ private:
|
|||
|
||||
DbQuery dbQuery;
|
||||
|
||||
const std::string TITLE_WARN = TR::tr("Log Lines Marked as Warning").toStdString();
|
||||
const std::string TITLE_SPEED = TR::tr("Time Taken to Serve Requests").toStdString();
|
||||
const std::string TEXT_COUNT_OTHERS = TR::tr("Others").toStdString();
|
||||
const std::string TITLE_DAY = TR::tr("Time of Day Count").toStdString();
|
||||
const std::string TITLE_RELAT = TR::tr("Relational Count").toStdString();
|
||||
const std::string LEGEND_FROM = TR::tr("from").toStdString();
|
||||
const std::string LEGEND_TO = TR::tr("to").toStdString();
|
||||
|
||||
// collection of available dates
|
||||
// { web_server_id : { year : { month_str : [ days ] } } }
|
||||
std::unordered_map<int, std::unordered_map<int, std::unordered_map<int, std::vector<int>>>> dates;
|
||||
|
|
|
@ -2125,7 +2125,7 @@ const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unord
|
|||
|
||||
// process the day of the week
|
||||
for ( int i=1; i<8; i++ ) {
|
||||
int &x = num_day_count.at( i );
|
||||
const int &x = num_day_count.at( i );
|
||||
if ( x > 0 ) {
|
||||
traf_day.at( i ) /= x;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ DialogSec::DialogSec()
|
|||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
//// LANGUAGE ////
|
||||
//////////////////
|
||||
|
@ -136,6 +135,12 @@ void DialogSec::errVersionCheckFailed( const int& err_code, QWidget *parent )
|
|||
case 11:
|
||||
msg = DialogSec::tr("An error occured while parsing:\nmalformed version");
|
||||
break;
|
||||
case 20:
|
||||
msg = DialogSec::tr("An error occured while comparing:\nversion lesser than 0");
|
||||
break;
|
||||
default:
|
||||
throw("Unexpected err_code in VersionCheck dialog: "+std::to_string(err_code));
|
||||
break;
|
||||
}
|
||||
|
||||
DialogMsg dialog = DialogMsg(
|
||||
|
|
|
@ -87,13 +87,8 @@ public:
|
|||
// files
|
||||
static void errFileNotFound( const QString& file, const bool& report=false, QWidget *parent=nullptr );
|
||||
// files permissions
|
||||
/*static void errFileNotExists( QWidget *parent=nullptr );
|
||||
static void errFileNotReadable( QWidget *parent=nullptr );
|
||||
static void errFileNotWritable( QWidget *parent=nullptr );*/
|
||||
static void warnFileNotReadable( const QString& file, QWidget *parent=nullptr );
|
||||
/*static const bool choiceFileNotExists( QWidget *parent=nullptr );
|
||||
static const bool choiceFileNotReadable( QWidget *parent=nullptr );
|
||||
static const bool choiceFileNotWritable( QWidget *parent=nullptr );*/
|
||||
|
||||
// files actions
|
||||
static void warnEmptyFile( const QString& file, QWidget *parent=nullptr );
|
||||
static void errFailedReadFile( const QString& file, const bool& skipping=false, QWidget *parent=nullptr );
|
||||
|
@ -106,16 +101,12 @@ public:
|
|||
static void errDirNotWritable( const QString& dir, QWidget *parent=nullptr );
|
||||
static void warnDirNotReadable( QWidget *parent=nullptr );
|
||||
static void warnDirNotWritable( QWidget *parent=nullptr );
|
||||
/*static void choiceDirNotReadable( QWidget *parent=nullptr );
|
||||
static void choiceDirNotWritable( QWidget *parent=nullptr );*/
|
||||
// folders actions
|
||||
static void errFailedMakeDir( const QString& msg, QWidget *parent=nullptr );
|
||||
|
||||
// generic choices
|
||||
static const bool choiceDirNotDir( const QString& path, QWidget *parent=nullptr );
|
||||
static const bool choiceFileNotFile( const QString& path, QWidget *parent=nullptr );
|
||||
/*static void choiceYesNo( QWidget *parent=nullptr );
|
||||
static const bool choiceIgnoreAbort( QWidget *parent=nullptr );*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
#include "dialogbool.h"
|
||||
#include "ui_dialogbool.h"
|
||||
|
||||
|
||||
DialogBool::DialogBool( const QString& title, const QString& text, QWidget *parent ) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogBool)
|
||||
|
@ -26,9 +28,7 @@ void DialogBool::on_button_NO_clicked()
|
|||
this->done( 0 );
|
||||
}
|
||||
|
||||
|
||||
void DialogBool::on_button_YES_clicked()
|
||||
{
|
||||
this->done( 1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class DialogBool;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
#include "dialogdia.h"
|
||||
#include "ui_dialogdia.h"
|
||||
|
||||
|
||||
DialogDia::DialogDia( const QString& title, const QString& text, const bool& ignore, const bool& discard, const bool& abort, QWidget *parent ) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogDia)
|
||||
|
@ -39,15 +41,12 @@ void DialogDia::on_button_IGNORE_clicked()
|
|||
this->done( 2 );
|
||||
}
|
||||
|
||||
|
||||
void DialogDia::on_button_DISCARD_clicked()
|
||||
{
|
||||
this->done( 1 );
|
||||
}
|
||||
|
||||
|
||||
void DialogDia::on_button_ABORT_clicked()
|
||||
{
|
||||
this->done( 0 );
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class DialogDia;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ DialogMsg::DialogMsg(const QString& title, const QString& text, const QString& a
|
|||
break;
|
||||
default:
|
||||
// shouldn't be here
|
||||
throw GenericException("Unexpected dialog type: "+ type);
|
||||
throw GenericException("Unexpected dialog type: "+ std::to_string(type));
|
||||
}
|
||||
|
||||
// insert the given text
|
||||
|
@ -86,4 +86,3 @@ void DialogMsg::on_button_Ok_clicked()
|
|||
{
|
||||
this->done( 1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class DialogMsg;
|
||||
}
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class TR : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TR(QObject *parent = nullptr);
|
||||
explicit TR(QObject *parent=nullptr);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@ void Crapnote::setTextFont( const QFont& font )
|
|||
this->ui->textEdit->setFont( f );
|
||||
}
|
||||
|
||||
void Crapnote::setColorScheme( const int& scheme_id )
|
||||
void Crapnote::setColorScheme( const int& color_scheme_id )
|
||||
{
|
||||
QColor b, t;
|
||||
// update the colors palette
|
||||
switch ( scheme_id ) {
|
||||
switch ( color_scheme_id ) {
|
||||
case 0:
|
||||
this->ui->textEdit->setPalette( QPalette() );
|
||||
break;
|
||||
|
@ -75,4 +75,3 @@ void Crapnote::on_button_FontSize_Plus_clicked()
|
|||
{
|
||||
this->ui->spinBox_FontSize->setValue( this->font_size+1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class Crapnote;
|
||||
}
|
||||
|
|
|
@ -94,16 +94,13 @@ const QPalette ColorSec::getPalette( const int&theme )
|
|||
case 2:
|
||||
// candy
|
||||
p = QPalette( QBrush(QColor( 45, 0, 30 )), /* window text */
|
||||
//QBrush(QColor( 215, 110, 111 )), /* button */
|
||||
QBrush(QColor( 225, 120, 121 )), /* button */
|
||||
QBrush(QColor( 255, 170, 171 )), /* light */
|
||||
QBrush(QColor( 195, 80, 81 )), /* dark */
|
||||
QBrush(QColor( 235, 120, 121 )), /* mid */
|
||||
QBrush(QColor( 45, 0, 30 )), /* text */
|
||||
QBrush(QColor( 145, 100, 130 )), /* bright text */
|
||||
//QBrush(QColor( 255, 180, 181 )), /* base */
|
||||
QBrush(QColor( 194, 255, 195 )), /* base */
|
||||
//QBrush(QColor( 195, 80, 81 )) /* window */
|
||||
QBrush(QColor( 255, 204, 143 )) /* window */ );
|
||||
p.setBrush( QPalette::ColorRole::Highlight, QBrush(QColor(195,80,81)) );
|
||||
break;
|
||||
|
|
|
@ -66,7 +66,7 @@ void GZutils::readFile( const std::string& path, std::string& content )
|
|||
if ( ferror( file ) ) {
|
||||
// error reading
|
||||
(void)inflateEnd( &strm );
|
||||
successful = false;
|
||||
/*successful = false;*/
|
||||
break;
|
||||
}
|
||||
if ( strm.avail_in == 0 ) {
|
||||
|
|
|
@ -138,9 +138,9 @@ void IOutils::randomLines(const std::string& path, std::vector<std::string>& lin
|
|||
// try reading a gzipped file
|
||||
GZutils::readFile( path, aux );
|
||||
|
||||
} catch ( const GenericException& e ) {
|
||||
} catch ( const GenericException& ) {
|
||||
// failed closing file pointer
|
||||
throw e;
|
||||
throw;
|
||||
|
||||
} catch (...) {
|
||||
// fallback in reading as text file
|
||||
|
@ -179,7 +179,7 @@ void IOutils::randomLines(const std::string& path, std::vector<std::string>& lin
|
|||
lines.push_back( line );
|
||||
}
|
||||
// add the first and last lines, to double check for file integrity
|
||||
for ( int& index : std::vector<int>({0,max-1}) ) {
|
||||
for ( const int& index : std::vector<int>({0,max-1}) ) {
|
||||
if ( ! VecOps::contains( picked_indexes, index ) ) {
|
||||
line = aux_lines.at( index );
|
||||
if ( strip_lines ) {
|
||||
|
@ -196,7 +196,7 @@ void IOutils::randomLines(const std::string& path, std::vector<std::string>& lin
|
|||
aux_lines.clear();
|
||||
|
||||
// re-catched in craplog
|
||||
} catch ( const GenericException ) {
|
||||
} catch ( const GenericException& ) {
|
||||
// failed closing gzip file pointer
|
||||
lines.clear(); aux_lines.clear();
|
||||
if ( file.is_open() ) {
|
||||
|
@ -204,7 +204,7 @@ void IOutils::randomLines(const std::string& path, std::vector<std::string>& lin
|
|||
}
|
||||
throw GenericException( "An error accured while reading the gzipped file" );
|
||||
|
||||
} catch (const std::ios_base::failure) {
|
||||
} catch ( const std::ios_base::failure& ) {
|
||||
// failed reading
|
||||
lines.clear(); aux_lines.clear();
|
||||
if ( file.is_open() ) {
|
||||
|
@ -247,12 +247,12 @@ void IOutils::readFile( const std::string& path , std::string& content )
|
|||
(std::istreambuf_iterator<char>( file )),
|
||||
std::istreambuf_iterator<char>() );
|
||||
|
||||
} catch (const std::ios_base::failure& err) {
|
||||
} catch ( const std::ios_base::failure& ) {
|
||||
// failed reading
|
||||
if ( file.is_open() ) {
|
||||
file.close();
|
||||
}
|
||||
throw err;
|
||||
throw;
|
||||
} catch (...) {
|
||||
if ( file.is_open() ) {
|
||||
file.close();
|
||||
|
@ -283,12 +283,12 @@ void IOutils::writeOnFile( const std::string& path, const std::string& content )
|
|||
// write the content
|
||||
file << content << std::endl;
|
||||
|
||||
} catch (const std::ios_base::failure& err) {
|
||||
} catch ( const std::ios_base::failure& ) {
|
||||
// failed writing
|
||||
if ( file.is_open() ) {
|
||||
file.close();
|
||||
}
|
||||
throw err;
|
||||
throw;
|
||||
} catch (...) {
|
||||
if ( file.is_open() ) {
|
||||
file.close();
|
||||
|
|
|
@ -25,7 +25,7 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co
|
|||
rich_content += "<br/>";
|
||||
}
|
||||
QString rich_line="", class_name="";
|
||||
std::string sep, fld, fld_str, aux_sep1, aux_sep2, aux_fld_str;
|
||||
std::string sep, fld, fld_str, aux_sep2;
|
||||
bool missing=false;
|
||||
size_t start, stop, i, aux_start, aux_stop,
|
||||
line_size, sep_size;
|
||||
|
@ -209,7 +209,6 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co
|
|||
|
||||
|
||||
|
||||
|
||||
void RichText::richLogsDefault( QString& rich_str )
|
||||
{
|
||||
rich_str.clear();
|
||||
|
|
|
@ -264,9 +264,9 @@ std::string StringOps::rstrip( const std::string& str, const std::string& chars
|
|||
std::string StringOps::lstripUntil( const std::string& str, const std::string& chr, const bool& inclusive, const bool& consecutives )
|
||||
{
|
||||
size_t start, aux_start, aux;
|
||||
const size_t max_size = str.size()-1;
|
||||
const size_t max_size = str.size();
|
||||
std::string stripped = "";
|
||||
if ( max_size >= 0 ) {
|
||||
if ( max_size > 0 ) {
|
||||
start = str.find( chr );
|
||||
if ( inclusive == true ) {
|
||||
start += chr.size();
|
||||
|
@ -286,17 +286,13 @@ std::string StringOps::lstripUntil( const std::string& str, const std::string& c
|
|||
}
|
||||
aux_start = aux;
|
||||
}
|
||||
if ( aux_start == max_size+1 ) {
|
||||
stripped = "";
|
||||
} else {
|
||||
if ( aux_start < max_size ) {
|
||||
stripped = str.substr( aux_start );
|
||||
}
|
||||
} else {
|
||||
if ( start == std::string::npos ) {
|
||||
stripped = str;
|
||||
} else if ( start == max_size+1 ) {
|
||||
stripped = "";
|
||||
} else {
|
||||
} else if ( start < max_size ) {
|
||||
stripped = str.substr( start );
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +306,7 @@ void StringOps::split( std::vector<std::string>& list, const std::string& target
|
|||
{
|
||||
std::string slice;
|
||||
size_t start=0, stop;
|
||||
if ( target_str.size()-1 >= 0 ) {
|
||||
if ( target_str.size() > 0 ) {
|
||||
while (true) {
|
||||
stop = target_str.find( separator, start );
|
||||
if ( stop == std::string::npos ) {
|
||||
|
@ -350,18 +346,23 @@ void StringOps::splitrip( std::vector<std::string>& list, const std::string& tar
|
|||
const std::string StringOps::replace( const std::string& str, const std::string& target, const std::string& replace )
|
||||
{
|
||||
size_t start=0, stop;
|
||||
const int size = target.size();
|
||||
const size_t size = target.size();
|
||||
std::string string = "";
|
||||
if ( str.size()-1 >= 0 ) {
|
||||
while ( true ) {
|
||||
stop = str.find( target, start );
|
||||
if ( stop == std::string::npos ) {
|
||||
string += str.substr( start );
|
||||
break;
|
||||
} else {
|
||||
string += str.substr( start, stop-start );
|
||||
string += replace;
|
||||
start = stop+size;
|
||||
if ( str.size() > 0 ) {
|
||||
if ( size == 0 ) {
|
||||
// target is empty, nothing to replace
|
||||
string = str;
|
||||
} else {
|
||||
while ( true ) {
|
||||
stop = str.find( target, start );
|
||||
if ( stop == std::string::npos ) {
|
||||
string += str.substr( start );
|
||||
break;
|
||||
} else {
|
||||
string += str.substr( start, stop-start );
|
||||
string += replace;
|
||||
start = stop+size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ VecOps::VecOps()
|
|||
}
|
||||
|
||||
|
||||
|
||||
const bool VecOps::contains( const std::vector<int>& list, const int& flag )
|
||||
{
|
||||
bool result = false;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class VecOps
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue