Commit 3be6ba42 authored by charras's avatar charras

Merged dialog_load_error_base and dialog_display_info_HTML_base, code cleaning

parent 1700a6a7
...@@ -24,7 +24,6 @@ set(COMMON_SRCS ...@@ -24,7 +24,6 @@ set(COMMON_SRCS
copy_to_clipboard.cpp copy_to_clipboard.cpp
dialog_display_info_HTML_base.cpp dialog_display_info_HTML_base.cpp
dialog_load_error.cpp dialog_load_error.cpp
dialog_load_error_base.cpp
dcsvg.cpp dcsvg.cpp
displlst.cpp displlst.cpp
dlist.cpp dlist.cpp
......
...@@ -10,7 +10,7 @@ DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, _("Load Error!"),wxDefaultPosit ...@@ -10,7 +10,7 @@ DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, _("Load Error!"),wxDefaultPosit
void DIALOG_LOAD_ERROR::OnCloseButtonClick( wxCommandEvent& event ) void DIALOG_LOAD_ERROR::OnCloseButtonClick( wxCommandEvent& event )
{ {
Destroy(); EndModal(0);
} }
...@@ -23,11 +23,11 @@ void DIALOG_LOAD_ERROR::ListClear(void) ...@@ -23,11 +23,11 @@ void DIALOG_LOAD_ERROR::ListClear(void)
* Add a list of items. * Add a list of items.
* @param list = a pointer on a string containing items. Items are separated by '\n' * @param list = a pointer on a string containing items. Items are separated by '\n'
*/ */
void DIALOG_LOAD_ERROR::ListSet(wxString *list) void DIALOG_LOAD_ERROR::ListSet(const wxString &list)
{ {
wxArrayString* wxStringSplit( wxString txt, wxChar splitter ); wxArrayString* wxStringSplit( wxString txt, wxChar splitter );
wxArrayString* strings_list = wxStringSplit( *list, wxChar('\n') ); wxArrayString* strings_list = wxStringSplit( list, wxChar('\n') );
m_htmlWindow->AppendToPage(wxT("<ul>") ); m_htmlWindow->AppendToPage(wxT("<ul>") );
for ( unsigned ii = 0; ii < strings_list->GetCount(); ii ++ ) for ( unsigned ii = 0; ii < strings_list->GetCount(); ii ++ )
{ {
...@@ -44,10 +44,10 @@ void DIALOG_LOAD_ERROR::ListSet(wxString *list) ...@@ -44,10 +44,10 @@ void DIALOG_LOAD_ERROR::ListSet(wxString *list)
* Add a message (in bold) to message list. * Add a message (in bold) to message list.
* @param message = a pointer to the message * @param message = a pointer to the message
*/ */
void DIALOG_LOAD_ERROR::MessageSet(wxString *message) void DIALOG_LOAD_ERROR::MessageSet(const wxString &message)
{ {
wxString message_value; wxString message_value;
message_value.Printf(wxT("<b>%s</b><br>"), message->GetData() ); message_value.Printf(wxT("<b>%s</b><br>"), message.GetData() );
m_htmlWindow->AppendToPage( message_value ); m_htmlWindow->AppendToPage( message_value );
} }
...@@ -76,9 +76,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ...@@ -76,9 +76,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
if( !tmp ) if( !tmp )
{ {
msg.Printf( _( "PCB foot print library file <%s> could not be found in the default search paths." ), mdc_files_not_found << filename.GetFullName() << wxT("\n");
filename.GetFullName().c_str() );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR );
continue; continue;
} }
...@@ -87,9 +85,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ...@@ -87,9 +85,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
if( file == NULL ) if( file == NULL )
{ {
msg.Printf( _( "Could not open PCB foot print library file <%s>." ), mdc_files_invalid << tmp << _(" (file cannot be opened)") << wxT("\n");
tmp.c_str() );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR );
continue; continue;
} }
...@@ -97,9 +93,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ...@@ -97,9 +93,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
fgets( buffer, 32, file ); fgets( buffer, 32, file );
if( strncmp( buffer, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) if( strncmp( buffer, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{ {
msg.Printf( _( "<%s> is not a valid Kicad PCB foot print library" ), mdc_files_invalid << tmp << _(" (Not a Kicad file)") << wxT("\n");
tmp.c_str() );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR );
fclose( file ); fclose( file );
continue; continue;
} }
...@@ -129,9 +123,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ...@@ -129,9 +123,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
if( !end ) if( !end )
{ {
msg.Printf( _( "Unexpected end of file occurred while parsing PCB foot print library <%s>." ), mdc_files_invalid << tmp << _(" (Unexpected end of file)") << wxT("\n");
tmp.c_str() );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR );
} }
} }
} }
...@@ -144,25 +136,25 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ...@@ -144,25 +136,25 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
/* Display if there are mdc files not found */ /* Display if there are mdc files not found */
if( !mdc_files_not_found.IsEmpty() || !mdc_files_invalid.IsEmpty() )
{
DIALOG_LOAD_ERROR dialog(NULL);
if( !mdc_files_not_found.IsEmpty() ) if( !mdc_files_not_found.IsEmpty() )
{ {
wxString message = _("Some MDC files could not be found!"); wxString message = _("Some MDC files could not be found!");
DIALOG_LOAD_ERROR *dialog = new DIALOG_LOAD_ERROR(NULL); dialog.MessageSet(message);
dialog->Show(); dialog.ListSet(mdc_files_not_found);
dialog->MessageSet(&message); mdc_files_not_found.Empty();
dialog->ListSet(&mdc_files_not_found);
mdc_files_not_found = wxT("");
} }
/* Display if there are mdc files invalid */ /* Display if there are mdc files invalid */
if( !mdc_files_invalid.IsEmpty() ) if( !mdc_files_invalid.IsEmpty() )
{ {
wxString message = _("Some MDC files are invalid!"); dialog.MessageSet( _("Some MDC files are invalid!"));
DIALOG_LOAD_ERROR *dialog = new DIALOG_LOAD_ERROR(NULL); dialog.ListSet(mdc_files_invalid);
dialog->Show(); mdc_files_invalid.Empty();
dialog->MessageSet(&message); }
dialog->ListSet(&mdc_files_invalid); dialog.ShowModal();
mdc_files_invalid = wxT("");
} }
list.sort(); list.sort();
......
...@@ -168,12 +168,11 @@ void LoadLibraries( WinEDA_SchematicFrame* frame ) ...@@ -168,12 +168,11 @@ void LoadLibraries( WinEDA_SchematicFrame* frame )
/* Print the libraries not found */ /* Print the libraries not found */
if( !libraries_not_found.IsEmpty() ) if( !libraries_not_found.IsEmpty() )
{ {
wxString message = _("The following libraries could not be found:"); DIALOG_LOAD_ERROR dialog(frame);
DIALOG_LOAD_ERROR *dialog = new DIALOG_LOAD_ERROR(NULL); dialog.MessageSet(_("The following libraries could not be found:"));
dialog->Show(); dialog.ListSet(libraries_not_found);
dialog->MessageSet(&message); libraries_not_found.empty();
dialog->ListSet(&libraries_not_found); dialog.ShowModal();
libraries_not_found = wxT("");
} }
......
...@@ -20,15 +20,15 @@ public: ...@@ -20,15 +20,15 @@ public:
DIALOG_LOAD_ERROR( wxWindow* parent ); DIALOG_LOAD_ERROR( wxWindow* parent );
/** Function ListSet /** Function ListSet
* Add a list of items. * Add a list of items.
* @param list = a pointer on a string containing items. Items are separated by '\n' * @param list = a string containing items. Items are separated by '\n'
*/ */
void ListSet(wxString *list); void ListSet(const wxString &list);
void ListClear(); void ListClear();
/** Function MessageSet /** Function MessageSet
* Add a message (in bold) to message list. * Add a message (in bold) to message list.
* @param message = a pointer to the message * @param message = the message
*/ */
void MessageSet(wxString *message); void MessageSet(const wxString &message);
}; };
#endif // __dialog_load_error_h_ #endif // __dialog_load_error_h_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment