diff --git a/common/widgets/wx_html_report_panel.cpp b/common/widgets/wx_html_report_panel.cpp
index 3f6765327a..38363eba08 100644
--- a/common/widgets/wx_html_report_panel.cpp
+++ b/common/widgets/wx_html_report_panel.cpp
@@ -37,22 +37,18 @@
#include
#include
-WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos,
- const wxSize& size, long style ) :
+WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
+ long style ) :
WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ),
m_reporter( this ),
- m_severities( -1 ),
m_lazyUpdate( false )
{
- syncCheckboxes();
m_htmlView->SetFont( KIUI::GetInfoFont( m_htmlView ) );
Flush();
- Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( WX_HTML_REPORT_PANEL::onMenuEvent ),
- nullptr, this );
+ Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( WX_HTML_REPORT_PANEL::onMenuEvent ), nullptr, this );
- m_htmlView->Bind( wxEVT_SYS_COLOUR_CHANGED,
- wxSysColourChangedEventHandler( WX_HTML_REPORT_PANEL::onThemeChanged ),
+ m_htmlView->Bind( wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler( WX_HTML_REPORT_PANEL::onThemeChanged ),
this );
}
@@ -83,8 +79,7 @@ REPORTER& WX_HTML_REPORT_PANEL::Reporter()
}
-void WX_HTML_REPORT_PANEL::Report( const wxString& aText, SEVERITY aSeverity,
- REPORTER::LOCATION aLocation )
+void WX_HTML_REPORT_PANEL::Report( const wxString& aText, SEVERITY aSeverity, REPORTER::LOCATION aLocation )
{
REPORT_LINE line;
line.message = aText;
@@ -105,12 +100,6 @@ void WX_HTML_REPORT_PANEL::Report( const wxString& aText, SEVERITY aSeverity,
}
-void WX_HTML_REPORT_PANEL::SetLazyUpdate( bool aLazyUpdate )
-{
- m_lazyUpdate = aLazyUpdate;
-}
-
-
void WX_HTML_REPORT_PANEL::Flush( bool aSort )
{
wxString html;
@@ -181,7 +170,7 @@ wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine )
{
wxString retv;
- if( !( m_severities & aLine.severity ) )
+ if( !( GetVisibleSeverities() & aLine.severity ) )
return retv;
if( KIPLATFORM::UI::IsDarkTheme() )
@@ -281,73 +270,16 @@ static int RPT_SEVERITY_ALL = RPT_SEVERITY_WARNING | RPT_SEVERITY_ERROR | RPT_SE
RPT_SEVERITY_ACTION;
-void WX_HTML_REPORT_PANEL::onCheckBoxShowAll( wxCommandEvent& event )
+void WX_HTML_REPORT_PANEL::onCheckBox( wxCommandEvent& event )
{
- if( event.IsChecked() )
- m_severities = RPT_SEVERITY_ALL;
- else
- m_severities = RPT_SEVERITY_ERROR;
+ CallAfter(
+ [&]()
+ {
+ m_checkBoxShowAll->SetValue( GetVisibleSeverities() == RPT_SEVERITY_ALL );
+ } );
- syncCheckboxes();
- Flush( true );
-}
-
-
-void WX_HTML_REPORT_PANEL::syncCheckboxes()
-{
- m_checkBoxShowAll->SetValue( m_severities == RPT_SEVERITY_ALL );
- m_checkBoxShowWarnings->SetValue( m_severities & RPT_SEVERITY_WARNING );
- m_checkBoxShowErrors->SetValue( m_severities & RPT_SEVERITY_ERROR );
- m_checkBoxShowInfos->SetValue( m_severities & RPT_SEVERITY_INFO );
- m_checkBoxShowActions->SetValue( m_severities & RPT_SEVERITY_ACTION );
-}
-
-
-void WX_HTML_REPORT_PANEL::onCheckBoxShowWarnings( wxCommandEvent& event )
-{
- if( event.IsChecked() )
- m_severities |= RPT_SEVERITY_WARNING;
- else
- m_severities &= ~RPT_SEVERITY_WARNING;
-
- syncCheckboxes();
- Flush( true );
-}
-
-
-void WX_HTML_REPORT_PANEL::onCheckBoxShowErrors( wxCommandEvent& event )
-{
- if( event.IsChecked() )
- m_severities |= RPT_SEVERITY_ERROR;
- else
- m_severities &= ~RPT_SEVERITY_ERROR;
-
- syncCheckboxes();
- Flush( true );
-}
-
-
-void WX_HTML_REPORT_PANEL::onCheckBoxShowInfos( wxCommandEvent& event )
-{
- if( event.IsChecked() )
- m_severities |= RPT_SEVERITY_INFO;
- else
- m_severities &= ~RPT_SEVERITY_INFO;
-
- syncCheckboxes();
- Flush( true );
-}
-
-
-void WX_HTML_REPORT_PANEL::onCheckBoxShowActions( wxCommandEvent& event )
-{
- if( event.IsChecked() )
- m_severities |= RPT_SEVERITY_ACTION;
- else
- m_severities &= ~RPT_SEVERITY_ACTION;
-
- syncCheckboxes();
Flush( true );
+ event.Skip();
}
@@ -384,12 +316,8 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
if( !f.IsOpened() )
{
- wxString msg;
-
- msg.Printf( _( "Cannot write report to file '%s'." ),
- fn.GetFullPath().GetData() );
- wxMessageBox( msg, _( "File save error" ), wxOK | wxICON_ERROR,
- wxGetTopLevelParent( this ) );
+ wxMessageBox( wxString::Format( _( "Cannot write report to file '%s'." ), fn.GetFullPath().GetData() ),
+ _( "File save error" ), wxOK | wxICON_ERROR, wxGetTopLevelParent( this ) );
return;
}
@@ -423,44 +351,23 @@ void WX_HTML_REPORT_PANEL::SetLabel( const wxString& aLabel )
}
-void WX_HTML_REPORT_PANEL::SetVisibleSeverities( int aSeverities )
-{
- if( aSeverities < 0 )
- m_severities = RPT_SEVERITY_ALL;
- else
- m_severities = aSeverities;
-
- syncCheckboxes();
-}
-
-
int WX_HTML_REPORT_PANEL::GetVisibleSeverities() const
{
- return m_severities;
-}
+ int severities = 0;
+ if( m_checkBoxShowErrors->GetValue() )
+ severities |= RPT_SEVERITY_ERROR;
-void WX_HTML_REPORT_PANEL::SetFileName( const wxString& aReportFileName )
-{
- m_reportFileName = aReportFileName;
-}
+ if( m_checkBoxShowWarnings->GetValue() )
+ severities |= RPT_SEVERITY_WARNING;
+ if( m_checkBoxShowActions->GetValue() )
+ severities |= RPT_SEVERITY_ACTION;
-wxString& WX_HTML_REPORT_PANEL::GetFileName( void )
-{
- return ( m_reportFileName );
-}
+ if( m_checkBoxShowInfos->GetValue() )
+ severities |= RPT_SEVERITY_INFO;
-
-void WX_HTML_REPORT_PANEL::SetShowSeverity( SEVERITY aSeverity, bool aValue )
-{
- switch( aSeverity )
- {
- case RPT_SEVERITY_INFO: m_checkBoxShowInfos->SetValue( aValue ); break;
- case RPT_SEVERITY_ACTION: m_checkBoxShowActions->SetValue( aValue ); break;
- case RPT_SEVERITY_WARNING: m_checkBoxShowWarnings->SetValue( aValue ); break;
- default: m_checkBoxShowErrors->SetValue( aValue ); break;
- }
+ return severities;
}
diff --git a/common/widgets/wx_html_report_panel.h b/common/widgets/wx_html_report_panel.h
index 8884221c48..b3a2032dc8 100644
--- a/common/widgets/wx_html_report_panel.h
+++ b/common/widgets/wx_html_report_panel.h
@@ -19,8 +19,7 @@
* with this program. If not, see .
*/
-#ifndef __WX_HTML_REPORT_PANEL_H__
-#define __WX_HTML_REPORT_PANEL_H__
+#pragma once
#include
#include
@@ -43,12 +42,8 @@ public:
virtual ~WX_HTML_PANEL_REPORTER() {}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
-
- REPORTER& ReportTail( const wxString& aText,
- SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
-
- REPORTER& ReportHead( const wxString& aText,
- SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
+ REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
+ REPORTER& ReportHead( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override;
bool HasMessageOfSeverity( int aSeverityMask ) const override;
@@ -66,9 +61,8 @@ private:
class KICOMMON_API WX_HTML_REPORT_PANEL : public WX_HTML_REPORT_PANEL_BASE
{
public:
- WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL );
+ WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxSize( 500, 300 ), long style = wxTAB_TRAVERSAL );
~WX_HTML_REPORT_PANEL();
@@ -85,8 +79,7 @@ public:
* @param aSeverity string classification level bitfield.
* @param aLocation REPORTER::LOCATION enum for placement of message.
*/
- void Report( const wxString& aText, SEVERITY aSeverity,
- REPORTER::LOCATION aLocation = REPORTER::LOC_BODY );
+ void Report( const wxString& aText, SEVERITY aSeverity, REPORTER::LOCATION aLocation = REPORTER::LOC_BODY );
/// Clears the report panel.
void Clear();
@@ -100,30 +93,21 @@ public:
/// Set the lazy update. If this mode is on, messages are stored but the display
/// is not updated (Updating display can be very time consuming if there are many messages)
/// A call to Flush() will be needed after build the report
- void SetLazyUpdate( bool aLazyUpdate );
+ void SetLazyUpdate( bool aLazyUpdate ) { m_lazyUpdate = aLazyUpdate; }
/// Force updating the HTML page, after the report is built in lazy mode
/// If aSort = true, the body messages will be ordered by severity
void Flush( bool aSort = false );
- /// Set the visible severity filter.
- /// if aSeverities < 0 the m_showAll option is set
- void SetVisibleSeverities( int aSeverities );
-
/// @return the visible severity filter.
/// If the m_showAll option is set, the mask is < 0
int GetVisibleSeverities() const;
- /// @return the visible severity filter.
- /// If the m_showAll option is set, the mask is < 0
- void SetShowSeverity( SEVERITY aSeverity, bool aValue );
-
/// Set the report full file name to the string.
- void SetFileName( const wxString& aReportFileName );
+ void SetFileName( const wxString& aReportFileName ) { m_reportFileName = aReportFileName; }
/// @return reference to the current report fill file name string.
- wxString& GetFileName( void );
-
+ wxString& GetFileName( void ) { return m_reportFileName; }
private:
struct REPORT_LINE
@@ -134,21 +118,15 @@ private:
typedef std::vector REPORT_LINES;
- wxString addHeader( const wxString& aBody );
wxString generateHtml( const REPORT_LINE& aLine );
wxString generatePlainText( const REPORT_LINE& aLine );
void updateBadges();
void scrollToBottom();
- void syncCheckboxes();
void onRightClick( wxMouseEvent& event ) override;
void onMenuEvent( wxMenuEvent& event );
- void onCheckBoxShowAll( wxCommandEvent& event ) override;
- void onCheckBoxShowWarnings( wxCommandEvent& event ) override;
- void onCheckBoxShowErrors( wxCommandEvent& event ) override;
- void onCheckBoxShowInfos( wxCommandEvent& event ) override;
- void onCheckBoxShowActions( wxCommandEvent& event ) override;
+ void onCheckBox( wxCommandEvent& event ) override;
void onBtnSaveToFile( wxCommandEvent& event ) override;
@@ -161,10 +139,7 @@ private:
REPORT_LINES m_reportTail; ///< Lines to print at the end, regardless of sorting
REPORT_LINES m_reportHead; ///< ... and at the beginning, regardless of sorting
- int m_severities; ///< message severities to display (mask)
bool m_lazyUpdate;
wxString m_reportFileName; ///< defaults to the not very useful /bin/report.txt
};
-
-#endif //__WX_HTML_REPORT_PANEL_H__
diff --git a/common/widgets/wx_html_report_panel_base.cpp b/common/widgets/wx_html_report_panel_base.cpp
index 09092c6e78..257843db0f 100644
--- a/common/widgets/wx_html_report_panel_base.cpp
+++ b/common/widgets/wx_html_report_panel_base.cpp
@@ -88,11 +88,11 @@ WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindow
// Connect Events
m_htmlView->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( WX_HTML_REPORT_PANEL_BASE::onRightClick ), NULL, this );
- m_checkBoxShowAll->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowAll ), NULL, this );
- m_checkBoxShowErrors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowErrors ), NULL, this );
- m_checkBoxShowWarnings->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowWarnings ), NULL, this );
- m_checkBoxShowActions->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowActions ), NULL, this );
- m_checkBoxShowInfos->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowInfos ), NULL, this );
+ m_checkBoxShowAll->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
+ m_checkBoxShowErrors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
+ m_checkBoxShowWarnings->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
+ m_checkBoxShowActions->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
+ m_checkBoxShowInfos->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
m_btnSaveReportToFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onBtnSaveToFile ), NULL, this );
}
@@ -100,11 +100,11 @@ WX_HTML_REPORT_PANEL_BASE::~WX_HTML_REPORT_PANEL_BASE()
{
// Disconnect Events
m_htmlView->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( WX_HTML_REPORT_PANEL_BASE::onRightClick ), NULL, this );
- m_checkBoxShowAll->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowAll ), NULL, this );
- m_checkBoxShowErrors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowErrors ), NULL, this );
- m_checkBoxShowWarnings->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowWarnings ), NULL, this );
- m_checkBoxShowActions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowActions ), NULL, this );
- m_checkBoxShowInfos->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBoxShowInfos ), NULL, this );
+ m_checkBoxShowAll->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
+ m_checkBoxShowErrors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
+ m_checkBoxShowWarnings->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
+ m_checkBoxShowActions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
+ m_checkBoxShowInfos->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onCheckBox ), NULL, this );
m_btnSaveReportToFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_HTML_REPORT_PANEL_BASE::onBtnSaveToFile ), NULL, this );
}
diff --git a/common/widgets/wx_html_report_panel_base.fbp b/common/widgets/wx_html_report_panel_base.fbp
index 947d1c8253..34ebe82d1b 100644
--- a/common/widgets/wx_html_report_panel_base.fbp
+++ b/common/widgets/wx_html_report_panel_base.fbp
@@ -273,7 +273,7 @@
- onCheckBoxShowAll
+ onCheckBox