Eeschema: move modification state code from SCH_SHEET_LIST to SCH_SHEET.

This commit is contained in:
Wayne Stambaugh 2015-12-16 19:27:53 -05:00
parent 2add6ca736
commit 1bd860d1aa
5 changed files with 53 additions and 39 deletions

View File

@ -1233,6 +1233,42 @@ void SCH_SHEET::ClearAnnotation( bool aIncludeSubSheets )
}
bool SCH_SHEET::IsModified() const
{
if( m_screen->IsModify() )
return true;
bool retv = false;
SCH_ITEM* item = m_screen->GetDrawItems();
while( item && !retv )
{
if( item->Type() == SCH_SHEET_T )
retv = static_cast<SCH_SHEET*>( item )->IsModified();
item = item->Next();
}
return retv;
}
void SCH_SHEET::ClearModifyStatus()
{
m_screen->ClrModify();
SCH_ITEM* item = m_screen->GetDrawItems();
while( item )
{
if( item->Type() == SCH_SHEET_T )
static_cast<SCH_SHEET*>( item )->m_screen->ClrModify();
item = item->Next();
}
}
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
{
wxLogDebug( wxT( "Sheet assignment operator." ) );

View File

@ -635,6 +635,20 @@ public:
void ClearAnnotation( bool aIncludeSubSheets = false );
/**
* Function IsModified
* checks the sheet and any of it's sub-sheets (hierarchy) for any modifications.
* @return true if the hierarchy is modified otherwise false.
*/
bool IsModified() const;
/**
* Function ClearModifyStatus
*
* clears the modification flag for everything in the sheet and all sub-sheets.
*/
void ClearModifyStatus();
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // override
#endif

View File

@ -684,18 +684,6 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
}
bool SCH_SHEET_LIST::IsModified()
{
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() )
{
if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
return true;
}
return false;
}
bool SCH_SHEET_LIST::IsAutoSaveRequired()
{
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() )
@ -708,16 +696,6 @@ bool SCH_SHEET_LIST::IsAutoSaveRequired()
}
void SCH_SHEET_LIST::ClearModifyStatus()
{
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() )
{
if( sheet->LastScreen() )
sheet->LastScreen()->ClrModify();
}
}
void SCH_SHEET_LIST::AnnotatePowerSymbols( PART_LIBS* aLibs )
{
int ref = 1;

View File

@ -436,13 +436,6 @@ public:
*/
SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true );
/**
* Function IsModified
* checks the entire hierarchy for any modifications.
* @returns True if the hierarchy is modified otherwise false.
*/
bool IsModified();
/**
* Function IsAutoSaveRequired
* checks the entire hierarchy for any modifications that require auto save.
@ -450,8 +443,6 @@ public:
*/
bool IsAutoSaveRequired();
void ClearModifyStatus();
/**
* Function AnnotatePowerSymbols
* clear and annotates the entire hierarchy of the sheet path list.

View File

@ -613,9 +613,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
return;
}
SCH_SHEET_LIST sheetList;
if( sheetList.IsModified() )
if( g_RootSheet->IsModified() )
{
wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
wxString msg = wxString::Format( _(
@ -666,7 +664,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
wxRemoveFile( fn.GetFullPath() );
}
sheetList.ClearModifyStatus();
g_RootSheet->ClearModifyStatus();
wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
@ -786,16 +784,13 @@ void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent )
void SCH_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
{
SCH_SHEET_LIST sheetList;
aEvent.Enable( sheetList.IsModified() );
aEvent.Enable( g_RootSheet->IsModified() );
}
void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( GetScreen()->IsModify() );
}