SYMBOL_LIB_TABLE and PANEL_SYM_LIB_TABLE: fix some issues:
- Ensure a change in plugin type is detected - do not force automatic plugin type selection for *.lib files that need an access to these libraries: they can be not always available.
This commit is contained in:
parent
5e21e94478
commit
ae7456e055
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2017 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2021 CERN
|
* Copyright (C) 2021 CERN
|
||||||
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
@ -328,6 +328,23 @@ PANEL_SYM_LIB_TABLE::~PANEL_SYM_LIB_TABLE()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PANEL_SYM_LIB_TABLE::allowAutomaticPluginTypeSelection( wxString& aLibraryPath )
|
||||||
|
{
|
||||||
|
// When the plugin type depends only of the file extension, return true.
|
||||||
|
// if it needs to read the actual file (taht can be not available), return false
|
||||||
|
|
||||||
|
wxFileName fn( aLibraryPath );
|
||||||
|
wxString ext = fn.GetExt().Lower();
|
||||||
|
|
||||||
|
// Currently, only the extension .lib is common to legacy libraries and Cadstar libraries
|
||||||
|
// so return false in this case
|
||||||
|
if( ext == LegacySymbolLibFileExtension )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PANEL_SYM_LIB_TABLE::verifyTables()
|
bool PANEL_SYM_LIB_TABLE::verifyTables()
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
@ -389,7 +406,16 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
|
||||||
{
|
{
|
||||||
// set the trimmed values back into the table so they get saved to disk.
|
// set the trimmed values back into the table so they get saved to disk.
|
||||||
model->SetValue( r, COL_NICKNAME, nick );
|
model->SetValue( r, COL_NICKNAME, nick );
|
||||||
model->SetValue( r, COL_URI, uri );
|
|
||||||
|
if( allowAutomaticPluginTypeSelection( uri ) )
|
||||||
|
model->SetValue( r, COL_URI, uri );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString ltype = model->GetValue( r, COL_TYPE );
|
||||||
|
model->LIB_TABLE_GRID::SetValue( r, COL_URI, uri );
|
||||||
|
model->SetValue( r, COL_TYPE, ltype );
|
||||||
|
}
|
||||||
|
|
||||||
++r; // this row was OK.
|
++r; // this row was OK.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,14 @@ private:
|
||||||
|
|
||||||
SYMBOL_LIB_TABLE_GRID* cur_model() const;
|
SYMBOL_LIB_TABLE_GRID* cur_model() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the plugin type can be selected from the library path only
|
||||||
|
* (i.e. only from its extension)
|
||||||
|
* if the type needs an access to the file itself, return false because
|
||||||
|
* the file can be not (at least temporary) available
|
||||||
|
*/
|
||||||
|
bool allowAutomaticPluginTypeSelection( wxString& aLibraryPath );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Caller's tables are modified only on OK button and successful verification.
|
// Caller's tables are modified only on OK button and successful verification.
|
||||||
SYMBOL_LIB_TABLE* m_globalTable;
|
SYMBOL_LIB_TABLE* m_globalTable;
|
||||||
|
|
|
@ -168,6 +168,11 @@ SCH_IO_MGR::SCH_FILE_T SCH_IO_MGR::GuessPluginTypeFromLibPath( const wxString& a
|
||||||
{
|
{
|
||||||
wxString fullName = ExpandEnvVarSubstitutions( aLibPath, nullptr );
|
wxString fullName = ExpandEnvVarSubstitutions( aLibPath, nullptr );
|
||||||
|
|
||||||
|
// Of course the file should exist to be read. If not, use the SCH_LEGACY
|
||||||
|
// format: it is more usual than SCH_CADSTAR_ARCHIVE
|
||||||
|
if( !wxFileExists( fullName ) )
|
||||||
|
return SCH_LEGACY;
|
||||||
|
|
||||||
for( SCH_FILE_T pluginType : { SCH_LEGACY, SCH_CADSTAR_ARCHIVE } )
|
for( SCH_FILE_T pluginType : { SCH_LEGACY, SCH_CADSTAR_ARCHIVE } )
|
||||||
{
|
{
|
||||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( pluginType ) );
|
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( pluginType ) );
|
||||||
|
@ -179,16 +184,13 @@ SCH_IO_MGR::SCH_FILE_T SCH_IO_MGR::GuessPluginTypeFromLibPath( const wxString& a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If not found, use the SCH_LEGACY.
|
||||||
|
return SCH_LEGACY;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( SCH_IO_MGR::SCH_FILE_T piType : SCH_IO_MGR::SCH_FILE_T_vector )
|
for( SCH_IO_MGR::SCH_FILE_T piType : SCH_IO_MGR::SCH_FILE_T_vector )
|
||||||
{
|
{
|
||||||
|
if( SCH_IO_MGR::GetLibraryFileExtension( piType ).Lower() == ext )
|
||||||
if( ext == LegacySymbolLibFileExtension )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if( SCH_IO_MGR::GetLibraryFileExtension( piType ).Lower() == fn.GetExt().Lower() )
|
|
||||||
{
|
{
|
||||||
ret = piType;
|
ret = piType;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2022 CERN
|
* Copyright (C) 2022 CERN
|
||||||
* Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -680,6 +680,26 @@ bool SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE& aTable )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SYMBOL_LIB_TABLE::operator==( const SYMBOL_LIB_TABLE& aOther ) const
|
||||||
|
{
|
||||||
|
if( m_rows.size() != aOther.m_rows.size() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
for( i = 0; i < m_rows.size(); ++i )
|
||||||
|
{
|
||||||
|
const SYMBOL_LIB_TABLE_ROW& curr = static_cast<const SYMBOL_LIB_TABLE_ROW&>( m_rows[i] );
|
||||||
|
const SYMBOL_LIB_TABLE_ROW& curr_other = static_cast<const SYMBOL_LIB_TABLE_ROW&>( aOther.m_rows[i] );
|
||||||
|
|
||||||
|
if( curr != curr_other )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString SYMBOL_LIB_TABLE::GetGlobalTableFileName()
|
wxString SYMBOL_LIB_TABLE::GetGlobalTableFileName()
|
||||||
{
|
{
|
||||||
wxFileName fn;
|
wxFileName fn;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2016 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2016-2021 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -308,6 +308,15 @@ public:
|
||||||
|
|
||||||
static const wxString& GetSymbolLibTableFileName();
|
static const wxString& GetSymbolLibTableFileName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares this table against another.
|
||||||
|
* This compares the row *contents* against each other.
|
||||||
|
*/
|
||||||
|
bool operator==( const SYMBOL_LIB_TABLE& aOther ) const;
|
||||||
|
|
||||||
|
bool operator!=( const SYMBOL_LIB_TABLE& aOther ) const { return !( *this == aOther ); }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SYMBOL_LIB_TABLE_GRID;
|
friend class SYMBOL_LIB_TABLE_GRID;
|
||||||
friend class PANEL_SYM_LIB_TABLE;
|
friend class PANEL_SYM_LIB_TABLE;
|
||||||
|
|
Loading…
Reference in New Issue