Library Manager: do not clear modified flag on 'save library as' action
This commit is contained in:
parent
df8dc01e8d
commit
33242fd111
|
@ -202,6 +202,40 @@ bool LIB_MANAGER::IsPartModified( const wxString& aAlias, const wxString& aLibra
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LIB_MANAGER::ClearLibraryModified( const wxString& aLibrary ) const
|
||||||
|
{
|
||||||
|
auto libIt = m_libs.find( aLibrary );
|
||||||
|
|
||||||
|
if( libIt == m_libs.end() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for( auto& partBuf : libIt->second.GetBuffers() )
|
||||||
|
{
|
||||||
|
SCH_SCREEN* screen = partBuf->GetScreen();
|
||||||
|
|
||||||
|
if( screen )
|
||||||
|
screen->ClrModify();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LIB_MANAGER::ClearPartModified( const wxString& aAlias, const wxString& aLibrary ) const
|
||||||
|
{
|
||||||
|
auto libI = m_libs.find( aLibrary );
|
||||||
|
|
||||||
|
if( libI == m_libs.end() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto partBuf = libI->second.GetBuffer( aAlias );
|
||||||
|
wxCHECK( partBuf, false );
|
||||||
|
|
||||||
|
partBuf->GetScreen()->ClrModify();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LIB_MANAGER::IsLibraryReadOnly( const wxString& aLibrary ) const
|
bool LIB_MANAGER::IsLibraryReadOnly( const wxString& aLibrary ) const
|
||||||
{
|
{
|
||||||
wxCHECK( LibraryExists( aLibrary ), true );
|
wxCHECK( LibraryExists( aLibrary ), true );
|
||||||
|
@ -348,8 +382,6 @@ bool LIB_MANAGER::RevertPart( const wxString& aAlias, const wxString& aLibrary )
|
||||||
|
|
||||||
auto partBuf = it->second.GetBuffer( aAlias );
|
auto partBuf = it->second.GetBuffer( aAlias );
|
||||||
wxCHECK( partBuf, false );
|
wxCHECK( partBuf, false );
|
||||||
|
|
||||||
partBuf->GetScreen()->ClrModify();
|
|
||||||
partBuf->SetPart( new LIB_PART( *partBuf->GetOriginal() ) );
|
partBuf->SetPart( new LIB_PART( *partBuf->GetOriginal() ) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -648,9 +680,8 @@ bool LIB_MANAGER::LIB_BUFFER::SaveBuffer( LIB_MANAGER::PART_BUFFER::PTR aPartBuf
|
||||||
wxCHECK( aPartBuf, false );
|
wxCHECK( aPartBuf, false );
|
||||||
LIB_PART* part = aPartBuf->GetPart();
|
LIB_PART* part = aPartBuf->GetPart();
|
||||||
wxCHECK( part, false );
|
wxCHECK( part, false );
|
||||||
wxCHECK( aLibTable->SaveSymbol( m_libName, new LIB_PART( *part ) ) != SYMBOL_LIB_TABLE::SAVE_OK, false );
|
wxCHECK( aLibTable->SaveSymbol( m_libName, new LIB_PART( *part ) ) == SYMBOL_LIB_TABLE::SAVE_OK, false );
|
||||||
|
|
||||||
aPartBuf->GetScreen()->ClrModify();
|
|
||||||
aPartBuf->SetOriginal( new LIB_PART( *part ) );
|
aPartBuf->SetOriginal( new LIB_PART( *part ) );
|
||||||
++m_hash;
|
++m_hash;
|
||||||
return true;
|
return true;
|
||||||
|
@ -670,7 +701,6 @@ bool LIB_MANAGER::LIB_BUFFER::SaveBuffer( LIB_MANAGER::PART_BUFFER::PTR aPartBuf
|
||||||
|
|
||||||
// TODO there is no way to check if symbol has been successfully saved
|
// TODO there is no way to check if symbol has been successfully saved
|
||||||
aPlugin->SaveSymbol( m_libName, new LIB_PART( *part ), aBuffer ? &properties : nullptr );
|
aPlugin->SaveSymbol( m_libName, new LIB_PART( *part ), aBuffer ? &properties : nullptr );
|
||||||
aPartBuf->GetScreen()->ClrModify();
|
|
||||||
aPartBuf->SetOriginal( new LIB_PART( *part ) );
|
aPartBuf->SetOriginal( new LIB_PART( *part ) );
|
||||||
++m_hash;
|
++m_hash;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -144,6 +144,16 @@ public:
|
||||||
*/
|
*/
|
||||||
bool IsPartModified( const wxString& aAlias, const wxString& aLibrary ) const;
|
bool IsPartModified( const wxString& aAlias, const wxString& aLibrary ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the modified flag for all parts in a library.
|
||||||
|
*/
|
||||||
|
bool ClearLibraryModified( const wxString& aLibrary ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the modified flag for a part.
|
||||||
|
*/
|
||||||
|
bool ClearPartModified( const wxString& aAlias, const wxString& aLibrary ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the library is stored in a read-only file.
|
* Returns true if the library is stored in a read-only file.
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
|
|
|
@ -352,8 +352,11 @@ void LIB_EDIT_FRAME::OnEditPart( wxCommandEvent& aEvent )
|
||||||
void LIB_EDIT_FRAME::OnSavePart( wxCommandEvent& aEvent )
|
void LIB_EDIT_FRAME::OnSavePart( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
LIB_ID libId = getTargetLibId();
|
LIB_ID libId = getTargetLibId();
|
||||||
m_libMgr->FlushPart( libId.GetLibItemName(), libId.GetLibNickname() );
|
|
||||||
m_treePane->Refresh();;
|
if( m_libMgr->FlushPart( libId.GetLibItemName(), libId.GetLibNickname() ) )
|
||||||
|
m_libMgr->ClearPartModified( libId.GetLibItemName(), libId.GetLibNickname() );
|
||||||
|
|
||||||
|
m_treePane->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -459,7 +462,8 @@ void LIB_EDIT_FRAME::OnRevertPart( wxCommandEvent& aEvent )
|
||||||
if( currentPart )
|
if( currentPart )
|
||||||
emptyScreen();
|
emptyScreen();
|
||||||
|
|
||||||
m_libMgr->RevertPart( libId.GetLibItemName(), libId.GetLibNickname() );
|
if( m_libMgr->RevertPart( libId.GetLibItemName(), libId.GetLibNickname() ) )
|
||||||
|
m_libMgr->ClearPartModified( libId.GetLibItemName(), libId.GetLibNickname() );
|
||||||
|
|
||||||
if( currentPart && m_libMgr->PartExists( libId.GetLibItemName(), libId.GetLibNickname() ) )
|
if( currentPart && m_libMgr->PartExists( libId.GetLibItemName(), libId.GetLibNickname() ) )
|
||||||
loadPart( libId.GetLibItemName(), libId.GetLibNickname(), unit );
|
loadPart( libId.GetLibItemName(), libId.GetLibNickname(), unit );
|
||||||
|
@ -559,6 +563,9 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !aNewFile )
|
||||||
|
m_libMgr->ClearLibraryModified( aLibrary );
|
||||||
|
|
||||||
msg.Printf( _( "Symbol library file '%s' saved" ), fn.GetFullPath() );
|
msg.Printf( _( "Symbol library file '%s' saved" ), fn.GetFullPath() );
|
||||||
wxString msg1;
|
wxString msg1;
|
||||||
msg1.Printf( _( "Symbol library documentation file '%s' saved" ), docFileName.GetFullPath() );
|
msg1.Printf( _( "Symbol library documentation file '%s' saved" ), docFileName.GetFullPath() );
|
||||||
|
|
Loading…
Reference in New Issue