Use the central SetIfPresent helper

This commit is contained in:
Marek Roszko 2020-10-07 22:13:46 -04:00
parent 0b43dc6e16
commit 93376fa80e
1 changed files with 11 additions and 18 deletions

View File

@ -241,24 +241,17 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
if( aVal.empty() || !aVal.is_object() ) if( aVal.empty() || !aVal.is_object() )
return; return;
auto setIfPresent = SetIfPresent( aVal, "lockedItems", m_SelectionFilter.lockedItems );
[&aVal]( const std::string& aKey, bool& aTarget ) SetIfPresent( aVal, "footprints", m_SelectionFilter.footprints );
{ SetIfPresent( aVal, "text", m_SelectionFilter.text );
if( aVal.contains( aKey ) && aVal.at( aKey ).is_boolean() ) SetIfPresent( aVal, "tracks", m_SelectionFilter.tracks );
aTarget = aVal.at( aKey ).get<bool>(); SetIfPresent( aVal, "vias", m_SelectionFilter.vias );
}; SetIfPresent( aVal, "pads", m_SelectionFilter.pads );
SetIfPresent( aVal, "graphics", m_SelectionFilter.graphics );
setIfPresent( "lockedItems", m_SelectionFilter.lockedItems ); SetIfPresent( aVal, "zones", m_SelectionFilter.zones );
setIfPresent( "footprints", m_SelectionFilter.footprints ); SetIfPresent( aVal, "keepouts", m_SelectionFilter.keepouts );
setIfPresent( "text", m_SelectionFilter.text ); SetIfPresent( aVal, "dimensions", m_SelectionFilter.dimensions );
setIfPresent( "tracks", m_SelectionFilter.tracks ); SetIfPresent( aVal, "otherItems", m_SelectionFilter.otherItems );
setIfPresent( "vias", m_SelectionFilter.vias );
setIfPresent( "pads", m_SelectionFilter.pads );
setIfPresent( "graphics", m_SelectionFilter.graphics );
setIfPresent( "zones", m_SelectionFilter.zones );
setIfPresent( "keepouts", m_SelectionFilter.keepouts );
setIfPresent( "dimensions", m_SelectionFilter.dimensions );
setIfPresent( "otherItems", m_SelectionFilter.otherItems );
}, },
{ {
{ "lockedItems", true }, { "lockedItems", true },