Add progress dialog when loading symbol libraries

- Provides UX feedback for user
This commit is contained in:
Oliver 2017-11-15 21:48:38 +11:00 committed by Wayne Stambaugh
parent 8b140186fe
commit e25a777c41
4 changed files with 37 additions and 14 deletions

View File

@ -24,7 +24,7 @@
#include <eda_pattern_match.h>
#include <wx/tokenzr.h>
#include <symbol_lib_table.h>
#include <wx/progdlg.h>
CMP_TREE_MODEL_ADAPTER::WIDTH_CACHE CMP_TREE_MODEL_ADAPTER::m_width_cache;
@ -135,6 +135,26 @@ void CMP_TREE_MODEL_ADAPTER::AddLibrary( wxString const& aLibNickname )
}
void CMP_TREE_MODEL_ADAPTER::AddLibrariesWithProgress( const std::vector<wxString>& aNicknames, EDA_DRAW_FRAME* aParent )
{
auto* prg = new wxProgressDialog(
_( "Loading symbol libraries" ),
wxEmptyString,
aNicknames.size(),
aParent );
unsigned int ii = 0;
for( auto nickname : aNicknames )
{
prg->Update( ii++, wxString::Format( _( "Loading library '%s'" ), nickname ) );
AddLibrary( nickname );
}
prg->Destroy();
}
void CMP_TREE_MODEL_ADAPTER::AddAliasList(
wxString const& aNodeName,
wxArrayString const& aAliasNameList )

View File

@ -24,6 +24,7 @@
#include <lib_id.h>
#include <draw_frame.h>
#include <cmp_tree_model.h>
#include <wx/hashmap.h>
@ -155,6 +156,17 @@ public:
*/
void AddLibrary( wxString const& aLibNickname );
/**
* Add all the libraries in a SYMBOL_LIB_TABLE to the model,
* displaying a progress dialog attached to the parent frame
*
* @param aNicknames is the list of library nicknames
* @param aParent is the parent window to display the progress dialog
*/
void AddLibrariesWithProgress( const std::vector<wxString>& aNicknames, EDA_DRAW_FRAME* aParent );
/**
* Add the given list of components, by name. To be called in the setup
* phase.

View File

@ -148,14 +148,11 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibrary(
adapter->SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit );
}
std::vector< wxString > libNicknames = libs->GetLogicalLibs();
const std::vector< wxString > libNicknames = libs->GetLogicalLibs();
if( !loaded )
{
for( auto nickname : libNicknames )
{
adapter->AddLibrary( nickname );
}
adapter->AddLibrariesWithProgress( libNicknames, this );
}
if( aHighlight && aHighlight->IsValid() )

View File

@ -44,7 +44,6 @@
#include <cmp_tree_model_adapter.h>
#include <symbol_lib_table.h>
void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
{
wxString dialogTitle;
@ -53,14 +52,9 @@ void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
// Container doing search-as-you-type.
auto adapter( CMP_TREE_MODEL_ADAPTER::Create( libs ) );
std::vector< wxString > libNicknames;
const auto libNicknames = libs->GetLogicalLibs();
libNicknames = libs->GetLogicalLibs();
for( auto nickname : libNicknames )
{
adapter->AddLibrary( nickname );
}
adapter->AddLibrariesWithProgress( libNicknames, this );
dialogTitle.Printf( _( "Choose Component (%d items loaded)" ),
adapter->GetComponentsCount() );