2015-06-16 12:20:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 CERN
|
2021-07-15 19:26:35 +00:00
|
|
|
* Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-06-16 12:20:42 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-05-21 22:28:26 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2015-06-16 12:20:42 +00:00
|
|
|
#include "wx_html_report_panel.h"
|
|
|
|
|
|
|
|
#include <wildcards_and_files_ext.h>
|
2018-02-20 01:40:14 +00:00
|
|
|
#include <gal/color4d.h>
|
2018-03-19 16:03:36 +00:00
|
|
|
#include <wx/clipbrd.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2020-12-12 18:11:51 +00:00
|
|
|
#include <wx/ffile.h>
|
2021-06-07 07:26:13 +00:00
|
|
|
#include <wx/log.h>
|
|
|
|
#include <wx/filedlg.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/menu.h>
|
2021-09-14 18:26:03 +00:00
|
|
|
#include <wx/textctrl.h>
|
2021-11-19 12:30:17 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2022-01-20 19:50:21 +00:00
|
|
|
#include <kiway_holder.h>
|
|
|
|
#include <project.h>
|
2015-06-16 12:20:42 +00:00
|
|
|
|
2021-09-14 18:26:03 +00:00
|
|
|
WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
|
|
|
const wxSize& size, long style ) :
|
2020-11-16 00:04:55 +00:00
|
|
|
WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ),
|
|
|
|
m_reporter( this ),
|
|
|
|
m_severities( -1 ),
|
2021-02-25 15:05:26 +00:00
|
|
|
m_lazyUpdate( false )
|
2015-06-16 12:20:42 +00:00
|
|
|
{
|
|
|
|
syncCheckboxes();
|
2021-09-12 11:17:22 +00:00
|
|
|
m_htmlView->SetFont( KIUI::GetInfoFont( m_htmlView ) );
|
2021-09-14 18:26:03 +00:00
|
|
|
Flush();
|
2018-03-19 16:03:36 +00:00
|
|
|
|
|
|
|
Connect( wxEVT_COMMAND_MENU_SELECTED,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxMenuEventHandler( WX_HTML_REPORT_PANEL::onMenuEvent ), nullptr, this );
|
2021-09-14 18:26:03 +00:00
|
|
|
|
|
|
|
m_htmlView->Bind( wxEVT_SYS_COLOUR_CHANGED,
|
|
|
|
wxSysColourChangedEventHandler( WX_HTML_REPORT_PANEL::onThemeChanged ),
|
|
|
|
this );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WX_HTML_REPORT_PANEL::~WX_HTML_REPORT_PANEL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-14 18:26:03 +00:00
|
|
|
void WX_HTML_REPORT_PANEL::onThemeChanged( wxSysColourChangedEvent &aEvent )
|
|
|
|
{
|
|
|
|
Flush();
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-04 17:06:54 +00:00
|
|
|
void WX_HTML_REPORT_PANEL::MsgPanelSetMinSize( const wxSize& aMinSize )
|
|
|
|
{
|
2018-02-17 11:43:56 +00:00
|
|
|
m_fgSizer->SetMinSize( aMinSize );
|
2015-12-04 17:06:54 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-16 12:20:42 +00:00
|
|
|
REPORTER& WX_HTML_REPORT_PANEL::Reporter()
|
|
|
|
{
|
|
|
|
return m_reporter;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
void WX_HTML_REPORT_PANEL::Report( const wxString& aText, SEVERITY aSeverity,
|
|
|
|
REPORTER::LOCATION aLocation )
|
2015-06-16 12:20:42 +00:00
|
|
|
{
|
|
|
|
REPORT_LINE line;
|
|
|
|
line.message = aText;
|
|
|
|
line.severity = aSeverity;
|
|
|
|
|
2018-05-21 22:28:26 +00:00
|
|
|
if( aLocation == REPORTER::LOC_HEAD )
|
|
|
|
m_reportHead.push_back( line );
|
|
|
|
else if( aLocation == REPORTER::LOC_TAIL )
|
|
|
|
m_reportTail.push_back( line );
|
|
|
|
else
|
|
|
|
m_report.push_back( line );
|
2015-07-24 15:47:48 +00:00
|
|
|
|
|
|
|
if( !m_lazyUpdate )
|
|
|
|
{
|
|
|
|
m_htmlView->AppendToPage( generateHtml( line ) );
|
|
|
|
scrollToBottom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::SetLazyUpdate( bool aLazyUpdate )
|
|
|
|
{
|
|
|
|
m_lazyUpdate = aLazyUpdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-21 22:28:26 +00:00
|
|
|
void WX_HTML_REPORT_PANEL::Flush( bool aSort )
|
2015-07-24 15:47:48 +00:00
|
|
|
{
|
2018-05-21 22:28:26 +00:00
|
|
|
wxString html;
|
|
|
|
|
|
|
|
if( aSort )
|
|
|
|
{
|
|
|
|
std::sort( m_report.begin(), m_report.end(),
|
2018-05-23 09:31:13 +00:00
|
|
|
[]( const REPORT_LINE& a, const REPORT_LINE& b)
|
2018-05-21 22:28:26 +00:00
|
|
|
{
|
|
|
|
return a.severity < b.severity;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const auto& line : m_reportHead )
|
2018-05-21 22:28:26 +00:00
|
|
|
html += generateHtml( line );
|
|
|
|
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const auto& line : m_report )
|
2018-05-21 22:28:26 +00:00
|
|
|
html += generateHtml( line );
|
|
|
|
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const auto& line : m_reportTail )
|
2018-05-21 22:28:26 +00:00
|
|
|
html += generateHtml( line );
|
|
|
|
|
2021-10-10 12:52:37 +00:00
|
|
|
m_htmlView->SetPage( html );
|
2015-06-16 12:20:42 +00:00
|
|
|
scrollToBottom();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::scrollToBottom()
|
|
|
|
{
|
|
|
|
int x, y, xUnit, yUnit;
|
2015-07-24 15:47:48 +00:00
|
|
|
|
2015-06-16 12:20:42 +00:00
|
|
|
m_htmlView->GetVirtualSize( &x, &y );
|
|
|
|
m_htmlView->GetScrollPixelsPerUnit( &xUnit, &yUnit );
|
|
|
|
m_htmlView->Scroll( 0, y / yUnit );
|
2018-02-20 01:40:14 +00:00
|
|
|
|
|
|
|
updateBadges();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::updateBadges()
|
|
|
|
{
|
2020-03-04 09:48:18 +00:00
|
|
|
int count = Count(RPT_SEVERITY_ERROR );
|
2020-10-20 01:32:49 +00:00
|
|
|
m_errorsBadge->UpdateNumber( count, RPT_SEVERITY_ERROR );
|
2018-02-20 01:40:14 +00:00
|
|
|
|
2020-03-04 09:48:18 +00:00
|
|
|
count = Count(RPT_SEVERITY_WARNING );
|
2020-10-20 01:32:49 +00:00
|
|
|
m_warningsBadge->UpdateNumber( count, RPT_SEVERITY_WARNING );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
int WX_HTML_REPORT_PANEL::Count( int severityMask )
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
for( const auto& reportLineArray : { m_report, m_reportHead, m_reportTail } )
|
|
|
|
{
|
|
|
|
for( const REPORT_LINE& reportLine : reportLineArray )
|
|
|
|
{
|
|
|
|
if( severityMask & reportLine.severity )
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
2018-02-17 11:43:56 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-16 12:20:42 +00:00
|
|
|
wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine )
|
|
|
|
{
|
2017-11-28 18:13:44 +00:00
|
|
|
wxString retv;
|
|
|
|
|
2018-11-24 04:29:33 +00:00
|
|
|
if( !( m_severities & aLine.severity ) )
|
2017-11-28 18:13:44 +00:00
|
|
|
return retv;
|
2015-06-16 12:20:42 +00:00
|
|
|
|
2021-11-19 12:30:17 +00:00
|
|
|
if( KIPLATFORM::UI::IsDarkTheme() )
|
|
|
|
{
|
|
|
|
switch( aLine.severity )
|
|
|
|
{
|
|
|
|
case RPT_SEVERITY_ERROR:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font color=#F04040 size=3>" ) + _( "Error:" ) + wxS( " </font>" )
|
|
|
|
wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
break;
|
|
|
|
case RPT_SEVERITY_WARNING:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font size=3>" ) + _( "Warning:" ) + wxS( " " ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
break;
|
|
|
|
case RPT_SEVERITY_INFO:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font color=#909090 size=3>" ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
break;
|
|
|
|
case RPT_SEVERITY_ACTION:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font color=#60D060 size=3>" ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-06-16 12:20:42 +00:00
|
|
|
{
|
2021-11-19 12:30:17 +00:00
|
|
|
switch( aLine.severity )
|
|
|
|
{
|
|
|
|
case RPT_SEVERITY_ERROR:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font color=#D00000 size=3>" ) + _( "Error:" ) + wxS( " </font>" )
|
|
|
|
wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
break;
|
|
|
|
case RPT_SEVERITY_WARNING:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font size=3>" ) + _( "Warning:" ) + wxS( " " ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
break;
|
|
|
|
case RPT_SEVERITY_INFO:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font color=#808080 size=3>" ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
break;
|
|
|
|
case RPT_SEVERITY_ACTION:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font color=#008000 size=3>" ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2023-01-17 04:14:38 +00:00
|
|
|
retv = wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
|
2021-11-19 12:30:17 +00:00
|
|
|
}
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
2017-11-28 18:13:44 +00:00
|
|
|
|
2021-11-22 15:36:14 +00:00
|
|
|
// wxHtmlWindow fails to do correct baseline alignment between Japanese/Chinese cells and
|
|
|
|
// Roman cells. This keeps the line in a single cell.
|
2023-01-17 04:14:38 +00:00
|
|
|
retv.Replace( wxS( " " ), wxS( " " ) );
|
2021-11-22 15:36:14 +00:00
|
|
|
|
2017-11-28 18:13:44 +00:00
|
|
|
return retv;
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString WX_HTML_REPORT_PANEL::generatePlainText( const REPORT_LINE& aLine )
|
|
|
|
{
|
|
|
|
switch( aLine.severity )
|
|
|
|
{
|
2021-09-14 18:26:03 +00:00
|
|
|
case RPT_SEVERITY_ERROR: return _( "Error:" ) + wxS( " " ) + aLine.message + wxT( "\n" );
|
|
|
|
case RPT_SEVERITY_WARNING: return _( "Warning:" ) + wxS( " " ) + aLine.message + wxT( "\n" );
|
|
|
|
case RPT_SEVERITY_INFO: return _( "Info:" ) + wxS( " " ) + aLine.message + wxT( "\n" );
|
|
|
|
default: return aLine.message + wxT( "\n" );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-19 16:03:36 +00:00
|
|
|
void WX_HTML_REPORT_PANEL::onRightClick( wxMouseEvent& event )
|
|
|
|
{
|
|
|
|
wxMenu popup;
|
|
|
|
popup.Append( wxID_COPY, "Copy" );
|
|
|
|
PopupMenu( &popup );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::onMenuEvent( wxMenuEvent& event )
|
|
|
|
{
|
|
|
|
if( event.GetId() == wxID_COPY )
|
|
|
|
{
|
2021-01-29 19:13:12 +00:00
|
|
|
wxLogNull doNotLog; // disable logging of failed clipboard actions
|
|
|
|
|
2018-03-19 16:03:36 +00:00
|
|
|
if( wxTheClipboard->Open() )
|
|
|
|
{
|
|
|
|
bool primarySelection = wxTheClipboard->IsUsingPrimarySelection();
|
|
|
|
wxTheClipboard->UsePrimarySelection( false ); // required to use the main clipboard
|
|
|
|
wxTheClipboard->SetData( new wxTextDataObject( m_htmlView->SelectionToText() ) );
|
2021-05-01 22:00:08 +00:00
|
|
|
wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
|
2018-03-19 16:03:36 +00:00
|
|
|
wxTheClipboard->Close();
|
|
|
|
wxTheClipboard->UsePrimarySelection( primarySelection );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
// Don't globally define this; different facilities use different definitions of "ALL"
|
2021-07-15 19:26:35 +00:00
|
|
|
static int RPT_SEVERITY_ALL = RPT_SEVERITY_WARNING | RPT_SEVERITY_ERROR | RPT_SEVERITY_INFO |
|
|
|
|
RPT_SEVERITY_ACTION;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
|
|
|
|
2015-06-16 12:20:42 +00:00
|
|
|
void WX_HTML_REPORT_PANEL::onCheckBoxShowAll( wxCommandEvent& event )
|
|
|
|
{
|
2018-03-19 16:03:36 +00:00
|
|
|
if( event.IsChecked() )
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities = RPT_SEVERITY_ALL;
|
2018-03-19 16:03:36 +00:00
|
|
|
else
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities = RPT_SEVERITY_ERROR;
|
2015-06-16 12:20:42 +00:00
|
|
|
|
|
|
|
syncCheckboxes();
|
2018-05-21 22:28:26 +00:00
|
|
|
Flush( true );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::syncCheckboxes()
|
|
|
|
{
|
2020-03-04 09:48:18 +00:00
|
|
|
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 );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::onCheckBoxShowWarnings( wxCommandEvent& event )
|
|
|
|
{
|
2018-05-21 22:28:26 +00:00
|
|
|
if( event.IsChecked() )
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities |= RPT_SEVERITY_WARNING;
|
2015-07-24 18:49:47 +00:00
|
|
|
else
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities &= ~RPT_SEVERITY_WARNING;
|
2015-06-16 12:20:42 +00:00
|
|
|
|
2018-11-24 04:29:33 +00:00
|
|
|
syncCheckboxes();
|
2018-05-21 22:28:26 +00:00
|
|
|
Flush( true );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::onCheckBoxShowErrors( wxCommandEvent& event )
|
|
|
|
{
|
2018-05-21 22:28:26 +00:00
|
|
|
if( event.IsChecked() )
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities |= RPT_SEVERITY_ERROR;
|
2018-05-21 22:28:26 +00:00
|
|
|
else
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities &= ~RPT_SEVERITY_ERROR;
|
2015-06-16 12:20:42 +00:00
|
|
|
|
2018-11-24 04:29:33 +00:00
|
|
|
syncCheckboxes();
|
2018-05-21 22:28:26 +00:00
|
|
|
Flush( true );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::onCheckBoxShowInfos( wxCommandEvent& event )
|
|
|
|
{
|
2018-05-21 22:28:26 +00:00
|
|
|
if( event.IsChecked() )
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities |= RPT_SEVERITY_INFO;
|
2018-05-21 22:28:26 +00:00
|
|
|
else
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities &= ~RPT_SEVERITY_INFO;
|
2015-06-16 12:20:42 +00:00
|
|
|
|
2018-11-24 04:29:33 +00:00
|
|
|
syncCheckboxes();
|
2018-05-21 22:28:26 +00:00
|
|
|
Flush( true );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::onCheckBoxShowActions( wxCommandEvent& event )
|
|
|
|
{
|
2018-05-21 22:28:26 +00:00
|
|
|
if( event.IsChecked() )
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities |= RPT_SEVERITY_ACTION;
|
2018-05-21 22:28:26 +00:00
|
|
|
else
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities &= ~RPT_SEVERITY_ACTION;
|
2015-06-16 12:20:42 +00:00
|
|
|
|
2018-11-24 04:29:33 +00:00
|
|
|
syncCheckboxes();
|
2018-05-21 22:28:26 +00:00
|
|
|
Flush( true );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
|
|
|
|
{
|
2020-04-21 01:44:17 +00:00
|
|
|
wxFileName fn;
|
|
|
|
|
2020-11-16 00:04:55 +00:00
|
|
|
if( m_reportFileName.empty() )
|
2022-01-20 19:50:21 +00:00
|
|
|
{
|
|
|
|
fn = wxT( "report.txt" );
|
|
|
|
|
|
|
|
KIWAY_HOLDER* parent = dynamic_cast<KIWAY_HOLDER*>( m_parent );
|
|
|
|
|
|
|
|
if( parent )
|
|
|
|
fn.SetPath( parent->Prj().GetProjectPath() );
|
|
|
|
}
|
2020-04-21 01:44:17 +00:00
|
|
|
else
|
2020-11-16 00:04:55 +00:00
|
|
|
fn = m_reportFileName;
|
2015-06-16 12:20:42 +00:00
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Report to File" ), fn.GetPath(), fn.GetFullName(),
|
|
|
|
TextFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
2015-06-16 12:20:42 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
fn = dlg.GetPath();
|
|
|
|
|
|
|
|
if( fn.GetExt().IsEmpty() )
|
2017-11-28 18:13:44 +00:00
|
|
|
fn.SetExt( "txt" );
|
2015-06-16 12:20:42 +00:00
|
|
|
|
2020-12-12 18:11:51 +00:00
|
|
|
wxFFile f( fn.GetFullPath(), "wb" );
|
2015-06-16 12:20:42 +00:00
|
|
|
|
|
|
|
if( !f.IsOpened() )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "Cannot write report to file '%s'." ),
|
2015-06-16 18:04:02 +00:00
|
|
|
fn.GetFullPath().GetData() );
|
2015-06-16 12:20:42 +00:00
|
|
|
wxMessageBox( msg, _( "File save error" ), wxOK | wxICON_ERROR, this );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-25 14:38:10 +00:00
|
|
|
for( REPORT_LINES section : { m_reportHead, m_report, m_reportTail } )
|
2015-06-16 12:20:42 +00:00
|
|
|
{
|
2021-02-25 14:38:10 +00:00
|
|
|
for( const REPORT_LINE& l : section )
|
|
|
|
{
|
|
|
|
wxString s = generatePlainText( l );
|
2020-08-10 17:15:44 +00:00
|
|
|
|
2021-02-25 14:38:10 +00:00
|
|
|
ConvertSmartQuotesAndDashes( &s );
|
|
|
|
f.Write( s );
|
|
|
|
}
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
2021-02-25 14:38:10 +00:00
|
|
|
|
2020-11-16 00:04:55 +00:00
|
|
|
m_reportFileName = fn.GetFullPath();
|
2015-06-16 12:20:42 +00:00
|
|
|
f.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::Clear()
|
|
|
|
{
|
|
|
|
m_report.clear();
|
2018-05-21 22:28:26 +00:00
|
|
|
m_reportHead.clear();
|
|
|
|
m_reportTail.clear();
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
2015-07-24 15:47:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::SetLabel( const wxString& aLabel )
|
|
|
|
{
|
|
|
|
m_box->GetStaticBox()->SetLabel( aLabel );
|
|
|
|
}
|
2015-07-24 18:49:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::SetVisibleSeverities( int aSeverities )
|
|
|
|
{
|
|
|
|
if( aSeverities < 0 )
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities = RPT_SEVERITY_ALL;
|
2015-07-24 18:49:47 +00:00
|
|
|
else
|
|
|
|
m_severities = aSeverities;
|
|
|
|
|
|
|
|
syncCheckboxes();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
int WX_HTML_REPORT_PANEL::GetVisibleSeverities() const
|
2015-07-24 18:49:47 +00:00
|
|
|
{
|
2018-11-24 04:29:33 +00:00
|
|
|
return m_severities;
|
2015-07-24 18:49:47 +00:00
|
|
|
}
|
2020-04-21 01:44:17 +00:00
|
|
|
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
void WX_HTML_REPORT_PANEL::SetFileName( const wxString& aReportFileName )
|
2020-04-21 01:44:17 +00:00
|
|
|
{
|
2020-11-16 00:04:55 +00:00
|
|
|
m_reportFileName = aReportFileName;
|
2020-04-21 01:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString& WX_HTML_REPORT_PANEL::GetFileName( void )
|
|
|
|
{
|
2020-11-16 00:04:55 +00:00
|
|
|
return ( m_reportFileName );
|
2020-04-21 01:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WX_HTML_REPORT_PANEL::SetShowSeverity( SEVERITY aSeverity, bool aValue )
|
|
|
|
{
|
|
|
|
switch( aSeverity )
|
|
|
|
{
|
2021-09-14 18:26:03 +00:00
|
|
|
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;
|
2020-04-21 01:44:17 +00:00
|
|
|
}
|
|
|
|
}
|