Rename modification flag routines

Differentiates better between the EDA_ITEM IsModified(), referring to
items themselves changing and the EDA_SCREEN IsContentModified(),
referring to whether we have made any unsaved changes.
This commit is contained in:
Seth Hillbrand 2021-05-28 12:07:04 -07:00
parent 11438eb0ec
commit 752ae4d519
30 changed files with 64 additions and 65 deletions

View File

@ -210,7 +210,7 @@ bool DIALOG_PAGES_SETTINGS::TransferDataFromWindow()
if( SavePageSettings() )
{
m_screen->SetModify();
m_screen->SetContentModified();
if( LocalPrjConfigChanged() )
m_parent->SaveProjectSettings();

View File

@ -750,7 +750,7 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow()
cmp.m_Component->SetLibId( id );
cmp.m_Component->SetLibSymbol( symbol->Flatten().release() );
cmp.m_Screen->Append( cmp.m_Component );
cmp.m_Screen->SetModify();
cmp.m_Screen->SetContentModified();
if ( m_checkBoxUpdateFields->IsChecked() )
{

View File

@ -269,7 +269,7 @@ void DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable( REPORTER& aReporter )
symbol->GetLibId().GetLibItemName().wx_str(),
symbol->GetLibId().GetLibNickname().wx_str() );
aReporter.Report( msg, RPT_SEVERITY_ACTION );
screen->SetModify();
screen->SetContentModified();
}
}
}

View File

@ -188,7 +188,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName )
UpdateFileHistory( schematicFileName.GetFullPath() );
}
screen->ClrModify();
screen->SetContentModified( false );
UpdateTitle();
msg.Printf( _( "File \"%s\" saved." ), screen->GetFileName() );
@ -379,7 +379,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
if( is_new )
{
// mark new, unsaved file as modified.
GetScreen()->SetModify();
GetScreen()->SetContentModified();
GetScreen()->SetFileName( fullFileName );
}
else
@ -1050,7 +1050,7 @@ bool SCH_EDIT_FRAME::doAutoSave()
for( size_t i = 0; i < screens.GetCount(); i++ )
{
// Only create auto save files for the schematics that have been modified.
if( !screens.GetScreen( i )->IsModify() )
if( !screens.GetScreen( i )->IsContentModified() )
continue;
tmpFileName = fn = screens.GetScreen( i )->GetFileName();
@ -1061,7 +1061,7 @@ bool SCH_EDIT_FRAME::doAutoSave()
screens.GetScreen( i )->SetFileName( fn.GetFullPath() );
if( SaveEEFile( screens.GetSheet( i ), false ) )
screens.GetScreen( i )->SetModify();
screens.GetScreen( i )->SetContentModified();
else
autoSaveOk = false;
@ -1145,7 +1145,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
Schematic().Root().SetFileName( newfilename.GetFullPath() );
GetScreen()->SetFileName( newfilename.GetFullPath() );
GetScreen()->SetModify();
GetScreen()->SetContentModified();
// Only fix junctions for CADSTAR importer for now as it may cause issues with
// other importers
@ -1194,7 +1194,7 @@ bool SCH_EDIT_FRAME::AskToSaveChanges()
// Save any currently open and modified project files.
for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
{
if( screen->IsModify() )
if( screen->IsContentModified() )
{
if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "
"Save changes?" ),

View File

@ -782,7 +782,7 @@ void SCH_EDIT_FRAME::OnModify()
if( !GetScreen() )
return;
GetScreen()->SetModify();
GetScreen()->SetContentModified();
if( ADVANCED_CFG::GetCfg().m_RealTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
RecalculateConnections( NO_CLEANUP );
@ -1217,7 +1217,7 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_SCREEN* aScreen, SCH_ITEM*
aItem->ClearFlags( IS_NEW );
aScreen->SetModify();
aScreen->SetContentModified();
UpdateItem( aItem );
if( !aItem->IsMoving() && aItem->IsConnectable() )

View File

@ -1912,7 +1912,7 @@ void SCH_SEXPR_PARSER::parseSchSheetInstances( SCH_SHEET* aRootSheet, SCH_SCREEN
// Set the file as modified so the user can be warned.
if( numReplacements > 0 )
aScreen->SetModify();
aScreen->SetContentModified();
NeedRIGHT();
break;

View File

@ -1563,7 +1563,7 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader )
// Set the file as modified so the user can be warned.
if( m_rootSheet->GetScreen() )
m_rootSheet->GetScreen()->SetModify();
m_rootSheet->GetScreen()->SetContentModified();
}
symbol->SetUnit( unit );
@ -1577,7 +1577,7 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader )
// Set the file as modified so the user can be warned.
if( m_rootSheet->GetScreen() )
m_rootSheet->GetScreen()->SetModify();
m_rootSheet->GetScreen()->SetContentModified();
}
symbol->SetConvert( convert );

View File

@ -296,7 +296,7 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
// Markers are not saved in the file, no need to flag as modified.
// TODO: Maybe we should have a listing somewhere of items that aren't saved?
if( aItem->Type() != SCH_MARKER_T )
SetModify();
SetContentModified();
Remove( aItem );

View File

@ -566,7 +566,7 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet, bool aCheckIntegrity )
for( SCH_SHEET* sheet : badSheets )
{
m_currentSheetPath.LastScreen()->Remove( sheet );
m_currentSheetPath.LastScreen()->SetModify();
m_currentSheetPath.LastScreen()->SetContentModified();
}
}
@ -622,7 +622,7 @@ bool SCH_SHEET_LIST::IsModified() const
{
for( const SCH_SHEET_PATH& sheet : *this )
{
if( sheet.LastScreen() && sheet.LastScreen()->IsModify() )
if( sheet.LastScreen() && sheet.LastScreen()->IsContentModified() )
return true;
}
@ -635,7 +635,7 @@ void SCH_SHEET_LIST::ClearModifyStatus()
for( const SCH_SHEET_PATH& sheet : *this )
{
if( sheet.LastScreen() )
sheet.LastScreen()->ClrModify();
sheet.LastScreen()->SetContentModified( false );
}
}

View File

@ -95,7 +95,7 @@ bool SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds( SCH_SHEET* aSheet )
void SCH_EDIT_FRAME::InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename )
{
aSheet->SetScreen( new SCH_SCREEN( &Schematic() ) );
aSheet->GetScreen()->SetModify();
aSheet->GetScreen()->SetContentModified();
aSheet->GetScreen()->SetFileName( aNewFilename );
}

View File

@ -781,7 +781,7 @@ SYMBOL_LIBRARY_MANAGER& SYMBOL_EDIT_FRAME::GetLibManager()
void SYMBOL_EDIT_FRAME::OnModify()
{
GetScreen()->SetModify();
GetScreen()->SetContentModified();
storeCurrentPart();
m_treePane->GetLibTree()->RefreshLibTree();
@ -1043,7 +1043,7 @@ bool SYMBOL_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxStr
void SYMBOL_EDIT_FRAME::storeCurrentPart()
{
if( m_my_part && !GetCurLib().IsEmpty() && GetScreen()->IsModify() )
if( m_my_part && !GetCurLib().IsEmpty() && GetScreen()->IsContentModified() )
m_libMgr->UpdatePart( m_my_part, GetCurLib() ); // UpdatePart() makes a copy
}
@ -1235,7 +1235,7 @@ bool SYMBOL_EDIT_FRAME::IsContentModified() const
wxCHECK( m_libMgr, false );
// Test if the currently edited part is modified
if( GetScreen() && GetScreen()->IsModify() && GetCurPart() )
if( GetScreen() && GetScreen()->IsContentModified() && GetCurPart() )
return true;
// Test if any library has been modified

View File

@ -140,7 +140,7 @@ void SYMBOL_EDIT_FRAME::updateTitle()
if( IsSymbolFromSchematic() )
{
title = wxString::Format( _( "%s%s [from schematic]" ) + wxT( " \u2014 " ),
GetScreen() && GetScreen()->IsModify() ? "*" : "",
GetScreen() && GetScreen()->IsContentModified() ? "*" : "",
m_reference );
}
else
@ -150,7 +150,7 @@ void SYMBOL_EDIT_FRAME::updateTitle()
bool readOnly = m_libMgr && m_libMgr->IsLibraryReadOnly( GetCurLib() );
title = wxString::Format( wxT( "%s%s %s\u2014 " ),
GetScreen() && GetScreen()->IsModify() ? "*" : "",
GetScreen() && GetScreen()->IsContentModified() ? "*" : "",
GetCurPart()->GetLibId().Format().c_str(),
readOnly ? _( "[Read Only Library]" ) + wxT( " " ) : "" );
}
@ -253,7 +253,7 @@ bool SYMBOL_EDIT_FRAME::LoadSymbol( const LIB_ID& aLibId, int aUnit, int aConver
return true;
}
if( GetScreen()->IsModify() && GetCurPart() )
if( GetScreen()->IsContentModified() && GetCurPart() )
{
if( !HandleUnsavedChanges( this, _( "The current symbol has been modified. "
"Save changes?" ),
@ -522,7 +522,7 @@ void SYMBOL_EDIT_FRAME::Save()
else
{
schframe->SaveSymbolToSchematic( *m_my_part );
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
}
}
else

View File

@ -298,7 +298,7 @@ bool SYMBOL_LIBRARY_MANAGER::ClearLibraryModified( const wxString& aLibrary ) co
SCH_SCREEN* screen = partBuf->GetScreen();
if( screen )
screen->ClrModify();
screen->SetContentModified( false );
}
return true;
@ -316,7 +316,7 @@ bool SYMBOL_LIBRARY_MANAGER::ClearPartModified( const wxString& aAlias,
auto partBuf = libI->second.GetBuffer( aAlias );
wxCHECK( partBuf, false );
partBuf->GetScreen()->ClrModify();
partBuf->GetScreen()->SetContentModified( false );
return true;
}
@ -456,7 +456,7 @@ bool SYMBOL_LIBRARY_MANAGER::UpdatePart( LIB_PART* aPart, const wxString& aLibra
wxCHECK( bufferedPart, false );
*bufferedPart = *aPart;
partBuf->GetScreen()->SetModify();
partBuf->GetScreen()->SetContentModified();
}
else // New symbol
{
@ -466,7 +466,7 @@ bool SYMBOL_LIBRARY_MANAGER::UpdatePart( LIB_PART* aPart, const wxString& aLibra
SCH_SCREEN* screen = new SCH_SCREEN;
libBuf.CreateBuffer( partCopy, screen );
screen->SetModify();
screen->SetContentModified();
}
return true;
@ -863,7 +863,7 @@ void SYMBOL_LIBRARY_MANAGER::PART_BUFFER::SetOriginal( LIB_PART* aPart )
bool SYMBOL_LIBRARY_MANAGER::PART_BUFFER::IsModified() const
{
return m_screen && m_screen->IsModify();
return m_screen && m_screen->IsContentModified();
}

View File

@ -42,7 +42,7 @@ bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )
if( GetGerberLayout() == NULL )
return false;
if( query && GetScreen()->IsModify() )
if( query && GetScreen()->IsContentModified() )
{
if( !IsOK( this, _( "Current data will be lost?" ) ) )
return false;

View File

@ -56,9 +56,8 @@ public:
void InitDataPoints( const wxSize& aPageSizeInternalUnits );
void SetModify() { m_flagModified = true; }
void ClrModify() { m_flagModified = false; }
bool IsModify() const { return m_flagModified; }
void SetContentModified( bool aModified = true ) { m_flagModified = aModified; }
bool IsContentModified() const { return m_flagModified; }
/**
* Return the class name.

View File

@ -133,7 +133,7 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
}
else
{
GetScreen()->SetModify();
GetScreen()->SetContentModified();
HardRedraw();
msg.Printf( _( "File \"%s\" inserted" ), filename );
SetStatusText( msg );
@ -237,7 +237,7 @@ bool PL_EDITOR_FRAME::LoadPageLayoutDescrFile( const wxString& aFullFileName )
SetCurrentFileName( aFullFileName );
UpdateFileHistory( aFullFileName );
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
wxFileName fn = aFullFileName;
m_infoBar->Dismiss();
@ -291,7 +291,7 @@ bool PL_EDITOR_FRAME::SavePageLayoutDescrFile( const wxString& aFullFileName )
if( !wxRenameFile( tempFile.GetFullPath(), aFullFileName ) )
return false;
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
return true;
}

View File

@ -330,7 +330,7 @@ bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, i
bool PL_EDITOR_FRAME::IsContentModified() const
{
return GetScreen() && GetScreen()->IsModify();
return GetScreen() && GetScreen()->IsContentModified();
}
@ -872,7 +872,7 @@ DS_DATA_ITEM* PL_EDITOR_FRAME::AddPageLayoutItem( int aType )
void PL_EDITOR_FRAME::OnNewPageLayout()
{
ClearUndoRedoList();
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
GetCanvas()->DisplayWorksheet();
m_propertiesPagelayout->CopyPrmsFromItemToPanel( nullptr );

View File

@ -255,7 +255,7 @@ public:
*/
void OnModify()
{
GetScreen()->SetModify();
GetScreen()->SetContentModified();
}
/**

View File

@ -199,7 +199,7 @@ void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
{
wxFileName brdFile = GetBoard()->GetFileName();
if( GetScreen()->IsModify() || brdFile.GetFullPath().empty() )
if( GetScreen()->IsContentModified() || brdFile.GetFullPath().empty() )
{
if( !doAutoSave() )
{

View File

@ -350,7 +350,7 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
if( !IsOK( this, msg ) )
return false;
GetScreen()->ClrModify(); // do not prompt the user for changes
GetScreen()->SetContentModified( false ); // do not prompt the user for changes
if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
{
@ -772,7 +772,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
if( loadedBoard->IsModified() )
OnModify();
else
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
if( ( pluginType == IO_MGR::LEGACY &&
loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION ) ||
@ -1064,7 +1064,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
if( m_infoBar->IsShown() && m_infoBar->HasCloseButton() )
m_infoBar->Dismiss();
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
UpdateTitle();
return true;
}
@ -1178,7 +1178,7 @@ bool PCB_EDIT_FRAME::doAutoSave()
if( SavePcbFile( autoSaveFileName.GetFullPath(), false, false ) )
{
GetScreen()->SetModify();
GetScreen()->SetContentModified();
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
UpdateTitle();
m_autoSaveState = false;

View File

@ -318,7 +318,7 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
bool FOOTPRINT_EDIT_FRAME::IsContentModified() const
{
return GetScreen() && GetScreen()->IsModify() && GetBoard() && GetBoard()->GetFirstFootprint();
return GetScreen() && GetScreen()->IsContentModified() && GetBoard() && GetBoard()->GetFirstFootprint();
}
@ -408,7 +408,7 @@ void FOOTPRINT_EDIT_FRAME::ClearModify()
if( GetBoard()->GetFirstFootprint() )
m_footprintNameWhenLoaded = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
}

View File

@ -86,7 +86,7 @@ void FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary( LIB_ID aFPID )
Update3DView( true, true );
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
UpdateView();
GetCanvas()->Refresh();
@ -252,7 +252,7 @@ bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileS
if( GetBoard()->GetFirstFootprint() )
GetBoard()->GetFirstFootprint()->ClearFlags();
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
Zoom_Automatique( false );
GetCanvas()->Refresh();

View File

@ -1052,7 +1052,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( FOOTPRINT* aFootprint )
bool FOOTPRINT_EDIT_FRAME::RevertFootprint()
{
if( GetScreen()->IsModify() && m_revertModule )
if( GetScreen()->IsContentModified() && m_revertModule )
{
wxString msg = wxString::Format( _( "Revert \"%s\" to last version saved?" ),
GetLoadedFPID().GetLibItemName().wx_str() );
@ -1067,7 +1067,7 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint()
Update3DView( true, true );
ClearUndoRedoList();
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
UpdateView();
GetCanvas()->Refresh();

View File

@ -180,7 +180,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
node->m_Name = m_frame->GetLoadedFPID().GetLibItemName();
// mark modified part with an asterisk
if( m_frame->GetScreen()->IsModify() )
if( m_frame->GetScreen()->IsContentModified() )
aVariant = node->m_Name + " *";
else
aVariant = node->m_Name;
@ -253,7 +253,7 @@ bool FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsign
#endif
// mark modified libs with bold font
if( m_frame->GetScreen()->IsModify() && !m_frame->IsCurrentFPFromBoard() )
if( m_frame->GetScreen()->IsContentModified() && !m_frame->IsCurrentFPFromBoard() )
aAttr.SetBold( true );
}
break;
@ -271,7 +271,7 @@ bool FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsign
#endif
// mark modified part with bold font
if( m_frame->GetScreen()->IsModify() && !m_frame->IsCurrentFPFromBoard() )
if( m_frame->GetScreen()->IsContentModified() && !m_frame->IsCurrentFPFromBoard() )
aAttr.SetBold( true );
}
break;

View File

@ -58,7 +58,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal )
// Clear undo and redo lists because we want a full deletion
ClearUndoRedoList();
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
if( !aFinal )
{
@ -120,7 +120,7 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
// Clear undo and redo lists because we want a full deletion
ClearUndoRedoList();
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
BOARD* board = new BOARD;

View File

@ -158,7 +158,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( FOOTPRINT* aFootprint )
m_adapter->SetPreselectNode( newFootprint->GetFPID(), 0 );
ClearUndoRedoList();
GetScreen()->ClrModify();
GetScreen()->SetContentModified( false );
// Update the save items if needed.
if( !is_last_fp_from_brd )

View File

@ -689,7 +689,7 @@ void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
void PCB_BASE_FRAME::OnModify()
{
GetScreen()->SetModify();
GetScreen()->SetContentModified();
GetBoard()->IncrementTimeStamp();

View File

@ -449,14 +449,14 @@ void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
bool PCB_EDIT_FRAME::IsContentModified() const
{
return GetScreen() && GetScreen()->IsModify();
return GetScreen() && GetScreen()->IsContentModified();
}
bool PCB_EDIT_FRAME::isAutoSaveRequired() const
{
if( GetScreen() )
return GetScreen()->IsModify();
return GetScreen()->IsContentModified();
return false;
}

View File

@ -87,7 +87,7 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
wxString errorText;
BASE_SCREEN* screen = GetScreen();
bool wasModified = screen->IsModify();
bool wasModified = screen->IsContentModified();
db.SetPCB( SPECCTRA_DB::MakePCB() );
@ -122,7 +122,7 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
// modified flag, yet their actions cancel each other out, so it should
// be ok to clear the modify flag.
if( !wasModified )
screen->ClrModify();
screen->SetContentModified( false );
if( ok )
{

View File

@ -158,7 +158,7 @@ int FOOTPRINT_EDITOR_CONTROL::NewFootprint( const TOOL_EVENT& aEvent )
newFootprint->ClearFlags();
m_frame->Zoom_Automatique( false );
m_frame->GetScreen()->SetModify();
m_frame->GetScreen()->SetContentModified();
// If selected from the library tree then go ahead and save it there
if( !selected.GetLibNickname().empty() )
@ -218,7 +218,7 @@ int FOOTPRINT_EDITOR_CONTROL::CreateFootprint( const TOOL_EVENT& aEvent )
newFootprint->ClearFlags();
m_frame->Zoom_Automatique( false );
m_frame->GetScreen()->SetModify();
m_frame->GetScreen()->SetContentModified();
// If selected from the library tree then go ahead and save it there
if( !selected.GetLibNickname().empty() )