From 3de00eef5f7fbdfbe01823616daf9ec665018141 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 17 Jul 2019 21:45:43 +0100 Subject: [PATCH] Cleanup. --- eeschema/cross-probing.cpp | 6 +- .../dialogs/dialog_fields_editor_global.cpp | 61 +++++++++---------- eeschema/tools/sch_editor_control.h | 4 -- pcbnew/tools/edit_tool.cpp | 5 +- 4 files changed, 33 insertions(+), 43 deletions(-) diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index cf75327854..47e3e729aa 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -29,8 +29,6 @@ #include #include #include -#include -#include #include #include #include @@ -316,7 +314,7 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT std::string packet = FormatProbeItem( aObjectToSync, aLibItem ); - if( packet.size() ) + if( !packet.empty() ) { if( Kiface().IsSingle() ) SendCommand( MSG_TO_PCB, packet.c_str() ); @@ -337,7 +335,7 @@ void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName ) std::string packet = StrPrintf( "$NET: \"%s\"", TO_UTF8( aNetName ) ); - if( packet.size() ) + if( !packet.empty() ) { if( Kiface().IsSingle() ) SendCommand( MSG_TO_PCB, packet.c_str() ); diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp index a747f8cc21..0dd29b1060 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp @@ -32,13 +32,10 @@ #include #include #include -#include #include -#include #include #include #include -#include #include #include #include @@ -291,25 +288,25 @@ public: { // Remove duplicates (other units of multi-unit parts) std::sort( references.begin(), references.end(), - []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool - { - wxString l_ref( l.GetRef() << l.GetRefNumber() ); - wxString r_ref( r.GetRef() << r.GetRefNumber() ); - return UTIL::RefDesStringCompare( l_ref, r_ref ) < 0; - } ); + []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool + { + wxString l_ref( l.GetRef() << l.GetRefNumber() ); + wxString r_ref( r.GetRef() << r.GetRefNumber() ); + return UTIL::RefDesStringCompare( l_ref, r_ref ) < 0; + } ); auto logicalEnd = std::unique( references.begin(), references.end(), - []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool - { - // If unannotated then we can't tell what units belong together - // so we have to leave them all - if( l.GetRefNumber() == wxT( "?" ) ) - return false; + []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool + { + // If unannotated then we can't tell what units belong together + // so we have to leave them all + if( l.GetRefNumber() == wxT( "?" ) ) + return false; - wxString l_ref( l.GetRef() << l.GetRefNumber() ); - wxString r_ref( r.GetRef() << r.GetRefNumber() ); - return l_ref == r_ref; - } ); + wxString l_ref( l.GetRef() << l.GetRefNumber() ); + wxString r_ref( r.GetRef() << r.GetRefNumber() ); + return l_ref == r_ref; + } ); references.erase( logicalEnd, references.end() ); } @@ -331,13 +328,11 @@ public: if( aCol == REFERENCE || aCol == QUANTITY_COLUMN ) return; // Can't modify references or quantity - wxString value = aValue; - DATA_MODEL_ROW& rowGroup = m_rows[ aRow ]; wxString fieldName = m_fieldNames[ aCol ]; for( const auto& ref : rowGroup.m_Refs ) - m_dataStore[ ref.GetComp()->GetTimeStamp() ][ fieldName ] = value; + m_dataStore[ ref.GetComp()->GetTimeStamp() ][ fieldName ] = aValue; m_edited = true; } @@ -386,10 +381,10 @@ public: CollapseForSort(); std::sort( m_rows.begin(), m_rows.end(), - [ this ]( const DATA_MODEL_ROW& lhs, const DATA_MODEL_ROW& rhs ) -> bool - { - return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending ); - } ); + [ this ]( const DATA_MODEL_ROW& lhs, const DATA_MODEL_ROW& rhs ) -> bool + { + return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending ); + } ); ExpandAfterSort(); } @@ -485,7 +480,7 @@ public: } if( !matchFound ) - m_rows.push_back( DATA_MODEL_ROW( ref, GROUP_SINGLETON ) ); + m_rows.emplace_back( DATA_MODEL_ROW( ref, GROUP_SINGLETON ) ); } if ( GetView() ) @@ -518,7 +513,7 @@ public: } if( !matchFound ) - children.push_back( DATA_MODEL_ROW( ref, CHILD_ITEM ) ); + children.emplace_back( DATA_MODEL_ROW( ref, CHILD_ITEM ) ); } if( children.size() < 2 ) @@ -843,9 +838,9 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::AddField( const wxString& aName, m_config->Read( "SymbolFieldEditor/Show/" + aName, &defaultShow ); m_config->Read( "SymbolFieldEditor/GroupBy/" + aName, &defaultSortBy ); - fieldsCtrlRow.push_back( wxVariant( aName ) ); - fieldsCtrlRow.push_back( wxVariant( defaultShow ) ); - fieldsCtrlRow.push_back( wxVariant( defaultSortBy ) ); + fieldsCtrlRow.emplace_back( wxVariant( aName ) ); + fieldsCtrlRow.emplace_back( wxVariant( defaultShow ) ); + fieldsCtrlRow.emplace_back( wxVariant( defaultSortBy ) ); m_fieldsCtrl->AppendItem( fieldsCtrlRow ); } @@ -875,11 +870,11 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::LoadFieldNames() AddField( _( "Footprint" ), true, true ); AddField( _( "Datasheet" ), true, false ); - for( auto fieldName : userFieldNames ) + for( const wxString& fieldName : userFieldNames ) AddField( fieldName, true, false ); // Add any templateFieldNames which aren't already present in the userFieldNames - for( auto templateFieldName : m_parent->GetTemplateFieldNames() ) + for( const TEMPLATE_FIELDNAME& templateFieldName : m_parent->GetTemplateFieldNames() ) if( userFieldNames.count( templateFieldName.m_Name ) == 0 ) AddField( templateFieldName.m_Name, false, false ); } diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index 37b966a1bc..eb8ae5a40f 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -65,10 +65,6 @@ public: int UpdateFind( const TOOL_EVENT& aEvent ); - int ToggleLockSelected( const TOOL_EVENT& aEvent ); - int LockSelected( const TOOL_EVENT& aEvent ); - int UnlockSelected( const TOOL_EVENT& aEvent ); - ///> Notifies pcbnew about the selected item. int CrossProbeToPcb( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 675b91d3cf..053d91e150 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -515,7 +515,8 @@ bool EDIT_TOOL::changeTrackWidthOnClick( const PCBNEW_SELECTION& selection ) if( auto via = dyn_cast( item ) ) { - int new_width, new_drill; + int new_width; + int new_drill; if( via->GetViaType() == VIA_MICROVIA ) { @@ -881,7 +882,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) else m_commit->Push( _( "Delete" ) ); - if( !m_lockedSelected && lockedItems.size() > 0 ) + if( !m_lockedSelected && !lockedItems.empty() ) { ///> Popup nag for deleting locked items STATUS_TEXT_POPUP statusPopup( frame() );