Commit f3ad2463 authored by Dick Hollenbeck's avatar Dick Hollenbeck

*) 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.
parent 468d5031
...@@ -71,7 +71,71 @@ void FP_LIB_TABLE::ROW::SetType( const wxString& aType ) ...@@ -71,7 +71,71 @@ void FP_LIB_TABLE::ROW::SetType( const wxString& aType )
void FP_LIB_TABLE::ROW::SetFullURI( const wxString& aFullURI ) void FP_LIB_TABLE::ROW::SetFullURI( const wxString& aFullURI )
{ {
uri_user = aFullURI; uri_user = aFullURI;
#if !FP_LATE_ENVVAR
uri_expanded = FP_LIB_TABLE::ExpandSubstitutions( aFullURI ); 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 @@ ...@@ -27,13 +27,13 @@
#define FP_LIB_TABLE_H_ #define FP_LIB_TABLE_H_
#include <macros.h> #include <macros.h>
#include <vector> #include <vector>
#include <map> #include <map>
#include <io_mgr.h> #include <io_mgr.h>
#define FP_LATE_ENVVAR 1 ///< late=1/early=0 environment variable expansion
#define KISYSMOD "KISYSMOD" #define KISYSMOD "KISYSMOD"
class wxFileName; class wxFileName;
...@@ -122,44 +122,17 @@ public: ...@@ -122,44 +122,17 @@ public:
SetType( aType ); SetType( aType );
} }
ROW( const ROW& a ) : 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() ~ROW()
{ {
delete properties; delete properties;
} }
ROW& operator=( const ROW& r ) 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;
// do not copy the PLUGIN, it is lazily created.
setPlugin( NULL );
return *this;
}
bool operator==( const ROW& r ) const /// Used in DIALOG_FP_LIB_TABLE for detecting an edit.
{ bool operator==( const ROW& r ) const;
return nickName==r.nickName && uri_user==r.uri_user && type==r.type && options==r.options;
}
bool operator!=( const ROW& r ) const { return !( *this == r ); } bool operator!=( const ROW& r ) const { return !( *this == r ); }
...@@ -196,13 +169,7 @@ public: ...@@ -196,13 +169,7 @@ public:
* *
* @param aSubstituted Tells if caller wanted the substituted form, else not. * @param aSubstituted Tells if caller wanted the substituted form, else not.
*/ */
const wxString& GetFullURI( bool aSubstituted = false ) const const wxString GetFullURI( bool aSubstituted = false ) const;
{
if( aSubstituted )
return uri_expanded;
else
return uri_user;
}
/** /**
* Function SetFullURI * Function SetFullURI
...@@ -280,7 +247,11 @@ public: ...@@ -280,7 +247,11 @@ public:
wxString nickName; wxString nickName;
wxString uri_user; ///< what user entered from UI or loaded from disk wxString uri_user; ///< what user entered from UI or loaded from disk
#if !FP_LATE_ENVVAR
wxString uri_expanded; ///< from ExpandSubstitutions() wxString uri_expanded; ///< from ExpandSubstitutions()
#endif
LIB_T type; LIB_T type;
wxString options; wxString options;
wxString description; wxString description;
......
...@@ -330,11 +330,12 @@ public: ...@@ -330,11 +330,12 @@ public:
wxGrid* g = i==0 ? m_global_grid : m_project_grid; wxGrid* g = i==0 ? m_global_grid : m_project_grid;
// all but COL_OPTIONS, which is edited with Option Editor anyways. // 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_TYPE, false );
g->AutoSizeColumn( COL_URI, false ); g->AutoSizeColumn( COL_URI, false );
g->AutoSizeColumn( COL_DESCR, false ); g->AutoSizeColumn( COL_DESCR, false );
// would set this to width of title, if it was easily known.
g->SetColSize( COL_OPTIONS, 80 ); g->SetColSize( COL_OPTIONS, 80 );
} }
......
...@@ -432,13 +432,11 @@ protected: ...@@ -432,13 +432,11 @@ protected:
*/ */
void updateTitle(); void updateTitle();
wxString m_lib_nick_name;
/// The library nickName is a short string, for now the same as the library path /// 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 /// but without path and without extension. After library table support it becomes
/// a lookup key. /// a lookup key.
wxString getLibNickName() const { return m_lib_nick_name; } const wxString& getLibNickName() const;
void setLibNickName( const wxString& aLibNickName ) { m_lib_nick_name = aLibNickName; } void setLibNickName( const wxString& aNickname );
#if !defined(USE_FP_LIB_TABLE) #if !defined(USE_FP_LIB_TABLE)
......
...@@ -255,12 +255,28 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME() ...@@ -255,12 +255,28 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
m_Pcb = 0; 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() wxString FOOTPRINT_EDIT_FRAME::getLibPath()
{ {
try 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 ); return row->GetFullURI( true );
} }
catch( IO_ERROR ioe ) catch( IO_ERROR ioe )
...@@ -600,6 +616,8 @@ void FOOTPRINT_EDIT_FRAME::OnModify() ...@@ -600,6 +616,8 @@ void FOOTPRINT_EDIT_FRAME::OnModify()
void FOOTPRINT_EDIT_FRAME::updateTitle() void FOOTPRINT_EDIT_FRAME::updateTitle()
{ {
wxString title = _( "Module Editor " ); wxString title = _( "Module Editor " );
#if !defined(USE_FP_LIB_TABLE)
wxString libPath = getLibPath(); wxString libPath = getLibPath();
if( !libPath ) if( !libPath )
...@@ -633,5 +651,36 @@ void FOOTPRINT_EDIT_FRAME::updateTitle() ...@@ -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 ); SetTitle( title );
} }
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