Move HasMessageOfSeverity to base class.
KICAD-HPP
This commit is contained in:
+14
-30
@@ -53,15 +53,10 @@ REPORTER& REPORTER::Report( const char* aText, SEVERITY aSeverity )
|
||||
}
|
||||
|
||||
|
||||
bool REPORTER::HasMessageOfSeverity( int aSeverityMask ) const
|
||||
{
|
||||
wxFAIL_MSG( "HasMessageOfSeverity is not implemented in this reporter" );
|
||||
return HasMessage();
|
||||
}
|
||||
|
||||
|
||||
REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
REPORTER::Report( aText, aSeverity );
|
||||
|
||||
wxCHECK_MSG( m_textCtrl != nullptr, *this,
|
||||
wxT( "No wxTextCtrl object defined in WX_TEXT_CTRL_REPORTER." ) );
|
||||
|
||||
@@ -78,7 +73,8 @@ bool WX_TEXT_CTRL_REPORTER::HasMessage() const
|
||||
|
||||
REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
m_severityMask |= aSeverity;
|
||||
REPORTER::Report( aText, aSeverity );
|
||||
|
||||
m_string << aText << wxS( "\n" );
|
||||
return *this;
|
||||
}
|
||||
@@ -92,7 +88,7 @@ const wxString& WX_STRING_REPORTER::GetMessages() const
|
||||
|
||||
void WX_STRING_REPORTER::Clear()
|
||||
{
|
||||
m_severityMask = 0;
|
||||
REPORTER::Clear();
|
||||
m_string.clear();
|
||||
}
|
||||
|
||||
@@ -103,15 +99,9 @@ bool WX_STRING_REPORTER::HasMessage() const
|
||||
}
|
||||
|
||||
|
||||
bool WX_STRING_REPORTER::HasMessageOfSeverity( int aSeverityMask ) const
|
||||
{
|
||||
return ( m_severityMask & aSeverityMask ) != 0;
|
||||
}
|
||||
|
||||
|
||||
REPORTER& NULL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
return *this;
|
||||
return REPORTER::Report( aText, aSeverity );
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +118,8 @@ REPORTER& NULL_REPORTER::GetInstance()
|
||||
|
||||
REPORTER& CLI_REPORTER::Report( const wxString& aMsg, SEVERITY aSeverity )
|
||||
{
|
||||
REPORTER::Report( aMsg, aSeverity );
|
||||
|
||||
FILE* target = stdout;
|
||||
|
||||
if( aSeverity == RPT_SEVERITY_ERROR )
|
||||
@@ -138,24 +130,10 @@ REPORTER& CLI_REPORTER::Report( const wxString& aMsg, SEVERITY aSeverity )
|
||||
else
|
||||
wxFprintf( target, aMsg + wxS( "\n" ) );
|
||||
|
||||
m_hasMessageMap[aSeverity] = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool CLI_REPORTER::HasMessageOfSeverity( int aSeverityMask ) const
|
||||
{
|
||||
for( const auto& [severity, flag] : m_hasMessageMap )
|
||||
{
|
||||
if( ( aSeverityMask & severity ) > 0 && flag )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
REPORTER& CLI_REPORTER::GetInstance()
|
||||
{
|
||||
static CLI_REPORTER s_cliReporter;
|
||||
@@ -166,6 +144,8 @@ REPORTER& CLI_REPORTER::GetInstance()
|
||||
|
||||
REPORTER& STDOUT_REPORTER::Report( const wxString& aMsg, SEVERITY aSeverity )
|
||||
{
|
||||
REPORTER::Report( aMsg, aSeverity );
|
||||
|
||||
switch( aSeverity )
|
||||
{
|
||||
case RPT_SEVERITY_UNDEFINED: std::cout << "SEVERITY_UNDEFINED: "; break;
|
||||
@@ -197,6 +177,8 @@ REPORTER& STDOUT_REPORTER::GetInstance()
|
||||
|
||||
REPORTER& WXLOG_REPORTER::Report( const wxString& aMsg, SEVERITY aSeverity )
|
||||
{
|
||||
REPORTER::Report( aMsg, aSeverity );
|
||||
|
||||
switch( aSeverity )
|
||||
{
|
||||
case RPT_SEVERITY_ERROR: wxLogError( aMsg ); break;
|
||||
@@ -227,6 +209,8 @@ REPORTER& WXLOG_REPORTER::GetInstance()
|
||||
|
||||
REPORTER& STATUSBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
REPORTER::Report( aText, aSeverity );
|
||||
|
||||
if( m_statusBar )
|
||||
m_statusBar->SetStatusText( aText, m_position );
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ wxString WX_HTML_REPORT_BOX::generateHtml( const wxString& aLine )
|
||||
|
||||
void WX_HTML_REPORT_BOX::Clear()
|
||||
{
|
||||
REPORTER::Clear();
|
||||
m_messages.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
/**
|
||||
* Delete the stored messages
|
||||
*/
|
||||
void Clear();
|
||||
void Clear() override;
|
||||
|
||||
private:
|
||||
void onThemeChanged( wxSysColourChangedEvent &aEvent );
|
||||
|
||||
@@ -48,8 +48,8 @@ WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id, con
|
||||
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 ),
|
||||
@@ -190,7 +190,7 @@ wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine )
|
||||
{
|
||||
case RPT_SEVERITY_ERROR:
|
||||
retv = wxS( "<font color=#F04040 size=3>" ) + _( "Error:" ) + wxS( " </font>" )
|
||||
wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
|
||||
+ wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
|
||||
break;
|
||||
case RPT_SEVERITY_WARNING:
|
||||
retv = wxS( "<font size=3>" ) + _( "Warning:" ) + wxS( " " ) + aLine.message
|
||||
@@ -212,7 +212,7 @@ wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine )
|
||||
{
|
||||
case RPT_SEVERITY_ERROR:
|
||||
retv = wxS( "<font color=#D00000 size=3>" ) + _( "Error:" ) + wxS( " </font>" )
|
||||
wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
|
||||
+ wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
|
||||
break;
|
||||
case RPT_SEVERITY_WARNING:
|
||||
retv = wxS( "<font size=3>" ) + _( "Warning:" ) + wxS( " " ) + aLine.message
|
||||
@@ -393,7 +393,7 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
|
||||
return;
|
||||
}
|
||||
|
||||
for( REPORT_LINES section : { m_reportHead, m_report, m_reportTail } )
|
||||
for( const REPORT_LINES& section : { m_reportHead, m_report, m_reportTail } )
|
||||
{
|
||||
for( const REPORT_LINE& l : section )
|
||||
{
|
||||
@@ -466,6 +466,8 @@ void WX_HTML_REPORT_PANEL::SetShowSeverity( SEVERITY aSeverity, bool aValue )
|
||||
|
||||
REPORTER& WX_HTML_PANEL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
REPORTER::Report( aText, aSeverity );
|
||||
|
||||
wxCHECK_MSG( m_panel != nullptr, *this,
|
||||
wxT( "No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
|
||||
|
||||
@@ -476,6 +478,8 @@ REPORTER& WX_HTML_PANEL_REPORTER::Report( const wxString& aText, SEVERITY aSever
|
||||
|
||||
REPORTER& WX_HTML_PANEL_REPORTER::ReportTail( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
REPORTER::ReportTail( aText, aSeverity );
|
||||
|
||||
wxCHECK_MSG( m_panel != nullptr, *this,
|
||||
wxT( "No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
|
||||
|
||||
@@ -486,6 +490,8 @@ REPORTER& WX_HTML_PANEL_REPORTER::ReportTail( const wxString& aText, SEVERITY aS
|
||||
|
||||
REPORTER& WX_HTML_PANEL_REPORTER::ReportHead( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
REPORTER::ReportHead( aText, aSeverity );
|
||||
|
||||
wxCHECK_MSG( m_panel != nullptr, *this,
|
||||
wxT( "No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
|
||||
|
||||
|
||||
@@ -35,7 +35,10 @@ class WX_HTML_REPORT_PANEL;
|
||||
class KICOMMON_API WX_HTML_PANEL_REPORTER : public REPORTER
|
||||
{
|
||||
public:
|
||||
WX_HTML_PANEL_REPORTER( WX_HTML_REPORT_PANEL* aPanel ) : REPORTER(), m_panel( aPanel ) {}
|
||||
WX_HTML_PANEL_REPORTER( WX_HTML_REPORT_PANEL* aPanel ) :
|
||||
REPORTER(),
|
||||
m_panel( aPanel )
|
||||
{}
|
||||
|
||||
virtual ~WX_HTML_PANEL_REPORTER() {}
|
||||
|
||||
@@ -64,8 +67,9 @@ 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 );
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL );
|
||||
|
||||
~WX_HTML_REPORT_PANEL();
|
||||
|
||||
/// Set the min size of the area which displays html messages.
|
||||
|
||||
+34
-34
@@ -72,6 +72,13 @@ class WX_INFOBAR;
|
||||
class KICOMMON_API REPORTER
|
||||
{
|
||||
public:
|
||||
REPORTER() :
|
||||
m_severityMask( 0 )
|
||||
{ }
|
||||
|
||||
virtual ~REPORTER()
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Location where the message is to be reported.
|
||||
* LOC_HEAD messages are printed before all others (typically intro messages)
|
||||
@@ -93,7 +100,11 @@ public:
|
||||
*/
|
||||
|
||||
virtual REPORTER& Report( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) = 0;
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
|
||||
{
|
||||
m_severityMask |= aSeverity;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the report at the end of the list, for objects that support report ordering
|
||||
@@ -126,16 +137,23 @@ public:
|
||||
* Returns true if the reporter has one or more messages matching the specified
|
||||
* severity mask.
|
||||
*/
|
||||
virtual bool HasMessageOfSeverity( int aSeverityMask ) const;
|
||||
virtual bool HasMessageOfSeverity( int aSeverityMask ) const
|
||||
{
|
||||
return ( m_severityMask & aSeverityMask ) != 0;
|
||||
}
|
||||
|
||||
virtual EDA_UNITS GetUnits() const
|
||||
{
|
||||
return EDA_UNITS::MM;
|
||||
}
|
||||
|
||||
virtual ~REPORTER()
|
||||
virtual void Clear()
|
||||
{
|
||||
m_severityMask = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_severityMask;
|
||||
};
|
||||
|
||||
|
||||
@@ -172,26 +190,21 @@ class KICOMMON_API WX_STRING_REPORTER : public REPORTER
|
||||
{
|
||||
public:
|
||||
WX_STRING_REPORTER() :
|
||||
REPORTER(),
|
||||
m_severityMask( 0 )
|
||||
{
|
||||
}
|
||||
REPORTER()
|
||||
{ }
|
||||
|
||||
virtual ~WX_STRING_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override;
|
||||
bool HasMessageOfSeverity( int aSeverityMask ) const override;
|
||||
|
||||
const wxString& GetMessages() const;
|
||||
void Clear();
|
||||
void Clear() override;
|
||||
|
||||
private:
|
||||
wxString m_string;
|
||||
int m_severityMask;
|
||||
};
|
||||
|
||||
|
||||
@@ -204,12 +217,10 @@ class KICOMMON_API NULL_REPORTER : public REPORTER
|
||||
{
|
||||
public:
|
||||
NULL_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
virtual ~NULL_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
static REPORTER& GetInstance();
|
||||
|
||||
@@ -227,22 +238,16 @@ class KICOMMON_API CLI_REPORTER : public REPORTER
|
||||
{
|
||||
public:
|
||||
CLI_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
virtual ~CLI_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
static REPORTER& GetInstance();
|
||||
|
||||
REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override { return false; }
|
||||
bool HasMessageOfSeverity( int aSeverityMask ) const override;
|
||||
|
||||
private:
|
||||
std::map<SEVERITY, bool> m_hasMessageMap;
|
||||
};
|
||||
|
||||
|
||||
@@ -253,12 +258,10 @@ class KICOMMON_API STDOUT_REPORTER : public REPORTER
|
||||
{
|
||||
public:
|
||||
STDOUT_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
virtual ~STDOUT_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
static REPORTER& GetInstance();
|
||||
|
||||
@@ -272,12 +275,10 @@ class KICOMMON_API WXLOG_REPORTER : public REPORTER
|
||||
{
|
||||
public:
|
||||
WXLOG_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
virtual ~WXLOG_REPORTER()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
static REPORTER& GetInstance();
|
||||
|
||||
@@ -297,8 +298,7 @@ public:
|
||||
: REPORTER(),
|
||||
m_statusBar( aStatusBar ),
|
||||
m_position( aPosition )
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user