Timestamp-based paths were ugly. UUID-based ones are worse.

Show a human-readable path in the Edit Footprint dialog.
This commit is contained in:
Jeff Young 2020-02-20 19:43:39 +00:00
parent 129042f8a6
commit 81dd1d7a68
5 changed files with 66 additions and 5 deletions

View File

@ -168,6 +168,33 @@ const wxString PROJECT::libTableName( const wxString& aLibTableName ) const
}
const wxString PROJECT::GetSheetName( const UUID& aSheetID )
{
if( m_sheetNames.empty() )
{
std::unique_ptr<wxConfigBase> config( configCreate( SEARCH_STACK(), GROUP_SHEET_NAMES ) );
config->SetPath( GROUP_SHEET_NAMES );
int index = 1;
wxString entry;
while( config->Read( wxString::Format( "%d", index++ ), &entry ) )
{
wxArrayString tokens = wxSplit( entry, ':' );
if( tokens.size() == 2 )
m_sheetNames[ UUID( tokens[0] ) ] = tokens[1];
}
}
if( m_sheetNames.count( aSheetID ) )
return m_sheetNames.at( aSheetID );
else
return aSheetID.AsString();
}
void PROJECT::SetRString( RSTRING_T aIndex, const wxString& aString )
{
unsigned ndx = unsigned( aIndex );

View File

@ -535,6 +535,25 @@ bool SCH_EDIT_FRAME::SaveProject()
CreateArchiveLibraryCacheFile();
wxString configFile = Prj().GetProjectFullName();
wxConfigBase* config = new wxFileConfig( wxEmptyString, wxEmptyString, configFile );
int index = 1;
config->DeleteGroup( GROUP_SHEET_NAMES );
config->SetPath( GROUP_SHEET_NAMES );
SCH_SHEET_LIST sheetList( g_RootSheet );
for( SCH_SHEET_PATH& sheetPath : sheetList )
{
SCH_SHEET* sheet = sheetPath.Last();
config->Write( wxString::Format( "%d", index++ ),
wxString::Format( "%s:%s", sheet->m_Uuid.AsString(), sheet->GetName() ) );
}
config->Flush();
delete config;
UpdateTitle();
return success;

View File

@ -52,9 +52,10 @@ using KIGFX::COLOR4D;
/// (Now in fp lib tables)
#define GROUP_SCH_LIBS wxT( "/eeschema/libraries" ) /// library list section
#define GROUP_CVP wxT("/cvpcb")
#define GROUP_CVP_EQU wxT("/cvpcb/equfiles")
#define GROUP_CVP wxT( "/cvpcb" )
#define GROUP_CVP_EQU wxT( "/cvpcb/equfiles" )
#define GROUP_SHEET_NAMES wxT( "/sheetnames" )
#define CONFIG_VERSION 1

View File

@ -31,6 +31,7 @@
#include <wx/string.h>
#include <wx/filename.h>
#include <core/typeinfo.h>
#include <common.h>
/// A variable name whose value holds the current project directory.
/// Currently an environment variable, eventually a project variable.
@ -111,6 +112,11 @@ public:
*/
VTBL_ENTRY const wxString GetProjectName() const;
/**
* Return the name of the sheet identified by the given UUID.
*/
VTBL_ENTRY const wxString GetSheetName( const UUID& aSheetID );
/**
* Function FootprintLibTblName
* returns the path and filename of this project's fp-lib-table,
@ -331,6 +337,8 @@ private:
wxFileName m_project_name; ///< \<fullpath\>/\<basename\>.pro
wxString m_pro_date_and_time;
std::map<UUID, wxString> m_sheetNames;
/// @see this::SetRString(), GetRString(), and enum RSTRING_T.
wxString m_rstrings[RSTRING_COUNT];

View File

@ -275,10 +275,16 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow()
m_BoardSideCtrl->SetSelection( (m_footprint->GetLayer() == B_Cu) ? 1 : 0 );
wxString path;
wxString path = "/";
for( const UUID& pathStep : m_footprint->GetPath() )
path += '/' + pathStep.AsString();
// Exclude the last path step (it's the component)
for( int i = 0; i + 1 < m_footprint->GetPath().size(); ++i )
{
if( path.length() > 1 )
path += "/";
path += Prj().GetSheetName( m_footprint->GetPath()[i] );
}
m_tcUniqueID->SetValue( path );