*) Switch to later environment variable expansion in fp-lib-table.
*) Save library nickname in APP so upon module editor re-entry last is re-used. *) Fix bug editing fp-lib-table Description field.
This commit is contained in:
parent
468d50317d
commit
f3ad2463e2
|
@ -71,7 +71,71 @@ void FP_LIB_TABLE::ROW::SetType( const wxString& aType )
|
|||
void FP_LIB_TABLE::ROW::SetFullURI( const wxString& aFullURI )
|
||||
{
|
||||
uri_user = aFullURI;
|
||||
|
||||
#if !FP_LATE_ENVVAR
|
||||
uri_expanded = FP_LIB_TABLE::ExpandSubstitutions( aFullURI );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
const wxString FP_LIB_TABLE::ROW::GetFullURI( bool aSubstituted ) const
|
||||
{
|
||||
if( aSubstituted )
|
||||
{
|
||||
#if !FP_LATE_ENVVAR // early expansion
|
||||
return uri_expanded;
|
||||
|
||||
#else // late expansion
|
||||
return FP_LIB_TABLE::ExpandSubstitutions( uri_user );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return uri_user;
|
||||
}
|
||||
|
||||
|
||||
FP_LIB_TABLE::ROW::ROW( const ROW& a ) :
|
||||
nickName( a.nickName ),
|
||||
type( a.type ),
|
||||
options( a.options ),
|
||||
description( a.description ),
|
||||
properties( 0 )
|
||||
{
|
||||
// may call ExpandSubstitutions()
|
||||
SetFullURI( a.uri_user );
|
||||
|
||||
if( a.properties )
|
||||
properties = new PROPERTIES( *a.properties );
|
||||
}
|
||||
|
||||
|
||||
FP_LIB_TABLE::ROW& FP_LIB_TABLE::ROW::operator=( const ROW& r )
|
||||
{
|
||||
nickName = r.nickName;
|
||||
type = r.type;
|
||||
options = r.options;
|
||||
description = r.description;
|
||||
properties = r.properties ? new PROPERTIES( *r.properties ) : NULL;
|
||||
|
||||
// may call ExpandSubstitutions()
|
||||
SetFullURI( r.uri_user );
|
||||
|
||||
// Do not copy the PLUGIN, it is lazily created. Delete any existing
|
||||
// destination plugin.
|
||||
setPlugin( NULL );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool FP_LIB_TABLE::ROW::operator==( const ROW& r ) const
|
||||
{
|
||||
return nickName == r.nickName
|
||||
&& uri_user == r.uri_user
|
||||
&& type == r.type
|
||||
&& options == r.options
|
||||
&& description == r.description
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,13 +27,13 @@
|
|||
#define FP_LIB_TABLE_H_
|
||||
|
||||
#include <macros.h>
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <io_mgr.h>
|
||||
|
||||
|
||||
|
||||
#define FP_LATE_ENVVAR 1 ///< late=1/early=0 environment variable expansion
|
||||
#define KISYSMOD "KISYSMOD"
|
||||
|
||||
class wxFileName;
|
||||
|
@ -122,44 +122,17 @@ public:
|
|||
SetType( aType );
|
||||
}
|
||||
|
||||
ROW( const ROW& a ) :
|
||||
nickName( a.nickName ),
|
||||
uri_user( a.uri_user ),
|
||||
uri_expanded( a.uri_expanded ),
|
||||
type( a.type ),
|
||||
options( a.options ),
|
||||
description( a.description ),
|
||||
properties( 0 )
|
||||
{
|
||||
if( a.properties )
|
||||
properties = new PROPERTIES( *a.properties );
|
||||
}
|
||||
ROW( const ROW& a );
|
||||
|
||||
~ROW()
|
||||
{
|
||||
delete properties;
|
||||
}
|
||||
|
||||
ROW& operator=( const ROW& r )
|
||||
{
|
||||
nickName = r.nickName;
|
||||
uri_user = r.uri_user;
|
||||
uri_expanded = r.uri_expanded;
|
||||
type = r.type;
|
||||
options = r.options;
|
||||
description = r.description;
|
||||
properties = r.properties ? new PROPERTIES( *r.properties ) : NULL;
|
||||
ROW& operator=( const ROW& r );
|
||||
|
||||
// do not copy the PLUGIN, it is lazily created.
|
||||
setPlugin( NULL );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==( const ROW& r ) const
|
||||
{
|
||||
return nickName==r.nickName && uri_user==r.uri_user && type==r.type && options==r.options;
|
||||
}
|
||||
/// Used in DIALOG_FP_LIB_TABLE for detecting an edit.
|
||||
bool operator==( const ROW& r ) const;
|
||||
|
||||
bool operator!=( const ROW& r ) const { return !( *this == r ); }
|
||||
|
||||
|
@ -196,13 +169,7 @@ public:
|
|||
*
|
||||
* @param aSubstituted Tells if caller wanted the substituted form, else not.
|
||||
*/
|
||||
const wxString& GetFullURI( bool aSubstituted = false ) const
|
||||
{
|
||||
if( aSubstituted )
|
||||
return uri_expanded;
|
||||
else
|
||||
return uri_user;
|
||||
}
|
||||
const wxString GetFullURI( bool aSubstituted = false ) const;
|
||||
|
||||
/**
|
||||
* Function SetFullURI
|
||||
|
@ -280,7 +247,11 @@ public:
|
|||
|
||||
wxString nickName;
|
||||
wxString uri_user; ///< what user entered from UI or loaded from disk
|
||||
|
||||
#if !FP_LATE_ENVVAR
|
||||
wxString uri_expanded; ///< from ExpandSubstitutions()
|
||||
#endif
|
||||
|
||||
LIB_T type;
|
||||
wxString options;
|
||||
wxString description;
|
||||
|
|
|
@ -330,11 +330,12 @@ public:
|
|||
wxGrid* g = i==0 ? m_global_grid : m_project_grid;
|
||||
|
||||
// all but COL_OPTIONS, which is edited with Option Editor anyways.
|
||||
g->AutoSizeColumn( COL_NICKNAME, true );
|
||||
g->AutoSizeColumn( COL_NICKNAME, false );
|
||||
g->AutoSizeColumn( COL_TYPE, false );
|
||||
g->AutoSizeColumn( COL_URI, false );
|
||||
g->AutoSizeColumn( COL_DESCR, false );
|
||||
|
||||
// would set this to width of title, if it was easily known.
|
||||
g->SetColSize( COL_OPTIONS, 80 );
|
||||
}
|
||||
|
||||
|
|
|
@ -432,13 +432,11 @@ protected:
|
|||
*/
|
||||
void updateTitle();
|
||||
|
||||
wxString m_lib_nick_name;
|
||||
|
||||
/// The library nickName is a short string, for now the same as the library path
|
||||
/// but without path and without extension. After library table support it becomes
|
||||
/// a lookup key.
|
||||
wxString getLibNickName() const { return m_lib_nick_name; }
|
||||
void setLibNickName( const wxString& aLibNickName ) { m_lib_nick_name = aLibNickName; }
|
||||
const wxString& getLibNickName() const;
|
||||
void setLibNickName( const wxString& aNickname );
|
||||
|
||||
|
||||
#if !defined(USE_FP_LIB_TABLE)
|
||||
|
|
|
@ -255,12 +255,28 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
|
|||
m_Pcb = 0;
|
||||
}
|
||||
|
||||
#if defined(USE_FP_LIB_TABLE)
|
||||
|
||||
const wxString& FOOTPRINT_EDIT_FRAME::getLibNickName() const
|
||||
{
|
||||
return wxGetApp().GetModuleLibraryNickname();
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::setLibNickName( const wxString& aNickname )
|
||||
{
|
||||
wxGetApp().SetModuleLibraryNickname( aNickname );
|
||||
}
|
||||
|
||||
|
||||
#if 1 && defined(USE_FP_LIB_TABLE)
|
||||
wxString FOOTPRINT_EDIT_FRAME::getLibPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
const FP_LIB_TABLE::ROW* row = GetFootprintLibraryTable()->FindRow( m_lib_nick_name );
|
||||
const wxString& nickname = getLibNickName();
|
||||
|
||||
const FP_LIB_TABLE::ROW* row = GetFootprintLibraryTable()->FindRow( nickname );
|
||||
|
||||
return row->GetFullURI( true );
|
||||
}
|
||||
catch( IO_ERROR ioe )
|
||||
|
@ -600,6 +616,8 @@ void FOOTPRINT_EDIT_FRAME::OnModify()
|
|||
void FOOTPRINT_EDIT_FRAME::updateTitle()
|
||||
{
|
||||
wxString title = _( "Module Editor " );
|
||||
|
||||
#if !defined(USE_FP_LIB_TABLE)
|
||||
wxString libPath = getLibPath();
|
||||
|
||||
if( !libPath )
|
||||
|
@ -633,5 +651,36 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
|
|||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
wxString nickname = getLibNickName();
|
||||
|
||||
if( !nickname )
|
||||
{
|
||||
L_none:
|
||||
title += _( "(no active library)" );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
bool writable = m_footprintLibTable->IsFootprintLibWritable( nickname );
|
||||
|
||||
// no exception was thrown, this means libPath is valid, but it may be read only.
|
||||
title = _( "Module Editor (active library: " ) + nickname + wxT( ")" );
|
||||
|
||||
if( !writable )
|
||||
title += _( " [Read Only]" );
|
||||
}
|
||||
catch( IO_ERROR ioe )
|
||||
{
|
||||
// user may be bewildered as to why after selecting a library it is not showing up
|
||||
// in the title, we could show an error message, but that should have been done at time
|
||||
// of libary selection UI.
|
||||
goto L_none;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SetTitle( title );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue