Minor code improvements

This commit is contained in:
Valentino Orlandi 2024-01-21 21:14:38 +01:00
parent fc92115597
commit 8a0bb2046d
Signed by: elB4RTO
GPG key ID: 1719E976DB2D4E71
3 changed files with 19 additions and 21 deletions

View file

@ -23,9 +23,9 @@ void DbQuery::setDialogLevel(const int new_level ) noexcept
this->dialog_level = new_level; this->dialog_level = new_level;
} }
void DbQuery::setDbPath( const std::string& path ) noexcept void DbQuery::setDbPath( std::string&& path ) noexcept
{ {
this->db_path = path; this->db_path = std::move(path);
this->db_name = QString::fromStdString( this->db_path.substr( this->db_path.find_last_of( '/' ) + 1ul ) ); this->db_name = QString::fromStdString( this->db_path.substr( this->db_path.find_last_of( '/' ) + 1ul ) );
} }

View file

@ -24,25 +24,25 @@ public:
// convert log fields IDs to log fields // convert log fields IDs to log fields
const std::unordered_map<int, std::string> FIELDS{ const std::unordered_map<int, std::string> FIELDS{
{0, FIELDS__WARNING}, {0, FIELDS__WARNING},
{10,FIELDS__PROTOCOL}, {11,FIELDS__METHOD}, {10,FIELDS__PROTOCOL}, {11,FIELDS__METHOD},
{12,FIELDS__URI}, {13,FIELDS__QUERY}, {14,FIELDS__RESPONSE_CODE}, {12,FIELDS__URI}, {13,FIELDS__QUERY}, {14,FIELDS__RESPONSE_CODE},
{15,FIELDS__TIME_TAKEN}, {16,FIELDS__BYTES_SENT}, {17,FIELDS__BYTES_RECEIVED}, {15,FIELDS__TIME_TAKEN}, {16,FIELDS__BYTES_SENT}, {17,FIELDS__BYTES_RECEIVED},
{18,FIELDS__REFERRER}, {22,FIELDS__COOKIE}, {18,FIELDS__REFERRER}, {22,FIELDS__COOKIE},
{20,FIELDS__CLIENT}, {21,FIELDS__USER_AGENT} }; {20,FIELDS__CLIENT}, {21,FIELDS__USER_AGENT} };
// convert month numbers to month names // convert month numbers to month names
const std::unordered_map<int, std::string> MONTHS{ const std::unordered_map<int, std::string> MONTHS{
{1, MONTHS__JANUARY}, {2, MONTHS__FEBRUARY}, {3, MONTHS__MARCH}, {1, MONTHS__JANUARY}, {2, MONTHS__FEBRUARY}, {3, MONTHS__MARCH},
{4, MONTHS__APRIL}, {5, MONTHS__MAY}, {6, MONTHS__JUNE}, {4, MONTHS__APRIL}, {5, MONTHS__MAY}, {6, MONTHS__JUNE},
{7, MONTHS__JULY}, {8, MONTHS__AUGUST}, {9, MONTHS__SEPTEMBER}, {7, MONTHS__JULY}, {8, MONTHS__AUGUST}, {9, MONTHS__SEPTEMBER},
{10,MONTHS__OCTOBER}, {11,MONTHS__NOVEMBER}, {12,MONTHS__DECEMBER} }; {10,MONTHS__OCTOBER}, {11,MONTHS__NOVEMBER}, {12,MONTHS__DECEMBER} };
// convert week-day numbers to day names // convert week-day numbers to day names
const std::unordered_map<int, std::string> DAYS{ const std::unordered_map<int, std::string> DAYS{
{1, DAYS__SUNDAY}, {2, DAYS__MONDAY}, {3, DAYS__TUESDAY}, {1, DAYS__SUNDAY}, {2, DAYS__MONDAY}, {3, DAYS__TUESDAY},
{4, DAYS__WEDNESDAY}, {5, DAYS__THURSDAY}, {6, DAYS__FRIDAY}, {4, DAYS__WEDNESDAY}, {5, DAYS__THURSDAY}, {6, DAYS__FRIDAY},
{7, DAYS__SATURDAY} }; {7, DAYS__SATURDAY} };
//! Returns the Dialogs level //! Returns the Dialogs level
@ -53,7 +53,7 @@ public:
/*! /*!
\see Crapview::setDbPath() \see Crapview::setDbPath()
*/ */
void setDbPath( const std::string& path ) noexcept; void setDbPath( std::string&& path ) noexcept;
/*const std::string getDbPath( const int web_server );*/ /*const std::string getDbPath( const int web_server );*/

View file

@ -149,11 +149,9 @@ QString printableDate( const int year, const int month, const int day ) noexcept
QString printableBool( const int value ) noexcept QString printableBool( const int value ) noexcept
{ {
if ( value == 0 ) { return value == 0
return TR::tr( BOOLS__FALSE.c_str() ); ? TR::tr( BOOLS__FALSE.c_str() )
} else { : TR::tr( BOOLS__TRUE.c_str() );
return TR::tr( BOOLS__TRUE.c_str() );
}
} }
} // namespace PrintSec } // namespace PrintSec